7、listener监听
发动长途图形界面登录的东西
[root@db11g ~]# vncserver
监听
监听的发动
[oracle@db11g ~]$ lsnrctl start
判别监听是否发动
[oracle@db11g ~]$ 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端口
检查监听状况
[oracle@db11g ~]$ 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
检查监听进程
[oracle@db11g ~]$ ps -ef | grep 1440
oracle 1440 1 0 Jan10 ? 00:00:11 /u01/app/oracle/product/11.2.0/db_1/bin/tnslsnr LISTENER -inherit
oracle 13687 13645 0 02:59 pts/0 00:00:00 grep 1440
监听表现为一个进程,默许端口号:1521
监听的装备文件
1、listener.ora文件(首要装备监听)
listener.ora文件:服务器端的(发动监听的时分读listener.ora文件)
listener.ora文件方位:
[oracle@db11g ~]$ cd /u01/app/oracle/product/11.2.0/db_1/network/admin
[oracle@db11g admin]$ ls
listener.ora samples shrept.lst tnsnames.ora
listener.ora文件操控着监听
没有listener.ora文件时:
假如没有listener.ora装备文件,监听也能够发动,默许运用1521端口,一切IP都发动1521端口,下图解说:
默许状况下,今后经过一切的IP地址都能够衔接
检查恣意一个IP地址是否发动1521端口,发动着1521端口都能够衔接上数据库实例
以192.168.56.70为例:
[oracle@db11g ~]$ telnet 192.168.56.70 1521
这就表明着:在192.168.56.70地址上发动着1521端口
然后ctrl+c退出
发动数据库实例:
[oracle@db11g ~]$ 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衔接上数据库
2、点击continue按钮
3、输入暗码,点击OK
点击'X'封闭
翻开open terminal
4、运用netca指令装备监听,能够生成listener.ora这个文件:
首要Set and export DISPLAY(指定图画映射机器):
[oracle@db11g admin]$ export DISPLAY=192.168.56.1:0.0
5、挑选listener configuration,点击next
6、由于没有listener.ora这个文件,所以挑选Add,点击next
7、监听的姓名,默许就要LISTENER,点击next
8、挑选TCP,点击next
9、挑选默许端口1521
10、挑选No,点击next
11、点击finish
装备完结
12、检查装备完结的listener.ora文件:
[oracle@db11g ~]$ cd $ORACLE_HOME
[oracle@db11g db_1]$ cd network/admin
[oracle@db11g admin]$ ls
listener.ora samples shrept.lst tnsnames.ora
13、修正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、重新发动监听
[oracle@db11g admin]$ 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
[oracle@db11g admin]$ lsnrctl start -- 发动监听
[oracle@db11g admin]$ 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 successfully
15、再次检查监听
[oracle@db11g admin]$ 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,就会导致运用其他监听衔接数据库实例的时分衔接不上
图解:
怎么静态注册监听?
1、运用netmgr指令:
[oracle@db11g admin]$ netmgr
2、挑选listener1,然后挑选database services
3、挑选add database
4、输入global database name:cis1(服务名,能够自己输入),SID:cis(数据库实例名)
5、保存,然后退出
6、重启监听listener1,检查状况
[oracle@db11g admin]$ lsnrctl reload listener1
[oracle@db11g admin]$ lsnrctl status listener1
静态注册的监听listener1:
status的几个状况
1、ready:能够衔接,动态注册
2、blocked:不能够衔接,动态注册
3、unknown:静态注册,是否能够衔接取决于实例是否发动
监听的几个状况:
多个监听
1、两个姓名:
一个ip、两个端口
两个ip、一个端口
2、一个姓名:
一个ip、两个端口,可是只起一个进程
两个ip、一个端口
一般状况咱们说的是:两个姓名、两个ip、同一个端口,listener1静态注册的