配置鲲鹏节点作为MySQL的从服务器,加入到现有的主从复制架构中。
1
|
mysql -uroot -p -S /data/mysql/run/mysql.sock |
或者
1
|
/usr/bin/mysql -uroot -p -S /data/mysql/run/mysql.sock |
1 2 3 |
create user 'replicate'@'%' identified with caching_sha2_password by '123456'; grant replication slave on *.* to 'replicate'@'%'; flush privileges; |
1
|
select User from mysql.user; |
1
|
mysql -uroot -p -S /data/mysql/run/mysql.sock |
1
|
show master status; |
记录主库的状态信息,特别是“File”和“Position”,这些在配置从库时需要使用。
1
|
mysql -uroot -p123456 -S /data/mysql/run/mysql.sock |
1 2 3 |
create user 'replicate'@'%' identified with caching_sha2_password by '123456'; grant replication slave on *.* to 'replicate'@'%'; flush privileges; |
1
|
mysql -uroot -p123456 -S /data/mysql/run/mysql.sock |
1 2 3 4 5 |
set global enforce_gtid_consistency='on'; set global gtid_mode='off_permissive'; set global gtid_mode='on_permissive'; set global gtid_mode='on'; show variables like '%gtid_mode%'; |
1
|
mysql -uroot -p123456 -S /data/mysql/run/mysql.sock |
1
|
start slave; |
若出现如下报错,请尝试重置从库配置后再启动,详细解决方案请参见将鲲鹏节点加入主从复制部署过程中提示ERROR 1872。
1 2 |
mysql> start slave; ERROR 1872 (HY000): Replica failed to initialize applier metadata structure from the repository |
1
|
show slave hosts; |
Server_id、Host和Master_id与表3中一致,表示部署成功。