mysql误删数据的恢复(淘宝技术团队)
来源:互联网 发布:龙瞎皮肤淘宝多少钱 编辑:程序博客网 时间:2024/05/01 07:36
转自:http://www.taobaodba.com/
阿里巴巴集团数据库技术团队
数据平台开发误删数据,但是不知道具体时间点,就给了一个模糊时间,同事使用rollback逆向恢复(解析binlog产生反向SQL),我使用备份集恢复apply binlog正向恢复,尽快解决问题
- 选择数据出问题时间之前最近的备份集恢复在一个新实例(restorebak.pl恢复工具支持,操作方便)
- 将备份集pos与数据出问题pos之间的binlog拷贝到新实例上(拷贝binlog操作繁琐)
- 使用mysqlbinlog –stop-datetime来apply binlog到新实例,以便恢复到数据出问题前的一致性数据快照(mysqlbinlog每次只支持单个binlog apply ,操作繁琐)
其中关于pos点的查找一般都是通过类似mysqlbinlog –no-defaults –stop-datetime=”2012-11-11 11:11:11″ |grep “具体操作” -C 3方式来查找的,先通过大体时间段确定一个范围,然后在范围内的精确查找具体的pos
其实mysql有个函数master_pos_wait 可以指定具体pos并返回期间执行事件,于是改进恢复过程,将新实例直接指向原主库拉binlog
- 选择数据出问题时间之前最近的备份集恢复在一个新实例(恢复工具支持,操作方便)
- start slave;select MASTER_POS_WAIT(‘mysql-bin.000396′,67698920,0);stop slave; (relay 到指定pos后 触发stop slave操作)
- show slave status\G; (保存复制关系)
- change master to master_host=’ ‘, master_user=’slave’,master_password=’slave’; (取消复制关系,防止误操作开启复制)
MASTER_POS_WAIT(log_name,log_pos[,timeout])
This function is useful for control of master/slave synchronization. It blocks until the slave has read and applied all updates up to the specified position in the master log. The return value is the number of log events the slave had to wait for to advance to the specified position. The function returns NULL if the slave SQL thread is not started, the slave’s master information is not initialized, the arguments are incorrect, or an error occurs. It returns -1 if the timeout has been exceeded. If the slave SQL thread stops while MASTER_POS_WAIT() is waiting, the function returns NULL. If the slave is past the specified position, the function returns immediately.
If a timeout value is specified, MASTER_POS_WAIT() stops waiting when timeout seconds have elapsed. timeoutmust be greater than 0; a zero or negative timeout means no timeout.
This function is unsafe for statement-based replication. Beginning with MySQL 5.5.1, a warning is logged if you use this function when binlog_format is set to STATEMENT. (Bug #47995)
An UNTIL clause may be added to specify that the slave should start and run until the SQL thread reaches a given point in the master binary log or in the slave relay log. When the SQL thread reaches that point, it stops. If the SQL_THREAD option is specified in the statement, it starts only the SQL thread. Otherwise, it starts both slave threads. If the SQL thread is running, the UNTIL clause is ignored and a warning is issued.
For an UNTIL clause, you must specify both a log file name and position. Do not mix master and relay log options.
Any UNTIL condition is reset by a subsequent STOP SLAVE statement, a START SLAVE statement that includes noUNTIL clause, or a server restart.
The UNTIL clause can be useful for debugging replication, or to cause replication to proceed until just before the point where you want to avoid having the slave replicate an event. For example, if an unwise DROP TABLE statement was executed on the master, you can use UNTIL to tell the slave to execute up to that point but no farther. To find what the event is, use mysqlbinlog with the master binary log or slave relay log, or by using a SHOW BINLOG EVENTS statement.
If you are using UNTIL to have the slave process replicated queries in sections, it is recommended that you start the slave with the –skip-slave-start option to prevent the SQL thread from running when the slave server starts. It is probably best to use this option in an option file rather than on the command line, so that an unexpected server restart does not cause it to be forgotten.
- 选择数据出问题时间之前最近的备份集恢复在一个新实例(恢复工具支持,操作方便)
- start slave until master_log_file=’mysql-bin.000396′,master_log_pos=67698920;
- show slave status\G; (保存复制关系)
- change master to master_host=’ ‘, master_user=’slave’,master_password=’slave’; (取消复制关系,防止误操作开启复制)
- mysql误删数据的恢复(淘宝技术团队)
- mysql 恢复误删数据的方法
- MySql恢复误删的表或数据(不完全恢复)
- mysql 误删数据恢复
- mysql 恢复误删数据
- mysql的数据恢复
- mysql使用binlog恢复使用delete误删的数据
- MySQL误操作后的数据恢复
- mysql数据误删除的恢复
- 讲述数据恢复的技术
- 淘宝海量数据产品的技术架构
- 淘宝海量数据产品的技术架构
- 淘宝海量数据产品的技术架构
- 淘宝mysql技术分享
- 淘宝 腾讯 百度 新浪 技术团队 博客
- 淘宝 腾讯 百度 技术团队 博客
- 淘宝 腾讯 百度 新浪 技术团队 博客
- 淘宝 腾讯 百度 新浪 技术团队 博客
- 美工之道-Photoshop和Illstrator的颜色抓取
- ADO.Net之自定义SqlHelper类
- 约翰伍登名言录
- 深入理解android 系列
- Win32编程中如何处理控制台消息
- mysql误删数据的恢复(淘宝技术团队)
- 针对WinCE6.0下繁多的补丁包该怎么打及WinCE6.0 R3安装步骤----自己的经历
- 关于Yaffs2移植问题
- 用django实现redirect的几种方法总结
- java中volatile关键字的含义
- PHP动态网页设计(第2版)——使用PHP
- Rails 3.2 的 Ajax 向导(非常好)
- 【Android常用控件】EditText常用属性【三】:EditText选取操作
- 三层架构(一)——理论点滴