java atlas mysql_使用Atlas实现MySQL读写分离+MySQL-(Master-Slave)配置
參考博文:
MySQL-(Master-Slave)配置? 本人按照博友北在北方的配置已成功 ?我使用的是 mysql5.6.27版本。
配置中 又進(jìn)一步對(duì)mysql5.6的日志進(jìn)行了了解 :mysql日志詳細(xì)解析
1.安裝
注意:只能安裝在64位的Linux操作系統(tǒng)上,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、編寫(xiě)簡(jiǎn)單Atlas的啟動(dòng)腳本:
[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
授權(quán)并加入開(kāi)機(jī)啟動(dòng)
[root@jhq0229~]# chmod +x /etc/init.d/atlas
[root@jhq0229~]# chkconfig atlas on
啟動(dòng)atlas服務(wù)
[root@jhq0229~]# service atlas start
3、注意事項(xiàng)
3.1?主master上的 mysql 重新啟動(dòng)
主master上的 mysql 每重新啟動(dòng)一次 ?配置在master 上的 “在master上查看?binary log文件名和 position”就會(huì)發(fā)生改變:如下
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)
重新啟動(dòng)mysql服務(wù)后:
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)
這就會(huì)導(dǎo)致 從slave上的配置失效,從而導(dǎo)致主-從無(wú)法同步:所以每次重新啟動(dòng) 主(master)上的mysql服務(wù)都需要修改 從(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 重新啟動(dòng)
從slave上的 mysql 重新啟動(dòng) ?會(huì)導(dǎo)致 主從配置失效無(wú)法完成寫(xiě)同步功能,所以需要重啟 mysql服務(wù)后 ,重新啟動(dòng) slave ;
總結(jié)
以上是生活随笔為你收集整理的java atlas mysql_使用Atlas实现MySQL读写分离+MySQL-(Master-Slave)配置的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 大家一般在哪里购买润康?
- 下一篇: 真润康包装上有哪些标识?