mysql主主配置
Posted yxnyd
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了mysql主主配置相关的知识,希望对你有一定的参考价值。
数据安装完成后
配置信息 开启二进制文件复制
[client]
port=3306
[mysqld]
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
#socket=/usr/local/mysql/mysql.sock
socket=/tmp/mysql.sock
user=mysql
#skip-grant-tables
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
#主从复制配置
server-id=1 #设置server-id
log_bin=mysql-bin #开启二进制日志
expire_logs_days=10
max_binlog_size=100M
binlog-do_db=test_master_slave
binlog_ignore_db=mysql
[mysqld_safe]
log-error=/var/log/mariadb/mariadb.log
pid-file=/var/run/mariadb/mariadb.pid
#
# include all files from the config directory
#
!includedir /etc/my.cnf.d
复制用户授权
GRANT REPLICATION SLAVE ON *.* TO ‘root‘@‘%‘;
查看二进制是否开启
show variables like ‘%log_bin%‘;
查看二进制文件名/id
SHOW MASTER STATUS;
根据二进制文件 配置复制脚本
CHANGE MASTER TO MASTER_HOST=‘192.168.0.114‘,MASTER_USER=‘root‘,MASTER_PASSWORD=‘root‘,MASTER_LOG_FILE=‘mysql-bin.000003‘,MASTER_LOG_POS=154;
CHANGE MASTER TO MASTER_HOST=‘192.168.0.113‘,MASTER_USER=‘root‘,MASTER_PASSWORD=‘root‘,MASTER_LOG_FILE=‘mysql-bin.000002‘,MASTER_LOG_POS=848;
启动复制(更新脚本时需要停止 stop slave)
start slave;
查看配置是否成功
show slave status\G;
刷新
flush privileges;
以上是关于mysql主主配置的主要内容,如果未能解决你的问题,请参考以下文章