首页 > 代码库 > listener配置小练习

listener配置小练习


作业:1521 1526
环境里存在一个数据库实例A

实现:
1521监听A数据库
A数据库的信息主动注册到1526监听器上
并且通过easy connect和sqlplus sys/oracle@网络服务名 as sysdba 方式验证

解析:
保证数据库处于open状态,数据库sid=WDD service_name=wsweididi.dba.oracle.com
1 配置listener.ora,如下,lsnr1配置了1521端口是静态监听  lsnr2是1526端口是动态监听
LSNR2 =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.195.60)(PORT = 1526))
    )
  )


LSNR1 =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.195.60)(PORT = 1521))
    )
  )
SID_LIST_LSNR1=
  (SID_LIST=
   (SID_DESC=
     (SID_NAME=WDD)
     (ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1)
     (GLOBAL_DBNAME=wsweididi.dba.oracle.com)
   )
  )
2 配置tnsnames.ora
LSNR2 =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.195.60)(PORT = 1526))
    )
  )
3 此时可以启动静态监听了,如下可以看到静态监听启动成功,1521端口监听数据库WDD信息
lsnrctl start lsnr1

  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=172.16.195.60)(PORT=1521)))
Services Summary...
Service "wsweididi.dba.oracle.com" has 1 instance(s).
  Instance "WDD", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully

4 由于动态监听是从1526端口接收到的,而数据库默认不找寻找1521以外的其他端口注册数据库,除非修改了local_listener的值
alter system set local_listener=‘LSNR2‘;
5 启动动态监听lsnr2
lsnrctl start lsnr2
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=172.16.195.60)(PORT=1526)))
Services Summary...
Service "WDDXDB.dba.oracle.com" has 1 instance(s).
  Instance "WDD", status READY, has 1 handler(s) for this service...
Service "wsweididi.dba.oracle.com" has 1 instance(s).
  Instance "WDD", status READY, has 1 handler(s) for this service...
The command completed successfully

如果发现是no service状态,可以到数据库里alter system register;



进行连接验证,客户端的tnsnames文件配置如下
WDD1 =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.195.60)(PORT = 1521))
    )
    (CONNECT_DATA =http://www.mamicode.com/
      (SERVER = DEDICATED)
      (SERVICE_NAME = wsweididi.dba.oracle.com)
    )
  )


 
WDD2 =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.195.60)(PORT = 1526))
    )
    (CONNECT_DATA =http://www.mamicode.com/
      (SERVER = DEDICATED)
      (SERVICE_NAME = wsweididi.dba.oracle.com)
    )
  )
 

验证
1 sqlplus system/oracle@WDD1
2 sqlplus system/oracle@WDD2
3 sqlplus system/oracle@172.16.195.60:1521/wsweididi.dba.oracle.com
4 sqlplus system/oracle@172.16.195.60:1526/wsweididi.dba.oracle.com




listener配置小练习