Posts Tagged “replication”

This is a quick setup of MySQL replication, but only works if both server are new builds with no dataset

On the master:

1. Put the following in my.cnf in the [mysqld] section:

server-id=1
log-bin=master-bin

2. Run the following one-liner:

# /etc/init.d/mysqld restart; mysql -e “GRANT REPLICATION SLAVE ON *.* TO ‘$user’@'$slave_ip_addr’ IDENTIFIED BY ‘$password’;”; mysql -e “RESET MASTER;”

On the slave:

1. Put the follwing in my.cnf in the [mysqld] section:

server-id=2

2. Run the follwoing one-liner:

/etc/init.d mysqld restart; mysql -e “CHANGE MASTER TO┬áMASTER_HOST=’$master_ip_addr’, MASTER_USER=’$user’, MASTER_PASSWORD=’$password’, MASTER_LOG_FILE=’master-bin.000001′, MASTER_LOG_POS=98;”; mysql -e “START SLAVE;”

Comments No Comments »