<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Control WebPanel Wiki &#187; InnoDB Recovery</title>
	<atom:link href="https://wiki.centos-webpanel.com/tag/innodb-recovery/feed" rel="self" type="application/rss+xml" />
	<link>https://wiki.centos-webpanel.com</link>
	<description>CentOS WebPanel Wiki</description>
	<lastBuildDate>Wed, 12 Feb 2025 20:38:16 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=4.1.1</generator>
	<item>
		<title>MySQL: Recover Crashed innodb tables</title>
		<link>https://wiki.centos-webpanel.com/mysql-recover-crashed-innodb-tables</link>
		<comments>https://wiki.centos-webpanel.com/mysql-recover-crashed-innodb-tables#comments</comments>
		<pubDate>Wed, 12 Feb 2025 20:22:12 +0000</pubDate>
		<dc:creator><![CDATA[publisher]]></dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[InnoDB Recovery]]></category>

		<guid isPermaLink="false">http://wiki.centos-webpanel.com/?p=1865</guid>
		<description><![CDATA[How Innodb crash can happen ? - Innodb table can crash if there is power lose for your dedicated server. - Force shutdown of MySQL service can end up in Innodb crash. - Space issue on the serve can case Innodb crash, if the server space is 100% filled and mysql not able to write [&#8230;]]]></description>
				<content:encoded><![CDATA[<p><strong>How Innodb crash can happen ?</strong></p>
<p>- Innodb table can crash if there is power lose for your dedicated server.<br />
- Force shutdown of MySQL service can end up in Innodb crash.<br />
- Space issue on the serve can case Innodb crash, if the server space is 100% filled and mysql not able to write on the disk.<br />
- High load on the server can cause Innodb crash.<br />
- High I/O wait on the disk can also cause MySQL innodb crash.</p>
<p><strong>How to determine if innodb is crashed.?</strong><br />
You can determine this by checking MySQL logs, On most of the servers location of the Log is /var/lib/mysql/HOSTNAME.err<br />
You can also use commands:</p>
<pre>systemctl status mariadb.service
journalctl -xe</pre>
<p><strong>Full MySQL backup</strong><br />
Backup MySQL users and permissions</p>
<pre>pt-show-grants > /root/pt-show-grants.sql</pre>
<p>Backup Full MySQL folder, Make sure MySQL is <strong>STOPPED</strong> for this step</p>
<pre>rsync -a /var/lib/mysql /home/mysql_bkp/ </pre>
<p><strong>Instructions for full mysql reinstall and recovery</strong><br />
If you can't start mysql, you can try by adding the following code in file /etc/my.cnf.d/server.cnf under <strong>[galera]</strong> settings</p>
<pre>innodb_force_recovery = 1</pre>
<p><strong>Now try to start/restart MariaDB</strong></p>
<pre>systemctl restart mariadb.service</pre>
<p>* If started successfully then you can start with backup, please note that MySQL is now in read-only  mode.<br />
* If not starting then try increasing recovery number for one number in each test</p>
<pre>innodb_force_recovery = 2</pre>
<pre>innodb_force_recovery = 3</pre>
<pre>innodb_force_recovery = 4</pre>
<pre>innodb_force_recovery = 5</pre>
<pre>innodb_force_recovery = 6</pre>
<p>When the MySQL is started in recovery mode we need to take backup of all the crashed databases and restore it</p>
<p><strong>Create backup location folders</strong></p>
<pre>mkdir /home/mysql_innodb_recovery
mkdir /home/mysql_innodb_recovery/database_backup
</pre>
<p><strong>Create the list of databases</strong></p>
<pre>mysql -e 'show databases;' | grep -v information_schema | grep -v Database  > /home/mysql_innodb_recovery/database_list.txt</pre>
<p>* Please confirm that all databases are listed in the file /home/mysql_innodb_recovery/database_list.txt</p>
<p><strong>Make backup of each databases including the database called mysql which is very important. </strong></p>
<pre>for db in `cat /home/mysql_innodb_recovery/database_list.txt`; do mysqldump $db > /home/mysql_innodb_recovery/database_backup/$db.sql;done</pre>
<p>* this process can take a lot of time depending on your MySQL disk usage.<br />
* Make sure you confirm that all <strong>.sql</strong> files in folder <strong>/home/mysql_innodb_recovery/database_backup/</strong> are not empty.</p>
<p><strong>Drop current databases</strong> (We can remove them if the backup was successful)</p>
<pre>for db in `cat /home/mysql_innodb_recovery/database_list.txt`; do mysqladmin drop $db;done</pre>
<p>Some database won’t get dropped which can be directly removed using the rm -Rf command</p>
<pre>rm -Rf /var/lib/mysql/DATABASENAME</pre>
<p>Next is to remove ibdata and ib_log files</p>
<pre>rm -f ibdata* ib_logfile*</pre>
<p><strong>Restarting MariaDB</strong><br />
Remove recovery line <strong>innodb_force_recovery</strong> from <strong>/etc/my.cnf.d/server.cnf</strong> and restart MariaDB</p>
<pre>systemctl restart mariadb.service</pre>
<p><strong>Creating Databases</strong><br />
If the MySQL now works we can start restoring databases, first create databases</p>
<pre>for db in `cat /home/mysql_innodb_recovery/database_list.txt`; do mysqladmin create $db;done</pre>
<p><strong>Restoring Databases</strong><br />
Now we will restore the backups we have taken.</p>
<pre>for db in `cat /home/mysql_innodb_recovery/database_list.txt`; do mysqldump $db < /home/mysql_innodb_recovery/database_backup/$db.sql;done</pre>
<p>* This process will take some time, after it is done confirm that there are no any issues in the MySQL logs.</p>
<p>In case of some issues you still have the exact replica of databases in folder /home/mysql_bkp/<br />
MySQL users and permissions are stored in file /root/pt-show-grants.sql<br />
Individual databases backups are stored in .sql files in folder /home/mysql_innodb_recovery/database_backup/</p>
<p>* We suggest to keep all those files few days after the successful restore.</p>
]]></content:encoded>
			<wfw:commentRss>https://wiki.centos-webpanel.com/mysql-recover-crashed-innodb-tables/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
