场景:MySQL主库无故宕机:判断是IO问题导致。The manual page at http://dev.mysql.com/doc/mysql/en/crashing.html containsinformation that should help you find out what is causing the crash.200118 02:11:39 mysqld_safe Number of processes running now: 0200118 02:11:39 mysqld_safe mysqld restarted
原来主库的my.cnf:
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html
# *** DO NOT EDIT THIS FILE. It's a template which will be copied to the
# *** default location during install, and will be replaced if you
# *** upgrade to a newer version of MySQL.
[mysqld]
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
# These are commonly set, remove the # and set as required.
# basedir = .....
# datadir = .....
# port = .....
# server_id = .....
# socket = .....
basedir=/usr/local/mysql
datadir=/data/bak1
socket=/tmp/mysql.sock
server-id =11224722
default_password_lifetime=0
log-bin=/data/bak1/mysql-bin2
expire_logs_days = 1
max_binlog_size =600M
binlog_format = MIXED
#max_allowed_packet =1*1024*1024*1024
max_allowed_packet =1024M
event_scheduler = 1
transaction-isolation = READ-COMMITTED
max_connections=5000
innodb_buffer_pool_size = 80G
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
1.确保所有的relay log全部更新完毕,在每个从库上执行stop slave io_thread; show processlist;
直到看到Has read all relay log,则表
示从库更新都执行完毕了。2.登陆所有从库,查看master.info文件,对比选择pos最大的作为新的主库,这里我们选择192.168.112.10为新的主库。
3.登陆192.168.112.10,执行stop slave; 并进入数据库目录,删除master.info和relay-log.info文件, 配置my.cnf文件,
开启log-bin,如果有
log-slaves-updates和read-only则要注释掉,执行reset master。
新主库的my.cnf:
[mysqld]
#datadir=/var/lib/mysql
#socket=/var/lib/mysql/mysql.sock
datadir=/data/db
socket=/tmp/mysql.sock
server-id =111210
log-bin = /data/db/mysql-bin.log
# binlog_format = MIXED
#relay-log = rep_relay_log1
#relay-log-index = rep_relay_log1
#log-error=/data/bak/mysqld1.err
#skip-slave-start = 1
default_password_lifetime=0
# binlog-ignore-db=mysql
#expire_logs_days =7
max_connections = 2000
# user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
#symbolic-links=0
max_allowed_packet =1024M
#master_info_repository=table
#relay_log_info_repository=table
#relay_log_recovery=1
#transaction-isolation = READ-COMMITTED
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
4.SHOW MASTER STATUS; 查询主库状态。
OK。
MySQL 5.7 主库崩溃切备库
来源:这里教程网
时间:2026-03-01 14:49:10
作者:
编辑推荐:
下一篇:
相关推荐
-
雷神推出 MIX PRO II 迷你主机:基于 Ultra 200H,玻璃上盖 + ARGB 灯效
2 月 9 日消息,雷神 (THUNDEROBOT) 现已宣布推出基于英
-
制造商 Musnap 推出彩色墨水屏电纸书 Ocean C:支持手写笔、第三方安卓应用
2 月 10 日消息,制造商 Musnap 现已在海外推出一款 Oce
热文推荐
- MySQL 5.7 主库崩溃切备库
MySQL 5.7 主库崩溃切备库
26-03-01 - 求索作文网采用ZBLOG-PHP系统目前唯有纯静态化插件不满意[图]
求索作文网采用ZBLOG-PHP系统目前唯有纯静态化插件不满意[图]
26-03-01 - MySQL各版本架构图
MySQL各版本架构图
26-03-01 - DB-Engines 2019 年度数据库出炉:MySQL 成为年度数据库赢家
- Centos7以rpm方式安装mysql-5.5
Centos7以rpm方式安装mysql-5.5
26-03-01 - 原来微信被删除后仍可以继续聊天,只要这样简单操作就可以了
原来微信被删除后仍可以继续聊天,只要这样简单操作就可以了
26-03-01 - mysql 5.7 虚拟列功能
mysql 5.7 虚拟列功能
26-03-01 - 第19节 从库MTS多线程并行回放(一)
第19节 从库MTS多线程并行回放(一)
26-03-01 - MySQL数据库之互联网常用架构方案(全)
MySQL数据库之互联网常用架构方案(全)
26-03-01 - 第20节 从库MTS多线程并行回放(二)
第20节 从库MTS多线程并行回放(二)
26-03-01
