您好,登錄后才能下訂單哦!
MariaDB主主同步,也就是兩個MariaDB之間互為主從,每個MariaDB均為主、從雙角色。
1. MariaDB01配置
vi /etc/my.cnf.d/server.cnf
[mysqld]
server-id = 1
log-bin = master-log
relay-log = slave-log
auto_increment_offset = 1
auto_increment_increment = 2
2. MariaDB02配置
vi /etc/my.cnf.d/server.cnf
[mysqld]
server-id = 2
log-bin = master-log
relay-log = slave-log
auto_increment_offset = 2
auto_increment_increment = 2
3. 重啟MariaDB服務
root用戶: sudo -u mysql service mysql restart
mysql用戶:service mysql restart
4. MariaDB01主,MariaDB02從配置
MariaDB01執行:
CREATE USER 'repl'@'192.168.10.%' IDENTIFIED BY '123456';
GRANT REPLICATION SLAVE ON *.* TO 'repl'@'192.168.10.%';
show master status;
MariaDB02執行:
CHANGE MASTER TO MASTER_HOST='192.168.10.178', MASTER_USER='repl', MASTER_PASSWORD='123456', MASTER_LOG_FILE='master-log.000002', MASTER_LOG_POS=329;
start slave;
show slave status\G
5. MariaDB02主,MariaDB01從配置
MariaDB02執行:
CREATE USER 'repl'@'192.168.10.%' IDENTIFIED BY '123456';
GRANT REPLICATION SLAVE ON *.* TO 'repl'@'192.168.10.%';
show master status;
MariaDB01執行:
CHANGE MASTER TO MASTER_HOST='192.168.10.179', MASTER_USER='repl', MASTER_PASSWORD='123456', MASTER_LOG_FILE='master-log.000002', MASTER_LOG_POS=329;
start slave;
show slave status\G
至此,主主同步復制配置完成。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。