Professional Documents
Culture Documents
How it works
Mysql have 2 tipes of replication: master-slave
and master-master and it works doing a copy of
database in other server.
The main different bettween both is that in
mysql master-slave replication only the change
that do the master server will be made in the
slave server
Mysql master-slave
If we want to do a mysql master-slave we must
make the follow steps:
First step: the main is have installed mysql in
both server, we can do it with next commant
apt-get install mysql-server mysql-client
Mysql master-slave
Secont step: In the server 1 we need to do a change in the configuration file of
mysql. This can be on /etc/mysql/my.cnf, or also can use
/etc/mysql/mysql.conf.d/mysqld.cnf.
Open file and do the next changes:
Put a server Id on 1 and erase the #.
Erase the # of log_bin and binlog_dp_db and add the database that you need to do a
replication.
And comment the line bind-address with # because we need that mysql accept
conection not only of localhost
server-id =1
log_bin = /var/log/mysql/mysql-bin.log
binlog_do_db = exampledb
# bind-address = 127.0.0.1
Mysql master-slave
Third step: Log in mysql console and make an user with replication
privileges.
CREATE USER 'replicator'@'%' IDENTIFIED BY 'password';
GRANT REPLICATION SLAVE ON *.* TO 'replicator'@'%';
FLUSH PRIVILEGES;