Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

replican.

txt
Server A: 192.168.153.1 Server B: 192.168.153.100

SERVER A:
----------
/etc/mysql/my.cnf (my.ini)
server-id = 1
log_bin = /var/log/mysql/mysql-bin.log (mysql-bin)
binlog_do_db = example
# bind-address = 127.0.0.1
-----------
•sudo service mysql restart
•mysql -u root -p
•mysql>create user 'replicator'@'%' identified by 'password';
•mysql>grant replication slave on *.* to 'replicator'@'%';
FLUSH PRIVILEGES;
•mysql>show master status;
+------------------+----------+--------------+------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+----------+--------------+------------------+
| mysql-bin.000001 | 107 | example | |
+------------------+----------+--------------+------------------+
1 row in set (0.00 sec)

==========================
Server B
server-id = 2
log_bin = /var/log/mysql/mysql-bin.log
binlog_do_db = example
# bind-address = 127.0.0.1
-----------------
sudo service mysql restart
•mysql -u root -p
•mysql>create user 'replicator'@'%' identified by 'password';
•mysql>create database example;
•mysql>grant replication slave on *.* to 'replicator'@'%';

•mysql>slave stop;
•mysql>CHANGE MASTER TO MASTER_HOST = '192.168.153.1', MASTER_USER = 'replicator',
MASTER_PASSWORD = 'password', MASTER_LOG_FILE = 'mysql-bin.000001', MASTER_LOG_POS
= 107;
•mysql>slave start;
•mysql>SHOW MASTER STATUS;
+------------------+----------+--------------+------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+----------+--------------+------------------+
| mysql-bin.000004 | 107 | example | |
+------------------+----------+--------------+------------------+
Page 1

Created with Print2PDF. To remove this line, buy a license at: http://www.software602.com/
replican.txt
1 row in set (0.00 sec)

===================================
Server A
•mysql>slave stop;
•mysql>CHANGE MASTER TO MASTER_HOST = '192.168.153.100', MASTER_USER =
'replicator', MASTER_PASSWORD = 'password', MASTER_LOG_FILE = 'mysql-bin.000004',
MASTER_LOG_POS = 107;
•mysql>slave start;

Page 2

Created with Print2PDF. To remove this line, buy a license at: http://www.software602.com/

You might also like