7、listener监听
启动远程图形界面登录的工具# vncserver监听
监听的启动
$ lsnrctl start判断监听是否启动
$ netstat -tulnp | grep 1521
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
tcp 0 0 :::1521 :::* LISTEN 1440/tnslsnr-- LISTEN:表示监听已经启动
-- 1440:监听对应的进程编号
-- ::: 表示所有的IP地址都启动1521端口
检察监听状态
$ lsnrctl status -- 这个命令默认是:lsnrctl status listener
LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 13-JAN-2017 02:56:53
Copyright (c) 1991, 2013, Oracle.All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=db11g)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.4.0 - Production
Start Date 10-JAN-2017 19:47:03
Uptime 2 days 7 hr. 9 min. 49 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/db11g/listener/alert/log.xml
Listening Endpoints Summary…
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=db11g)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Services Summary…
Service "orcl" has 1 instance(s).
Instance "orcl", status READY, has 1 handler(s) for this service…
Service "orclXDB" has 1 instance(s).
Instance "orcl", status READY, has 1 handler(s) for this service…
The command completed successfully检察监听进程
$ ps -ef | grep 1440
oracle 1440 10 Jan10 ? 00:00:11 /u01/app/oracle/product/11.2.0/db_1/bin/tnslsnr LISTENER -inherit
oracle 13687 136450 02:59 pts/0 00:00:00 grep 1440监听表现为一个进程,默认端标语:1521
监听的配置文件
1、listener.ora文件(主要配置监听)
listener.ora文件:服务器端的(启动监听的时间读listener.ora文件)
listener.ora文件位置:
$ cd /u01/app/oracle/product/11.2.0/db_1/network/admin
$ ls
listener.orasamplesshrept.lsttnsnames.oralistener.ora文件控制着监听
没有listener.ora文件时:
假如没有listener.ora配置文件,监听也可以启动,默认使用1521端口,所有IP都启动1521端口,下图表明:
https://img2024.cnblogs.com/blog/2538737/202411/2538737-20241118164557433-358065092.png
默认情况下,以后通过所有的IP地址都可以毗连
检察恣意一个IP地址是否启动1521端口,启动着1521端口都可以毗连上数据库实例
以192.168.56.70为例:
$ telnet 192.168.56.70 1521https://img2024.cnblogs.com/blog/2538737/202411/2538737-20241118164846898-2089480869.png
这就表示着:在192.168.56.70地址上启动着1521端口
然后ctrl+c退出
启动数据库实例:
$ sqlplus / as sysdba --登录数据库
SQL*Plus: Release 11.2.0.4.0 Production on Fri Jan 13 06:02:46 2017
Copyright (c) 1982, 2013, Oracle.All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> startup --启动数据库实例配置listener.ora监听文件(建立、添加一个监听)
只想要某一个IP地址启动1521端口,例如:只想在192.168.56.70这个IP地址上启动1521端口,这时要去生成一个配置文件:
1、使用vnc毗连上数据库
https://img2024.cnblogs.com/blog/2538737/202411/2538737-20241118164902811-2062213124.png
2、点击continue按钮
https://img2024.cnblogs.com/blog/2538737/202411/2538737-20241118165020027-1308731563.png
3、输入暗码,点击OK
https://img2024.cnblogs.com/blog/2538737/202411/2538737-20241118165031015-171406638.png
点击'X'关闭
https://img2024.cnblogs.com/blog/2538737/202411/2538737-20241118165040453-95995666.png
打开open terminal
https://img2024.cnblogs.com/blog/2538737/202411/2538737-20241118165049100-943551882.png
4、使用netca下令配置监听,可以生成listener.ora这个文件:
首先Set and export DISPLAY(指定图像映射机器):
$ export DISPLAY=192.168.56.1:0.0 https://img2024.cnblogs.com/blog/2538737/202411/2538737-20241118165111831-546200184.png
5、选择listener configuration,点击next
https://img2024.cnblogs.com/blog/2538737/202411/2538737-20241118165119224-557218175.png
6、由于没有listener.ora这个文件,所以选择Add,点击next
https://img2024.cnblogs.com/blog/2538737/202411/2538737-20241118165126372-1219770913.png
7、监听的名字,默认就要LISTENER,点击next
https://img2024.cnblogs.com/blog/2538737/202411/2538737-20241118165132765-1754064297.png
8、选择TCP,点击next
https://img2024.cnblogs.com/blog/2538737/202411/2538737-20241118165138767-1645570918.png
9、选择默认端口1521
https://img2024.cnblogs.com/blog/2538737/202411/2538737-20241118165146331-1418295368.png
10、选择No,点击next
https://img2024.cnblogs.com/blog/2538737/202411/2538737-20241118165152953-1491325210.png
https://img2024.cnblogs.com/blog/2538737/202411/2538737-20241118165158548-1897481756.png
11、点击finish
https://img2024.cnblogs.com/blog/2538737/202411/2538737-20241118165206519-2146921736.png
配置完成
12、检察配置完成的listener.ora文件:
$ cd $ORACLE_HOME
$ cd network/admin
$ ls
listener.orasamplesshrept.lsttnsnames.ora13、修改listener.ora文件:
# listener.ora Network Configuration File: /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
# Generated by Oracle configuration tools.
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.70)(PORT = 1521)) --将原来的主机名改为IP地址:192.168.56.70
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
)
ADR_BASE_LISTENER = /u01/app/oracle注意:LISTENER监听这个名字不要去修改它,由于pmonitor默认是往名字为LISTENER的监听里注册instancename和servername
14、重新启动监听
$ lsnrctl stop -- 关闭监听
LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 16-JAN-2017 15:08:18
Copyright (c) 1991, 2013, Oracle.All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.56.12)(PORT=1521)))
The command completed successfully
$ lsnrctl start -- 启动监听
$ lsnrctl status --查看监听状态
LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 16-JAN-2017 15:09:53
Copyright (c) 1991, 2013, Oracle.All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.56.12)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.4.0 - Production
Start Date 16-JAN-2017 15:09:04
Uptime 0 days 0 hr. 0 min. 49 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFFL
istener Parameter File /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/db11g/listener/alert/log.xml
Listening Endpoints Summary…
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.56.12)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Services Summary…
Service "orcl" has 1 instance(s).
Instance "orcl", status READY, has 1 handler(s) for this service… --说明监听已成功启动
Service "orclXDB" has 1 instance(s).
Instance "orcl", status READY, has 1 handler(s) for this service…
The command completed successfully15、再次检察监听
$ netstat -tulpn | grep 1521
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
tcp 0 0 192.168.56.70:1521 0.0.0.0:* LISTEN 1583/tnslsnr这时间只有192.168.56.70这个IP地址上启动了1521端口
监听的静态注册
我们也可以建立多个监听,但是pmonitor默认是往名字为LISTENER的监听里注册instancename和servername,就会导致使用其他监听连接数据库实例的时候连接不上图解:
https://img2024.cnblogs.com/blog/2538737/202411/2538737-20241118165250796-1019860327.png
如何静态注册监听?
1、使用netmgr下令:
$ netmgr2、选择listener1,然后选择database services
https://img2024.cnblogs.com/blog/2538737/202411/2538737-20241118165409798-534604598.png
3、选择add database
https://img2024.cnblogs.com/blog/2538737/202411/2538737-20241120135435091-513530926.png
4、输入global database name:cis1(服务名,可以自己输入),SID:cis(数据库实例名)
https://img2024.cnblogs.com/blog/2538737/202411/2538737-20241120135445691-360753364.png
5、生存,然后退出
https://img2024.cnblogs.com/blog/2538737/202411/2538737-20241120135456520-987712192.png
6、重启监听listener1,检察状态
$ lsnrctl reload listener1
$ lsnrctl status listener1https://img2024.cnblogs.com/blog/2538737/202411/2538737-20241120135539110-376051105.png
静态注册的监听listener1:
https://img2024.cnblogs.com/blog/2538737/202411/2538737-20241120135530267-365209094.png
status的几个状态
1、ready:可以连接,动态注册
2、blocked:不可以连接,动态注册
3、unknown:静态注册,是否可以连接取决于实例是否启动监听的几个情况:
多个监听
1、两个名字:
一个ip、两个端口
两个ip、一个端口
2、一个名字:
一个ip、两个端口,但是只起一个进程
https://img2024.cnblogs.com/blog/2538737/202411/2538737-20241120135602440-1625432953.png
两个ip、一个端口
一般情况我们说的是:两个名字、两个ip、同一个端口,listener1静态注册的
https://img2024.cnblogs.com/blog/2538737/202411/2538737-20241120135612007-50917880.png
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。
页:
[1]