Schedule preventive maintenance of MYSQL database server [group chart] _ MySQL

Source: Internet
Author: User
To schedule preventive maintenance for the MYSQL database server [team chart], you should consider setting up a schedule for preventive maintenance to help automatically detect problems so that you can take measures to correct them:

1) perform regular database backup and allow log updates.

2) arrange regular table checks. Using the checklist will reduce the chances of using backup. This job uses a cron job (generally called from the crontab file of the account used by the running server) and is easy to implement. For example, if you run the server as a mysqladm user, you can create a regular check from the crontab file of mysqladm. If you do not know how to use c r o n, use the following command to view the relevant UNIX manual page:

% Man cron

% Man crontab

3) check the database table during system boot before the server starts. The machine may be restarted due to an early crash. If so, the database table may have been destroyed and should be checked.

To run an automatic table check, you can write a script to change the directory to the server data directory and run myisamchk and I s a m c h k on all database tables. We will use both programs in the script discussed below. If you only have a MyISAM table or an ISAM table, you only need one program to remove the unrelated program from the script.

Both myisamchk and isamchk generate some output results based on the table check method to understand which tables are being checked, even if there is no problem. For crontab items, unless there is an error in the table, output results are usually prohibited (if the job generates any output, the cron job usually generates a mail message, rarely receive emails for table check jobs without any problems ). If you use the -- silent option to call any utility, it generates output only when a problem is detected. In addition, myisamchk supports the -- fast option, which allows the program to skip any table that has not been modified since the last check.

Check a simple script for all tables in the server data directory as follows (DATADIR should be changed to the value corresponding to your system ):

A potential problem with this script is: if there are many tables, the wildcard mode '*/*. m y I 'or '*/*. I S m' may cause shell program explosion due to "too arg um e n t s (too many parameters)" error. Another alternative script is as follows (similarly, change DATADIR to the value corresponding to your system ):

No matter which form of script you choose, I assume that you are calling c h e c k _ mysql _ tables. make sure that this method is changed in time to make it executable, then you manually call it to verify that it works properly:

% Chmod + x check_mysql_tables

% Chmod_mysql_tables

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.