oracle之lsnrctl命令采样:
[oracle@sh02 ~]$ cat /etc/redhat-release
Red Hat Enterprise Linux Server release 6.4 (Santiago)
[oracle@sh02 ~]$ uname -r
2.6.32-358.el6.x86_64
[oracle@shfpdb02 ~]$ uname -r
2.6.32-358.el6.x86_64
[oracle@shfpdb02 ~]$ lscpu
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
CPU(s): 80
On-line CPU(s) list: 0-79
Thread(s) per core: 2
Core(s) per socket: 10
Socket(s): 4
NUMA node(s): 4
Vendor ID: GenuineIntel
CPU family: 6
Model: 62
Stepping: 7
CPU MHz: 2194.697
BogoMIPS: 4388.89
Virtualization: VT-x
L1d cache: 32K
L1i cache: 32K
L2 cache: 256K
L3 cache: 20480K
NUMA node0 CPU(s): 0-9,40-49
NUMA node1 CPU(s): 10-19,50-59
NUMA node2 CPU(s): 20-29,60-69
NUMA node3 CPU(s): 30-39,70-79
查看是否启⽤,查看监听状态:
/
/做两个测试,因为节点是两个,当前节点的停⽌
[grid@sh02 ~]$ srvctl status listener
Listener LISTENER is enabled
Listener LISTENER is running on node(s): shfpdb01
//启动
[grid@sh02 ~]$ lsnrctl start
LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 11-MAR-2022 16:30:59 Copyright (c) 1991, 2013, Oracle. All rights reserved.
Starting /u01/app/11.2.0/grid/bin/tnslsnr:
TNSLSNR for Linux: Version 11.2.0.4.0 - Production
System parameter file is /u01/app/11.2.0/grid/network/a
Log messages written to /u01/app/grid/diag/tnslsnr/shfpdb02/listener/l Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER))) Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER))) STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.4.0 - Production
Start Date 11-MAR-2022 16:30:59
Uptime 0 days 0 hr. 0 min. 0 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/11.2.0/grid/network/a
Listener Log File /u01/app/grid/diag/tnslsnr/sh02/listener/l
Listening
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER)))
Service "ht" has 1 instance(s).
Instance "ht", status UNKNOWN, has 1 handler(s) for
The command completed successfully
//重新查看本地
[grid@sh02 ~]$ srvctl status listener
Listener LISTENER is enabled
Listener LISTENER is running on node(s): sh02,sh01
/
/查看进程
[grid@sh02 ~]$ ps -efww |grep lsnr//注意这⾥的所属⽤户,否则你设置了密码保护之后,只能⽤所属⽤户登录后才能进⾏更改grid 12854 1 0 15:46 ? 00:00:00 /u01/app/11.2.0/grid/bin/tnslsnr LISTENER_SCAN1 -inherit
grid 32735 1 0 16:30 ? 00:00:00 /u01/app/11.2.0/grid/bin/tnslsnr LISTENER -inherit
grid 33921 31866 0 16:33 pts/0 00:00:00 grep lsnr
//我们进⼊oracle⽤户,尝试停⽌监听
[grid@sh02 ~]$ exit
logout
[root@sh02 ~]# su - oracle
oracle登录命令[oracle@sh02 ~]$ lsnrctl stop
LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 11-MAR-2022 16:34:30
Copyright (c) 1991, 2013, Oracle. All rights reserved.
Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
TNS-01190: The user is not authorized to execute the requested listener command
lsnrctl命令常⽤参数详解:
1)start 启动指定的
2)stop 关闭指定的
3)status
显⽰的状态。status命令显⽰是不是活动的,⽇志与跟踪⽂件的位置,
已经持续运⾏了多长时间,以及所监听的任务。
4)services
列举的服务信息,⽐如这些服务是否有任何专⽤的预⽣成服务器进程或与之相关的调度进程,以及每个服务已有多少连接被接受或拒绝。
这种⽅法⽤来检查⼀个是否在监听⼀个指定服务。
列出服务的⼀个汇总表及为每个协议服务处理程序所建⽴和拒绝的连接信息个数。
5)Version 显⽰oracle net软件与协议适配器的版本。
6)reload 重新装⼊,重新读取a⽂件,但不关闭。如果该⽂件发⽣了变化,重新刷新。
7)save_config 当从lsnrctl⼯具中对a⽂件进⾏了修改时,复制⼀个叫做listener.bak的a的⽂件。
8)trace 打开的跟踪特性。
9)change_password 允许⽤户修改关闭所需要的密码。
10)quit 退出lsnrctl⼯具。
set*
password
指定在lsnrctl命令⾏⼯具中执⾏管理任务所需要的密码。
trc_file
指定跟踪信息的位置。默认设置是$ORACLE_HOME\network\
trc_directory
trc_level
跟踪级别
OFF – 未启⽤跟踪功能。OFF 为默认设置。
USER – 将跟踪设置为⽤户的相应级别。跟踪以标识⽤户导致的错误条件。
ADMIN – 将跟踪设置为数据库管理员的相应级别。跟踪以标识特定的安装问题。
SUPPORT – 将跟踪设置为客户⽀持⼈员的相应级别。跟踪⽂件可能会变得很⼤。
Oracle Corporation 建议在不进⾏⽹络问题诊断时关闭跟踪功能。
log_file
指定⼀个将把⽇志信息写到哪⾥。这个参数在默认的情况下是ON,并默认为%oracle_home%\network\log\listener.log
log_directory
log_status
current_listener
inbound_connect_timeout
定义在⼀个会话得到启动时将等待的有效响应时间。默认设置为10秒。
startup_waittime
定义在响应lsnrctl命令⾏⼯具中的⼀条status命令之前将等待多长时间。
save_config_on_stop
指定在⼀个lsnrctl会话期内所发⽣的修改在退出时是否应该被保存起来。
show命令
rawmode
显⽰关于status和service的较详细信息(当他们设置成on时)值为ON或OFF。
displaymode
把lsnrctl⼯具的显⽰模式设置成raw、compact、normal或verbose
服务显⽰模式为NORMAL
rules
trc_file
指定跟踪信息的位置。默认设置是$ORACLE_HOME\network\
current_listener
⽬前的为 listener2
inbound_connect_timeout
定义在⼀个会话得到启动时将等待的有效响应时间。默认设置为10秒。
startup_waittime
定义在响应lsnrctl命令⾏⼯具中的⼀条status命令之前将等待多长时间。
snmp_visible
save_config_on_stop
指定在⼀个lsnrctl会话期内所发⽣的修改在退出时是否应该被保存起来。
命令演⽰
LSNRCTL> help
The following operations are available
An asterisk (*) denotes a modifier or extended command:
start stop status
services version reload
save_config trace spawn
change_password quit exit
set* show*
//change_password改变监听密码
//save_config 执⾏该命令后,会备份a,同时设置到a⽂件
LSNRCTL> version
Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
TNSLSNR for Linux: Version 11.2.0.4.0 - Production
TNS for Linux: Version 11.2.0.4.0 - Production
Unix Domain Socket IPC NT Protocol Adaptor for Linux: Version 11.2.0.4.0 - Production Oracle Bequeath NT Protocol Adapter for Linux: Version 11.2.0.4.0 - Production
TCP/IP NT Protocol Adapter for Linux: Version 11.2.0.4.0 - Production,,
The command completed successfully
LSNRCTL> status
Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
STATUS of the LISTENER //名为LISTENER
------------------------
Alias LISTENER //别名LISTENER
Version TNSLSNR for Linux: Version 11.2.0.4.0 - Production //版本信息
Start Date 15-DEC-2021 11:18:18 //启动时间
Uptime 86 days 2 hr. 30 min. 23 sec //正常运⾏
Trace Level off //跟踪级别
Security ON: Local OS Authentication //安全性
SNMP OFF
Listener Parameter File /u01/app/11.2.0/grid/network/a //监听程序参数⽂件Listener Log File /u01/app/grid/diag/tnslsnr/sh02/listener/l //监听程序log⽂件Listening
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER))) (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=10.128.51.21)(PORT=1521))) (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=10.128.51.24)(PORT=1521)))
Service "+ASM" has 1 instance(s).
Instance "+ASM2", status READY, has 1 handler(s) for
Service "fp" has 1 instance(s).
Instance "fp2", status READY, has 1 handler(s) for
Service "ht" has 1 instance(s).
Instance "ht2", status UNKNOWN, has 1 handler(s) for
LSNRCTL> show 或者 help show
The following operations are available after show //以下是有效的,跟在show命令之后,例如:show An asterisk (*) denotes a modifier or extended command:
rawmode displaymode //
rules trc_file
trc_directory trc_level
log_file log_directory
log_status current_listener
inbound_connect_timeout startup_waittime
snmp_visible save_config_on_stop
dynamic_registration enable_global_dynamic_endpoint
oracle_home pid
connection_rate_limit valid_node_checking_registration
registration_invited_nodes registration_excluded_nodes
LSNRCTL> show trc_file
Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
TNS-01190: The user is not authorized to execute the requested listener command
TNS-01190: ⽤户⽆权执⾏所请求的监听程序命令LSNRCTL> show trc_directory
Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
TNS-01190: The user is not authorized to execute the requested listener command
TNS-01190: ⽤户⽆权执⾏所请求的监听程序命令
Oracle lsnrctl设置密码
1、设置的⼝令.默认⼝令为空.
LSNRCTL> change_password
2、设置session级别的密码,如果密码错误,不报错,也显⽰”命令执⾏成功”,但不能停⽌.
LSNRCTL> set password
3、保存到配置⽂件,否则下次登陆,以前设置的密码⽆效.
LSNRCTL> save_config
lsnrctl 监听命令
[grid@sh02 ~]$ lsnrctl status
LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 10-MAR-2022 20:21:04
Copyright (c) 1991, 2013, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.4.0 - Production
Start Date 15-DEC-2021 11:18:18
Uptime 85 days 9 hr. 2 min. 46 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/11.2.0/grid/network/a
Listener Log File /u01/app/grid/diag/tnslsnr/sh02/listener/l
Listening
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=10.128.51.21)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=10.128.51.24)(PORT=1521)))
Service "+ASM" has 1 instance(s). //有⼀个服务未+ASM,数据库实例名为:+ASM2
Instance "+ASM2", status READY, has 1 handler(s) for //状态ready说明是⽬前处于动态注册
Service "fp" has 1 instance(s).
Instance "fp2", status READY, has 1 handler(s) for
Service "ht" has 1 instance(s).
Instance "ht2", status UNKNOWN, has 1 handler(s) for //状态处于UNKNOWN表明处于静态注册
列举的服务信息
[oracle@sh02 ~]$ lsnrctl services
LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 11-MAR-202213:30:38
Copyright (c) 1991, 2013, Oracle. All rights reserved.
Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
Service "+ASM" has 1 instance(s).
Instance "+ASM2", status READY, has 1 handler(s) for
Handler(s):
"DEDICATED" established:0 refused:0 state:ready
LOCAL SERVER
Service "fp" has 1 instance(s).
Instance "fp2", status READY, has 1 handler(s) for
Handler(s):
"DEDICATED" established:1791 refused:0 state:ready
LOCAL SERVER
//htcmsdb服务
Service "ht" has 1 instance(s).
Instance "ht2", status UNKNOWN, has 1 handler(s) for
Handler(s):
"DEDICATED" established:0 refused:0
LOCAL SERVER
The command completed successfully
三个监听⽂件
[grid@sh02 ~]$ a
/u01/app/11.2.0/grid/network/a
[grid@sh02 ~]$ a/u01/app/oracle/product/11.2.0/db_1/network/a
[grid@sh02 ~]$ a
/u01/app/11.2.0/grid/network/a
//查看监听⽂件
[oracle@sh02 ~]$ cat /u01/app/11.2.0/grid/network/a
LISTENER_SCAN1=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER_SCAN1)))) # line added by Agent
LISTENER=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER)))) #出⼀个定义的起始点ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER=ON # line added by Agent
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = htcmsdb)
(ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_1) //安装位置
(SID_NAME =htcmsdb2) //oracle sid
)
)
监听⽂件的各个参数的作⽤描述如下:
LISTENER 指出⼀个定义的起始点。它实际上是正被定义的当前的名称。默认的名称是LISTENER。
DESCRIPTION 描述每个监听位置
ADDRESS_LIST 含有与正在监听的那些位置有关的地址信息
PROTOCOL 指定⽤于本监听位置的协议
HOST 保存所驻留在的那台计算机的名称
PORT 含有正在上⾯监听的地址
SID_LIST_LISTENER 定义配置所针对的ORACLE服务的列表
SID_DESC 描述每个Oracel SID
GLOBAL_DBNAME 标识全局数据库名称。本项应该与当前Oracle服务的 a⽂件中的SERVICE_NAMES项要⼀致
ORACLE_HOME 给出服务器上Oracle可执⾏程序的位置
SID_NAME 含有⽤于本Oracle实例的Oracle SID的名称
如果你对监听设置了密码
[oracle@sh02 ~]$ lsnrctl stop
LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 11-MAR-202214:29:51
Copyright (c) 1991, 2013, Oracle. All rights reserved.
Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
TNS-01190: The user is not authorized to execute the requested listener command
//不允许随便关闭监听
由于集采⽤的scan 对外服务,所以这⾥要讲这块,远程访问时,如果关闭scan 监听就会不到,但是关闭本地没有关系.
修改SCAN Listener的端⼝配置
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论