应用Atlas完成MySQL读写分离+MySQL-(Master-Slave)配置

参照博文:

MySQL-(Master-Slave)配置 
本人根据博友北在北方的安插已成功
 我动用的是 mysql5.6.27本子。

行使Atlas达成MySQL读写分离  

数据切分——Atlas读写分离Mysql集群的搭建

[转]
MySQL主从复制(Master-Slave)与读写分离(MySQL-Proxy)实践
 博文中的数据迁移(主从复制)挺好

 配置中 又越来越对mysql5.6的日志举行了询问
mysql日志详细分析

 

1.安装

         注意:只好设置在64位的Linux操作系统上,CentOS官方提出rpm安装格局

         获取地址:https://github.com/Qihoo360/Atlas/releases

         近日风行的版本为:

          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" in
        start)
                start
                ;;
        stop)
                stop
                ;;
        restart)
                stop
                sleep 1
                start
                ;;
        *)
                echo $"Usage: $0 {start|stop|restart}"
                exit 1
esac
exit 0

授权并加入开机启动
[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.00 sec)
重新启动mysql服务后:
mysql> show master status;
ERROR 2006 (HY000): MySQL server has gone away
No connection. Trying to reconnect...
Connection id:    3
Current 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 ;

网站地图xml地图