remote_listener和listener password

warehouse發表於2010-01-16
listener註冊在遠端的目的是rac為了實現伺服器負載均衡,如何把db的service_names註冊在遠端的listener上呢,注意遠端註冊service_name一定是動態註冊的,把service_name註冊到遠端的listener上有什麼缺點?[@more@]

測試版本:10.2.0.1

接下來來看上面提到的2個問題:

1.如何把sevice_names註冊到遠端的lisenter上,目前db的資訊如下,資料庫執行在windows下

C:>sqlplus / as sysdba

SQL*Plus: Release 10.2.0.1.0 - Production on 星期六 1月 16 22:05:49 2010

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


連線到:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options

SQL> show parameter service_names

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
service_names string ABC
SQL> show parameter db_name

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_name string orcl
SQL>

在win下的tnsnames.ora中加入下面內容:

LISTENER_R =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.253)(PORT = 1521))

這裡的ip:192.168.0.253對應的是一臺linux主機

之後修改win下db的

SQL> alter system set remote_listener=LISTENER_R;

系統已更改。

SQL>

之後轉移到linux主機下觀察listener的狀態:

LSNRCTL> status
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=xys)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 10.2.0.1.0 - Production
Start Date 16-JAN-2010 21:56:50
Uptime 0 days 0 hr. 13 min. 10 sec
Trace Level off
Security ON: Password
SNMP OFF
Listener Parameter File /opt/app/oracle/product/10.2.0/db_1/network/admin/listener.ora
Listener Log File /opt/app/oracle/product/10.2.0/db_1/network/log/listener.log
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=xys)(PORT=1521)))
Services Summary...
Service "ABC" has 1 instance(s).
Instance "orcl", 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 "TEST" has 2 instance(s).
Instance "TEST", status UNKNOWN, has 1 handler(s) for this service...
Instance "TEST", status READY, has 1 handler(s) for this service...
Service "orcl_XPT" has 1 instance(s).
Instance "orcl", 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
LSNRCTL>

清楚的發現了下面的資訊:

Service "ABC" has 1 instance(s).
Instance "orcl", status READY, has 1 handler(s) for this service...

.........

service...
Instance "orcl", status READY, has 1 handler(s) for this service...

這2條資訊都是win下db的service_names(值為A,orcl是win下db的db_name,這個不論service_names是否有值,始終都會使用db_name進行動態註冊的)

2.db的service_names進行了遠端註冊之後,我們可以把遠端的listener,這裡是linux主機看作是listner的server段,把windows主機看作是client段,這樣稱呼不知道是否準確.危險的事情出現了,在9i我們可以直接在listener 的client段(windows機器上)直接把遠端的listener(linux機器上)停止,這是非常危險的,oracle為了防止這樣的事情發生,提供了為listener設定密碼.10g進行了安全性加強,從client段嘗試停止遠端的listener時出現如下錯誤:

LSNRCTL> stop listener_r
正在連線到 (ADDRESS=(PROTOCOL=TCP)(HOST=192.168.0.253)(PORT=1521))
TNS-01189: 監聽程式無法驗證使用者
LSNRCTL> exit

C:>set nls_lang=american_

C:>lsnrctl

LSNRCTL for 32-bit Windows: Version 10.2.0.1.0 - Production on 16-JAN-2010 21:51
:04

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

Welcome to LSNRCTL, type "help" for information.

LSNRCTL> stop listener_r
Connecting to (ADDRESS=(PROTOCOL=TCP)(HOST=192.168.0.253)(PORT=1521))
TNS-01189: The listener could not authenticate the user

在remote listener(listener server段,這裡是linux機器上)上設定password之後:
LSNRCTL> change_password
Old password:
New password:
Reenter new password:
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=xys)(PORT=1521)))
Password changed for LISTENER
The command completed successfully
LSNRCTL> save_config
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=xys)(PORT=1521)))
Saved LISTENER configuration parameters.
Listener Parameter File /opt/app/oracle/product/10.2.0/db_1/network/admin/listener.ora
Old Parameter File /opt/app/oracle/product/10.2.0/db_1/network/admin/listener.bak
The command completed successfully
在listener的server段為listener設定口令之後繼續在client段嘗試停止listener:
LSNRCTL> stop listener_r
Connecting to (ADDRESS=(PROTOCOL=TCP)(HOST=192.168.0.253)(PORT=1521))
TNS-01169: The listener has not recognized the password
LSNRCTL> set password manager
The command completed successfully
LSNRCTL> stop listener_r
Connecting to (ADDRESS=(PROTOCOL=TCP)(HOST=192.168.0.253)(PORT=1521))
The command completed successfully
檢查遠端listener(linux機器上)的狀態:
LSNRCTL> status
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=xys)(PORT=1521)))
TNS-12541: TNS:no listener
TNS-12560: TNS:protocol adapter error
TNS-00511: No listener
Linux Error: 111: Connection refused
LSNRCTL>
很listener已經從client段被成功stop了

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/19602/viewspace-1030631/,如需轉載,請註明出處,否則將追究法律責任。

相關文章