Oracle 创建非1521端口监听



现有的监听文件配置

点击(此处)折叠或打开

  1. [oracle@test-db admin]$ cat listener.ora
  2. # listener.ora Network Configuration File: /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
  3. # Generated by Oracle configuration tools.

  4. LISTENER =
  5.   (DESCRIPTION_LIST =
  6.     (DESCRIPTION =
  7.       (ADDRESS = (PROTOCOL = TCP)(HOST = test-db)(PORT = 1521))
  8.       (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
  9.     )
  10.   )

  11. ADR_BASE_LISTENER = /u01/app/oracle



  12. SID_LIST_LISTENER =
  13.   (SID_LIST =
  14.     (SID_DESC =
  15.       (GLOBAL_DBNAME=orcl)
  16.       (ORACLE_HOME = /u01/app/oracle/product/11.2.0/dbhome_1)
  17.      (SID_NAME = orcl)
  18.     )
  19.   )

目前的监听状态

点击(此处)折叠或打开

  1. [oracle@test-db admin]$ lsnrctl status

  2. LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 04-APR-2018 00:09:29

  3. Copyright (c) 1991, 2011, Oracle. All rights reserved.

  4. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=test-db)(PORT=1521)))
  5. STATUS of the LISTENER
  6. ------------------------
  7. Alias LISTENER
  8. Version TNSLSNR for Linux: Version 11.2.0.3.0 - Production
  9. Start Date 03-APR-2018 23:30:31
  10. Uptime 0 days 0 hr. 38 min. 57 sec
  11. Trace Level off
  12. Security ON: Local OS Authentication
  13. SNMP OFF
  14. Listener Parameter File /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
  15. Listener Log File /u01/app/oracle/diag/tnslsnr/test-db/listener/alert/log.xml
  16. Listening Endpoints Summary...
  17.   (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=test-db)(PORT=1521)))
  18.   (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
  19. Services Summary...
  20. Service "orcl" has 1 instance(s).
  21.   Instance "orcl", status UNKNOWN, has 1 handler(s) for this service...
  22. Service "orclXDB" has 1 instance(s).
  23.   Instance "orcl", status READY, has 1 handler(s) for this service...
  24. Service "primary_orcl" has 1 instance(s).
  25.   Instance "orcl", status READY, has 1 handler(s) for this service...
  26. The command completed successfully

----------------------------------分隔线-----------------------------------------

在listener.ora文件中添加1522端口的监听,添加后的文件内容如下

点击(此处)折叠或打开

  1. [oracle@test-db admin]$ cat listener.ora
  2. # listener.ora Network Configuration File: /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
  3. # Generated by Oracle configuration tools.

  4. LISTENER =
  5.   (DESCRIPTION_LIST =
  6.     (DESCRIPTION =
  7.       (ADDRESS = (PROTOCOL = TCP)(HOST = test-db)(PORT = 1521))
  8.       (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
  9.     )
  10.   )

  11. ADR_BASE_LISTENER = /u01/app/oracle



  12. SID_LIST_LISTENER =
  13.   (SID_LIST =
  14.     (SID_DESC =
  15.       (GLOBAL_DBNAME=orcl)
  16.       (ORACLE_HOME = /u01/app/oracle/product/11.2.0/dbhome_1)
  17.      (SID_NAME = orcl)
  18.     )
  19.   )


  20. #1522
  21. MY_LISTENER =
  22.   (DESCRIPTION_LIST =
  23.     (DESCRIPTION =
  24.       (ADDRESS = (PROTOCOL = TCP)(HOST = test-db)(PORT = 1522))
  25.       (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1522))
  26.     )
  27.   )

  28. #用于在1522端口注册服务
  29. SID_LIST_MY_LISTENER =
  30.   (SID_LIST =
  31.     (SID_DESC =
  32.       (GLOBAL_DBNAME=orcl)
  33.       (ORACLE_HOME = /u01/app/oracle/product/11.2.0/dbhome_1)
  34.      (SID_NAME = orcl)
  35.     )
  36.   )

启动1522端口监听

点击(此处)折叠或打开

  1. [oracle@test-db admin]$ lsnrctl start my_listener

  2. LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 04-APR-2018 00:16:18

  3. Copyright (c) 1991, 2011, Oracle. All rights reserved.

  4. Starting /u01/app/oracle/product/11.2.0/dbhome_1/bin/tnslsnr: please wait...

  5. TNSLSNR for Linux: Version 11.2.0.3.0 - Production
  6. System parameter file is /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
  7. Log messages written to /u01/app/oracle/diag/tnslsnr/test-db/my_listener/alert/log.xml
  8. Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=test-db)(PORT=1522)))
  9. Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1522)))

  10. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=test-db)(PORT=1522)))
  11. STATUS of the LISTENER
  12. ------------------------
  13. Alias my_listener
  14. Version TNSLSNR for Linux: Version 11.2.0.3.0 - Production
  15. Start Date 04-APR-2018 00:16:18
  16. Uptime 0 days 0 hr. 0 min. 0 sec
  17. Trace Level off
  18. Security ON: Local OS Authentication
  19. SNMP OFF
  20. Listener Parameter File /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
  21. Listener Log File /u01/app/oracle/diag/tnslsnr/test-db/my_listener/alert/log.xml
  22. Listening Endpoints Summary...
  23.   (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=test-db)(PORT=1522)))
  24.   (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1522)))
  25. Services Summary...
  26. Service "orcl" has 1 instance(s).
  27.   Instance "orcl", status UNKNOWN, has 1 handler(s) for this service...
  28. The command completed successfully

使用PLSQL Developer工具测试可以正常连接。

-----------------------分割线----------------------------
在1522端口注册服务器还有一种方法,就是使用tnsnames.ora文件
在去掉了listener.ora中有关 SID_LIST_MY_LISTENER 静态注册的代码后,重启 my_listener 监听发现没有任何服务注册

点击(此处)折叠或打开

  1. [oracle@test-db admin]$ lsnrctl start my_listener

  2. LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 04-APR-2018 00:18:08

  3. Copyright (c) 1991, 2011, Oracle. All rights reserved.

  4. Starting /u01/app/oracle/product/11.2.0/dbhome_1/bin/tnslsnr: please wait...

  5. TNSLSNR for Linux: Version 11.2.0.3.0 - Production
  6. System parameter file is /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
  7. Log messages written to /u01/app/oracle/diag/tnslsnr/test-db/my_listener/alert/log.xml
  8. Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=test-db)(PORT=1522)))
  9. Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1522)))

  10. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=test-db)(PORT=1522)))
  11. STATUS of the LISTENER
  12. ------------------------
  13. Alias my_listener
  14. Version TNSLSNR for Linux: Version 11.2.0.3.0 - Production
  15. Start Date 04-APR-2018 00:18:08
  16. Uptime 0 days 0 hr. 0 min. 0 sec
  17. Trace Level off
  18. Security ON: Local OS Authentication
  19. SNMP OFF
  20. Listener Parameter File /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
  21. Listener Log File /u01/app/oracle/diag/tnslsnr/test-db/my_listener/alert/log.xml
  22. Listening Endpoints Summary...
  23.   (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=test-db)(PORT=1522)))
  24.   (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1522)))
  25. The listener supports no services
  26. The command completed successfully

在tnsnames.ora文件中添加如下代码

点击(此处)折叠或打开

  1. my_orcl =
  2.   (DESCRIPTION =
  3.     (ADDRESS = (PROTOCOL = TCP)(HOST = test-db)(PORT = 1522))
  4.     (ADDRESS = (PROTOCOL = TCP)(HOST = test-db)(PORT = 1521))
  5.     (CONNECT_DATA =
  6.       (SERVER = DEDICATED)
  7.       (SERVICE_NAME = orcl)
  8.     )
  9.   )

注:如果不添加(ADDRESS = (PROTOCOL = TCP)(HOST = test-db)(PORT = 1521))这段的话,那么在默认1521端口中将不会有服务注册

登录数据库设置local_listener参数

点击(此处)折叠或打开

  1. alter system set local_listener='my_orcl' scope=both;

使用命令分别检查监听状态

点击(此处)折叠或打开

  1. [oracle@test-db admin]$ lsnrctl status

  2. LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 04-APR-2018 00:32:38

  3. Copyright (c) 1991, 2011, Oracle. All rights reserved.

  4. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=test-db)(PORT=1521)))
  5. STATUS of the LISTENER
  6. ------------------------
  7. Alias LISTENER
  8. Version TNSLSNR for Linux: Version 11.2.0.3.0 - Production
  9. Start Date 03-APR-2018 23:30:31
  10. Uptime 0 days 1 hr. 2 min. 6 sec
  11. Trace Level off
  12. Security ON: Local OS Authentication
  13. SNMP OFF
  14. Listener Parameter File /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
  15. Listener Log File /u01/app/oracle/diag/tnslsnr/test-db/listener/alert/log.xml
  16. Listening Endpoints Summary...
  17.   (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=test-db)(PORT=1521)))
  18.   (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
  19. Services Summary...
  20. Service "orcl" has 1 instance(s).
  21.   Instance "orcl", status UNKNOWN, has 1 handler(s) for this service...
  22. Service "orclXDB" has 1 instance(s).
  23.   Instance "orcl", status READY, has 1 handler(s) for this service...
  24. Service "primary_orcl" has 1 instance(s).
  25.   Instance "orcl", status READY, has 1 handler(s) for this service...
  26. The command completed successfully
  27. [oracle@test-db admin]$ lsnrctl status my_listener

  28. LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 04-APR-2018 00:32:45

  29. Copyright (c) 1991, 2011, Oracle. All rights reserved.

  30. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=test-db)(PORT=1522)))
  31. STATUS of the LISTENER
  32. ------------------------
  33. Alias my_listener
  34. Version TNSLSNR for Linux: Version 11.2.0.3.0 - Production
  35. Start Date 04-APR-2018 00:18:08
  36. Uptime 0 days 0 hr. 14 min. 37 sec
  37. Trace Level off
  38. Security ON: Local OS Authentication
  39. SNMP OFF
  40. Listener Parameter File /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
  41. Listener Log File /u01/app/oracle/diag/tnslsnr/test-db/my_listener/alert/log.xml
  42. Listening Endpoints Summary...
  43.   (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=test-db)(PORT=1522)))
  44.   (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1522)))
  45. Services Summary...
  46. Service "orclXDB" has 1 instance(s).
  47.   Instance "orcl", status READY, has 1 handler(s) for this service...
  48. Service "primary_orcl" has 1 instance(s).
  49.   Instance "orcl", status READY, has 1 handler(s) for this service...
  50. The command completed successfully

使用PLSQL Developer工具测试可以正常连接。





来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/2317695/viewspace-2152591/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/2317695/viewspace-2152591/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值