For example, if the sample script is saved to a file named test_lsnr, execute the following commands:
chmod +x test_lsnr
If the sample script is saved to a file named test_lsnr, execute the following commands:
./test_lsnr -serv
OR
./test_lsnr -stat
Script
#!/bin/bash
#
#
# Usage: test_lsnr [-stat||-serv]
#
if [ "$1" = "-serv" ]; then
switch="service"
elif [ "$1" = "-stat" ]; then
switch="status"
else
echo "Usage: test_lsnr [-stat||-serv]"
exit
fi
echo "Switch = $switch"
# PS, GREP and AWK must be executable by the script user
for lsnr in `ps -ef | grep tnslsnr | grep -v grep | awk '{ print $9}'`; do
TEMP=`ps -ef | grep tnslsnr | grep " ${lsnr} " | grep -v grep | awk '{print $8}'`
export ORACLE_HOME=`printf "%s" "${TEMP%\/bin\/tnslsnr}"`
echo "Listener Name: ${lsnr}"
echo "Home: ${ORACLE_HOME}"
${ORACLE_HOME}/bin/lsnrctl ${switch} ${lsnr}
echo ""
echo ""
done
Sample output
>test_lsnr -stat
Switch = status
Listener Name: LISTENER_node1
Home: /home/oracle/oracle/product/11.1.0/asm
LSNRCTL for Linux: Version 11.1.0.7.0 - Production on 12-AUG-2011 01:54:15
Copyright (c) 1991, 2008, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=node1-vip.sftech.corp.biz)(PORT=1521)(IP=FIRST)))
STATUS of the LISTENER
------------------------
Alias LISTENER_node1
Version TNSLSNR for Linux: Version 11.1.0.7.0 - Production
Start Date 12-JUN-2011 00:47:03
Uptime 31 days 1 hr. 7 min. 11 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /home/oracle/oracle/product/11.1.0/asm/network/admin/listener.ora
Listener Log File /home/oracle/oracle/diag/tnslsnr/node1/listener_node1/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=XX.XXX.XX.XXX)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=XX.XXX.XX.XXX)(PORT=1521)))
Services Summary...
Service "+ASM" has 1 instance(s).
Instance "+ASM1", status READY, has 1 handler(s) for this service...
Service "+ASM_XPT" has 1 instance(s).
Instance "+ASM1", status READY, has 1 handler(s) for this service...
Service "instance" has 2 instance(s).
Instance "instance1", status READY, has 2 handler(s) for this service...
Instance "instance2", status READY, has 1 handler(s) for this service...
Service "instanceXDB" has 2 instance(s).
Instance "instance1", status READY, has 1 handler(s) for this service...
Instance "instance2", status READY, has 1 handler(s) for this service...
Service "instance_XPT" has 2 instance(s).
Instance "instance1", status READY, has 2 handler(s) for this service...
Instance "instance2", status READY, has 1 handler(s) for this service...
Service "conn1" has 2 instance(s).
Instance "instance1", status READY, has 2 handler(s) for this service...
Instance "instance2", status READY, has 1 handler(s) for this service...
The command completed successfully
> test_lsnr - serv
Switch = service
Listener Name: LISTENER_node1
Home: /home/oracle/oracle/product/11.1.0/asm
LSNRCTL for Linux: Version 11.1.0.7.0 - Production on 12-AUG-2011 01:57:45
Copyright (c) 1991, 2008, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=node1-vip.test.com)(PORT=1521)(IP=FIRST)))
Services Summary...
Service "+ASM" has 1 instance(s).
Instance "+ASM1", status READY, has 1 handler(s) for this service...
Handler(s):
"DEDICATED" established:0 refused:0 state:ready
LOCAL SERVER
Service "+ASM_XPT" has 1 instance(s).
Instance "+ASM1", status READY, has 1 handler(s) for this service...
Handler(s):
"DEDICATED" established:0 refused:0 state:ready
LOCAL SERVER
Service "instance" has 2 instance(s).
Instance "instance1", status READY, has 2 handler(s) for this service...
Handler(s):
"DEDICATED" established:0 refused:0 state:ready
REMOTE SERVER
(ADDRESS=(PROTOCOL=TCP)(HOST=node1-vip.test.com)(PORT=1521))
"DEDICATED" established:1097331 refused:0 state:ready
LOCAL SERVER
Instance "instance2", status READY, has 1 handler(s) for this service...
Handler(s):
"DEDICATED" established:2201353 refused:0 state:ready
REMOTE SERVER
(ADDRESS=(PROTOCOL=TCP)(HOST=node2-vip.test.com)(PORT=1521))
Service "instanceXDB" has 2 instance(s).
Instance "instance1", status READY, has 1 handler(s) for this service...
Handler(s):
"D000" established:0 refused:0 current:0 max:972 state:ready
DISPATCHER <machine: node1.test.com, pid: 4904>
(ADDRESS=(PROTOCOL=tcp)(HOST=node1.test.com)(PORT=3909))
Instance "instance2", status READY, has 1 handler(s) for this service...
Handler(s):
"D000" established:0 refused:0 current:0 max:972 state:ready
DISPATCHER <machine: node2.test.com, pid: 5389>
(ADDRESS=(PROTOCOL=tcp)(HOST=node2.test.com)(PORT=54323))
Service "instance_XPT" has 2 instance(s).
Instance "instance1", status READY, has 2 handler(s) for this service...
Handler(s):
"DEDICATED" established:0 refused:0 state:ready
REMOTE SERVER
(ADDRESS=(PROTOCOL=TCP)(HOST=node1-vip.test.com)(PORT=1521))
"DEDICATED" established:1097331 refused:0 state:ready
LOCAL SERVER
Instance "instance2", status READY, has 1 handler(s) for this service...
Handler(s):
"DEDICATED" established:2201353 refused:0 state:ready
REMOTE SERVER
(ADDRESS=(PROTOCOL=TCP)(HOST=node2-vip.test.com)(PORT=1521))
Service "conn1" has 2 instance(s).
Instance "instance1", status READY, has 2 handler(s) for this service...
Handler(s):
"DEDICATED" established:0 refused:0 state:ready
REMOTE SERVER
(ADDRESS=(PROTOCOL=TCP)(HOST=node1-vip.test.com)(PORT=1521))
"DEDICATED" established:1097331 refused:0 state:ready
LOCAL SERVER
Instance "instance2", status READY, has 1 handler(s) for this service...
Handler(s):
"DEDICATED" established:2201353 refused:0 state:ready
REMOTE SERVER
(ADDRESS=(PROTOCOL=TCP)(HOST=node2-vip.test.com)(PORT=1521))
The command completed successfully
chmod +x test_lsnr
If the sample script is saved to a file named test_lsnr, execute the following commands:
./test_lsnr -serv
OR
./test_lsnr -stat
Script
#!/bin/bash
#
#
# Usage: test_lsnr [-stat||-serv]
#
if [ "$1" = "-serv" ]; then
switch="service"
elif [ "$1" = "-stat" ]; then
switch="status"
else
echo "Usage: test_lsnr [-stat||-serv]"
exit
fi
echo "Switch = $switch"
# PS, GREP and AWK must be executable by the script user
for lsnr in `ps -ef | grep tnslsnr | grep -v grep | awk '{ print $9}'`; do
TEMP=`ps -ef | grep tnslsnr | grep " ${lsnr} " | grep -v grep | awk '{print $8}'`
export ORACLE_HOME=`printf "%s" "${TEMP%\/bin\/tnslsnr}"`
echo "Listener Name: ${lsnr}"
echo "Home: ${ORACLE_HOME}"
${ORACLE_HOME}/bin/lsnrctl ${switch} ${lsnr}
echo ""
echo ""
done
Sample output
>test_lsnr -stat
Switch = status
Listener Name: LISTENER_node1
Home: /home/oracle/oracle/product/11.1.0/asm
LSNRCTL for Linux: Version 11.1.0.7.0 - Production on 12-AUG-2011 01:54:15
Copyright (c) 1991, 2008, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=node1-vip.sftech.corp.biz)(PORT=1521)(IP=FIRST)))
STATUS of the LISTENER
------------------------
Alias LISTENER_node1
Version TNSLSNR for Linux: Version 11.1.0.7.0 - Production
Start Date 12-JUN-2011 00:47:03
Uptime 31 days 1 hr. 7 min. 11 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /home/oracle/oracle/product/11.1.0/asm/network/admin/listener.ora
Listener Log File /home/oracle/oracle/diag/tnslsnr/node1/listener_node1/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=XX.XXX.XX.XXX)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=XX.XXX.XX.XXX)(PORT=1521)))
Services Summary...
Service "+ASM" has 1 instance(s).
Instance "+ASM1", status READY, has 1 handler(s) for this service...
Service "+ASM_XPT" has 1 instance(s).
Instance "+ASM1", status READY, has 1 handler(s) for this service...
Service "instance" has 2 instance(s).
Instance "instance1", status READY, has 2 handler(s) for this service...
Instance "instance2", status READY, has 1 handler(s) for this service...
Service "instanceXDB" has 2 instance(s).
Instance "instance1", status READY, has 1 handler(s) for this service...
Instance "instance2", status READY, has 1 handler(s) for this service...
Service "instance_XPT" has 2 instance(s).
Instance "instance1", status READY, has 2 handler(s) for this service...
Instance "instance2", status READY, has 1 handler(s) for this service...
Service "conn1" has 2 instance(s).
Instance "instance1", status READY, has 2 handler(s) for this service...
Instance "instance2", status READY, has 1 handler(s) for this service...
The command completed successfully
> test_lsnr - serv
Switch = service
Listener Name: LISTENER_node1
Home: /home/oracle/oracle/product/11.1.0/asm
LSNRCTL for Linux: Version 11.1.0.7.0 - Production on 12-AUG-2011 01:57:45
Copyright (c) 1991, 2008, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=node1-vip.test.com)(PORT=1521)(IP=FIRST)))
Services Summary...
Service "+ASM" has 1 instance(s).
Instance "+ASM1", status READY, has 1 handler(s) for this service...
Handler(s):
"DEDICATED" established:0 refused:0 state:ready
LOCAL SERVER
Service "+ASM_XPT" has 1 instance(s).
Instance "+ASM1", status READY, has 1 handler(s) for this service...
Handler(s):
"DEDICATED" established:0 refused:0 state:ready
LOCAL SERVER
Service "instance" has 2 instance(s).
Instance "instance1", status READY, has 2 handler(s) for this service...
Handler(s):
"DEDICATED" established:0 refused:0 state:ready
REMOTE SERVER
(ADDRESS=(PROTOCOL=TCP)(HOST=node1-vip.test.com)(PORT=1521))
"DEDICATED" established:1097331 refused:0 state:ready
LOCAL SERVER
Instance "instance2", status READY, has 1 handler(s) for this service...
Handler(s):
"DEDICATED" established:2201353 refused:0 state:ready
REMOTE SERVER
(ADDRESS=(PROTOCOL=TCP)(HOST=node2-vip.test.com)(PORT=1521))
Service "instanceXDB" has 2 instance(s).
Instance "instance1", status READY, has 1 handler(s) for this service...
Handler(s):
"D000" established:0 refused:0 current:0 max:972 state:ready
DISPATCHER <machine: node1.test.com, pid: 4904>
(ADDRESS=(PROTOCOL=tcp)(HOST=node1.test.com)(PORT=3909))
Instance "instance2", status READY, has 1 handler(s) for this service...
Handler(s):
"D000" established:0 refused:0 current:0 max:972 state:ready
DISPATCHER <machine: node2.test.com, pid: 5389>
(ADDRESS=(PROTOCOL=tcp)(HOST=node2.test.com)(PORT=54323))
Service "instance_XPT" has 2 instance(s).
Instance "instance1", status READY, has 2 handler(s) for this service...
Handler(s):
"DEDICATED" established:0 refused:0 state:ready
REMOTE SERVER
(ADDRESS=(PROTOCOL=TCP)(HOST=node1-vip.test.com)(PORT=1521))
"DEDICATED" established:1097331 refused:0 state:ready
LOCAL SERVER
Instance "instance2", status READY, has 1 handler(s) for this service...
Handler(s):
"DEDICATED" established:2201353 refused:0 state:ready
REMOTE SERVER
(ADDRESS=(PROTOCOL=TCP)(HOST=node2-vip.test.com)(PORT=1521))
Service "conn1" has 2 instance(s).
Instance "instance1", status READY, has 2 handler(s) for this service...
Handler(s):
"DEDICATED" established:0 refused:0 state:ready
REMOTE SERVER
(ADDRESS=(PROTOCOL=TCP)(HOST=node1-vip.test.com)(PORT=1521))
"DEDICATED" established:1097331 refused:0 state:ready
LOCAL SERVER
Instance "instance2", status READY, has 1 handler(s) for this service...
Handler(s):
"DEDICATED" established:2201353 refused:0 state:ready
REMOTE SERVER
(ADDRESS=(PROTOCOL=TCP)(HOST=node2-vip.test.com)(PORT=1521))
The command completed successfully
No comments:
Post a Comment