Mysql+keepalived
测试环境
192.168.2.201 master slave
192.168.2.202 master slave
配置流程:安装MySQL->优化系统->优化配置my.cnf->初始化mysqld->添加同步用户->开始同步->查看同步状态。
1.先关闭master
2.配置 /etc/my.cnf
[mysql] default-character-set=utf8 [mysqld] default-storage-engine=INNODB character_set_server=utf8 basedir=/opt/mysql datadir=/data/mysql/data socket=/data/mysql/mysql.sock skip_ssl server-id = 1 #backup这台设置2 binlog-ignore-db = mysql,information_schema,sys #忽略写入binlog日志的库 binlog-ignore-db = mysql replicate-do-db = test replicate-do-db = test2 relay_log = mysql-relay-bin gtid-mode=on enforce_gtid_consistency = 1 log_slave_updates =1 auto_increment_offset=1 #自增ID起始值 auto_increment_increment=2 #每次自增数字 log-bin=mysql-bin #开启二进制功能,主服务器必须打开 max_binlog_size=1024M #binlog单文件最大值 slave_skip_errors=1396 slave_skip_errors=all symbolic-links=0 [mysqld_safe] log-error=/data/mysql/log/mysqld.log pid-file=/var/run/mysqld/mysqld.pid
3. 启动master
4. 创建复制账户
create user repl@'%' identified by '123456'; grant replication slave on *.* to repl@'%' ; flush privileges;
5. 启动slave
6.启动复制
change master to master_host='192.168.2.201', master_user='repl',master_password='123456',master_auto_position=1;
start slave;
7. 查看状态
show slave status;
如果对您有帮助,轻轻点个赞!