Create 2 or more VM with clean Centos 64bit and 1 Public IP and 1 Private IP
For each VM we now need to install MYSQL server:
SSH: yum -y install mysql mysql-server |
set a mysql password:
SSH: mysqladmin -u root password MYNEWPASSWORD |
Now we need to work only on master VM. Create a database (in this tutorial with name "DBreplicated") and populate it.
Login to mysql console:
SSH: mysql -u root -p |
anf give privileges:
SSH: GRANT ALL ON DBreplicated.* TO 'root'@'%' IDENTIFIED BY 'MYNEWPASSWORD'; |
Now change the file /etc/my.cnf:
my.cnf:server-id = 1 log-bin = mysql-bin log-bin-index = mysql-bin.index expire-logs-days = 10 max-binlog-size = 100M binlog-do-db = DBreplicated |
restart MySQL
SSH: service mysqld restart |
Create new User:
SSH: mysql -u root -p |
And take the exact master VM DB position
SSH: mysql -u root -p |
Please save Position:
SSH: *************************** 1. row *************************** File: mysql-bin.000001 |
Now login on slave VM and repeat next steps for each slave vm. Install MySQL, create database (as above) and populate DB with same master vm db data
Change /etc/my.cnf file (if you have more than one slave vm replace server-id with unique number)
SSH: server-id=2 |
restart mysql
SSH: service mysqld restart |
Setup the replication:
SSH:mysql -u root -p change master to
master_host='VM_IP_PRIMARIO',
master_user='DBreplicated',
master_password='ANEWPASSOWRD',
master_log_file='mysql-bin.000001',
master_log_pos=99;
start slave;
|
Check that replication work well
SSH: show slave status |