參考博文:
MySQL-(Master-Slave)配置? 本人按照博友北在北方的配置已成功 ?我使用的是 mysql5.6.27版本。
配置中 又進一步對mysql5.6的日志進行了了解 :mysql日志詳細解析
1.安裝
注意:只能安裝在64位的Linux操作系統上,CentOS官方建議rpm安裝方式
目前最新的版本為:
Atlas-2.2.1.el5.x86_64.rpm??????????????????????CentOS 5.*? 版本
Atlas-2.2.1.el6.x86_64.rpm??????????????????????CentOS 6.*? 版本
安裝命令:
[root@jhq0229 src]# rpm -i Atlas-2.2.1.el6.x86_64.rpm
安裝位置:
/usr/local/mysql-proxy
配置文件:
/usr/local/mysql-proxy/conf/test.cnf
2、編寫簡單Atlas的啟動腳本:
[root@jhq0229 ~]# vim /etc/init.d/atlas
#!/bin/sh
#
#atlas: Atlas Daemon
#
# chkconfig:- 90 25# description: Atlas Daemon
#
# Source function library.
start()
{
echo-n $"Starting atlas:"
/usr/local/mysql-proxy/bin/mysql-proxyd test start
echo
}
stop()
{
echo-n $"Shutting down atlas:"
/usr/local/mysql-proxy/bin/mysql-proxyd test stop
echo
}
ATLAS="/usr/local/mysql-proxy/bin/mysql-proxyd"[-f $ATLAS ] || exit 1# See how we were called.case "$1" instart)
start
;;
stop)
stop
;;
restart)
stop
sleep 1start
;;*)
echo $"Usage: $0 {start|stop|restart}"exit1esac
exit0
授權并加入開機啟動
[root@jhq0229~]# chmod +x /etc/init.d/atlas
[root@jhq0229~]# chkconfig atlas on
啟動atlas服務
[root@jhq0229~]# service atlas start
3、注意事項
3.1?主master上的 mysql 重新啟動
主master上的 mysql 每重新啟動一次 ?配置在master 上的 “在master上查看?binary log文件名和 position”就會發生改變:如下
mysql>show master status;+------------------+----------+--------------+------------------+-------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+------------------+----------+--------------+------------------+-------------------+
| mysql-bin.000005 | 276 | | | |
+------------------+----------+--------------+------------------+-------------------+
1 row in set (0.00sec)
重新啟動mysql服務后:
mysql>show master status;
ERROR2006(HY000): MySQL server has gone away
No connection. Trying to reconnect...
Connection id:3Current database: mysql+------------------+----------+--------------+------------------+-------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+------------------+----------+--------------+------------------+-------------------+
| mysql-bin.000006 | 120 | | | |
+------------------+----------+--------------+------------------+-------------------+
1 row in set (0.08 sec)
這就會導致 從slave上的配置失效,從而導致主-從無法同步:所以每次重新啟動 主(master)上的mysql服務都需要修改 從(slave)上的配置。目前只能這么做具體需要怎么改 再研究。
mysql> change master to master_host='192.168.29.128',master_user='repl',master_password='123456',master_port=3306,master_log_file='mysql-bin.000006',master_log_pos=120,master_connect_retry=10;
Query OK,0 rows affected, 2 warnings (0.30 sec)
3.2 從slave上的 mysql 重新啟動
從slave上的 mysql 重新啟動 ?會導致 主從配置失效無法完成寫同步功能,所以需要重啟 mysql服務后 ,重新啟動 slave ;