现有的监听文件配置
点击(此处)折叠或打开
- [oracle@test-db admin]$ cat listener.ora
- # listener.ora Network Configuration File: /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
- # Generated by Oracle configuration tools.
-
- LISTENER =
- (DESCRIPTION_LIST =
- (DESCRIPTION =
- (ADDRESS = (PROTOCOL = TCP)(HOST = test-db)(PORT = 1521))
- (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
- )
- )
-
- ADR_BASE_LISTENER = /u01/app/oracle
-
-
-
- SID_LIST_LISTENER =
- (SID_LIST =
- (SID_DESC =
- (GLOBAL_DBNAME=orcl)
- (ORACLE_HOME = /u01/app/oracle/product/11.2.0/dbhome_1)
- (SID_NAME = orcl)
- )
- )
目前的监听状态
点击(此处)折叠或打开
- [oracle@test-db admin]$ lsnrctl status
-
- LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 04-APR-2018 00:09:29
-
- Copyright (c) 1991, 2011, Oracle. All rights reserved.
-
- Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=test-db)(PORT=1521)))
- STATUS of the LISTENER
- ------------------------
- Alias LISTENER
- Version TNSLSNR for Linux: Version 11.2.0.3.0 - Production
- Start Date 03-APR-2018 23:30:31
- Uptime 0 days 0 hr. 38 min. 57 sec
- Trace Level off
- Security ON: Local OS Authentication
- SNMP OFF
- Listener Parameter File /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
- Listener Log File /u01/app/oracle/diag/tnslsnr/test-db/listener/alert/log.xml
- Listening Endpoints Summary...
- (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=test-db)(PORT=1521)))
- (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
- Services Summary...
- Service "orcl" has 1 instance(s).
- Instance "orcl", status UNKNOWN, has 1 handler(s) for this service...
- Service "orclXDB" has 1 instance(s).
- Instance "orcl", status READY, has 1 handler(s) for this service...
- Service "primary_orcl" has 1 instance(s).
- Instance "orcl", status READY, has 1 handler(s) for this service...
- The command completed successfully
----------------------------------分隔线-----------------------------------------
在listener.ora文件中添加1522端口的监听,添加后的文件内容如下
点击(此处)折叠或打开
- [oracle@test-db admin]$ cat listener.ora
- # listener.ora Network Configuration File: /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
- # Generated by Oracle configuration tools.
-
- LISTENER =
- (DESCRIPTION_LIST =
- (DESCRIPTION =
- (ADDRESS = (PROTOCOL = TCP)(HOST = test-db)(PORT = 1521))
- (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
- )
- )
-
- ADR_BASE_LISTENER = /u01/app/oracle
-
-
-
- SID_LIST_LISTENER =
- (SID_LIST =
- (SID_DESC =
- (GLOBAL_DBNAME=orcl)
- (ORACLE_HOME = /u01/app/oracle/product/11.2.0/dbhome_1)
- (SID_NAME = orcl)
- )
- )
-
-
- #1522
- MY_LISTENER =
- (DESCRIPTION_LIST =
- (DESCRIPTION =
- (ADDRESS = (PROTOCOL = TCP)(HOST = test-db)(PORT = 1522))
- (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1522))
- )
- )
-
- #用于在1522端口注册服务
- SID_LIST_MY_LISTENER =
- (SID_LIST =
- (SID_DESC =
- (GLOBAL_DBNAME=orcl)
- (ORACLE_HOME = /u01/app/oracle/product/11.2.0/dbhome_1)
- (SID_NAME = orcl)
- )
- )
启动1522端口监听
点击(此处)折叠或打开
- [oracle@test-db admin]$ lsnrctl start my_listener
-
- LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 04-APR-2018 00:16:18
-
- Copyright (c) 1991, 2011, Oracle. All rights reserved.
-
- Starting /u01/app/oracle/product/11.2.0/dbhome_1/bin/tnslsnr: please wait...
-
- TNSLSNR for Linux: Version 11.2.0.3.0 - Production
- System parameter file is /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
- Log messages written to /u01/app/oracle/diag/tnslsnr/test-db/my_listener/alert/log.xml
- Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=test-db)(PORT=1522)))
- Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1522)))
-
- Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=test-db)(PORT=1522)))
- STATUS of the LISTENER
- ------------------------
- Alias my_listener
- Version TNSLSNR for Linux: Version 11.2.0.3.0 - Production
- Start Date 04-APR-2018 00:16:18
- 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/11.2.0/dbhome_1/network/admin/listener.ora
- Listener Log File /u01/app/oracle/diag/tnslsnr/test-db/my_listener/alert/log.xml
- Listening Endpoints Summary...
- (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=test-db)(PORT=1522)))
- (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1522)))
- Services Summary...
- Service "orcl" has 1 instance(s).
- Instance "orcl", status UNKNOWN, has 1 handler(s) for this service...
- The command completed successfully
使用PLSQL Developer工具测试可以正常连接。
-----------------------分割线----------------------------
在1522端口注册服务器还有一种方法,就是使用tnsnames.ora文件
在去掉了listener.ora中有关 SID_LIST_MY_LISTENER 静态注册的代码后,重启 my_listener 监听发现没有任何服务注册
点击(此处)折叠或打开
- [oracle@test-db admin]$ lsnrctl start my_listener
-
- LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 04-APR-2018 00:18:08
-
- Copyright (c) 1991, 2011, Oracle. All rights reserved.
-
- Starting /u01/app/oracle/product/11.2.0/dbhome_1/bin/tnslsnr: please wait...
-
- TNSLSNR for Linux: Version 11.2.0.3.0 - Production
- System parameter file is /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
- Log messages written to /u01/app/oracle/diag/tnslsnr/test-db/my_listener/alert/log.xml
- Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=test-db)(PORT=1522)))
- Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1522)))
-
- Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=test-db)(PORT=1522)))
- STATUS of the LISTENER
- ------------------------
- Alias my_listener
- Version TNSLSNR for Linux: Version 11.2.0.3.0 - Production
- Start Date 04-APR-2018 00:18:08
- 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/11.2.0/dbhome_1/network/admin/listener.ora
- Listener Log File /u01/app/oracle/diag/tnslsnr/test-db/my_listener/alert/log.xml
- Listening Endpoints Summary...
- (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=test-db)(PORT=1522)))
- (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1522)))
- The listener supports no services
- The command completed successfully
在tnsnames.ora文件中添加如下代码
点击(此处)折叠或打开
- my_orcl =
- (DESCRIPTION =
- (ADDRESS = (PROTOCOL = TCP)(HOST = test-db)(PORT = 1522))
- (ADDRESS = (PROTOCOL = TCP)(HOST = test-db)(PORT = 1521))
- (CONNECT_DATA =
- (SERVER = DEDICATED)
- (SERVICE_NAME = orcl)
- )
- )
注:如果不添加(ADDRESS = (PROTOCOL = TCP)(HOST = test-db)(PORT = 1521))这段的话,那么在默认1521端口中将不会有服务注册
点击(此处)折叠或打开
- alter system set local_listener='my_orcl' scope=both;
使用命令分别检查监听状态
点击(此处)折叠或打开
- [oracle@test-db admin]$ lsnrctl status
-
- LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 04-APR-2018 00:32:38
-
- Copyright (c) 1991, 2011, Oracle. All rights reserved.
-
- Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=test-db)(PORT=1521)))
- STATUS of the LISTENER
- ------------------------
- Alias LISTENER
- Version TNSLSNR for Linux: Version 11.2.0.3.0 - Production
- Start Date 03-APR-2018 23:30:31
- Uptime 0 days 1 hr. 2 min. 6 sec
- Trace Level off
- Security ON: Local OS Authentication
- SNMP OFF
- Listener Parameter File /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
- Listener Log File /u01/app/oracle/diag/tnslsnr/test-db/listener/alert/log.xml
- Listening Endpoints Summary...
- (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=test-db)(PORT=1521)))
- (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
- Services Summary...
- Service "orcl" has 1 instance(s).
- Instance "orcl", status UNKNOWN, has 1 handler(s) for this service...
- Service "orclXDB" has 1 instance(s).
- Instance "orcl", status READY, has 1 handler(s) for this service...
- Service "primary_orcl" has 1 instance(s).
- Instance "orcl", status READY, has 1 handler(s) for this service...
- The command completed successfully
- [oracle@test-db admin]$ lsnrctl status my_listener
-
- LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 04-APR-2018 00:32:45
-
- Copyright (c) 1991, 2011, Oracle. All rights reserved.
-
- Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=test-db)(PORT=1522)))
- STATUS of the LISTENER
- ------------------------
- Alias my_listener
- Version TNSLSNR for Linux: Version 11.2.0.3.0 - Production
- Start Date 04-APR-2018 00:18:08
- Uptime 0 days 0 hr. 14 min. 37 sec
- Trace Level off
- Security ON: Local OS Authentication
- SNMP OFF
- Listener Parameter File /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
- Listener Log File /u01/app/oracle/diag/tnslsnr/test-db/my_listener/alert/log.xml
- Listening Endpoints Summary...
- (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=test-db)(PORT=1522)))
- (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1522)))
- Services Summary...
- Service "orclXDB" has 1 instance(s).
- Instance "orcl", status READY, has 1 handler(s) for this service...
- Service "primary_orcl" has 1 instance(s).
- Instance "orcl", status READY, has 1 handler(s) for this service...
- The command completed successfully
使用PLSQL Developer工具测试可以正常连接。
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/2317695/viewspace-2152591/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/2317695/viewspace-2152591/