环境清理:
sql>show parameter local local_listener
sql>alter system set local_listener='' scope=memory;
#cd $ORACLE_HOME/network/admin
#rm -rf listener.ora tnsnames.ora
listener中存放监听器位置和静态注册,其他的配置都放在客户端tnsnames.ora中
查看进程中的监听器及kill监听器进程
ps -ef | grep tnsl
查看监听器服务:
lsnrctl service
查看监听器状态,开,关
lsnrctl stat|start|stop 监听器名称
操作监听程序使用监听控制台
1.无配置启动监听程序
lsnrctl start
Alias --> LISTENER (默认名称)
HOST=oracle7.example.com
PORT=1521(默认端口)
lsnrctl status
Service "orcl.example.com" has 1 instance(s).
Instance "orcl", status READY, has 1 handler(s) for this service...
Service "prod" has 1 instance(s).
Instance "prod", status READY, has 1 handler(s) for this service...
在服务器端查看连接的会话:
select sid,serial#,username,machine from v$session where username is not null;
监听文件中有连接请求的记录:
/u01/app/oracle/diag/tnslsnr/oracle0/listener/alert/log.xml
2.客户端使用简单连接:
起用新的设备指定新的
IP:
ifconfig eth0:0 172.25.0.110/24
使用命令手动激活
pmon注册实例信息到监听程序
conn / as sysdba
alter system register;
3.使用监听配置文件约束监听程序
vi $ORACLE_HOME/network/admin/listener.ora
-------------------------------------------------------------------
LISTENER =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.25.0.10)(PORT = 1521))
)
-------------------------------------------------------------------
实例的静态注册:实例的信息手工写在listener.ora文件
vi $ORACLE_HOME/network/admin/listener.ora
------------------------------------------------------------------
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = qq) --数据库为一名
(ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_1)
(SID_NAME = qq) --ORACLE_SID
)
)
LISTENER =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.25.0.10)(PORT = 1521))
)
------------------------------------------------------------------
PS:静态注册信息一定要放在上方。
4.客户端的配置使用服务命名
vi $ORACLE_HOME/network/admin/tnsnames.ora
-------------------------------------------------------------------
TEACHER10 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.25.0.10)(PORT = 1521))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = prod)
)
)
-------------------------------------------------------------------
5.修改监听端口
lsnrctl stop
vi $ORACLE_HOME/network/admin/listener.ora
-------------------------------------------------------------------
LISTENER =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.25.0.10)(PORT = 9527))
)
-------------------------------------------------------------------
使用参数说明监听的
IP和端口
local_listener:向指定IP指定端口注册实例
赋值方法
1:
alter system set local_listener='(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=172.25.0.10)(PORT=9527)))';
赋值方法
2:
vi $ORACLE_HOME/network/admin/tnsnames.ora
-------------------------------------------------------------------
LISTENER_PROD
=
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.25.0.10)(PORT = 9527))
)
-------------------------------------------------------------------
alter system set local_listener='
LISTENER_PROD
';
6.修改监听名称,启动自定义名称的监听程序
lsnrctl stop
vi $ORACLE_HOME/network/admin/listener.ora
-------------------------------------------------------------------
L2 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.25.0.10)(PORT = 9527))
)
-------------------------------------------------------------------
lsnrctl stop L2
lsnrctl start L2
lsnrctl status L2
如何查看已经启动的监听叫什么名字
[oracle@oracle0 admin]$ ps -ef | grep tnsl
oracle 5276 1 0 13:10 ? 00:00:00 /u01/app/oracle/product/11.2.0/db_1/bin/tnslsnr l2 -inherit
=========================================================================================
由于本人能力有限,文章若有书写,表达错误请指正...