监听分为动态注册和静态注册
?
动态注册:
?
oracle实例启动之后通过pmon进程实时的把实例状态和参数传递给listener,动态注册可以不需要listener.ora文件和tnsnames.ora文件,
数据库一定在开启的状态
?
?
[oracle@up admin]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on Fri Oct 30 20:30:14 2015
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup
ORACLE instance started.
Total System Global Area 409194496 bytes
Fixed Size 2213856 bytes
Variable Size 293603360 bytes
Database Buffers 104857600 bytes
Redo Buffers 8519680 bytes
Database mounted.
Database opened.
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@up admin]$
?
查看监听配置文件所在的目录,没有listener和tnsnames文件
[oracle@up admin]$ pwd
/u01/app/oracle/product/11.2.0/network/admin
[oracle@up admin]$ ls
listener.ora.old samples shrept.lst sqlnet.ora tnsnames.ora.old
?
启动监听:
[oracle@up admin]$ lsnrctl start
LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 30-OCT-2015 20:32:41
Copyright (c) 1991, 2009, Oracle. All rights reserved.
Starting /u01/app/oracle/product/11.2.0/bin/tnslsnr: please wait...
TNSLSNR for Linux: Version 11.2.0.1.0 - Production
Log messages written to /u01/app/oracle/diag/tnslsnr/up/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=up.oracle.com)(PORT=1521)))
Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.1.0 - Production
Start Date 30-OCT-2015 20:32:42
Uptime 0 days 0 hr. 0 min. 0 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Log File /u01/app/oracle/diag/tnslsnr/up/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=up.oracle.com)(PORT=1521)))
The listener supports no services
The command completed successfully
[oracle@up admin]$
?
?
然后在客户端登录
[oracle@up admin]$ sqlplus scott/tiger@192.168.231.3/orcl
SQL*Plus: Release 11.2.0.1.0 Production on Fri Oct 30 21:21:29 2015
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL>
?
登录成功。
?
静态注册
?
静态注册listener不知道数据库的状态,根据listener文件里的配置来设置监听
listener.ora文件内容如下:
[oracle@up admin]$ cat listener.ora
# listener.ora Network Configuration File: /u01/app/oracle/product/11.2.0/network/admin/listener.ora
# Generated by Oracle configuration tools.
#LISTENER =
# (DESCRIPTION_LIST =
# (DESCRIPTION =
# (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
# (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.231.3)(PORT = 1521))
# )
# )
#ADR_BASE_LISTENER = /u01/app/oracle
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = oracle)
(ORACLE_HOME = /u01/app/oracle/product/11.2.0)
(SID_NAME = oracle)
)
(SID_DESC =
(GLOBAL_DBNAME = ora11g)
(ORACLE_HOME = /u01/app/oracle/product/11.2.0)
(SID_NAME = oracle)
)
)
?
listener文件中
?
gl