[20170705]lsnrctl status LISTENER_SCAN1.txt
--//前几天在解决问题时遇到的问题,现在分析看看.当时没注意操作用户名,选择错误的用户执行(oracle用户执行).
1.环境:
--//rac
SYS@dbcn2> @ &r/ver1
PORT_STRING VERSION BANNER
------------------------------ -------------- --------------------------------------------------------------------------------
x86_64/Linux 2.4.xx 11.2.0.4.0 Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
--//以oracle用户执行:
$ lsnrctl status LISTENER_SCAN1
LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 05-JUL-2017 10:26:47
Copyright (c) 1991, 2013, Oracle. All rights reserved.
TNS-01101: Could not find service name LISTENER_SCAN1
--//实际上使用grid用户执行就ok了.使用strace做一次跟踪看看.
$ strace -f -o /tmp/a.txt lsnrctl status LISTENER_SCAN1
$ grep listener.ora /tmp/a.txt
90212 access("/etc/listener.ora", F_OK) = -1 ENOENT (No such file or directory)
90212 access("/u01/app/oracle/product/11.2.0.4/dbhome_1/network/admin/listener.ora", F_OK) = -1 ENOENT (No such file or directory)
--//可以发现这个文件不存在.不要在正式的数据库做这样的操作,这里仅仅是测试.
# cp /u01/app/11.2.0.4/grid/network/admin/listener.ora /u01/app/oracle/product/11.2.0.4/dbhome_1/network/admin/
--//再次执行就ok了.
$ lsnrctl status LISTENER_SCAN1
--//删除文件/u01/app/oracle/product/11.2.0.4/dbhome_1/network/admin/listener.ora
2.疑问:
--//为什么在oracle下单独执行lsnrctl status 没有问题呢?
--//实际上oracle 缺省默认的建立名字就是LISTENER.
$ lsnrctl status
LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 05-JUL-2017 10:37:27
Copyright (c) 1991, 2013, Oracle. All rights reserved.
Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
STATUS of the LISTENER
------------------------
Alias LISTENER
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Version TNSLSNR for Linux: Version 11.2.0.4.0 - Production
Start Date 29-JUN-2017 19:23:54
Uptime 5 days 15 hr. 13 min. 33 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/11.2.0.4/grid/network/admin/listener.ora
Listener Log File /u01/app/11.2.0.4/grid/network/log/listener.log
....
--//让我感到奇怪的是,为什么现在能找到参数文件正确的参数文件/u01/app/11.2.0.4/grid/network/admin/listener.ora呢.
3.再次跟踪看看:
$ strace -f -o /tmp/a2.txt lsnrctl status
$ grep listener.ora /tmp/a2.txt
115234 access("/etc/listener.ora", F_OK) = -1 ENOENT (No such file or directory)
115234 access("/u01/app/oracle/product/11.2.0.4/dbhome_1/network/admin/listener.ora", F_OK) = -1 ENOENT (No such file or directory)
--//也是没有找到监听.
115234 access("/var/tmp/.oracle/s#48978.2", F_OK) = 0
115234 connect(6, {sa_family=AF_FILE, path="/var/tmp/.oracle/s#48978.2"...}, 110) = 0
115234 fcntl(6, F_SETFD, FD_CLOEXEC) = 0
--//进程会读取/var/tmp/.oracle/s#48978.2.
# ls -l /var/tmp/.oracle/s#48978.2
srwxrwxrwx 1 grid oinstall 0 2017-06-29 19:23:54 /var/tmp/.oracle/s#48978.2
--//socket文件.里面的数值对于进程号.
# lsof | grep /var/tmp/.oracle/s#48978.2
tnslsnr 48978 grid 10u unix 0xffff881738bfe180 0t0 1991767425 /var/tmp/.oracle/s#48978.2
# ps -elf | egrep "48978|PID"
F S UID PID PPID C PRI NI ADDR SZ WCHAN STIME TTY TIME CMD
0 S root 1936 87074 0 80 0 - 15299 pipe_w 10:50 pts/1 00:00:00 egrep 48978|PID
0 S grid 48978 1 0 80 0 - 38621 poll_s Jun29 ? 00:36:25 /u01/app/11.2.0.4/grid/bin/tnslsnr LISTENER -inherit
--//正是进程/u01/app/11.2.0.4/grid/bin/tnslsnr LISTENER -inherit.监听的别名是LISTENER.
# cat /proc/48978/environ | tr '\0' '\n'| grep -i admin
TNS_ADMIN=/u01/app/11.2.0.4/grid/network/admin/
--//所以oracle用户可以正常执行lsnrctl status .
4.补充说明:
--//实际上跟踪查看前面的/tmp/a.txt文件,只要对应的tnsnames.ora存在这个名字,一样ok了.
$ grep tnsnames.ora /tmp/a.txt
90212 access("/home/oracle/.tnsnames.ora", F_OK) = -1 ENOENT (No such file or directory)
90212 access("/etc/tnsnames.ora", F_OK) = -1 ENOENT (No such file or directory)
90212 access("/u01/app/oracle/product/11.2.0.4/dbhome_1/network/admin/tnsnames.ora", F_OK) = 0
90212 stat("/u01/app/oracle/product/11.2.0.4/dbhome_1/network/admin/tnsnames.ora", {st_mode=S_IFREG|0640, st_size=6403, ...}) = 0
90212 open("/u01/app/oracle/product/11.2.0.4/dbhome_1/network/admin/tnsnames.ora", O_RDONLY) = 5
90212 read(5, "# tnsnames.ora Network Configura"..., 4096) = 4096
--//在/u01/app/oracle/product/11.2.0.4/dbhome_1/network/admin目录的tnsnames.ora文件中加入如下:
LISTENER_SCAN1=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER_SCAN1))))
$ lsnrctl status LISTENER_SCAN1
LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 05-JUL-2017 11:09:36
Copyright (c) 1991, 2013, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER_SCAN1)))
STATUS of the LISTENER
------------------------
Alias LISTENER_SCAN1
Version TNSLSNR for Linux: Version 11.2.0.4.0 - Production
Start Date 30-JUN-2017 12:01:44
Uptime 4 days 23 hr. 7 min. 51 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/11.2.0.4/grid/network/admin/listener.ora
Listener Log File /u01/app/11.2.0.4/grid/network/log/listener_scan1.log
...
--//收尾:
--//仅仅作为一次学习与了解这方面内容,还原现场.
--//正常作为管理rac数据库系统还是应该选择grid用户来执行这些命令.