解决数据库Operation not allowed when innodb_forced_recovery > 0
请修改my.cnf innodb_force_recovery = 1 修改为 innodb_force_recovery = 0
讯享网
在关闭时,参数innodb_fast_shutdown影响着表的存储引擎为InnoDB的行为。
讯享网该参数取值为0、1、2
测试: 环境:innodb_fast_shutdown = 2 innodb_flush_log_at_trx_commit = 2 sync_binlog = 0
innodb_force_recovery影响整个InnoDB存储引擎的恢复状况。默认为0,表示当需要恢复时执行所有的
恢复操作。当不能进行有效的恢复操作时,mysql有可能无法启动,并记录下错误日志。
innodb_force_recovery可以设置为1-6,大的数字包含前面所有数字的影响。
当设置参数值大于0后,可以对表进行select,create,drop操作,但insert,update或者delete这类操作
是不允许的。
1(SRV_FORCE_IGNORE_CORRUPT):忽略检查到的corrupt页。
2(SRV_FORCE_NO_BACKGROUND):阻止主线程的运行,如主线程需要执行full purge操作,会导致crash。
3(SRV_FORCE_NO_TRX_UNDO):不执行事务回滚操作。
4(SRV_FORCE_NO_IBUF_MERGE):不执行插入缓冲的合并操作。
5(SRV_FORCE_NO_UNDO_LOG_SCAN):不查看重做日志,InnoDB存储引擎会将未提交的事务视为已提交。
6(SRV_FORCE_NO_LOG_REDO):不执行前滚的操作。
讯享网测试一 破坏xbb5.ibd表 删除了数据页
innodb_force_recovery = 1-3 表不可用
报ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/tmp/mysqld.sock’ 错误
innodb_force_recovery = 4-6 select * 可用,select count(*) 不准缺
报ERROR 2013 (HY000): Lost connection to MySQL server during query错误
root@test 04:32:32>begin; Query OK, 0 rows affected (0.01 sec) root@test 04:33:14>update test set b = b+100; Query OK, 9999 rows affected (0.18 sec) Rows matched: 9999 Changed: 9999 Warnings: 0 innodb_force_recovery =0 要检查回滚操作
16:32:20 InnoDB: Database was not shut down normally!
InnoDB: Starting crash recovery.
InnoDB: Reading tablespace information from the .ibd files…
InnoDB: Restoring possible half-written data pages from the doublewrite
InnoDB: buffer…
InnoDB: 1 transaction(s) which must be rolled back or cleaned up
InnoDB: in total 9999 row operations to undo
InnoDB: Trx id counter is 0 12544
InnoDB: Last MySQL binlog file position 0 , file name /vobiledata/mysqllog/mysql-bin.000245
InnoDB: Starting in background the rollback of uncommitted transactions
16:32:21 InnoDB: Rolling back trx with id 0 12032, 9999 rows to undo
InnoDB: Progress in percents: 16:32:21 InnoDB: Started; log sequence number 0
16:32:21 [Note] Recovering after a crash using /vobiledata/mysqllog/mysql-bin
16:32:21 [Note] Starting crash recovery…
16:32:21 [Note] Crash recovery finished.
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 16:32:21 [Note] Event Scheduler: Loaded 0 events
16:32:21 [Note] /usr/local/mysql/bin/mysqld: ready for connections.
Version: ‘5.1.57-log’ socket: ‘/tmp/mysqld.sock’ port: 3306 MySQL Community Server (GPL)
98 99 100
InnoDB: Rolling back of trx id 0 12032 completed
16:32:21 InnoDB: Rollback of non-prepared transactions completed
InnoDB: Starting crash recovery.
InnoDB: Reading tablespace information from the .ibd files…
InnoDB: Restoring possible half-written data pages from the doublewrite
InnoDB: buffer…
InnoDB: 1 transaction(s) which must be rolled back or cleaned up
InnoDB: in total 9999 row operations to undo
InnoDB: Trx id counter is 0 15616
InnoDB: Last MySQL binlog file position 0 , file name /vobiledata/mysqllog/mysql-bin.000245
InnoDB: Starting in background the rollback of uncommitted transactions
17:05:53 InnoDB: Rolling back trx with id 0 15104, 9999 rows to undo
InnoDB: Progress in percents: 17:05:53 InnoDB: Started; log sequence number 0
InnoDB: !!! innodb_force_recovery is set to 2 !!!
17:05:53 [Note] Recovering after a crash using /vobiledata/mysqllog/mysql-bin
17:05:53 [Note] Starting crash recovery…
17:05:53 [Note] Crash recovery finished.
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 17:05:53 [Note] Event Scheduler: Loaded 0 events
17:05:53 [Note] /usr/local/mysql/bin/mysqld: ready for connections.
Version: ‘5.1.57-log’ socket: ‘/tmp/mysqld.sock’ port: 3306 MySQL Community Server (GPL)
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
InnoDB: Rolling back of trx id 0 15104 completed
17:05:53 InnoDB: Rollback of non-prepared transactions completed
innodb_force_recovery =3 不执行回滚操作
16:33:53 InnoDB: Database was not shut down normally!
InnoDB: Starting crash recovery.
InnoDB: Reading tablespace information from the .ibd files…
InnoDB: Restoring possible half-written data pages from the doublewrite
InnoDB: buffer…
InnoDB: 1 transaction(s) which must be rolled back or cleaned up
InnoDB: in total 9999 row operations to undo
InnoDB: Trx id counter is 0 13056
InnoDB: Last MySQL binlog file position 0 , file name /vobiledata/mysqllog/mysql-bin.000245
16:33:53 InnoDB: Started; log sequence number 0
InnoDB: !!! innodb_force_recovery is set to 3 !!!
16:33:53 [Note] Recovering after a crash using /vobiledata/mysqllog/mysql-bin
16:33:53 [Note] Starting crash recovery…
16:33:53 [Note] Crash recovery finished.
16:33:53 [Note] Event Scheduler: Loaded 0 events
16:33:53 [Note] /usr/local/mysql/bin/mysqld: ready for connections.
Version: ‘5.1.57-log’ socket: ‘/tmp/mysqld.sock’ port: 3306 MySQL Community Server (GPL)
±—±-----±-----±-----+
| a | b | c | d |
±—±-----±-----±-----+
| 1 | 101 | 1 | 1 |
| 2 | 102 | 2 | 2 |
| 3 | 103 | 3 | 3 |
| 4 | 104 | 4 | 4 |
| 5 | 105 | 5 | 5 |
| 6 | 106 | 6 | 6 |
| 7 | 107 | 7 | 7 |
| 8 | 108 | 8 | 8 |
| 9 | 109 | 9 | 9 |
| 10 | 110 | 10 | 10 |
±—±-----±-----±-----+
innodb_force_recovery =6 不执行前滚操作,但是恢复的时候有回滚操作
±—±-----±-----±-----+
| a | b | c | d |
±—±-----±-----±-----+
| 1 | 101 | 1 | 1 |
| 2 | 102 | 2 | 2 |
| 3 | 103 | 3 | 3 |
| 4 | 104 | 4 | 4 |
| 5 | 105 | 5 | 5 |
| 6 | 106 | 6 | 6 |
| 7 | 107 | 7 | 7 |
| 8 | 108 | 8 | 8 |
| 9 | 109 | 9 | 9 |
| 10 | 110 | 10 | 10 |
±—±-----±-----±-----+
16:44:29 InnoDB: Database was not shut down normally!
InnoDB: Starting crash recovery.
InnoDB: Reading tablespace information from the .ibd files…
InnoDB: Restoring possible half-written data pages from the doublewrite
InnoDB: buffer…
InnoDB: Doing recovery: scanned up to log sequence number 0
InnoDB: 1 transaction(s) which must be rolled back or cleaned up
InnoDB: in total 9999 row operations to undo
InnoDB: Trx id counter is 0 14080
InnoDB: Last MySQL binlog file position 0 , file name /vobiledata/mysqllog/mysql-bin.000245
InnoDB: Starting in background the rollback of uncommitted transactions
16:44:29 InnoDB: Rolling back trx with id 0 13057, 9999 rows to undo
InnoDB: Progress in percents: 16:44:29 InnoDB: Started; log sequence number 0
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 16:44:29 [Note] Event Scheduler: Loaded 0 events
16:44:29 [Note] /usr/local/mysql/bin/mysqld: ready for connections.
Version: ‘5.1.57-log’ socket: ‘/tmp/mysqld.sock’ port: 3306 MySQL Community Server (GPL)
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
InnoDB: Rolling back of trx id 0 13057 completed
16:44:29 InnoDB: Rollback of non-prepared transactions completed
16:45:08 mysqld_safe Starting mysqld daemon with databases from /vobiledata/mysqldata
16:45:08 [Note] Plugin ‘FEDERATED’ is disabled.
16:45:08 InnoDB: Initializing buffer pool, size = 2.0G
16:45:08 InnoDB: Completed initialization of buffer pool
InnoDB: The user has set SRV_FORCE_NO_LOG_REDO on
InnoDB: Skipping log redo
16:45:08 InnoDB: Started; log sequence number 0 0
InnoDB: !!! innodb_force_recovery is set to 6 !!!
16:45:08 [Note] Recovering after a crash using /vobiledata/mysqllog/mysql-bin
16:45:08 [Note] Starting crash recovery…
16:45:08 [Note] Crash recovery finished.
16:45:08 [Note] Event Scheduler: Loaded 0 events
16:45:08 [Note] /usr/local/mysql/bin/mysqld: ready for connections.
Version: ‘5.1.57-log’ socket: ‘/tmp/mysqld.sock’ port: 3306 MySQL Community Server (GPL)
16:45:14 InnoDB: error: space object of table test/test,
InnoDB: space id 3 did not exist in memory. Retrying an open.
-±-----±-----±-----+
| 1 | 101 | 1 | 1 |
| 2 | 102 | 2 | 2 |
| 3 | 103 | 3 | 3 |
| 4 | 104 | 4 | 4 |
| 5 | 105 | 5 | 5 |
| 6 | 106 | 6 | 6 |
| 7 | 107 | 7 | 7 |
| 8 | 108 | 8 | 8 |
| 9 | 109 | 9 | 9 |
| 10 | 110 | 10 | 10 |
±—±-----±-----±-----+
16:44:29 InnoDB: Database was not shut down normally!
InnoDB: Starting crash recovery.
InnoDB: Reading tablespace information from the .ibd files…
InnoDB: Restoring possible half-written data pages from the doublewrite
InnoDB: buffer…
InnoDB: Doing recovery: scanned up to log sequence number 0
InnoDB: 1 transaction(s) which must be rolled back or cleaned up
InnoDB: in total 9999 row operations to undo
InnoDB: Trx id counter is 0 14080
InnoDB: Last MySQL binlog file position 0 , file name /vobiledata/mysqllog/mysql-bin.000245
InnoDB: Starting in background the rollback of uncommitted transactions
16:44:29 InnoDB: Rolling back trx with id 0 13057, 9999 rows to undo
InnoDB: Progress in percents: 16:44:29 InnoDB: Started; log sequence number 0
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 16:44:29 [Note] Event Scheduler: Loaded 0 events
16:44:29 [Note] /usr/local/mysql/bin/mysqld: ready for connections.
Version: ‘5.1.57-log’ socket: ‘/tmp/mysqld.sock’ port: 3306 MySQL Community Server (GPL)
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
InnoDB: Rolling back of trx id 0 13057 completed
16:44:29 InnoDB: Rollback of non-prepared transactions completed
16:45:08 mysqld_safe Starting mysqld daemon with databases from /vobiledata/mysqldata
16:45:08 [Note] Plugin ‘FEDERATED’ is disabled.
16:45:08 InnoDB: Initializing buffer pool, size = 2.0G
16:45:08 InnoDB: Completed initialization of buffer pool
InnoDB: The user has set SRV_FORCE_NO_LOG_REDO on
InnoDB: Skipping log redo
16:45:08 InnoDB: Started; log sequence number 0 0
InnoDB: !!! innodb_force_recovery is set to 6 !!!
16:45:08 [Note] Recovering after a crash using /vobiledata/mysqllog/mysql-bin
16:45:08 [Note] Starting crash recovery…
16:45:08 [Note] Crash recovery finished.
16:45:08 [Note] Event Scheduler: Loaded 0 events
16:45:08 [Note] /usr/local/mysql/bin/mysqld: ready for connections.
Version: ‘5.1.57-log’ socket: ‘/tmp/mysqld.sock’ port: 3306 MySQL Community Server (GPL)
16:45:14 InnoDB: error: space object of table test/test,
InnoDB: space id 3 did not exist in memory. Retrying an open

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容,请联系我们,一经查实,本站将立刻删除。
如需转载请保留出处:https://51itzy.com/kjqy/65376.html