본문 바로가기

Database/Oracle

57 - [Oracle 19C] Creating dynamic listener example

 

새로운 동적인 리스너를 추가하는 방법

 

1. tnsnames.ora 수정 - LISTENER2 추가

2. listener.ora 수정 - LISTENER2 추가

3. update local_listener

 

 

[oracle@test ~]$ cd /u01/app/oracle/product/19/db_1/network/admin/


[oracle@test admin]$ ll
합계 28
-rw-r----- 1 oracle oinstall  452 11월 29 22:24 listener.ora
-rw-r----- 1 oracle oinstall  328 11월 29 22:24 listener23112910PM2442.bak
drwxr-xr-x 2 oracle oinstall   64  4월 17  2019 samples
-rw-r--r-- 1 oracle oinstall 1536  2월 14  2018 shrept.lst
-rw-r----- 1 oracle oinstall  194 11월 29 22:24 sqlnet.ora
-rw-r----- 1 oracle oinstall  187 11월 29 22:24 sqlnet23112910PM2442.bak
-rw-r----- 1 oracle oinstall 1242 11월 30 11:48 tnsnames.ora
-rw-r----- 1 oracle oinstall  762 11월 29 22:24 tnsnames23112910PM2442.bak


[oracle@test admin]$ cat tnsnames.ora
# tnsnames.ora Network Configuration File: /u01/app/oracle/product/19/db_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.

LISTENER2 =
  (ADDRESS = (PROTOCOL = TCP)(HOST = test.com)(PORT = 1528))

LISTENER_ORCL =
  (ADDRESS = (PROTOCOL = TCP)(HOST = test.com)(PORT = 1529))

LISTENER_HONG =
  (ADDRESS_LIST =
    #(ADDRESS = (PROTOCOL = TCP)(HOST = test.com)(PORT = 1529))
    (ADDRESS = (PROTOCOL = TCP)(HOST = test.com)(PORT = 1530))
  )

ORCLPDB =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = test.com)(PORT = 1529))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orclpdb.com)
    )
  )

PDB1 =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = test.com)(PORT = 1529))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = pdb1.com)
    )
  )

ORCL =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = test.com)(PORT = 1529))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orcl.com)
    )
  )

HONG =
  (DESCRIPTION =
    #(ADDRESS = (PROTOCOL = TCP)(HOST = test.com)(PORT = 1529))
    (ADDRESS = (PROTOCOL = TCP)(HOST = test.com)(PORT = 1530))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = hong.com)
    )
  )

[oracle@test admin]$

 

 

 

[oracle@test admin]$ cat listener.ora
# listener.ora Network Configuration File: /u01/app/oracle/product/19/db_1/network/admin/listener.ora
# Generated by Oracle configuration tools.

LISTENER2 =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = test.com)(PORT = 1528))
    )

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = test.com)(PORT = 1529))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
    )
  )

HONG =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = test.com)(PORT = 1530))
    )
  )

[oracle@test admin]$

 

 

 

[oracle@test ~]$ sqlplus / as sysdba

SQL*Plus: Release 19.0.0.0.0 - Production on Thu Nov 30 12:07:35 2023
Version 19.3.0.0.0

Copyright (c) 1982, 2019, Oracle.  All rights reserved.


Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0

SQL> show parameter local

NAME				     TYPE	 VALUE
------------------------------------ ----------- ------------------------------
local_listener			     string	 LISTENER_ORCL
parallel_force_local		     boolean	 FALSE
SQL>
SQL> alter system set local_listener="LISTENER_ORCL,LISTENER2";

System altered.

SQL> show parameter local

NAME				     TYPE	 VALUE
------------------------------------ ----------- ------------------------------
local_listener			     string	 LISTENER_ORCL,LISTENER2
parallel_force_local		     boolean	 FALSE
SQL>

 

 

 

[oracle@test admin]$ ps -ef | grep tns
root           6       2  0 11월29 ?      00:00:00 [netns]
oracle     23628       1  0 10:57 ?        00:00:00 /u01/app/oracle/product/19/db_1/bin/tnslsnr LISTENER -inherit
oracle     23634       1  0 10:58 ?        00:00:00 /u01/app/oracle/product/19/db_1/bin/tnslsnr HONG -inherit
oracle     25391   24675  0 12:28 pts/2    00:00:00 grep --color=auto tns
[oracle@test admin]$

 

 

 

LSNRCTL> start listener2
Starting /u01/app/oracle/product/19/db_1/bin/tnslsnr: please wait...

TNSLSNR for Linux: Version 19.0.0.0.0 - Production
System parameter file is /u01/app/oracle/product/19/db_1/network/admin/listener.ora
Log messages written to /u01/app/oracle/diag/tnslsnr/test/listener2/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=test.com)(PORT=1528)))

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=test.com)(PORT=1528)))
STATUS of the LISTENER
------------------------
Alias                     listener2
Version                   TNSLSNR for Linux: Version 19.0.0.0.0 - Production
Start Date                30-NOV-2023 12:28:44
Uptime                    0 days 0 hr. 0 min. 0 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/19/db_1/network/admin/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/test/listener2/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=test.com)(PORT=1528)))
The listener supports no services
The command completed successfully
LSNRCTL>

 

 

 

LSNRCTL> status listener2
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=test.com)(PORT=1528)))
STATUS of the LISTENER
------------------------
Alias                     listener2
Version                   TNSLSNR for Linux: Version 19.0.0.0.0 - Production
Start Date                30-NOV-2023 12:28:44
Uptime                    0 days 0 hr. 1 min. 4 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/19/db_1/network/admin/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/test/listener2/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=test.com)(PORT=1528)))
Services Summary...
Service "09d7302c9140311ce0639802a8c09c66.com" has 1 instance(s).
  Instance "orcl", status READY, has 1 handler(s) for this service...
Service "0ae8ae6e8e43ba20e063e102a8c0700c.com" has 1 instance(s).
  Instance "orcl", status READY, has 1 handler(s) for this service...
Service "0b23a05d4693eaa3e063e102a8c05ada.com" has 1 instance(s).
  Instance "orcl", status READY, has 1 handler(s) for this service...
Service "86b637b62fdf7a65e053f706e80a27ca.com" has 1 instance(s).
  Instance "orcl", status READY, has 1 handler(s) for this service...
Service "orcl.com" has 1 instance(s).
  Instance "orcl", status READY, has 1 handler(s) for this service...
Service "orclXDB.com" has 1 instance(s).
  Instance "orcl", status READY, has 1 handler(s) for this service...
Service "orclpdb.com" has 1 instance(s).
  Instance "orcl", status READY, has 1 handler(s) for this service...
Service "pdb1.com" has 1 instance(s).
  Instance "orcl", status READY, has 1 handler(s) for this service...
Service "pdbtest1.com" has 1 instance(s).
  Instance "orcl", status READY, has 1 handler(s) for this service...
The command completed successfully
LSNRCTL>

 

 

 

[oracle@test admin]$ ps -ef | grep tns
root           6       2  0 11월29 ?      00:00:00 [netns]
oracle     23628       1  0 10:57 ?        00:00:00 /u01/app/oracle/product/19/db_1/bin/tnslsnr LISTENER -inherit
oracle     23634       1  0 10:58 ?        00:00:00 /u01/app/oracle/product/19/db_1/bin/tnslsnr HONG -inherit
oracle     25403       1  0 12:28 ?        00:00:00 /u01/app/oracle/product/19/db_1/bin/tnslsnr listener2 -inherit
oracle     25444   24675  0 12:31 pts/2    00:00:00 grep --color=auto tns
[oracle@test admin]$

 

 

 

1528, 1529 포트로 모두 접속이 되는것을 볼 수 있다.

 

[oracle@test ~]$ sqlplus / as sysdba

SQL*Plus: Release 19.0.0.0.0 - Production on Thu Nov 30 12:31:47 2023
Version 19.3.0.0.0

Copyright (c) 1982, 2019, Oracle.  All rights reserved.


Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0



SQL> conn sys/Manager123#@test.com:1528/orcl.com as sysdba
Connected.
SQL> show con_name

CON_NAME
------------------------------
CDB$ROOT
SQL> show pdbs

    CON_ID CON_NAME			  OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
	 2 PDB$SEED			  READ ONLY  NO
	 3 ORCLPDB			  READ WRITE NO
	 4 PDB1 			  READ WRITE NO
	 5 PDBTEST1			  READ WRITE NO



SQL> conn sys/Manager123#@test.com:1529/orcl.com as sysdba
Connected.
SQL> show con_name

CON_NAME
------------------------------
CDB$ROOT
SQL> show pdbs

    CON_ID CON_NAME			  OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
	 2 PDB$SEED			  READ ONLY  NO
	 3 ORCLPDB			  READ WRITE NO
	 4 PDB1 			  READ WRITE NO
	 5 PDBTEST1			  READ WRITE NO
SQL>