(2)如果一个数据库节点不会成为备选master,且no_master=1,则不需要创建复制用户
只在candidate master创建复制用户,必须与master的复制用户相同
mysql> grant replication slave on *.* to 'repl1'@'192.168.0.%' identified by '123456';
mysql> flush privileges;
1.6.5、注意******************所有数据库节点都要创建监控用户,监控用户必须要
只在master上创建监控用户:但是会被复制
(1)其他节点必须创建监控用户,否则报错:
Mon Jun 29 18:02:41 2015 - [error][/usr/local/share/perl5/MHA/ServerManager.pm, ln255] Got MySQL error when connecting 192.168.0.4(192.168.0.4:3306) :1045:Access denied for user 'monitor'@'192.168.0.4' (using password: YES), but this is not mysql crash. Check MySQL server settings.
mysql> grant all privileges on *.* to 'monitor'@'192.168.0.%' identified by '123456';
mysql> flush privileges;
1.7、配置MHA
(2)如果一个数据库节点不会成为备选master,且no_master=1,则不需要创建复制用户
# mkdir -p /etc/mha/app1 # vi /etc/mha/app1/app1.cnf [server default] manager_workdir=/etc/mha/app1 manager_log=/var/log/manager.log master_binlog_dir=/data/mysql/data/ ssh_user=root user=monitor password=123456 repl_user=repl1 repl_password=123456 secondary_check_script=masterha_secondary_check -s 192.168.0.3 -s 192.168.0.5 ping_interval=3 #master_ip_failover_script=/etc/mha/app1/master_ip_failover #shutdown_script=/script/masterha/power_manager #report_script=/script/masterha/send_report #master_ip_online_change_script=/etc/mha/master_ip_failover [server1] hostname=192.168.0.3 port=3306 #master_binlog_dir=/data/mysql/data candidate_master=1 [server2] hostname=192.168.0.4 port=3306 #master_binlog_dir=/data/mysql/data candidate_master=1 [server3] hostname=192.168.0.5 port=3306 no_master=1
1.7.2、所有数据库节点 relay log的自动清除
# mysql -e "set global relay_log_purge=0"
1.7.3、所有数据库节点在环境变量中输出mysqlbinlog
# ln -sv /usr/mysql/bin/mysqlbinlog /usr/bin/mysqlbinlog
1.7.4、检查ssh的配置
注意:
(1)# cp /yangsq/ftp/mha4mysql-manager-0.54/samples/scripts/master_ip_failover /etc/mha/app1/master_ip_failover或将master_ip_failover_script=/etc/mha/app1/master_ip_failover注释掉
否则报错:Mon Jun 29 17:05:26 2015 - [info] /etc/mha/app1/master_ip_failover --command=status --ssh_user=root --orig_master_host=192.168.0.3 --orig_master_ip=192.168.0.3 --orig_master_port=3306
Bareword "FIXME_xxx" not allowed while "strict subs" in use at /etc/mha/app1/master_ip_failover line 93.
(2)没有mysqlbinlog,报错:
Mon Jun 29 17:52:11 2015 - [info] Executing command: save_binary_logs --command=test --start_pos=4 --binlog_dir=/var/lib/mysql,/var/log/mysql --output_file=/var/tmp/save_binary_logs_test --manager_version=0.54 --start_file=mysql-bin.000008
Mon Jun 29 17:52:11 2015 - [info] Connecting to root@192.168.0.3(192.168.0.3)..
Failed to save binary log: Binlog not found from /var/lib/mysql,/var/log/mysql! If you got this error at MHA Manager, please set "master_binlog_dir=/path/to/binlog_directory_of_the_master" correctly in the MHA Manager's configuration file and try again.
# masterha_che