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

 

mysql mysqld_multi多实例实现主从库_第1张图片

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

你可能感兴趣的:(MYSQL)