Locations of visitors to this page

Tuesday, February 24, 2009

remote listener - 远程监听器

remote listener



配置远程监听器

远程监听器将客户端的连接重新定向(re-direct)到数据库服务器上的本地监听器

1.
数据库服务器上启一个本地监听器
grep -q "^LISTENER_LOCAL" $ORACLE_HOME/network/admin/listener.ora || \
cat >>$ORACLE_HOME/network/admin/listener.ora <<'EOF'
LISTENER_LOCAL =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = )(PORT = 1541)))
    )
  )
EOF
lsnrctl start LISTENER_LOCAL
[oracle@MGT ~]$ lsnrctl start LISTENER_LOCAL

LSNRCTL for Linux: Version 10.2.0.4.0 - Production on 24-FEB-2009 12:00:52

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

Starting /home/oracle/app/oracle/product/10.2/bin/tnslsnr: please wait...

TNSLSNR for Linux: Version 10.2.0.4.0 - Production
System parameter file is /home/oracle/app/oracle/product/10.2/network/admin/listener.ora
Log messages written to /home/oracle/app/oracle/product/10.2/network/log/listener_local.log
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=MGT.s3lab.mot.com)(PORT=1541)))

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=)(PORT=1541)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER_LOCAL
Version                   TNSLSNR for Linux: Version 10.2.0.4.0 - Production
Start Date                24-FEB-2009 12:00:52
Uptime                    0 days 0 hr. 0 min. 0 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /home/oracle/app/oracle/product/10.2/network/admin/listener.ora
Listener Log File         /home/oracle/app/oracle/product/10.2/network/log/listener_local.log
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=MGT.s3lab.mot.com)(PORT=1541)))
The listener supports no services
The command completed successfully
[oracle@MGT ~]$

tail -f $ORACLE_HOME/network/log/listener_local.log



2.
另找一台机器作为监听器服务器, 用来监听远程数据库
grep -q "^LISTENER_REMOTE" $ORACLE_HOME/network/admin/listener.ora || \
cat >>$ORACLE_HOME/network/admin/listener.ora <<'EOF'
LISTENER_REMOTE =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = )(PORT = 1531)))
    )
  )
EOF
lsnrctl start LISTENER_REMOTE
[oracle@DEV-RPT-2 ~]$ lsnrctl start LISTENER_REMOTE

LSNRCTL for Linux: Version 10.2.0.4.0 - Production on 24-FEB-2009 12:03:35

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

Starting /home/oracle/app/oracle/product/10.2/bin/tnslsnr: please wait...

TNSLSNR for Linux: Version 10.2.0.4.0 - Production
System parameter file is /home/oracle/app/oracle/product/10.2/network/admin/listener.ora
Log messages written to /home/oracle/app/oracle/product/10.2/network/log/listener_remote.log
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=DEV-RPT-2.s3lab.mot.com)(PORT=1531)))

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=)(PORT=1531)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER_REMOTE
Version                   TNSLSNR for Linux: Version 10.2.0.4.0 - Production
Start Date                24-FEB-2009 12:03:35
Uptime                    0 days 0 hr. 0 min. 0 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /home/oracle/app/oracle/product/10.2/network/admin/listener.ora
Listener Log File         /home/oracle/app/oracle/product/10.2/network/log/listener_remote.log
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=DEV-RPT-2.s3lab.mot.com)(PORT=1531)))
The listener supports no services
The command completed successfully
[oracle@DEV-RPT-2 ~]$

tail -f $ORACLE_HOME/network/log/listener_remote.log


3.
在数据库上配置本地/远程监听器参数
alter system set local_listener="(address=(protocol=tcp)(host=MGT.s3lab.mot.com)(port=1541))";
alter system set remote_listener="(address=(protocol=tcp)(host=DEV-RPT-2.s3lab.mot.com)(port=1531))";
SQL> alter system set local_listener="(address=(protocol=tcp)(host=MGT.s3lab.mot.com)(port=1541))";

System altered.

SQL> alter system set remote_listener="(address=(protocol=tcp)(host=DEV-RPT-2.s3lab.mot.com)(port=1531))";

System altered.

SQL>

在远程监听器服务器上显示
24-FEB-2009 12:04:26 * service_register * test * 0
24-FEB-2009 12:05:26 * service_update * test * 0
24-FEB-2009 12:05:38 * service_update * test * 0

查看监听器状态, 已经注册上了
lsnrctl status listener_remote
lsnrctl service listener_remote
[oracle@DEV-RPT-2 ~]$ lsnrctl status LISTENER_REMOTE

LSNRCTL for Linux: Version 10.2.0.4.0 - Production on 24-FEB-2009 12:14:06

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=)(PORT=1531)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER_REMOTE
Version                   TNSLSNR for Linux: Version 10.2.0.4.0 - Production
Start Date                24-FEB-2009 12:03:35
Uptime                    0 days 0 hr. 10 min. 31 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /home/oracle/app/oracle/product/10.2/network/admin/listener.ora
Listener Log File         /home/oracle/app/oracle/product/10.2/network/log/listener_remote.log
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=DEV-RPT-2.s3lab.mot.com)(PORT=1531)))
Services Summary...
Service "test" has 1 instance(s).
  Instance "test", status READY, has 1 handler(s) for this service...
Service "test_XPT" has 1 instance(s).
  Instance "test", status READY, has 1 handler(s) for this service...
The command completed successfully
[oracle@DEV-RPT-2 ~]$ lsnrctl service LISTENER_REMOTE

LSNRCTL for Linux: Version 10.2.0.4.0 - Production on 24-FEB-2009 12:14:08

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=)(PORT=1531)))
Services Summary...
Service "test" has 1 instance(s).
  Instance "test", status READY, has 1 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:0 refused:0 state:ready
         REMOTE SERVER
         (address=(protocol=tcp)(host=MGT.s3lab.mot.com)(port=1541))
Service "test_XPT" has 1 instance(s).
  Instance "test", status READY, has 1 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:0 refused:0 state:ready
         REMOTE SERVER
         (address=(protocol=tcp)(host=MGT.s3lab.mot.com)(port=1541))
The command completed successfully
[oracle@DEV-RPT-2 ~]$


本地监听器显示:
24-FEB-2009 12:05:46 * service_register * test * 0
24-FEB-2009 12:14:02 * service_update * test * 0

监听器状态
[oracle@MGT ~]$ lsnrctl status listener_local

LSNRCTL for Linux: Version 10.2.0.4.0 - Production on 24-FEB-2009 12:12:57

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=)(PORT=1541)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER_LOCAL
Version                   TNSLSNR for Linux: Version 10.2.0.4.0 - Production
Start Date                24-FEB-2009 12:00:52
Uptime                    0 days 0 hr. 12 min. 5 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /home/oracle/app/oracle/product/10.2/network/admin/listener.ora
Listener Log File         /home/oracle/app/oracle/product/10.2/network/log/listener_local.log
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=MGT.s3lab.mot.com)(PORT=1541)))
Services Summary...
Service "test" has 1 instance(s).
  Instance "test", status READY, has 1 handler(s) for this service...
Service "test_XPT" has 1 instance(s).
  Instance "test", status READY, has 1 handler(s) for this service...
The command completed successfully
[oracle@MGT ~]$ lsnrctl service listener_local

LSNRCTL for Linux: Version 10.2.0.4.0 - Production on 24-FEB-2009 12:13:05

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=)(PORT=1541)))
Services Summary...
Service "test" has 1 instance(s).
  Instance "test", status READY, has 1 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:0 refused:0 state:ready
         LOCAL SERVER
Service "test_XPT" has 1 instance(s).
  Instance "test", status READY, has 1 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:0 refused:0 state:ready
         LOCAL SERVER
The command completed successfully
[oracle@MGT ~]$


4.
客户端通过远程监听器连接远程的数据库
conn kitty/kitty@DEV-RPT-2:1531/test
SQLL> conn kitty/kitty@DEV-RPT-2:1531/test
Connected.
SQLL>
远程监听器重定向(re-direct)了客户端的连接
实际上, 客户端最终连的还是数据库所在服务器上的监听器



外部链接:
How To Configure a Dispatcher or Instance to Register Against a Remote Listener
Init.ora Parameter "REMOTE_LISTENER" Reference Note
How To Set Up a 9i Database to Contact a Remote Listener
Conntinuing question "Remote Listener Registration"



-fin-

No comments:

Website Analytics

Followers