【mysql】 mysql数据库 M-M-S 的实现

【1】编辑mysql的配置文件/etc/my.cnf
1】 M : 10.10.68.1

[mysqld]
log-bin=mysql_bin   
server-id=1
master_host='10.10.68.22'
master_user='slave'
master_password='1234'
log-slave-updates



2】 M : 10.10.68.22

[mysqld]
log-bin=mysql_bin   
server-id=2
master_host='10.10.68.1'
master_user='slave'
master_password='1234'


3】 M : 10.10.68.23

[mysqld]
server-id=3
master_host='10.10.68.1'
master_user='slave'
master_password='1234'


【2】 登录 M:10.10.68.1 授权用户


mysql > grant replication slave on *.* to [email protected] identified by '1234';
> grant replication slave on *.* to [email protected] identified by '1234';

mysql > show master status;

【3】 登录 M:10.10.68.22 授权用户


mysql > grant replication slave on *.* to [email protected] identified by '1234';

mysql >show master status;

【4】 登录 S:10.10.68.23 配置

mysql > change master to
> master_host='10.10.68.1',
> master_user='slave',
> master_password='1234',
> master_log_file='bin_log_00001', #由Master status 得到
> master_log_pos=339;

mysql > slave start;

mysql > show slave status \G 查看状态


Slave_IO_Running = YES
Slave_SQL_Running = YES
表示成功


【5】 M :10.10.68.1 和 M :10.10.68.22 互相设置从服务器 方法同4

配置完成

【6】 测试 登录一个数据节点 创建数据库 可同步copy到其他节点

你可能感兴趣的:(mysql)