nagios 實現Mysql 主從同步狀態的監控,nagiosmysql

來源:互聯網
上載者:User

nagios 實現Mysql 主從同步狀態的監控,nagiosmysql

一、系統內容

     

主機名稱

IP

nagios

192.168.15.111

mysql_s

192.168.15.21

 

二、操作步驟

2.1 mysql_s端的配置

2.1.1 編寫check_mysql_slave監控指令碼

     cd /usr/local/nagios/libexec   #切換到nagios監控外掛程式所在目錄

     vim check_mysql_slave       #開始編寫mysql_slave監控指令碼

注意:監控指令碼中的mysql賬戶一定要建立一個,並設定有限的許可權。

 

2.1.2 給指令碼增加可執行許可權

chmod 755 check_mysql_slave

-rwxr-xr-x   1 root root        471 Oct 16 12:59 check_mysql_slave

 

2.1.3編輯nrpe的設定檔

vim  /usr/local/nagios/libexec/etc/nrpe.cfg +204

#添加監控mysql 主從同步狀態的命令

 command[check_mysql_slave]=/usr/local/nagios/libexec/check_mysql_slave

  

2.1.4重新啟動 nrpe 服務

 

2.1.5執行指令碼測試輸出

 

 [root@mysql_s  libexec]#  ./check_mysql_slave

 

OK mysql_s  is running

  

2.2  nagios端的配置:

 

2.2.1 修改已有的 /usr/local/nagios/etc/objects/service.cfg 設定檔

 

define service {

use                                          generic-service

host_name                            mysql_slave

service_description            check_21_mysql_replication_status

check_command                 check_nrpe!check_mysql_slave

max_check_attempts          3

normal_check_interval        2

retry_check_interval             2

check_period                        24x7

notification_interval             10

notification_period                24x7

notification_options            w,u,c,r

contact_groups                   admins

process_perf_data            1

}

 

2.2.2重啟 nagios

 

[root@nagios objects]#/etc/init.d/nagios  checkconfig  #檢查設定檔是否有誤

[root@nagios objects]#/etc/init.d/nagios  reload           #重新載入設定檔

Running configuration check...done.

Stopping nagios: done.

Starting nagios: done.

 

說明:如果nagios reload完畢,監控頁面尚未出現檢測結果,可以手動測試

/usr/local/nagios/libexec/check_nrpe -H192.168.15.21 -c check_mysql_slave

 

2.2.3 最終




nagios 監控各項服務的什?

留郵箱,我給你發,好吧
 
mysql怎實現主從同步Database Backup?

1.主伺服器:
#Master start
   log-bin="d:/log/mysql/mysql_log_bin"
  server-id=1
   #Master end
  2.從伺服器:
#Slave start
log-bin="D:/log/mysql2/log-bin.log"
relay_log="D:/log/mysql2/relay-log-bin"
#從機id,區別於主機id
server-id=2
#主機ip,供從機串連主機用
#master-host=localhost
#主機連接埠
#master-port=3300
#剛才為從機複製主機資料建立的帳號
#master-user=slave
#剛才為從機複製主機資料建立的密碼
#master-password=654321
#稍候再試時間10秒
#master-connect-retry=10
#需要同步的資料庫
#replicate-do-db=test
#啟用從庫日誌,這樣可以進行鏈式複製
log-slave-updates
#從庫是否唯讀,0表示可讀寫,1表示唯讀
read-only=1

#只複製某個表
#replicate-do-table=tablename
#只複製某些表(可用匹配符)
#replicate-wild-do-table=tablename%
#只複製某個庫
#replicate-do-db=dbname
#不複製某個表
#replicate-ignore-table=tablename
#不複製某些表
#replicate-wild-ignore-table=tablename%
#不複製某個庫
#replicate-ignore-db=dbname
#Slave end
3.對從伺服器制定主伺服器使用CHANGE MASTER 語句
注意:1.一定要在主伺服器上建立一個可以執行replication的使用者
2.該使用者名稱在從伺服器上可遠程登入到主伺服器。
3.開啟MySQL的log-bin日誌功能
參考資料:blog.163.com/...31959/
 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.