Mysql Replication Cluster 

Master-Slave

node1 — master

Edit mysqld config

[mysqld]
server-id = 1
log-bin = /var/lib/mysql/mysql-bin 
replicate-do-db = somedb

Grand replicate permissoin to user replication on database somedb:

mysql@master>  GRANT replication slave ON "somedb".* TO "replication"@"192.168.1.102" IDENTIFIED BY "password";

Then restart daemon

service mysqld restart

Set ReadOnly mode:

mysql@master> SET GLOBAL read_only = ON;

Make dump:

 /usr/bin/mysqldump --single-transaction --flush-logs --routines --events somedb > master.dump

View binlog inforamation:

mysql@master> SHOW MASTER STATUS\G
File: mysql-bin.000003
Position: 98
Binlog_Do_DB:
Binlog_Ignore_DB:

Remove ReadOnly mode:

mysql@master> SET GLOBAL read_only = OFF;

node2 — slave

Edit mysqld config:

server-id = 2
relay-log = /var/lib/mysql/mysql-relay-bin
relay-log-index = /var/lib/mysql/mysql-relay-bin.index
replicate-do-db = somedb

Then restart daemon

service mysqld restart

Restore from master dump:

mysql somedb < master.dump

Configure slave replication:

mysql@replica> CHANGE MASTER TO MASTER_HOST = "192.168.1.101 ", MASTER_USER = "replication ", MASTER_PASSWORD = "password", MASTER_LOG_FILE = "mysql-bin.000003", MASTER_LOG_POS = 98;

Start replication:

mysql@replica> start slave;

View status

mysql@replica> SHOW SLAVE STATUS\G
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.1.101
Master_User: replication
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000003
Read_Master_Log_Pos: 98
Relay_Log_File: mysql-relay-bin.001152
Relay_Log_Pos: 235
Relay_Master_Log_File: mysql-bin.000003
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB: testdb,testdb
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno: 0
Last_Error:
Skip_Counter: 0
Exec_Master_Log_Pos: 98
Relay_Log_Space: 235
Until_Condition: None
Until_Log_File:
Until_Log_Pos: 0
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master: 5