版权声明:本文为博主原创,未经本人允许不得转载。本人有权追究法律责任 https://blog.csdn.net/wuxingpu5/article/details/82290291
control:172.21.120.101 102
yum install -y mariadb python2-PyMySQL
master:
yum install mariadb mariadb-server python2-PyMySQL -y
node : 172.21.120.103 104
yum install mariadb mariadb-server -y
添加官方的配置文件 配置binlog 配置serverid
https://docs.openstack.org/install-guide/environment-sql-database-rdo.html
从库添加配置文件 配置serverid
初始化mysql
创建同步账号
到处配置
拷贝到从库
从库执行操作:导入
主库创建同步账号:
GRANT REPLICATION SLAVE,REPLICATION CLIENT ON *.* TO 'syncuser'@'192.168.7.%' IDENTIFIED BY '123456';
查看备份文件master log file 和master log pos 在备份文件中 越22行左右
MASTER_LOG_FILE='master-log.000006',MASTER_LOG_POS=120;
备库执行:
CHANGE MASTER TO MASTER_HOST='192.168.7.1',MASTER_USER='syncuser',MASTER_PASSWORD='123456',MASTER_LOG_FILE='bin-log.000005', MASTER_LOG_POS=362;
start slave;
查看同步状态
MariaDB [(none)]> show slave status\G;
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.7.1
Master_User: syncuser
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: bin-log.000005
Read_Master_Log_Pos: 362
Relay_Log_File: mariadb-relay-bin.000002
Relay_Log_Pos: 535
Relay_Master_Log_File: bin-log.000005
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB:
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno: 0
Last_Error:
Skip_Counter: 0
Exec_Master_Log_Pos: 362
Relay_Log_Space: 835
Until_Condition: None
Until_Log_File:
Until_Log_Pos: 0
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master: 0
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 0
Last_IO_Error:
Last_SQL_Errno: 0
Last_SQL_Error:
Replicate_Ignore_Server_Ids:
Master_Server_Id: 10
Master_SSL_Crl:
Master_SSL_Crlpath:
Using_Gtid: No
Gtid_IO_Pos:
Replicate_Do_Domain_Ids:
Replicate_Ignore_Domain_Ids:
Parallel_Mode: conservative
2个均为yes
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
同步成功
参见: