侧边栏壁纸
  • 累计撰写 84 篇文章
  • 累计创建 35 个标签
  • 累计收到 1 条评论

目 录CONTENT

SQL

mysql主从配置

天明
2023-10-26 / 0 评论 / 0 点赞 / 28 阅读 / 1064 字 / 正在检测是否收录...

my.cnf配置

[mysqld]
character-set-server=utf8mb4
thread_handling=pool-of-threads
thread_pool_max_threads=1000
thread_pool_idle_timeout=900
max_connections=3001
#在master增加配置
server-id=153
log_bin = mysql-bin
relay_log = /var/lib/mysql/mysql-relay-bin
log_slave_updates = 1
read_only =1

数据库设置

#分别在master和slave上创建用户
create user slave identified by 'slave#mysql123';
grant replication slave,replication client on *.* to 'slave'@'192.168.1.%' identified by 'slave#mysql123';
flush privileges;
# 停止slave
STOP SLAVE IO_THREAD FOR CHANNEL '';
# 查看slave状态
show slave status\G;
# 查看master状态,用于设置slave【File、Position】
show master status\G;
# 在slave设置master
change master to master_host='192.168.1.12',master_user='slave',master_password='slave#mysql123',master_log_file='File',master_log_pos=Position;
# 开启slave
start slave;

binlog内容查看

mysqlbinlog  -v --base64-output=DECODE-ROWS /home/log/mysql/bin-file.000448 | grep -A '20' 210812275
0

评论区