程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 數據庫知識 >> Oracle數據庫 >> 關於Oracle數據庫 >> Oracle 監聽器密碼設置方法(LISTENER)

Oracle 監聽器密碼設置方法(LISTENER)

編輯:關於Oracle數據庫

監聽器也有安全?Sure!在缺省的情況下,任意用戶不需要使用任何密碼即通過lsnrctl 工具對Oracle Listener進行操作或關閉,從而造成任意新的會話都將無法建立連接。在Oracle 9i 中Oracle監聽器允許任何一個人利用lsnrctl從遠程發起對監聽器的管理。也容易導致數據庫受到損壞。

1. 未設定密碼情形下停止監聽

[oracle@test ~]$ lsnrctl stop listener_demo92  -->停止監聽,可以看出不需要任何密碼即可停止 
                                              
LSNRCTL for Linux: Version 9.2.0.8.0 - Production on 26-JUN-2011 08:22:26          
                                              
Copyright (c) 1991, 2006, Oracle Corporation. All rights reserved.             
                                              
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=test)(PORT=1521)))         
The command completed successfully 

2. 重新啟動監聽並設置密碼

[oracle@test ~]$ lsnrctl                                                 
                                                             
LSNRCTL for Linux: Version 9.2.0.8.0 - Production on 26-JUN-2011 08:24:09                         
Copyright (c) 1991, 2006, Oracle Corporation. All rights reserved.                            
                                                             
Welcome to LSNRCTL, type "help" for information.	                                    
LSNRCTL> set current_listener listener_demo92 -->設置當前監聽器                             
Current Listener is listener_demo92                                            
LSNRCTL> start       -->啟動過程也不需要任何密碼,啟動的詳細信息省略                         
LSNRCTL> change_password  -->使用change_password來設置密碼                                
Old password:                                                       
New password:                                                       
Reenter new password:                                                   
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=test)(PORT=1521)))                        
Password changed for listener_demo92                                           
The command completed successfully                                            
LSNRCTL> save_config    -->注意此處的save_config失敗                                 
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=test)(PORT=1521)))                        
TNS-01169: The listener has not recognized the password                                  
LSNRCTL> set password    -->輸入新設定的密碼驗證                                    
Password:                                                         
The command completed successfully                                            
LSNRCTL> save_config    -->再次save_config成功                                     
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=test)(PORT=1521)))                        
Saved listener_demo92 configuration parameters.                                      
Listener Parameter File  /oracle/92/network/admin/listener.ora                              
Old Parameter File  /oracle/92/network/admin/listener.bak                                
The command completed successfully                                            
                                                             
-->增加密碼之後可以看到listener.ora文件中有一條新增的記錄,即密碼選項(注:盡管使用了密碼管理方式,仍然可以無需密碼啟動監聽)
[oracle@test admin]$ more listener.ora                                          
	#----ADDED BY TNSLSNR 26-JUN-2011 05:12:48---                                      
	PASSWORDS_listener_demo92 =                                               
	#--------------------------------------------

3. 嘗試未使用密碼的情況下停止監聽

[oracle@test ~]$ lsnrctl stop listener_demo92                        
LSNRCTL for Linux: Version 9.2.0.8.0 - Production on 26-JUN-2011 06:09:51          
Copyright (c) 1991, 2006, Oracle Corporation. All rights reserved.             
                                              
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=test)(PORT=1521)))         
TNS-01169: The listener has not recognized the password  -->收到錯誤信息,需要使用密碼認證

4. 使用密碼來停止監聽

[oracle@test ~]$ lsnrctl                            
LSNRCTL> set current_listener listener_demo92                 
Current Listener is listener_demo92                      
LSNRCTL> stop                                 
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=test)(PORT=1521)))   
TNS-01169: The listener has not recognized the password            
LSNRCTL> set password                             
Password:                                   
The command completed successfully                       
LSNRCTL> stop                                 
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=test)(PORT=1521)))   
The command completed successfully                       
LSNRCTL> status                                
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=test)(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=EXTPROC)))       
TNS-12541: TNS:no listener                           
 TNS-12560: TNS:protocol adapter error                     
 TNS-00511: No listener                            
  Linux Error: 2: No such file or directory	                 

5. save_config失敗的問題

-->在 Oracle 9i中,使用save_config命令將會失敗                                     
	LSNRCTL> save_config                                                 
	Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=<hostname>)(PORT=<port>)))                  
	TNS-01169: The listener has not recognized the password	                               
                                                            
-->應該先使用set password之後再save_config,則保存配置成功。                              
	LSNRCTL> set password                                                
	Password: <the password you chose>                                          
	The command completed successfully                          
/*在Oracle 10g 中不會出現類似的問題,因為在10g中可以使用基於操作系統驗證方式。listener將檢測到如果用戶屬於dba組的成員,
將會被授予改變密碼,保存配置以及停止監聽等權限。 */                                 

6. 配置listener.ora中ADMIN_RESTRICTIONS參數

參數作用:
當在listener.ora文件中設置了ADMIN_RESTRICTIONS參數後,在監聽器運行時,不允許執行任何管理命令,同時set命令將不可用
,不論是在服務器本地還是從遠程執行都不行。此時對於監聽的設置僅僅通過手工修改listener.ora文件,要使修改生效,只能
使用lsnrctl reload命令或lsnrctl stop/start命令重新載入一次監聽器配置信息。
修改方法:
在listener.ora文件中手動加入下面這樣一行
ADMIN_RESTRICTIONS_<監聽器名> = ON

下面是其它網友的補充:

LSNRCTL> change_password
Old password:
New password:
Reenter new password:
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=ecp-uc-db1)(PORT=1521)))
Password changed for LISTENER
The command completed successfully
LSNRCTL> set password
Password:
The command completed successfully
LSNRCTL> save_config
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=ecp-uc-db1)(PORT=1521)))
Saved LISTENER configuration parameters.
Listener Parameter File /opt/oracle/product/10.2.0/db_1/network/admin/listener.ora
Old Parameter File /opt/oracle/product/10.2.0/db_1/network/admin/listener.bak
The command completed successfully
[oracle@ecp-uc-db1 admin]$ cat listener.ora
#—-ADDED BY TNSLSNR 10-JUN-2011 18:13:24—
PASSWORDS_LISTENER = 6D7AA003392C436A
#——————————————–
note:10g數據庫上需要上添加(重啟監聽)
LOCAL_OS_AUTHENTICATION_LISTENER = OFF

1、添加LOCAL_OS_AUTHENTICATION_LISTENER = OFF之前

Security ON: Password or Local OS Authentication

2、添加LOCAL_OS_AUTHENTICATION_LISTENER = OFF之後

Security ON: Password
LSNRCTL> status
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=ecp-uc-db1)(PORT=1521)))
TNS-01169: The listener has not recognized the password
LSNRCTL> stop
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=ecp-uc-db1)(PORT=1521)))
TNS-01169: The listener has not recognized the password
LSNRCTL> set password 123456
The command completed successfully
LSNRCTL> status
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=ecp-uc-db1)(PORT=1521)))
STATUS of the LISTENER
————————
Alias LISTENER
Version TNSLSNR for Linux: Version 10.2.0.4.0 – Production
Start Date 10-JUN-2011 18:15:49
Uptime 0 days 0 hr. 1 min. 16 sec
Trace Level off
Security ON: Password
SNMP OFF
Listener Parameter File /opt/oracle/product/10.2.0/db_1/network/admin/listener.ora
Listener Log File /opt/oracle/product/10.2.0/db_1/network/log/listener.log
Listening Endpoints Summary…
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=ECP-UC-DB1)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC0)))
Services Summary…
Service “PLSExtProc” has 1 instance(s).
Instance “PLSExtProc”, status UNKNOWN, has 1 handler(s) for this service…
Service “ecp” has 1 instance(s).
Instance “ecp”, status READY, has 1 handler(s) for this service…
Service “ecpXDB” has 1 instance(s).
Instance “ecp”, status READY, has 1 handler(s) for this service…
Service “ecp_XPT” has 1 instance(s).
Instance “ecp”, status READY, has 1 handler(s) for this service…
The command completed successfully

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved