Estou tentando configurar a replicação do mysql fazendo o instantâneo lvm do datadir principal e copiando-o para o escravo.
O procedimento é bastante simples, no servidor master eu executo "FLUSH TABLES WITH READ LOCK" e no segundo terminal fazendo o instantâneo lvm com lvcreate -l40%FREE -s -n mysql-backup /dev/MySQL/mysql
, depois das tabelas de desbloqueio.
Em seguida, montei o snapshot e copiei o datadir para o slave, mas o mysql não está conseguindo iniciar com os erros:
150105 12:50:53 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql 150105 12:50:53 [Warning] Changed limits: max_open_files: 1024 max_connections: 100 table_cache: 457 150105 12:50:54 InnoDB: The InnoDB memory heap is disabled 150105 12:50:54 InnoDB: Mutexes and rw_locks use GCC atomic builtins 150105 12:50:54 InnoDB: Compressed tables use zlib 1.2.7 150105 12:50:54 InnoDB: Using Linux native AIO 150105 12:50:54 InnoDB: Initializing buffer pool, size = 3.9G 150105 12:50:54 InnoDB: Completed initialization of buffer pool 150105 12:50:54 InnoDB: highest supported file format is Barracuda. InnoDB: Log scan progressed past the checkpoint lsn 29552065932592 150105 12:50:54 InnoDB: Database was not shut down normally! InnoDB: Starting crash recovery. InnoDB: Reading tablespace information from the .ibd files... InnoDB: Error: trying to add tablespace 210146 of name './somedatabase/CRM_printers.ibd' InnoDB: to the tablespace memory cache, but tablespace InnoDB: 210146 of name './somedatabase/status.ibd' already exists in the tablespace InnoDB: memory cache! 150105 12:50:55 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
Eu verifiquei e os arquivos dessas tabelas existem. Então, a seguir eu iniciei o banco de dados com innodb_force_recovery = 1 e o mysql depois disso começou com muitos erros como este:
InnoDB: Starting crash recovery. InnoDB: Reading tablespace information from the .ibd files... InnoDB: Error: trying to add tablespace 210146 of name './db/k.ibd' InnoDB: to the tablespace memory cache, but tablespace InnoDB: 210146 of name './db/y.ibd' already exists in the tablespace InnoDB: memory cache! InnoDB: innodb_force_recovery was set to 1. Continuing crash recovery InnoDB: even though the tablespace creation of this table failed. InnoDB: Error: trying to add tablespace 210235 of name './db/a.ibd' InnoDB: to the tablespace memory cache, but tablespace InnoDB: 210235 of name './db/ty.ibd' already exists in the tablespace InnoDB: memory cache! InnoDB: innodb_force_recovery was set to 1. Continuing crash recovery InnoDB: even though the tablespace creation of this table failed. InnoDB: Error: trying to add tablespace 210285 of name './db/PC.ibd' InnoDB: to the tablespace memory cache, but tablespace InnoDB: 210285 of name './portal/HR.ibd' already exists in the tablespace InnoDB: memory cache!
Agora estou executando mysqlcheck -A neste banco de dados, e há uma saída que algumas tabelas não existem, mas os arquivos frm e idb existem.
Qual é o problema, isso é algo errado com o meu instantâneo?