Thursday 1 December 2011

Step by step process for how to set the mk-heartbeat monitoring

Process For setting mk-heartbeat mechanism.

Take a case you have two servers(Master and Slave1 and Slave2)

replication is as Master->Slave
We want to set monitoring for slave.

Steps:
1.Download mk-heartbeat script

from terminal you can download as:
wget http://www.maatkit.org/get/mk-heartbeat


2.create a database Heartbeat and a table heartbeat on the master.It will automatically be replicated on the slave.

create database Heartbeat;

use Heartbeat;

CREATE TABLE heartbeat (
id int NOT NULL PRIMARY KEY,
ts datetime NOT NULL
)Engine = Memory;


Insert one row in the table heartbeat as

INSERT INTO heartbeat (id, ts) VALUES (1, NOW());

If the user has permissions on the Heartbeat we dont need to insert the row manually in the table,The mk-heartbeat will itself insert the row in it.



3.Now create a user heartbeat with some password as
Grant all on Heartbeat.* to heartbeat@'%' identified by 'maatkit';

the user heartbeat should have permissions on the Database Heartbeat, We have created the user heartbeat for our sake otherwise we have to start mk-heartbeat by any other or current user.mk-heartbeat takes the default values from the my.cnf it did not pass them at the script execution time.

4.Now we have to make mk-heartbeat to update the master and monitor the slave.

For master:
mk-heartbeat -D Heartbeat --update -h 10.167.29.58 -u heartbeat -p maatkit --daemonize

where 10.167.29.58 is IP for master

For Slave:
mk-heartbeat -D Heartbeat --monitor -h 10.166.162.231 -u heartbeat -p maatkit --daemonize --log /home/slave.log

where 10.166.162.231 is IP for slave.
It will generate the log in slave.log file generated by above command
Issue tail -f slave.log

It should be working fine.

No comments:

Post a Comment