Chengdu MySQL Server disk space cleanup
2.7.1 Project Name
Chengdu Project
2.7.2 Problem Description
Disk space 90%
2.7.3 Impact Range
Planned downtime
Analysis of 2.7.4 problems
Database disk space is full, view is log file causes
2.7.5 Solutions
First, the operation steps:
1. Close Map Service
2. Backing Up the database
Mysqldump-uroot–pxxxx--quick--routines--add-drop-database--all-databases--add-drop-table >/bak/mysqldump.sql
3. Turn off the standby service side Heartbeat
1) Service Heartbeat stop
2) CAT/PROC/DRBD, make sure the status is as follows:
0:cs:connected ro:secondary/primary ds:uptodate/uptodate C r----
4. Close the main server side heartbeat
1) Service Heartbeat stop
2) CAT/PROC/DRBD, make sure the status is as follows:
0:cs:connected ro:primary/secondary ds:uptodate/uptodate C r----
5. Back up the main server MySQL database file
In order to prevent clean-up failure, easy fallback, in the use of mysqldump to export all user databases, but also the/drbddata/mysql directory and the following files back to the same time, to confirm the cleanup is not a problem before deleting
Log in to the main MySQL server
SSH [email protected]
Turn off MySQL service
Service MySQL Stop
Go to the DRBD directory
cd/drbddata/
Back up the Drbddata directory to the backup server
scp-r MySQL [email protected]:/backup
Compare the number and size of source and destination folder files
6. Delete all files and directories in the main server drbddata/mysql except the MySQL directory
Rm-f ibdata1
Rm-f ib_logfile*
Rm–f global/* (delete files in the corresponding database directory, if you have multiple databases, delete files from other database directories)
7. Modifying the main server my.cnf configuration file add innodb_file_per_table option
Vi/etc/my.cnf
Add innodb_file_per_table after [mysqld]
Innodb_file_per_table=1
8. Modifying the standby server my.cnf configuration file add innodb_file_per_table option
Vi/etc/my.cnf
Add innodb_file_per_table after [mysqld]
Innodb_file_per_table=1
9. Turn on the master server MySQL service
Service MySQL Start
10. Turn on the main service side Heartbeat
1) Service Heartbeat start
2) CAT/PROC/DRBD, make sure the status is as follows:
0:cs:connected ro:primary/secondary ds:uptodate/uptodate C r----
11. Open Standby server Heartbeat
1) Service Heartbeat start
2) CAT/PROC/DRBD, make sure the status is as follows:
0:cs:connected ro:secondary/primary ds:uptodate/uptodate C r----
12. Recovering a Database
Restore recovery using a dump file backed up by mysqldump
A.source/bak/mysqldump.sql
Or
B.mysql–uroot–p </bak/mysqldump.sql
13. Check if disk usage is down
14. Verify that the data is correct and that the database error log has a log of errors.
15. Open Map Service
Second, cleanup failure fallback operation:
1. Turn off the standby service side Heartbeat
1) Service Heartbeat stop
2) CAT/PROC/DRBD, make sure the status is as follows:
0:cs:connected ro:secondary/primary ds:uptodate/uptodate C r----
2. Close the main server side heartbeat
1) Service Heartbeat stop
2) CAT/PROC/DRBD, make sure the status is as follows:
0:cs:connected ro:primary/secondary ds:uptodate/uptodate C r----
3. Restore/drbddata/mysql Original file
4. Turn on the main service side Heartbeat
1) Service Heartbeat start
2) CAT/PROC/DRBD, make sure the status is as follows:
0:cs:connected ro:primary/secondary ds:uptodate/uptodate C r----
5. Open Standby server Heartbeat
1) Service Heartbeat start
2) CAT/PROC/DRBD, make sure the status is as follows:
0:cs:connected ro:secondary/primary ds:uptodate/uptodate C r----
6. Open Map Service
MYSQL ibdata1 Space Full processing