Rechercher dans le manuel MySQL
15.20.2 Forcing InnoDB Recovery
To investigate database page corruption, you might dump your
tables from the database with
SELECT ... INTO
OUTFILE
. Usually, most of the data obtained in this way
is intact. Serious corruption might cause SELECT * FROM
statements or
tbl_name
InnoDB
background operations to crash or
assert, or even cause InnoDB
roll-forward
recovery to crash. In such cases, you can use the
innodb_force_recovery
option to
force the InnoDB
storage engine to start up
while preventing background operations from running, so that you
can dump your tables. For example, you can add the following line
to the [mysqld]
section of your option file
before restarting the server:
[mysqld]
innodb_force_recovery = 1
For information about using option files, see Section 4.2.2.2, “Using Option Files”.
Only set innodb_force_recovery
to a value greater than 0 in an emergency situation, so that you
can start InnoDB
and dump your tables. Before
doing so, ensure that you have a backup copy of your database in
case you need to recreate it. Values of 4 or greater can
permanently corrupt data files. Only use an
innodb_force_recovery
setting
of 4 or greater on a production server instance after you have
successfully tested the setting on a separate physical copy of
your database. When forcing InnoDB
recovery,
you should always start with
innodb_force_recovery=1
and
only increase the value incrementally, as necessary.
innodb_force_recovery
is 0 by
default (normal startup without forced recovery). The permissible
nonzero values for
innodb_force_recovery
are 1 to 6.
A larger value includes the functionality of lesser values. For
example, a value of 3 includes all of the functionality of values
1 and 2.
If you are able to dump your tables with an
innodb_force_recovery
value of 3
or less, then you are relatively safe that only some data on
corrupt individual pages is lost. A value of 4 or greater is
considered dangerous because data files can be permanently
corrupted. A value of 6 is considered drastic because database
pages are left in an obsolete state, which in turn may introduce
more corruption into B-trees
and other database structures.
As a safety measure, InnoDB
prevents
INSERT
,
UPDATE
, or
DELETE
operations when
innodb_force_recovery
is greater
than 0. An innodb_force_recovery
setting of 4 or greater places InnoDB
in
read-only mode.
1
(SRV_FORCE_IGNORE_CORRUPT
)Lets the server run even if it detects a corrupt page. Tries to make
SELECT * FROM
jump over corrupt index records and pages, which helps in dumping tables.tbl_name
2
(SRV_FORCE_NO_BACKGROUND
)Prevents the master thread and any purge threads from running. If a crash would occur during the purge operation, this recovery value prevents it.
3
(SRV_FORCE_NO_TRX_UNDO
)Does not run transaction rollbacks after crash recovery.
4
(SRV_FORCE_NO_IBUF_MERGE
)Prevents insert buffer merge operations. If they would cause a crash, does not do them. Does not calculate table statistics. This value can permanently corrupt data files. After using this value, be prepared to drop and recreate all secondary indexes. Sets
InnoDB
to read-only.5
(SRV_FORCE_NO_UNDO_LOG_SCAN
)Does not look at undo logs when starting the database:
InnoDB
treats even incomplete transactions as committed. This value can permanently corrupt data files. SetsInnoDB
to read-only.6
(SRV_FORCE_NO_LOG_REDO
)Does not do the redo log roll-forward in connection with recovery. This value can permanently corrupt data files. Leaves database pages in an obsolete state, which in turn may introduce more corruption into B-trees and other database structures. Sets
InnoDB
to read-only.
You can SELECT
from tables to dump
them. With an
innodb_force_recovery
value of 3
or less you can DROP
or
CREATE
tables. DROP
TABLE
is also supported with an
innodb_force_recovery
value
greater than 3. DROP TABLE
is not
permitted with an
innodb_force_recovery
value
greater than 4.
If you know that a given table is causing a crash on rollback, you
can drop it. If you encounter a runaway rollback caused by a
failing mass import or ALTER TABLE
,
you can kill the mysqld process and set
innodb_force_recovery
to
3
to bring the database up without the
rollback, and then DROP
the table that is
causing the runaway rollback.
If corruption within the table data prevents you from dumping the
entire table contents, a query with an ORDER BY
clause might
be able to dump the portion of the table after the corrupted part.
primary_key
DESC
If a high innodb_force_recovery
value is required to start InnoDB
, there may be
corrupted data structures that could cause complex queries
(queries containing WHERE
, ORDER
BY
, or other clauses) to fail. In this case, you may
only be able to run basic SELECT * FROM t
queries.
Nederlandse vertaling
U hebt gevraagd om deze site in het Nederlands te bezoeken. Voor nu wordt alleen de interface vertaald, maar nog niet alle inhoud.Als je me wilt helpen met vertalingen, is je bijdrage welkom. Het enige dat u hoeft te doen, is u op de site registreren en mij een bericht sturen waarin u wordt gevraagd om u toe te voegen aan de groep vertalers, zodat u de gewenste pagina's kunt vertalen. Een link onderaan elke vertaalde pagina geeft aan dat u de vertaler bent en heeft een link naar uw profiel.
Bij voorbaat dank.
Document heeft de 26/06/2006 gemaakt, de laatste keer de 26/10/2018 gewijzigd
Bron van het afgedrukte document:https://www.gaudry.be/nl/mysql-rf-forcing-innodb-recovery.html
De infobrol is een persoonlijke site waarvan de inhoud uitsluitend mijn verantwoordelijkheid is. De tekst is beschikbaar onder CreativeCommons-licentie (BY-NC-SA). Meer info op de gebruiksvoorwaarden en de auteur.
Referenties
Deze verwijzingen en links verwijzen naar documenten die geraadpleegd zijn tijdens het schrijven van deze pagina, of die aanvullende informatie kunnen geven, maar de auteurs van deze bronnen kunnen niet verantwoordelijk worden gehouden voor de inhoud van deze pagina.
De auteur Deze site is als enige verantwoordelijk voor de manier waarop de verschillende concepten, en de vrijheden die met de referentiewerken worden genomen, hier worden gepresenteerd. Vergeet niet dat u meerdere broninformatie moet doorgeven om het risico op fouten te verkleinen.