1. 程式人生 > >linux上zabbix監控mysql主從狀態

linux上zabbix監控mysql主從狀態

linux上zabbix監控mysql主從狀態

1:主從mysql上,建立監控使用者
   #建立zabbix監控使用者(只有查詢許可權)
   grant select on *.*  to [email protected]'127.0.0.1'  identified by '密碼';
   grant select on *.*  to [email protected]'localhost'  identified by '密碼';
   ##建立監控mysql使用者
   grant replication client on *.* to 'zabbix'@'localhost' identified by '密碼'
   grant replication client on *.* to 'zabbix'@'127.0.0.1' identified by '密碼';FLUSH PRIVILEGES;
   
2:自定義監控項(從庫上)
   vim /etc/zabbix/zabbix_agentd.d/userparameter_mysql.conf
   
   #slave從存活:
               UserParameter=mysql.slave,mysql -uzabbix -p"

[email protected]#8695gHf" -e "show slave status \G;" 2> /dev/null |  grep -E 'Slave_IO_Running: Yes|Slave_SQL_Running: Yes' | grep -c Yes
               
    重啟zabbix-agnet

3:web端新增監控項