视频1 视频21 视频41 视频61 视频文章1 视频文章21 视频文章41 视频文章61 推荐1 推荐3 推荐5 推荐7 推荐9 推荐11 推荐13 推荐15 推荐17 推荐19 推荐21 推荐23 推荐25 推荐27 推荐29 推荐31 推荐33 推荐35 推荐37 推荐39 推荐41 推荐43 推荐45 推荐47 推荐49 关键词1 关键词101 关键词201 关键词301 关键词401 关键词501 关键词601 关键词701 关键词801 关键词901 关键词1001 关键词1101 关键词1201 关键词1301 关键词1401 关键词1501 关键词1601 关键词1701 关键词1801 关键词1901 视频扩展1 视频扩展6 视频扩展11 视频扩展16 文章1 文章201 文章401 文章601 文章801 文章1001 资讯1 资讯501 资讯1001 资讯1501 标签1 标签501 标签1001 关键词1 关键词501 关键词1001 关键词1501 专题2001
Mysql-MHA高可用实验测试
2020-11-09 12:55:29 责编:小采
文档


说明:centos6.5mysql5.5.37mha4mysql-manager-0.55mha4mysql-node-0.54manager192.168.1.1db1192.168.1.2db2192.168.1.3db3192.168.1.4配置mysql主从db1:server

说明:

centos 6.5 mysql 5.5.37 mha4mysql-manager-0.55 mha4mysql-node-0.54

manager 192.168.1.1
db1 192.168.1.2
db2 192.168.1.3
db3 192.168.1.4


配置mysql主从
db1:

server-id = 1
read_only = 1
relay_log_purge=0
binlog_format=mixed

db2,db3忽略

db1主

grant replication slave on *.* to mharep@'192.168.1.%' identified by 'passwd'; flush privileges; stop slave; #设置复制权限帐号 GRANT ALL PRIVILEGES ON *.* TO 'mha_manager'@'192.168.1.%' IDENTIFIED BY '123456'; reset master; show master status\G

db2备

grant replication slave on *.* to mharep@'192.168.1.%' identified by 'passwd'; GRANT ALL PRIVILEGES ON *.* TO 'mha_manager'@'192.168.1.%' IDENTIFIED BY '123456'; flush privileges; reset master; slave stop; change master to MASTER_HOST='192.168.1.2', MASTER_PORT=3306,MASTER_USER='mharep', MASTER_PASSWORD='passwd',master_log_file='mysql-bin.000001', master_log_pos=107; slave start; show slave status\G;

db3从

reset master; slave stop; GRANT ALL PRIVILEGES ON *.* TO 'mha_manager'@'192.168.1.%' IDENTIFIED BY '123456'; flush privileges; change master to MASTER_HOST='192.168.1.2', MASTER_PORT=3306,MASTER_USER='mharep', MASTER_PASSWORD='passwd',master_log_file='mysql-bin.000001', master_log_pos=107; slave start; show slave status\G;


配置双机互信
manager

ssh-keygen -t rsa for i in db1 db2 db3;do ssh-copy-id -i ~/.ssh/id_rsa.pub root@$i;done

db1主

ssh-keygen -t rsa for i in manager db2 db3;do ssh-copy-id -i ~/.ssh/id_rsa.pub root@$i;done

db2备 和 db3从 配置略


安装mysql-MHA
https://downloads.mariadb.com/files/MHA

wget https://downloads.mariadb.com/files/MHA/mha4mysql-manager-0.55-0.el6.noarch.rpm wget https://downloads.mariadb.com/files/MHA/mha4mysql-node-0.54-0.el6.noarch.rpm

db1主 db2备 db3从
yum install perl-DBD-MySQL
yum localinstall mha4mysql-node-0.54-0.el6.noarch.rpm

manager

yum install perl cpan yum install perl-DBD-MySQL perl-Config-Tiny perl-Log-Dispatch perl-Parallel-ForkManager

#这两个yum没有安装上 perl-Log-Dispatch perl-Parallel-ForkManager

wget wget ftp://rpmfind.net/linux/dag/redhat/el6/en/x86_/dag/RPMS/perl-Parallel-ForkManager-0.7.5-2.2.el6.rf.noarch.rpm wget ftp://rpmfind.net/linux/dag/redhat/el6/en/x86_/dag/RPMS/perl-Mail-Sender-0.8.16-1.el6.rf.noarch.rpm wget ftp://rpmfind.net/linux/dag/redhat/el6/en/x86_/dag/RPMS/perl-Mail-Sendmail-0.79-1.2.el6.rf.noarch.rpm

rpm -ivh perl-Mail-Sender-0.8.16-1.el6.rf.noarch.rpm
rpm -ivh perl-Mail-Sendmail-0.79-1.2.el6.rf.noarch.rpm
yum localinstall perl-Log-Dispatch-2.27-1.el6.noarch.rpm
yum localinstall perl-Parallel-ForkManager-0.7.5-2.2.el6.rf.noarch.rpm
yum localinstall mha4mysql-node-0.54-0.el6.noarch.rpm
yum localinstall mha4mysql-manager-0.55-0.el6.noarch.rpm


配置mysql-MHA
[root@manager ~]# masterha_
masterha_check_repl masterha_conf_host masterha_master_switch
masterha_check_ssh masterha_manager masterha_secondary_check
masterha_check_status masterha_master_monitor masterha_stop

tar -xzf mha4mysql-manager-0.55.tar.gz
ls mha4mysql-manager-0.55/samples/conf
masterha_default.cnf app1.cnf

mkdir -p /usr/local/mha/scripts
cp mha4mysql-manager-0.55/samples/scripts/* /usr/local/mha/scripts

[root@manager ~]# vim /usr/local/mha/mha.conf [server default] user=mha_manager password=123456 manager_workdir=/usr/local/mha manager_log=/usr/local/mha/manager.log remote_workdir=/usr/local/mha ssh_user=root repl_user=mharep repl_password=passwd ping_interval=1 secondary_check_script= masterha_secondary_check -s 192.168.1.2 -s 192.168.1.3 -s 192.168.1.4 master_ip_failover_script=/usr/local/mha/scripts/master_ip_failover #shutdown_script= /usr/local/mha/scripts/power_manager report_script= /usr/local/mha/scripts/send_report master_ip_online_change_script= /usr/local/mha/scripts/master_ip_online_change [server1] hostname=192.168.1.2 ssh_port=22 master_binlog_dir=/var/mysql/log candidate_master=1 [server2] hostname=192.168.1.3 ssh_port=22 master_binlog_dir=/var/mysql/log candidate_master=1 [server3] hostname=192.168.1.4 ssh_port=22 master_binlog_dir=/var/mysql/log no_master=1


#验证ssh通讯
masterha_check_ssh --conf=/usr/local/mha/mha.conf

下载本文
显示全文
专题