On the primary DB node:
Enable binary logging in my.cnf:
[mysqld]
log_bin=mysql-bin
server-id=1
Restart MySQL
/etc/init.d/mysqld restart
Create a user for replication:
mysql> GRANT REPLICATION SLAVE ON *.* TO 'user'@'1.2.3.4' IDENTIFIED BY 'slavepass';
Find filename of binlog:
mysql> show master status;
Do the mysqldump of the database you want to replicate:
mysqldump -c –create-options -u root -ppassword –lock-tables databasename > dump.sql
Copy the sql file over to the slave:
scp dump.sql user@slave-server:~/
On the secondary DB node:
Edit the configuration file:
[mysqld]
server-id=2
Create the replicated database in mysql:
mysql> create database databasename;
Import the data from the sqldump into the database you just created on the slave:
mysql -u root -ppassword databasename < ~/dump.sql
Set master configuration on the slave:
CHANGE MASTER TO
MASTER_HOST='master_host_name',
MASTER_USER='replication_user_name',
MASTER_PASSWORD='replication_password',
MASTER_PORT=10306,
MASTER_LOG_FILE='log_file_name',
MASTER_LOG_POS=123456;
Start slave on slave
mysql> start-slave;
Check status of secondary db
mysql> show slave status\G