/**PageBeginHtml Block Begin **/ /***自定义返回顶部小火箭***/ /*生成博客目录的JS 开始*/ /*生成博客目录的JS 结束*/

Oracle 网络监听配置管理

Oracle 网络配置与管理

详细信息可以参考以下信息:

【学习目标】


Oracle 网络配置方法

0:安装 xmanager 图形化工具

1:软件工具获取方法: 链接:http://pan.baidu.com/s/1gf5cbKn 密码:m1pn

 image

2:安装步骤:

image

image

image

image

image

image

image


image


3:启动:xmanager

image





1: netca 图形工具

1:启动数据库

---启动 orcl 实例数据库

Last login: Wed Jun 13 20:48:50 2018 from 192.168.242.1
[root@localhost ~]# su - oracle
[oracle@localhost ~]$ export ORACLE_SID=orcl
[oracle@localhost ~]$ rlwrap sqlplus / as sysdba;

SQL*Plus: Release 11.2.0.3.0 Production on Wed Jun 13 20:50:39 2018

Copyright (c) 1982, 2011, Oracle.  All rights reserved.

Connected to an idle instance.

SYS@orcl> set time on;


20:50:59 SYS@orcl> startup
ORACLE instance started.

Total System Global Area  523108352 bytes
Fixed Size                  1346052 bytes
Variable Size             390071804 bytes
Database Buffers          125829120 bytes
Redo Buffers                5861376 bytes
Database mounted.
Database opened.
20:51:29 SYS@orcl> ho clear


20:51:34 SYS@orcl> select instance_name , status from v$instance;

INSTANCE_NAME    STATUS
---------------- ------------
orcl             OPEN


2:调用客户机的 图形工具

 #调用客户机的 图形工具 
[oracle@localhost ~]$ export DISPLAY=192.168.242.1:0.0
# 调用 oracle 监听设置的 natca 命令 
[oracle@localhost ~]$ netca

Oracle Net Services Configuration:

启动图形界面:

image


image


配置监听器:

image

新增、重新配置、删除、重命名

image

image

image

image

image

image

image

image

image

启动:查看 刚才配置的 监听器信息:

#进入监听命令行
[oracle@localhost ~]$ lsnrctl

LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 13-JUN-2018 21:31:17

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

Welcome to LSNRCTL, type "help" for information.
 #查看帮助信息
LSNRCTL> help
The following operations are available
An asterisk (*) denotes a modifier or extended command:

start               stop                status
services            version             reload
save_config         trace               spawn
change_password     quit                exit
set*                show*
#查看 listener_nerorcl 监听状态
LSNRCTL> status listener_nerorcl
TNS-01101: Could not find service name listener_nerorcl
LSNRCTL> status  listener_neworcl
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost.localdomain)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER_NEWORCL
Version                   TNSLSNR for Linux: Version 11.2.0.3.0 - Production
Start Date                13-JUN-2018 21:28:51
Uptime                    0 days 0 hr. 4 min. 1 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/localhost/listener_neworcl/alert/log.xml
Listening 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_neworcl
LSNRCTL> stop listener_neworcl
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost.localdomain)(PORT=1521)))
The command completed successfully
LSNRCTL> status listener_neworcl
Connecting 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_neworcl
LSNRCTL> start listener_neworcl
Starting /u01/app/oracle/product/11.2.0/db_1/bin/tnslsnr: please wait...

TNSLSNR for Linux: Version 11.2.0.3.0 - Production
System parameter file is /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
Log messages written to /u01/app/oracle/diag/tnslsnr/localhost/listener_neworcl/alert/log.xml
Listening 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_neworcl
Version                   TNSLSNR for Linux: Version 11.2.0.3.0 - Production
Start Date                13-JUN-2018 21:41:20
Uptime                    0 days 0 hr. 0 min. 20 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/localhost/listener_neworcl/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1521)))
The listener supports no services
The command completed successfully
#查看监听 listener_neworcl 的状态 
LSNRCTL> status listener_neworcl
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost.localdomain)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     listener_neworcl
Version                   TNSLSNR for Linux: Version 11.2.0.3.0 - Production
Start Date                13-JUN-2018 21:41:20
Uptime                    0 days 0 hr. 0 min. 30 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/localhost/listener_neworcl/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1521)))
The listener supports no services
The command completed successfully
#查看监听 listener_neworcl 的状态 
LSNRCTL> status listener_neworcl
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost.localdomain)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     listener_neworcl
Version                   TNSLSNR for Linux: Version 11.2.0.3.0 - Production
Start Date                13-JUN-2018 21:41:20
Uptime                    0 days 0 hr. 1 min. 31 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/localhost/listener_neworcl/alert/log.xml
Listening 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
LSNRCTL>


配置一个网络服务名:

image

image

image

image

image

image

image

image

image

image

image

这个 tnsnames.ora 一般是在 客户端生成的。

这个 listener.ora  一般是要在 服务器端生成


测试:使用 ser_name1 服务名连接:

[oracle@localhost admin]$ rlwrap sqlplus / as sysdba;

SQL*Plus: Release 11.2.0.3.0 Production on Thu Jun 14 00:43:11 2018

Copyright (c) 1982, 2011, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SYS@orcl> set time on;
00:43:18 SYS@orcl> alter user scott identified by scott account unlock;

User altered.

00:43:44 SYS@orcl> conn scott/scott@ser_name1
Connected.
00:44:54 SCOTT@ser_name1>



2:netmar 图形工具

 


image


保存后,进行查看 文件信息 。就可以查到刚新增的 监听信息  list_name1


再配置网络服务名:

image

image

image

image

image

image

image


当启动监听出现下图的问题:检查其 listener.ora 文件信息都没什么问题的情况下,得要检查linux系统的 hostname是否跟你配置的有差异。

imageimage

然后把监听配置文件信息的 主机地址改为了 linux 系统的hostname 信息 如下图:

image

这个时候监听启动成功了。而且都是自动注册的服务

imageimage


image





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]$ ls
listener1806197PM5534.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)
    )
  )

ser_orcl_1 =
  (DESCRIPTION =
    (ADDRESS_LIST=
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.242.146)(PORT= 1521))
    )
    (CONNECT_DATA =
       (SERVICE_NAME = orcl)
    )
   )
#---检查服务配置情况

   [oracle@localhost admin]$ rlwrap sqlplus /nolog;

SQL*Plus: Release 11.2.0.3.0 Production on Tue Jun 19 20:53:14 2018

Copyright (c) 1982, 2011, Oracle.  All rights reserved.

@> conn sys/oracle@ser_orcl_1 as sysdba;
Connected.
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、需要指定侦听器的端口,默认的端口为1521

LISTENER =
  (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 中
        alter system register;



静态注册


--将实例名和服务名写到listener 中




如何查看是动态注册?还是静态注册?


---使用lsnrctl status命令查看,如果显示的READY状态,表示动态注册
---使用lsnrctl status命令查看,如果显示的UNKNOWN状态,表示静态注册


动态实验操作


1:动态注册  默认端口 1521 

请参考 netmgr 的实现操作方式


2:配置动态注册,指定 service_name 的值,将tnsnames.ora 中的 SERVICE_NAME 进行修改并测试

操作步骤参考文档:

 -- 1) show parameter service_names
      alter system set 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
--   4)修改tnsnames.ora中的SERVICE_NAME的值为orcl,然后测试是否能连接

具体操作实操:


Last login: Wed Jun 20 21:38:41 2018 from 192.168.242.1
[root@localhost ~]# su - oracle
[oracle@localhost ~]$ echo $ORACLE_SID
orcl
[oracle@localhost ~]$ rlwrap sqlplus / as sysdba;

SQL*Plus: Release 11.2.0.3.0 Production on Wed Jun 20 21:39:21 2018

Copyright (c) 1982, 2011, Oracle.  All rights reserved.

Connected to an idle instance.

SYS@orcl> startup
ORACLE instance started.

Total System Global Area  523108352 bytes
Fixed Size                  1346052 bytes
Variable Size             390071804 bytes
Database Buffers          125829120 bytes
Redo Buffers                5861376 bytes
Database mounted.
Database opened.
SYS@orcl> select instance_name ,status from v$instance;

INSTANCE_NAME    STATUS
---------------- ------------
orcl             OPEN

SYS@orcl> ho lsnrctl status

LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 20-JUN-2018 21:40:55

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

Connecting 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
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
TNS-12541: TNS:no listener
 TNS-12560: TNS:protocol adapter error
  TNS-00511: No listener
   Linux Error: 111: Connection refused

SYS@orcl> ho lsnrctl start

LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 20-JUN-2018 21:41:09

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

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

TNSLSNR for Linux: Version 11.2.0.3.0 - Production
System parameter file is /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
Log messages written to /u01/app/oracle/diag/tnslsnr/localhost/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1521)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost.localdomain)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.3.0 - Production
Start Date                20-JUN-2018 21:41:11
Uptime                    0 days 0 hr. 0 min. 20 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/localhost/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
The listener supports no services
The command completed successfully

SYS@orcl> ho lsnrctl status

LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 20-JUN-2018 21:41:38

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost.localdomain)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.3.0 - Production
Start Date                20-JUN-2018 21:41:11
Uptime                    0 days 0 hr. 0 min. 27 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/localhost/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Services Summary...
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...
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...
The command completed successfully

SYS@orcl> show parameter service

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
service_names                        string      orcl
SYS@orcl> ho  cat   /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
# listener.ora Network Configuration File: /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
# Generated by Oracle configuration tools.

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = localhost.localdomain)(PORT = 1521))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
    )
  )

ADR_BASE_LISTENER = /u01/app/oracle


SYS@orcl> ho  ls   /u01/app/oracle/product/11.2.0/db_1/network/admin
listener.ora  samples  shrept.lst  sqlnet.ora

SYS@orcl> alter system set service_name = orcl_1,orcl_2,orcl_3,orcl;
alter system set service_name = orcl_1,orcl_2,orcl_3,orcl
                 *
ERROR at line 1:
ORA-02065: illegal option for ALTER SYSTEM


SYS@orcl> alter system set service_names = orcl_1,orcl_2,orcl_3,orcl;

System altered.

SYS@orcl> show parameter service

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
service_names                        string      ORCL_1, ORCL_2, ORCL_3, ORCL
SYS@orcl> ho  touch /u01/app/oracle/product/11.2.0/db_1/network/admin/tnsnames.ora

SYS@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.ora

SYS@orcl> ho  ls /u01/app/oracle/product/11.2.0/db_1/network/admin/
listener.ora  samples  shrept.lst  sqlnet.ora  tnsnames.ora

SYS@orcl> ho  vi  /u01/app/oracle/product/11.2.0/db_1/network/admin/tnsnames.ora


   )
# Generated by 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 written

SYS@orcl> ho  cat  /u01/app/oracle/product/11.2.0/db_1/network/admin/tnsnames.ora
# Generated by 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 reload

LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 20-JUN-2018 21:49:54

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost.localdomain)(PORT=1521)))
The command completed successfully

SYS@orcl> ho lsnrctl status

LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 20-JUN-2018 21:50:06

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost.localdomain)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.3.0 - Production
Start Date                20-JUN-2018 21:41:11
Uptime                    0 days 0 hr. 8 min. 54 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/localhost/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Services Summary...
Service "ORCL_1" has 1 instance(s).
  Instance "orcl", status READY, has 1 handler(s) for this service...
Service "ORCL_2" has 1 instance(s).
  Instance "orcl", status READY, has 1 handler(s) for this service...
Service "ORCL_3" has 1 instance(s).
  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...
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...
The command completed successfully

SYS@orcl> conn  sys/oracle@ORCL_1 as sysdba;
Connected.
SYS@ORCL_1>


SYS@ORCL_1> conn  sys/oracle@ORCL_2 as sysdba;
ERROR:
ORA-12154: TNS:could not resolve the connect identifier specified


Warning: You are no longer connected to ORACLE.
@>

注:因为  ORCL_2 在 tnsnames.ora中并没有配置所以,此处访问并没有成功

@> quit
[oracle@localhost ~]$ rlwrap sqlplus / as sysdba;

SQL*Plus: Release 11.2.0.3.0 Production on Wed Jun 20 21:58:18 2018

Copyright (c) 1982, 2011, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SYS@orcl> ho  vi  /u01/app/oracle/product/11.2.0/db_1/network/admin/tnsnames.ora

# Generated by 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 written

SYS@orcl> ho lsnrctl reload

LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 20-JUN-2018 21:59:32

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost.localdomain)(PORT=1521)))
The command completed successfully

SYS@orcl> ho lsnrctl status

LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 20-JUN-2018 21:59:45

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost.localdomain)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.3.0 - Production
Start Date                20-JUN-2018 21:41:11
Uptime                    0 days 0 hr. 18 min. 33 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/localhost/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
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 "ORCL_1" has 1 instance(s).
  Instance "orcl", status READY, has 1 handler(s) for this service...
Service "ORCL_2" has 1 instance(s).
  Instance "orcl", status READY, has 1 handler(s) for this service...
Service "ORCL_3" has 1 instance(s).
  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

SYS@orcl> ho  cat  /u01/app/oracle/product/11.2.0/db_1/network/admin/tnsnames.ora
# Generated by 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 as sysdba;
Connected.
SYS@ORCL_2> conn  sys/oracle@ORCL_3 as sysdba;
Connected.
SYS@ORCL_3> conn  sys/oracle@ORCL as sysdba;
Connected.
SYS@ORCL>


SYS@ORCL_3> conn  sys/oracle@ORCL as sysdba;
Connected.
SYS@ORCL> select instance_name ,status from v$instacne;
select instance_name ,status from v$instacne
                                  *
ERROR at line 1:
ORA-00942: table or view does not exist


SYS@ORCL> startup
ORA-01081: cannot start already-running ORACLE - shut it down first
SYS@ORCL> select instance_name,status from v$instance;

INSTANCE_NAME    STATUS
---------------- ------------
orcl             OPEN

SYS@ORCL> show parameter service

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
service_names                        string      ORCL_1, ORCL_2, ORCL_3, ORCL
SYS@ORCL> conn  sys/oracle@ORCL_3 as sysdba;
Connected.
SYS@ORCL_3> select instance_name,status from v$instance;

INSTANCE_NAME    STATUS
---------------- ------------
orcl             OPEN

SYS@ORCL_3> show parameter service

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
service_names                        string      ORCL_1, ORCL_2, ORCL_3, ORCL
SYS@ORCL_3> conn  sys/oracle@ORCL_2 as sysdba;
Connected.
SYS@ORCL_2> select instance_name,status from v$instance;

INSTANCE_NAME    STATUS
---------------- ------------
orcl             OPEN

SYS@ORCL_2> show parameter service

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
service_names                        string      ORCL_1, ORCL_2, ORCL_3, ORCL
SYS@ORCL_2>


另外一种方式:如果  把 service_names 中 包含该数据库实例名 togogo 去掉,从原有值集合中 A1 ,A2  ,A3, TOGOGO

删除 togogo 的值,然后在把 tnsnames.ora 中的ww 服务中的service_name的值修改为 togogo后。再重启 监听服务 lsnrctl  reload.

接着用  sqlplus scott/scoot@ww 的方式进行连接。也是可以连接成功的。原因是:该数据库的实例名称 为 togogo.同时其数据库的service_name的值也是为 togogo.

也就是这2者的值一致的。即使再 系统参数中 的service_name中没有指定 togogo 该值。也是可以使用 实例名进行配置tnsname.ora中的某个服务的service_name的值的。反之,如果 service_name 之中的值 和 数据库实例的值再 tnsnames.ora中的配置信息中的 service_name中没有出现,而是其他的值,则 tnsname.ora 中的 服务是无法成功的服务数据库的。

image

image

image

image





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/oracle


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)
    )
  )


实际操作实验:

Last login: Thu Jun  7 23:43:19 2018 from 192.168.242.1
[root@localhost ~]# su - oracle
[oracle@localhost ~]$ echo $ORACLE_SID
orcl
[oracle@localhost ~]$ rlwrap sqlplus / as sysdba;

SQL*Plus: Release 11.2.0.3.0 Production on Wed Jun 20 22:58:37 2018

Copyright (c) 1982, 2011, Oracle.  All rights reserved.

Connected to an idle instance.

SYS@orcl> startup
ORACLE instance started.

Total System Global Area  523108352 bytes
Fixed Size                  1346052 bytes
Variable Size             390071804 bytes
Database Buffers          125829120 bytes
Redo Buffers                5861376 bytes
Database mounted.
Database opened.
SYS@orcl> select instacnce_name ,status from v$instance;
select instacnce_name ,status from v$instance
       *
ERROR at line 1:
ORA-00904: "INSTACNCE_NAME": invalid identifier


SYS@orcl> select instance_name ,status from v$instance;

INSTANCE_NAME    STATUS
---------------- ------------
orcl             OPEN

SYS@orcl> ho ls /u01/app/oracle/product/11.2.0/db_1/network/admin
listener.ora  samples  shrept.lst  sqlnet.ora

SYS@orcl> ho cat  /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
# listener.ora Network Configuration File: /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
# Generated by Oracle configuration tools.

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = localhost.localdomain)(PORT = 1521))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
    )
  )

ADR_BASE_LISTENER = /u01/app/oracle


SYS@orcl> ho vi  /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora

# listener.ora Network Configuration File: /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
# Generated by 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)(KEY = EXTPROC1521))
    )
  )

ADR_BASE_LISTENER = /u01/app/oracle

~
~
~
~
~
~
~
~
"/u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora" 18L, 772C written

SYS@orcl> ho cat  /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
# listener.ora Network Configuration File: /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
# Generated by 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)(KEY = EXTPROC1521))
    )
  )

ADR_BASE_LISTENER = /u01/app/oracle


SYS@orcl> ho ls /u01/app/oracle/product/11.2.0/db_1/network/admin
listener.ora  samples  shrept.lst  sqlnet.ora

SYS@orcl> ho touch  /u01/app/oracle/product/11.2.0/db_1/network/admin/tnsnames.ora

SYS@orcl> ho ls /u01/app/oracle/product/11.2.0/db_1/network/admin
listener.ora  samples  shrept.lst  sqlnet.ora  tnsnames.ora

SYS@orcl> ho vi  /u01/app/oracle/product/11.2.0/db_1/network/admin/tnsnames.ora

  )
# Generated by 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 written

SYS@orcl> ho cat  /u01/app/oracle/product/11.2.0/db_1/network/admin/tnsnames.ora

racle 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 File: /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
# Generated by 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)(KEY = EXTPROC1521))
    )
  )

ADR_BASE_LISTENER = /u01/app/oracle


SYS@orcl> SELECT INSTANCE_NAME ,STATUS FROM V$INSTANCE;

INSTANCE_NAME    STATUS
---------------- ------------
orcl             OPEN

SYS@orcl> quit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@localhost ~]$ lsnrctl

LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 20-JUN-2018 23:21:05

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

Welcome to LSNRCTL, type "help" for information.

LSNRCTL> start LISTENER
TNS-01106: Listener using listener name LISTENER has already been started
LSNRCTL> reload
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost.localdomain)(PORT=1521)))
The command completed successfully
LSNRCTL> stop
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost.localdomain)(PORT=1521)))
The command completed successfully
LSNRCTL> start
Starting /u01/app/oracle/product/11.2.0/db_1/bin/tnslsnr: please wait...

TNSLSNR for Linux: Version 11.2.0.3.0 - Production
System parameter file is /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
Log messages written to /u01/app/oracle/diag/tnslsnr/localhost/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1521)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1522)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1523)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1524)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1525)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1526)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost.localdomain)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.3.0 - Production
Start Date                20-JUN-2018 23:26:36
Uptime                    0 days 0 hr. 2 min. 0 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/localhost/listener/alert/log.xml
Listening 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)(KEY=EXTPROC1521)))
Services Summary...
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...
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...
The command completed successfully
LSNRCTL> quit
[oracle@localhost ~]$ rlwrap sqlplus / as sysdba;

SQL*Plus: Release 11.2.0.3.0 Production on Wed Jun 20 23:34:24 2018

Copyright (c) 1982, 2011, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SYS@orcl> conn sys/oracle@orcl_1521 as sysdba;
Connected.
SYS@orcl_1521> select instance_name ,status from v$instance;

INSTANCE_NAME    STATUS
---------------- ------------
orcl             OPEN

SYS@orcl_1521> conn sys/oracle@orcl_1522 as sysdba;
Connected.
SYS@orcl_1522> select instance_name ,status from v$instance;

INSTANCE_NAME    STATUS
---------------- ------------
orcl             OPEN

SYS@orcl_1522> conn sys/oracle@orcl_1523 as sysdba;
Connected.
SYS@orcl_1523> select instance_name ,status from v$instance;

INSTANCE_NAME    STATUS
---------------- ------------
orcl             OPEN

SYS@orcl_1523> conn sys/oracle@orcl_1524 as sysdba;
Connected.
SYS@orcl_1524> select instance_name ,status from v$instance;

INSTANCE_NAME    STATUS
---------------- ------------
orcl             OPEN

SYS@orcl_1524> conn sys/oracle@orcl_1525 as sysdba;
Connected.
SYS@orcl_1525> select instance_name ,status from v$instance;

INSTANCE_NAME    STATUS
---------------- ------------
orcl             OPEN

SYS@orcl_1525> conn sys/oracle@orcl_1526 as sysdba;
ERROR:
ORA-12154: TNS:could not resolve the connect identifier specified


Warning: You are no longer connected to ORACLE.
@> conn sys/oracle@orcl_1525 as sysdba;
Connected.
SYS@orcl_1525> select instance_name ,status from v$instance;

INSTANCE_NAME    STATUS
---------------- ------------
orcl             OPEN

SYS@orcl_1525> conn sys/oracle@orcl_1526 as sysdba;
ERROR:
ORA-12154: TNS:could not resolve the connect identifier specified


Warning: You are no longer connected to ORACLE.
@> conn sys/oracle@neworcl_1526 as sysdba;
Connected.
SYS@neworcl_1526> select instance_name ,status from v$instance;

INSTANCE_NAME    STATUS
---------------- ------------
neworcl          OPEN

SYS@neworcl_1526> conn sys/oracle@neworcl_1525 as sysdba;
Connected.
SYS@neworcl_1525> select instance_name ,status from v$instance;

INSTANCE_NAME    STATUS
---------------- ------------
neworcl          OPEN

SYS@neworcl_1525> conn sys/oracle@neworcl_1524 as sysdba;
Connected.
SYS@neworcl_1524> select instance_name ,status from v$instance;

INSTANCE_NAME    STATUS
---------------- ------------
neworcl          OPEN

SYS@neworcl_1524> conn sys/oracle@neworcl_1523 as sysdba;
Connected.
SYS@neworcl_1523> select instance_name ,status from v$instance;

INSTANCE_NAME    STATUS
---------------- ------------
neworcl          OPEN

SYS@neworcl_1523> conn sys/oracle@neworcl_1522 as sysdba;
Connected.
SYS@neworcl_1522> select instance_name ,status from v$instance;

INSTANCE_NAME    STATUS
---------------- ------------
neworcl          OPEN

SYS@neworcl_1522> conn sys/oracle@neworcl_1521 as sysdba;

[2]+  Stopped                 rlwrap sqlplus / as sysdba
[oracle@localhost ~]$ rlwrap sqlplus / as sysdba;

SQL*Plus: Release 11.2.0.3.0 Production on Wed Jun 20 23:38:39 2018

Copyright (c) 1982, 2011, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SYS@orcl> quit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@localhost ~]$ cd /u01/app/oracle/product/11.2.0/db_1/network/admin/
[oracle@localhost admin]$ ls
listener.ora  samples  shrept.lst  sqlnet.ora  tnsnames.ora
[oracle@localhost admin]$ vi tnsnames.ora


racle 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 / as sysdba;

SQL*Plus: Release 11.2.0.3.0 Production on Wed Jun 20 23:39:50 2018

Copyright (c) 1982, 2011, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SYS@orcl> conn sys/oracle@orcl_1526 as sysdba;
Connected.
SYS@orcl_1526> conn sys/oracle@neworcl_1521 as 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)
    )
  )



alter system set local_listener=wl,aa;

--测试发现:
--  LISTENER1和LISTENER3可以正常使用,LISTENER不能注册使用。


[oracle@localhost ~]$ cd /u01/app/oracle/product/11.2.0/db_1/network/admin/
[oracle@localhost admin]$ ls
listener1806197PM5534.bak  listener.ora  samples  shrept.lst  sqlnet1806197PM5534.bak  sqlnet.ora  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)
    )
  )

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 File: /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
# Generated by 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_SID
orcl
[oracle@localhost admin]$ rlwrap sqlplus / as sysdba;

SQL*Plus: Release 11.2.0.3.0 Production on Tue Jun 19 21:38:02 2018

Copyright (c) 1982, 2011, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SYS@orcl> select instance_name ,status from v$instance;

INSTANCE_NAME    STATUS
---------------- ------------
orcl             OPEN

SYS@orcl> show parameter local_listener

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
local_listener                       string
SYS@orcl> alter system set local_listener=SER_ORCL1522;

System altered.

SYS@orcl> show parameter local_listener

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
local_listener                       string      SER_ORCL1522
SYS@orcl> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SYS@orcl> stratup
SP2-0042: unknown command "stratup" - rest of line ignored.
SYS@orcl> startup
ORACLE instance started.

Total System Global Area  523108352 bytes
Fixed Size                  1346052 bytes
Variable Size             390071804 bytes
Database Buffers          125829120 bytes
Redo Buffers                5861376 bytes
Database mounted.
Database opened.
SYS@orcl> quit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@localhost admin]$ lsnrctl reload LISTENER1

LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 19-JUN-2018 21:42:47

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost.localdomain)(PORT=1522)))
The command completed successfully
[oracle@localhost admin]$ lsnrctl status LISTENER1

LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 19-JUN-2018 21:43:02

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost.localdomain)(PORT=1522)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER1
Version                   TNSLSNR for Linux: Version 11.2.0.3.0 - Production
Start Date                19-JUN-2018 21:17:19
Uptime                    0 days 0 hr. 25 min. 42 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/localhost/listener1/alert/log.xml
Listening 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) for this service...
Service "orclXDB" has 1 instance(s).
  Instance "orcl", status READY, has 1 handler(s) for this service...
The command completed successfully
[oracle@localhost admin]$ rlwrap sqlplus /nolog;

SQL*Plus: Release 11.2.0.3.0 Production on Tue Jun 19 21:43:23 2018

Copyright (c) 1982, 2011, Oracle.  All rights reserved.

@> conn sys/oracle@SER_ORCL1522 as sysdba;
Connected.
SYS@SER_ORCL1522> conn sys/oracle@SER_ORCL as sysdba;
ERROR:
ORA-12514: TNS:listener does not currently know of service requested in connect
descriptor


Warning: You are no longer connected to ORACLE.
@> quit;
[oracle@localhost admin]$ lsnrctl reload LISTENER

LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 19-JUN-2018 21:44:22

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost.localdomain)(PORT=1521)))
The command completed successfully
[oracle@localhost admin]$ lsnrctl status LISTENER

LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 19-JUN-2018 21:44:35

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost.localdomain)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.3.0 - Production
Start Date                19-JUN-2018 20:07:49
Uptime                    0 days 1 hr. 36 min. 46 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/localhost/listener/alert/log.xml
Listening 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) for this service...
Service "neworcl" has 1 instance(s).
  Instance "neworcl", status READY, has 1 handler(s) for this service...
The command completed successfully
[oracle@localhost admin]$ rlwrap sqlplus /nolog;

SQL*Plus: Release 11.2.0.3.0 Production on Tue Jun 19 21:44:40 2018

Copyright (c) 1982, 2011, Oracle.  All rights reserved.

@> conn sys/oracle@SER_ORCL as sysdba;
ERROR:
ORA-12514: TNS:listener does not currently know of service requested in connect
descriptor


@>
[oracle@localhost admin]$ rlwrap sqlplus / as sysdba;

SQL*Plus: Release 11.2.0.3.0 Production on Tue Jun 19 21:46:44 2018

Copyright (c) 1982, 2011, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SYS@orcl> show parameter local_list

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
local_listener                       string      SER_ORCL1522
SYS@orcl> alter system set local_listener=SER_ORCL1522,SER_ORCL;

System altered.

SYS@orcl> show parameter local_list

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
local_listener                       string      SER_ORCL1522, SER_ORCL
SYS@orcl> quit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@localhost admin]$ rlwrap sqlplus / as sysdba;

SQL*Plus: Release 11.2.0.3.0 Production on Tue Jun 19 21:47:43 2018

Copyright (c) 1982, 2011, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SYS@orcl> startu force
SP2-0734: unknown command beginning "startu for..." - rest of line ignored.
SYS@orcl> startup force
ORACLE instance started.

Total System Global Area  523108352 bytes
Fixed Size                  1346052 bytes
Variable Size             390071804 bytes
Database Buffers          125829120 bytes
Redo Buffers                5861376 bytes
Database mounted.
Database opened.
SYS@orcl> quit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@localhost admin]$ lsnrctl status LISTENER

LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 19-JUN-2018 21:48:26

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost.localdomain)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.3.0 - Production
Start Date                19-JUN-2018 20:07:49
Uptime                    0 days 1 hr. 40 min. 37 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/localhost/listener/alert/log.xml
Listening 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
[oracle@localhost admin]$ lsnrctl status LISTENER1

LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 19-JUN-2018 21:48:36

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost.localdomain)(PORT=1522)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER1
Version                   TNSLSNR for Linux: Version 11.2.0.3.0 - Production
Start Date                19-JUN-2018 21:17:19
Uptime                    0 days 0 hr. 31 min. 16 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/localhost/listener1/alert/log.xml
Listening 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) for this service...
Service "orclXDB" has 1 instance(s).
  Instance "orcl", status READY, has 1 handler(s) for this service...
The command completed successfully
[oracle@localhost admin]$ rlwrap sqlplus /nolog;

SQL*Plus: Release 11.2.0.3.0 Production on Tue Jun 19 21:48:49 2018

Copyright (c) 1982, 2011, Oracle.  All rights reserved.

@> conn sys/oracle@SER_ORCL as sysdba;
Connected.
SYS@SER_ORCL> conn sys/oracle@SER_ORCL1522 as sysdba;
Connected.
SYS@SER_ORCL1522>
[oracle@localhost admin]$ rlwrap sqlplus /nolog;

SQL*Plus: Release 11.2.0.3.0 Production on Tue Jun 19 21:48:49 2018

Copyright (c) 1982, 2011, Oracle.  All rights reserved.

@> conn sys/oracle@SER_ORCL as sysdba;
Connected.
SYS@SER_ORCL> conn sys/oracle@SER_ORCL1522 as sysdba;
Connected.
SYS@SER_ORCL1522> select  instance_name ,status from v$instance;

INSTANCE_NAME    STATUS
---------------- ------------
orcl             OPEN

SYS@SER_ORCL1522> conn sys/oracle@SER_ORCL as sysdba;
Connected.
SYS@SER_ORCL> select  instance_name ,status from v$instance;

INSTANCE_NAME    STATUS
---------------- ------------
orcl             OPEN

SYS@SER_ORCL>




imageimageimageimageimageimageimageimageimageimageimage

同理打开 listener2 listener3的监听信息

image

查看状态信息 发现:只有  LISTENER 有监听到的注册服务信息;其他的 LISTENER1  LISTENER2 LISTENER3 都没有服务注册信息。因为 LISTENER 是动态注册的 。

imageimageimageimage

注意:  LISTENER  LISTENER1  LISTENER2 LISTENER3  在修改了local_listener 这个参数值之后,则默认的 LISTENER的监听器就不能再用了。

imageimageimage







imageimageimage



静态注册实验


1、配置静态注册,默认端口1521

netmgr

Last login: Thu Jun  7 23:43:19 2018 from 192.168.242.1
[root@localhost ~]# su - oracle
[oracle@localhost ~]$ rlwrap sqlplus / as sysdba;

SQL*Plus: Release 11.2.0.3.0 Production on Thu Jun 21 21:10:42 2018

Copyright (c) 1982, 2011, Oracle.  All rights reserved.

Connected to an idle instance.

SYS@orcl> startup
ORACLE instance started.

Total System Global Area  523108352 bytes
Fixed Size                  1346052 bytes
Variable Size             390071804 bytes
Database Buffers          125829120 bytes
Redo Buffers                5861376 bytes
Database mounted.
Database opened.
SYS@orcl> select instance_name ,status  from v$instance;

INSTANCE_NAME    STATUS
---------------- ------------
orcl             OPEN

SYS@orcl> ho lsnrctl status

LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 21-JUN-2018 21:11:55

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

Connecting 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
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
TNS-12541: TNS:no listener
 TNS-12560: TNS:protocol adapter error
  TNS-00511: No listener
   Linux Error: 111: Connection refused

SYS@orcl> ho lsnrctl start

LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 21-JUN-2018 21:12:02

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

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

TNSLSNR for Linux: Version 11.2.0.3.0 - Production
System parameter file is /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
Log messages written to /u01/app/oracle/diag/tnslsnr/localhost/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1521)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost.localdomain)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.3.0 - Production
Start Date                21-JUN-2018 21:12:04
Uptime                    0 days 0 hr. 0 min. 20 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/localhost/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
The listener supports no services
The command completed successfully

SYS@orcl> ho lsnrctl status

LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 21-JUN-2018 21:12:32

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost.localdomain)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.3.0 - Production
Start Date                21-JUN-2018 21:12:04
Uptime                    0 days 0 hr. 0 min. 27 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/localhost/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
The listener supports no services
The command completed successfully

SYS@orcl> ho export DISPLAY=192.168.242.1:0.0

SYS@orcl> ho echo $ORACLE_SID
orcl

SYS@orcl> ho netmgr
****DISPLAY environment variable not set!
    Oracle Net Manager is a GUI tool which
    requires that DISPLAY specify a location
    where GUI tools can display.
    Set and export DISPLAY, then re-run.

SYS@orcl> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@localhost ~]$ netmgr
****DISPLAY environment variable not set!
    Oracle Net Manager is a GUI tool which
    requires that DISPLAY specify a location
    where GUI tools can display.
    Set and export DISPLAY, then re-run.
[oracle@localhost ~]$ export DISPLAY=192.168.242.1:0.0
[oracle@localhost ~]$ netmgr

image

image

image


image

image

image

image

image

image


解析生成的 静态注册的监听器信息

image


[oracle@localhost ~]$ netmgr
[oracle@localhost ~]$ lsnrctl

LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 21-JUN-2018 21:27:48

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

Welcome to LSNRCTL, type "help" for information.

LSNRCTL> stop
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost.localdomain)(PORT=1521)))
The command completed successfully
LSNRCTL> start
Starting /u01/app/oracle/product/11.2.0/db_1/bin/tnslsnr: please wait...

TNSLSNR for Linux: Version 11.2.0.3.0 - Production
System parameter file is /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
Log messages written to /u01/app/oracle/diag/tnslsnr/localhost/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1521)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost.localdomain)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.3.0 - Production
Start Date                21-JUN-2018 21:28:04
Uptime                    0 days 0 hr. 0 min. 20 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/localhost/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Services Summary...
Service "orcl" has 1 instance(s).
  Instance "orcl", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
LSNRCTL> quit
[oracle@localhost ~]$ cd /u01/app/oracle/product/11.2.0/db_1/network/admin/
[oracle@localhost admin]$ ls
listener.ora  samples  shrept.lst  sqlnet.ora  tnsnames.ora
[oracle@localhost admin]$ cat listener.ora
# listener.ora Network Configuration File: /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
# Generated by 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)(KEY = EXTPROC1521))
    )
  )

ADR_BASE_LISTENER = /u01/app/oracle

[oracle@localhost admin]$ lsnrctl status

LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 21-JUN-2018 21:42:07

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost.localdomain)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.3.0 - Production
Start Date                21-JUN-2018 21:28:04
Uptime                    0 days 0 hr. 14 min. 3 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/localhost/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Services Summary...
Service "neworcl" has 1 instance(s).
  Instance "neworcl", status READY, has 1 handler(s) for this service...
Service "orcl" has 2 instance(s).
  Instance "orcl", status UNKNOWN, has 1 handler(s) for this service...
  Instance "orcl", status READY, has 1 handler(s) for this service...
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...
The command completed successfully
[oracle@localhost admin]$ rlwrap sqlplus /nolog;

SQL*Plus: Release 11.2.0.3.0 Production on Thu Jun 21 21:43:15 2018

Copyright (c) 1982, 2011, Oracle.  All rights reserved.

@> conn sys/oracle@orcl_1 as sysdba;
Connected.
SYS@orcl_1>
SYS@orcl_1> select  instance_name ,status from v$instance;

INSTANCE_NAME    STATUS
---------------- ------------
orcl             OPEN

SYS@orcl_1> quit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@localhost admin]$ ls
listener.ora  samples  shrept.lst  sqlnet.ora  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.

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/oracle

WL =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.10)(PORT = 1522))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = orcl)
    )
  )


实验操作:

Last login: Thu Jun  7 23:43:19 2018 from 192.168.242.1
[root@localhost ~]# su - oracle
[oracle@localhost ~]$ rlwrap sqlplus / as sysdba;

SQL*Plus: Release 11.2.0.3.0 Production on Thu Jun 21 22:15:55 2018

Copyright (c) 1982, 2011, Oracle.  All rights reserved.

Connected to an idle instance.

SYS@orcl> startup
ORACLE instance started.

Total System Global Area  523108352 bytes
Fixed Size                  1346052 bytes
Variable Size             390071804 bytes
Database Buffers          125829120 bytes
Redo Buffers                5861376 bytes
Database mounted.
Database opened.
SYS@orcl> select  instance_name ,status from v$instance;

INSTANCE_NAME    STATUS
---------------- ------------
orcl             OPEN

SYS@orcl> quit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@localhost ~]$ cd /u01/app/oracle/product/11.2.0/db_1/network/admin/
[oracle@localhost admin]$ ls
listener.ora  samples  shrept.lst  sqlnet.ora
[oracle@localhost admin]$ cat listener.ora
# listener.ora Network Configuration File: /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
# Generated by Oracle configuration tools.

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = localhost.localdomain)(PORT = 1521))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
    )
  )

ADR_BASE_LISTENER = /u01/app/oracle

[oracle@localhost admin]$ lsnrctl start

LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 21-JUN-2018 22:24:55

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

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

TNSLSNR for Linux: Version 11.2.0.3.0 - Production
System parameter file is /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
Log messages written to /u01/app/oracle/diag/tnslsnr/localhost/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1521)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost.localdomain)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.3.0 - Production
Start Date                21-JUN-2018 22:24:57
Uptime                    0 days 0 hr. 0 min. 20 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/localhost/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
The listener supports no services
The command completed successfully
[oracle@localhost admin]$ lsnrctl status

LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 21-JUN-2018 22:26:18

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost.localdomain)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.3.0 - Production
Start Date                21-JUN-2018 22:24:57
Uptime                    0 days 0 hr. 1 min. 21 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/localhost/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Services Summary...
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...
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...
The command completed successfully
[oracle@localhost admin]$ cat listener.ora
# listener.ora Network Configuration File: /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
# Generated by Oracle configuration tools.

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = localhost.localdomain)(PORT = 1521))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
    )
  )

ADR_BASE_LISTENER = /u01/app/oracle

[oracle@localhost admin]$ vi listener.ora

# listener.ora Network Configuration File: /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
# Generated by 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)(KEY = EXTPROC1521))
    )
  )



"listener.ora" 36L, 745C written
[oracle@localhost admin]$ cat listener.ora
# listener.ora Network Configuration File: /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
# Generated by 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)(KEY = EXTPROC1521))
    )
  )



LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = localhost.localdomain)(PORT = 1521))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
    )
  )

ADR_BASE_LISTENER = /u01/app/oracle

[oracle@localhost admin]$ ls
listener.ora  samples  shrept.lst  sqlnet.ora
[oracle@localhost admin]$ touch tnsnames.ora
[oracle@localhost admin]$ ls
listener.ora  samples  shrept.lst  sqlnet.ora  tnsnames.ora
[oracle@localhost admin]$  vi tnsnames.ora


orcl_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.ora

orcl_1 =
  (DESCRIPTION =
   (ADDRESS_LIST =
    (ADDRESS =(PROTOCOL = TCP)(HOST = 192.168.242.146)(PORT =1522))
   )
   (CONNECT_DATA =
     (SERVICE_NAME = orcl)
   )
  )
[oracle@localhost admin]$ lsnrctl stop

LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 21-JUN-2018 22:46:53

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost.localdomain)(PORT=1521)))
The command completed successfully
[oracle@localhost admin]$ lsnrctl start

LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 21-JUN-2018 22:47:00

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

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

TNSLSNR for Linux: Version 11.2.0.3.0 - Production
System parameter file is /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
Log messages written to /u01/app/oracle/diag/tnslsnr/localhost/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1521)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost.localdomain)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.3.0 - Production
Start Date                21-JUN-2018 22:47:01
Uptime                    0 days 0 hr. 0 min. 20 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/localhost/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
The listener supports no services
The command completed successfully
[oracle@localhost admin]$ lsnrctl stop LISTENER_1

LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 21-JUN-2018 22:48:04

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost.localdomain)(PORT=1522)))
TNS-12541: TNS:no listener
 TNS-12560: TNS:protocol adapter error
  TNS-00511: No listener
   Linux Error: 111: Connection refused
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
The command completed successfully
[oracle@localhost admin]$ lsnrctl start LISTENER_1

LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 21-JUN-2018 22:48:17

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

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

TNSLSNR for Linux: Version 11.2.0.3.0 - Production
System parameter file is /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
Log messages written to /u01/app/oracle/diag/tnslsnr/localhost/listener_1/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1522)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost.localdomain)(PORT=1522)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER_1
Version                   TNSLSNR for Linux: Version 11.2.0.3.0 - Production
Start Date                21-JUN-2018 22:48:19
Uptime                    0 days 0 hr. 0 min. 21 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/localhost/listener_1/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1522)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Services Summary...
Service "orcl" has 1 instance(s).
  Instance "orcl", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
[oracle@localhost admin]$ lsnrctl  status LISTENER_1

LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 21-JUN-2018 22:49:45

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost.localdomain)(PORT=1522)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER_1
Version                   TNSLSNR for Linux: Version 11.2.0.3.0 - Production
Start Date                21-JUN-2018 22:48:19
Uptime                    0 days 0 hr. 1 min. 28 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/localhost/listener_1/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1522)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Services Summary...
Service "orcl" has 1 instance(s).
  Instance "orcl", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
[oracle@localhost admin]$ rlwrap sqlplus /nolog;

SQL*Plus: Release 11.2.0.3.0 Production on Thu Jun 21 22:50:25 2018

Copyright (c) 1982, 2011, Oracle.  All rights reserved.

@> conn sys/oracle@orcl_1 as 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/oracle

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)
    )
  )



实验操作:






  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)
    )
  )




























————————————————————————————————————————————————————————————————————————————————————————

posted @ 2018-06-13 13:18  一品堂.技术学习笔记  阅读(862)  评论(0编辑  收藏  举报