Knowledgebase

MySQL replication

With CloudFlow you can balance load trought two or more Database VM. First you need to keep DB data in sync.

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
chkconfig --levels 235 mysqld on
service mysqld start










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
create user userslave;
create user 'userslave'@'*';
grant replication slave on *.* to userslave identified by 'ANEWPASSOWRD';
flush privileges;











And take the exact master VM DB position


SSH:

mysql -u root -p
show master status









Please save Position:

SSH:

*************************** 1. row *************************** File: mysql-bin.000001
Position: 99
Binlog_Do_DB: powerdns
Binlog_Ignore_DB: 1
row in set (0.00 sec)

















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
master-connect-retry=60
relay-log=slave-relay-bin
relay-log-index=slave-relay-bin.index
replicate-do-db=DBreplicated












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 










  • 1 Users Found This Useful

Was this answer helpful?

Related Articles

Configure LoadBalancer

With CloudFlow you can set one or more balancers for sharing requests between two or more...