当前位置:Gxlcms >
mysql >
源代码编译MYSQL5.6环境下的MHA+KEEPALIVED的安装和维护
源代码编译MYSQL5.6环境下的MHA+KEEPALIVED的安装和维护
时间:2021-07-01 10:21:17
帮助过:43人阅读
前言摘要MHA是当master出现故障,挑选一个slave作为新的master并构建成新的主从架构的管理工具。从master出..
[root@MYSQL ~]# cd /usr/local/src/
[root@MYSQL src]# ls
installmysql5.sh mysql-5.6.10 mysql-5.6.10.tar.gz
[root@MYSQL src]# sh installmysql5.sh
please enter you mysql version (eg:/mysql-5.5.34):mysql-5.6.10
please enter you mysql datadir (eg:/data/mysql/data):/date/mysql/data
[root@MANAGER ~]# vi /etc/hosts
[root@MYSQL etc]# vi /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.186.141 MYSQL.COM
192.168.186.142 SLAVE1.COM
192.168.186.146 SLAVE2.COM
192.168.186.144 MANAGER.COM
[root@MYSQL etc]# for i in 142 146 144;do scp /etc/hosts 192.168.186.$i:/etc/;done
root@192.168.186.142's password:
Permission denied, please try again.
root@192.168.186.142's password:
Permission denied, please try again.
root@192.168.186.142's password:
hosts 100% 266 0.3KB/s 00:00
root@192.168.186.146's password:
hosts 100% 266 0.3KB/s 00:00
root@192.168.186.144's password:
# 所有mysql数据库服务器,安装半同步插件(semisync_master.so,semisync_slave.so)
mysql> install plugin rpl_semi_sync_master soname 'semisync_master.so';
mysql> install plugin rpl_semi_sync_slave soname 'semisync_slave.so';
[root@MYSQL etc]vi /etc/my.cnf
[mysqld]
rpl_semi_sync_master_enabled=1
rpl_semi_sync_master_timeout=1000
rpl_semi_sync_slave_enabled=1
relay_log_purge=0
skip-name-resolve
#socket=/usr/mysql.sock
#auto_increment_offset = 2
#auto_increment_increment = 2
server-id = 1
log-bin=mysql-bin
read_only=1
slave-skip-errors=1396
rpl_semi_sync_master_net_avg_wait_time:事务进入等待队列后,到网络平均等待时间
[root@MYSQL src]# service mysqld restart 每台机器重启
4.每一台机器配置互相无交互
[root@MYSQL src]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.186.141 MYSQL.COM
192.168.186.142 SLAVE1.COM
192.168.186.146 SLAVE2.COM
192.168.186.144 MANAGER.COM
[root@MYSQL src]# ssh-keygen
[root@MYSQL src]# ssh-copy-id 192.168.186.142
[root@MYSQL src]# ssh-copy-id 192.168.186.144
[root@MYSQL src]# ssh-copy-id 192.168.186.146
其他台配置方法与以上一致 保证每台互相无交互
配置完成后每一个都登录一次
[root@MYSQL ~]# ssh MANAGER.COM
[root@MYSQL ~]# ssh SLAVE1.COM
[root@MYSQL ~]# ssh SALVE2.COM
作用首次连接需要输入一次YES 在know-hosts问价记录,达成无交互
5.配置主从
执行主从脚本
建议自己做 用这个脚本要是后期带来各种不便 不要怪我
详见附件
[root@MYSQL src]# sh mslave.sh
please enter you mysql SLAVEIP (eg:192.168.152.138):192.168.186.142
please enter you master mysql password (eg:yunwei123):123
please enter you slave mysql password (eg:yunwei123):123
please enter you master mysql binlog (eg:mysql-bin.000001):mysql-bin.000001
[root@MYSQL src]# sh mslave.sh
please enter you mysql SLAVEIP (eg:192.168.152.138):192.168.186.146
please enter you master mysql password (eg:yunwei123):123 这个是你的主MYSQL 登录密码
please enter you slave mysql password (eg:yunwei123):123 这个是你的从的MYSQL登录密码
please enter you master mysql binlog (eg:mysql-bin.000001):mysql-bin.000001
至此MYSQL 安装主从半同步配置完成
三.安装配置MHA
1.安装