mysql北非之主从同步
主实例配置:
[mysqld] log-bin=mysql-bin #/ [必须]启用二进制日志 server-id=1 # [必须]服务器唯一ID
从实例配置:
[mysqld] log-bin=mysql-bin # [非必须]Slave可以不启用二进制日志,配置二进制日志可以便于Master和Slave交换角色 server-id=2 # [必须]服务器唯一ID
在Master上使用root用户登录建立同步账户并授权Slave
mysql> GRANT REPLICATION SLAVE ON *.* to 'lover'@'%' identified by 'kiss'; mysql> FLUSH PRIVILEGES;
使用root账户登录Master查看Master状态
mysql> show master status; +------------------+----------+--------------+------------------+-------------------+ | File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set | +------------------+----------+--------------+------------------+-------------------+ | mysql-bin.000002 | 6584 | thisonedb | mysql | | +------------------+----------+--------------+------------------+-------------------+
配置Slave跟踪Master日志的位置
mysql> change master to master_host='127.0.0.1',master_user='lover',master_password='kiss',master_log_file='mysql-bin.000002',master_log_pos=6584 ; mysql> start slave;
使用root账户登录MySQL核对Slave状态,看到如下信息就说明配置成功了
mysql> show slave status\G; *************************** 1. row *************************** Slave_IO_State: Waiting for master to send event Master_Host: 10.16.13.128 Master_User: username Master_Port: 3306 Connect_Retry: 60 Master_Log_File: mysql-bin.000002 Read_Master_Log_Pos: 6584 Relay_Log_File: bx-13-129-relay-bin.000003 Relay_Log_Pos: 6797 Relay_Master_Log_File: mysql-bin.000002 Slave_IO_Running: Yes Slave_SQL_Running: Yes
相关推荐
emmm00 2020-11-17
暗夜之城 2020-11-11
疯狂老司机 2020-09-08
CoderToy 2020-11-16
王艺强 2020-11-17
ribavnu 2020-11-16
bianruifeng 2020-11-16
wangshuangbao 2020-11-13
苏康申 2020-11-13
vivenwan 2020-11-13
moyekongling 2020-11-13
云中舞步 2020-11-12
要啥自行车一把梭 2020-11-12
aydh 2020-11-12
kuwoyinlehe 2020-11-12
minerk 2020-11-12
vitasfly 2020-11-12
jazywoo在路上 2020-11-11