The disk is full, the service is abnormal and MySQL reports "Table ** is marked as crashed and should be repaired" problem solved

Today, the small station has been attacked. Simply sort out the solutions so that friends who encounter the same problem can quickly locate the problem and solve it.

The service cannot respond normally

The website is self-developed, just for fun, there are not too many functions and access restrictions, just a single page and download function. It is estimated that some friends are so idle and want to challenge other people's technology (congratulations, you won this time), there is always someone who is fine to brush traffic and visit, the server is Alibaba Cloud, and the disk storage is relatively small. Only 40GB.

Through the server-side access error, you can see that it is a server-side abnormality. First, I plan to restart tomcat. When I start it again, it is stuck directly. Then I use the password df -h to check the disk space, which is full.

[[email protected] logs]# df -hFilesystem      Size  Used Avail Use% Mounted on/dev/vda1        40G   39G  183M 100% /devtmpfs        1.9G     0  1.9G   0% /devtmpfs           1.9G     0  1.9G   0% /dev/shmtmpfs           1.9G  476K  1.9G   1% /runtmpfs           1.9G     0  1.9G   0% /sys/fs/cgrouptmpfs           379M     0  379M   0% /run/user/0

Quickly delete some installation packages and software on the server, try to release some resources, let the service start normally, after deleting some installation packages, check again, it is still 100% used, the resources are not released, I thought it was the resource caused by the number of handles Occupied did not release in time, reboot, restarted the Alibaba Cloud server. Checking it again, it was still the same, and I realized that the problem was not as simple as I thought.

Full disk

Look is to view the disk file size:

du -lh --max-depth=1 /

It is found that the disk under the usr folder occupies a lot (mainly the personal path)

Continue to check the file size under /usr,

du -lh --max-depth=1 /usr/


Until the file in the largest folder was finally located, I finally located the log under tomcat.

[[email protected] usr]# du -lh --max-depth=1 /usr/local/tomcat/logs/33G	/usr/local/tomcat/logs/

Get rid of those log files decisively. The space is also briefly released.

The database is down

After the resource is released, restart the service. This time the server started normally, but during the database connection, an error was reported, indicating that the table is abnormal and needs to be repaired.

表需要修复: Table ** is marked as crashed and should be repaired; nested exception is java.sql.SQLException

ok, enter Mysql. Directly manipulate the data sheet.

# mysql -uroot -p
mysql> show databases;+--------------------+| Database           |+--------------------+| information_schema || idea_db            || mysql              || performance_schema || sys                |+--------------------+5 rows in set (0.00 sec)
mysql> use idea_db;Database changed mysql> check table post_basic;+--------------------+-------+----------+-----------------------------------------------------------+| Table              | Op    | Msg_type | Msg_text                                                  |+--------------------+-------+----------+-----------------------------------------------------------+| idea_db.post_basic | check | warning  | Table is marked as crashed                                || idea_db.post_basic | check | error    | Size of datafile is: 75198464         Should be: 75198476 || idea_db.post_basic | check | error    | Corrupt                                                   |+--------------------+-------+----------+-----------------------------------------------------------+3 rows in set (0.01 sec)

Switch the database and find the abnormal table. Execute repair table table name and repair the table.

mysql> repair table post_basic; +--------------------+--------+----------+-------------------------------------------------------+| Table              | Op     | Msg_type | Msg_text                                              |+--------------------+--------+----------+-------------------------------------------------------+| idea_db.post_basic | repair | info     | Found block that points outside data file at 75198436 || idea_db.post_basic | repair | status   | OK                                                    |+--------------------+--------+----------+-------------------------------------------------------+2 rows in set (9.34 sec)  mysql> check table post_basic;+--------------------+-------+----------+----------+| Table              | Op    | Msg_type | Msg_text |+--------------------+-------+----------+----------+| idea_db.post_basic | check | status   | OK       |+--------------------+-------+----------+----------+1 row in set (0.62 sec)

At this point, the data table repair is complete, restart the service, and restart the database. Visit the small station and return to normal.

Later, some security treatments will be done on the website.