mysql 配置主从复制
主库配置
# Binary Logging. # log-bin log-bin=mysql-bin #[必须]启用二进制日志 # Error Logging. log-error="mysql-error.log" # Server Id. server-id=200 #不同步的数据库,可设置多个 binlog-ignore-db=information_schema binlog-ignore-db=performance_schema binlog-ignore-db=mysql
expire-logs-days=10
从库配置
server-id=200 # 不能与主库的 server-id 相同
查看master状态,记录下结果中的File和Position 配置
show master status;
配置
CHANGE MASTER TO MASTER_HOST='192.168.2.238', MASTER_USER='root', MASTER_PASSWORD='*****', MASTER_LOG_FILE='mysql-bin.000248', MASTER_LOG_POS=870, master_port=3306;
开启
start slave;
查询状态
show slave status;
Slave_IO_Running 与 Slave_SQL_Running 都为Yes 表示配置成功
Slave_IO_Running: Yes
Slave_SQL_Running: Yes