1、 配置主库:
-
安装插件
set session explicit_defaults_for_timestamp = 1;
INSTALL PLUGIN clone SONAME 'mysql_clone.so'; -
创建clone账号
create user 'xp'@'%' identified by 'a';
grant backup_admin on . to 'xp'@'%'; -
创建复制账号
create user 'repl'@'%' identified by 'repl4slave';
grant replication slave on . to 'repl'@'%';
2、 配置从库:(mysqld_safe 启动)
-
安装插件
INSTALL PLUGIN clone SONAME 'mysql_clone.so'; -
创建clone账号
create user 'xp'@'%' identified by 'a';
grant clone_admin on . to 'xp'@'%'; -
设置clone源
set global clone_valid_donor_list='172.16.215.222:3306'; -
设置写日志方式
set global log_error_verbosity=3; -
开始clone数据
clone instance from 'xp'@172.16.215.222:3306 identified by 'a';
。。。这里会重启数据库 -
配置同步的主库源
change master to master_host='172.16.215.222',
master_port=3306,
master_user='repl',
master_password='repl4slave',
master_auto_position=1,
get_master_public_key=1; -
开启同步
start slave;
网友评论