MySQL数据库,简述MHA数据库集群的配置方法。
事先准备MHA软件包,以及其他需要的服务器。
master主节点服务器 4.51
备用1主节点 4.52
备用2主节点 4.53
slave服务器1 4.54
slave服务器2 4.55
MHA管理服务器 4.56
VIP地址 4.100 //由MHA自动配置,不需要手动配置。
安装MHA预先环境
yum -y install perl-*
编译安装:
[root@sql56 mha4mysql-manager-0.56]# perl Makefile.PL [root@sql56 mha4mysql-manager-0.56]# make [root@sql56 mha4mysql-manager-0.56]# make install
修改主节点服务器配置文件:
vim /etc/my.cnf [mysqld] server_id=51 log-bin=master51 binlog_format='mixed' plugin-load = "rpl_semi_sync_master=semisync_master.so;rpl_semi_sync_slave=semisync_slave.so" rpl-semi-sync-master-enabled = 1 rpl-semi-sync-slave-enabled = 1 [root@sql51 ~]# systemctl restart mysqld
两台主节点服务器均需要创建、授权主从同步账户。
grant replication slave on *.* to repluser@"%" identified by "123456.aA";
以51主库为基准,备选两台服务器均设置为主从库,两台slave服务器设置为从库。(配置文件需要正确的修改为主从库、或从库的设置)
mysql> show master status; +-----------------+----------+--------------+------------------+-------------------+ | File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set | +-----------------+----------+--------------+------------------+-------------------+ | master51.000001 | 441 | | | | +-----------------+----------+--------------+------------------+-------------------+ 1 row in set (0.00 sec) mysql> change master to -> master_host='192.168.4.51', -> master_host='mha', -> master_password='123465.Aa', -> master_log_file='master51.000001', -> master_log_pos=441; change master to master_host='192.168.4.51', master_host='repluser', master_password='123456.aA', master_log_file='master51.000002', master_log_pos=441;
配置56管理主机:
[root@mgm56 ~]# cd mysql/mha-soft-student/mha4mysql-manager-0.56/ [root@mgm56 mha4mysql-manager-0.56]# cp bin/* /usr/local/bin/ //提示覆盖,说明安装的时候有,没有可以拷贝过来 [root@mgm56 mha4mysql-manager-0.56]# mkdir /etc/mha_manager //创建工作目录 [root@mgm56 mha4mysql-manager-0.56]# cp samples/conf/app1.cnf /etc/mha_manager //建立样板文件 [root@mgm56 mha4mysql-manager-0.56]# vim /etc/mha_manager/app1.cnf //编辑主配置文件app1.cnf [server default] manager_workdir=/etc/mha_manager manager_log=/etc/mha_manager/manager.log master_ip_failover_script=/usr/local/bin/master_ip_failover ssh_user=root ssh_port=22 repl_user=repluser repl_password=123456 user=root password=123456 [server1] hostname=192.168.4.51 port=3306 [server2] hostname=192.168.4.52 port=3306 candidate_master=1 [server3] hostname=192.168.4.53 port=3306 candidate_master=1 [server4] hostname=192.168.4.54 no_master=1 [server5] hostname=192.168.4.55 no_master=1 [root@mgm56 mha4mysql-manager-0.56]# cp samples/scripts/master_ip_failover /usr/local/bin/ //创建故障切换的脚本
发表评论