mysql 5.5的主从配置及容错方案
主服配置文件
server-id = 1
log-bin = mysql-bin
binlog-ignore-db = mysql
binlog-ignore-db = information_schema
binlog-do-db = master_slave
//重启主服
service mysqld restart
//查看主服状态,并记下bin log pos,主服的所有操作均记录在Binlog中
show master status;
从服配置文件
server_id = 2
log_bin = mysql-bin
relay_log = mysql-relay-bin
log_slave_updates = 1
read_only = 1
replicate-ignore-db = mysql
replicate-ignore-db = test
replicate-ignore-db = information_schema
replicate-do-db = master_slave
//重启从服
service mysqld restart
//设定主服并启动同步
mysql> change master to master_host=’192.168.0.1′, master_user=’root’, master_password=’123456′, master_log_file=’mysql-bin.000001′, master_log_pos=106;
mysql> start slave;
mysql> show slave status;