废话少说,直接上配置
master my.conf 配置
[mysqld]
# 启动binlog日志,并定义日志名
log_bin=/usr/local/mysql/log/mysql-bin108
# 服务器id号
server_id=108
# binlog日志保存时间
expire_logs_days=3
# 指定同步某个数据库
#binlog-do-db=
# 忽略mysql库
binlog_ignore_db=mysql
binlog_ignore_db=information_schema
binlog_ignore_db=performance_schema
binlog_ignore_db=sys
#log_bin_trust_function_creators=1
slave my.conf 配置
[mysqld]
server_id=229
relay_log=/usr/local/mysql/log/relay-bin
relay_log_recovery=1
master上创建同步账号
create user mysync;
update mysql.user set authentication_string=password("111111") where user="mysync";
GRANT REPLICATION SLAVE ON *.* TO 'mysync'@'1.1.1.229';
查看master的状态
slave开启复制
change master to master_host='1.1.1.108', master_user='mysync', master_password='111111',master_log_file='mysql-bin108.000002', master_log_pos=1061;
重启mysql后,查看slave状态