Linux下MySQL5.5的主从热备(自动同步)配置

 
 
环境说明:
 
Master:192.168.1.200
Slave:192.168.1.132

 

 
 
MySQL 的 Master 配置:
 
配置my.cnf:

 

 
# vi /etc/my.cnf

 

 
 
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
 
server-id=200
log-bin=mysql-bin
relay-log=relay-bin
relay-log-index=relay-bin-index

 

 
 
*配置好后,重启Master 的 MySQL服务!!!

 

 
service mysqld restart

 

 
 
//--------------------------------------------------
 
MySQL 的 Slave 配置:
 
配置my.cnf:

 

 
# vi /etc/my.cnf

 

 
 
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
 
 
server-id=132
log-bin=mysql-bin
replicate-do-db=test
log-slave-updates=1

 

 
 
 
*配置好后,重启Slave 的 MySQL服务!!!

 

 
service mysqld restart

 

 
//--------------------------------------------------
 
 
登录Slave,然后执行下面命令:

 

 
mysql> stop slave;
 
mysql> change master to master_host='192.168.1.200',master_user='root',master_password='123456';
 
mysql> start slave;
 
mysql> show slave status\G;

 

 
查看这两项是否为YES,yes为正常。
Slave_IO_Running: Yes
Slave_SQL_Running: Yes

你可能感兴趣的:(系统架构,MySQL)