动态注册(Dynamic service Registration)
service_names =Global database name=db_name.db_domain
instance_name 默认是SID
修改spfileSID.ora文件方法如下:
先查看参数:
SQL> show parameter service
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
service_names string guo
SQL> show parameter instance
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
active_instance_count integer
cluster_database_instances integer 1
instance_groups string
instance_name string guo
增加这2个参数
SQL> alter system set service_names='guo' scope=spfile;
System altered.
SQL> alter system set instance_name='guo' scope=spfile;
System altered.
然后在strings spfileSID.ora。
动态注册只需要在spfileSID.ora中注册上上述的2个参数就可以直接连接到数据库了。然后删除掉$ORACLE_HOME/network/admin中的listener.ora文件。
先查看客户端的tnsnames.ora中的信息
# tnsnames.ora Network Configuration File: E:\oracle\product\10.2.0\client_1\network\admin\tnsnames.ora
# Generated by Oracle configuration tools.GUO =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.205)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = guo)
)
)
c:\>sqlplus hr/hr@guo
即可成功连接到数据库。
查看监听状态如下:
[oracle@oral admin]$ lsnrctl status
LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 22-NOV-2011 03:02:34
Copyright (c) 1991, 2005, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.205)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 10.2.0.1.0 - Production
Start Date 22-NOV-2011 02:21:12
Uptime 0 days 0 hr. 41 min. 21 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Log File /u01/app/oracle/product/10.2.0/db_1/network/log/listener.log
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1521)))
Services Summary...
Service "guo" has 1 instance(s).
Instance "guo", status READY, has 1 handler(s) for this service...
Service "guoXDB" has 1 instance(s).
Instance "guo", status READY, has 1 handler(s) for this service...
Service "guo_XPT" has 1 instance(s).
Instance "guo", status READY, has 1 handler(s) for this service...
The command completed successfully
静态注册(Static service Registration)
如果要使用Oracle Enterprise Manager (OEM)的话,就必须要使用静态注册(Static service configuration)
listener name listener
Port 1521
Protocols TCP/IP
SID name default instance
Host name default host name
牛人可以记事本手工写,本人只有netca或者Netmanager的方式来搞了。
在XWindows下,直接netca,直接Next到头即可(但是也要看实际情况)。
netca只能简单的配置下。
view listener.ora
# listener.ora Network Configuration File: /u01/app/oracle/product/10.2.0/db_1/n
etwork/admin/listener.ora
# Generated by Oracle configuration tools.SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = /u01/app/oracle/product/10.2.0/db_1)
(PROGRAM = extproc)
)
)LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.205)(PORT = 1521))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
)
)
通过 net manager可以配置更多参数。
直接netmgr。
其中 Global database name = db_name.db_domain
本人的参数如下:
show parameter name
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_file_name_convert string
db_name string guo
db_unique_name string guo
global_names boolean FALSE
instance_name string guo
lock_name_space string
log_file_name_convert string
service_names string guo
SQL> show parameter doma
SQL> show parameter doma
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_domain string
所以 我的Global database name就是 guo
通过net manager修改过后listener.ora如下
# listener.ora Network Configuration File: /u01/app/oracle/product/10.2.0/db_1/n
etwork/admin/listener.ora
# Generated by Oracle configuration tools.SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = /u01/app/oracle/product/10.2.0/db_1)
(PROGRAM = extproc)
)
(SID_DESC =
(GLOBAL_DBNAME = guo)
(ORACLE_HOME = /u01/app/oracle/product/10.2.0/db_1)
(SID_NAME = guo)
)
)LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.205)(PORT = 1521))
)
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
)
)TRACE_LEVEL_LISTENER = USER
监听如下:
[oracle@oral admin]$ lsnrctl start
LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 22-NOV-2011 03:02:52
Copyright (c) 1991, 2005, Oracle. All rights reserved.
Starting /u01/app/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/product/10.2.0/db_1/network/admin/listener.ora
Log messages written to /u01/app/oracle/product/10.2.0/db_1/network/log/listener.log
Trace information written to /u01/app/oracle/product/10.2.0/db_1/network/trace/listener.trc
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.1.205)(PORT=1521)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC0)))Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.205)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 10.2.0.1.0 - Production
Start Date 22-NOV-2011 03:02:52
Uptime 0 days 0 hr. 0 min. 0 sec
Trace Level user
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/oracle/product/10.2.0/db_1/network/admin/listener.ora
Listener Log File /u01/app/oracle/product/10.2.0/db_1/network/log/listener.log
Listener Trace File /u01/app/oracle/product/10.2.0/db_1/network/trace/listener.trc
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.1.205)(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 "guo" has 1 instance(s).
Instance "guo", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
c:\>sqlplus hr/hr@guo
即可成功连接到数据库。
用tail –f 可以查看实时日志信息。
[oracle@oral admin]$ tail -f //u01/app/oracle/product/10.2.0/db_1/network/log/listener.log
Listener completed notification to CRS on startTIMESTAMP * CONNECT DATA [* PROTOCOL INFO] * EVENT [* SID] * RETURN CODE
WARNING: Subscription for node down event still pending
22-NOV-2011 03:02:52 * (CONNECT_DATA=(CID=(PROGRAM=)(HOST=oral)(USER=oracle))(COMMAND=status)(ARGUMENTS=64)(SERVICE=LISTENER)(VERSION=169869568)) * status * 0
WARNING: Subscription for node down event still pending
22-NOV-2011 03:07:06 * (CONNECT_DATA=(CID=(PROGRAM=)(HOST=oral)(USER=oracle))(COMMAND=status)(ARGUMENTS=64)(SERVICE=LISTENER)(VERSION=169869568)) * status * 0
WARNING: Subscription for node down event still pending
22-NOV-2011 03:22:00 * (CONNECT_DATA=(CID=(PROGRAM=)(HOST=oral)(USER=oracle))(COMMAND=status)(ARGUMENTS=64)(SERVICE=LISTENER)(VERSION=169869568)) * status * 0
22-NOV-2011 03:22:24 * (CONNECT_DATA=(SERVICE_NAME=guo)(CID=(PROGRAM=E:\oracle\product\10.2.0\client_1\bin\sqlplus.exe)(HOST=PC-201102141146)(USER=Administrator))) * (ADDRESS=(PROTOCOL=tcp)(HOST=192.168.1.102)(PORT=2187)) * establish * guo * 0
22-NOV-2011 03:24:44 * (CONNECT_DATA=(SERVICE_NAME=guo)(CID=(PROGRAM=E:\oracle\product\10.2.0\client_1\bin\sqlplus.exe)(HOST=PC-201102141146)(USER=Administrator))) * (ADDRESS=(PROTOCOL=tcp)(HOST=192.168.1.102)(PORT=2219)) * establish * guo * 0
我PC机名字 和IP 加粗显示了。
lsnrctl 命令
lsnrctl start 启动默认的listener
lsnrctl start listener02 启动listener.ora中新增的监听
lsnrctl stop
lsnrctl status 查看lsnrctl的现在状态
lsnrctl > help
lsnrctl >reload 刷新
lsnrctl >trace