mysql mysqld_multi多实例实现主从库

https://www.cnblogs.com/agang-php/p/11465856.html

上述网址实现mysqld_multi多实例

 /etc/init.d/mysqld_multi start 1-3

/etc/init.d/mysqld_multi restart 1-3

/etc/init.d/mysqld_multi stop 1-3

 

连接实例

ysql多实例:

[root@localhost ~]# mysql -u root -p123456 -S /tmp/mysql3306.sock

[root@localhost ~]# mysql -u root -p123456 -S /tmp/mysql3307.sock

[root@localhost ~]# mysql -u root -p123456 -S /tmp/mysql3308.sock

 

主库

log-bin=mysql-bin #slave会基于此log-bin来做replication

server-id=1 #master的标示

innodb_flush_log_at_trx_commit=1

sync_binlog=1

从库

server-id=2 #slave的标示 ,192.168.2.203:3307配置

server-id=3 #slave的标示 ,192.168.2.203:3308配置

 

 

3306

mysql>create user 'slave_yy'@'192.168.2.%' identified by 'slaveadmin';

mysql>grant replication slave on *.* to 'slave_yy'@'192.168.2.%';

 

mysql>flush tables with read lock;

 

mysql> show master status;

 

主库

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

| File             | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |

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

| mysql-bin.000001 |     2347 |              |                  |                   |

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

从库3307

mysql>change master to

    -> master_host='192.168.2.243',

    -> master_user='slave_yy',

    -> master_password='aaaaaa',

    -> master_port=3306,

    -> master_log_file='mysql-bin.000001',

    -> master_log_pos= 7747384;

mysql>start slave;

Query OK, 0 rows affected (0.00 sec)

 

mysql> show slave status\G

 

等主从设置成功后,再unlock tables;position恢复

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值