Configure independent listeners for multiple Oracle instances on the same machine

andelwu 2021-01-23 18:33:21
configure independent listeners multiple oracle

scene :

Suppose we need to put multiple oracle The instances are deployed in the same set RAC colony / On the same physical machine , By default , Multiple oracle Instance sharing uses the default 1521 Monitor .

There are several problems with the use of listener sharing :

  1. Network access to different instances cannot be isolated , Each instance needs to manage its own user password , Avoid accessing other instances
  2. If the short connection login frequency of one instance is too high, the listener will respond slowly , Will affect the login access of other instances
  3. The instance does not have a separate listener configuration , such as wallet/tnsname/TDE/SSL/EUS Authentication and other configuration , You can't configure related features for an instance alone . To ensure network isolation , And support and set different wallet/sqlnet/tnsnames/listener/TDE/SSL/EUS Authentication and other configuration , Here's a way to configure a separate listener for each instance , Each listener sets a different environment variable configuration file , And discuss the operation specification requirements and possible impact of configuration ;

The listener starts the analysis

Generally speaking , On a stand-alone instance , It can be modified by $ORACLE_HOME/network/admin/listener.ora and lsnrctl Command to create a listener :

 stay listener.ora Add :
(ADDRESS = (PROTOCOL = TCP)(HOST = x.x.x.x)(PORT = 1524)(IP = FIRST))))
(SID_DESC = (ORACLE_HOME = /u01/app/oracle/product)(SID_NAME = TEST)))
lsnrctl start LISTENER_TEST
lsnrctl status LISTENER_TEST

stay RAC Environment , Adding an independent listener to the instance is also relatively simple :

DB user :oracle
Listening port :1524
Listener name :test122
su - oracle
srvctl add listener -listener test122 -oraclehome /u01/app/oracle/product -endpoints 1524
srvctl start listener -listener test122

The default usage of the listener after starting in this way $ORACLE_HOME/network/admin In the catalog listener.ora、tnsnames.ora、sqlnet.ora Etc ;

If we need multiple versions of the same listener , These configuration files are shared among multiple listeners . When you need to configure parameters separately for an instance , In this case, it's impossible to customize .

We can start the monitor with 、database By setting the environment variables of the listener process TNS_ADMIN Environment variables to modify the default listener.ora The path of , To specify a separate listener configuration directory for each instance ;

But here we need to understand several common scenarios oracle/listner Authority / How to introduce environment variables :

  1. Command line fork Inherit , such as sqlplus / as sysdba, lsnrctl start etc. , Attention should be paid to the local management of the server ;
  2. Remote connection +dedicate server, Inherit the environment variable of the listener (ORACLE_HOME/ORACLE_SID With the exception of );
  3. Remote connection +shared server, Integrate DB Environment variables for the process ,DB Process environment variables may come from the command line / Remote connection + Static monitoring ;

The relationship between environment variables of database and environment variables of listener :

  1. Dynamic registration :db When the node starts up pmon The process registers the service to the listener , And pass their own environment variables to the listener ; After that, all the processes started by the listener , They all apply pmon Environment variables passed in ; By default pmon Sign up to 1521 Default listening for , Can pass local_listner Parameter configuration is registered to other listeners ; remarks :RAC After instance creation and srvctl Create a listener, etc , Dynamic registration is used by default .SID_LIST_LISTENER_TEST = (SID_LIST = (SID_DESC = (GLOBAL_DBNAME = <db_name>) (ORACLE_HOME = /u01/app/oracle/product/) (SID_NAME = <sid_name>) (ENVS="TNS_ADMIN=/u01/app/oracle/product/network/admin/<db_name>") ) )
  2. Static registration : adopt listener.ora Configuration file configuration SID_LIST_listener_name Parameters , for example :
  3. If you use srvctl Tool configuration environment variables , The configuration is stored in OCR in , When srvctl When starting related services , From ocr Read and configure the environment variables in and restart the service ;
  4. Last , Once the process's environment variables are set , There is no way to modify it after startup , If the modification needs to restart the process (database/listener)

To sum up the above different scenes , terms of settlement :

  1. For each instance in $ORACLE_HOME/product/network/admin Create <db_name> Catalog , Deposit listener.ora, tnsnames.ora, sqlnet.ora Other configuration
  2. adopt srvctl setenv by database and listener Set up TNS_ADMIN Parameters , Point to 1 In the directory
  3. In case management operation ( For example, start stop DB, Monitor ) When , Need to set up TNS_ADMIN environment variable .
  4. If in listener.ora Configure static listening in , You need to add environment variable information ;

Potential impacts and operational specifications ( important )

  1. stay RAC On the operation example 、 Try to get all the monitors through srvctl To operate , Avoid the command line lsnrctl/sqlplus Connection direct operation .SID_LIST_LISTENER_TEST = (SID_LIST = (SID_DESC = (GLOBAL_DBNAME = <db_name>) (ORACLE_HOME = /u01/app/oracle/product/) (SID_NAME = <sid_name>) (ENVS="TNS_ADMIN=/u01/app/oracle/product/network/admin/<db_name>") ) )
  2. If you operate from the command line , because fork Environment variable inheritance , From the command line sqlplus/lsnrctl In the process oracle/tnslsnr process , Therefore, it is necessary to test the node of a single instance on the machine listener/database Start of / When you restart the operation , Before operation, you need to load the environment variables of the corresponding instance . remarks : Can be in su When switching users, prompt and list environment variables immediately , Avoid operation and maintenance operation forgetting ;
  3. If you need to listener.ora Configure static listening in , stay ENVS The environment variable information that the instance should have is included in the setting of , for example :
  4. RAC Don't use in the environment lsnrctl save_config <listener_name> The way to modify listener.ora;

Debug related commands

Debugging related :

  1. linux How to view process environment variables :ps -ef Find out where the process is pid, View the search environment variables through the command xargs --null --max-args=1 echo < /proc/58144/environ|grep -i tnssrvctl getenv database -d test122 srvctl getenv listener -l test122 -- modify srvctl setenv database -d test122 -t "TNS_ADMIN=/u01/app/oracle/product/network/admin/test122/" srvctl setenv listener -listener test122 -t TNS_ADMIN=/u01/app/oracle/product/network/admin/test122/ -- restart srvctl stop listener -listener test122 srvctl start listener -listener test122 srvctl stop database -d test122 srvctl start database -d test122
  2. adopt srvctl Tools to see the presence of ocr Environment variable configuration in , Configure or modify variables , Need to pass through srvctl Restart and take effect ( Invalid command line )

Reference material :

Original statement , This article is authorized by the author + Community publication , Unauthorized , Shall not be reproduced .

If there is any infringement , Please contact the Delete .


  1. 【计算机网络 12(1),尚学堂马士兵Java视频教程
  2. 【程序猿历程,史上最全的Java面试题集锦在这里
  3. 【程序猿历程(1),Javaweb视频教程百度云
  4. Notes on MySQL 45 lectures (1-7)
  5. [computer network 12 (1), Shang Xuetang Ma soldier java video tutorial
  6. The most complete collection of Java interview questions in history is here
  7. [process of program ape (1), JavaWeb video tutorial, baidu cloud
  8. Notes on MySQL 45 lectures (1-7)
  9. 精进 Spring Boot 03:Spring Boot 的配置文件和配置管理,以及用三种方式读取配置文件
  10. Refined spring boot 03: spring boot configuration files and configuration management, and reading configuration files in three ways
  11. 精进 Spring Boot 03:Spring Boot 的配置文件和配置管理,以及用三种方式读取配置文件
  12. Refined spring boot 03: spring boot configuration files and configuration management, and reading configuration files in three ways
  13. 【递归,Java传智播客笔记
  14. [recursion, Java intelligence podcast notes
  15. [adhere to painting for 386 days] the beginning of spring of 24 solar terms
  16. K8S系列第八篇(Service、EndPoints以及高可用kubeadm部署)
  17. K8s Series Part 8 (service, endpoints and high availability kubeadm deployment)
  18. 【重识 HTML (3),350道Java面试真题分享
  19. 【重识 HTML (2),Java并发编程必会的多线程你竟然还不会
  20. 【重识 HTML (1),二本Java小菜鸟4面字节跳动被秒成渣渣
  21. [re recognize HTML (3) and share 350 real Java interview questions
  22. [re recognize HTML (2). Multithreading is a must for Java Concurrent Programming. How dare you not
  23. [re recognize HTML (1), two Java rookies' 4-sided bytes beat and become slag in seconds
  24. 造轮子系列之RPC 1:如何从零开始开发RPC框架
  25. RPC 1: how to develop RPC framework from scratch
  26. 造轮子系列之RPC 1:如何从零开始开发RPC框架
  27. RPC 1: how to develop RPC framework from scratch
  28. 一次性捋清楚吧,对乱糟糟的,Spring事务扩展机制
  29. 一文彻底弄懂如何选择抽象类还是接口,连续四年百度Java岗必问面试题
  30. Redis常用命令
  31. 一双拖鞋引发的血案,狂神说Java系列笔记
  32. 一、mysql基础安装
  33. 一位程序员的独白:尽管我一生坎坷,Java框架面试基础
  34. Clear it all at once. For the messy, spring transaction extension mechanism
  35. A thorough understanding of how to choose abstract classes or interfaces, baidu Java post must ask interview questions for four consecutive years
  36. Redis common commands
  37. A pair of slippers triggered the murder, crazy God said java series notes
  38. 1、 MySQL basic installation
  39. Monologue of a programmer: despite my ups and downs in my life, Java framework is the foundation of interview
  40. 【大厂面试】三面三问Spring循环依赖,请一定要把这篇看完(建议收藏)
  41. 一线互联网企业中,springboot入门项目
  42. 一篇文带你入门SSM框架Spring开发,帮你快速拿Offer
  43. 【面试资料】Java全集、微服务、大数据、数据结构与算法、机器学习知识最全总结,283页pdf
  44. 【leetcode刷题】24.数组中重复的数字——Java版
  45. 【leetcode刷题】23.对称二叉树——Java版
  46. 【leetcode刷题】22.二叉树的中序遍历——Java版
  47. 【leetcode刷题】21.三数之和——Java版
  48. 【leetcode刷题】20.最长回文子串——Java版
  49. 【leetcode刷题】19.回文链表——Java版
  50. 【leetcode刷题】18.反转链表——Java版
  51. 【leetcode刷题】17.相交链表——Java&python版
  52. 【leetcode刷题】16.环形链表——Java版
  53. 【leetcode刷题】15.汉明距离——Java版
  54. 【leetcode刷题】14.找到所有数组中消失的数字——Java版
  55. 【leetcode刷题】13.比特位计数——Java版
  56. oracle控制用户权限命令
  57. 三年Java开发,继阿里,鲁班二期Java架构师
  58. Oracle必须要启动的服务
  59. 万字长文!深入剖析HashMap,Java基础笔试题大全带答案
  60. 一问Kafka就心慌?我却凭着这份,图灵学院vip课程百度云