原作者未知,这是从一份pdf里面摘录出来的。


MySQL  版本 5.6.14

公司有几台 MySQL 服务器的错误日志显示 , 有几个系统表不存在 .

innodb_table_stats

innodb_index_stats

slave_master_info

slave_relay_log_info

slave_worker_info

这是因为数据库初始化的时候 ,dba 可能删除过 ibdata1 文件

虽然重启之后 , 数据库会自动创建一个 ibdata1 文件 , 但是上述系统表也是 innodb 引擎 , 所以不能访问了 .

这虽然不会影响业务 , 但是使用 innobackupex 备份的时候 , 会写入错误日志 .

 

最后错误日志里 , 都是这种信息 . 影响日常检查。

 

解决的方法 .

1. 删除上述系统表

droptable mysql.innodb_index_stats;

droptable mysql.innodb_table_stats;

droptable mysql.slave_master_info;

droptable mysql.slave_relay_log_info;

droptable mysql.slave_worker_info;

 

 

2. cd mysqldatadir删除相关的.frm .ibd 文件

rm -rfinnodb_index_stats*

rm -rfinnodb_table_stats*

rm -rfslave_master_info*

rm -rfslave_relay_log_info*

rm -rfslave_worker_info*

 

 

3. 重新创建上述系统表

CREATETABLE `innodb_index_stats` (

`database_name`varchar(64) COLLATE utf8_bin NOT NULL,

`table_name`varchar(64) COLLATE utf8_bin NOT NULL,

`index_name`varchar(64) COLLATE utf8_bin NOT NULL,

`last_update`timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,

`stat_name`varchar(64) COLLATE utf8_bin NOT NULL,

`stat_value`bigint(20) unsigned NOT NULL,

`sample_size`bigint(20) unsigned DEFAULT NULL,

`stat_description`varchar(1024) COLLATE utf8_bin NOT NULL,

PRIMARYKEY (`database_name`,`table_name`,`index_name`,`stat_name`)

)ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin STATS_PERSISTENT=0;

 

 

CREATETABLE `innodb_table_stats` (

`database_name`varchar(64) COLLATE utf8_bin NOT NULL,

`table_name`varchar(64) COLLATE utf8_bin NOT NULL,

`last_update`timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,

`n_rows`bigint(20) unsigned NOT NULL,

`clustered_index_size`bigint(20) unsigned NOT NULL,

`sum_of_other_index_sizes`bigint(20) unsigned NOT NULL,

PRIMARYKEY (`database_name`,`table_name`)

)ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin STATS_PERSISTENT=0;

 

 

CREATETABLE `slave_master_info` (

`Number_of_lines`int(10) unsigned NOT NULL COMMENT 'Number of lines in the file.',

`Master_log_name`text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL COMMENT 'The name of themaster binary log currently being read from the master.',

`Master_log_pos`bigint(20) unsigned NOT NULL COMMENT 'The master log position of the last readevent.',

`Host`char(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '' COMMENT 'Thehost name of the master.',

`User_name`text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The user name used to connectto the master.',

`User_password`text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The password used to connectto the master.',

`Port`int(10) unsigned NOT NULL COMMENT 'The network port used to connect to themaster.',

`Connect_retry`int(10) unsigned NOT NULL COMMENT 'The period (in seconds) that the slave willwait before trying to reconnect to the master.',

`Enabled_ssl`tinyint(1) NOT NULL COMMENT 'Indicates whether the server supports SSLconnections.',

`Ssl_ca`text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The file used for theCertificate Authority (CA) certificate.',

`Ssl_capath`text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The path to the CertificateAuthority (CA) certificates.',

`Ssl_cert`text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The name of the SSLcertificate file.',

`Ssl_cipher`text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The name of the cipher in usefor the SSL connection.',

`Ssl_key`text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The name of the SSL keyfile.',

`Ssl_verify_server_cert`tinyint(1) NOT NULL COMMENT 'Whether to verify the server certificate.',

`Heartbeat`float NOT NULL,

`Bind`text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'Displays which interface isemployed when connecting to the MySQL server',

`Ignored_server_ids`text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The number of server IDs tobe ignored, followed by the actual server IDs',

`Uuid`text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The master server uuid.',

`Retry_count`bigint(20) unsigned NOT NULL COMMENT 'Number of reconnect attempts, to themaster, before giving up.',

`Ssl_crl`text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The file used for theCertificate Revocation List (CRL)',

`Ssl_crlpath`text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The path used for CertificateRevocation List (CRL) files',

`Enabled_auto_position`tinyint(1) NOT NULL COMMENT 'Indicates whether GTIDs will be used to retrieveevents from the master.',

PRIMARYKEY (`Host`,`Port`)

)ENGINE=InnoDB DEFAULT CHARSET=utf8 STATS_PERSISTENT=0 COMMENT='MasterInformation';

 

 

CREATETABLE `slave_relay_log_info` (

`Number_of_lines`int(10) unsigned NOT NULL COMMENT 'Number of lines in the file or rows in thetable. Used to version table definitions.',

`Relay_log_name`text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL COMMENT 'The name of thecurrent relay log file.',

`Relay_log_pos`bigint(20) unsigned NOT NULL COMMENT 'The relay log position of the lastexecuted event.',

`Master_log_name`text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL COMMENT 'The name of themaster binary log file from which the events in the relay log

file wereread.',

`Master_log_pos`bigint(20) unsigned NOT NULL COMMENT 'The master log position of the lastexecuted event.',

`Sql_delay`int(11) NOT NULL COMMENT 'The number of seconds that the slave must lag behindthe master.',

`Number_of_workers`int(10) unsigned NOT NULL,

`Id`int(10) unsigned NOT NULL COMMENT 'Internal Id that uniquely identifies thisrecord.',

PRIMARYKEY (`Id`)

)ENGINE=InnoDB DEFAULT CHARSET=utf8 STATS_PERSISTENT=0 COMMENT='Relay Log Information';

 

 

CREATETABLE `slave_worker_info` (

`Id`int(10) unsigned NOT NULL,

`Relay_log_name`text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,

`Relay_log_pos`bigint(20) unsigned NOT NULL,

`Master_log_name`text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,

`Master_log_pos`bigint(20) unsigned NOT NULL,

`Checkpoint_relay_log_name`text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,

`Checkpoint_relay_log_pos`bigint(20) unsigned NOT NULL,

`Checkpoint_master_log_name`text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,

`Checkpoint_master_log_pos`bigint(20) unsigned NOT NULL,

`Checkpoint_seqno`int(10) unsigned NOT NULL,

`Checkpoint_group_size`int(10) unsigned NOT NULL,

`Checkpoint_group_bitmap`blob NOT NULL,

PRIMARYKEY (`Id`)

)ENGINE=InnoDB DEFAULT CHARSET=utf8 STATS_PERSISTENT=0 COMMENT='WorkerInformation';

 

 

4. 如果是Slave 备机, 停止复制, 记录pos 等信息

> stop slave;

Query OK,0 rows affected (0.09 sec)

 

5. 重启数据库

 

6. 如果Slave 启动报错, 则使用步骤4 的信息, 重新change master

再删除 ibdata1 文件的时候 , 一定要想起系统数据库还有 5 innodb ...