主库配置
server-id=1
port=3306
datadir=/data/mysql
socket=/var/lib/mysql/mysql.sock
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
#log
expire_logs_days = 7
tmp_table_size=1G
#bin-log
log-bin=mysql-bin
sync_binlog=1
binlog_format=mixed
max_binlog_size=5G
binlog_cache_size=128m
max_binlog_cache_size=512m
#config
innodb_buffer_pool_size=1G
添加用户
添加用户权限
grant replication slave on *.* to 'relay'@'%';
FLUSH PRIVILEGES;
显示主库状态
show master status;
配置
配置从库
CHANGE MASTER TO
MASTER_HOST = '11.11.4.15',
MASTER_USER = 'relay',
MASTER_PASSWORD = 'xxxx',
MASTER_PORT = 3306,
MASTER_LOG_FILE='mysql-bin.000001',
MASTER_LOG_POS=852,
MASTER_RETRY_COUNT = 60,
GET_MASTER_PUBLIC_KEY=1,
MASTER_HEARTBEAT_PERIOD = 10000;
启动从库
start slave;
如果要重新修改配置 ,需要先停止文章来源:https://www.toymoban.com/news/detail-834413.html
stop slave;
最后查看从库状态文章来源地址https://www.toymoban.com/news/detail-834413.html
show slave status;
到了这里,关于配置mysql的主从同步的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!