1、环境
服务器名称 | IP地址 | 备注 |
db-161-131 | 10.32.161.131 | 主 |
db-161-132 | 10.32.161.132 | 从 |
2、MySQL安装
参考:https://www.cnblogs.com/a120608yby/p/17164694.html
3、修改配置并重启服务
# 主节点主要配置 # vim /etc/my.cnf ... server-id = 131 log_bin = mysql-bin plugin-load=mysql_clone.so ... # 从节点主要配置 # vim /etc/my.cnf ... server-id = 132 log_bin = mysql-bin plugin-load=mysql_clone.so relay-log=db-161-132-relay-bin relay-log-index=db-161-132-relay-bin read_only=1 report-host=db-161-132 ... # 重启MySQL服务 systemctl restart mysqld # 在主节点上创建复制账号 > create user 'repl_user'@'%' identified by 'password'; > grant replication slave on *.* to repl_user@'%'; # 在主节点上创建克隆账号 > create user 'clone_user'@'%' identified by 'password'; > grant backup_admin on *.* to 'clone_user'@'%'; # 在从节点上创建克隆账号 > create user 'clone_user'@'%' identified by 'password'; > grant clone_admin on *.* to 'clone_user'@'%';
4、克隆主节点上的所有数据并启动复制
# 在从节点上克隆主节点数据 > set global clone_valid_donor_list = '10.32.161.131:3306'; > clone instance from [email protected]:3306 identified by 'password'; # 在从节点上查看克隆状态且是否完成 > select ID,STATE,SOURCE,DESTINATION,BINLOG_FILE,BINLOG_POSITION from performance_schema.clone_status; # 在从节点上复制配置 > change master to master_host='10.32.161.131', master_user='repl_user', master_password='password', master_log_file='mysql-bin.000001', master_log_pos=1087; # 在从节点上启动配置 > start slave; # 查看复制状态(Slave_IO_Running: Yes和Slave_SQL_Running: Yes) > show slave status\G
标签:bin,8.0,log,clone,主从,user,MySQL,password,节点 From: https://www.cnblogs.com/a120608yby/p/17437485.html