签到成功

知道了

CNDBA社区CNDBA社区

Mysql myisam_recover_options参数

2021-11-27 11:35 1025 0 原创 mysql
作者: hbhe0316

关于myisam_recover_options参数:
https://dev.mysql.com/doc/refman/8.0/en/myisam-start.htmlhttp://www.cndba.cn/hbhe0316/article/22614

设置MyISAM存储引擎的恢复模式。变量值是OFF、DEFAULT、BACKUP、FORCE或QUICK值的任意组合。如果指定多个值,则用逗号分隔。在服务器启动时指定不带值的变量与指定DEFAULT相同,并且指定显式值“”禁用恢复(与值OFF相同)。如果启用了恢复,那么每次mysqld打开MyISAM表时,它会检查表是否被标记为崩溃或没有被正确关闭。(最后一个选项只在禁用外部锁定的情况下运行。)如果是这种情况,mysqld会对表进行检查。如果表被损坏,mysqld尝试修复它。http://www.cndba.cn/hbhe0316/article/22614

Automatic recovery is activated if you start mysqld with the myisam_recover_options system variable set. In this case, when the server opens a MyISAM table, it checks whether the table is marked as crashed or whether the open count variable for the table is not 0 and you are running the server with external locking disabled. If either of these conditions is true, the following happens:http://www.cndba.cn/hbhe0316/article/22614http://www.cndba.cn/hbhe0316/article/22614

The server checks the table for errors.

If the server finds an error, it tries to do a fast table repair (with sorting and without re-creating the data file).

If the repair fails because of an error in the data file (for example, a duplicate-key error), the server tries again, this time re-creating the data file.http://www.cndba.cn/hbhe0316/article/22614

If the repair still fails, the server tries once more with the old repair option method (write row by row without sorting). This method should be able to repair any type of error and has low disk space requirements.http://www.cndba.cn/hbhe0316/article/22614

If the recovery wouldn’t be able to recover all rows from previously completed statements and you didn’t specify FORCE in the value of the myisam_recover_options system variable, automatic repair aborts with an error message in the error log:

Error: Couldn't repair table: test.g00pages

If you specify FORCE, a warning like this is written instead:

http://www.cndba.cn/hbhe0316/article/22614

Warning: Found 344 of 354 rows when repairing ./test/g00pages

If the automatic recovery value includes BACKUP, the recovery process creates files with names of the form tbl_name-datetime.BAK. You should have a cron script that automatically moves these files from the database directories to backup media.

http://www.cndba.cn/hbhe0316/article/22614

1.修改/etc/mysql.cnf文件http://www.cndba.cn/hbhe0316/article/22614http://www.cndba.cn/hbhe0316/article/22614

[root@mysql57 ~]# cat /etc/my.cnf | grep -i myisam_recover_options
myisam_recover_options = FORCE,BACKUP
[root@mysql57 ~]# service mysqld restart
Shutting down MySQL... SUCCESS! 
Starting MySQL. SUCCESS!

2.查看是否设置生效

mysql> SHOW VARIABLES LIKE 'myisam_recover_options';
+------------------------+--------------+
| Variable_name          | Value        |
+------------------------+--------------+
| myisam_recover_options | BACKUP,FORCE |
+------------------------+--------------+
1 row in set (0.00 sec)

版权声明:本文为博主原创文章,未经博主允许不得转载。

MYSQL

用户评论
* 以下用户言论只代表其个人观点,不代表CNDBA社区的观点或立场
hbhe0316

hbhe0316

关注

1.只有承认无知,才能装下新的东西; 2.进步来自一点点滴滴的积累; 3.广博让你更优秀,而专业让你无法替代; 4.挫折和失败能够转换为一种财富。

  • 889
    原创
  • 1
    翻译
  • 13
    转载
  • 24
    评论
  • 访问:1173367次
  • 积分:1523
  • 等级:核心会员
  • 排名:第6名
精华文章
    最新问题
    查看更多+
    热门文章
      热门用户
      推荐用户
        Copyright © 2016 All Rights Reserved. Powered by CNDBA · 皖ICP备2022006297号-1·

        QQ交流群

        注册联系QQ