Shashikant shah

Thursday, 3 October 2013

MY-SQL Replication RHEL5.5


MY-SQL Replication Configuration


MASTER :-
IP :-192.168.0.10
Hostname :- shashi.example.com

SLAVE :-
IP :- 192.168.0.11
Hostname :- sk.unicom.com

****MASTER DB SERVER****

1.Install Packages :-

# yum install mysql-server mysql-client

# vim /etc/my.cnf
[mysqld]
server-id=1
binlog-do-db=ruby
log-bin=/var/lib/mysql/mysql-bin.log
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
#
#
old_passwords=1

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

# /etc/init.d/mysqld start

# mysqladmin – u root – password – 'shashi'

# mysql -u root -p shashi

mysql> GRANT REPLICATION SLAVE ON *.* TO 'root'@'%' IDENTIFIED BY 'shashi';
mysql> FLUSH PRIVILEGES;
mysql> CREATE DATABASE ruby;
mysql> USE ruby;
mysql> FLUSH TABLES WITH LOCK;
mysql> SHOW DATABASES;
mysql> \q

# /etc/init.d/mysqld restart

# chkconfig mysqld on

# mysql -u root -p shashi

mysql> unlock tables;

mysql>SHOW MASTER STATUS;











****SLAVE DB SERVER****

1.Install Packages :-

# yum install mysql-server mysql-client

# vim /etc/my.cnf
[mysqld]
report-host=192.168.0.11
server-id=2
master-host=192.168.0.10
master-user=root
master-password=shashi
master-port=3306
master-connect-retry=60
replicate-do-db=ruby
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
#
#
old_passwords=1

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

# /etc/init.d/mysqld start

# mysqladmin – u root – password – 'shashi'

mysql -u root -p shashi
mysql>CHANGE MATER TO MASTER_LOG_FILE='mysql-bin.000010', MASTER_LOG_POS=98;
mysql>START SLAVE;
mysql>SHOW SLAVE STATUS\G;












Check slave server IP :-

# Go to master DB server.
# show slave hosts;
Check slave is properly working or not :-
go to Master DB Server.

mysql>show databases;
mysql>use ruby;
mysql>show tables;
mysql>CREATE TABLE shashi (c int);
mysql>INSERT INTO shashi (c) VALUES (1);
mysql>select * from shashi; ----------------{check values}

Go to Slave DB Server

mysql>show databases;
mysql>use ruby;
mysql>show tables;
mysql>select * from shashi;

No comments:

Post a Comment