監聽程序即Oracle Net Service服務,由一個Oracle文件管理,該文件名為listener.ora,該文件在Linux系統上默認位于$ORACL_HOME/network/admin目錄下。Oracle的監聽程序只運行在數據庫服務器上,完成監聽客戶連接請求的作用。Oracle使用lsnrctl實用程序完成監聽程序的配置和管理。
[Oracle@ocm1 admin]$ lsnrctl start listener1;
LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 24-OCT-2011 09:31:13
Copyright (c) 1991, 2005, Oracle. All rights reserved.
Starting /u01/app/Oracle/Oracle/product/10.2.0/db_1/bin/tnslsnr: please wait...
TNSLSNR for Linux: Version 10.2.0.1.0 - Production
System parameter file is /u01/app/Oracle/Oracle/product/10.2.0/db_1/network/admin/listener.ora
Log messages written to /u01/app/Oracle/Oracle/product/10.2.0/db_1/network/log/listener1.log
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=ocm1.oracle)(PORT=1522)))
Connecting to
(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=ocm1.oracle)(PORT=1522)))
STATUS of the LISTENER
------------------------
Alias listener1
Version TNSLSNR for Linux: Version 10.2.0.1.0 - Production
Start Date 24-OCT-2011 09:31:13
Uptime 0 days 0 hr. 0 min. 0 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/Oracle/Oracle/product/10.2.0/db_1/network/admin/listener.ora
Listener Log File /u01/app/Oracle/Oracle/product/10.2.0/db_1/network/log/listener1.log
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=ocm1.oracle)(PORT=1522)))
The listener supports no services
The command completed successfully
[Oracle@ocm1 admin]$ lsnrctl status listener1
LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 24-OCT-2011 09:40:29
Copyright (c) 1991, 2005, Oracle. All rights reserved.
Connecting to
(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=ocm1.oracle)(PORT=1522)))
STATUS of the LISTENER
------------------------
Alias listener1
Version TNSLSNR for Linux: Version 10.2.0.1.0 - Production
Start Date 24-OCT-2011 09:31:13
Uptime 0 days 0 hr. 9 min. 15 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/Oracle/Oracle/product/10.2.0/db_1/network/admin/listener.ora
Listener Log File /u01/app/Oracle/Oracle/product/10.2.0/db_1/network/log/listener1.log
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=ocm1.oracle)(PORT=1522)))
The listener supports no services
The command completed successfully
SQL> show parameter service_name
NAME TYPE VALUE
-------------------------------- ------------------------------- -----------------------------
service_names string PROD
SQL> show parameter local_listener;
NAME TYPE VALUE
------------------------------------ -------------------------------- ------------------------------
local_listener string
[Oracle@ocm1 admin]$ lsnrctl status listener1
LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 24-OCT-2011 09:54:12
Copyright (c) 1991, 2005, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=ocm1.oracle)(PORT=1522)))
STATUS of the LISTENER
------------------------
Alias listener1
Version TNSLSNR for Linux: Version 10.2.0.1.0 - Production
Start Date 24-OCT-2011 09:31:13
Uptime 0 days 0 hr. 22 min. 59 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/Oracle/Oracle/product/10.2.0/db_1/network/admin/listener.ora
Listener Log File /u01/app/Oracle/Oracle/product/10.2.0/db_1/network/log/listener1.log
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=ocm1.oracle)(PORT=1522)))
The listener supports no services
The command completed successfully
[Oracle@ocm1 admin]$ lsnrctl status listener1
LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 24-OCT-2011 10:00:50
Copyright (c) 1991, 2005, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=ocm1.oracle)(PORT=1522)))
STATUS of the LISTENER
------------------------
Alias listener1
Version TNSLSNR for Linux: Version 10.2.0.1.0 - Production
Start Date 24-OCT-2011 09:31:13
Uptime 0 days 0 hr. 29 min. 36 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/Oracle/Oracle/product/10.2.0/db_1/network/admin/listener.ora
Listener Log File /u01/app/Oracle/Oracle/product/10.2.0/db_1/network/log/listener1.log
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=ocm1.oracle)(PORT=1522)))
Services Summary...
Service "PROD" has 1 instance(s).
Instance "PROD", status READY, has 1 handler(s) for this service...
Service "PROD_XPT" has 1 instance(s).
Instance "PROD", status READY, has 1 handler(s) for this service...
The command completed successfully
[Oracle@ocm1 admin]$ lsnrctl status listener
LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 24-OCT-2011 10:12:41
Copyright (c) 1991, 2005, Oracle. All rights reserved.
Connecting to
(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=ocm1.oracle)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 10.2.0.1.0 - Production
Start Date 24-OCT-2011 09:39:54
Uptime 0 days 0 hr. 32 min. 47 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/Oracle/Oracle/product/10.2.0/db_1/network/admin/listener.ora
Listener Log File /u01/app/Oracle/Oracle/product/10.2.0/db_1/network/log/listener.log
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=ocm1.oracle)(PORT=1521)))
The listener supports no services
The command completed successfully
[Oracle@ocm1 admin]$ lsnrctl status listener
LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 24-OCT-2011 10:14:10
Copyright (c) 1991, 2005, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=ocm1.oracle)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias listener
Version TNSLSNR for Linux: Version 10.2.0.1.0 - Production
Start Date 24-OCT-2011 10:13:48
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/Oracle/product/10.2.0/db_1/network/admin/listener.ora
Listener Log File /u01/app/Oracle/Oracle/product/10.2.0/db_1/network/log/listener.log
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=ocm1.oracle)(PORT=1521)))
Services Summary...
Service "PROD" has 1 instance(s).
Instance "PROD", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
顯然,從Services Summary...數據庫服務PROD靜態注冊到了監聽器LISTENER。“Instance "PROD", status UNKNOWN”說明這是一個靜態注冊。
[Oracle@ocm1 admin]$ tnsping myprod
TNS Ping Utility for Linux: Version 10.2.0.1.0 - Production on 24-OCT-2011 10:26:01
Copyright (c) 1997, 2005, Oracle. All rights reserved.
Used parameter files:
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL =
TCP)(HOST = ocm1.oracle)(PORT = 1521))) (CONNECT_DATA = (SERVER = DEDICATED)
(SERVICE_NAME = PROD)))
OK (30 msec)
[Oracle@ocm1 admin]$ sqlplus sys/Oracle@myprod as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on Mon Oct 24 10:36:15 2011
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, Oracle Label Security, OLAP and Data Mining options
SQL>
[Oracle@ocm1 admin]$ lsnrctl help;
LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 24-OCT-2011 10:46:47
Copyright (c) 1991, 2005, Oracle. All rights reserved.
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*
LSNRCTL> set password
Password:
The command completed successfully
LSNRCTL> change_password
Old password:
New password:
Reenter new password:
Connecting to
(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=ocm1.oracle)(PORT=1521)))
Password changed for LISTENER
The command completed successfully
LSNRCTL> save_config
Connecting to
(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=ocm1.oracle)(PORT=1521)))
Saved LISTENER configuration parameters.
Listener Parameter File /u01/app/Oracle/Oracle/product/10.2.0/db_1/network/admin/listener.ora
Old Parameter File /u01/app/Oracle/Oracle/product/10.2.0/db_1/network/admin/listener.bak
The command completed successfully