墨墨导读:MySQL从8.0.17开始新增了克隆Clone技术,可以在线进行MySQL的本地克隆或远程克隆,从此搭建从库可以不再需要备份工具来实现了,本文分享Clone技术在线搭建主从复制全过程,希望对大家有帮助。
本文将通过Clone来实现一个远程从库的搭建:环境如下
Mater: 192.168.3.133 port:3307 doner 捐赠者
Slave: 192.168.3.134 port:3307 recipient 接受者
第一步:两台机器MySQL分别进行初始化安装
进入MySQL软件目录进行初始化安装并修改密码:(MySQL8.0.19 下载解压步骤省略)
[root@mgr2 bin]#cd /zcloud/db/abcMgr/abcMgr02/mysql/bin
[root@mgr2 bin]# ./mysqld --initialize --user=mysql
[root@mgr2 bin]# ./mysqld_safe --user=mysql &
[1] 19556
[root@mgr2 bin]# 2020-03-12T01:32:26.503048Z mysqld_safe Logging to ‘/rock/mysqldata/error.log’.
2020-03-12T01:32:26.536292Z mysqld_safe Starting mysqld daemon with databases from /rock/mysqldata
[root@mgr2 bin]#
[root@mgr2 bin]# mysql -uroot -p -P3307
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.19
Copyright © 2000, 2019, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.
root@localhost:(none) 09:33:06 >alter user user() identified by ‘root1234’;
Query OK, 0 rows affected (0.00 sec)
root@localhost:(none) 09:33:26 >flush privileges;
Query OK, 0 rows affected (0.00 sec)
root@localhost:(none) 09:33:31 >exit
Bye
第二步:doner节点192.168.3.133相关操作
–创建用户
root@localhost:(none) 10:07:05 >create user ‘donor_user’@‘192.168.3.134’ identified by ‘password’;
Query OK, 0 rows affected (0.00 sec)
root@localhost:(none) 10:07:07 >grant backup_admin on . to ‘donor_user’@‘192.168.3.134’;
Query OK, 0 rows affected (0.01 sec)
–安装clone插件