频道澳门葡京手机版网址
登录注册
澳门葡京手机版网址 > 网络 > 其他 > 正文

mysql多源复制实战

2018-11-30 10:51:38           
收藏   我要投稿
在master1上

vim /etc/my.cnf

[mysqld]

socket=/tmp/mysql.sock

basedir=/usr/local/mysql

datadir=/mydata/data

log-bin=/mydata/binlog/log-bin

server-id=1

bind-address = 0.0.0.0

skip-name-resolve

mysql

GRANT REPLICATION SLAVE,REPLICATION CLIENT ON *.* TO 'repluser'@'192.168.130.%' IDENTIFIED BY 'replpass';

FLUSH PRIVILEGES;

mysql> show master status;

+----------------+----------+--------------+------------------+-------------------+

| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |

+----------------+----------+--------------+------------------+-------------------+

| log-bin.000017 | 154 | | | |

+----------------+----------+--------------+------------------+-------------------+

1 row in set (0.00 sec)

在master2上

vim /etc/my.cnf

[mysqld]

socket=/tmp/mysql.sock

basedir=/usr/local/mysql

datadir=/mydata/data

log-bin=/mydata/binlog/log-bin

server-id=2

bind-address = 0.0.0.0

skip-name-resolve

mysql

GRANT REPLICATION SLAVE,REPLICATION CLIENT ON *.* TO 'repluser'@'192.168.130.%' IDENTIFIED BY 'replpass';

FLUSH PRIVILEGES;

mysql> show master status;

+----------------+----------+--------------+------------------+-------------------+

| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |

+----------------+----------+--------------+------------------+-------------------+

| log-bin.000017 | 154 | | | |

+----------------+----------+--------------+------------------+-------------------+

1 row in set (0.00 sec)

在slave上

vim /etc/my.cnf

[mysqld]

socket=/tmp/mysql.sock

basedir=/usr/local/mysql

datadir=/mydata/data

#log-bin=/mydata/binlog/log-bin

server-id=3

relay-log = /mydata/binlog/relay-bin

bind-address = 0.0.0.0

skip-name-resolve

master_info_repository=TABLE

relay_log_info_repository=TABLE

SHOW GLOBAL VARIABLES LIKE '%repository%';

CHANGE MASTER TO MASTER_HOST='192.168.130.61', MASTER_USER='repluser', MASTER_PASSWORD='replpass', MASTER_LOG_FILE='log-bin.000017', MASTER_LOG_POS=154 FOR CHANNEL 'Master_1';

START SLAVE FOR CHANNEL 'Master_1';

SHOW SLAVE STATUS FOR CHANNEL 'Master_1'\G;

CHANGE MASTER TO MASTER_HOST='192.168.130.62', MASTER_USER='repluser', MASTER_PASSWORD='replpass', MASTER_LOG_FILE='log-bin.000017', MASTER_LOG_POS=154 FOR CHANNEL 'Master_2';

START SLAVE FOR CHANNEL 'Master_2';

SHOW SLAVE STATUS FOR CHANNEL 'Master_2'\G;

上一篇:Linux服务器之安装Tomcat
下一篇:Centos7 编译安装搭建LAMP平台
相关文章
图文推荐

关于大家 | 联系大家 | 广告服务 | 投资合作 | 版权申明 | 在线帮助 | 网站地图 | 作品发布 | Vip技术培训 | 举报中心

版权所有: 澳门葡京手机版网址_澳门新莆京娱乐_www.88807.com - 点此进入--致力于做实用的IT技术学习网站

XML 地图 | Sitemap 地图