MySQL数据同步多主一从[参考].pdfVIP

  • 2
  • 0
  • 约3.01千字
  • 约 3页
  • 2021-10-19 发布于福建
  • 举报
MySQL 数据同步 多主一从 我们这里的多主一从的实现,是通过在从服务器上,增加一个端口和服务实例实现的。 这个增加的端口就是 3307 ,增加服务实例后,我们便多了一个配置文件 my.ini. 详细的配置 其实也很简单,参照下面。 Master1 主服务器 1 的 ip: 192.168.1.99 Master2 主服务器 2 的 ip: 192.168.1.111 Slave 从服务器的 ip: 192.168.1.113 一、 master1主服务器上设置: 1.权限设置 允许用户 user 从 ip 为 192.168.1.1 13 的主机连接到 mysql 服务器( master ),并使用 password 作为密码 下面涉及到,从服务器的 ip 、登陆用户名、登陆密码。 下面用户名是 repl ,密码是 repl mysqlGRANT ALL PRIVILEGES ON *.* TO repl@192.168.1.113 IDENTIFIED BY repl ; 2.文件配置 修改 my.ini 配置文件 [mysqld] # The TCP/IP Port the MySQL Server will listen on port=3306 加入下面两行,设置服务 id、 log 文件 server-id = 1 log-bin = mysql-bin.log 重启 mysql 服务。 3.得到主服务器上当前的二进制日志名和偏移量 mysql show master status; +++++ | File | Position | Binlog_Do_DB | Binlog_Ignore_DB | +++++ | mysql-bin.000005 | 106 | | | +++++ 1 row in set 二、 master2主服务器上设置: 1.权限设置 允许用户 user 从 ip 为 192.168.1.1 13 的主机连接到 mysql 服务器( master ),并使用 password 作为密码 下面涉及到,从服务器的 ip 、登陆用户名、登陆密码。 下面用户名是 repl ,密码是 repl mysqlGRANT ALL PRIVILEGES ON *.* TO repl@192.168.1.113 IDENTIFIED BY repl ; 2.文件配置 修改 my.ini 配置文件 [mysqld] # The TCP/IP Port the MySQL Server will listen on port=3306 加入下面两行,设置服务 id、 log 文件 server-id = 1 log-bin = mysql-bin.log 重启 mysql 服务。 3.得到主服务器上当前的二进制日志名和偏移量 mysql show master status; +++++ | File | Position | Binlog_Do_DB | Binlog_Ignore_DB | +++++ | mysql-bin.000005 | 106 | | | +++++ 1 row in set 三、 slave 从服务器上设置: 1.文件配置 MySQL 文件中 my.ini 文件 [mysqld] # The TCP/IP Port the MySQL Server will listen on port=3306 加入下面两行,设置服务 id、log 文件 server-id = 3 log-bin = mysql-bin-3306

文档评论(0)

1亿VIP精品文档

相关文档