配置监听 listener
- [oracle@oracle ~]$ netca
- Oracle Net Services Configuration:
- # listener.ora Network Configuration File: /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
- # Generated by Oracle configuration tools.
- LISTENER1 =
- (DESCRIPTION_LIST =
- (DESCRIPTION =
- (ADDRESS = (PROTOCOL = TCP)(HOST = oracle)(PORT = 1522))
- )
- )
- ADR_BASE_LISTENER1 = /u01/app/oracle
- LISTENER =
- (DESCRIPTION_LIST =
- (DESCRIPTION =
- (ADDRESS = (PROTOCOL = TCP)(HOST = oracle)(PORT = 1521))
- )
- )
- ADR_BASE_LISTENER = /u01/app/oracle
- LISTENER =
- (DESCRIPTION =
- (ADDRESS = (PROTOCOL = TCP)(HOST = oracle)(PORT = 1521))
- )
- SID_LIST_LISTENER =
- (SID_LIST =
- (SID_DESC =
- (GLOBAL_DBNAME = Oracle8)
- (ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_1)
- (SID_NAME = oracl)
- )
- )
- ADR_BASE_LISTENER = /u01/app/oracle
- LISTENER1 =
- (DESCRIPTION =
- (ADDRESS = (PROTOCOL = TCP)(HOST = oracle)(PORT = 1522))
- )
查看 listener1 的监听状态
- SID_LIST_LISTENER1 =
- (SID_LIST =
- (SID_DESC =
- (GLOBAL_DBNAME = Oracle8)
- (ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_1)
- (SID_NAME = oracl)
- )
- )
- ADR_BASE_LISTENER1 = /u01/app/oracle
实例的几种状态 Status 的几种状态。
- [oracle@oracle~] $ lsnrctl status listener1Service "Oracle8"has 1 instance(s).Instance "oracl",
- status UNKNOWN,
- has 1 handler(s) for this service...The command completed successfully[oracle@oracle~] $
查看监听 listener1 的状态
- SQL > alter system set LOCAL_LISTENER = ' (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.10)(PORT = 1522))';
- System altered.SQL >
- [oracle@oracle~] $ lsnrctl status listener1Service "oracl"has 1 instance(s).Instance "oracl",
- status READY,
- has 5 handler(s) for this service...The command completed successfully
修改 databaseservicesGlobal Database Name: 数据库名随便起一个就可以 Oracle Home Directory 默认就可以 Sid 实例名 保存就可以了 保存后重新加载监听 listener1
- [oracle@oracle ~]$ netmgr
修改监听后要重启监听。
- [oracle@oracle~] $ lsnrctl reload listener1 LSNRCTL
- for Linux: Version 11.2.0.4.0 - Production on 16 - JAN - 2017 10 : 14 : 24 Copyright(c) 1991,
- 2013,
- Oracle. All rights reserved. Connecting to(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.10)(PORT = 1511))) The command completed successfully[oracle@oracle~] $
选择 tcp 连接 填写 ip 地址填写一个本地网络服务名可以随便起。配置完成后查看查看参数文件 tnsnames.ora 文件
- [oracle@oracle admin] $ lsnrctl statusService "oracl"has 1 instance(s).---服务名 Instance "oracl",
- status READY,
- has 5 handler(s) for this service...用The command completed successfully
连接测试 sqlplus u1/u1@oracl-- 相当于 sqlplus u1/u1@192.168.56.10:1521/oracl
- # tnsnames.ora Network Configuration File: /u01/app/oracle/product/11.2.0/db_1/network/admin/tnsnames.ora
- # Generated by Oracle configuration tools.
- ORACL =
- (DESCRIPTION =
- (ADDRESS_LIST =
- (ADDRESS = (PROTOCOL = TCP)(HOST = oracle)(PORT = 1521))
- )
- (CONNECT_DATA =
- (SERVER = dedicated)
- (SERVICE_NAME = oracl)
- )
- )
- [oracle@oracle~] $ sqlplus u1 / u1@oracl--相当于sqlplus u1 / u1@192.168.56.10 : 1521 / oraclSQL * Plus: Release 11.2.0.4.0 Production on Sun Feb 12 19 : 23 : 46 2017Copyright(c) 1982,
- 2013,
- Oracle.All rights reserved.Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit ProductionWith the Partitioning,
- OLAP,
- Data Mining and Real Application Testing optionsSQL >
- [oracle@oracle ~]$ cd /u01/app/oracle/product/11.2.0/db_1/network/admin/
- [oracle@oracle admin]$ ls
- listener1702126PM3810.bak samples sqlnet.ora tnsnames.ora
- listener.ora shrept.lst tnsnames1702126PM3810.bak
- [oracle@oracle admin]$ cat tnsnames.ora
- # tnsnames.ora Network Configuration File: /u01/app/oracle/product/11.2.0/db_1/network/admin/tnsnames.ora
- # Generated by Oracle configuration tools.
- ORACL =
- (DESCRIPTION =
- (ADDRESS_LIST =
- (ADDRESS = (PROTOCOL = TCP)(HOST = oracle)(PORT = 1521))
- )
- (CONNECT_DATA =
- (SERVER = dedicated)
- (SERVICE_NAME = oracl)
- )
- )
- ORACL2 =
- (DESCRIPTION =
- (ADDRESS_LIST =
- (ADDRESS = (PROTOCOL = TCP)(HOST = oracle)(PORT = 1521))
- )
- (CONNECT_DATA =
- (SERVER = shared)
- (SERVICE_NAME = oracl)
- )
- )
- [oracle@oracle admin]$
- [oracle@oracle~] $ tnsping oraclTNS Ping Utility
- for Linux: Version 11.2.0.4.0 - Production on 12 - FEB - 2017 21 : 08 : 54Copyright(c) 1997,
- 2013,
- Oracle.All rights reserved.Used parameter files: /u01/app / oracle / product / 11.2.0 / db_1 / network / admin / sqlnet.oraUsed TNSNAMES adapter to resolve the aliasAttempting to contact(DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = oracle)(PORT = 1521)))(CONNECT_DATA = (SERVER = dedicated)(SERVICE_NAME = oracl))) OK(0 msec)[oracle@oracle~] $
现在只是开启了监听 listener,关闭了 listener1。在监听 listener 上只有一个 oracl 服务查看监听状态
- [oracle@oracle admin] $ tnsping oracl2TNS Ping Utility
- for Linux: Version 11.2.0.4.0 - Production on 14 - FEB - 2017 19 : 21 : 01Copyright(c) 1997,
- 2013,
- Oracle.All rights reserved.Used parameter files: Used TNSNAMES adapter to resolve the aliasAttempting to contact(DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = oracle)(PORT = 1521)))(CONNECT_DATA = (SERVER = shared)(SERVICE_NAME = oracl))) OK(0 msec)[oracle@oracle admin] $
- [oracle@oracle~] $ lsnrctl statusService "oracl"has 1 instance(s).Instance "oracl",
- status READY,
- has 5 handler(s) for this service...The command completed successfully[oracle@oracle~] $
测试 oracl2 可以看到还是成功了。说明不负责确认 service_name 是否正确
- ORACL2 =
- (DESCRIPTION =
- (ADDRESS_LIST =
- (ADDRESS = (PROTOCOL = TCP)(HOST = oracle)(PORT = 1521))
- )
- (CONNECT_DATA =
- (SERVER = shared)
- (SERVICE_NAME = ora)----没有这个服务名
- )
- )
- [oracle@oracle admin] $ tnsping oracl2TNS Ping Utility
- for Linux: Version 11.2.0.4.0 - Production on 14 - FEB - 2017 19 : 29 : 12Copyright(c) 1997,
- 2013,
- Oracle.All rights reserved.Used parameter files: Used TNSNAMES adapter to resolve the aliasAttempting to contact(DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = oracle)(PORT = 1521)))(CONNECT_DATA = (SERVER = shared)(SERVICE_NAME = ora))) OK(0 msec)[oracle@oracle admin] $
- ORACL2 =
- (DESCRIPTION =
- (ADDRESS_LIST =
- (ADDRESS = (PROTOCOL = TCP)(HOST = oracle)(PORT = 1520))--
- )
- (CONNECT_DATA =
- (SERVER = shared)
- (SERVICE_NAME = oracl)
- )
- )
- [oracle@oracle admin] $ tnsping oracl2TNS Ping Utility
- for Linux: Version 11.2.0.4.0 - Production on 14 - FEB - 2017 19 : 31 : 28Copyright(c) 1997,
- 2013,
- Oracle.All rights reserved.Used parameter files: Used TNSNAMES adapter to resolve the aliasAttempting to contact(DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = oracle)(PORT = 1520)))(CONNECT_DATA = (SERVER = shared)(SERVICE_NAME = oracl))) TNS - 12541 : TNS: no listener[oracle@oracle admin] $
- ORACL2 =
- (DESCRIPTION =
- (ADDRESS_LIST =
- (ADDRESS = (PROTOCOL = TCP)(HOST = oracl)(PORT = 1521))
- )
- (CONNECT_DATA =
- (SERVER = shared)
- (SERVICE_NAME = oracl)
- )
- )
- [oracle@oracle admin] $ tnsping oracl2TNS Ping Utility
- for Linux: Version 11.2.0.4.0 - Production on 14 - FEB - 2017 19 : 33 : 34Copyright(c) 1997,
- 2013,
- Oracle.All rights reserved.Used parameter files: Used TNSNAMES adapter to resolve the aliasAttempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = oracl)(PORT = 1520))) (CONNECT_DATA = (SERVER = shared)(SERVICE_NAME = oracl))) TNS - 12545 : Connect failed because target host or object does not exist[oracle@oracle admin] $
开启第二个的窗口查看 trace 文件
- [oracle@oracle~] $ lsnrctlLSNRCTL
- for Linux: Version 11.2.0.4.0 - Production on 12 - FEB - 2017 19 : 35 : 38Copyright(c) 1991,
- 2013,
- Oracle.All rights reserved.Welcome to LSNRCTL,
- type "help"
- for information.LSNRCTL > trace user--用户级别的traceConnecting to(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = oracle)(PORT = 1521))) //trace文件位置Opened trace file: /u01/app/oracle/diag/tnslsnr/oracle/listener/trace/ora_5831_140524026951424.trc The command completed successfullyLSNRCTL>
再开启第三个窗口登陆数据库
- [oracle@oracle ~]$ tail -100f
- /u01/app/oracle/diag/tnslsnr/oracle/listener/trace/ora_5831_140524026951424.trc
看第二个窗口可以看到
- [oracle@oracle~] $ sqlplus u1 / u1@oraclSQL * Plus: Release 11.2.0.4.0 Production on Sun Feb 12 19 : 38 : 52 2017Copyright(c) 1982,
- 2013,
- Oracle.All rights reserved.Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit ProductionWith the Partitioning,
- OLAP,
- Data Mining and Real Application Testing optionsSQL >
- 2017 - 02 - 12 19 : 42 : 18.314043 : nstoSetupTimeout: ATO enabled
- for ctx = 0x0xe76d20,
- val = 60000(millisecs) 2017 - 02 - 12 19 : 42 : 18.314587 : nstoUpdateActive: Active timeout is 0(see nstotyp) 2017 - 02 - 12 19 : 42 : 18.314697 : nsopen: opening transport...2017 - 02 - 12 19 : 42 : 18.314735 : nttcnp: getting sockname2017 - 02 - 12 19 : 42 : 18.314792 : nttcnp: getting peername2017 - 02 - 12 19 : 42 : 18.314888 : nttcnr: waiting to accept a connection.2017 - 02 - 12 19 : 42 : 18.314923 : nttcnr: getting sockname2017 - 02 - 12 19 : 42 : 18.314953 : nttcnr: connected on ipaddr 192.168.56.102017 - 02 - 12 19 : 42 : 18.315083 : nttcon: set TCP_NODELAY on 132017 - 02 - 12 19 : 42 : 18.315113 : nsopen: transport is open2017 - 02 - 12 19 : 42 : 18.315324 : nsnainit: inf - >nsinfflg[0] : 0xd inf - >nsinfflg[1] : 0xd2017 - 02 - 12 19 : 42 : 18.315442 : nsopen: global context check - in(to slot 5) complete2017 - 02 - 12 19 : 42 : 18.315482 : nsanswer: deferring connect attempt;
- at stage 52017 - 02 - 12 19 : 42 : 18.315553 : nscon: doing connect handshake...2017 - 02 - 12 19 : 42 : 18.315737 : nscon: got NSPTCN packet2017 - 02 - 12 19 : 42 : 18.315777 : nsevdansw: exit2017 - 02 - 12 19 : 42 : 18.315967 : nstoClearTimeout: ATO disabled
- for ctx = 0x0xe76d202017 - 02 - 12 19 : 42 : 18.316001 : nstoUpdateActive: Active timeout is - 1(see nstotyp) 2017 - 02 - 12 19 : 42 : 18.316025 : nstoControlATO: ATO disabled
- for ctx = 0x0xe76d202017 - 02 - 12 19 : 42 : 18.316094 : nsglbgetRSPidx: returning ecode = 02017 - 02 - 12 19 : 42 : 18.316170 : nsglbgetSdPidx: secondary protocol = 42017 - 02 - 12 19 : 42 : 18.316310 : nsbeqaddr: connecting...2017 - 02 - 12 19 : 42 : 18.316353 : nsopen: opening transport...2017 - 02 - 12 19 : 42 : 18.316573 : sntpcall: detaching from parent with additional fork2017 - 02 - 12 19 : 42 : 18.318583 : sntpcall: hdl[IR] = 21,
- hdl[IW] = 202017 - 02 - 12 19 : 42 : 18.318669 : nsopen: global context check - in(to slot 9) complete2017 - 02 - 12 19 : 42 : 18.335100 : sntpcall: result string is NTP0 74812017 - 02 - 12 19 : 42 : 18.335270 : nsbequeath_stg2: doing connect handshake...2017 - 02 - 12 19 : 42 : 18.335320 : nsbequeath: doing connect handshake...2017 - 02 - 12 19 : 42 : 18.335940 : nsbequeath: NSE = 125862017 - 02 - 12 19 : 42 : 18.335998 : nsbequeath: error reading REDIR / NSE msg2017 - 02 - 12 19 : 42 : 18.336013 : nserror: nsres: id = 5,
- op = 72,
- ns = 12586,
- ns2 = 0; nt[0] = 0,
- nt[1] = 0,
- nt[2] = 0; ora[0] = 0,
- ora[1] = 0,
- ora[2] = 02017 - 02 - 12 19 : 42 : 18.336032 : nscon: sending NSPTRS packet2017 - 02 - 12 19 : 42 : 18.336091 : nstimarmed: no timer allocated2017 - 02 - 12 19 : 42 : 18.336119 : nstoClearTimeout: ATO disabled
- for ctx = 0x0xe7a6402017 - 02 - 12 19 : 42 : 18.336131 : nstoClearTimeout: STO disabled
- for ctx = 0x0xe7a6402017 - 02 - 12 19 : 42 : 18.336143 : nstoClearTimeout: RTO disabled
- for ctx = 0x0xe7a6402017 - 02 - 12 19 : 42 : 18.336154 : nstoClearTimeout: PITO disabled
- for ctx = 0x0xe7a6402017 - 02 - 12 19 : 42 : 18.336164 : nstoUpdateActive: Active timeout is - 1(see nstotyp) 2017 - 02 - 12 19 : 42 : 18.336182 : nsclose: closing transport2017 - 02 - 12 19 : 42 : 18.336258 : nsclose: global context check - out(from slot 9) complete2017 - 02 - 12 19 : 42 : 18.336322 : nstimarmed: no timer allocated2017 - 02 - 12 19 : 42 : 18.336383 : nsclose: closing transport2017 - 02 - 12 19 : 42 : 18.336493 : nsclose: global context check - out( < //
来源: http://www.bubuko.com/infodetail-1950084.html