PostgreSQL Hot Standby Environment Monitoring script

Source: Internet
Author: User
Tags postgres db

Postgresql introduced stream Replication in 9.0; Provides a high level of availability for DB clusters; This article provides an environmental monitoring script

Environment Construction: Reference--http://www.cnblogs.com/lottu/p/5584923.html

Environment switch: Reference--http://www.cnblogs.com/lottu/p/5725309.html

Provide the following script:

##===========================================================  ## postgres_db_check.sh## Created by Lottu## 2016/08/07## usage:postgres_db_check.sh##============================================================  #!/bin/bashExport LANG="En_us.utf8"Export DATE= ' Date +"%y%m%d"' Admail="[email protected]"Standby_number=1#there is only one repository for this environment;M_err_exit=20S_err_exit=21#determine if the main library is working correctly firstPg_ctl Status |grep runningif[ $? -NE 0];then Echo"Master Postgres db is not running;please check it!"| Mail-s"Master Postgres DB is not running"$admail exit ${m_err_exit}fi#View the status of stream replication in a cluster, which can be judged according to the table Pg_stat_replicationPsql-t-q-c"Select Client_addr,sync_state,state from Pg_stat_replication">Lottu.outl= ' Awk-f"|" '/streaming/{n+=1}end{print N}'Lottu.out 'if[$l-NE ${standby_number}];then Echo"standby Postgres db is not running;please check it!"| Mail-s"Standby Postgres DB is not running"$admail exit ${s_err_exit}fi

PostgreSQL Hot Standby Environment Monitoring script

Related Article

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.