Linux/Unix shell monitoring Oracle listener (Monitor listener)

Source: Internet
Author: User

Using shell scripts to monitor and manage Oracle databases will greatly simplify DBA workload, such as common instance monitoring, monitoring, and alarm log monitoring, and database backup, AWR report automatic mail, etc. This section describes how to use shell scripts to monitor Oracle listeners in Linux.

Linux Shell:
Linux/Unix shell scripts call SQL and RMAN scripts
Passing variables between Linux/Unix shell SQL statements
Linux/Unix shell calls PL/SQL
Linux/Unix shell monitoring Oracle instance (Monitor instance)

 

1. Monitor Oracle shell scripts

Robin @ szdb :~ /Dba_scripts/custom/bin> More ck_lsnr.sh # + listener + # + check listener status and restart it when failed | # + Author: Robinson | # + blog: http://blog.csdn.net/robinson_0612 | # + parameter: no | # + ------------------------------------------------------- + #! /Bin/bash # -------------------- # define variable # ------------------ if [-f ~ /. Bash_profile]; then .~ /. Bash_profilefi timestamp = 'date + % Y % m % d % H % m'; export timestampdbalist = "robinson.cheng@12306.com "; export dbalistmailpath =/users/Robin/dba_scripts/sendEmail-v1.56LOG_DIR =/users/Robin/dba_scripts/custom/LOG_FILE =$ {log_dir}/lsnr_status _ $ timestamp. logretention = 2 # --------------------------------------- # define how to publish listeners need to monitor # --------------------------------------- db_count = 6 DB [1] = cnbo1db [2] = cnbotstdb [3] = cnmmbodb [4] = mmbotstdb [5] = sybo2szdb [6] = cnbo2 # ----------------------- # begin to check listener # listener #------------------------- touch $ log_fileecho "'date'"> $ log_fileecho "The following listeners are down on 'hostname'" >>$ log_fileecho ">>$ log_filecount = 1 while [$ count -Le $ db_count]; do for dB in $ {DB [$ count]}; do lsnr_f Lag = 'ps-Ef | grep-I listener _ $ {DB [$ count]} | grep-V grep 'If [-z "$ lsnr_flag"]; then ECHO "the listener for the database $ {DB [$ count]} is down. ">>$ LOG_FILE echo" ======> restart listener for the database $ {DB [$ count]} ">>$ LOG_FILE LSNRCTL start listener _ $ {DB [$ count] >>>$ LOG_FILE echo-e "------------------------------------------------------------------ \ n"> $ LOG_FILE fi done; count = 'expr $ Count + 1 'done; # -------------------------- # Send email # ------------------------ CNT = 'grep "restart listener" $ LOG_FILE | WC-l' if ["$ CNT"-GT 0]; then $ mailpath/sendemail-F szdb@2gotrade.com-T $ dbalist-U "listener crashed on 'hostname'"-O message-file = $ log_fileelse Rm-RF $ log_filefi # Programs # removing files older than $ retention parameter #-------- -------------------------------------- Find $ {log_dir}-name "* lsnr_status *"-mtime + $ retention-exec RM {} \; exitoracle @ szdb: /users/Robin/dba_scripts/custom/bin>. /ck_lsnr.sh Feb 01 17:16:34 szdb sendemail [18611]: email was sent successfully! Fri Feb 1 17:16:33 CST 2013 # the following content contained in the test script email is the following listeners are down on szdb ------------------------------------------- the listener for the database cnbo1 is down. ======> restart listener for the database cnbo1lsnrctl for Linux: Version 10.2.0.3.0-production on 01-feb-2013 17: 16: 33 copyright (c) 1991,200 6, Oracle. all rights reserved. starting/users/Oracle/orahome10g/bin/tnslsnr: Please wait... tnslsnr for Linux: Version 10.2.0.3.0-production system parameter file is/users/Oracle/orahome10g/Network/admin/listener. oralog messages written to/users/Oracle/orahome10g/Network/log/listener_cnbo1.loglistening on: (description = (address = (Protocol = TCP) (host = 192.101.7.2) (Port = 1901) connecting to (description = (address = (Protocol = TCP) (host = 192.101.7.2) (Port = 1901 ))) status of the listener ---------------------- alias listener_cnbo1version tnslsnr for Linux: Version 10.2.0.3.0-productionstart date 01-feb-2013 17: 16: 33 uptime 0 days 0 HR. 0 min. 0 sectrace level offsecurity on: Local OS authenticationsnmp offlistener parameter file/users/Oracle/orahome10g/Network/admin/listener. oralistener log file/users/Oracle/orahome10g/Network/log/listener_cnbo1.loglistening endpoints summary... (description = (address = (Protocol = TCP) (host = 192.101.7.2) (Port = 1901) Services summary... service "cnbo1" has 1 instance (s ). instance "cnbo1", status unknown, has 1 handler (s) for this service... the command completed successfully ------------------------------------------------------------------

2. Supplement
A. The monitoring script above can monitor multiple listeners.
B. The name of the listener is defined in the format of listener _ $ oracle_sid. The default listener is not considered. If you use the default listener, make changes accordingly.
C. Use an array to define the Instance name. each listener corresponds to one listener. Make sure that the db_count value matches the number of listeners to be monitored.
D. Each element in the array uses oracle_sid. If it is RAC, you can change it to the host name.
E. If the listener is detected to be down, the listener is automatically restarted and an email is sent.
F. The sendemail mail program is used to send emails. See: Indispensable sendemail
G. Use crontab to deploy the script. In addition, Oracle 10 Gb testing is available, and Oracle 11 GB testing is available.

 

More references

For more information about Oracle RAC, see
Use crs_setperm to modify the resource owner and permissions of RAC.
Use crs_profile to manage RAC resource configuration files
RAC database startup and Shutdown
Oracle RAC services
Services in Oracle Database 10g
Migrate datbase from single instance to Oracle RAC
Connect Oracle RAC to a specified instance
Oracle RAC load balancing test (combined with server and client)
Oracle RAC server connection Load Balance)
Load Balance)
Non-Default port listening configuration in Oracle RAC (listener. ora tnsnames. ora)
Oracle RAC Listener Configuration (listener. ora tnsnames. ora)
Configure RAC load balancing and Failover
CRS-1006, CRS-0215 fault case
Installing Oracle 10g RAC Based on Linux (RHEL 5.5)
Use runcluvfy to verify the Oracle RAC installation environment

For more information about the basics and concepts of Oracle network configuration, see:
Configure dynamic service registration for non-default ports
Configure sqlnet. ora to restrict IP Access to Oracle
Configure and manage Oracle listener logs
Set the Oracle listener password (listener)
Configure the Oracle client to connect to the database

For more information about user-managed backup and recovery, see
Oracle cold backup
Oracle Hot Backup
Concept of Oracle backup recovery
Oracle instance recovery
Oracle recovery based on user management
System tablespace management and Backup Recovery
Sysaux tablespace management and recovery
Oracle backup control file recovery (unsing backup controlfile)

For information on RMAN backup recovery and management, see
RMAN overview and architecture
RMAN configuration, Monitoring and Management
Detailed description of RMAN backup
RMAN restoration and recovery
Create and use RMAN catalog
Create RMAN storage script based on catalog
Catalog-based RMAN backup and recovery
RMAN backup path confusion
Use RMAN for recovery from different machine backups (WIN platform)
Use RMAN to migrate a file system database to ASM
Linux RMAN backup shell script
Use RMAN to migrate the database to a different machine

For the Oracle architecture, see
Oracle tablespace and data files
Oracle Password File
Oracle parameter file
Oracle online redo log file)
Oracle Control File)
Oracle archiving logs
Oracle rollback and undo)
Oracle database instance startup and Shutdown Process
Automated Management of Oracle 10g SGA
Oracle instances and Oracle databases (Oracle Architecture)

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.