<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="zh-cn">
		<id>https://wiki.qiaochenglei.cn/index.php?action=history&amp;feed=atom&amp;title=MySQL%E5%9F%BA%E4%BA%8ELVM%E5%BF%AB%E7%85%A7%E7%9A%84%E5%A4%87%E4%BB%BD%E6%81%A2%E5%A4%8D</id>
		<title>MySQL基于LVM快照的备份恢复 - 版本历史</title>
		<link rel="self" type="application/atom+xml" href="https://wiki.qiaochenglei.cn/index.php?action=history&amp;feed=atom&amp;title=MySQL%E5%9F%BA%E4%BA%8ELVM%E5%BF%AB%E7%85%A7%E7%9A%84%E5%A4%87%E4%BB%BD%E6%81%A2%E5%A4%8D"/>
		<link rel="alternate" type="text/html" href="https://wiki.qiaochenglei.cn/index.php?title=MySQL%E5%9F%BA%E4%BA%8ELVM%E5%BF%AB%E7%85%A7%E7%9A%84%E5%A4%87%E4%BB%BD%E6%81%A2%E5%A4%8D&amp;action=history"/>
		<updated>2026-04-07T03:20:50Z</updated>
		<subtitle>本wiki的该页面的版本历史</subtitle>
		<generator>MediaWiki 1.24.2</generator>

	<entry>
		<id>https://wiki.qiaochenglei.cn/index.php?title=MySQL%E5%9F%BA%E4%BA%8ELVM%E5%BF%AB%E7%85%A7%E7%9A%84%E5%A4%87%E4%BB%BD%E6%81%A2%E5%A4%8D&amp;diff=1468&amp;oldid=prev</id>
		<title>2016年9月20日 (二) 13:37 Admin</title>
		<link rel="alternate" type="text/html" href="https://wiki.qiaochenglei.cn/index.php?title=MySQL%E5%9F%BA%E4%BA%8ELVM%E5%BF%AB%E7%85%A7%E7%9A%84%E5%A4%87%E4%BB%BD%E6%81%A2%E5%A4%8D&amp;diff=1468&amp;oldid=prev"/>
				<updated>2016-09-20T13:37:42Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;tr style='vertical-align: top;'&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;←上一版本&lt;/td&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;2016年9月20日 (二) 13:37的版本&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;第190行：&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;第190行：&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;|&amp;#160; 3 | zcj&amp;#160; |&amp;#160; 18 | &amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;|&amp;#160; 3 | zcj&amp;#160; |&amp;#160; 18 | &amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;+----+------+------+&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;+----+------+------+&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;/nowiki&amp;gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;6、总结&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;6、总结&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;第195行：&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;第197行：&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;基于LVM的数据备份方案几乎实现了热备，只是在请求读锁时会影响线上的业务，一旦当读锁请求到，创建快照几乎是瞬间完成，快照卷创建好后就可解除锁定，而备份就像复制或归档文件一样简单。数据恢复时只需要关闭mysql进程，把备份的数据复制到相应的数据目录，确保数据目录权限正确，启用服务即可，由于是直接复制的数据文件，所以索引不用重建。&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;基于LVM的数据备份方案几乎实现了热备，只是在请求读锁时会影响线上的业务，一旦当读锁请求到，创建快照几乎是瞬间完成，快照卷创建好后就可解除锁定，而备份就像复制或归档文件一样简单。数据恢复时只需要关闭mysql进程，把备份的数据复制到相应的数据目录，确保数据目录权限正确，启用服务即可，由于是直接复制的数据文件，所以索引不用重建。&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;/nowiki&amp;gt;&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;使用LVM创建弹性磁盘存储——第一部分&amp;#160; http://www.linuxidc.com/Linux/2014-10/107697.htm&amp;lt;br /&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;使用LVM创建弹性磁盘存储——第一部分&amp;#160; http://www.linuxidc.com/Linux/2014-10/107697.htm&amp;lt;br /&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;在Linux中扩展/缩减LVM（第二部分）&amp;#160; http://www.linuxidc.com/Linux/2014-10/107786.htm&amp;lt;br /&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;在Linux中扩展/缩减LVM（第二部分）&amp;#160; http://www.linuxidc.com/Linux/2014-10/107786.htm&amp;lt;br /&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	<entry>
		<id>https://wiki.qiaochenglei.cn/index.php?title=MySQL%E5%9F%BA%E4%BA%8ELVM%E5%BF%AB%E7%85%A7%E7%9A%84%E5%A4%87%E4%BB%BD%E6%81%A2%E5%A4%8D&amp;diff=1465&amp;oldid=prev</id>
		<title>2016年9月20日 (二) 13:36 Admin</title>
		<link rel="alternate" type="text/html" href="https://wiki.qiaochenglei.cn/index.php?title=MySQL%E5%9F%BA%E4%BA%8ELVM%E5%BF%AB%E7%85%A7%E7%9A%84%E5%A4%87%E4%BB%BD%E6%81%A2%E5%A4%8D&amp;diff=1465&amp;oldid=prev"/>
				<updated>2016-09-20T13:36:02Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;tr style='vertical-align: top;'&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;←上一版本&lt;/td&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;2016年9月20日 (二) 13:36的版本&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;第202行：&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;第202行：&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;在LVM中设置精简资源调配卷（第四部分） http://www.linuxidc.com/Linux/2014-11/109757.htm&amp;lt;br /&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;在LVM中设置精简资源调配卷（第四部分） http://www.linuxidc.com/Linux/2014-11/109757.htm&amp;lt;br /&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;使用条块化I/O管理多个LVM磁盘（第五部分） http://www.linuxidc.com/Linux/2014-12/110532.htm&amp;lt;br /&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;使用条块化I/O管理多个LVM磁盘（第五部分） http://www.linuxidc.com/Linux/2014-12/110532.htm&amp;lt;br /&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;本文永久更新链接地址：http&lt;/del&gt;://www.linuxidc.com/Linux/2015-04/116238.htm&amp;lt;br /&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;本文参考链接地址：http&lt;/ins&gt;://www.linuxidc.com/Linux/2015-04/116238.htm&amp;lt;br /&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	<entry>
		<id>https://wiki.qiaochenglei.cn/index.php?title=MySQL%E5%9F%BA%E4%BA%8ELVM%E5%BF%AB%E7%85%A7%E7%9A%84%E5%A4%87%E4%BB%BD%E6%81%A2%E5%A4%8D&amp;diff=1464&amp;oldid=prev</id>
		<title>2016年9月20日 (二) 13:35 Admin</title>
		<link rel="alternate" type="text/html" href="https://wiki.qiaochenglei.cn/index.php?title=MySQL%E5%9F%BA%E4%BA%8ELVM%E5%BF%AB%E7%85%A7%E7%9A%84%E5%A4%87%E4%BB%BD%E6%81%A2%E5%A4%8D&amp;diff=1464&amp;oldid=prev"/>
				<updated>2016-09-20T13:35:38Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;tr style='vertical-align: top;'&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;←上一版本&lt;/td&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;2016年9月20日 (二) 13:35的版本&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;第197行：&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;第197行：&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/nowiki&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/nowiki&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;使用LVM创建弹性磁盘存储——第一部分&amp;#160; http://www.linuxidc.com/Linux/2014-10/107697.htm&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;使用LVM创建弹性磁盘存储——第一部分&amp;#160; http://www.linuxidc.com/Linux/2014-10/107697.htm&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;br /&amp;gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;在Linux中扩展/缩减LVM（第二部分）&amp;#160; http://www.linuxidc.com/Linux/2014-10/107786.htm&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;在Linux中扩展/缩减LVM（第二部分）&amp;#160; http://www.linuxidc.com/Linux/2014-10/107786.htm&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;br /&amp;gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;在 LVM中 录制逻辑卷快照并恢复（第三部分） http://www.linuxidc.com/Linux/2014-11/108867.htm&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;在 LVM中 录制逻辑卷快照并恢复（第三部分） http://www.linuxidc.com/Linux/2014-11/108867.htm&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;br /&amp;gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;在LVM中设置精简资源调配卷（第四部分） http://www.linuxidc.com/Linux/2014-11/109757.htm&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;在LVM中设置精简资源调配卷（第四部分） http://www.linuxidc.com/Linux/2014-11/109757.htm&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;br /&amp;gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;使用条块化I/O管理多个LVM磁盘（第五部分） http://www.linuxidc.com/Linux/2014-12/110532.htm&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;使用条块化I/O管理多个LVM磁盘（第五部分） http://www.linuxidc.com/Linux/2014-12/110532.htm&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;br /&amp;gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;本文永久更新链接地址：http://www.linuxidc.com/Linux/2015-04/116238.htm&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;本文永久更新链接地址：http://www.linuxidc.com/Linux/2015-04/116238.htm&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;br /&amp;gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	<entry>
		<id>https://wiki.qiaochenglei.cn/index.php?title=MySQL%E5%9F%BA%E4%BA%8ELVM%E5%BF%AB%E7%85%A7%E7%9A%84%E5%A4%87%E4%BB%BD%E6%81%A2%E5%A4%8D&amp;diff=1463&amp;oldid=prev</id>
		<title>2016年9月20日 (二) 13:35 Admin</title>
		<link rel="alternate" type="text/html" href="https://wiki.qiaochenglei.cn/index.php?title=MySQL%E5%9F%BA%E4%BA%8ELVM%E5%BF%AB%E7%85%A7%E7%9A%84%E5%A4%87%E4%BB%BD%E6%81%A2%E5%A4%8D&amp;diff=1463&amp;oldid=prev"/>
				<updated>2016-09-20T13:35:12Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;tr style='vertical-align: top;'&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;←上一版本&lt;/td&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;2016年9月20日 (二) 13:35的版本&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;第195行：&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;第195行：&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;基于LVM的数据备份方案几乎实现了热备，只是在请求读锁时会影响线上的业务，一旦当读锁请求到，创建快照几乎是瞬间完成，快照卷创建好后就可解除锁定，而备份就像复制或归档文件一样简单。数据恢复时只需要关闭mysql进程，把备份的数据复制到相应的数据目录，确保数据目录权限正确，启用服务即可，由于是直接复制的数据文件，所以索引不用重建。&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;基于LVM的数据备份方案几乎实现了热备，只是在请求读锁时会影响线上的业务，一旦当读锁请求到，创建快照几乎是瞬间完成，快照卷创建好后就可解除锁定，而备份就像复制或归档文件一样简单。数据恢复时只需要关闭mysql进程，把备份的数据复制到相应的数据目录，确保数据目录权限正确，启用服务即可，由于是直接复制的数据文件，所以索引不用重建。&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;/nowiki&amp;gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;使用LVM创建弹性磁盘存储——第一部分&amp;#160; http://www.linuxidc.com/Linux/2014-10/107697.htm&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;使用LVM创建弹性磁盘存储——第一部分&amp;#160; http://www.linuxidc.com/Linux/2014-10/107697.htm&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;在Linux中扩展/缩减LVM（第二部分）&amp;#160; http://www.linuxidc.com/Linux/2014-10/107786.htm&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;在Linux中扩展/缩减LVM（第二部分）&amp;#160; http://www.linuxidc.com/Linux/2014-10/107786.htm&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;第200行：&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;第202行：&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;在LVM中设置精简资源调配卷（第四部分） http://www.linuxidc.com/Linux/2014-11/109757.htm&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;在LVM中设置精简资源调配卷（第四部分） http://www.linuxidc.com/Linux/2014-11/109757.htm&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;使用条块化I/O管理多个LVM磁盘（第五部分） http://www.linuxidc.com/Linux/2014-12/110532.htm&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;使用条块化I/O管理多个LVM磁盘（第五部分） http://www.linuxidc.com/Linux/2014-12/110532.htm&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;本文永久更新链接地址：http://www.linuxidc.com/Linux/2015-04/116238.htm&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;/nowiki&amp;gt;&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;本文永久更新链接地址：http://www.linuxidc.com/Linux/2015-04/116238.htm&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	<entry>
		<id>https://wiki.qiaochenglei.cn/index.php?title=MySQL%E5%9F%BA%E4%BA%8ELVM%E5%BF%AB%E7%85%A7%E7%9A%84%E5%A4%87%E4%BB%BD%E6%81%A2%E5%A4%8D&amp;diff=1462&amp;oldid=prev</id>
		<title>Admin：创建页面，内容为“ &lt;nowiki&gt;目录 1、数据库全备份 2、准备LVM卷 3、数据恢复到LVM卷 4、基于LVM快照备份数据 5、数据灾难恢复 6、总结  写在前面：...”</title>
		<link rel="alternate" type="text/html" href="https://wiki.qiaochenglei.cn/index.php?title=MySQL%E5%9F%BA%E4%BA%8ELVM%E5%BF%AB%E7%85%A7%E7%9A%84%E5%A4%87%E4%BB%BD%E6%81%A2%E5%A4%8D&amp;diff=1462&amp;oldid=prev"/>
				<updated>2016-09-20T13:34:49Z</updated>
		
		<summary type="html">&lt;p&gt;创建页面，内容为“ &amp;lt;nowiki&amp;gt;目录 1、数据库全备份 2、准备LVM卷 3、数据恢复到LVM卷 4、基于LVM快照备份数据 5、数据灾难恢复 6、总结  写在前面：...”&lt;/p&gt;
&lt;p&gt;&lt;b&gt;新页面&lt;/b&gt;&lt;/p&gt;&lt;div&gt; &amp;lt;nowiki&amp;gt;目录&lt;br /&gt;
1、数据库全备份&lt;br /&gt;
2、准备LVM卷&lt;br /&gt;
3、数据恢复到LVM卷&lt;br /&gt;
4、基于LVM快照备份数据&lt;br /&gt;
5、数据灾难恢复&lt;br /&gt;
6、总结&lt;br /&gt;
&lt;br /&gt;
写在前面：&lt;br /&gt;
测试环境中已安装有mysql 5.5.36数据库，但数据目录没有存放在LVM卷，此次要演示基于LVM的数据备份和恢复，所以就把mysql的数据先迁移到LVM上再做快照卷的备份。&lt;br /&gt;
如果innodb表基于LVM来做备份，那事务日志文件和数据文件要在同一个LVM的逻辑卷上，因为在同一时刻我们只能对一个逻辑卷做快照，如果事务日志与数据文件不在同一卷上，那做快照后会导致事务日志的事件与真正数据中提交的事务会不一致。&lt;br /&gt;
&lt;br /&gt;
1、数据库全备份&lt;br /&gt;
先把现有的数据利用mysqldum工具进行全备份：&lt;br /&gt;
[root@mariadb ~]# mysqldump -uroot -p123456 --lock-all-tables --flush-logs --events --routines --master-data=2 --all-databases &amp;gt; /backup/data_dir/fulldata-`date +%F` .sql &lt;br /&gt;
[root@mariadb ~]# ls /backup/data_dir/ &lt;br /&gt;
fulldata-2015-04-14.sql &lt;br /&gt;
[root@mariadb ~]# service mysqld stop  #停止mysql&lt;br /&gt;
&lt;br /&gt;
2、准备LVM卷&lt;br /&gt;
&lt;br /&gt;
事先准备好两个卷作为LVM的PV：&lt;br /&gt;
[root@mariadb ~]# fdisk -l &lt;br /&gt;
Disk /dev/sda: 53.7 GB, 53687091200 bytes &lt;br /&gt;
255 heads, 63 sectors/track, 6527 cylinders &lt;br /&gt;
Units = cylinders of 16065 * 512 = 8225280 bytes &lt;br /&gt;
Sector size (logical/physical): 512 bytes / 512 bytes &lt;br /&gt;
I/O size (minimum/optimal): 512 bytes / 512 bytes &lt;br /&gt;
Disk identifier: 0x000bf287 &lt;br /&gt;
  Device Boot      Start        End      Blocks  Id  System &lt;br /&gt;
/dev/sda1  *          1          13      102400  83  Linux &lt;br /&gt;
Partition 1 does not end on cylinder boundary. &lt;br /&gt;
/dev/sda2              13        1926    15360000  83  Linux &lt;br /&gt;
/dev/sda3            1926        2056    1048576  82  Linux swap / Solaris &lt;br /&gt;
/dev/sda4            2056        6527    35916127+  5  Extended &lt;br /&gt;
/dev/sda5            2056        2709    5248011  8e  Linux LVM &lt;br /&gt;
/dev/sda6            2710        3363    5253223+  8e  Linux LVM&lt;br /&gt;
&lt;br /&gt;
创建PV：&lt;br /&gt;
[root@mariadb ~]# pvcreate /dev/sda5 /dev/sda6 &lt;br /&gt;
  Physical volume &amp;quot;/dev/sda5&amp;quot; successfully created &lt;br /&gt;
  Physical volume &amp;quot;/dev/sda6&amp;quot; successfully created&lt;br /&gt;
&lt;br /&gt;
创建VG：&lt;br /&gt;
12 [root@mariadb ~]# vgcreate mygroup /dev/sda5 /dev/sda6 &lt;br /&gt;
  Volume group &amp;quot;mygroup&amp;quot; successfully created&lt;br /&gt;
&lt;br /&gt;
创建LV：&lt;br /&gt;
[root@mariadb ~]# lvcreate -n mysqldata --size 3G mygroup  #大小设置为3GB &lt;br /&gt;
  Logical volume &amp;quot;mysqldata&amp;quot; created&lt;br /&gt;
&lt;br /&gt;
格式化LV并挂载：&lt;br /&gt;
[root@mariadb ~]# lvdisplay #显示逻辑卷的详细信息 &lt;br /&gt;
[root@mariadb ~]# mke2fs -t ext4 /dev/mygroup/mysqldata #格式化 &lt;br /&gt;
[root@mariadb ~]# blkid /dev/mygroup/mysqldata #获取UUID &lt;br /&gt;
/dev/mygroup/mysqldata: UUID=&amp;quot;f863e626-e34e-4207-b9cb-7fbb9c5b7f1e&amp;quot; TYPE=&amp;quot;ext4&amp;quot;&lt;br /&gt;
[root@mariadb ~]# mkdir /mnt/mydata #创建挂载目录&lt;br /&gt;
&lt;br /&gt;
在/etc/fstab文件中加入下边一行：&lt;br /&gt;
[root@mariadb ~]# vim /etc/fstab &lt;br /&gt;
UUID=f863e626-e34e-4207-b9cb-7fbb9c5b7f1e /mnt/mydata  ext4  defaults 0 0 &lt;br /&gt;
[root@mariadb ~]# mount -a #重新挂载 &lt;br /&gt;
[root@mariadb ~]# mount &lt;br /&gt;
/dev/sda2 on / type ext4 (rw) &lt;br /&gt;
proc on /proc type proc (rw) &lt;br /&gt;
sysfs on /sys type sysfs (rw) &lt;br /&gt;
devpts on /dev/pts type devpts (rw,gid=5,mode=620) &lt;br /&gt;
tmpfs on /dev/shm type tmpfs (rw) &lt;br /&gt;
/dev/sda1 on /boot type ext4 (rw) &lt;br /&gt;
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw) &lt;br /&gt;
/dev/mapper/mygroup-mysqldata on /mnt/mydata type ext4 (rw)&lt;br /&gt;
&lt;br /&gt;
3、数据恢复到LVM卷&lt;br /&gt;
&lt;br /&gt;
创建数据目录及权限设置：&lt;br /&gt;
[root@mariadb ~]# mkdir /mnt/mydata/data &lt;br /&gt;
[root@mariadb ~]# chown -R mysql:mysql /mnt/mydata/data &lt;br /&gt;
[root@mariadb ~]# vim /etc/my.cnf  #修改数据目录位置 &lt;br /&gt;
datadir = /mnt/mydata/data&lt;br /&gt;
[root@mariadb ~]# cd /opt/lamp/mysql55/ #切换到mysql的安装目录&lt;br /&gt;
&lt;br /&gt;
初始化数据库:&lt;br /&gt;
&lt;br /&gt;
[root@mariadb mysql55]# scripts/mysql_install_db --user=mysql --datadir=/mnt/mydata/data&lt;br /&gt;
&lt;br /&gt;
修改datadir指向的目录:&lt;br /&gt;
&lt;br /&gt;
[root@mariadb mysql55]# vim /etc/rc.d/init.d/mysqld  &lt;br /&gt;
datadir=/mnt/mydata/data&lt;br /&gt;
&lt;br /&gt;
启动mysql，很奇怪，在我没有修改mysqld脚本文件中的datadir时也能正常启动:&lt;br /&gt;
&lt;br /&gt;
[root@mariadb mysql55]# service mysqld start&lt;br /&gt;
&lt;br /&gt;
接入mysql，修改接入密码导入备份数据：&lt;br /&gt;
mysql&amp;gt; SET PASSWORD FOR root@localhost=PASSWORD('123456'); &lt;br /&gt;
mysql&amp;gt; FLUSH PRIVILEGES; &lt;br /&gt;
mysql&amp;gt; source /backup/data_dir/fulldata-2015-04-14.sql &lt;br /&gt;
mysql&amp;gt; show databases;  #数据已恢复 &lt;br /&gt;
+--------------------+ &lt;br /&gt;
| Database          | &lt;br /&gt;
+--------------------+ &lt;br /&gt;
| information_schema | &lt;br /&gt;
| mydb1              | &lt;br /&gt;
| mydb2              | &lt;br /&gt;
| mysql              | &lt;br /&gt;
| performance_schema | &lt;br /&gt;
| test              | &lt;br /&gt;
+--------------------+&lt;br /&gt;
&lt;br /&gt;
4、备份数据库&lt;br /&gt;
4.1、准备备份目录&lt;br /&gt;
[root@mariadb mysql55]# mkdir -pv /backup/`date +%F`/{data,binlog}  &lt;br /&gt;
#以日期命令一个目录，在内还创建data和binlog目录，分别用来存放数据和二进制日志信息&lt;br /&gt;
&lt;br /&gt;
4.2、修改变量、请求全表读锁&lt;br /&gt;
mysql&amp;gt; SET GLOBAL sync_binlog=1; #设置此变量为1，让每个事件尽可能同步到二进制日志文件里，以消耗IO来尽可能确保数据一致性 &lt;br /&gt;
mysql&amp;gt; SHOW MASTER STATUS; #查看二进制日志和position，此信息保存在/backup/2015-04-14/binlog的binlog.txt里 &lt;br /&gt;
+------------------+----------+--------------+------------------+ &lt;br /&gt;
| File            | Position | Binlog_Do_DB | Binlog_Ignore_DB | &lt;br /&gt;
+------------------+----------+--------------+------------------+ &lt;br /&gt;
| mysql-bin.000016 |  1068076 |              |                  | &lt;br /&gt;
+------------------+----------+--------------+------------------+ &lt;br /&gt;
1 row in set (0.00 sec) &lt;br /&gt;
mysql&amp;gt; FLUSH LOGS; #刷新日志 &lt;br /&gt;
mysql&amp;gt; FLUSH TABLES WITH READ LOCK; #读锁请求到后不要关闭此mysql交互界面&lt;br /&gt;
&lt;br /&gt;
在innodb表中，即使是请求到了读锁，但InnoDB在后台依然可能会有事务在进行读写操作，可用&amp;quot;mysql&amp;gt; SHOW ENGINE INNODB STATUS;&amp;quot;查看后台进程的状态，等没有写请求后再做备份。&lt;br /&gt;
4.2、创建快照&lt;br /&gt;
以只读的方式创建一个1GB大小的快照卷data-snap：&lt;br /&gt;
[root@mariadb mysql55]# lvcreate --snapshot /dev/mygroup/mysqldata -n data-snap --size 1G --permission r&lt;br /&gt;
&lt;br /&gt;
查看快照卷的详情（快照卷也是LV）：&lt;br /&gt;
[root@mariadb mysql55]# lvdisplay&lt;br /&gt;
&lt;br /&gt;
4.3、解除锁定&lt;br /&gt;
回到锁定表的mysql交互式界面，解锁：&lt;br /&gt;
mysql&amp;gt; UNLOCK TABLES; &lt;br /&gt;
mysql&amp;gt; SET GLOBAL sync_binlog=0;  #此参数可以根据服务器磁盘IO的负载来调整&lt;br /&gt;
&lt;br /&gt;
4.4、挂载快照卷并备份数据&lt;br /&gt;
[root@mariadb ~]# mount /dev/mygroup/data-snap /tmp/  #挂载快照卷 &lt;br /&gt;
[root@mariadb ~]# ls /tmp/data/ &lt;br /&gt;
ibdata1  ib_logfile0  ib_logfile1  mariadb.pid  mydb1  mydb2  mysql  performance_schema  test&lt;br /&gt;
[root@mariadb mysql55]# cp -aR /tmp/data /backup/2015-04-14/data/  #备份数据 &lt;br /&gt;
[root@mariadb mysql55]# ls /backup/2015-04-14/data/data/ &lt;br /&gt;
ibdata1  ib_logfile0  ib_logfile1  mariadb.pid  mydb1  mydb2  mysql  performance_schema  test&lt;br /&gt;
&lt;br /&gt;
4.5、释放快照卷&lt;br /&gt;
&lt;br /&gt;
[root@mariadb ~]# umount /tmp/ &lt;br /&gt;
[root@mariadb ~]# lvremove /dev/mygroup/data-snap &lt;br /&gt;
Do you really want to remove active logical volume data-snap? [y/n]: y &lt;br /&gt;
  Logical volume &amp;quot;data-snap&amp;quot; successfully removed&lt;br /&gt;
&lt;br /&gt;
5、数据灾难恢复&lt;br /&gt;
&lt;br /&gt;
破坏数据，把数据目录下的所有文件都删除：&lt;br /&gt;
[root@mariadb mysql55]# rm -rf /mnt/mydata/data/* &lt;br /&gt;
[root@mariadb mysql55]# service mysqld stop  #PID文件也被删掉了，无法正常停止服务 &lt;br /&gt;
 ERROR! MySQL server PID file could not be found! &lt;br /&gt;
[root@mariadb mysql55]# killall mysqld&lt;br /&gt;
&lt;br /&gt;
把备份数据copy到数据目录：&lt;br /&gt;
[root@mariadb mysql55]# cp -Ra /backup/2015-04-14/data/data/* /mnt/mydata/data/ &lt;br /&gt;
[root@mariadb mysql55]# ll /mnt/mydata/data/  #确认各文件的权限是否为mysql &lt;br /&gt;
启动服务： &lt;br /&gt;
[root@mariadb mysql55]# service mysqld start &lt;br /&gt;
Starting MySQL SUCCESS!&lt;br /&gt;
&lt;br /&gt;
检查数据是否已恢复：&lt;br /&gt;
mysql&amp;gt; SHOW DATABASES; &lt;br /&gt;
+--------------------+ &lt;br /&gt;
| Database          | &lt;br /&gt;
+--------------------+ &lt;br /&gt;
| information_schema | &lt;br /&gt;
| mydb1              | &lt;br /&gt;
| mydb2              | &lt;br /&gt;
| mysql              | &lt;br /&gt;
| performance_schema | &lt;br /&gt;
| test              | &lt;br /&gt;
+--------------------+ &lt;br /&gt;
6 rows in set (0.00 sec) &lt;br /&gt;
mysql&amp;gt; SELECT * FROM mydb1.tb1; &lt;br /&gt;
+----+------+------+ &lt;br /&gt;
| id | name | age  | &lt;br /&gt;
+----+------+------+ &lt;br /&gt;
|  1 | tom  |  10 | &lt;br /&gt;
|  2 | jack |  20 | &lt;br /&gt;
|  3 | zcj  |  18 | &lt;br /&gt;
+----+------+------+&lt;br /&gt;
&lt;br /&gt;
6、总结&lt;br /&gt;
&lt;br /&gt;
基于LVM的数据备份方案几乎实现了热备，只是在请求读锁时会影响线上的业务，一旦当读锁请求到，创建快照几乎是瞬间完成，快照卷创建好后就可解除锁定，而备份就像复制或归档文件一样简单。数据恢复时只需要关闭mysql进程，把备份的数据复制到相应的数据目录，确保数据目录权限正确，启用服务即可，由于是直接复制的数据文件，所以索引不用重建。&lt;br /&gt;
&lt;br /&gt;
使用LVM创建弹性磁盘存储——第一部分  http://www.linuxidc.com/Linux/2014-10/107697.htm&lt;br /&gt;
在Linux中扩展/缩减LVM（第二部分）  http://www.linuxidc.com/Linux/2014-10/107786.htm&lt;br /&gt;
在 LVM中 录制逻辑卷快照并恢复（第三部分） http://www.linuxidc.com/Linux/2014-11/108867.htm&lt;br /&gt;
在LVM中设置精简资源调配卷（第四部分） http://www.linuxidc.com/Linux/2014-11/109757.htm&lt;br /&gt;
使用条块化I/O管理多个LVM磁盘（第五部分） http://www.linuxidc.com/Linux/2014-12/110532.htm&lt;br /&gt;
本文永久更新链接地址：http://www.linuxidc.com/Linux/2015-04/116238.htm&amp;lt;/nowiki&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	</feed>