一、MySQL数据初始化
1.1、创建ha元数据结构:
create database myha;
use myha;
CREATE TABLE `ha_conf` ( `id` int(11) NOT NULL DEFAULT '0', `from_host` varchar(64) DEFAULT NULL, `from_ip` varchar(15) DEFAULT NULL, `from_port` smallint(6) DEFAULT NULL, `to_host` varchar(64) DEFAULT NULL, `to_ip` varchar(15) DEFAULT NULL, `to_port` smallint(6) DEFAULT NULL, `switch_flag` tinyint(4) DEFAULT NULL, `check_time` datetime DEFAULT NULL, `switch_time` datetime DEFAULT NULL, `vip` varchar(20) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `ha_heartbeat` ( `server_id` int(11) NOT NULL, `last_timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`server_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1.1、创建检测用户:
grant replication slave, replication client, super on *.* to 'monitor'@'127.0.0.1' identified by 'monitor123';
grant all on myha.* to 'monitor'@'127.0.0.1';
flush privileges;