详细信息可以参考以下信息:
Oracle 网络配置方法
0:安装 xmanager 图形化工具
1:软件工具获取方法: 链接: 密码:m1pn
2:安装步骤:
3:启动:xmanager
1: netca 图形工具
1:启动数据库
---启动 orcl 实例数据库 login: Wed Jun 13 20:48:50 2018 192.168.242.1[root@localhost ~]# su - oracle[oracle@localhost ~]$ export ORACLE_SID=orcl[oracle@localhost ~]$ rlwrap sqlplus / sysdba;*Plus: Release 11.2.0.3.0 Production Wed Jun 13 20:50:39 2018Copyright (c) 1982, 2011, Oracle. rights reserved.Connected an idle instance.SYS@orcl> ;20:50:59 SYS@orcl> startupORACLE instance started.Total System Area 523108352 bytesFixed 1346052 bytesVariable 390071804 bytes Buffers 125829120 bytesRedo Buffers 5861376 bytes mounted. opened.20:51:29 SYS@orcl> ho clear20:51:34 SYS@orcl> instance_name , status v$instance;INSTANCE_NAME STATUS---------------- ------------orcl2:调用客户机的 图形工具
#调用客户机的 图形工具 [oracle@localhost ~]$ export DISPLAY=192.168.242.1:0.0# 调用 oracle 监听设置的 natca 命令 [oracle@localhost ~]$ netcaOracle Net Services Configuration:启动图形界面:
配置监听器:
新增、重新配置、删除、重命名
启动:查看 刚才配置的 监听器信息:
#进入监听命令行[oracle@localhost ~]$ lsnrctlLSNRCTL for Linux: Version 11.2.0.3.0 - Production on 13-JUN-2018 21:31:17Copyright (c) 1991, 2011, Oracle. All rights reserved.Welcome to LSNRCTL, type "help" for information. #查看帮助信息LSNRCTL> helpThe following operations are availableAn asterisk (*) denotes a modifier or extended command:start stop statusservices version reloadsave_config trace spawnchange_password quit exitset* show*#查看 listener_nerorcl 监听状态LSNRCTL> status listener_nerorclTNS-01101: Could not find service name listener_nerorclLSNRCTL> status listener_neworclConnecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost.localdomain)(PORT=1521)))STATUS of the LISTENER------------------------Alias LISTENER_NEWORCLVersion TNSLSNR for Linux: Version 11.2.0.3.0 - ProductionStart Date 13-JUN-2018 21:28:51Uptime 0 days 0 hr. 4 min. 1 secTrace Level offSecurity ON: Local OS AuthenticationSNMP OFFListener Parameter /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.oraListener Log /u01/app/oracle/diag/tnslsnr/localhost/listener_neworcl/alert/log.xmlListening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1521)))Services Summary...Service "ORCLXDB" has 2 instance(s). Instance "neworcl", status READY, has 1 handler(s) for this service... Instance "orcl", status READY, has 1 handler(s) for this service...Service "neworcl" has 1 instance(s). Instance "neworcl", status READY, has 1 handler(s) for this service...Service "orcl" has 1 instance(s). Instance "orcl", status READY, has 1 handler(s) for this service...The command completed successfully#关闭监听 listener_neworclLSNRCTL> stop listener_neworclConnecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost.localdomain)(PORT=1521)))The command completed successfullyLSNRCTL> status listener_neworclConnecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost.localdomain)(PORT=1521)))TNS-12541: TNS:no listener TNS-12560: TNS:protocol adapter error TNS-00511: No listener Linux Error: 111: Connection refused #启动监听 listener_neworclLSNRCTL> start listener_neworclStarting /u01/app/oracle/product/11.2.0/db_1/bin/tnslsnr: please wait...TNSLSNR for Linux: Version 11.2.0.3.0 - ProductionSystem parameter file is /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.oraLog messages written to /u01/app/oracle/diag/tnslsnr/localhost/listener_neworcl/alert/log.xmlListening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1521)))Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost.localdomain)(PORT=1521)))STATUS of the LISTENER------------------------Alias listener_neworclVersion TNSLSNR for Linux: Version 11.2.0.3.0 - ProductionStart Date 13-JUN-2018 21:41:20Uptime 0 days 0 hr. 0 min. 20 secTrace Level offSecurity ON: Local OS AuthenticationSNMP OFFListener Parameter /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.oraListener Log /u01/app/oracle/diag/tnslsnr/localhost/listener_neworcl/alert/log.xmlListening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1521)))The listener supports no servicesThe command completed successfully#查看监听 listener_neworcl 的状态 LSNRCTL> status listener_neworclConnecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost.localdomain)(PORT=1521)))STATUS of the LISTENER------------------------Alias listener_neworclVersion TNSLSNR for Linux: Version 11.2.0.3.0 - ProductionStart Date 13-JUN-2018 21:41:20Uptime 0 days 0 hr. 0 min. 30 secTrace Level offSecurity ON: Local OS AuthenticationSNMP OFFListener Parameter /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.oraListener Log /u01/app/oracle/diag/tnslsnr/localhost/listener_neworcl/alert/log.xmlListening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1521)))The listener supports no servicesThe command completed successfully#查看监听 listener_neworcl 的状态 LSNRCTL> status listener_neworclConnecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost.localdomain)(PORT=1521)))STATUS of the LISTENER------------------------Alias listener_neworclVersion TNSLSNR for Linux: Version 11.2.0.3.0 - ProductionStart Date 13-JUN-2018 21:41:20Uptime 0 days 0 hr. 1 min. 31 secTrace Level offSecurity ON: Local OS AuthenticationSNMP OFFListener Parameter /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.oraListener Log /u01/app/oracle/diag/tnslsnr/localhost/listener_neworcl/alert/log.xmlListening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1521)))Services Summary...Service "ORCLXDB" has 2 instance(s). Instance "neworcl", status READY, has 1 handler(s) for this service... Instance "orcl", status READY, has 1 handler(s) for this service...Service "neworcl" has 1 instance(s). Instance "neworcl", status READY, has 1 handler(s) for this service...Service "orcl" has 1 instance(s). Instance "orcl", status READY, has 1 handler(s) for this service...The command completed successfullyLSNRCTL>配置一个网络服务名:
这个 tnsnames.ora 一般是在 客户端生成的。
这个 listener.ora 一般是要在 服务器端生成
测试:使用 ser_name1 服务名连接:
[oracle@localhost admin]$ rlwrap sqlplus / sysdba;*Plus: Release 11.2.0.3.0 Production Thu Jun 14 00:43:11 2018Copyright (c) 1982, 2011, Oracle. rights reserved.Connected :Oracle 11g Enterprise Edition Release 11.2.0.3.0 - Production the Partitioning, OLAP, Data Mining Application Testing optionsSYS@orcl> ;00:43:18 SYS@orcl> scott identified scott account unlock; altered.00:43:44 SYS@orcl> conn scott/scott@ser_name1Connected.00:44:54 SCOTT@ser_name1>
2:netmar 图形工具
保存后,进行查看 文件信息 。就可以查到刚新增的 监听信息 list_name1
再配置网络服务名:
当启动监听出现下图的问题:检查其 listener.ora 文件信息都没什么问题的情况下,得要检查linux系统的 hostname是否跟你配置的有差异。
然后把监听配置文件信息的 主机地址改为了 linux 系统的hostname 信息 如下图:
这个时候监听启动成功了。而且都是自动注册的服务
3:修改配置文件 文本形式
直接编写这以下的2个文件的信息:
/u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
/u01/app/oracle/product/11.2.0/db_1/network/admin/tnsnames.ora[oracle@localhost admin]$ lslistener1806197PM5534.bak listener.ora samples shrept.lst sqlnet1806197PM5534.bak sqlnet.ora tnsnames.ora oracle@localhost admin]$ pwd/u01/app/oracle/product/11.2.0/db_1/network/admin #---修改前:查看 tnsnames.ora 文件配置信息[oracle@localhost 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.SER_ORCL = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.242.146)(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = orcl) ) )SER_NEWORCL = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.242.146)(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = neworcl) ) )# ---编辑 该文件 oracle@localhost admin]$ vi tnsnames.ora# ---查看配置后的结果信息 [oracle@localhost 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.SER_ORCL = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.242.146)(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = orcl) ) )SER_NEWORCL = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.242.146)(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = neworcl) ) )#---检查服务配置情况 [oracle@localhost admin]$ SQL*Plus: Release 11.2.0.3.0 Production on Tue Jun 19 20:53:14 2018Copyright (c) 1982, 2011, Oracle. All rights reserved.SYS@ser_orcl_1> quit注意:如果是修改了 listener.ora 文件的配置信息,则需要进行 lsnrctl reload 的监听重启操作。
配置文件的目录位置
/u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora/u01/app/oracle/product/11.2.0/db_1/network/admin/tnsnames.ora
服务需要配置 listener.ora
# 1、需要指定侦听器的名称,默认的侦听器的名称为listener# 2、需要指定侦听器的协议,默认的协议是tcp# 3、需要指定侦听器的端口,默认的端口为1521LISTENER = (DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = wl)(PORT = 1521)) ) ) )ADR_BASE_LISTENER = /u01/app/oracle
什么是注册
将数据库当中的实例名(instance_name参数下的值)和服务名(service_names 参数下的值)写入到侦听器的操作就叫做注册
注册分类
动态注册
---在instance 启动的时候PMON 进程根据参数文件中的instance_name和service_names 两个参数,将二个参数的值注册到listener 中。-- instance_name和service_names 两个参数的值什么时候写到listener 中? -- a)过一段时间,将instance_name,service_names 动态注册到listener 中 -- b) 手动写入到listener 中 system register;
静态注册
--将实例名和服务名写到listener 中
如何查看是动态注册?还是静态注册?
---使用lsnrctl status命令查看,如果显示的READY状态,表示动态注册---使用lsnrctl status命令查看,如果显示的UNKNOWN状态,表示静态注册
动态实验操作
1:动态注册 默认端口 1521
请参考 netmgr 的实现操作方式
2:配置动态注册,指定 service_name 的值,将tnsnames.ora 中的 SERVICE_NAME 进行修改并测试
操作步骤参考文档:
-- 1) show parameter service_names system service_names=t1,t2,orcl; show parameter service_names -- 2)修改tnsnames.ora中的SERVICE_NAME的值为t1或者t2,然后测试是否能连接 -- 3)alter system set service_names=t1,t2; show parameter service_names具体操作实操:
login: Wed Jun 20 21:38:41 2018 192.168.242.1[root@localhost ~]# su - oracle[oracle@localhost ~]$ echo $ORACLE_SIDorcl[oracle@localhost ~]$ rlwrap sqlplus / sysdba;*Plus: Release 11.2.0.3.0 Production Wed Jun 20 21:39:21 2018Copyright (c) 1982, 2011, Oracle. rights reserved.Connected an idle instance.SYS@orcl> startupORACLE instance started.Total System Area 523108352 bytesFixed 1346052 bytesVariable 390071804 bytes Buffers 125829120 bytesRedo Buffers 5861376 bytes mounted. opened.SYS@orcl> instance_name ,status v$instance;INSTANCE_NAME STATUS---------------- ------------orcl SYS@orcl> ho lsnrctl statusLSNRCTL Linux: Version 11.2.0.3.0 - Production 20-JUN-2018 21:40:55Copyright (c) 1991, 2011, Oracle. rights reserved.Connecting (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost.localdomain)(PORT=1521)))TNS-12541: TNS: listener TNS-12560: TNS:protocol adapter error TNS-00511: listener Linux Error: 111: refusedConnecting (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(=EXTPROC1521)))TNS-12541: TNS: listener TNS-12560: TNS:protocol adapter error TNS-00511: listener Linux Error: 111: refusedSYS@orcl> ho lsnrctl startLSNRCTL Linux: Version 11.2.0.3.0 - Production 20-JUN-2018 21:41:09Copyright (c) 1991, 2011, Oracle. rights reserved.Starting /u01/app/oracle/product/11.2.0/db_1/bin/tnslsnr: please wait...TNSLSNR Linux: Version 11.2.0.3.0 - ProductionSystem parameter /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.oraLog messages written /u01/app/oracle/diag/tnslsnr/localhost/listener/alert/log.xmlListening : (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1521)))Listening : (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(=EXTPROC1521)))Connecting (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost.localdomain)(PORT=1521)))STATUS the LISTENER------------------------Alias LISTENERVersion TNSLSNR Linux: Version 11.2.0.3.0 - ProductionStart 20-JUN-2018 21:41:11Uptime 0 days 0 hr. 0 . 20 secTrace Security : OS AuthenticationSNMP Listener Parameter /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.oraListener Log /u01/app/oracle/diag/tnslsnr/localhost/listener/alert/log.xmlListening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1521))) (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(=EXTPROC1521)))The listener supports servicesThe command completed successfullySYS@orcl> ho lsnrctl statusLSNRCTL Linux: Version 11.2.0.3.0 - Production 20-JUN-2018 21:41:38Copyright (c) 1991, 2011, Oracle. rights reserved.Connecting (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost.localdomain)(PORT=1521)))STATUS the LISTENER------------------------Alias LISTENERVersion TNSLSNR Linux: Version 11.2.0.3.0 - ProductionStart 20-JUN-2018 21:41:11Uptime 0 days 0 hr. 0 . 27 secTrace Security : OS AuthenticationSNMP Listener Parameter /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.oraListener Log /u01/app/oracle/diag/tnslsnr/localhost/listener/alert/log.xmlListening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1521))) (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(=EXTPROC1521)))Services Summary...Service "neworcl" has 1 instance(s). Instance "neworcl", status READY, has 1 handler(s) this service...Service "orcl" has 1 instance(s). Instance "orcl", status READY, has 1 handler(s) this service...Service "orclXDB" has 2 instance(s). Instance "neworcl", status READY, has 1 handler(s) this service... Instance "orcl", status READY, has 1 handler(s) this service...The command completed successfullySYS@orcl> show parameter serviceNAME TYPE ------------------------------------ ----------- ------------------------------service_names string orclSYS@orcl> ho cat /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora# listener.ora Network Configuration : /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora# Generated Oracle configuration tools.LISTENER = (DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = localhost.localdomain)(PORT = 1521)) (ADDRESS = (PROTOCOL = IPC)( = EXTPROC1521)) ) )ADR_BASE_LISTENER = /u01/app/oracleSYS@orcl> ho ls /u01/app/oracle/product/11.2.0/db_1/network/adminlistener.ora samples shrept.lst sqlnet.oraSYS@orcl> system service_name = orcl_1,orcl_2,orcl_3,orcl; system service_name = orcl_1,orcl_2,orcl_3,orcl *ERROR line 1:ORA-02065: illegal SYSTEMSYS@orcl> system service_names = orcl_1,orcl_2,orcl_3,orcl;System altered.SYS@orcl> show parameter serviceNAME TYPE ------------------------------------ ----------- ------------------------------service_names string ORCL_1, ORCL_2, ORCL_3, ORCLSYS@orcl> ho touch /u01/app/oracle/product/11.2.0/db_1/network/admin/tnsnames.oraSYS@orcl> ho ls /u01/app/oracle/product/11.2.0/db_1/network/admin/tnsnames.ora/u01/app/oracle/product/11.2.0/db_1/network/admin/tnsnames.oraSYS@orcl> ho ls /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora samples shrept.lst sqlnet.ora tnsnames.oraSYS@orcl> ho vi /u01/app/oracle/product/11.2.0/db_1/network/admin/tnsnames.ora )# Generated Oracle configuration tools.orcl_1 = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS =(PROTOCOL = TCP )(HOST = 192.168.242.146)(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = orcl_1) ) )~~~~~~~~~~~~"/u01/app/oracle/product/11.2.0/db_1/network/admin/tnsnames.ora" 14L, 230C writtenSYS@orcl> ho cat /u01/app/oracle/product/11.2.0/db_1/network/admin/tnsnames.ora# Generated Oracle configuration tools.orcl_1 = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS =(PROTOCOL = TCP )(HOST = 192.168.242.146)(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = orcl_1) ) )SYS@orcl> ho lsnrctl reloadLSNRCTL Linux: Version 11.2.0.3.0 - Production 20-JUN-2018 21:49:54Copyright (c) 1991, 2011, Oracle. rights reserved.Connecting (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost.localdomain)(PORT=1521)))The command completed successfullySYS@orcl> ho lsnrctl statusLSNRCTL Linux: Version 11.2.0.3.0 - Production 20-JUN-2018 21:50:06Copyright (c) 1991, 2011, Oracle. rights reserved.Connecting (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost.localdomain)(PORT=1521)))STATUS the LISTENER------------------------Alias LISTENERVersion TNSLSNR Linux: Version 11.2.0.3.0 - ProductionStart 20-JUN-2018 21:41:11Uptime 0 days 0 hr. 8 . 54 secTrace Security : OS AuthenticationSNMP Listener Parameter /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.oraListener Log /u01/app/oracle/diag/tnslsnr/localhost/listener/alert/log.xmlListening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1521))) (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(=EXTPROC1521)))Services Summary...Service "ORCL_1" has 1 instance(s). Instance "orcl", status READY, has 1 handler(s) this service...Service "ORCL_2" has 1 instance(s). Instance "orcl", status READY, has 1 handler(s) this service...Service "ORCL_3" has 1 instance(s). Instance "orcl", status READY, has 1 handler(s) this service...Service "neworcl" has 1 instance(s). Instance "neworcl", status READY, has 1 handler(s) this service...Service "orcl" has 1 instance(s). Instance "orcl", status READY, has 1 handler(s) this service...Service "orclXDB" has 2 instance(s). Instance "neworcl", status READY, has 1 handler(s) this service... Instance "orcl", status READY, has 1 handler(s) this service...The command completed successfullySYS@orcl> conn sys/oracle@ORCL_1 sysdba;Connected.SYS@ORCL_1>SYS@ORCL_1> conn sys/oracle@ORCL_2 sysdba;ERROR:ORA-12154: TNS:could resolve the identifier specifiedWarning: You longer connected ORACLE.@>注:因为 ORCL_2 在 tnsnames.ora中并没有配置所以,此处访问并没有成功
@> quit[oracle@localhost ~]$ rlwrap sqlplus / sysdba;*Plus: Release 11.2.0.3.0 Production Wed Jun 20 21:58:18 2018Copyright (c) 1982, 2011, Oracle. rights reserved.Connected :Oracle 11g Enterprise Edition Release 11.2.0.3.0 - Production the Partitioning, OLAP, Data Mining Application Testing optionsSYS@orcl> ho vi /u01/app/oracle/product/11.2.0/db_1/network/admin/tnsnames.ora# Generated Oracle configuration tools.orcl_1 = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS =(PROTOCOL = TCP )(HOST = 192.168.242.146)(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = orcl_1) ) )orcl_2 = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS =(PROTOCOL = TCP )(HOST = 192.168.242.146)(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = orcl_2) ) )orcl_3 = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS =(PROTOCOL = TCP )(HOST = 192.168.242.146)(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = orcl_3) ) )orcl = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS =(PROTOCOL = TCP )(HOST = 192.168.242.146)(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = orcl) ) )"/u01/app/oracle/product/11.2.0/db_1/network/admin/tnsnames.ora" 41L, 775C writtenSYS@orcl> ho lsnrctl reloadLSNRCTL Linux: Version 11.2.0.3.0 - Production 20-JUN-2018 21:59:32Copyright (c) 1991, 2011, Oracle. rights reserved.Connecting (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost.localdomain)(PORT=1521)))The command completed successfullySYS@orcl> ho lsnrctl statusLSNRCTL Linux: Version 11.2.0.3.0 - Production 20-JUN-2018 21:59:45Copyright (c) 1991, 2011, Oracle. rights reserved.Connecting (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost.localdomain)(PORT=1521)))STATUS the LISTENER------------------------Alias LISTENERVersion TNSLSNR Linux: Version 11.2.0.3.0 - ProductionStart 20-JUN-2018 21:41:11Uptime 0 days 0 hr. 18 . 33 secTrace Security : OS AuthenticationSNMP Listener Parameter /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.oraListener Log /u01/app/oracle/diag/tnslsnr/localhost/listener/alert/log.xmlListening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1521))) (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(=EXTPROC1521)))Services Summary...Service "ORCLXDB" has 2 instance(s). Instance "neworcl", status READY, has 1 handler(s) this service... Instance "orcl", status READY, has 1 handler(s) this service...Service "ORCL_1" has 1 instance(s). Instance "orcl", status READY, has 1 handler(s) this service...Service "ORCL_2" has 1 instance(s). Instance "orcl", status READY, has 1 handler(s) this service...Service "ORCL_3" has 1 instance(s). Instance "orcl", status READY, has 1 handler(s) this service...Service "neworcl" has 1 instance(s). Instance "neworcl", status READY, has 1 handler(s) this service...Service "orcl" has 1 instance(s). Instance "orcl", status READY, has 1 handler(s) this service...The command completed successfullySYS@orcl> ho cat /u01/app/oracle/product/11.2.0/db_1/network/admin/tnsnames.ora# Generated Oracle configuration tools.orcl_1 = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS =(PROTOCOL = TCP )(HOST = 192.168.242.146)(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = orcl_1) ) )orcl_2 = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS =(PROTOCOL = TCP )(HOST = 192.168.242.146)(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = orcl_2) ) )orcl_3 = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS =(PROTOCOL = TCP )(HOST = 192.168.242.146)(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = orcl_3) ) )orcl = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS =(PROTOCOL = TCP )(HOST = 192.168.242.146)(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = orcl) ) )SYS@orcl> conn sys/oracle@ORCL_2 sysdba;Connected.SYS@ORCL_2> conn sys/oracle@ORCL_3 sysdba;Connected.SYS@ORCL_3> conn sys/oracle@ORCL sysdba;Connected.SYS@ORCL>SYS@ORCL_3> conn sys/oracle@ORCL sysdba;Connected.SYS@ORCL> instance_name ,status v$instacne; instance_name ,status v$instacne *ERROR line 1:ORA-00942: does existSYS@ORCL> startupORA-01081: cannot start already-running ORACLE - shut it down SYS@ORCL> instance_name,status v$instance;INSTANCE_NAME STATUS---------------- ------------orcl SYS@ORCL> show parameter serviceNAME TYPE ------------------------------------ ----------- ------------------------------service_names string ORCL_1, ORCL_2, ORCL_3, ORCLSYS@ORCL> conn sys/oracle@ORCL_3 sysdba;Connected.SYS@ORCL_3> instance_name,status v$instance;INSTANCE_NAME STATUS---------------- ------------orcl SYS@ORCL_3> show parameter serviceNAME TYPE ------------------------------------ ----------- ------------------------------service_names string ORCL_1, ORCL_2, ORCL_3, ORCLSYS@ORCL_3> conn sys/oracle@ORCL_2 sysdba;Connected.SYS@ORCL_2> instance_name,status v$instance;INSTANCE_NAME STATUS---------------- ------------orcl SYS@ORCL_2> show parameter serviceNAME TYPE ------------------------------------ ----------- ------------------------------service_names string ORCL_1, ORCL_2, ORCL_3, ORCLSYS@ORCL_2>另外一种方式:如果 把 service_names 中 包含该数据库实例名 togogo 去掉,从原有值集合中 A1 ,A2 ,A3, TOGOGO
删除 togogo 的值,然后在把 tnsnames.ora 中的ww 服务中的service_name的值修改为 togogo后。再重启 监听服务 lsnrctl reload.
接着用 sqlplus 的方式进行连接。也是可以连接成功的。原因是:该数据库的实例名称 为 togogo.同时其数据库的service_name的值也是为 togogo.
也就是这2者的值一致的。即使再 系统参数中 的service_name中没有指定 togogo 该值。也是可以使用 实例名进行配置tnsname.ora中的某个服务的service_name的值的。反之,如果 service_name 之中的值 和 数据库实例的值再 tnsnames.ora中的配置信息中的 service_name中没有出现,而是其他的值,则 tnsname.ora 中的 服务是无法成功的服务数据库的。
3、配置动态注册,在listener侦听器中设置多个地址(不同端口)
--LISTENER = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.10)(PORT = 1521)) (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.10)(PORT = 1522)) (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.10)(PORT = 1523)) )ADR_BASE_LISTENER = /u01/app/oracleTOGOGO = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.10)(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = orcl) ) )wl = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.10)(PORT = 1522)) ) (CONNECT_DATA = (SERVICE_NAME = orcl) ) )aa = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.10)(PORT = 1523)) ) (CONNECT_DATA = (SERVICE_NAME = orcl) ) )实际操作实验:
login: Thu Jun 7 23:43:19 2018 192.168.242.1[root@localhost ~]# su - oracle[oracle@localhost ~]$ echo $ORACLE_SIDorcl[oracle@localhost ~]$ rlwrap sqlplus / sysdba;*Plus: Release 11.2.0.3.0 Production Wed Jun 20 22:58:37 2018Copyright (c) 1982, 2011, Oracle. rights reserved.Connected an idle instance.SYS@orcl> startupORACLE instance started.Total System Area 523108352 bytesFixed 1346052 bytesVariable 390071804 bytes Buffers 125829120 bytesRedo Buffers 5861376 bytes mounted. opened.SYS@orcl> instacnce_name ,status v$instance; instacnce_name ,status v$instance *ERROR line 1:ORA-00904: "INSTACNCE_NAME": invalid identifierSYS@orcl> instance_name ,status v$instance;INSTANCE_NAME STATUS---------------- ------------orcl SYS@orcl> ho ls /u01/app/oracle/product/11.2.0/db_1/network/adminlistener.ora samples shrept.lst sqlnet.oraSYS@orcl> ho cat /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora# listener.ora Network Configuration : /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora# Generated Oracle configuration tools.LISTENER = (DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = localhost.localdomain)(PORT = 1521)) (ADDRESS = (PROTOCOL = IPC)( = EXTPROC1521)) ) )ADR_BASE_LISTENER = /u01/app/oracleSYS@orcl> ho vi /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora# listener.ora Network Configuration : /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora# Generated Oracle configuration tools.LISTENER = (DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = localhost.localdomain)(PORT = 1521)) (ADDRESS = (PROTOCOL = TCP)(HOST = localhost.localdomain)(PORT = 1522)) (ADDRESS = (PROTOCOL = TCP)(HOST = localhost.localdomain)(PORT = 1523)) (ADDRESS = (PROTOCOL = TCP)(HOST = localhost.localdomain)(PORT = 1524)) (ADDRESS = (PROTOCOL = TCP)(HOST = localhost.localdomain)(PORT = 1525)) (ADDRESS = (PROTOCOL = TCP)(HOST = localhost.localdomain)(PORT = 1526)) (ADDRESS = (PROTOCOL = IPC)( = EXTPROC1521)) ) )ADR_BASE_LISTENER = /u01/app/oracle~~~~~~~~"/u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora" 18L, 772C writtenSYS@orcl> ho cat /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora# listener.ora Network Configuration : /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora# Generated Oracle configuration tools.LISTENER = (DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = localhost.localdomain)(PORT = 1521)) (ADDRESS = (PROTOCOL = TCP)(HOST = localhost.localdomain)(PORT = 1522)) (ADDRESS = (PROTOCOL = TCP)(HOST = localhost.localdomain)(PORT = 1523)) (ADDRESS = (PROTOCOL = TCP)(HOST = localhost.localdomain)(PORT = 1524)) (ADDRESS = (PROTOCOL = TCP)(HOST = localhost.localdomain)(PORT = 1525)) (ADDRESS = (PROTOCOL = TCP)(HOST = localhost.localdomain)(PORT = 1526)) (ADDRESS = (PROTOCOL = IPC)( = EXTPROC1521)) ) )ADR_BASE_LISTENER = /u01/app/oracleSYS@orcl> ho ls /u01/app/oracle/product/11.2.0/db_1/network/adminlistener.ora samples shrept.lst sqlnet.oraSYS@orcl> ho touch /u01/app/oracle/product/11.2.0/db_1/network/admin/tnsnames.oraSYS@orcl> ho ls /u01/app/oracle/product/11.2.0/db_1/network/adminlistener.ora samples shrept.lst sqlnet.ora tnsnames.oraSYS@orcl> ho vi /u01/app/oracle/product/11.2.0/db_1/network/admin/tnsnames.ora )# Generated oracle configuration tools.orcl_1521 = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.242.146)(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = orcl ) ) )orcl_1522 = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.242.146)(PORT = 1522)) ) (CONNECT_DATA = (SERVICE_NAME = orcl ) ) ))orcl_1523 = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.242.146)(PORT = 1523)) ) ) ))orcl_1524 = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.242.146)(PORT = 1524)) ) (CONNECT_DATA = (SERVICE_NAME = orcl ) ) ))orcl_1525 = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.242.146)(PORT = 1525)) ) (CONNECT_DATA = (SERVICE_NAME = orcl ) ) ))orcl_1526 = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.242.146)(PORT = 1526)) ) (CONNECT_DATA = (SERVICE_NAME = orcl ) ) )neworcl_1521 = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.242.146)(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = neworcl ) ) )neworcl_1522 = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.242.146)(PORT = 1522)) ) (CONNECT_DATA = (SERVICE_NAME = neworcl ) ) ))neworcl_1523 = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.242.146)(PORT = 1523)) ) ) ))neworcl_1524 = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.242.146)(PORT = 1524)) ) (CONNECT_DATA = (SERVICE_NAME = neworcl ) ) ))neworcl_1525 = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.242.146)(PORT = 1525)) ) (CONNECT_DATA = (SERVICE_NAME = neworcl ) ) ))neworcl_1526 = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.242.146)(PORT = 1526)) ) (CONNECT_DATA = (SERVICE_NAME = neworcl ) ) )"/u01/app/oracle/product/11.2.0/db_1/network/admin/tnsnames.ora" 117L, 2217C writtenSYS@orcl> ho cat /u01/app/oracle/product/11.2.0/db_1/network/admin/tnsnames.oraracle configuration tools.orcl_1521 = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.242.146)(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = orcl ) ) )orcl_1522 = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.242.146)(PORT = 1522)) ) (CONNECT_DATA = (SERVICE_NAME = orcl ) ) ))orcl_1523 = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.242.146)(PORT = 1523)) ) (CONNECT_DATA = (SERVICE_NAME = orcl ) ) ))orcl_1524 = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.242.146)(PORT = 1524)) ) (CONNECT_DATA = (SERVICE_NAME = orcl ) ) ))orcl_1525 = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.242.146)(PORT = 1525)) ) (CONNECT_DATA = (SERVICE_NAME = orcl ) ) ))orcl_1526 = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.242.146)(PORT = 1526)) ) (CONNECT_DATA = (SERVICE_NAME = orcl ) ) )neworcl_1521 = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.242.146)(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = neworcl ) ) )neworcl_1522 = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.242.146)(PORT = 1522)) ) (CONNECT_DATA = (SERVICE_NAME = neworcl ) ) ))neworcl_1523 = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.242.146)(PORT = 1523)) ) (CONNECT_DATA = (SERVICE_NAME = neworcl ) ) ))neworcl_1524 = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.242.146)(PORT = 1524)) ) (CONNECT_DATA = (SERVICE_NAME = neworcl ) ) ))neworcl_1525 = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.242.146)(PORT = 1525)) ) (CONNECT_DATA = (SERVICE_NAME = neworcl ) ) ))neworcl_1526 = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.242.146)(PORT = 1526)) ) (CONNECT_DATA = (SERVICE_NAME = neworcl ) ) )SYS@orcl> ho cat /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora# listener.ora Network Configuration : /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora# Generated Oracle configuration tools.LISTENER = (DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = localhost.localdomain)(PORT = 1521)) (ADDRESS = (PROTOCOL = TCP)(HOST = localhost.localdomain)(PORT = 1522)) (ADDRESS = (PROTOCOL = TCP)(HOST = localhost.localdomain)(PORT = 1523)) (ADDRESS = (PROTOCOL = TCP)(HOST = localhost.localdomain)(PORT = 1524)) (ADDRESS = (PROTOCOL = TCP)(HOST = localhost.localdomain)(PORT = 1525)) (ADDRESS = (PROTOCOL = TCP)(HOST = localhost.localdomain)(PORT = 1526)) (ADDRESS = (PROTOCOL = IPC)( = EXTPROC1521)) ) )ADR_BASE_LISTENER = /u01/app/oracleSYS@orcl> INSTANCE_NAME ,STATUS V$INSTANCE;INSTANCE_NAME STATUS---------------- ------------orcl SYS@orcl> quitDisconnected Oracle 11g Enterprise Edition Release 11.2.0.3.0 - Production the Partitioning, OLAP, Data Mining Application Testing options[oracle@localhost ~]$ lsnrctlLSNRCTL Linux: Version 11.2.0.3.0 - Production 20-JUN-2018 23:21:05Copyright (c) 1991, 2011, Oracle. rights reserved.Welcome LSNRCTL, type "help" information.LSNRCTL> start LISTENERTNS-01106: Listener listener name LISTENER has already been startedLSNRCTL> reloadConnecting (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost.localdomain)(PORT=1521)))The command completed successfullyLSNRCTL> stopConnecting (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost.localdomain)(PORT=1521)))The command completed successfullyLSNRCTL> startStarting /u01/app/oracle/product/11.2.0/db_1/bin/tnslsnr: please wait...TNSLSNR Linux: Version 11.2.0.3.0 - ProductionSystem parameter /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.oraLog messages written /u01/app/oracle/diag/tnslsnr/localhost/listener/alert/log.xmlListening : (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1521)))Listening : (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1522)))Listening : (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1523)))Listening : (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1524)))Listening : (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1525)))Listening : (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1526)))Listening : (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(=EXTPROC1521)))Connecting (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost.localdomain)(PORT=1521)))STATUS the LISTENER------------------------Alias LISTENERVersion TNSLSNR Linux: Version 11.2.0.3.0 - ProductionStart 20-JUN-2018 23:26:36Uptime 0 days 0 hr. 2 . 0 secTrace Security : OS AuthenticationSNMP Listener Parameter /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.oraListener Log /u01/app/oracle/diag/tnslsnr/localhost/listener/alert/log.xmlListening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1521))) (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1522))) (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1523))) (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1524))) (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1525))) (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1526))) (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(=EXTPROC1521)))Services Summary...Service "neworcl" has 1 instance(s). Instance "neworcl", status READY, has 1 handler(s) this service...Service "orcl" has 1 instance(s). Instance "orcl", status READY, has 1 handler(s) this service...Service "orclXDB" has 2 instance(s). Instance "neworcl", status READY, has 1 handler(s) this service... Instance "orcl", status READY, has 1 handler(s) this service...The command completed successfullyLSNRCTL> quit[oracle@localhost ~]$ rlwrap sqlplus / sysdba;*Plus: Release 11.2.0.3.0 Production Wed Jun 20 23:34:24 2018Copyright (c) 1982, 2011, Oracle. rights reserved.Connected :Oracle 11g Enterprise Edition Release 11.2.0.3.0 - Production the Partitioning, OLAP, Data Mining Application Testing optionsSYS@orcl> conn sys/oracle@orcl_1521 sysdba;Connected.SYS@orcl_1521> instance_name ,status v$instance;INSTANCE_NAME STATUS---------------- ------------orcl SYS@orcl_1521> conn sys/oracle@orcl_1522 sysdba;Connected.SYS@orcl_1522> instance_name ,status v$instance;INSTANCE_NAME STATUS---------------- ------------orcl SYS@orcl_1522> conn sys/oracle@orcl_1523 sysdba;Connected.SYS@orcl_1523> instance_name ,status v$instance;INSTANCE_NAME STATUS---------------- ------------orcl SYS@orcl_1523> conn sys/oracle@orcl_1524 sysdba;Connected.SYS@orcl_1524> instance_name ,status v$instance;INSTANCE_NAME STATUS---------------- ------------orcl SYS@orcl_1524> conn sys/oracle@orcl_1525 sysdba;Connected.SYS@orcl_1525> instance_name ,status v$instance;INSTANCE_NAME STATUS---------------- ------------orcl SYS@orcl_1525> conn sys/oracle@orcl_1526 sysdba;ERROR:ORA-12154: TNS:could resolve the identifier specifiedWarning: You longer connected ORACLE.@> conn sys/oracle@orcl_1525 sysdba;Connected.SYS@orcl_1525> instance_name ,status v$instance;INSTANCE_NAME STATUS---------------- ------------orcl SYS@orcl_1525> conn sys/oracle@orcl_1526 sysdba;ERROR:ORA-12154: TNS:could resolve the identifier specifiedWarning: You longer connected ORACLE.@> conn sys/oracle@neworcl_1526 sysdba;Connected.SYS@neworcl_1526> instance_name ,status v$instance;INSTANCE_NAME STATUS---------------- ------------neworcl SYS@neworcl_1526> conn sys/oracle@neworcl_1525 sysdba;Connected.SYS@neworcl_1525> instance_name ,status v$instance;INSTANCE_NAME STATUS---------------- ------------neworcl SYS@neworcl_1525> conn sys/oracle@neworcl_1524 sysdba;Connected.SYS@neworcl_1524> instance_name ,status v$instance;INSTANCE_NAME STATUS---------------- ------------neworcl SYS@neworcl_1524> conn sys/oracle@neworcl_1523 sysdba;Connected.SYS@neworcl_1523> instance_name ,status v$instance;INSTANCE_NAME STATUS---------------- ------------neworcl SYS@neworcl_1523> conn sys/oracle@neworcl_1522 sysdba;Connected.SYS@neworcl_1522> instance_name ,status v$instance;INSTANCE_NAME STATUS---------------- ------------neworcl SYS@neworcl_1522> conn sys/oracle@neworcl_1521 sysdba;[2]+ Stopped rlwrap sqlplus / sysdba[oracle@localhost ~]$ rlwrap sqlplus / sysdba;*Plus: Release 11.2.0.3.0 Production Wed Jun 20 23:38:39 2018Copyright (c) 1982, 2011, Oracle. rights reserved.Connected :Oracle 11g Enterprise Edition Release 11.2.0.3.0 - Production the Partitioning, OLAP, Data Mining Application Testing optionsSYS@orcl> quitDisconnected Oracle 11g Enterprise Edition Release 11.2.0.3.0 - Production the Partitioning, OLAP, Data Mining Application Testing options[oracle@localhost ~]$ cd /u01/app/oracle/product/11.2.0/db_1/network/admin/[oracle@localhost admin]$ lslistener.ora samples shrept.lst sqlnet.ora tnsnames.ora[oracle@localhost admin]$ vi tnsnames.oraracle configuration tools.orcl_1521 = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.242.146)(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = orcl ) ) )orcl_1522 = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.242.146)(PORT = 1522)) ) (CONNECT_DATA = (SERVICE_NAME = orcl ) ) ))orcl_1523 = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.242.146)(PORT = 1523)) ) (CONNECT_DATA = (SERVICE_NAME = orcl ) ) ))orcl_1524 = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.242.146)(PORT = 1524)) ) (CONNECT_DATA = (SERVICE_NAME = orcl ) ) ))orcl_1525 = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.242.146)(PORT = 1525)) ) (CONNECT_DATA = (SERVICE_NAME = orcl ) ) ))orcl_1526 = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.242.146)(PORT = 1526)) ) (CONNECT_DATA = (SERVICE_NAME = orcl ) ) )neworcl_1521 = (DESCRIPTION = (ADDRESS_LIST ="tnsnames.ora" 118L, 2218C written[oracle@localhost admin]$ rlwrap sqlplus / sysdba;*Plus: Release 11.2.0.3.0 Production Wed Jun 20 23:39:50 2018Copyright (c) 1982, 2011, Oracle. rights reserved.Connected :Oracle 11g Enterprise Edition Release 11.2.0.3.0 - Production the Partitioning, OLAP, Data Mining Application Testing optionsSYS@orcl> conn sys/oracle@orcl_1526 sysdba;Connected.SYS@orcl_1526> conn sys/oracle@neworcl_1521 sysdba;Connected.SYS@neworcl_1521>注:该配置方法与oracle数据库的系统参数 local_listener 的值并没有多大关系。该参数是否有值对该方式配置的 tnsnames.ora里的服务没有任何影响。
4、配置动态注册,指定多个侦听器,使用非默认端口(修改local_listener参数,将此参数改为网络服务名)
-- LISTENER = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.10)(PORT = 1521)) )LISTENER1 = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.10)(PORT = 1522)) )LISTENER3 = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.10)(PORT = 1523))TOGOGO = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.10)(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = orcl) ) )wl = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.10)(PORT = 1522)) ) (CONNECT_DATA = (SERVICE_NAME = orcl) ) )aa = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.10)(PORT = 1523)) ) (CONNECT_DATA = (SERVICE_NAME = orcl) ) )system local_listener=wl,aa;--测试发现:-- LISTENER1和LISTENER3可以正常使用,LISTENER不能注册使用。[oracle@localhost ~]$ cd /u01/app/oracle/product/11.2.0/db_1/network/admin/[oracle@localhost admin]$ lslistener1806197PM5534.bak listener.ora samples shrept.lst sqlnet1806197PM5534.bak sqlnet.ora tnsnames.ora[oracle@localhost admin]$ cat tnsnames.ora# tnsnames.ora Network Configuration : /u01/app/oracle/product/11.2.0/db_1/network/admin/tnsnames.ora# Generated Oracle configuration tools.SER_ORCL = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.242.146)(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = orcl) ) )SER_NEWORCL = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.242.146)(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = neworcl) ) )ser_orcl_1 = (DESCRIPTION = (ADDRESS_LIST= (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.242.146)(PORT= 1521)) ) (CONNECT_DATA = (SERVICE_NAME = orcl) ) )SER_ORCL1522 = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.242.146)(PORT = 1522)) ) (CONNECT_DATA = (SERVICE_NAME = orcl) ) )SER_NEWORCL1522 = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.242.146)(PORT = 1522)) ) (CONNECT_DATA = (SERVICE_NAME = neworcl) ) )[oracle@localhost admin]$ cat listener.ora# listener.ora Network Configuration : /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora# Generated Oracle configuration tools.LISTENER1 = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = localhost.localdomain)(PORT = 1522)) )LISTENER = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = localhost.localdomain)(PORT = 1521)) )ADR_BASE_LISTENER = /u01/app/oracle[oracle@localhost admin]$ export ORACLE_SID=orcl[oracle@localhost admin]$ echo $ORACLE_SIDorcl[oracle@localhost admin]$ rlwrap sqlplus / sysdba;*Plus: Release 11.2.0.3.0 Production Tue Jun 19 21:38:02 2018Copyright (c) 1982, 2011, Oracle. rights reserved.Connected :Oracle 11g Enterprise Edition Release 11.2.0.3.0 - Production the Partitioning, OLAP, Data Mining Application Testing optionsSYS@orcl> instance_name ,status v$instance;INSTANCE_NAME STATUS---------------- ------------orcl SYS@orcl> show parameter local_listenerNAME TYPE ------------------------------------ ----------- ------------------------------local_listener stringSYS@orcl> system local_listener=SER_ORCL1522;System altered.SYS@orcl> show parameter local_listenerNAME TYPE ------------------------------------ ----------- ------------------------------local_listener string SER_ORCL1522SYS@orcl> ; closed. dismounted.ORACLE instance shut down.SYS@orcl> stratupSP2-0042: command "stratup" - rest line ignored.SYS@orcl> startupORACLE instance started.Total System Area 523108352 bytesFixed 1346052 bytesVariable 390071804 bytes Buffers 125829120 bytesRedo Buffers 5861376 bytes mounted. opened.SYS@orcl> quitDisconnected Oracle 11g Enterprise Edition Release 11.2.0.3.0 - Production the Partitioning, OLAP, Data Mining Application Testing options[oracle@localhost admin]$ lsnrctl reload LISTENER1LSNRCTL Linux: Version 11.2.0.3.0 - Production 19-JUN-2018 21:42:47Copyright (c) 1991, 2011, Oracle. rights reserved.Connecting (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost.localdomain)(PORT=1522)))The command completed successfully[oracle@localhost admin]$ lsnrctl status LISTENER1LSNRCTL Linux: Version 11.2.0.3.0 - Production 19-JUN-2018 21:43:02Copyright (c) 1991, 2011, Oracle. rights reserved.Connecting (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost.localdomain)(PORT=1522)))STATUS the LISTENER------------------------Alias LISTENER1Version TNSLSNR Linux: Version 11.2.0.3.0 - ProductionStart 19-JUN-2018 21:17:19Uptime 0 days 0 hr. 25 . 42 secTrace Security : OS AuthenticationSNMP Listener Parameter /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.oraListener Log /u01/app/oracle/diag/tnslsnr/localhost/listener1/alert/log.xmlListening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1522)))Services Summary...Service "orcl" has 1 instance(s). Instance "orcl", status READY, has 1 handler(s) this service...Service "orclXDB" has 1 instance(s). Instance "orcl", status READY, has 1 handler(s) this service...The command completed successfully[oracle@localhost admin]$ rlwrap sqlplus /nolog;*Plus: Release 11.2.0.3.0 Production Tue Jun 19 21:43:23 2018Copyright (c) 1982, 2011, Oracle. rights reserved.@> conn sys/oracle@SER_ORCL1522 sysdba;Connected.SYS@SER_ORCL1522> conn sys/oracle@SER_ORCL sysdba;ERROR:ORA-12514: TNS:listener does currently know service requested Warning: You longer connected ORACLE.@> quit;[oracle@localhost admin]$ lsnrctl reload LISTENERLSNRCTL Linux: Version 11.2.0.3.0 - Production 19-JUN-2018 21:44:22Copyright (c) 1991, 2011, Oracle. rights reserved.Connecting (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost.localdomain)(PORT=1521)))The command completed successfully[oracle@localhost admin]$ lsnrctl status LISTENERLSNRCTL Linux: Version 11.2.0.3.0 - Production 19-JUN-2018 21:44:35Copyright (c) 1991, 2011, Oracle. rights reserved.Connecting (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost.localdomain)(PORT=1521)))STATUS the LISTENER------------------------Alias LISTENERVersion TNSLSNR Linux: Version 11.2.0.3.0 - ProductionStart 19-JUN-2018 20:07:49Uptime 0 days 1 hr. 36 . 46 secTrace Security : OS AuthenticationSNMP Listener Parameter /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.oraListener Log /u01/app/oracle/diag/tnslsnr/localhost/listener/alert/log.xmlListening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1521)))Services Summary...Service "ORCLXDB" has 1 instance(s). Instance "neworcl", status READY, has 1 handler(s) this service...Service "neworcl" has 1 instance(s). Instance "neworcl", status READY, has 1 handler(s) this service...The command completed successfully[oracle@localhost admin]$ rlwrap sqlplus /nolog;*Plus: Release 11.2.0.3.0 Production Tue Jun 19 21:44:40 2018Copyright (c) 1982, 2011, Oracle. rights reserved.@> conn sys/oracle@SER_ORCL sysdba;ERROR:ORA-12514: TNS:listener does currently know service requested @>[oracle@localhost admin]$ rlwrap sqlplus / sysdba;*Plus: Release 11.2.0.3.0 Production Tue Jun 19 21:46:44 2018Copyright (c) 1982, 2011, Oracle. rights reserved.Connected :Oracle 11g Enterprise Edition Release 11.2.0.3.0 - Production the Partitioning, OLAP, Data Mining Application Testing optionsSYS@orcl> show parameter local_listNAME TYPE ------------------------------------ ----------- ------------------------------local_listener string SER_ORCL1522SYS@orcl> system local_listener=SER_ORCL1522,SER_ORCL;System altered.SYS@orcl> show parameter local_listNAME TYPE ------------------------------------ ----------- ------------------------------local_listener string SER_ORCL1522, SER_ORCLSYS@orcl> quitDisconnected Oracle 11g Enterprise Edition Release 11.2.0.3.0 - Production the Partitioning, OLAP, Data Mining Application Testing options[oracle@localhost admin]$ rlwrap sqlplus / sysdba;*Plus: Release 11.2.0.3.0 Production Tue Jun 19 21:47:43 2018Copyright (c) 1982, 2011, Oracle. rights reserved.Connected :Oracle 11g Enterprise Edition Release 11.2.0.3.0 - Production the Partitioning, OLAP, Data Mining Application Testing optionsSYS@orcl> startu forceSP2-0734: command beginning "startu for..." - rest line ignored.SYS@orcl> startup forceORACLE instance started.Total System Area 523108352 bytesFixed 1346052 bytesVariable 390071804 bytes Buffers 125829120 bytesRedo Buffers 5861376 bytes mounted. opened.SYS@orcl> quitDisconnected Oracle 11g Enterprise Edition Release 11.2.0.3.0 - Production the Partitioning, OLAP, Data Mining Application Testing options[oracle@localhost admin]$ lsnrctl status LISTENERLSNRCTL Linux: Version 11.2.0.3.0 - Production 19-JUN-2018 21:48:26Copyright (c) 1991, 2011, Oracle. rights reserved.Connecting (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost.localdomain)(PORT=1521)))STATUS the LISTENER------------------------Alias LISTENERVersion TNSLSNR Linux: Version 11.2.0.3.0 - ProductionStart 19-JUN-2018 20:07:49Uptime 0 days 1 hr. 40 . 37 secTrace Security : OS AuthenticationSNMP Listener Parameter /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.oraListener Log /u01/app/oracle/diag/tnslsnr/localhost/listener/alert/log.xmlListening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1521)))Services Summary...Service "ORCLXDB" has 2 instance(s). Instance "neworcl", status READY, has 1 handler(s) this service... Instance "orcl", status READY, has 1 handler(s) this service...Service "neworcl" has 1 instance(s). Instance "neworcl", status READY, has 1 handler(s) this service...Service "orcl" has 1 instance(s). Instance "orcl", status READY, has 1 handler(s) this service...The command completed successfully[oracle@localhost admin]$ lsnrctl status LISTENER1LSNRCTL Linux: Version 11.2.0.3.0 - Production 19-JUN-2018 21:48:36Copyright (c) 1991, 2011, Oracle. rights reserved.Connecting (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost.localdomain)(PORT=1522)))STATUS the LISTENER------------------------Alias LISTENER1Version TNSLSNR Linux: Version 11.2.0.3.0 - ProductionStart 19-JUN-2018 21:17:19Uptime 0 days 0 hr. 31 . 16 secTrace Security : OS AuthenticationSNMP Listener Parameter /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.oraListener Log /u01/app/oracle/diag/tnslsnr/localhost/listener1/alert/log.xmlListening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1522)))Services Summary...Service "orcl" has 1 instance(s). Instance "orcl", status READY, has 1 handler(s) this service...Service "orclXDB" has 1 instance(s). Instance "orcl", status READY, has 1 handler(s) this service...The command completed successfully[oracle@localhost admin]$ rlwrap sqlplus /nolog;*Plus: Release 11.2.0.3.0 Production Tue Jun 19 21:48:49 2018Copyright (c) 1982, 2011, Oracle. rights reserved.@> conn sys/oracle@SER_ORCL sysdba;Connected.SYS@SER_ORCL> conn sys/oracle@SER_ORCL1522 sysdba;Connected.SYS@SER_ORCL1522>[oracle@localhost admin]$ rlwrap sqlplus /nolog;*Plus: Release 11.2.0.3.0 Production Tue Jun 19 21:48:49 2018Copyright (c) 1982, 2011, Oracle. rights reserved.@> conn sys/oracle@SER_ORCL sysdba;Connected.SYS@SER_ORCL> conn sys/oracle@SER_ORCL1522 sysdba;Connected.SYS@SER_ORCL1522> instance_name ,status v$instance;INSTANCE_NAME STATUS---------------- ------------orcl SYS@SER_ORCL1522> conn sys/oracle@SER_ORCL sysdba;Connected.SYS@SER_ORCL> instance_name ,status v$instance;INSTANCE_NAME STATUS---------------- ------------orcl SYS@SER_ORCL>同理打开 listener2 listener3的监听信息
查看状态信息 发现:只有 LISTENER 有监听到的注册服务信息;其他的 LISTENER1 LISTENER2 LISTENER3 都没有服务注册信息。因为 LISTENER 是动态注册的 。
注意: LISTENER LISTENER1 LISTENER2 LISTENER3 在修改了local_listener 这个参数值之后,则默认的 LISTENER的监听器就不能再用了。
静态注册实验
1、配置静态注册,默认端口1521
netmgr
login: Thu Jun 7 23:43:19 2018 192.168.242.1[root@localhost ~]# su - oracle[oracle@localhost ~]$ rlwrap sqlplus / sysdba;*Plus: Release 11.2.0.3.0 Production Thu Jun 21 21:10:42 2018Copyright (c) 1982, 2011, Oracle. rights reserved.Connected an idle instance.SYS@orcl> startupORACLE instance started.Total System Area 523108352 bytesFixed 1346052 bytesVariable 390071804 bytes Buffers 125829120 bytesRedo Buffers 5861376 bytes mounted. opened.SYS@orcl> instance_name ,status v$instance;INSTANCE_NAME STATUS---------------- ------------orcl SYS@orcl> ho lsnrctl statusLSNRCTL Linux: Version 11.2.0.3.0 - Production 21-JUN-2018 21:11:55Copyright (c) 1991, 2011, Oracle. rights reserved.Connecting (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost.localdomain)(PORT=1521)))TNS-12541: TNS: listener TNS-12560: TNS:protocol adapter error TNS-00511: listener Linux Error: 111: refusedConnecting (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(=EXTPROC1521)))TNS-12541: TNS: listener TNS-12560: TNS:protocol adapter error TNS-00511: listener Linux Error: 111: refusedSYS@orcl> ho lsnrctl startLSNRCTL Linux: Version 11.2.0.3.0 - Production 21-JUN-2018 21:12:02Copyright (c) 1991, 2011, Oracle. rights reserved.Starting /u01/app/oracle/product/11.2.0/db_1/bin/tnslsnr: please wait...TNSLSNR Linux: Version 11.2.0.3.0 - ProductionSystem parameter /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.oraLog messages written /u01/app/oracle/diag/tnslsnr/localhost/listener/alert/log.xmlListening : (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1521)))Listening : (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(=EXTPROC1521)))Connecting (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost.localdomain)(PORT=1521)))STATUS the LISTENER------------------------Alias LISTENERVersion TNSLSNR Linux: Version 11.2.0.3.0 - ProductionStart 21-JUN-2018 21:12:04Uptime 0 days 0 hr. 0 . 20 secTrace Security : OS AuthenticationSNMP Listener Parameter /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.oraListener Log /u01/app/oracle/diag/tnslsnr/localhost/listener/alert/log.xmlListening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1521))) (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(=EXTPROC1521)))The listener supports servicesThe command completed successfullySYS@orcl> ho lsnrctl statusLSNRCTL Linux: Version 11.2.0.3.0 - Production 21-JUN-2018 21:12:32Copyright (c) 1991, 2011, Oracle. rights reserved.Connecting (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost.localdomain)(PORT=1521)))STATUS the LISTENER------------------------Alias LISTENERVersion TNSLSNR Linux: Version 11.2.0.3.0 - ProductionStart 21-JUN-2018 21:12:04Uptime 0 days 0 hr. 0 . 27 secTrace Security : OS AuthenticationSNMP Listener Parameter /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.oraListener Log /u01/app/oracle/diag/tnslsnr/localhost/listener/alert/log.xmlListening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1521))) (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(=EXTPROC1521)))The listener supports servicesThe command completed successfullySYS@orcl> ho export DISPLAY=192.168.242.1:0.0SYS@orcl> ho echo $ORACLE_SIDorclSYS@orcl> ho netmgr****DISPLAY environment variable ! Oracle Net Manager a GUI tool which requires that DISPLAY specify a location GUI tools can display. export DISPLAY, re-run.SYS@orcl> Disconnected Oracle 11g Enterprise Edition Release 11.2.0.3.0 - Production the Partitioning, OLAP, Data Mining Application Testing options[oracle@localhost ~]$ netmgr****DISPLAY environment variable ! Oracle Net Manager a GUI tool which requires that DISPLAY specify a location GUI tools can display. export DISPLAY, re-run.[oracle@localhost ~]$ export DISPLAY=192.168.242.1:0.0[oracle@localhost ~]$ netmgr解析生成的 静态注册的监听器信息
[oracle@localhost ~]$ netmgr[oracle@localhost ~]$ lsnrctlLSNRCTL Linux: Version 11.2.0.3.0 - Production 21-JUN-2018 21:27:48Copyright (c) 1991, 2011, Oracle. rights reserved.Welcome LSNRCTL, type "help" information.LSNRCTL> stopConnecting (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost.localdomain)(PORT=1521)))The command completed successfullyLSNRCTL> startStarting /u01/app/oracle/product/11.2.0/db_1/bin/tnslsnr: please wait...TNSLSNR Linux: Version 11.2.0.3.0 - ProductionSystem parameter /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.oraLog messages written /u01/app/oracle/diag/tnslsnr/localhost/listener/alert/log.xmlListening : (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1521)))Listening : (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(=EXTPROC1521)))Connecting (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost.localdomain)(PORT=1521)))STATUS the LISTENER------------------------Alias LISTENERVersion TNSLSNR Linux: Version 11.2.0.3.0 - ProductionStart 21-JUN-2018 21:28:04Uptime 0 days 0 hr. 0 . 20 secTrace Security : OS AuthenticationSNMP Listener Parameter /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.oraListener Log /u01/app/oracle/diag/tnslsnr/localhost/listener/alert/log.xmlListening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1521))) (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(=EXTPROC1521)))Services Summary...Service "orcl" has 1 instance(s). Instance "orcl", status , has 1 handler(s) this service...The command completed successfullyLSNRCTL> quit[oracle@localhost ~]$ cd /u01/app/oracle/product/11.2.0/db_1/network/admin/[oracle@localhost admin]$ lslistener.ora samples shrept.lst sqlnet.ora tnsnames.ora[oracle@localhost admin]$ cat listener.ora# listener.ora Network Configuration : /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora# Generated Oracle configuration tools.SID_LIST_LISTENER = (SID_LIST = (SID_DESC = (GLOBAL_DBNAME = orcl) (ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_1) (SID_NAME = orcl) ) )LISTENER = (DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = localhost.localdomain)(PORT = 1521)) ) (DESCRIPTION = (ADDRESS = (PROTOCOL = IPC)( = EXTPROC1521)) ) )ADR_BASE_LISTENER = /u01/app/oracle[oracle@localhost admin]$ lsnrctl statusLSNRCTL Linux: Version 11.2.0.3.0 - Production 21-JUN-2018 21:42:07Copyright (c) 1991, 2011, Oracle. rights reserved.Connecting (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost.localdomain)(PORT=1521)))STATUS the LISTENER------------------------Alias LISTENERVersion TNSLSNR Linux: Version 11.2.0.3.0 - ProductionStart 21-JUN-2018 21:28:04Uptime 0 days 0 hr. 14 . 3 secTrace Security : OS AuthenticationSNMP Listener Parameter /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.oraListener Log /u01/app/oracle/diag/tnslsnr/localhost/listener/alert/log.xmlListening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1521))) (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(=EXTPROC1521)))Services Summary...Service "neworcl" has 1 instance(s). Instance "neworcl", status READY, has 1 handler(s) this service...Service "orcl" has 2 instance(s). Instance "orcl", status , has 1 handler(s) this service... Instance "orcl", status READY, has 1 handler(s) this service...Service "orclXDB" has 2 instance(s). Instance "neworcl", status READY, has 1 handler(s) this service... Instance "orcl", status READY, has 1 handler(s) this service...The command completed successfully[oracle@localhost admin]$ rlwrap sqlplus /nolog;*Plus: Release 11.2.0.3.0 Production Thu Jun 21 21:43:15 2018Copyright (c) 1982, 2011, Oracle. rights reserved.@> conn sys/oracle@orcl_1 sysdba;Connected.SYS@orcl_1>SYS@orcl_1> instance_name ,status v$instance;INSTANCE_NAME STATUS---------------- ------------orcl SYS@orcl_1> quitDisconnected Oracle 11g Enterprise Edition Release 11.2.0.3.0 - Production the Partitioning, OLAP, Data Mining Application Testing options[oracle@localhost admin]$ lslistener.ora samples shrept.lst sqlnet.ora tnsnames.ora[oracle@localhost admin]$ cat tnsnames.ora# tnsnames.ora Network Configuration : /u01/app/oracle/product/11.2.0/db_1/network/admin/tnsnames.ora# Generated Oracle configuration tools.ORCL_1 = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.242.146)(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = orcl) ) )[oracle@localhost admin]$
2、配置静态注册,非默认端口1522
SID_LIST_LISTENER = (SID_LIST = (SID_DESC = (GLOBAL_DBNAME = orcl) (ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_1) (SID_NAME = orcl) ) )LISTENER = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.10)(PORT = 1522)) )ADR_BASE_LISTENER = /u01/app/oracleWL = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.10)(PORT = 1522)) ) (CONNECT_DATA = (SERVICE_NAME = orcl) ) )实验操作:
login: Thu Jun 7 23:43:19 2018 192.168.242.1[root@localhost ~]# su - oracle[oracle@localhost ~]$ rlwrap sqlplus / sysdba;*Plus: Release 11.2.0.3.0 Production Thu Jun 21 22:15:55 2018Copyright (c) 1982, 2011, Oracle. rights reserved.Connected an idle instance.SYS@orcl> startupORACLE instance started.Total System Area 523108352 bytesFixed 1346052 bytesVariable 390071804 bytes Buffers 125829120 bytesRedo Buffers 5861376 bytes mounted. opened.SYS@orcl> instance_name ,status v$instance;INSTANCE_NAME STATUS---------------- ------------orcl SYS@orcl> quitDisconnected Oracle 11g Enterprise Edition Release 11.2.0.3.0 - Production the Partitioning, OLAP, Data Mining Application Testing options[oracle@localhost ~]$ cd /u01/app/oracle/product/11.2.0/db_1/network/admin/[oracle@localhost admin]$ lslistener.ora samples shrept.lst sqlnet.ora[oracle@localhost admin]$ cat listener.ora# listener.ora Network Configuration : /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora# Generated Oracle configuration tools.LISTENER = (DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = localhost.localdomain)(PORT = 1521)) (ADDRESS = (PROTOCOL = IPC)( = EXTPROC1521)) ) )ADR_BASE_LISTENER = /u01/app/oracle[oracle@localhost admin]$ lsnrctl startLSNRCTL Linux: Version 11.2.0.3.0 - Production 21-JUN-2018 22:24:55Copyright (c) 1991, 2011, Oracle. rights reserved.Starting /u01/app/oracle/product/11.2.0/db_1/bin/tnslsnr: please wait...TNSLSNR Linux: Version 11.2.0.3.0 - ProductionSystem parameter /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.oraLog messages written /u01/app/oracle/diag/tnslsnr/localhost/listener/alert/log.xmlListening : (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1521)))Listening : (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(=EXTPROC1521)))Connecting (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost.localdomain)(PORT=1521)))STATUS the LISTENER------------------------Alias LISTENERVersion TNSLSNR Linux: Version 11.2.0.3.0 - ProductionStart 21-JUN-2018 22:24:57Uptime 0 days 0 hr. 0 . 20 secTrace Security : OS AuthenticationSNMP Listener Parameter /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.oraListener Log /u01/app/oracle/diag/tnslsnr/localhost/listener/alert/log.xmlListening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1521))) (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(=EXTPROC1521)))The listener supports servicesThe command completed successfully[oracle@localhost admin]$ lsnrctl statusLSNRCTL Linux: Version 11.2.0.3.0 - Production 21-JUN-2018 22:26:18Copyright (c) 1991, 2011, Oracle. rights reserved.Connecting (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost.localdomain)(PORT=1521)))STATUS the LISTENER------------------------Alias LISTENERVersion TNSLSNR Linux: Version 11.2.0.3.0 - ProductionStart 21-JUN-2018 22:24:57Uptime 0 days 0 hr. 1 . 21 secTrace Security : OS AuthenticationSNMP Listener Parameter /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.oraListener Log /u01/app/oracle/diag/tnslsnr/localhost/listener/alert/log.xmlListening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1521))) (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(=EXTPROC1521)))Services Summary...Service "neworcl" has 1 instance(s). Instance "neworcl", status READY, has 1 handler(s) this service...Service "orcl" has 1 instance(s). Instance "orcl", status READY, has 1 handler(s) this service...Service "orclXDB" has 2 instance(s). Instance "neworcl", status READY, has 1 handler(s) this service... Instance "orcl", status READY, has 1 handler(s) this service...The command completed successfully[oracle@localhost admin]$ cat listener.ora# listener.ora Network Configuration : /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora# Generated Oracle configuration tools.LISTENER = (DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = localhost.localdomain)(PORT = 1521)) (ADDRESS = (PROTOCOL = IPC)( = EXTPROC1521)) ) )ADR_BASE_LISTENER = /u01/app/oracle[oracle@localhost admin]$ vi listener.ora# listener.ora Network Configuration : /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora# Generated Oracle configuration tools.SID_LIST_LISTENER_1 = (SID_LIST = (SID_DESC = (GLOBAL_DBNAME = orcl) (ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_1) (SID_NAME = orcl ) ) )LISTENER_1 = (DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = localhost.localdomain)(PORT = 1522)) (ADDRESS = (PROTOCOL = IPC)( = EXTPROC1521)) ) )"listener.ora" 36L, 745C written[oracle@localhost admin]$ cat listener.ora# listener.ora Network Configuration : /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora# Generated Oracle configuration tools.SID_LIST_LISTENER_1 = (SID_LIST = (SID_DESC = (GLOBAL_DBNAME = orcl) (ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_1) (SID_NAME = orcl ) ) )LISTENER_1 = (DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = localhost.localdomain)(PORT = 1522)) (ADDRESS = (PROTOCOL = IPC)( = EXTPROC1521)) ) )LISTENER = (DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = localhost.localdomain)(PORT = 1521)) (ADDRESS = (PROTOCOL = IPC)( = EXTPROC1521)) ) )ADR_BASE_LISTENER = /u01/app/oracle[oracle@localhost admin]$ lslistener.ora samples shrept.lst sqlnet.ora[oracle@localhost admin]$ touch tnsnames.ora[oracle@localhost admin]$ lslistener.ora samples shrept.lst sqlnet.ora tnsnames.ora[oracle@localhost admin]$ vi tnsnames.oraorcl_1 = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS =(PROTOCOL = TCP)(HOST = 192.168.242.146)(PORT =1522)) ) (CONNECT_DATA = (SERVICE_NAME = orcl) ) )~~~~~~~~~~~~~~~~"tnsnames.ora" 10L, 175C written[oracle@localhost admin]$ cat tnsnames.oraorcl_1 = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS =(PROTOCOL = TCP)(HOST = 192.168.242.146)(PORT =1522)) ) (CONNECT_DATA = (SERVICE_NAME = orcl) ) )[oracle@localhost admin]$ lsnrctl stopLSNRCTL Linux: Version 11.2.0.3.0 - Production 21-JUN-2018 22:46:53Copyright (c) 1991, 2011, Oracle. rights reserved.Connecting (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost.localdomain)(PORT=1521)))The command completed successfully[oracle@localhost admin]$ lsnrctl startLSNRCTL Linux: Version 11.2.0.3.0 - Production 21-JUN-2018 22:47:00Copyright (c) 1991, 2011, Oracle. rights reserved.Starting /u01/app/oracle/product/11.2.0/db_1/bin/tnslsnr: please wait...TNSLSNR Linux: Version 11.2.0.3.0 - ProductionSystem parameter /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.oraLog messages written /u01/app/oracle/diag/tnslsnr/localhost/listener/alert/log.xmlListening : (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1521)))Listening : (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(=EXTPROC1521)))Connecting (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost.localdomain)(PORT=1521)))STATUS the LISTENER------------------------Alias LISTENERVersion TNSLSNR Linux: Version 11.2.0.3.0 - ProductionStart 21-JUN-2018 22:47:01Uptime 0 days 0 hr. 0 . 20 secTrace Security : OS AuthenticationSNMP Listener Parameter /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.oraListener Log /u01/app/oracle/diag/tnslsnr/localhost/listener/alert/log.xmlListening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1521))) (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(=EXTPROC1521)))The listener supports servicesThe command completed successfully[oracle@localhost admin]$ lsnrctl stop LISTENER_1LSNRCTL Linux: Version 11.2.0.3.0 - Production 21-JUN-2018 22:48:04Copyright (c) 1991, 2011, Oracle. rights reserved.Connecting (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost.localdomain)(PORT=1522)))TNS-12541: TNS: listener TNS-12560: TNS:protocol adapter error TNS-00511: listener Linux Error: 111: refusedConnecting (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(=EXTPROC1521)))The command completed successfully[oracle@localhost admin]$ lsnrctl start LISTENER_1LSNRCTL Linux: Version 11.2.0.3.0 - Production 21-JUN-2018 22:48:17Copyright (c) 1991, 2011, Oracle. rights reserved.Starting /u01/app/oracle/product/11.2.0/db_1/bin/tnslsnr: please wait...TNSLSNR Linux: Version 11.2.0.3.0 - ProductionSystem parameter /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.oraLog messages written /u01/app/oracle/diag/tnslsnr/localhost/listener_1/alert/log.xmlListening : (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1522)))Listening : (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(=EXTPROC1521)))Connecting (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost.localdomain)(PORT=1522)))STATUS the LISTENER------------------------Alias LISTENER_1Version TNSLSNR Linux: Version 11.2.0.3.0 - ProductionStart 21-JUN-2018 22:48:19Uptime 0 days 0 hr. 0 . 21 secTrace Security : OS AuthenticationSNMP Listener Parameter /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.oraListener Log /u01/app/oracle/diag/tnslsnr/localhost/listener_1/alert/log.xmlListening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1522))) (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(=EXTPROC1521)))Services Summary...Service "orcl" has 1 instance(s). Instance "orcl", status , has 1 handler(s) this service...The command completed successfully[oracle@localhost admin]$ lsnrctl status LISTENER_1LSNRCTL Linux: Version 11.2.0.3.0 - Production 21-JUN-2018 22:49:45Copyright (c) 1991, 2011, Oracle. rights reserved.Connecting (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost.localdomain)(PORT=1522)))STATUS the LISTENER------------------------Alias LISTENER_1Version TNSLSNR Linux: Version 11.2.0.3.0 - ProductionStart 21-JUN-2018 22:48:19Uptime 0 days 0 hr. 1 . 28 secTrace Security : OS AuthenticationSNMP Listener Parameter /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.oraListener Log /u01/app/oracle/diag/tnslsnr/localhost/listener_1/alert/log.xmlListening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1522))) (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(=EXTPROC1521)))Services Summary...Service "orcl" has 1 instance(s). Instance "orcl", status , has 1 handler(s) this service...The command completed successfully[oracle@localhost admin]$ rlwrap sqlplus /nolog;*Plus: Release 11.2.0.3.0 Production Thu Jun 21 22:50:25 2018Copyright (c) 1982, 2011, Oracle. rights reserved.@> conn sys/oracle@orcl_1 sysdba;Connected.SYS@orcl_1>
3、配置静态注册,配置多个侦听器,非默认端口1522,1523
SID_LIST_LISTENER = (SID_LIST = (SID_DESC = (GLOBAL_DBNAME = orcl) (ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_1) (SID_NAME = orcl) ) )LISTENER = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.10)(PORT = 1522)) )SID_LIST_LISTENER1 = (SID_LIST = (SID_DESC = (GLOBAL_DBNAME = orcl) (ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_1) (SID_NAME = orcl) ) )LISTENER1 = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.10)(PORT = 1523)) )SID_LIST_LISTENER2 = (SID_LIST = (SID_DESC = (GLOBAL_DBNAME = orcl) (ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_1) (SID_NAME = orcl) ) )LISTENER2 = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.10)(PORT = 1524)) )ADR_BASE_LISTENER = /u01/app/oracleWL = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.10)(PORT = 1522)) ) (CONNECT_DATA = (SERVICE_NAME = orcl) ) )aa = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.10)(PORT = 1523)) ) (CONNECT_DATA = (SERVICE_NAME = orcl) ) )bb = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.10)(PORT = 1524)) ) (CONNECT_DATA = (SERVICE_NAME = orcl) ) )实验操作:
4、配置静态注册,配置一个侦听器,多个地址,非默认端口1524,1525
SID_LIST_LISTENER = (SID_LIST = (SID_DESC = (GLOBAL_DBNAME = orcl) (ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_1) (SID_NAME = orcl) ) )LISTENER = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.10)(PORT = 1522)) (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.10)(PORT = 1523)) (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.10)(PORT = 1524)) )WL = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.10)(PORT = 1522)) ) (CONNECT_DATA = (SERVICE_NAME = orcl) ) )aa = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.10)(PORT = 1523)) ) (CONNECT_DATA = (SERVICE_NAME = orcl) ) )bb = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.10)(PORT = 1524)) ) (CONNECT_DATA = (SERVICE_NAME = orcl) ) )
————————————————————————————————————————————————————————————————————————————————————————