当前位置:网站首页>binglog log tracking: data backup and backup tracking
binglog log tracking: data backup and backup tracking
2022-07-31 00:15:00 【Miracle_ze】
目录
1)编辑打开mysql配置文件【linux:my.cnf windows:my.ini】
3)Log in to the database to see if logging is enabled【使用likeFuzzy query system variableslog_开头的关键词】
2)查看master状态,即最后(最新)一个binlog日志的编号名称,及其最后一个操作事件pos结束点(Position)值
3)flush刷新log日志,自此刻开始产生一个新编号的binlog日志文件
1)View the content of existing libraries and tables
一、简单了解binlog
MySQL的二进制日志binlog可以说是MySQL最重要的日志,它记录了所有的DDL(create alter drop)和DML语句(除了数据查询语句select),以事件形式记录,还包含语句所执行的消耗的时间,MySQL的二进制日志是事务安全型的.
一般来说开启binlog日志大概会有1%的性能损耗.
binlog日志有两个最重要的使用场景
1)MySQL主从复制:MySQL Replication在Master端开启binlog,Master把它的二进制日志传递给slaves来达到 master-slave数据一致的目的.
2)自然就是数据恢复了,通过使用mysqlbinlog工具来使恢复数据.
binlog日志包括两类文件
1)二进制日志索引文件(文件名后缀为.index)用于记录所有的二进制文件
2)二进制日志文件(文件名后缀为.00000*)记录数据库所有的DDL和DML(除了数据查询语句select)语句事件.
二、binlog日志功能
1.开启binglog日志功能
1)编辑打开mysql配置文件【linux:my.cnf windows:my.ini】
文件在mysql 文件路径下
[mysqld]
log-bin=mysql-bin
确认是打开状态(mysql-bin 是日志的基本名或前缀名)

2)Turn on the log function and restartmysqlservice to refresh the read file call service【调用flush logs】
刷新后binglog会创建一个binlog日志
语句:
service mysql restart
结果:
![]()
3)Log in to the database to see if logging is enabled【使用likeFuzzy query system variableslog_开头的关键词】
语句:
show variables like 'log_%';
结果:

上图显示:log_bin 的状态是ON【开启状态】
2.对binglog日志的操作
1)查看创建的binglog日志
语句:
show master logs;
结果:

The file name of the above image starts with.xxxxxxEnds with a log file
2)查看master状态,即最后(最新)一个binlog日志的编号名称,及其最后一个操作事件pos结束点(Position)值
语句:
show master status;结果:

3)flush刷新log日志,自此刻开始产生一个新编号的binlog日志文件
语句:
flush logs;结果:

在 Restarting the database is that this command is executed automatically;另外在mysqldump备份数据的时候 -F选项也会刷新binglog日志
4)重置(清空)所有binlog日志
语句:
reset master;结果:【Cleared the log but it will still get an up-to-date log after clearing it】

三、备份数据库
1)View the content of existing libraries and tables

2)备份数据库
这里手动执行下,将lzy数据库备份到/opt/backup/ops$(date +%F).sql.gz文件中:
[[email protected] ~]# mysqldump -uroot -p -B -F -R -x --master-data=2 lzy|gzip >/opt/backup/ops$(date +%F).sql.gz Enter password:
**参数说明:**
-B:指定数据库
-F:刷新日志
-R:备份存储过程等
-x:锁表
--master-data:在备份语句里添加CHANGE MASTER语句以及binlog文件及位置点信息
\-----------------
待到数据库备份完成,就不用担心数据丢失了,因为有完全备份数据在!!
由于上面在全备份的时候使用了-F选项,那么当数据备份操作刚开始的时候系统就会自动刷新log,这样就会自动产生
3)读取备份
[[email protected] mysql]# mysqlbinlog mysql-bin.000003边栏推荐
- uniapp develops WeChat applet - soft exam brushing applet
- 加密传输过程
- 对象集合去重的方法
- ABC 261 F - Sorting Color Balls(逆序对)
- 封装、获取系统用户信息、角色及权限控制
- align-content、justify-content、align-items三个属性的作用和效果
- WebServer process explanation (registration module)
- 47. 【Pointers and Arrays】
- @requestmapping注解的作用及用法
- Ukraine's foreign ministry: wu was restored to complete the export of food security
猜你喜欢

实验8(vlan实验)

如何在WordPress网站上添加导航菜单

在微服务中使用事件溯源的六大原因 - Herath

Steven Giesel recently published a 5-part series documenting his first experience building an application with the Uno Platform.

边缘计算与小程序也能结合!智能家居是否能借势上台阶

软件开发设计流程

How to Repair Word File Corruption

How to install joiplay emulator rtp

MySQL的grant语句

C# VSCode & Rider引用命名空间快捷键
随机推荐
joiplay模拟器不支持此游戏类型怎么解决
VSCode高效开源神器有哪些
binglog日志追踪:数据备份并备份追踪
uniapp folding box secondary loop
【VisDrone数据集】YOLOV4训练VisDrone数据集步骤与结果
uni-ui installation
uniapp折叠框二级循环
Steven Giesel recently published a 5-part series documenting his first experience building an application with the Uno Platform.
How to ensure the consistency of database and cache data?
Manually set transaction commit in mysql
xss绕过:prompt(1)
测试人面试 常被问到的计算机网络题,高薪回答模板来了
mysql 中手动设置事务提交
xss的绕过
动态修改el-tab-pane 的label(整理)
【深入浅出玩转FPGA学习13-----------测试用例设计1】
限制字符绕过
background对float的子元素无效
【VisDrone数据集】YOLOV3训练VisDrone数据集步骤与结果
joiplay模拟器rtp如何安装