[DB_NAME]: DB-name to recovery.
/dev/shm Usage: First, check your memory if you can use shm directory.
For recovery speed, I use /dev/shm/ directory.
Process flow.
01. Stop DB
service mysqld stop
02. Stop web-service. (If you don't use, block DB-connection by using firewall-cmd.)
service httpd stop
03. Change DB-mode on server.cnf
set innodb_force_recovery = 5 on /etc/my.cnf.d/server.cnf
04. Start DB for recovery.
service mysqld start
05. Run DB-dump.
mysqldump -u root -p --databases [DB_NAME] > /dev/shm/[DB_NAME].sql
06. Stop DB
service mysqld stop
07. Change DB-mode on server.cnf (normal mode)
set innodb_force_recovery = 0 on /etc/my.cnf.d/server.cnf
08. Backup old DB-files. (Run follows if you necessarily need backup.)
mkdir /backup/DB_BackupTmp
mv /backup/DB/ibdata1 /backup/DB_BackupTmp
mv /backup/DB/ib_logfile0 /backup/DB_BackupTmp
mv /backup/DB/ib_logfile1 /backup/DB_BackupTmp
mv /backup/DB/[DB_NAME] /backup/DB_BackupTmp
09. Start DB
service mysqld start
10. Create Database: [DB_NAME]
mysql -u root -p
CREATE DATABASE [DB_NAME];
11. Recover DB-dump
mysql -uroot -p [DB_NAME] < /dev/shm/[DB_NAME].sql
12. Start web-service. (If you don't use, change DB-connection for allow by using firewall-cmd.)
service httpd start
-End-
Comments
Post a Comment