how to configure mysql master slave replication
Here is a basic step by step tutorial, that will cover the mysql master and slave replication and also will describe the mysql master and master replication.
Step 1:Here is a basic step by step tutorial, that will cover the mysql master and slave replication and also will describe the mysql master and master replication.
Install mysql on master 1 and slave 1. configure network services on both system, like
Master ip: 192.168.16.4
Slave ip : 192.168.16.5
Step 2:
On Master 1, make changes in my.cnf:[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
old_passwords=1
log-bin
binlog-do-db=<database name> # input the database which should be replicated
binlog-ignore-db=mysql # input the database that should be ignored for replication
binlog-ignore-db=test
server-id=1
[mysql.server]
user=mysql
basedir=/var/lib
[mysqld_safe]
err-log=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
Step 3:
On master 1, create a replication slave account in mysql.
mysql> grant replication slave on *.* to
'replication'@192.168.16.5 \
identified by 'slave';
and restart the
mysql master1.identified by 'slave';
Step 4:
Now edit my.cnf on Slave1 or Master2 :[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
old_passwords=1
server-id=2
master-host = 192.168.16.4
master-user = replication
master-password = slave
master-port = 3306
[mysql.server]
user=mysql
basedir=/var/lib
[mysqld_safe]
err-log=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
Step 5:
Restart mysql slave 1 and at
mysql> start slave;
mysql> show slave status\G;
mysql> show slave status\G;
Step 6:
On master 1:mysql> show master status;
No comments:
Post a Comment