首页 > 课堂 > 基础知识 > 正文

MariaDB 10.3 主同步拷贝

2024-09-12 20:30:16
字体:
来源:转载
供稿:网友
  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
 
  至此,主主同步复制配置完成。

(编辑:武林网)

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表