MySQL – 但行好事 莫问前程 http://www.jydba.net Tue, 08 Oct 2024 07:22:55 +0000 zh-CN hourly 1 https://wordpress.org/?v=4.9.10 MySQL 5.7 禁用GTID联机事务 http://www.jydba.net/index.php/archives/3592 http://www.jydba.net/index.php/archives/3592#respond Tue, 08 Oct 2024 07:22:55 +0000 http://www.jydba.net/?p=3592 在线禁用GTID事务
如何在已经在线的服务器上禁用GTID事务。此过程不需要使服务器离线,适合在生产环境中使用。但是,如果您有可能在禁用GTIDs模式时 使服务器离线,那么这个过程会更容易。

该过程类似于在服务器在线时启用GTID事务,但步骤相反。唯一不同的是等待已记录事务复制的时间点。

在开始之前,请确保服务器满足以下前提条件:
.拓扑中的所有服务器必须使用MySQL 5.7.6或更高版本。您不能在任何一台服务器上在线禁用GTID事务,除非拓扑中的所有服务器都使用此版本 。

.所有服务器都将gtid_mode设置为ON。

1.在每个从服务器上执行以下命令,如果您使用多源复制,请为每个通道执行此操作,并包含for channel channel子句:

STOP SLAVE [FOR CHANNEL 'channel'];
CHANGE MASTER TO MASTER_AUTO_POSITION = 0, MASTER_LOG_FILE = file,MASTER_LOG_POS = position [FOR CHANNEL 'channel'];
START SLAVE [FOR CHANNEL 'channel'];


mysql> stop slave for channel 'master-1';
Query OK, 0 rows affected, 1 warning (0.01 sec)

mysql> stop slave for channel 'master-2';
Query OK, 0 rows affected, 1 warning (0.01 sec)

mysql> CHANGE MASTER TO MASTER_AUTO_POSITION = 0, MASTER_LOG_FILE ='binlog.000008',MASTER_LOG_POS=194 for channel 'master-1';
Query OK, 0 rows affected (0.01 sec)

mysql> CHANGE MASTER TO MASTER_AUTO_POSITION = 0, MASTER_LOG_FILE ='binlog.000007',MASTER_LOG_POS=194 for channel 'master-2';
Query OK, 0 rows affected (0.00 sec)

mysql> start slave for channel 'master-1';
Query OK, 0 rows affected (0.00 sec)

mysql> start slave for channel 'master-2';
Query OK, 0 rows affected (0.00 sec)

2.在每个服务器上执行:

SET @@GLOBAL.GTID_MODE = ON_PERMISSIVE;

mysql> SET @@GLOBAL.GTID_MODE = ON_PERMISSIVE;
Query OK, 0 rows affected (0.01 sec)

3.在每个服务器上执行:

SET @@GLOBAL.GTID_MODE = OFF_PERMISSIVE;

mysql> SET @@GLOBAL.GTID_MODE = OFF_PERMISSIVE;
Query OK, 0 rows affected (0.03 sec)

4.在每个服务器上,等待变量@@GLOBAL。GTID_OWNED等于空字符串。可以使用以下命令检查:

mysql> SELECT @@GLOBAL.GTID_OWNED;
+---------------------+
| @@GLOBAL.GTID_OWNED |
+---------------------+
|                     |
+---------------------+
1 row in set (0.00 sec)

在复制从机上,从理论上讲,它可能是空的,然后又变为非空的。这不是问题,空一次就足够了。

5.等待当前存在于任何二进制日志中的所有事务复制到所有从属日志
1.在主服务器执行:

SHOW MASTER STATUS;

主库1:10.18.30.50

mysql> SHOW MASTER STATUS;
+---------------+----------+--------------+------------------+-------------------------------------------+
| File          | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set                         |
+---------------+----------+--------------+------------------+-------------------------------------------+
| binlog.000010 |      194 |              |                  | bb8b95d1-6f47-11ef-9592-005056a390e6:1-10 |
+---------------+----------+--------------+------------------+-------------------------------------------+
1 row in set (0.00 sec)


主库2:10.18.30.43

mysql> SHOW MASTER STATUS;
+---------------+----------+--------------+------------------+-------------------------------------------+
| File          | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set                         |
+---------------+----------+--------------+------------------+-------------------------------------------+
| binlog.000009 |      194 |              |                  | 684e1f7d-6f47-11ef-a6d5-005056a3a162:1-11 |
+---------------+----------+--------------+------------------+-------------------------------------------+
1 row in set (0.00 sec)

记下“文件和位置”列中的值

2.在每个从属服务器上,使用来自主服务器的文件和位置信息执行:

SELECT MASTER_POS_WAIT('source_log_file', source_log_pos [, timeout][, channel])

从库:10.18.30.39

mysql> SELECT MASTER_POS_WAIT('binlog.000010',194,0,'master-1');
+---------------------------------------------------+
| MASTER_POS_WAIT('binlog.000007',194,0,'master-1') |
+---------------------------------------------------+
|                                                 0 |
+---------------------------------------------------+
1 row in set (0.00 sec)

mysql> SELECT MASTER_POS_WAIT('binlog.000009',194,0,'master-2');
+---------------------------------------------------+
| MASTER_POS_WAIT('binlog.000006',194,0,'master-2') |
+---------------------------------------------------+
|                                                 0 |
+---------------------------------------------------+
1 row in set (0.00 sec)

返回值为0 ,代表从库已经应用了主库1binlog.000010 194与 主库2binlog.000009 194位置的数据。

如果有一个主服务器和多层的从服务器,或者换句话说,有从服务器的从服务器,那么在每层都重复第2步,从主服务器开始,然后是所有的直 接从服务器,然后是所有从服务器的从服务器,以此类推。

6.如果您将二进制日志用于复制以外的其他用途,例如执行时间点备份或恢复:请等到不需要具有GTID事务的旧二进制日志时再使用。

例如,在步骤5完成之后,可以在进行备份的服务器上执行FLUSH LOGS。然后,要么显式地进行备份,要么等待您可能设置的任何定期备份例程 的下一次迭代。

理想情况下,等待服务器清除步骤5完成时存在的所有二进制日志。还要等待步骤5之前所做的备份过期。

这是整个过程中最重要的一点。重要的是要理解,包含GTID事务的日志在下一步之后不能使用。在继续之前,必须确保GTID事务不存在于拓扑中 的任何位置。

7.在每个服务器上执行:

mysql> SET @@GLOBAL.GTID_MODE = OFF;
Query OK, 0 rows affected (0.01 sec)

8.在每个服务器上,在my.cnf文件中设置gtid-mode=OFF
如果你想设置enforce_gtid_consistency=OFF,现在就可以这样做。设置好后,你应该在你的配置文件中添加enforce_gtid_consistency=OFF。

如果您想降级到MySQL的早期版本,现在就可以这样做,使用正常的降级过程。

]]>
http://www.jydba.net/index.php/archives/3592/feed 0
MySQL 5.7 启用GTID联机事务 http://www.jydba.net/index.php/archives/3589 http://www.jydba.net/index.php/archives/3589#respond Tue, 08 Oct 2024 07:17:25 +0000 http://www.jydba.net/?p=3589 启用GTID联机事务
如何在已经在线并使用匿名事务的服务器上启用GTID事务,以及可选的自动定位功能。此过程不需要使服务器离线,适合在生产环境中 使用。但是,如果您可以在启用GTID事务时使服务器脱机,那么处理就会更容易。

在开始安之前,请确保服务器满足以下前提条件:
.拓扑中的所有服务器必须使用MySQL 5.7.6或更高版本。您不能在任何一台服务器上在线启用GTID事务,除非拓扑中的所有服务器都使用此版本 。

.所有服务器都将gtid_mode设置为默认值OFF

启用GTID事务:
1.在每个服务器上执行:

SET @@GLOBAL.ENFORCE_GTID_CONSISTENCY = WARN;

主库1:10.18.30.50

mysql> SET @@GLOBAL.ENFORCE_GTID_CONSISTENCY = WARN;
Query OK, 0 rows affected (0.01 sec)

主库2:10.18.30.43

mysql> SET @@GLOBAL.ENFORCE_GTID_CONSISTENCY = WARN;
Query OK, 0 rows affected (0.01 sec)

从库:10.18.30.39

mysql> SET @@GLOBAL.ENFORCE_GTID_CONSISTENCY = WARN;
Query OK, 0 rows affected (0.01 sec)

让服务器在正常工作负载下运行一段时间,并监视日志。如果此步骤导致日志中出现任何警告,请调整应用程序,使其只使用gtid兼容的特性, 而不生成任何警告。

这是重要的第一步。在进入下一步之前,必须确保错误日志中没有生成警告。

2.在每个服务器上执行:

SET @@GLOBAL.ENFORCE_GTID_CONSISTENCY = ON;

主库1:10.18.30.50

mysql> SET @@GLOBAL.ENFORCE_GTID_CONSISTENCY = ON;
Query OK, 0 rows affected (0.00 sec)

主库2:10.18.30.43

mysql> SET @@GLOBAL.ENFORCE_GTID_CONSISTENCY = ON;
Query OK, 0 rows affected (0.00 sec)

从库:10.18.30.39

mysql> SET @@GLOBAL.ENFORCE_GTID_CONSISTENCY = ON;
Query OK, 0 rows affected (0.00 sec)

3.在每个服务器上执行:

SET @@GLOBAL.GTID_MODE = OFF_PERMISSIVE;

主库1:10.18.30.50

mysql> SET @@GLOBAL.GTID_MODE = OFF_PERMISSIVE;
Query OK, 0 rows affected (0.01 sec)

主库2:10.18.30.43

mysql> SET @@GLOBAL.GTID_MODE = OFF_PERMISSIVE;
Query OK, 0 rows affected (0.01 sec)

从库:10.18.30.39

mysql> SET @@GLOBAL.GTID_MODE = OFF_PERMISSIVE;
Query OK, 0 rows affected (0.01 sec)

哪个服务器首先执行此语句并不重要,但重要的是,所有服务器都要在任何服务器开始下一步之前完成此步骤。

4.在每个服务器上执行:

SET @@GLOBAL.GTID_MODE = ON_PERMISSIVE;

主库1:10.18.30.50

mysql> SET @@GLOBAL.GTID_MODE = ON_PERMISSIVE;
Query OK, 0 rows affected (0.01 sec)

主库2:10.18.30.43

mysql> SET @@GLOBAL.GTID_MODE = ON_PERMISSIVE;
Query OK, 0 rows affected (0.01 sec)


从库:10.18.30.39

mysql> SET @@GLOBAL.GTID_MODE = ON_PERMISSIVE;
Query OK, 0 rows affected (0.01 sec)

哪个服务器先执行该语句并不重要。

5.在每个服务器上,等待状态变量ONGOING_ANONYMOUS_TRANSACTION_COUNT为零。可以使用以下命令进行检查:

SHOW STATUS LIKE 'ONGOING_ANONYMOUS_TRANSACTION_COUNT';

主库1:10.18.30.50

mysql> SHOW STATUS LIKE 'ONGOING_ANONYMOUS_TRANSACTION_COUNT';
+-------------------------------------+-------+
| Variable_name                       | Value |
+-------------------------------------+-------+
| Ongoing_anonymous_transaction_count | 0     |
+-------------------------------------+-------+
1 row in set (0.01 sec)

主库2:10.18.30.43

mysql> SHOW STATUS LIKE 'ONGOING_ANONYMOUS_TRANSACTION_COUNT';
+-------------------------------------+-------+
| Variable_name                       | Value |
+-------------------------------------+-------+
| Ongoing_anonymous_transaction_count | 0     |
+-------------------------------------+-------+
1 row in set (0.01 sec)

从库:10.18.30.39

mysql> SHOW STATUS LIKE 'ONGOING_ANONYMOUS_TRANSACTION_COUNT';
+-------------------------------------+-------+
| Variable_name                       | Value |
+-------------------------------------+-------+
| Ongoing_anonymous_transaction_count | 0     |
+-------------------------------------+-------+
1 row in set (0.01 sec)

注意:在复制从机上,理论上有可能显示为零,然后再次显示为非零。这不是问题,它显示一次零就足够了。

6.等待步骤5之前生成的所有事务复制到所有服务器。您可以在不停止更新的情况下执行此操作:唯一重要的是所有匿名事务都会被复制。
1.在主服务器执行:

SHOW MASTER STATUS;

主库1:10.18.30.50

mysql> SHOW MASTER STATUS;
+---------------+----------+--------------+------------------+-------------------------------------------+
| File          | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set                         |
+---------------+----------+--------------+------------------+-------------------------------------------+
| binlog.000007 |      194 |              |                  | bb8b95d1-6f47-11ef-9592-005056a390e6:1-10 |
+---------------+----------+--------------+------------------+-------------------------------------------+
1 row in set (0.00 sec)


主库2:10.18.30.43

mysql> SHOW MASTER STATUS;
+---------------+----------+--------------+------------------+-------------------------------------------+
| File          | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set                         |
+---------------+----------+--------------+------------------+-------------------------------------------+
| binlog.000006 |      194 |              |                  | 684e1f7d-6f47-11ef-a6d5-005056a3a162:1-10 |
+---------------+----------+--------------+------------------+-------------------------------------------+
1 row in set (0.00 sec)

记下“文件和位置”列中的值

2.在每个从属服务器上,使用来自主服务器的文件和位置信息执行:

SELECT MASTER_POS_WAIT('source_log_file', source_log_pos [, timeout][, channel])

从库:10.18.30.39

mysql> SELECT MASTER_POS_WAIT('binlog.000007',194,0,'master-1');
+---------------------------------------------------+
| MASTER_POS_WAIT('binlog.000007',194,0,'master-1') |
+---------------------------------------------------+
|                                                 0 |
+---------------------------------------------------+
1 row in set (0.00 sec)

mysql> SELECT MASTER_POS_WAIT('binlog.000006',194,0,'master-2');
+---------------------------------------------------+
| MASTER_POS_WAIT('binlog.000006',194,0,'master-2') |
+---------------------------------------------------+
|                                                 0 |
+---------------------------------------------------+
1 row in set (0.00 sec)


mysql> SELECT MASTER_POS_WAIT('binlog.000006',195,0,'master-2');
+---------------------------------------------------+
| MASTER_POS_WAIT('binlog.000006',194,0,'master-2') |
+---------------------------------------------------+
|                                                 0 |
+---------------------------------------------------+
1 row in set (0.00 sec)

返回值为0 ,代表从库已经应用了主库1binlog.000007 194与 主库2binlog.000006 194位置的数据。

如果有一个主服务器和多层的从服务器,或者换句话说,有从服务器的从服务器,那么在每层都重复第2步,从主服务器开始,然后是所有的直 接从服务器,然后是所有从服务器的从服务器,以此类推。

如果使用循环复制拓扑,其中多个服务器可能有写客户端,则对每个主从连接执行步骤2,直到完成整个循环。重复整个过程,这样你就可以完 成整个循环两次。

例如,假设你有3个服务器A、B和C,它们在一个循环中复制A -> B -> C -> A。过程如下:

? Do step 1 on A and step 2 on B.
? Do step 1 on B and step 2 on C.
? Do step 1 on C and step 2 on A.
? Do step 1 on A and step 2 on B.
? Do step 1 on B and step 2 on C.
? Do step 1 on C and step 2 on A.

7.如果您将二进制日志用于除了复制之外的任何事情,例如时间点备份和恢复,请等待,直到您不需要具有没有gtid的事务的旧二进制日志。

例如,在步骤6完成后,可以在正在备份的服务器上执行FLUSH LOGS。然后,要么显式地进行备份,要么等待您可能设置的任何定期备份例程的 下一次迭代。理想情况下,等待服务器清除步骤6完成时存在的所有二进制日志。还要等待步骤6之前所做的备份过期。

这是第二点。理解包含匿名事务的二进制日志(没有gtid)在下一步中是无法使用的,这一点至关重要。在此步骤之后,您必须确保没有GTIDs的 事务在拓扑中不存在。

8.在每个服务器上

mysql> SET @@GLOBAL.GTID_MODE = ON;
Query OK, 0 rows affected (10.06 sec)

9.在每个服务器的my.cnf文件中加上gtid-mode=ON
现在可以保证所有的事务都有一个GTID(除了第5步或更早阶段生成的事务,它们已经被处理过)。要开始使用GTID协议以便稍后执行自动故障转 移,请在每个从服务器上执行以下操作。如果使用多源复制,可选地对每个通道执行此操作,并包括for channel channel子句:

STOP SLAVE [FOR CHANNEL 'channel'];
CHANGE MASTER TO MASTER_AUTO_POSITION = 1 [FOR CHANNEL 'channel'];
START SLAVE [FOR CHANNEL 'channel'];


mysql> stop slave for channel 'master-1';
Query OK, 0 rows affected (0.02 sec)

mysql> stop slave for channel 'master-2';
Query OK, 0 rows affected (0.01 sec)

mysql> CHANGE MASTER TO MASTER_AUTO_POSITION = 1 for channel 'master-1';
Query OK, 0 rows affected (0.00 sec)

mysql> CHANGE MASTER TO MASTER_AUTO_POSITION = 1 for channel 'master-2';
Query OK, 0 rows affected (0.00 sec)

mysql> start slave for channel 'master-1';
Query OK, 0 rows affected (0.01 sec)

mysql> start slave for channel 'master-2';
Query OK, 0 rows affected (0.00 sec)
]]>
http://www.jydba.net/index.php/archives/3589/feed 0
MySQL 5.7 多源复制 http://www.jydba.net/index.php/archives/3587 http://www.jydba.net/index.php/archives/3587#respond Sun, 08 Sep 2024 07:10:27 +0000 http://www.jydba.net/?p=3587 MySQL多源复制
MySQL多源复制,它使您能够从多个直接主服务器并行复制。介绍多源复制的配置、监控和故障排除方法。

MySQL多源复制概述
MySQL多源复制允许复制从服务器同时接收来自多个源的事务。多源复制可以将多台服务器备份到一台服务器,可以合并表分片,也可以将多台服务器的数据合并到一台服务器。在应用事务时,多源复制不实现任何冲突的检测或解决,如果需要,这些任务将留给应用程序。在多源复制拓扑中,从节点为应该从其接收事务的每个主节点创建复制通道。

配置多源复制
介绍多源复制拓扑的配置方法,以及配置主从拓扑的详细信息。这样的拓扑至少需要配置两个主节点和一个从节点。

可以将多源复制拓扑中的主机配置为使用基于全局事务标识符(GTID)的复制或基于二进制日志位置的复制。

多源复制拓扑中的从服务器需要基于TABLE的存储库。多源复制与基于文件的存储库不兼容。mysqld使用的存储库类型可以在启动时配置,也可以动态配置。

多源复制
主库1:10.18.30.25
主库2:10.18.30.43
从库: 10.18.30.39

1.在主库中创建用于复制的用户
主库1:10.18.30.25

[root@localhost mysql]#  mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.26-log Source distribution

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> CREATE USER 'repl'@'%' IDENTIFIED BY 'slavepass';
Query OK, 0 rows affected (0.01 sec)

mysql> GRANT REPLICATION SLAVE ON *.* TO 'repl'@'%';
Query OK, 0 rows affected (0.01 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.02 sec)

主库2:10.18.30.43
[root@localhost mysql]#  mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.26-log Source distribution

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> CREATE USER 'repl'@'%' IDENTIFIED BY 'slavepass';
Query OK, 0 rows affected (0.01 sec)

mysql> GRANT REPLICATION SLAVE ON *.* TO 'repl'@'%';
Query OK, 0 rows affected (0.01 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.02 sec)

2.对主库进行复制相关参数的设置
2.1 配置二进制日志和服务器ID选项

log-bin=mysql-bin
server-id=1

2.2 要配置复制从服务器启动时使用的存储库类型,请使用以下选项启动mysqld:

master-info-repository=TABLE
relay-log-info-repository=TABLE

要修改一个使用FILE存储库的复制从库,使其使用TABLE存储库,需要执行以下命令动态转换现有的复制存储库:

STOP SLAVE;
SET GLOBAL master_info_repository = 'TABLE';
SET GLOBAL relay_log_info_repository = 'TABLE';


mysql> stop slave;
ERROR 2006 (HY000): MySQL server has gone away
No connection. Trying to reconnect...
Connection id:    5
Current database: undo

Query OK, 0 rows affected (0.10 sec)

mysql> SET GLOBAL master_info_repository = 'TABLE';
Query OK, 0 rows affected (0.01 sec)

mysql> SET GLOBAL relay_log_info_repository = 'TABLE';
Query OK, 0 rows affected (0.00 sec)

2.3 如果使用基于全局事务标识符(GTID)的复制,还要检查全局事务标识符(GTID)的设置

mysql> show variables like '%server%id%';
+----------------+--------------------------------------+
| Variable_name  | Value                                |
+----------------+--------------------------------------+
| server_id      | 1                                    |
| server_id_bits | 32                                   |
| server_uuid    | f044fd89-6b6c-11ef-9f9f-005056a390e6 |
+----------------+--------------------------------------+
3 rows in set (0.01 sec)


mysql> show variables like '%server%id%';
+----------------+--------------------------------------+
| Variable_name  | Value                                |
+----------------+--------------------------------------+
| server_id      | 2                                    |
| server_id_bits | 32                                   |
| server_uuid    | 3f706e9b-6b6b-11ef-a6e3-005056a3a162 |
+----------------+--------------------------------------+
3 rows in set (0.01 sec)


mysql> show variables like '%server%id%';
+----------------+--------------------------------------+
| Variable_name  | Value                                |
+----------------+--------------------------------------+
| server_id      | 3                                    |
| server_id_bits | 32                                   |
| server_uuid    | b064fda1-6b68-11ef-8226-005056b9a980 |
+----------------+--------------------------------------+
3 rows in set (0.01 sec)

3.向多源复制从端添加基于GTID的主端
假设您已经使用gtid_mode= on在主服务器上启用了基于GTID的事务,启用了复制用户,并确保从服务器使用基于TABLE的复制存储库。使用CHANGE MASTER TO语句通过使用FOR channel通道子句向通道添加一个新的主通道。

mysql> CHANGE MASTER TO MASTER_HOST='10.18.30.25',MASTER_PORT=3306,MASTER_USER='repl',MASTER_PASSWORD='slavepass',MASTER_AUTO_POSITION=1 FOR CHANNEL 'master-1';
Query OK, 0 rows affected, 2 warnings (0.05 sec)




mysql> CHANGE MASTER TO MASTER_HOST='10.18.30.43',MASTER_PORT=3306,MASTER_USER='repl',MASTER_PASSWORD='slavepass',MASTER_AUTO_POSITION=1 FOR CHANNEL 'master-2';
Query OK, 0 rows affected, 2 warnings (0.01 sec)

启动多源复制从服务器
添加了想要用作复制主机的所有通道后,使用START SLAVE thread_types语句启动复制。当您在从属服务器上启用了多个通道时,您可以选择启动所有通道,或者选择要启动的特定通道。

.启动所有当前配置的复制区域通道

mysql> start slave;
Query OK, 0 rows affected (0.00 sec)

从库日志信息显示如下:

2024-09-09T09:16:09.641054Z 11 [Note] Slave I/O thread for channel 'master-1': connected to master 'repl@10.18.30.25:3306',replication started in log 'binlog.000002' at position 1841
2024-09-09T09:16:09.645067Z 13 [Note] Slave I/O thread for channel 'master-2': connected to master 'repl@10.18.30.43:3306',replication started in log 'binlog.000002' at position 1841

主库日志信息显示如下:
主库1:10.18.30.25

2024-09-10T08:40:48.526865Z 4 [Warning] IP address '10.18.30.39' could not be resolved: Temporary failure in name resolution
2024-09-10T08:40:48.534271Z 4 [Note] Start binlog_dump to master_thread_id(4) slave_server(3), pos(binlog.000004, 194)

主库2:10.18.30.43

2024-09-10T08:33:01.936331Z 7 [Warning] IP address '10.18.30.39' could not be resolved: Temporary failure in name resolution
2024-09-10T08:33:01.943408Z 7 [Note] Start binlog_dump to master_thread_id(7) slave_server(3), pos(binlog.000003, 194)

查看从库日志发现出错了。

2024-09-10T07:55:34.529867Z 4 [ERROR] Slave SQL for channel 'master-1': Error 'Operation ALTER USER failed for 'root'@'localhost'' on query. Default database: ''. Query: 'ALTER USER 'root'@'localhost' IDENTIFIED WITH 'mysql_native_password' AS '*6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9'', Error_code: 1396
2024-09-10T07:55:34.529945Z 4 [Warning] Slave: Operation ALTER USER failed for 'root'@'localhost' Error_code: 1396
2024-09-10T07:55:34.529980Z 4 [ERROR] Error running query, slave SQL thread aborted. Fix the problem, and restart the slave SQL thread with "SLAVE START". We stopped at log 'binlog.000002' position 154.
2024-09-10T07:55:34.530177Z 6 [ERROR] Slave SQL for channel 'master-2': Error 'Operation ALTER USER failed for 'root'@'localhost'' on query. Default database: ''. Query: 'ALTER USER 'root'@'localhost' IDENTIFIED WITH 'mysql_native_password' AS '*6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9'', Error_code: 1396
2024-09-10T07:55:34.530231Z 6 [Warning] Slave: Operation ALTER USER failed for 'root'@'localhost' Error_code: 1396
2024-09-10T07:55:34.530249Z 6 [ERROR] Error running query, slave SQL thread aborted. Fix the problem, and restart the slave SQL thread with "SLAVE START". We stopped at log 'binlog.000002' position 154.


2024-09-10T07:55:34.529867Z 4 [ERROR] Slave SQL for channel 'master-1': Error 'Operation ALTER USER failed for 'root'@'localhost'' on query. Default database: ''. Query: 'ALTER USER 'root'@'localhost' IDENTIFIED WITH 'mysql_native_password' AS '*6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9'', Error_code: 1396
2024-09-10T07:55:34.529945Z 4 [Warning] Slave: Operation ALTER USER failed for 'root'@'localhost' Error_code: 1396
2024-09-10T07:55:34.529980Z 4 [ERROR] Error running query, slave SQL thread aborted. Fix the problem, and restart the slave SQL thread with "SLAVE START". We stopped at log 'binlog.000002' position 154.
2024-09-10T07:55:34.530177Z 6 [ERROR] Slave SQL for channel 'master-2': Error 'Operation ALTER USER failed for 'root'@'localhost'' on query. Default database: ''. Query: 'ALTER USER 'root'@'localhost' IDENTIFIED WITH 'mysql_native_password' AS '*6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9'', Error_code: 1396
2024-09-10T07:55:34.530231Z 6 [Warning] Slave: Operation ALTER USER failed for 'root'@'localhost' Error_code: 1396
2024-09-10T07:55:34.530249Z 6 [ERROR] Error running query, slave SQL thread aborted. Fix the problem, and restart the slave SQL thread with "SLAVE START". We stopped at log 'binlog.000002' position 154.

mysql> show slave status\G
*************************** 1. row ***************************
               Slave_IO_State: Waiting for master to send event
                  Master_Host: 10.18.30.25
                  Master_User: repl
                  Master_Port: 3306
                Connect_Retry: 60
              Master_Log_File: binlog.000004
          Read_Master_Log_Pos: 194
               Relay_Log_File: localhost-relay-bin-master@002d1.000002
                Relay_Log_Pos: 361
        Relay_Master_Log_File: binlog.000002
             Slave_IO_Running: Yes
            Slave_SQL_Running: No
              Replicate_Do_DB:
          Replicate_Ignore_DB:
           Replicate_Do_Table:
       Replicate_Ignore_Table:
      Replicate_Wild_Do_Table:
  Replicate_Wild_Ignore_Table:
                   Last_Errno: 1396
                   Last_Error: Error 'Operation ALTER USER failed for 'root'@'localhost'' on query. Default database: ''. Query: 'ALTER USER 'root'@'localhost' IDENTIFIED WITH 'mysql_native_password' AS '*6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9''
                 Skip_Counter: 0
          Exec_Master_Log_Pos: 154
              Relay_Log_Space: 3214
              Until_Condition: None
               Until_Log_File:
                Until_Log_Pos: 0
           Master_SSL_Allowed: No
           Master_SSL_CA_File:
           Master_SSL_CA_Path:
              Master_SSL_Cert:
            Master_SSL_Cipher:
               Master_SSL_Key:
        Seconds_Behind_Master: NULL
Master_SSL_Verify_Server_Cert: No
                Last_IO_Errno: 0
                Last_IO_Error:
               Last_SQL_Errno: 1396
               Last_SQL_Error: Error 'Operation ALTER USER failed for 'root'@'localhost'' on query. Default database: ''. Query: 'ALTER USER 'root'@'localhost' IDENTIFIED WITH 'mysql_native_password' AS '*6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9''
  Replicate_Ignore_Server_Ids:
             Master_Server_Id: 1
                  Master_UUID: bb8b95d1-6f47-11ef-9592-005056a390e6
             Master_Info_File: mysql.slave_master_info
                    SQL_Delay: 0
          SQL_Remaining_Delay: NULL
      Slave_SQL_Running_State:
           Master_Retry_Count: 86400
                  Master_Bind:
      Last_IO_Error_Timestamp:
     Last_SQL_Error_Timestamp: 240910 15:55:34
               Master_SSL_Crl:
           Master_SSL_Crlpath:
           Retrieved_Gtid_Set: bb8b95d1-6f47-11ef-9592-005056a390e6:1-8
            Executed_Gtid_Set: ca006ef3-6f46-11ef-8203-005056b9a980:1-5
                Auto_Position: 1
         Replicate_Rewrite_DB:
                 Channel_Name: master-1
           Master_TLS_Version:
*************************** 2. row ***************************
               Slave_IO_State: Waiting for master to send event
                  Master_Host: 10.18.30.43
                  Master_User: repl
                  Master_Port: 3306
                Connect_Retry: 60
              Master_Log_File: binlog.000003
          Read_Master_Log_Pos: 194
               Relay_Log_File: localhost-relay-bin-master@002d2.000002
                Relay_Log_Pos: 361
        Relay_Master_Log_File: binlog.000002
             Slave_IO_Running: Yes
            Slave_SQL_Running: No
              Replicate_Do_DB:
          Replicate_Ignore_DB:
           Replicate_Do_Table:
       Replicate_Ignore_Table:
      Replicate_Wild_Do_Table:
  Replicate_Wild_Ignore_Table:
                   Last_Errno: 1396
                   Last_Error: Error 'Operation ALTER USER failed for 'root'@'localhost'' on query. Default database: ''. Query: 'ALTER USER 'root'@'localhost' IDENTIFIED WITH 'mysql_native_password' AS '*6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9''
                 Skip_Counter: 0
          Exec_Master_Log_Pos: 154
              Relay_Log_Space: 2766
              Until_Condition: None
               Until_Log_File:
                Until_Log_Pos: 0
           Master_SSL_Allowed: No
           Master_SSL_CA_File:
           Master_SSL_CA_Path:
              Master_SSL_Cert:
            Master_SSL_Cipher:
               Master_SSL_Key:
        Seconds_Behind_Master: NULL
Master_SSL_Verify_Server_Cert: No
                Last_IO_Errno: 0
                Last_IO_Error:
               Last_SQL_Errno: 1396
               Last_SQL_Error: Error 'Operation ALTER USER failed for 'root'@'localhost'' on query. Default database: ''. Query: 'ALTER USER 'root'@'localhost' IDENTIFIED WITH 'mysql_native_password' AS '*6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9''
  Replicate_Ignore_Server_Ids:
             Master_Server_Id: 2
                  Master_UUID: 684e1f7d-6f47-11ef-a6d5-005056a3a162
             Master_Info_File: mysql.slave_master_info
                    SQL_Delay: 0
          SQL_Remaining_Delay: NULL
      Slave_SQL_Running_State:
           Master_Retry_Count: 86400
                  Master_Bind:
      Last_IO_Error_Timestamp:
     Last_SQL_Error_Timestamp: 240910 15:55:34
               Master_SSL_Crl:
           Master_SSL_Crlpath:
           Retrieved_Gtid_Set: 684e1f7d-6f47-11ef-a6d5-005056a3a162:1-8
            Executed_Gtid_Set: ca006ef3-6f46-11ef-8203-005056b9a980:1-5
                Auto_Position: 1
         Replicate_Rewrite_DB:
                 Channel_Name: master-2
           Master_TLS_Version:
2 rows in set (0.00 sec)

因为使用基于gtid事务复制,于是尝试使用基于二进制日志的复制

mysql> stop slave;
Query OK, 0 rows affected (0.02 sec)

mysql> reset slave;
Query OK, 0 rows affected (0.02 sec)

mysql> change master to master_auto_position=0;
ERROR 3079 (HY000): Multiple channels exist on the slave. Please provide channel name as an argument.
mysql> change master to master_auto_position=0 for channel 'master-1';
Query OK, 0 rows affected (0.01 sec)

mysql> change master to master_auto_position=0 for channel 'master-2';
Query OK, 0 rows affected (0.01 sec)

mysql> CHANGE MASTER TO   MASTER_HOST='10.18.30.25',MASTER_USER='repl',MASTER_PASSWORD='slavepass',MASTER_LOG_FILE='binlog.000004',MASTER_LOG_POS=194 FOR CHANNEL 'master-1';
Query OK, 0 rows affected, 2 warnings (0.01 sec)

mysql> CHANGE MASTER TO   MASTER_HOST='10.18.30.43',MASTER_USER='repl',MASTER_PASSWORD='slavepass',MASTER_LOG_FILE='binlog.000003',MASTER_LOG_POS=194 FOR CHANNEL 'master-2';
Query OK, 0 rows affected, 2 warnings (0.00 sec)

mysql> start slave;
Query OK, 0 rows affected (0.01 sec)

查看从库日志

2024-09-10T08:24:19.657675Z 2 [Note] 'CHANGE MASTER TO FOR CHANNEL 'master-1' executed'. Previous state master_host='10.18.30.25', master_port= 3306, master_log_file='', master_log_pos= 4, master_bind=''. New state master_host='10.18.30.25', master_port= 3306, master_log_file='binlog.000004', master_log_pos= 194, master_bind=''.
2024-09-10T08:24:32.746649Z 2 [Note] 'CHANGE MASTER TO FOR CHANNEL 'master-2' executed'. Previous state master_host='10.18.30.43', master_port= 3306, master_log_file='', master_log_pos= 4, master_bind=''. New state master_host='10.18.30.43', master_port= 3306, master_log_file='binlog.000003', master_log_pos= 194, master_bind=''.
2024-09-10T08:24:40.193771Z 7 [Warning] Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SLAVE; see the 'START SLAVE Syntax' in the MySQL Manual for more information.
2024-09-10T08:24:40.200216Z 8 [Note] Slave SQL thread for channel 'master-1' initialized, starting replication in log 'binlog.000004' at position 194, relay log './localhost-relay-bin-master@002d1.000001' position: 4
2024-09-10T08:24:40.200505Z 9 [Warning] Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SLAVE; see the 'START SLAVE Syntax' in the MySQL Manual for more information.
2024-09-10T08:24:40.203240Z 10 [Note] Slave SQL thread for channel 'master-2' initialized, starting replication in log 'binlog.000003' at position 194, relay log './localhost-relay-bin-master@002d2.000001' position: 4
2024-09-10T08:24:47.987545Z 9 [Note] Slave I/O thread for channel 'master-2': connected to master 'repl@10.18.30.43:3306',replication started in log 'binlog.000003' at position 194
2024-09-10T08:24:47.987835Z 7 [Note] Slave I/O thread for channel 'master-1': connected to master 'repl@10.18.30.25:3306',replication started in log 'binlog.000004' at position 194

测试同步
主库1:10.18.30.25

mysql> create table t_cs(id int ,name varchar(30));
Query OK, 0 rows affected (0.03 sec)

mysql> insert into t_cs values(1,'cs');
Query OK, 1 row affected (0.01 sec)

mysql> select * from t_cs;
+------+------+
| id   | name |
+------+------+
|    1 | cs   |
+------+------+
1 row in set (0.00 sec)

从库:

mysql> select * from t_cs;
+------+------+
| id   | name |
+------+------+
|    1 | cs   |
+------+------+
1 row in set (0.00 sec)

主库2:10.18.30.43

mysql> create table t_repl(t_id int,t_name varchar(50));
Query OK, 0 rows affected (0.19 sec)

mysql> insert into t_repl values(1,'jy');
Query OK, 1 row affected (0.01 sec)

mysql> select * from t_repl;
+------+--------+
| t_id | t_name |
+------+--------+
|    1 | jy     |
+------+--------+
1 row in set (0.00 sec)

从库:

mysql> select * from t_repl;
+------+--------+
| t_id | t_name |
+------+--------+
|    1 | jy     |
+------+--------+
1 row in set (0.00 sec)



mysql> show slave status\G
*************************** 1. row ***************************
               Slave_IO_State: Waiting for master to send event
                  Master_Host: 10.18.30.25
                  Master_User: repl
                  Master_Port: 3306
                Connect_Retry: 60
              Master_Log_File: binlog.000004
          Read_Master_Log_Pos: 662
               Relay_Log_File: localhost-relay-bin-master@002d1.000002
                Relay_Log_Pos: 785
        Relay_Master_Log_File: binlog.000004
             Slave_IO_Running: Yes
            Slave_SQL_Running: Yes
              Replicate_Do_DB:
          Replicate_Ignore_DB:
           Replicate_Do_Table:
       Replicate_Ignore_Table:
      Replicate_Wild_Do_Table:
  Replicate_Wild_Ignore_Table:
                   Last_Errno: 0
                   Last_Error:
                 Skip_Counter: 0
          Exec_Master_Log_Pos: 662
              Relay_Log_Space: 1009
              Until_Condition: None
               Until_Log_File:
                Until_Log_Pos: 0
           Master_SSL_Allowed: No
           Master_SSL_CA_File:
           Master_SSL_CA_Path:
              Master_SSL_Cert:
            Master_SSL_Cipher:
               Master_SSL_Key:
        Seconds_Behind_Master: 0
Master_SSL_Verify_Server_Cert: No
                Last_IO_Errno: 0
                Last_IO_Error:
               Last_SQL_Errno: 0
               Last_SQL_Error:
  Replicate_Ignore_Server_Ids:
             Master_Server_Id: 1
                  Master_UUID: bb8b95d1-6f47-11ef-9592-005056a390e6
             Master_Info_File: mysql.slave_master_info
                    SQL_Delay: 0
          SQL_Remaining_Delay: NULL
      Slave_SQL_Running_State: Slave has read all relay log; waiting for more updates
           Master_Retry_Count: 86400
                  Master_Bind:
      Last_IO_Error_Timestamp:
     Last_SQL_Error_Timestamp:
               Master_SSL_Crl:
           Master_SSL_Crlpath:
           Retrieved_Gtid_Set: bb8b95d1-6f47-11ef-9592-005056a390e6:9-10
            Executed_Gtid_Set: 684e1f7d-6f47-11ef-a6d5-005056a3a162:9-10,
bb8b95d1-6f47-11ef-9592-005056a390e6:9-10,
ca006ef3-6f46-11ef-8203-005056b9a980:1-5
                Auto_Position: 0
         Replicate_Rewrite_DB:
                 Channel_Name: master-1
           Master_TLS_Version:
*************************** 2. row ***************************
               Slave_IO_State: Waiting for master to send event
                  Master_Host: 10.18.30.43
                  Master_User: repl
                  Master_Port: 3306
                Connect_Retry: 60
              Master_Log_File: binlog.000003
          Read_Master_Log_Pos: 669
               Relay_Log_File: localhost-relay-bin-master@002d2.000002
                Relay_Log_Pos: 792
        Relay_Master_Log_File: binlog.000003
             Slave_IO_Running: Yes
            Slave_SQL_Running: Yes
              Replicate_Do_DB:
          Replicate_Ignore_DB:
           Replicate_Do_Table:
       Replicate_Ignore_Table:
      Replicate_Wild_Do_Table:
  Replicate_Wild_Ignore_Table:
                   Last_Errno: 0
                   Last_Error:
                 Skip_Counter: 0
          Exec_Master_Log_Pos: 669
              Relay_Log_Space: 1016
              Until_Condition: None
               Until_Log_File:
                Until_Log_Pos: 0
           Master_SSL_Allowed: No
           Master_SSL_CA_File:
           Master_SSL_CA_Path:
              Master_SSL_Cert:
            Master_SSL_Cipher:
               Master_SSL_Key:
        Seconds_Behind_Master: 0
Master_SSL_Verify_Server_Cert: No
                Last_IO_Errno: 0
                Last_IO_Error:
               Last_SQL_Errno: 0
               Last_SQL_Error:
  Replicate_Ignore_Server_Ids:
             Master_Server_Id: 2
                  Master_UUID: 684e1f7d-6f47-11ef-a6d5-005056a3a162
             Master_Info_File: mysql.slave_master_info
                    SQL_Delay: 0
          SQL_Remaining_Delay: NULL
      Slave_SQL_Running_State: Slave has read all relay log; waiting for more updates
           Master_Retry_Count: 86400
                  Master_Bind:
      Last_IO_Error_Timestamp:
     Last_SQL_Error_Timestamp:
               Master_SSL_Crl:
           Master_SSL_Crlpath:
           Retrieved_Gtid_Set: 684e1f7d-6f47-11ef-a6d5-005056a3a162:9-10
            Executed_Gtid_Set: 684e1f7d-6f47-11ef-a6d5-005056a3a162:9-10,
bb8b95d1-6f47-11ef-9592-005056a390e6:9-10,
ca006ef3-6f46-11ef-8203-005056b9a980:1-5
                Auto_Position: 0
         Replicate_Rewrite_DB:
                 Channel_Name: master-2
           Master_TLS_Version:
]]>
http://www.jydba.net/index.php/archives/3587/feed 0
MySQL 5.7 使用全局事务标识符(GTIDs)进行主从复制 http://www.jydba.net/index.php/archives/3584 http://www.jydba.net/index.php/archives/3584#respond Mon, 19 Aug 2024 08:17:44 +0000 http://www.jydba.net/?p=3584 使用全局事务标识符进行复制
下面解释使用全局事务标识符(GTIDs)进行基于事务的复制。当使用GTIDs时,每个事务都可以被识别和跟踪,因为它是在原始服务器上提交的, 并由任何从服务器应用;这意味着在启动一个新的slave或故障转移到一个新的master时,使用gtid时不需要引用日志文件或这些文件中的位置, 这大大简化了这些任务。因为基于gtid的复制完全是基于事务的,所以很容易确定主节点和从节点是否一致;只要在主节点上提交的所有事务也 在从节点上提交,就可以保证两者之间的一致性。你可以在GTIDs中使用基于语句或基于行的复制;不过,为了获得最佳效果,我们建议您使用基 于行的格式。

GTID概念
全局事务标识符(GTID)是与原始服务器(主服务器)上提交的每个事务相关联的唯一标识符。此标识符不仅对其发起的服务器是唯一的,而且在给 定复制设置中的所有服务器上也是唯一的。在所有事务和所有gtid之间存在1对1的映射。

以下段落提供了gtid的基本描述。更高级的概念将在后面的章节中介绍:
.GTID集

.mysql.gtid_executed表

.mysql.gtid_executed表压缩

GTID表示为一对坐标,由冒号(:)分隔,如下所示:
GTID = source_id:transaction_id

source_id标识原始服务器。通常,服务器的server_uuid用于此目的。transaction_id是一个序号,由事务在此服务器上提交的顺序决定;例如 ,要提交的第一个事务的transaction_id为1,在同一个原始服务器上要提交的第10个事务的transaction_id为10。在GTID中,事务不可能有0作 为序号。例如,在服务器上提交的第23个事务的UUID是3E11FA47-71CA-11E1-9E33-C80AA9429562,其GTID是这样的:
3E11FA47-71CA-11E1-9E33-C80AA9429562:23

这种格式用于在SHOW SLAVE STATUS等语句的输出以及二进制日志中表示gtid。当使用mysqlbinlog –base64-output=DECODE-ROWS查看日志文件 或在SHOW BINLOG EVENTS的输出中也可以看到它们。

正如在SHOW MASTER STATUS或SHOW SLAVE STATUS等语句的输出中所写的那样,来自同一服务器的gtid序列可以折叠成单个表达式,如下所示。

3E11FA47-71CA-11E1-9E33-C80AA9429562:1-5

刚才显示的示例表示在server_uuid为3E11FA47-71CA-11E1-9E33-C80AA9429562的MySQL服务器上发起的第一个到第五个事务。

这种格式还用于提供START SLAVE选项所需的参数SQL_BEFORE_GTIDS和SQL_AFTER_GTIDS。

GTID集
GTID集合是全局事务标识符的集合,表示如下:

gtid_set:
uuid_set [, uuid_set] ...
| ''
uuid_set:
uuid:interval[:interval]...
uuid:
hhhhhhhh-hhhh-hhhh-hhhh-hhhhhhhhhhhh
h:
[0-9|A-F]
interval:
n[-n]
(n >= 1)

GTID集在MySQL服务器中有多种使用方式。例如,gtid_executed和gtid_purged系统变量存储的值表示为GTID集合。此外,函数GTID_SUBSET()和 GTID_SUBTRACT()也要求输入GTID集合。当GTID集从服务器变量返回时,uuid按字母顺序排列,数值区间合并并升序排列。

gtid总是保存在master和slave之间。这意味着您总是可以通过检查任何从属服务器上应用的任何事务的二进制日志来确定其来源。此外,一旦 具有给定GTID的事务在给定服务器上提交,该服务器将忽略具有相同GTID的后续事务。因此,在主节点上提交的事务只能在从节点上应用一次, 这有助于保证一致性。

当使用gtid时,从节点不需要任何非本地的数据,例如主节点上一个文件的名称和在该文件中的位置。所有与主节点同步的必要信息都可以直接 从复制数据流中获得。GTIDs替换了之前用来确定在主从之间启动、停止或恢复数据流的点的文件偏移量对。因此,不要在CHANGE MASTER TO语 句中包含MASTER_LOG_FILE或MASTER_LOG_POS选项,这些选项用于指导从主机进行复制;相反,只需要启用MASTER_AUTO_POSITION选项。

GTID的生成和生命周期包括以下步骤:
1. 事务在主服务器上执行和提交
这个事务使用主服务器的UUID和最小的非零事务序列号分配一个GTID;GTID被写入到master的二进制日志中(紧跟在事务本身之前)。

2.在二进制日志数据传输到从服务器并存储到从服务器的中继日志之后(使用针对该进程建立的机制),从服务器读取GTID,并将其gtid_next系 统变量的值设置为该GTID。这告诉从服务器必须使用这个GTID记录下下一个事务。

注意slave在会话上下文中设置gtid_next是很重要的。

3.从服务器验证这个GTID是否已经被用来在它自己的二进制日志中记录事务。如果这个GTID没有被使用,从服务器就会写入GTID,应用事务,并 将事务写入它的二进制日志。在处理事务本身之前,通过首先读取和检查事务的GTID,从服务器不仅保证没有先前拥有该GTID的事务应用于从服 务器,而且还保证没有其他会话已经读取该GTID但尚未提交相关事务。换句话说,不允许多个客户端并发地应用相同的事务。

4.因为gtid_next不为空,所以从服务器并不试图为该事务生成一个GTID,而是将存储在该变量中的GTID,即从主服务器获得的GTID,在其二进 制日志中紧接在事务之前。

mysql.gtid_executed表
mysql.gtid_execute表是在MySQL服务器安装或升级时创建的(如果它不存在),使用如下所示的create table语句:
CREATE TABLE gtid_executed (
source_uuid CHAR(36) NOT NULL,
interval_start BIGINT(20) NOT NULL,
interval_end BIGINT(20) NOT NULL,
PRIMARY KEY (source_uuid, interval_start)
)

警告
与其他MySQL系统表一样,不要尝试自己创建或修改该表。

只有当gtid_mode为ON或ON_PERMISSIVE时,gtid才会存储在mysql.gtid_executed表中。表中存储的gtid与是否启用二进制日志记录无关。但它 们存储的方式取决于log_bin是开启还是关闭。
.如果二进制日志被禁用(log_bin为OFF),服务器将属于每个事务的GTID与表中的事务一起存储。

此外,当二进制日志被禁用时,该表会以用户可配置的速率定期压缩;看mysql.gtid_executed表压缩,以获取更多信息。

.如果启用了二进制日志记录(打开log_bin),那么除了将gtid存储在mysql.gtid_executed表之外,每当二进制日志被轮换或服务器关闭时,服 务器都会将所有写入前一个二进制日志的事务的GTIDs写入到新的二进制日志中。

在服务器意外停止的情况下,之前的二进制日志中的gtid集合不会保存到mysql中。gtid_executed表。在这种情况下,这些gtid会被添加到表中 ,并在恢复期间被添加到gtid_executed系统变量中的gtid集合中。

当启用二进制日志记录时,mysql。gtid_executed表没有提供所有已执行事务的GTIDs的完整记录。该信息由gtid_executed系统变量的全局值提供。

mysql.gtid_executed表被RESET MASTER重置。

mysql.gtid_executed表压缩
随着时间的推移,mysql.gtid_execute表可能会被许多行填充,这些行引用来自同一服务器上的单个gtid,并且其事务id组成一个序列,类似于 下面所示:

mysql> SELECT * FROM mysql.gtid_executed;
+--------------------------------------+----------------+--------------+
| source_uuid                          | interval_start | interval_end |
|--------------------------------------+----------------+--------------|
| 3E11FA47-71CA-11E1-9E33-C80AA9429562 | 37             | 37           |
| 3E11FA47-71CA-11E1-9E33-C80AA9429562 | 38             | 38           |
| 3E11FA47-71CA-11E1-9E33-C80AA9429562 | 39             | 39           |
| 3E11FA47-71CA-11E1-9E33-C80AA9429562 | 40             | 40           |
| 3E11FA47-71CA-11E1-9E33-C80AA9429562 | 41             | 41           |
| 3E11FA47-71CA-11E1-9E33-C80AA9429562 | 42             | 42           |
| 3E11FA47-71CA-11E1-9E33-C80AA9429562 | 43             | 43           |
...

如果将该表定期压缩,可以将每组这样的行替换为跨越整个事务标识符间隔的单行,这样可以节省相当大的空间,如下所示:

+--------------------------------------+----------------+--------------+
| source_uuid                          | interval_start | interval_end |
|--------------------------------------+----------------+--------------|
| 3E11FA47-71CA-11E1-9E33-C80AA9429562 |             37 | 43           |
...

当启用GTIDs时,服务器会对mysql.gtid_executed表周期性地执行这种类型的压缩。通过设置executed_gtids_compression_period系统变量, 可以控制压缩表之前允许发生的事务数,从而控制压缩率。这个变量的默认值是1000;这意味着,默认情况下,每1000个事务之后都会对表进行 压缩。将executed_gtid_compression_period设置为0将禁止执行压缩;但是,用户应该做好准备,如果这样做,gtid_executed表可能会需要大 量的磁盘空间

注意:
当启用二进制日志记录时,不使用executed_gtids_compression_period时。每次二进制日志轮换时,mysql.gtid_executed表都会被压缩。

压缩mysql.gtid_execute表是由一个名为thread/sql/compress_gtid_table的专用前台线程执行。这个线程没有在SHOW PROCESSLIST的输出中列 出,但是它可以被看作是线程表中的一行,如下所示:

mysql> SELECT * FROM performance_schema.threads WHERE NAME LIKE '%gtid%'\G
*************************** 1. row ***************************
          THREAD_ID: 26
               NAME: thread/sql/compress_gtid_table
               TYPE: FOREGROUND
     PROCESSLIST_ID: 1
   PROCESSLIST_USER: NULL
   PROCESSLIST_HOST: NULL
     PROCESSLIST_DB: NULL
PROCESSLIST_COMMAND: Daemon
   PROCESSLIST_TIME: 631286
  PROCESSLIST_STATE: Suspending
   PROCESSLIST_INFO: NULL
   PARENT_THREAD_ID: 1
               ROLE: NULL
       INSTRUMENTED: YES
            HISTORY: YES
    CONNECTION_TYPE: NULL
       THREAD_OS_ID: 24594
1 row in set (0.00 sec)

thread/sql/compress_gtid_table线程通常休眠,直到executed_gtids_compression_period事务被执行,如前所述,然后唤醒执行 mysql.gtid_performed表压缩。然后它休眠,直到另一个executed_gtids_compression_period事务发生,然后唤醒再次执行压缩,无限地重复 这个循环。当禁用二进制日志记录时,将此值设置为0意味着线程始终处于睡眠状态,永远不会醒来。

使用gtid设置复制
对于最简单的GTID复制拓扑(由一个主节点和一个从节点组成),启动过程中的关键步骤如下:
1.如果复制已经在运行,则通过将两台服务器设置为只读来同步它们。

2.停止两个服务器。

3.启用gtid并配置正确的选项并重新启动两个服务器。
启动所描述的服务器所需的mysqld选项将在本节后面的示例中讨论。

注意:
server_uuid必须存在,gtid才能正常工作。

4.指示从服务器使用主服务器作为复制数据源并使用自动定位,然后启动从服务器。完成此步骤所需的SQL语句将在本节后面的示例中描述。

5.做一个新的备份。包含没有gtid的事务的二进制日志不能在启用gtid的服务器上使用,因此在此之前进行的备份不能用于您的新配置。

6.启动从属服务器,然后在两台服务器上再次启用读取模式,以便它们可以接受更新。

在下面的示例中,三台服务器已经分别作为主服务器和从服务器运行,使用MySQL的二进制日志基于位置的复制协议。下面的例子展示了如何在 服务器的选项文件中存储mysqld启动选项。

下面的大多数步骤都需要使用MySQL root帐户或其他具有SUPER权限的MySQL用户帐户。mysqladmin shutdown需要SUPER权限或SHUTDOWN特权。

步骤1:同步服务器。对于已经在进行复制而不是使用gtid方式的服务器才需要执行此步骤。对于新服务器,请继续执行步骤3。通过在每个服务 器上发出以下命令,设置read_only系统变量为ON使服务器只读:

mysql> show variables like '%server%id%';
+----------------+--------------------------------------+
| Variable_name  | Value                                |
+----------------+--------------------------------------+
| server_id      | 1                                    |
| server_id_bits | 32                                   |
| server_uuid    | 7877044c-a8f0-11ec-be08-005056a390e6 |
+----------------+--------------------------------------+
3 rows in set (0.01 sec)

mysql> SET @@global.read_only = ON;
Query OK, 0 rows affected (0.00 sec)


mysql> show variables like '%server%id%';
+----------------+--------------------------------------+
| Variable_name  | Value                                |
+----------------+--------------------------------------+
| server_id      | 2                                    |
| server_id_bits | 32                                   |
| server_uuid    | 1c5eb4fb-9479-11ec-8f21-005056a390e6 |
+----------------+--------------------------------------+
3 rows in set (0.06 sec)

mysql> SET @@global.read_only = ON;
Query OK, 0 rows affected (0.00 sec)


mysql> show variables like '%server%id%';
+----------------+--------------------------------------+
| Variable_name  | Value                                |
+----------------+--------------------------------------+
| server_id      | 3                                    |
| server_id_bits | 32                                   |
| server_uuid    | f08c0957-3d11-11ef-bea6-005056b9a980 |
+----------------+--------------------------------------+
3 rows in set (0.05 sec)

mysql> SET @@global.read_only = ON;
Query OK, 0 rows affected (0.00 sec)

等待所有正在进行的事务提交或回滚。然后,让从服务器追上主服务器。在继续工作之前,确保从服务器已经处理了所有的更新是极其重要的。

如果您将二进制日志用于除复制之外的任何事情,例如执行时间点备份和恢复,请等待,直到您不需要包含没有gtid的事务的旧二进制日志。理 想情况下,应该等待服务器清除所有二进制日志,并等待任何现有的备份过期。

重点
重要的是要理解,包含没有gtid的事务的日志不能在启用了gtid的服务器上使用。在继续之前,必须确保没有gtid的事务在拓扑中的任何位置都 不存在。

步骤2:
停止所有服务器。使用如下所示的mysqladmin停止每个服务器,其中username是MySQL用户的用户名,该用户有足够的权限关闭服务器:

shell> mysqladmin -uusername -p shutdown

然后在提示符下输入该用户的密码。

关闭主库

[root@localhost ~]# mysqladmin -uroot -pxxzx7817600 shutdown
mysqladmin: [Warning] Using a password on the command line interface can be insecure.

关闭两个从库

[root@localhost /]# mysqladmin -uroot -pxxzx7817600 shutdown
mysqladmin: [Warning] Using a password on the command line interface can be insecure.

[root@localhost mysql]# mysqladmin -uroot -pxxzx7817600 shutdown
mysqladmin: [Warning] Using a password on the command line interface can be insecure.

步骤3:启动所有启用gtid的服务器。要启用基于GTID的复制,每个服务器必须以启用GTID模式的方式启动,即通过将gtid_mode变量设置为ON, 并启用enforce_gtid_consistency变量以确保只记录适用于基于GTID复制的语句。此外,在配置从服务器设置之前,应以“–skip-slave-start ”选项启动从服务器。

为了使用gtid,并不是必须启用二进制日志记录,因为在MySQL 5.7.5添加了mysql.gtid_execute表,这意味着从服务器可以只使用gtid而不需要 二进制日志记录。主服务器必须始终启用二进制日志记录,以便能够进行复制。例如,要启动启用gtid但没有二进制日志记录的从服务器,请在 服务器的选项文件中配置这些变量:

gtid_mode=ON
enforce-gtid-consistency=true

修改主服务器的参数配置

[root@localhost ~]# vi /mysqlsoft/mysql/my.cnf
gtid_mode=ON
enforce-gtid-consistency=true

修改两个从服务器的参数配置

[root@localhost /]# vi /mysqlsoft/mysql/my.cnf
gtid_mode=ON
enforce-gtid-consistency=true
skip-slave-start=1

[root@localhost mysql]# vi /mysqlsoft/mysql/my.cnf
gtid_mode=ON
enforce-gtid-consistency=true
skip-slave-start=1

根据您的配置,为mysqld提供额外的选项。

启动主服务器

[root@localhost ~]# service mysqld start
Starting MySQL.... SUCCESS!

启动两个从服务器

[root@localhost /]# service mysqld start
Starting MySQL.. SUCCESS!

[root@localhost mysql]# service mysqld start
Starting MySQL.. SUCCESS!

步骤4:配置从服务器使用基于gtid的自动定位。告诉从服务器使用基于GTID事务的主服务器作为复制数据源,并使用基于GTID的自动定位,而 不是基于文件的定位。在从服务器上发出CHANGE MASTER TO语句,包括MASTER_AUTO_POSITION选项告诉从服务器,主服务器的事务是由gtid标识 的。

您可能还需要为主服务器的主机名和端口号提供适当的值,以及用于从服务器连接到主服务器的复制用户帐户的用户名和密码;如果在步骤1之前 已经设置了这些选项,并且不需要进行进一步的更改,则可以安全地从这里显示的语句中省略相应的选项。

对所有从服务器执行以下命令

mysql> show variables like '%server%id%';
+----------------+--------------------------------------+
| Variable_name  | Value                                |
+----------------+--------------------------------------+
| server_id      | 2                                    |
| server_id_bits | 32                                   |
| server_uuid    | 1c5eb4fb-9479-11ec-8f21-005056a390e6 |
+----------------+--------------------------------------+
3 rows in set (0.06 sec)

mysql> CHANGE MASTER TO  MASTER_HOST='10.138.130.250',MASTER_PORT=3306,MASTER_USER='repl',MASTER_PASSWORD='slavepass',MASTER_AUTO_POSITION=1;
Query OK, 0 rows affected, 2 warnings (0.03 sec)



mysql> show variables like '%server%id%';
+----------------+--------------------------------------+
| Variable_name  | Value                                |
+----------------+--------------------------------------+
| server_id      | 3                                    |
| server_id_bits | 32                                   |
| server_uuid    | f08c0957-3d11-11ef-bea6-005056b9a980 |
+----------------+--------------------------------------+
3 rows in set (0.00 sec)


mysql> CHANGE MASTER TO  MASTER_HOST='10.138.130.250',MASTER_PORT=3306,MASTER_USER='repl',MASTER_PASSWORD='slavepass',MASTER_AUTO_POSITION=1;
Query OK, 0 rows affected, 2 warnings (0.01 sec)

MASTER_LOG_FILE选项和MASTER_LOG_POS选项都不能在MASTER_AUTO_POSITION设置为1时使用。尝试这样做会导致CHANGE MASTER to语句失败并出现错误。

步骤5:做一个新的备份。在启用gtid之前所做的现有备份不能再在启用gtid后的这些服务器上使用。此时进行新的备份,这样就不会没有可用 的备份。

例如,您可以在进行备份的服务器上执行FLUSH LOGS。然后,要么显式地进行备份,要么等待您可能设置的任何定期备份例程的下一次迭代。
对主库执行备份

mysql> FLUSH LOGS;
Query OK, 0 rows affected (0.01 sec)

[root@localhost ~]# mysqldump -uroot -pxxzx7817600 --all-databases --master-data > dbdump20240711.db
mysqldump: [Warning] Using a password on the command line interface can be insecure.
Warning: A partial dump from a server that has GTIDs will by default include the GTIDs of all transactions, even those that  changed suppressed parts of the database. If you don't want to restore GTIDs, pass --set-gtid-purged=OFF. To make a complete  dump, pass --all-databases --triggers --routines --events.

步骤6:启动从服务器并禁用只读模式。像这样启动slave:

mysql> start slave;
Query OK, 0 rows affected (0.01 sec)

mysql> start slave;
Query OK, 0 rows affected (0.01 sec)

只有在步骤1中将服务器配置为只读时,才需要执行以下步骤。要允许服务器再次开始接受更新,请发出以下语句:
从库

mysql> SET @@global.read_only = OFF;
Query OK, 0 rows affected (0.00 sec)

mysql> SET @@global.read_only = OFF;
Query OK, 0 rows affected (0.00 sec)

主库

mysql> SET @@global.read_only = OFF;
Query OK, 0 rows affected (0.00 sec)

基于gtid的复制现在应该正在运行,可以像以前一样在主服务器上开始(或恢复)进行操作。

下面来进行验证
主库

mysql> create table t5(id int primary key not null,name varchar(30),age int not null);
Query OK, 0 rows affected (0.07 sec)

mysql> desc t5;
+-------+-------------+------+-----+---------+-------+
| Field | Type        | Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+-------+
| id    | int(11)     | NO   | PRI | NULL    |       |
| name  | varchar(30) | YES  |     | NULL    |       |
| age   | int(11)     | NO   |     | NULL    |       |
+-------+-------------+------+-----+---------+-------+
3 rows in set (0.00 sec)

从库
1.

mysql> desc t5;
+-------+-------------+------+-----+---------+-------+
| Field | Type        | Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+-------+
| id    | int(11)     | NO   | PRI | NULL    |       |
| name  | varchar(30) | YES  |     | NULL    |       |
| age   | int(11)     | NO   |     | NULL    |       |
+-------+-------------+------+-----+---------+-------+
3 rows in set (0.00 sec)

2.

mysql> desc t5;
+-------+-------------+------+-----+---------+-------+
| Field | Type        | Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+-------+
| id    | int(11)     | NO   | PRI | NULL    |       |
| name  | varchar(30) | YES  |     | NULL    |       |
| age   | int(11)     | NO   |     | NULL    |       |
+-------+-------------+------+-----+---------+-------+
3 rows in set (0.00 sec)

主库:

mysql> insert into t5 values(1,'jingyong',39);
Query OK, 1 row affected (0.00 sec)

mysql> select * from t5;
+----+----------+-----+
| id | name     | age |
+----+----------+-----+
|  1 | jingyong |  39 |
+----+----------+-----+
1 row in set (0.01 sec)

从库
1.

mysql> select * from t5;
+----+----------+-----+
| id | name     | age |
+----+----------+-----+
|  1 | jingyong |  39 |
+----+----------+-----+
1 row in set (0.00 sec)

2.

mysql> select * from t5;
+----+----------+-----+
| id | name     | age |
+----+----------+-----+
|  1 | jingyong |  39 |
+----+----------+-----+
1 row in set (0.00 sec)

可以看到同步正常。

]]>
http://www.jydba.net/index.php/archives/3584/feed 0
MySQL 5.7向主从复制环境增加从库 http://www.jydba.net/index.php/archives/3582 http://www.jydba.net/index.php/archives/3582#respond Thu, 15 Aug 2024 08:09:23 +0000 http://www.jydba.net/?p=3582 向复制环境添加从机
可以在不停止主复制的情况下向现有复制配置添加另一个从复制。相反,可以通过创建一个现有从属服务器的副本来设置新的从属服务器,只不 过要用不同的服务器id值来配置新的从属服务器。

复制一个已存在的从节点。
1.关闭现有从服务器:

[mysql@localhost ~]$ mysqladmin -uroot -pxxzx7817600 shutdown
mysqladmin: [Warning] Using a password on the command line interface can be insecure.

2.将数据目录从现有的从服务器复制到新的从服务器。您可以通过使用tar或WinZip创建存档,或者使用cp或rsync等工具执行直接复制来实现这 一点。确保还复制了日志文件和中继日志文件。

[root@localhost mysql]# rsync -avz * root@10.138.130.239:/mysqldata/mysql/
The authenticity of host '10.138.130.239 (10.138.130.239)' can't be established.
ECDSA key fingerprint is 7f:1f:9a:0f:8b:d1:e0:17:32:08:12:73:d8:1d:9c:da.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '10.138.130.239' (ECDSA) to the list of known hosts.
root@10.138.130.239's password:
sending incremental file list
binlog.006119
ib_buffer_pool
ib_logfile0
ibdata1
localhost-relay-bin.000004
localhost-relay-bin.000005
localhost-relay-bin.index
master.info
mysql.err
relay-log.info
.........

sent 86590 bytes  received 262429 bytes  4748.56 bytes/sec
total size is 22282098540  speedup is 63842.08

在添加新的复制从服务器时遇到的一个常见问题是,新的从服务器失败,并显示一系列警告和错误消息,如下所示:

071118 16:44:10 [Warning] Neither --relay-log nor --relay-log-index were used; so
replication may break when this MySQL server acts as a slave and has his hostname
changed!! Please use '--relay-log=new_slave_hostname-relay-bin' to avoid this problem.
071118 16:44:10 [ERROR] Failed to open the relay log './old_slave_hostname-relay-bin.003525'
(relay_log_pos 22940879)
071118 16:44:10 [ERROR] Could not find target log during relay log initialization
071118 16:44:10 [ERROR] Failed to initialize the master info structure

发生这种问题最可能的原因是启动mysql时没有指明–relay-log参数,在没有指定这个参数的情况下relay log会默认以主机名为前缀生成日志 文件。如果不指定–relay-log-index,relay log index文件也是如此。

要避免这个问题,把新从库的–relay-log的值设置为与原来的从库一致。如果原来的从库没有设置这个参数,那么把新从库的–relay-log参 数设置为existing_slave_hostname-relay-bin。如果不能这样设置,把原来从库的relay log索引文件复制到新从库,并设置新从库的– relay-log-index与原来从库的这个参数一致。如果原来从库没有设置–relay-log-index,把新从库的–relay-log-index设置为 existing_slave_hostname-relay-bin.index。

[root@localhost mysql]# vi /mysqlsoft/mysql/my.cnf
relay-log=localhost-relay-bin
relay-log-index=localhost-relay-bin.index

如果已经执行了后边步骤,在启动新从库的时候遇到这个问题,请执行以下步骤:

a.在新从库和原从库上执行stop slave

b.复制原来的从库的relay log索引文件到新从库,确保覆盖新从库的relay log索引文件。

c.执行后边的步骤。

3.复制原来从库的master info和relay log info文件到新从库。(这两个也可能存在表里边,跟如何配置的有关)这两个文件保存了当前的主 库binlog的坐标和从库relay log的坐标。

4.start原来的从库

[root@localhost mysql]# service mysqld start
Starting MySQL.. SUCCESS!

5.编辑新从库的配置文件,给新从库配置一个不同于现在主从结构中服务器的server-id

[root@localhost mysql]# vi /mysqlsoft/mysql/my.cnf
server-id=3

6.启动新从库。从服务器使用其主信息存储库中的信息启动复制进程。

[root@localhost mysql]# service mysqld start
Starting MySQL.. SUCCESS!

但是原来的从库出现以下错误

2024-07-08T09:50:20.245669Z 5 [ERROR] Slave I/O for channel '': Got fatal error 1236 from master when reading data from binary  log: 'A slave with the same server_uuid/server_id as this slave has connected to the master; the first event 'binlog.000183'  at 1395, the last event read from '/mysqldata/mysql/binlog.000183' at 1848, the last byte read from  '/mysqldata/mysql/binlog.000183' at 1848.', Error_code: 1236


mysql> show variables like '%server%id%';
+----------------+--------------------------------------+
| Variable_name  | Value                                |
+----------------+--------------------------------------+
| server_id      | 2                                    |
| server_id_bits | 32                                   |
| server_uuid    | 1c5eb4fb-9479-11ec-8f21-005056a390e6 |
+----------------+--------------------------------------+
3 rows in set (0.00 sec)

mysql> show variables like '%server%id%';
+----------------+--------------------------------------+
| Variable_name  | Value                                |
+----------------+--------------------------------------+
| server_id      | 3                                    |
| server_id_bits | 32                                   |
| server_uuid    | 1c5eb4fb-9479-11ec-8f21-005056a390e6 |
+----------------+--------------------------------------+
3 rows in set (0.90 sec)

因为新从库是用原来的从库复制而来,所以在${data_dir}/auto.cnf中的server-uuid值是一样的,要处理该问题只需要删除新从库中的auto.cnf文件,就会自动创建和生成新的server-uuid值。

[root@localhost mysql]# ll auto.cnf
-rwxrwxr-x. 1 mysql mysql 56 Feb 23  2022 auto.cnf
[root@localhost mysql]# rm -rf auto.cnf
[root@localhost mysql]# ll auto.cnf
ls: cannot access auto.cnf: No such file or directory

[root@localhost mysql]# service mysqld start
Starting MySQL..... SUCCESS!
[root@localhost mysql]# ll auto.cnf
-rw-r-----. 1 mysql mysql 56 Jul  8 18:07 auto.cnf

mysql> show variables like '%server%id%';
+----------------+--------------------------------------+
| Variable_name  | Value                                |
+----------------+--------------------------------------+
| server_id      | 3                                    |
| server_id_bits | 32                                   |
| server_uuid    | f08c0957-3d11-11ef-bea6-005056b9a980 |
+----------------+--------------------------------------+
3 rows in set (0.00 sec)

验证主从同步
主库

mysql> create table t4(t_id int primary key not null,t_name varchar(30));
Query OK, 0 rows affected (0.02 sec)

mysql>  insert into t4 values(1,'jingyong');
Query OK, 1 row affected (0.01 sec)

mysql> select * from t4;
+------+----------+
| t_id | t_name   |
+------+----------+
|    1 | jingyong |
+------+----------+
1 row in set (0.00 sec)

原来从库

mysql> select * from t4;
+------+----------+
| t_id | t_name   |
+------+----------+
|    1 | jingyong |
+------+----------+
1 row in set (0.00 sec)

新从库

mysql> select * from t4;
+------+----------+
| t_id | t_name   |
+------+----------+
|    1 | jingyong |
+------+----------+
1 row in set (0.00 sec)
]]>
http://www.jydba.net/index.php/archives/3582/feed 0
MySQL基于二进制日志文件的主从复制 http://www.jydba.net/index.php/archives/3577 http://www.jydba.net/index.php/archives/3577#respond Mon, 08 Jul 2024 07:23:35 +0000 http://www.jydba.net/?p=3577 基于二进制日志文件位置的复制配置概述
本节描述了基于二进制日志文件定位方法的MySQL服务器之间的复制,其中MySQL实例作为主(数据库更改的源)将更新和更改作为“事件”写入二 进制日志。根据记录的数据库变化,二进制日志中的信息以不同的日志格式存储。从节点被配置为从主节点读取二进制日志,并在从节点的本地 数据库上执行二进制日志中的事件。

每个从服务器接收二进制日志全部内容的副本。从服务器负责决定应该执行二进制日志中的哪些语句。除非您另行指定,否则主二进制日志中的 所有事件都在从二进制日志上执行。如果需要,可以将从服务器配置为只处理适用于特定数据库或表的事件。不能将主服务器配置为只记录某些事件

每个从服务器保存二进制日志坐标的记录:从服务器读取和处理的文件中的文件名和位置。这意味着可以将多个从服务器连接到主服务器,并执 行同一二进制日志的不同部分。因为从服务器控制这个过程,所以可以在不影响主服务器操作的情况下连接和断开各个从服务器。另外,由于每 个从服务器都在二进制日志中记录当前位置,因此有可能断开连接,重新连接,然后恢复处理。

主服务器和每个从服务器必须配置一个唯一的ID(使用server-id选项)。此外,每个从服务器必须配置有关主主机名、日志文件名和该文件中的 位置的信息。这些细节可以在从服务器上的MySQL会话中使用CHANGE MASTER TO的语句来控制。详细信息存储在从服务器的主信息存储库中,主 信息存储库可以是文件也可以是表。

设置基于二进制日志文件位置的复制
本节介绍如何设置MySQL服务器以使用基于二进制日志文件位置的复制。设置复制有许多不同的方法,具体使用哪种方法取决于设置复制的方式 ,以及主数据库中是否已经有数据。

有一些通用任务对所有设置都是通用的:
.在主服务器上,必须启用二进制日志记录并配置唯一的服务器ID。这可能需要重新启动服务器。

.在要连接到主服务器的每个从服务器上,必须配置唯一的服务器ID。这可能需要重新启动服务器。

.还可以为从服务器创建一个单独的用户,以便在与主服务器进行身份验证时读取二进制日志进行复制时使用。

.在创建数据快照或启动复制过程之前,应该在主服务器上记录二进制日志中的当前位置。在配置从服务器时需要这些信息,以便从服务器知道 在二进制日志的哪个位置开始执行事件。

.如果您已经在主服务器上有数据,并且希望使用它来同步从服务器,则需要创建数据快照将数据复制到从服务器上。您使用的存储引擎会影响 您创建快照的方式。在使用MyISAM时,必须停止处理主服务器上的语句以获得读锁,然后获取其当前二进制日志坐标并转储其数据,然后才允许 主服务器继续执行语句。如果不停止语句的执行,数据转储和主状态信息将不匹配,导致不一致。如果你使用的是InnoDB,你不需要一个读锁, 一个足够长的事务来传输数据快照就足够了。

.为从服务器配置连接到主服务器的设置,例如主机名、登录凭据、二进制日志文件名和位置。

注意:设置过程中的某些步骤需要SUPER权限。如果您没有此权限,则可能无法启用复制。

配置完基本选项后,选择您的场景:
.为不包含数据的主服务器和从服务器的新安装设置复制。

.使用现有MySQL服务器上的数据建立一个新的主服务器的复制。

.要向现有复制环境添加复制从节点。

设置复制主配置
要将主机配置为使用基于二进制日志文件位置的复制,必须启用二进制日志记录并建立唯一的服务器ID。如果还没有这样做,则需要重新启动服 务器。

必须在主服务器上启用二进制日志记录,因为二进制日志是将更改从主服务器复制到从服务器的基础。如果没有在使用log-bin选项的主机上启 用二进制日志记录,则无法进行复制。

复制组中的每个服务器必须配置唯一的服务器ID。该ID用于标识组内的各个服务器,必须是1 ~2的32次方?1之间的正整数。你如何组织和选择数 字是你的选择。

要配置二进制日志和服务器ID选项,请关闭MySQL服务器并编辑my.cnf或my.ini文件。在配置文件的[mysqld]部分中,添加log-bin和server-id 选项。如果这些选项已经存在,但是被注释掉了,取消这些选项的注释,并根据您的需要更改它们。例如,要使用日志文件名前缀mysql-bin启 用二进制日志记录,并配置服务器ID为1,使用以下行:

[mysqld]
log-bin=mysql-bin
server-id=1

进行更改后,重新启动服务器。

注意:
以下选项对该过程有影响:
.如果省略server-id(或将其显式设置为默认值0),主服务器将拒绝来自从服务器的任何连接。

.为了在使用InnoDB事务的复制设置中获得最大的持久性和一致性,您应该在主my.cnf文件中使用innodb_flush_log_at_trx_commit=1和 sync_binlog=1。

.确保在复制主机上未启用跳过网络连接选项。如果禁用网络连接,则从端无法与主端通信,导致复制失败。

创建复制用户
每个从服务器使用一个MySQL用户名和密码连接到主服务器,所以在主服务器上必须有一个从服务器可以用来连接的用户帐户。任何帐户都可以 用于此操作,前提是该帐户已被授予REPLICATION SLAVE特权。您可以选择为每个从服务器创建一个不同的帐户,或者为每个从服务器使用相同 的帐户连接到主服务器。

虽然不必专门为复制创建帐户,但应该知道复制用户名和密码以明文形式存储在主信息存储库文件或表中。因此,您可能需要创建一个单独的帐 户,该帐户仅对复制过程具有特权,以尽量减少危及其他帐户的可能性。

要创建一个新帐户,请使用create USER。要向该帐户授予复制所需的特权,请使用grant语句。如果仅为复制目的创建帐户,则该帐户只需要 replication SLAVE特权。例如,要设置一个新用户repl,它可以从任何主机连接进行复制,请在主服务器上发出以下语句:

mysql> CREATE USER 'repl'@'%' IDENTIFIED BY 'slavepass';
Query OK, 0 rows affected (0.00 sec)

mysql> GRANT REPLICATION SLAVE ON *.* TO 'repl'@'%';
Query OK, 0 rows affected (0.01 sec)


[root@localhost mysql]# mysql -h 10.13.13.50 -P 3306 -urepl -pslavepass
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.26-log Source distribution

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
+--------------------+
1 row in set (0.00 sec)

mysql> exit

获取复制主二进制日志坐标
要配置从服务器以在正确的点启动复制过程,您需要主服务器的二进制日志中的当前坐标。

如果master之前没有启用二进制日志,那么SHOW MASTER STATUS或mysqldump –master-data显示的日志文件名和位置值都是空的。在这种情况 下,你需要在稍后指定从服务器的日志文件和位置时使用空字符串(“)和4。

如果之前主服务器已经有二进制日志记录,可以使用下面的过程来获取主服务器的二进制日志坐标:

警告
这个过程使用了FLUSH TABLES WITH READ LOCK,阻塞了InnoDB表的COMMIT操作。

1.通过命令行客户端连接到主服务器,在主服务器上启动会话,并通过执行FLUSH TABLES WITH READ LOCK语句来清空所有表和阻塞写语句。

mysql> FLUSH TABLES WITH READ LOCK;
Query OK, 0 rows affected (0.01 sec)

警告
让发出FLUSH TABLES语句的客户端继续运行,这样读锁仍然有效。如果退出客户端,锁将被释放。

2.在主服务器上的另一个会话中,使用SHOW MASTER STATUS语句来确定当前二进制日志文件名和位置:

[root@localhost ~]# mysql -uroot -ptest12345 mysql
mysql: [Warning] Using a password on the command line interface can be insecure.
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.7.26-log Source distribution

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> SHOW MASTER STATUS;
+---------------+----------+--------------+------------------+-------------------+
| File          | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+---------------+----------+--------------+------------------+-------------------+
| binlog.000183 |      326 |              |                  |                   |
+---------------+----------+--------------+------------------+-------------------+
1 row in set (0.00 sec)

“File”列显示日志文件的名称,“Position”列显示在文件中的位置。在此例中,二进制日志文件为binlog.000183,位置是326。记录这些值 。稍后在设置slave时需要它们。它们表示从服务器开始处理来自主服务器的新更新的复制坐标。

现在,您已经获得了所需的信息,使从服务器能够从正确位置的二进制日志开始读取,从而开始复制。

下一步取决于您是否在主服务器上已有数据。选择下列选项之一:
.如果在开始复制之前有需要与从服务器同步的现有数据,请保持客户端运行,以便锁保持在适当位置。这可以防止任何进一步的更改,以便复 制到从服务器的数据与主服务器保持同步。

.如果您正在建立一个新的主从复制组,您可以退出第一个会话以释放读锁

选择数据快照的方法
如果主数据库包含现有数据,则有必要将这些数据复制到每个从数据库。从主数据库转储数据有不同的方法。以下部分描述了可能的选项。

要选择适当的转储数据库的方法,请在以下选项中进行选择:
.使用mysqldump工具创建要复制的所有数据库的转储。这是推荐的方法,特别是在使用InnoDB时。

.如果数据库存储在二进制可移植文件中,则可以将原始数据文件复制到从服务器。这可能比使用mysqldump并在每个slave上导入文件更有效, 因为它跳过了在重播INSERT语句时更新索引的开销。对于InnoDB这样的存储引擎,不建议这样做。

使用mysqldump创建数据快照
使用mysqldump工具对现有主数据库中的数据创建快照。完成数据转储后,在启动复制进程之前将该数据导入从服务器。

下面的例子将所有数据库转储到一个名为dbdump.db的文件中,并包含–masterdata选项,它会自动在slave上添加CHANGE MASTER TO语句以启动 复制过程:
[root@localhost ~]# mysqldump -uroot -ptest12345 –all-databases –master-data > dbdump.db
mysqldump: [Warning] Using a password on the command line interface can be insecure.
[root@localhost ~]# ll dbdump.db
-rw-r–r–. 1 root root 4657877334 Jul 2 16:49 dbdump.db
[root@localhost ~]# du -sh dbdump.db
4.5G dbdump.db

注意:
如果不使用–master-data,则必须手动锁定单独会话中的所有表。

使用mysqldump工具可以从转储中排除某些数据库。如果要选择转储中包含哪些数据库,请不要使用–all-databases。选择以下选项之一:
.使用–ignore-table选项排除数据库中的所有表

.使用–atabases选项只命名那些您想要转储的数据库

要导入数据,可以将转储文件复制到从服务器,或者在远程连接到从服务器时从主服务器访问该文件。

[root@localhost ~]# mysql -h 10.13.13.43 -P 3306 -uroot -ptest1234 < dbdump.db
mysql: [Warning] Using a password on the command line interface can be insecure.

使用原始数据文件创建数据快照
本节描述如何使用组成数据库的原始文件创建数据快照。对于使用具有复杂缓存或日志算法的存储引擎的表,使用这种方法需要额外的步骤来生 成完美的“时间点”快照:初始复制命令可能会忽略缓存信息和日志更新,即使您已经获得了全局读锁。存储引擎如何响应这取决于它的崩溃恢 复能力。

如果你使用的是InnoDB表,你可以使用MySQL企业版的mysqlbackup命令备份组件以生成一致性快照。该命令记录从机上要使用的快照对应的日志 名称和偏移量。

如果主服务器和从服务器的ft_stopword_file、ft_min_word_len或ft_max_word_len的值不同,并且您正在复制具有全文索引的表,那么这种方 法也不能可靠地工作。

假设上述异常不适用于您的数据库,请使用冷备份技术获取InnoDB表的可靠二进制快照:慢速关闭MySQL服务器,然后手动复制数据文件。

当您的MySQL数据文件存在于单个文件系统中时,要创建MyISAM表的原始数据快照,您可以使用标准的文件复制工具,如cp或copy,远程复制工 具,如scp或rsync,归档工具,如zip或tar,或文件系统快照工具,如dump。如果只复制某些数据库,则只复制与这些表相关的文件。对于 InnoDB,所有数据库中的所有表都存储在系统表空间文件中,除非你启用了innodb_file_per_table选项。

复制不需要以下文件:
.mysql数据库相关文件。

.主信息存储库文件(如果使用)。

.主机的二进制日志文件。

.任何中继日志文件。

根据您是否使用InnoDB表,选择以下一种:

如果你使用的是InnoDB表,并且想要获得与原始数据快照最一致的结果,请在此过程中关闭主服务器,如下所示:
1.获取读锁并获取主库状态

mysql> FLUSH TABLES WITH READ LOCK;
mysql> SHOW MASTER STATUS;

2.在一个单独的会话中,关闭主服务器:

shell> mysqladmin shutdown

3.复制MySQL数据文件。下面的示例展示了实现此目的的常用方法。你只需要选择其中一个:

shell> tar cf /tmp/db.tar ./data
shell> zip -r /tmp/db.zip ./data
shell> rsync --recursive ./data /tmp/dbdata

4.重新启动主服务器。

如果您不使用InnoDB表,您可以从主服务器获取系统快照,而无需关闭服务器,如下所示:
1.获取读锁并获取主库状态

mysql> FLUSH TABLES WITH READ LOCK;
mysql> SHOW MASTER STATUS;

2.复制MySQL数据文件。下面的示例展示了实现此目的的常用方法。你只需要选择其中一个:

shell> tar cf /tmp/db.tar ./data
shell> zip -r /tmp/db.zip ./data
shell> rsync --recursive ./data /tmp/dbdata

3.在获取读锁的客户端,释放该锁:

mysql> UNLOCK TABLES;

创建了数据库的存档或副本之后,在启动从复制进程之前,将文件复制到每个从服务器。

设置复制从服务器
下面描述如何设置从服务器。在你继续之前,确保你有:
.用必要的配置属性配置MySQL主机。

.获取主库状态信息。

.在主服务器上,释放读锁。

mysql> UNLOCK TABLES;
Query OK, 0 rows affected (0.00 sec)

设置复制从服务器配置
每个复制从服务器必须有一个唯一的服务器ID。如果还没有这样做,从服务器设置的这一部分需要重新启动服务器。

如果从服务器ID尚未设置,或者当前值与您为主服务器选择的值冲突,请关闭从服务器并编辑配置文件的[mysqld]部分以指定唯一的服务器ID。 例如:

[root@localhost ~]# service mysqld stop
Shutting down MySQL. SUCCESS!

[mysql@localhost mysql]$ vi my.cnf
[mysqld]
server-id=2

进行更改后,重新启动服务器。

[root@localhost mysql]# service mysqld start
Starting MySQL... SUCCESS!

如果要设置多个从服务器,则每个从服务器必须具有唯一的服务器id值,该值与主服务器和任何其他从服务器的服务器id值不同。

注意:
如果省略server-id(或将其显式设置为默认值0),从服务器将拒绝连接到主服务器。

您不必在从服务器上启用二进制日志记录,就可以设置复制。但是,如果在从属服务器上启用二进制日志记录,则可以使用从属服务器的二进制 日志进行数据备份和崩溃恢复,还可以将从属服务器用作更复杂的复制拓扑的一部分。例如,这个从服务器充当其他从服务器的主库。

在从服务器上设置主配置
要设置从服务器与主服务器通信以进行复制,请使用必要的连接信息配置从服务器。为此,在从属服务器上执行以下语句,将选项值替换为与系 统相关的实际值:

mysql> CHANGE MASTER TO   MASTER_HOST='10.13.13.50',MASTER_USER='repl',MASTER_PASSWORD='slavepass',MASTER_LOG_FILE='binlog.000183',MASTER_LOG_POS=326 ;
Query OK, 0 rows affected, 2 warnings (0.14 sec)

注意:
复制不能使用Unix套接字文件。你必须能连接到主服务器MySQL服务器使用TCP/IP。CHANGE MASTER TO语句还有其他选项。例如,可以使用SSL设置安全复制。

启动从线程:

mysql> start slave;
Query OK, 0 rows affected (0.01 sec)

在执行此过程之后,从服务器连接到主服务器,并复制自拍摄快照以来在主服务器上发生的任何更新。

如果没有正确设置主服务器的server-id选项,则从服务器无法连接到主服务器。类似地,如果你没有为slave设置正确的server-id选项,你会 在slave的错误日志中得到以下错误:

Warning: You should set server-id to a non-0 value if master_host
is set; we will force server id to 2, but this MySQL server will
not act as a slave.

如果由于任何其他原因无法复制,您还可以在从属服务器的错误日志中找到错误消息。

从节点在其主服务器的信息存储库中存储了用户配置的关于主节点的信息。主服务器的信息存储库可以是文件的形式,也可以是表的形式,这由 –masterinfo- repository的值决定。当一个从节点使用–master-info-repository=FILE时,数据目录中会存储两个文件,分别名为 master.info和relay-log.info。相反,如果–master-info-repository=TABLE,则该信息保存在mysql数据库的master_slave_info表中。无论 哪种情况,都不要删除或编辑文件或表。始终使用CHANGE MASTER TO语句更改复制参数。从节点可以使用语句中指定的值自动更新状态文件。

注意:
主服务器的信息存储库的内容覆盖在命令行或my.cnf中指定的一些服务器选项。

一个主服务器的快照就可以满足多个从服务器的需求。要设置额外的从服务器,请使用相同的主服务器快照,并遵循上述过程的从服务器部分。

[root@localhost mysql]# pwd
/mysqldata/mysql
[root@localhost mysql]# ll master.info

[root@localhost mysql]# ll relay-log.info
-rw-r-----. 1 mysql mysql 62 Jul  4 17:50 relay-log.info

在主库中向表t9插入数据

mysql> select * from t9;
Empty set (0.00 sec)

mysql> desc t9;
+-------+---------+------+-----+---------+-------+
| Field | Type    | Null | Key | Default | Extra |
+-------+---------+------+-----+---------+-------+
| c1    | int(11) | YES  |     | NULL    |       |
+-------+---------+------+-----+---------+-------+
1 row in set (0.01 sec)

mysql> insert into t9 values(1),(2),(3);
Query OK, 3 rows affected (0.01 sec)
Records: 3  Duplicates: 0  Warnings: 0

mysql> commit;
Query OK, 0 rows affected (0.00 sec)

mysql> select * from t9;
+------+
| c1   |
+------+
|    1 |
|    2 |
|    3 |
+------+
3 rows in set (0.00 sec)

在从库上执行查询看数据是否已经同步过来

mysql> select * from t9;
+------+
| c1   |
+------+
|    1 |
|    2 |
|    3 |
+------+
3 rows in set (0.01 sec)

主库日志文件内容如下:

[root@localhost ~]# tail -f /msyqldata/mysql/mysql.err
tail: cannot open ‘/msyqldata/mysql/mysql.err’ for reading: No such file or directory
tail: no files remaining
[root@localhost ~]# tail -f /mysqldata/mysql/mysql.err
2024-07-04T08:46:10.847512Z 9 [Warning] IP address '10.13.13.43' could not be resolved: Temporary failure in name  resolution
2024-07-04T08:46:10.859391Z 9 [Note] Start binlog_dump to master_thread_id(9) slave_server(2), pos(binlog.000183, 326)

从库日志文件内容如下:

[root@localhost ~]# tail -f /msyqldata/mysql/mysql.err
2024-07-04T07:57:29.132449Z 0 [Note] InnoDB: Buffer pool(s) load completed at 240704 15:57:29
2024-07-04T08:03:48.366164Z 2 [Note] 'CHANGE MASTER TO FOR CHANNEL '' executed'. Previous state master_host='', master_port=  3306, master_log_file='binlog.000183', master_log_pos= 326, master_bind=''. New state master_host='10.13.13.50',  master_port= 3306, master_log_file='binlog.000183', master_log_pos= 326, master_bind=''.
2024-07-04T08:44:33.000217Z 0 [Note] InnoDB: page_cleaner: 1000ms intended loop took 1981125ms. The settings might not be  optimal. (flushed=0 and evicted=0, during the time.)
2024-07-04T08:46:01.839437Z 3 [Warning] Storing MySQL user name or password information in the master info repository is not  secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SLAVE; see  the 'START SLAVE Syntax' in the MySQL Manual for more information.
2024-07-04T08:46:01.840179Z 4 [Warning] Slave SQL for channel '': If a crash happens this configuration does not guarantee  that the relay log info will be consistent, Error_code: 0
2024-07-04T08:46:01.840283Z 4 [Note] Slave SQL thread for channel '' initialized, starting replication in log 'binlog.000183'  at position 326, relay log './localhost-relay-bin.000001' position: 4
2024-07-04T08:46:10.062847Z 3 [Note] Slave I/O thread for channel '': connected to master  'repl@10.13.13.50:3306',replication started in log 'binlog.000183' at position 326
]]>
http://www.jydba.net/index.php/archives/3577/feed 0
MySQL InnoDB数据字典操作的故障处理 http://www.jydba.net/index.php/archives/3574 http://www.jydba.net/index.php/archives/3574#respond Sat, 08 Jun 2024 07:12:10 +0000 http://www.jydba.net/?p=3574 InnoDB数据字典操作的故障处理
表定义的信息存储在.frm文件和InnoDB数据字典中。如果您移动了.frm文件,或者服务器在数据字典操作过程中崩溃,这些信息源可能会变得不一致。如果数据字典损坏或一致性问题导致无法启动InnoDB

由于孤儿表导致CREATE TABLE失败
数据字典不同步的一个症状是CREATE TABLE语句失败。如果发生这种情况,请查看服务器的错误日志。如果日志显示这个表已经存在于InnoDB内 部数据字典中,那么在InnoDB表空间文件中就有一个孤儿表,没有相应的.frm文件。错误信息看起来像这样:

InnoDB: Error: table test/parent already exists in InnoDB internal
InnoDB: data dictionary. Have you deleted the .frm file
InnoDB: and not used DROP TABLE? Have you used DROP DATABASE
InnoDB: for InnoDB tables in MySQL version < = 3.23.43?
InnoDB: See the Restrictions section of the InnoDB manual.
InnoDB: You can drop the orphaned table inside InnoDB by
InnoDB: creating an InnoDB table with the same name in another
InnoDB: database and moving the .frm file to the current database.
InnoDB: Then MySQL thinks the table exists, and DROP TABLE will
InnoDB: succeed.

您可以按照错误消息中给出的说明删除孤立表。如果你仍然不能成功使用DROP TABLE,问题可能是由于mysql客户端的名称完成。要解决这个问 题,使用--skip-auto-rehash选项启动mysql客户端并再次尝试DROP TABLE表。(在名称完成的情况下,mysql试图构建一个表名列表,当存在上 述问题时,该列表会失败。)

无法打开文件错误
数据字典不同步的另一个症状是MySQL打印无法打开InnoDB文件的错误:

ERROR 1016: Can't open file: 'child2.ibd'. (errno: 1)

在错误日志中,您可以找到这样的消息:

InnoDB: Cannot find table test/child2 from the internal data dictionary
InnoDB: of InnoDB though the .frm file for the table exists. Maybe you
InnoDB: have deleted and recreated InnoDB data files but have forgotten
InnoDB: to delete the corresponding .frm files of InnoDB tables?

这意味着在InnoDB中存在一个没有相应表的孤儿.frm文件。您可以通过手动删除.frm文件来删除它。

孤立中间表
如果MySQL在执行就地ALTER TABLE操作(ALGORITHM=INPLACE)的过程中退出,可能会留下一个孤立的中间表,占用系统空间。另外,在空的通用 表空间中存在孤立的中间表可以防止删除通用表空间。本节描述如何识别和删除孤立中间表。

中间表名以#sql-ib前缀开始(例如,#sql-ib87-856498050)。附带的.frm文件有一个#sql-*前缀,并且命名不同(例如,#sql-36ab_2.frm)。

要识别系统中的孤儿中间表,可以查询INFORMATION_SCHEMA.INNODB_SYS_TABLES。查找以#sql开头的表名。如果原始表驻留在file-per-table的 表空间中,对于孤儿中间表的表空间文件(#sql-*.ibd文件)应该在数据库目录中可见。

SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES WHERE NAME LIKE '%#sql%';

删除孤立中间表的步骤如下:
1.在数据库目录下,重命名#sql-*.frm文件,以匹配孤立中间表的基名:

#mv #sql-36ab_2.frm #sql-ib87-856498050.frm

注意:
如果没有.frm文件,您可以重新创建它。.frm文件必须具有与孤立中间表相同的表模式(它必须具有相同的列和索引),并且必须放置在孤立中间 表的数据库目录中。

2.通过drop table语句删除孤立的中间表,例如在表名前加上#mysql50#,并将表名括起来:

mysql> DROP TABLE `#mysql50##sql-ib87-856498050`;

#mysql50#前缀告诉MySQL忽略在MySQL5.1中引入的文件名安全编码。需要用反引号括起表名,以便对带有特殊字符(如“#”)的表名执行SQL语句 。

注意:
如果在将表移动到另一个表空间的就地ALTER TABLE操作期间发生崩溃,则恢复进程将表恢复到其原始位置,但在目标表空间中留下一个孤立的 中间表。

孤立临时表
如果MySQL在执行复制表的ALTER TABLE操作(ALGORITHM=COPY)时退出,可能会留下一个孤立的临时表,占用系统空间。另外,在一个空的通用表 空间中存在孤立临时表可以防止删除通用表空间。本节介绍如何识别和删除孤立临时表。

孤立临时表名以#sql-开头(例如,#sql-540_3)。附带的.frm文件具有与孤立临时表相同的基名。

注意:
如果没有.frm文件,您可以重新创建它。.frm文件必须具有与孤立临时表相同的表模式(它必须具有相同的列和索引),并且必须放置在孤立临时 表的数据库目录中

要识别系统上的孤立临时表,可以进行查询INFORMATION_SCHEMA.INNODB_SYS_TABLES。查找以#sql开头的表名。如果原始表驻留在file-per- table表空间中,则孤立临时表的表空间文件(#sql-*.ibd文件),在数据库目录中应该可以看到。

SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES WHERE NAME LIKE '%#sql%';

要删除孤立临时表,可以通过发出drop table语句删除表,例如在表名前加上#mysql50#,并将表名括起来:

mysql> DROP TABLE `#mysql50##sql-540_3`;

#mysql50#前缀告诉MySQL忽略在MySQL5.1中引入的文件名安全编码。需要用反引号括起表名,以便对带有特殊字符(如“#”)的表名执行SQL语句 。

表空间不存在
启用innodb_file_per_table后,如果.frm或.ibd文件(或两者)丢失,可能会出现以下消息:

InnoDB: in InnoDB data dictionary has tablespace id N,
InnoDB: but tablespace with that id or name does not exist. Have
InnoDB: you deleted or moved .ibd files?
InnoDB: This may also be a table created with CREATE TEMPORARY TABLE
InnoDB: whose .ibd and .frm files MySQL automatically removed, but the
InnoDB: table still exists in the InnoDB internal data dictionary.

如果出现这种情况,请尝试以下步骤来解决问题:
1.在其他数据库目录中创建一个匹配的.frm文件,并将其复制到孤立表所在的数据库目录中。

2.对原始表发出DROP TABLE命令。这样就可以成功地删除表,InnoDB应该会在错误日志中打印一个.ibd文件丢失的警告。

恢复孤立的File-Per-Table的ibd文件
这个过程描述了如何将孤立的file-per-table的ibd文件恢复到另一个MySQL实例。如果系统表空间丢失或不可恢复,并且希望在新的MySQL实例 上恢复.idb文件备份,则可以使用此过程。

通用表空间.ibd文件不支持此过程。

该过程假设您只有.ibd文件备份,您将恢复到最初创建.idb文件的MySQL的相同版本,并且.idb文件备份是干净的。
1.在新的MySQL实例上,在同名的数据库中重新创建表。

mysql> CREATE DATABASE test;
mysql> USE test;
mysql>  CREATE TABLE `user` (
  `uid` int(11) NOT NULL AUTO_INCREMENT,
  `data` json DEFAULT NULL,
  PRIMARY KEY (`uid`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4

2.丢弃新创建表的表空间

mysql> ALTER TABLE test.user DISCARD TABLESPACE;

3.将孤立.idb文件从备份目录复制到新的数据库目录。

scp root@10.13.13.25:/mysqldata/mysql/test/user.ibd /mysqldata/mysql/test/

4.确保.ibd文件具有必要的文件权限。

[root@localhost test]# chown -R mysql:mysql user.ibd
[root@localhost test]# chmod 660 user.ibd

5.导入孤立.ibd文件。发出一个警告,表示InnoDB将尝试在没有模式验证的情况下导入文件。

mysql> ALTER TABLE test.user IMPORT TABLESPACE; SHOW WARNINGS;
Query OK, 0 rows affected, 1 warning (0.18 sec)

+---------+------ +----------------------------------------------------------------------------------------------------------------------------- --------------+
| Level   | Code | Message                                                                                                                                    |
+---------+------ +----------------------------------------------------------------------------------------------------------------------------- --------------+
| Warning | 1810 | InnoDB: IO Read error: (2, No such file or directory) Error opening './test/user.cfg', will attempt to  import without schema verification |
+---------+------ +----------------------------------------------------------------------------------------------------------------------------- --------------+
1 row in set (0.00 sec)

6.查询表以验证.ibd文件是否已成功恢复。

mysql> select * from test.user;
+-----+------------------------------------------------------------------------------+
| uid | data                                                                         |
+-----+------------------------------------------------------------------------------+
|   1 | {"mail": "jiangchengyao@gmail.com", "name": "David", "address": "Shangahai"} |
|   2 | {"mail": "amy@gmail.com", "name": "Amy"}                                     |
+-----+------------------------------------------------------------------------------+
2 rows in set (0.01 sec)
]]>
http://www.jydba.net/index.php/archives/3574/feed 0
MySQL InnoDB memcached插件 http://www.jydba.net/index.php/archives/3570 http://www.jydba.net/index.php/archives/3570#respond Wed, 05 Jun 2024 00:46:39 +0000 http://www.jydba.net/?p=3570 InnoDB memcached插件
InnoDB memcached插件(daemon_memcached)提供了一个集成的memcached守护进程,可以自动存储和检索InnoDB表中的数据,将MySQL服务器变成一个快速的“key value store”。您可以使用简单的get、set和incr操作来避免与SQL解析和构造查询优化计划相关的性能开销,而不是在SQL 中制定查询。您还可以通过SQL访问相同的InnoDB表,以获得便利性,复杂的查询,批量操作以及传统数据库软件的其他优势。

这个“nosql-style”的接口使用memcached API来加速数据库操作,让InnoDB使用其缓冲池机制处理内存缓存。在InnoDB表中,通过memcached操作(如add、set和incr)修改的数据被存储在磁盘中。

InnoDB memcached插件的好处
下面概述daemon_memcached插件的优点。InnoDB表和memcached的组合比单独使用任何一个都有优势。
.直接访问InnoDB存储引擎避免了SQL的解析和规划开销。

.在与MySQL服务器相同的进程空间中运行memcached可以避免来回传递请求的网络开销。

.使用memcached协议写入的数据被透明地写入到InnoDB表中,而不需要经过MySQL SQL层。更新非关键数据时,可以通过控制写频率来获得更高的原始性能。

.通过memcached协议请求的数据可以透明地从InnoDB表中查询,而无需经过MySQL SQL层。

.对相同数据的后续请求由InnoDB缓冲池提供。缓冲池处理内存中的缓存。您可以使用InnoDB配置选项来调优数据密集型操作的性能。

.根据应用程序的类型,数据可以是非结构化的,也可以是结构化的。您可以为数据创建一个新表,也可以使用现有的表。

.InnoDB可以将多个列值组合和分解为单个memcached项值,从而减少应用程序中需要解析和连接字符串的数量。例如,你可以将字符串值2|4| 6|8存储在memcached缓存中,并让InnoDB根据分隔符分割该值,然后将结果存储在4个数值列中。

.内存和磁盘之间的传输是自动处理的,简化了应用程序逻辑。

.数据存储在MySQL数据库中,以防止崩溃、中断和损坏。

.你可以通过SQL访问底层的InnoDB表,用于报告、分析、即席查询、批量加载、多步事务计算、集合操作(如union和intersection),以及其他适合SQL表现力和灵活性的操作。

.可以在主服务器上使用daemon_memcached插件并结合MySQL复制来确保高可用性。

.memcached与MySQL的集成提供了一种持久化内存数据的方法,这样您就可以将它用于更重要的数据类型。您可以在应用程序中使用更多的add、incr和类似的写操作,而不必担心数据可能丢失。您可以停止和启动memcached服务器,而不会丢失对缓存数据的更新。为了防止意外的中断,你可以利用InnoDB的崩溃恢复、复制和备份功能。

.InnoDB快速主键查找的方式非常适合memcached的单元素查询。daemon_memcached插件使用的直接、低级数据库访问路径对于键值查找来说比等价的SQL查询要高效得多。

.memcached的序列化特性可以将复杂的数据结构、二进制文件甚至代码块转换为可存储的字符串,它提供了一种将此类对象放入数据库的简单方 法。

.因为可以通过SQL访问底层数据,所以可以生成报告、跨多个键进行搜索或更新,并在memcached数据上调用AVG()和MAX()等函数。使用 memcached所有这些操作都是昂贵或复杂的。

.不需要在启动时手动将数据加载到memcached中。当应用程序请求特定的键时,值会自动从数据库中检索出来,并使用InnoDB缓冲池缓存在内存 中。

.因为memcached消耗的CPU相对较少,而且它的内存占用很容易控制,所以它可以在同一个系统上与MySQL实例一起轻松运行。

.因为数据一致性是由常规InnoDB表使用的机制强制执行的,所以你不必担心memcached数据过期,或者在缺少键的情况下查询数据库的回滚逻辑 。

InnoDB memcached架构
InnoDB memcached插件将memcached作为一个MySQL插件守护进程来实现直接访问InnoDB存储引擎,绕过MySQL SQL层。

daemon_memcached插件的特性:
.Memcached作为mysqld的守护程序插件。mysqld和memcached都运行在相同的进程空间中,对数据的访问延迟非常低。

.直接访问InnoDB表,绕过SQL解析器,优化器,甚至Handler API层。

.标准memcached协议,包括基于文本的协议和二进制协议。daemon_memcached插件通过memcapable命令的所有55个兼容性测试。

.多列支持。您可以将多个列映射到键/值存储的“值”部分,列值由用户指定的分隔符分隔。

.默认情况下,memcached协议用于直接向InnoDB读取和写入数据,让MySQL使用InnoDB缓冲池管理内存缓存。默认设置代表了高可靠性和数据库 应用程序最少意外的组合。例如,默认设置避免在数据库端提交未提交的数据,或者为memcached get请求返回过时的数据。

.高级用户可以将系统配置为传统的memcached服务器,所有数据只缓存在memcached引擎(内存缓存)中,或者使用“memcached引擎”(内存缓存) 和InnoDB memcached引擎(InnoDB作为后端持久存储)的组合。

.通过innodb_api_bk_commit_interval、daemon_memcached_r_batch_size和daemon_memcached_w_batch_size配置选项来控制数据在InnoDB和 memcached操作之间来回传递的频率。批量大小选项的默认值为1,表示最大可靠性。

.通过daemon_memcached_option配置参数指定memcached选项的能力。例如,您可以更改memcached监听的端口,减少最大同时连接数,更改键值 对的最大内存大小,或打开错误日志的调试消息。

.innodb_api_trx_level配置选项控制memcached处理的查询的事务隔离级别。尽管memcached没有事务的概念,但是您可以使用这个选项来控制 memcached对daemon_memcached插件使用的表发出的SQL语句所引起的更改的处理速度。默认情况下,innodb_api_trx_level设置为READ UNCOMMITTED。

.innodb_api_enable_mdl选项可以用来在MySQL级别锁定表,这样映射的表就不能被DDL通过SQL接口删除或修改。如果没有锁,表可以从MySQL层 删除,但仍然保留在InnoDB存储中,直到memcached或其他用户停止使用它。MDL代表“元数据锁定”。

InnoDB memcached与传统memcached的区别
您可能已经熟悉在MySQL中使用memcached,如使用MySQL与memcached中所述。本节描述集成的InnoDB memcached插件与传统memcached的不同之 处。
.安装: memcached库随MySQL服务器一起提供,使得安装和设置相对容易。安装过程中需要运行innodb_memcached_config.sql脚本创建一个 demo_test表供memcached使用,发出INSTALL PLUGIN语句以启用daemon_memcached插件,并将所需的memcached选项添加到MySQL配置文件或启动 脚本中。对于memcp、memcat和memcapable等其他实用程序,您可能仍然需要安装传统的memcached发行版。

.部署:对于传统的memcached,通常会运行大量低容量的memcached服务器。但是,典型的daemon_memcached插件部署只涉及少量已经在运行 MySQL的中等或高性能服务器。这种配置的好处是提高了单个数据库服务器的效率,而不是利用未使用的内存或在大量服务器上分布查找。在默 认配置中,memcached只使用很少的内存,而内存中的查找是从InnoDB缓冲池中提供的,它会自动缓存最新和频繁使用的数据。与传统的MySQL服 务器实例一样,保持innodb_buffer_pool_size配置选项的值尽可能高(不引起操作系统级别的分页),以便尽可能多的工作在内存中.终止执行。

.过期:默认情况下(即使用innodb_only缓存策略),总是返回InnoDB表中最新的数据,因此过期选项没有实际作用。如果将缓存策略更改为缓存 或仅缓存,则过期选项照常工作,但是如果在从内存缓存过期之前在基础表中更新了请求的数据,则请求的数据可能会过期。

.命名空间:memcached就像一个大目录,您可以为文件提供带有前缀和后缀的详细名称,以防止文件发生冲突。daemon_memcached插件允许对键 使用类似的命名约定,但增加了一点。Key名称格式为@@table_id.key.table_id被解码为引用一个特定的表,使用来自 innodb_memcache.containers表的映射数据。在指定的表中查找或写入键。

@@符号只适用于get、add和set函数的单独调用,而不适用于诸如incr或delete之类的其他调用。要为会话中的后续memcached操作指定一个默认 表,可以使用带table_id的@@符号执行get请求,但不带key部分。例如:

get @@table_id

后续的get、set、incr、delete等操作将使用innodb_memcache.containers.name列中table_id指定的表。

.哈希和分布: 默认配置使用innodb_only缓存策略,适合传统的部署配置,即所有数据都在所有服务器上可用,例如一组复制从服务器。

如果像在分片配置中那样物理地划分数据,就可以在运行daemon_memcached插件的多台机器上划分数据,并使用传统的memcached散列机制将请 求路由到特定的机器上。在MySQL端,通常通过add请求向memcached插入所有数据,以便将适当的值存储在适当的服务器上的数据库中。

.内存使用:默认情况下(在innodb_only缓存策略下),memcached协议在InnoDB表之间来回传递信息,InnoDB缓冲池处理内存查找,而不是 memcached内存使用的增长和收缩。memcached端使用的内存相对较少。

如果将缓存策略切换为缓存或仅缓存,则适用memcached内存使用的常规规则。用于memcached数据值的内存是按“slab”分配的。您可以控制 slab大小和用于memcached的最大内存。无论采用哪种方式,都可以使用熟悉的统计系统(例如,通过telnet会话通过标准协议访问)监视daemon_memcached插件并对其进行故障排除。额 外的实用程序不包含在daemon_memcached插件中。您可以使用memcached-tool脚本来安装完整的memcached发行版。

线程使用:MySQL线程和memcached线程共存于同一服务器上。操作系统对线程施加的限制适用于线程总数。

日志使用:由于memcached守护进程与MySQL服务器一起运行并写入stderr,因此用于记录日志的-v、-vv和-vvv选项将输出写入MySQL错误日志。

memcached操作:熟悉的memcached操作,如get、set、add和delete都是可用的。序列化(即表示复杂数据结构的确切字符串格式)取决于语言接口 。

使用memcached作为MySQL前端:这是InnoDB memcached插件的主要目的。集成的memcached守护进程提高了应用程序的性能,并且让InnoDB处理内 存和磁盘之间的数据传输简化了应用程序的逻辑。

工具:MySQL服务器包括libmemcached库,但不包括其他命令行实用程序。要使用memcp、memcat和memcapable等命令,请安装完整的memcached发 行版。当memm和memflush从缓存中删除项时,这些项也会从底层InnoDB表中删除。

编程接口:可以使用所有支持的语言(C和c++、Java、Perl、Python、PHP和Ruby),通过daemon_memcached插件访问MySQL服务器。与传统的 memcached服务器一样指定服务器主机名和端口。默认情况下,daemon_memcached插件在端口11211上监听。可以同时使用文本和二进制协议。您 可以在运行时自定义memcached函数的行为。序列化(即表示复杂数据结构的确切字符串格式)取决于语言接口。

常见问题:MySQL为传统的memcached提供了广泛的常见问题解答。常见问题解答是最适用的,除了使用InnoDB表作为memcached数据的存储介质意 味着您可以将memcached用于比以前更写密集型的应用程序,而不是作为只读缓存。

设置InnoDB memcached插件
下面描述如何在MySQL服务器上设置daemon_memcached插件。因为memcached守护进程与MySQL服务器紧密集成,以避免网络流量并最小化延迟, 所以您可以在使用此特性的每个MySQL实例上执行此过程。

先决条件
.daemon_memcached插件仅支持Linux、Solaris和OS X平台。不支持其他操作系统。

.当从源代码构建MySQL时,您必须使用-DWITH_INNODB_MEMCACHED=ON进行构建。这个构建选项在MySQL插件目录(plugin_dir)中生成两个共享库 ,用于运行daemon_memcached插件:
.libmemcached.so:MySQL的memcached守护进程插件。

.innodb_engine.so:memcached的一个InnoDB API插件。

.Libevent必须安装。
.如果您没有从源代码构建MySQL,则libevent库不会包含在您的安装中。请按照操作系统的安装方法安装libevent 1.4.12及以上版本。例如, 根据不同的操作系统,你可能会使用apt-get、yum或port install。例如,在Ubuntu Linux中,使用:

sudo apt-get install libevent-dev

.如果您从源代码版本安装MySQL,则libevent 1.4.12与软件包捆绑在一起,位于MySQL源代码目录的顶层。如果您使用的是捆绑版本的 libevent,则无需执行任何操作。如果您想使用本地系统版本的libevent,则必须将-DWITH_LIBEVENT build选项设置为system或yes来构建 MySQL。

安装和配置InnoDB memcached插件
1.运行位于MYSQL_HOME/share中的innodb_memcached_config.sql配置脚本配置daemon_memcached插件,使其可以与InnoDB表交互。这个脚本安 装了innodb_memcache数据库,包含三个必需的表(cache_policies, config_options和containers)。它还将demo_test样例表安装到test数据库 中。

mysql> source /mysqlsoft/mysql/share/innodb_memcached_config.sql
Query OK, 1 row affected (0.01 sec)

Database changed
Query OK, 0 rows affected (0.08 sec)

Query OK, 0 rows affected (0.09 sec)

Query OK, 0 rows affected (0.09 sec)

Query OK, 1 row affected (0.02 sec)

Query OK, 1 row affected (0.01 sec)

Query OK, 1 row affected (0.03 sec)

Query OK, 1 row affected (0.01 sec)

Query OK, 1 row affected, 1 warning (0.04 sec)

Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
Query OK, 0 rows affected (0.07 sec)

Query OK, 1 row affected (0.03 sec)

执行innodb_memcached_config.sql脚本是一次性操作。如果以后卸载并重新安装daemon_memcached插件,这些表将保留在原来的位置。

mysql> use innodb_memcache
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> show tables;
+---------------------------+
| Tables_in_innodb_memcache |
+---------------------------+
| cache_policies            |
| config_options            |
| containers                |
+---------------------------+
3 rows in set (0.00 sec)


mysql> use test
Database changed
mysql> show tables;
+----------------+
| Tables_in_test |
+----------------+
| demo_test      |
+----------------+
1 row in set (0.00 sec)

在这些表中,innodb_memcache.containers表是最重要的。containers表中的条目提供了到InnoDB表列的映射。daemon_memcached插件使用的每 个InnoDB表都需要在containers表中添加一个条目。

innodb_memcached_config.sql脚本在容器表中插入单个条目,该条目为demo_test表提供映射。它还将一行数据插入demo_test表中。该数据允 许您在安装完成后立即验证安装。

mysql> select * from innodb_memcache.containers\G;
*************************** 1. row ***************************
                  name: aaa
             db_schema: test
              db_table: demo_test
           key_columns: c1
         value_columns: c2
                 flags: c3
            cas_column: c4
    expire_time_column: c5
unique_idx_name_on_key: PRIMARY
1 row in set (0.00 sec)

ERROR:
No query specified

mysql> select * from test.demo_test;
+----+--------------+------+------+------+
| c1 | c2           | c3   | c4   | c5   |
+----+--------------+------+------+------+
| AA | HELLO, HELLO |    8 |    0 |    0 |
+----+--------------+------+------+------+
1 row in set (0.00 sec)



mysql> INSTALL PLUGIN daemon_memcached soname "libmemcached.so";
Query OK, 0 rows affected (0.18 sec)

一旦安装了这个插件,每次MySQL服务器重新启动时,它就会自动激活。

验证InnoDB和memcached的安装
要验证daemon_memcached插件设置,请使用telnet会话发出memcached命令。默认情况下,memcached守护进程监听端口11211。

[root@localhost /]# netstat -ltnp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:11211           0.0.0.0:*               LISTEN      998/mysqld
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      1630/sshd
tcp6       0      0 :::3306                 :::*                    LISTEN      998/mysqld
tcp6       0      0 :::11211                :::*                    LISTEN      998/mysqld
tcp6       0      0 :::22                   :::*                    LISTEN      1630/sshd

1.从test.demo_test表中检索数据。demo_test表中的单行数据的键值为AA。

mysql> select * from test.demo_test;
+----+--------------+------+------+------+
| c1 | c2           | c3   | c4   | c5   |
+----+--------------+------+------+------+
| AA | HELLO, HELLO |    8 |    0 |    0 |
+----+--------------+------+------+------+
1 row in set (0.00 sec)


[root@localhost /]# telnet localhost 11211
Trying ::1...
Connected to localhost.
Escape character is '^]'.
get AA
VALUE AA 8 12
HELLO, HELLO
END

2.使用set命令插入数据。

set BB 10 0 16
GOODBYE, GOODBYE
STORED

说明:
.set命令用来存储值

.BB 是键

.10是操作标志;被memcached忽略,但可以被客户端用来表示任何类型的信息;如果未使用,则指定0

.0为过期时间(TTL);如果未使用,则指定0

.16是所提供值块的长度,以字节为单位

.GOODBYE, GOODBYE是存储的值

3.通过连接MySQL服务器,查询test.demo_test表,验证插入的数据是否存储在MySQL中。

mysql> select * from test.demo_test;
+----+------------------+------+------+------+
| c1 | c2               | c3   | c4   | c5   |
+----+------------------+------+------+------+
| AA | HELLO, HELLO     |    8 |    0 |    0 |
| BB | GOODBYE, GOODBYE |   10 |    1 |    0 |
+----+------------------+------+------+------+
2 rows in set (0.00 sec)

4.返回到telnet会话并检索您先前使用BB键插入的数据。

get BB
VALUE BB 10 16
GOODBYE, GOODBYE
END

如果关闭MySQL服务器,同时也关闭了集成的memcached服务器,那么进一步访问memcached数据的尝试将会失败,并出现连接错误。通常, memcached数据在此时也会消失,当memcached重启时,需要应用程序逻辑将数据加载回内存。但是,InnoDB memcached插件会自动完成这个过
程。

重新启动MySQL时,get操作再次返回存储在早期memcached会话中的键/值对。当一个键被请求并且相关的值不在内存缓存中时,该值将自动从 MySQL test.demo_test表中查询。

创建新的表和列映射
这个例子展示了如何使用daemon_memcached插件设置自己的InnoDB表。
1.创建一个InnoDB表。表必须有一个具有唯一索引的键列。city表的键列是city_id,它被定义为主键。该表还必须包括用于标记、cas和过期值 的列。可能有一个或多个值列。城市表有三个值列(名称、州、国家)。

mysql> create table test.city (
    -> city_id varchar(32),
    -> name varchar(1024),
    -> state varchar(1024),
    -> country varchar(1024),
    -> flags int,
    -> cas bigint unsigned,
    -> expiry int,
    -> primary key(city_id)
    -> ) engine=innodb;
Query OK, 0 rows affected (0.08 sec)

2.在innodb_memcache中添加一个表项。以便daemon_memcached插件知道如何访问InnoDB表。该表项必须满足innodb_memcache.containers表定义。

mysql> desc innodb_memcache.containers;
+------------------------+--------------+------+-----+---------+-------+
| Field                  | Type         | Null | Key | Default | Extra |
+------------------------+--------------+------+-----+---------+-------+
| name                   | varchar(50)  | NO   | PRI | NULL    |       |
| db_schema              | varchar(250) | NO   |     | NULL    |       |
| db_table               | varchar(250) | NO   |     | NULL    |       |
| key_columns            | varchar(250) | NO   |     | NULL    |       |
| value_columns          | varchar(250) | YES  |     | NULL    |       |
| flags                  | varchar(250) | NO   |     | 0       |       |
| cas_column             | varchar(250) | YES  |     | NULL    |       |
| expire_time_column     | varchar(250) | YES  |     | NULL    |       |
| unique_idx_name_on_key | varchar(250) | NO   |     | NULL    |       |
+------------------------+--------------+------+-----+---------+-------+
9 rows in set (0.00 sec)

city表的innodb_memcache.containers表项定义为:

mysql> insert into innodb_memcache.containers (
    -> name, db_schema, db_table, key_columns, value_columns,
    -> flags, cas_column, expire_time_column, unique_idx_name_on_key)
    -> values ('default', 'test', 'city', 'city_id', 'name|state|country',
    -> 'flags','cas','expiry','primary');
Query OK, 1 row affected (0.04 sec)

.default指定给containers.name列以将ctiy表配置为默认值,InnoDB表与daemon_memcached插件一起使用。

.多个InnoDB表列(name, state, country)被映射containers.value_columns使用” | “分隔符。

.innodb_memcache.containers的flags、cas_column和expire_time_column字段在使用daemon_memcached插件的应用程序中通常不重要。但是, 每个表都需要一个指定的InnoDB表列。在插入数据时,如果这些列未使用,则将它们指定为0。

3.更新innodb_memcache.containers表后,重新启动daemon_memcache插件以应用更改。

mysql> UNINSTALL PLUGIN daemon_memcached;
Query OK, 0 rows affected (2.01 sec)

mysql> INSTALL PLUGIN daemon_memcached soname "libmemcached.so";
Query OK, 0 rows affected (0.10 sec)

4.通过telnet,使用memcached set命令向city表插入数据。

[root@localhost ~]# telnet localhost 11211
Trying ::1...
Connected to localhost.
Escape character is '^]'.
set B 0 0 22
BANGALORE|BANGALORE|IN
STORED

5.使用MySQL查询test.city表,以验证插入的数据是否已存储。

mysql> select * from test.city;
+---------+-----------+-----------+---------+-------+------+--------+
| city_id | name      | state     | country | flags | cas  | expiry |
+---------+-----------+-----------+---------+-------+------+--------+
| B       | BANGALORE | BANGALORE | IN      |     0 |    2 |      0 |
+---------+-----------+-----------+---------+-------+------+--------+
1 row in set (0.00 sec)

6.使用MySQL,向test.city表插入额外的数据。

mysql> insert into city values ('c','chennai','tamil nadu','in', 0, 0 ,0);
Query OK, 1 row affected (0.02 sec)

mysql> insert into city values ('d','delhi','delhi','in', 0, 0, 0);
Query OK, 1 row affected (0.00 sec)

mysql> insert into city values ('h','hyderabad','telangana','in', 0, 0, 0);

Query OK, 1 row affected (0.05 sec)

mysql> insert into city values ('m','mumbai','maharashtra','in', 0, 0, 0);
Query OK, 1 row affected (0.02 sec)

7.使用telnet,发出memcached get命令来检索使用MySQL插入的数据。

get H
VALUE H 0 22
hyderabad|telangana|in
END
get C
VALUE C 0 21
chennai|tamil nadu|in
END
]]>
http://www.jydba.net/index.php/archives/3570/feed 0
MySQL InnoDB和MySQL复制 http://www.jydba.net/index.php/archives/3567 http://www.jydba.net/index.php/archives/3567#respond Wed, 05 Jun 2024 00:39:57 +0000 http://www.jydba.net/?p=3567 InnoDB和MySQL复制
MySQL复制适用于InnoDB表和MyISAM表。当从节点上的存储引擎与主节点上的原始存储引擎不同时,也可以使用复制。例如,用户可以将对主节点上的InnoDB表的修改复制到从节点上的MyISAM表。

在主服务器上失败的事务完全不会影响复制。MySQL复制基于二进制日志,MySQL在其中写入修改数据的SQL语句。一个失败的事务(例如,因为违反了外键,或者因为回滚)不会被写入二进制日志,因此它不会被发送到从服务器。

复制和级联
只有当共享外键关系的表同时在主从上使用InnoDB时,主上InnoDB表的级联操作才会在从上复制。无论使用基于语句的复制还是基于行的复制,都是如此。假设已经启动了复制,然后使用下面的create TABLE语句在master上创建了两个表:

CREATE TABLE fc1 (
i INT PRIMARY KEY,
j INT
) ENGINE = InnoDB;

CREATE TABLE fc2 (
m INT PRIMARY KEY,
n INT,
FOREIGN KEY ni (n) REFERENCES fc1 (i)
ON DELETE CASCADE
) ENGINE = InnoDB;

假设从服务器没有启用InnoDB支持。如果是这种情况,那么从节点上的表会被创建,但是它们使用MyISAM存储引擎,并且外键选项会被忽略。现在我们向master上的表中插入一些行:

master> INSERT INTO fc1 VALUES (1, 1), (2, 2);
Query OK, 2 rows affected (0.09 sec)
Records: 2 Duplicates: 0 Warnings: 0
master> INSERT INTO fc2 VALUES (1, 1), (2, 2), (3, 1);
Query OK, 3 rows affected (0.19 sec)
Records: 3 Duplicates: 0 Warnings: 0

此时,在主节点和从节点上,表fc1包含2行,表fc2包含3行,如下所示:

master> SELECT * FROM fc1;
+---+------+
| i | j |
+---+------+
| 1 | 1 |
| 2 | 2 |
+---+------+
2 rows in set (0.00 sec)
master> SELECT * FROM fc2;
+---+------+
| m | n |
+---+------+
| 1 | 1 |
| 2 | 2 |
| 3 | 1 |
+---+------+
3 rows in set (0.00 sec)
slave> SELECT * FROM fc1;
+---+------+
| i | j |
+---+------+
| 1 | 1 |
| 2 | 2 |
+---+------+
2 rows in set (0.00 sec)
slave> SELECT * FROM fc2;
+---+------+
| m | n |
+---+------+
| 1 | 1 |
| 2 | 2 |
| 3 | 1 |
+---+------+
3 rows in set (0.00 sec)

现在假设你在主服务器上执行了下面的DELETE语句:

master> DELETE FROM fc1 WHERE i=1;
Query OK, 1 row affected (0.09 sec)

由于级联,主服务器表fc2现在只包含1行:

master> SELECT * FROM fc2;
+---+---+
| m | n |
+---+---+
| 2 | 2 |
+---+---+
1 row in set (0.00 sec)

但是,级联不会传播到从节点上,因为从节点上对fc1的DELETE不会从fc2中删除任何行。从节点的fc2副本仍然包含原来插入的所有行:

slave> SELECT * FROM fc2;
+---+---+
| m | n |
+---+---+
| 1 | 1 |
| 3 | 1 |
| 2 | 2 |
+---+---+
3 rows in set (0.00 sec)

这种差异是由于级联删除是由InnoDB存储引擎在内部处理的,这意味着没有任何更改被记录下来。

]]>
http://www.jydba.net/index.php/archives/3567/feed 0
Linux 使用源码安装mysqlfrm http://www.jydba.net/index.php/archives/3565 http://www.jydba.net/index.php/archives/3565#respond Mon, 03 Jun 2024 00:37:13 +0000 http://www.jydba.net/?p=3565 由于mysqlfrm是mysql-utilities工具一部分,那么我们安装mysql-utilities即可,下载好对应的源码包,进行编译安装
1、mysqlfrm安装

[root@localhost soft]# tar -xvzf mysql-utilities-1.6.5.tar.gz
mysql-utilities-1.6.5/
mysql-utilities-1.6.5/PKG-INFO
mysql-utilities-1.6.5/README.txt
mysql-utilities-1.6.5/mysql/
mysql-utilities-1.6.5/mysql/utilities/
mysql-utilities-1.6.5/mysql/utilities/common/
mysql-utilities-1.6.5/mysql/utilities/common/pattern_matching.py
mysql-utilities-1.6.5/mysql/utilities/common/server.py
mysql-utilities-1.6.5/mysql/utilities/common/user.py
mysql-utilities-1.6.5/mysql/utilities/common/variables.py
mysql-utilities-1.6.5/mysql/utilities/common/ip_parser.py
mysql-utilities-1.6.5/mysql/utilities/common/replication_ms.py
mysql-utilities-1.6.5/mysql/utilities/common/audit_log_parser.py
mysql-utilities-1.6.5/mysql/utilities/common/__init__.py
mysql-utilities-1.6.5/mysql/utilities/common/lock.py
mysql-utilities-1.6.5/mysql/utilities/common/tools.py
mysql-utilities-1.6.5/mysql/utilities/common/topology.py
mysql-utilities-1.6.5/mysql/utilities/common/table.py
mysql-utilities-1.6.5/mysql/utilities/common/charsets.py
mysql-utilities-1.6.5/mysql/utilities/common/parser.py
mysql-utilities-1.6.5/mysql/utilities/common/messages.py
mysql-utilities-1.6.5/mysql/utilities/common/gtid.py
mysql-utilities-1.6.5/mysql/utilities/common/audit_log_reader.py
mysql-utilities-1.6.5/mysql/utilities/common/database.py
mysql-utilities-1.6.5/mysql/utilities/common/grants_info.py
mysql-utilities-1.6.5/mysql/utilities/common/options.py
mysql-utilities-1.6.5/mysql/utilities/common/my_print_defaults.py
mysql-utilities-1.6.5/mysql/utilities/common/utilities.py
mysql-utilities-1.6.5/mysql/utilities/common/options_parser.py
mysql-utilities-1.6.5/mysql/utilities/common/binary_log_file.py
mysql-utilities-1.6.5/mysql/utilities/common/daemon.py
mysql-utilities-1.6.5/mysql/utilities/common/binlog.py
mysql-utilities-1.6.5/mysql/utilities/common/frm_reader.py
mysql-utilities-1.6.5/mysql/utilities/common/sql_transform.py
mysql-utilities-1.6.5/mysql/utilities/common/dbcompare.py
mysql-utilities-1.6.5/mysql/utilities/common/console.py
mysql-utilities-1.6.5/mysql/utilities/common/topology_map.py
mysql-utilities-1.6.5/mysql/utilities/common/format.py
mysql-utilities-1.6.5/mysql/utilities/common/rpl_sync.py
mysql-utilities-1.6.5/mysql/utilities/common/replication.py
mysql-utilities-1.6.5/mysql/utilities/__init__.py
mysql-utilities-1.6.5/mysql/utilities/command/
mysql-utilities-1.6.5/mysql/utilities/command/dbexport.py
mysql-utilities-1.6.5/mysql/utilities/command/rpl_admin.py
mysql-utilities-1.6.5/mysql/utilities/command/__init__.py
mysql-utilities-1.6.5/mysql/utilities/command/userclone.py
mysql-utilities-1.6.5/mysql/utilities/command/binlog_admin.py
mysql-utilities-1.6.5/mysql/utilities/command/serverclone.py
mysql-utilities-1.6.5/mysql/utilities/command/grep.py
mysql-utilities-1.6.5/mysql/utilities/command/indexcheck.py
mysql-utilities-1.6.5/mysql/utilities/command/grants.py
mysql-utilities-1.6.5/mysql/utilities/command/check_rpl.py
mysql-utilities-1.6.5/mysql/utilities/command/setup_rpl.py
mysql-utilities-1.6.5/mysql/utilities/command/dbimport.py
mysql-utilities-1.6.5/mysql/utilities/command/failover_console.py
mysql-utilities-1.6.5/mysql/utilities/command/dbcopy.py
mysql-utilities-1.6.5/mysql/utilities/command/proc.py
mysql-utilities-1.6.5/mysql/utilities/command/rpl_sync_check.py
mysql-utilities-1.6.5/mysql/utilities/command/serverinfo.py
mysql-utilities-1.6.5/mysql/utilities/command/failover_daemon.py
mysql-utilities-1.6.5/mysql/utilities/command/dbcompare.py
mysql-utilities-1.6.5/mysql/utilities/command/read_frm.py
mysql-utilities-1.6.5/mysql/utilities/command/diskusage.py
mysql-utilities-1.6.5/mysql/utilities/command/utilitiesconsole.py
mysql-utilities-1.6.5/mysql/utilities/command/audit_log.py
mysql-utilities-1.6.5/mysql/utilities/command/diff.py
mysql-utilities-1.6.5/mysql/utilities/command/show_rpl.py
mysql-utilities-1.6.5/mysql/utilities/exception.py
mysql-utilities-1.6.5/mysql/__init__.py
mysql-utilities-1.6.5/mysql/connector/
mysql-utilities-1.6.5/mysql/connector/custom_types.py
mysql-utilities-1.6.5/mysql/connector/__init__.py
mysql-utilities-1.6.5/mysql/connector/charsets.py
mysql-utilities-1.6.5/mysql/connector/errors.py
mysql-utilities-1.6.5/mysql/connector/cursor_cext.py
mysql-utilities-1.6.5/mysql/connector/abstracts.py
mysql-utilities-1.6.5/mysql/connector/utils.py
mysql-utilities-1.6.5/mysql/connector/constants.py
mysql-utilities-1.6.5/mysql/connector/django/
mysql-utilities-1.6.5/mysql/connector/django/introspection.py
mysql-utilities-1.6.5/mysql/connector/django/validation.py
mysql-utilities-1.6.5/mysql/connector/django/__init__.py
mysql-utilities-1.6.5/mysql/connector/django/schema.py
mysql-utilities-1.6.5/mysql/connector/django/client.py
mysql-utilities-1.6.5/mysql/connector/django/operations.py
mysql-utilities-1.6.5/mysql/connector/django/compiler.py
mysql-utilities-1.6.5/mysql/connector/django/features.py
mysql-utilities-1.6.5/mysql/connector/django/creation.py
mysql-utilities-1.6.5/mysql/connector/django/base.py
mysql-utilities-1.6.5/mysql/connector/fabric/
mysql-utilities-1.6.5/mysql/connector/fabric/__init__.py
mysql-utilities-1.6.5/mysql/connector/fabric/caching.py
mysql-utilities-1.6.5/mysql/connector/fabric/connection.py
mysql-utilities-1.6.5/mysql/connector/fabric/balancing.py
mysql-utilities-1.6.5/mysql/connector/dbapi.py
mysql-utilities-1.6.5/mysql/connector/pooling.py
mysql-utilities-1.6.5/mysql/connector/network.py
mysql-utilities-1.6.5/mysql/connector/conversion.py
mysql-utilities-1.6.5/mysql/connector/connection.py
mysql-utilities-1.6.5/mysql/connector/version.py
mysql-utilities-1.6.5/mysql/connector/connection_cext.py
mysql-utilities-1.6.5/mysql/connector/cursor.py
mysql-utilities-1.6.5/mysql/connector/optionfiles.py
mysql-utilities-1.6.5/mysql/connector/authentication.py
mysql-utilities-1.6.5/mysql/connector/catch23.py
mysql-utilities-1.6.5/mysql/connector/locales/
mysql-utilities-1.6.5/mysql/connector/locales/eng/
mysql-utilities-1.6.5/mysql/connector/locales/eng/__init__.py
mysql-utilities-1.6.5/mysql/connector/locales/eng/client_error.py
mysql-utilities-1.6.5/mysql/connector/locales/__init__.py
mysql-utilities-1.6.5/mysql/connector/protocol.py
mysql-utilities-1.6.5/mysql/connector/errorcode.py
mysql-utilities-1.6.5/unit_tests/
mysql-utilities-1.6.5/unit_tests/__init__.py
mysql-utilities-1.6.5/unit_tests/test_decode_encode.py
mysql-utilities-1.6.5/unit_tests/test_binary_log_file.py
mysql-utilities-1.6.5/unit_tests/test_utilities_console.py
mysql-utilities-1.6.5/unit_tests/test_server_version.py
mysql-utilities-1.6.5/unit_tests/test_parsers.py
mysql-utilities-1.6.5/unit_tests/test_options.py
mysql-utilities-1.6.5/unit_tests/test_ip_parser.py
mysql-utilities-1.6.5/unit_tests/test_user_privileges.py
mysql-utilities-1.6.5/unit_tests/test_missing_connector.py
mysql-utilities-1.6.5/unit_tests/test_my_print_defaults.py
mysql-utilities-1.6.5/unit_tests/test_gtid.py
mysql-utilities-1.6.5/docs/
mysql-utilities-1.6.5/docs/man/
mysql-utilities-1.6.5/docs/man/mysqlrplcheck.1
mysql-utilities-1.6.5/docs/man/mysqlmetagrep.1
mysql-utilities-1.6.5/docs/man/mysqlfailover.1
mysql-utilities-1.6.5/docs/man/mysqlserverclone.1
mysql-utilities-1.6.5/docs/man/mysqlbinlogmove.1
mysql-utilities-1.6.5/docs/man/mysqlrplms.1
mysql-utilities-1.6.5/docs/man/mysqldbimport.1
mysql-utilities-1.6.5/docs/man/mysqldiskusage.1
mysql-utilities-1.6.5/docs/man/mysqlreplicate.1
mysql-utilities-1.6.5/docs/man/mysqldbexport.1
mysql-utilities-1.6.5/docs/man/mysqlfrm.1
mysql-utilities-1.6.5/docs/man/mysqlauditgrep.1
mysql-utilities-1.6.5/docs/man/mysqluc.1
mysql-utilities-1.6.5/docs/man/mysqldiff.1
mysql-utilities-1.6.5/docs/man/mysqlslavetrx.1
mysql-utilities-1.6.5/docs/man/mysqlbinlogpurge.1
mysql-utilities-1.6.5/docs/man/mysqlgrants.1
mysql-utilities-1.6.5/docs/man/mysqldbcopy.1
mysql-utilities-1.6.5/docs/man/mysqlrpladmin.1
mysql-utilities-1.6.5/docs/man/mysqlprocgrep.1
mysql-utilities-1.6.5/docs/man/mysqlauditadmin.1
mysql-utilities-1.6.5/docs/man/mysqlindexcheck.1
mysql-utilities-1.6.5/docs/man/mysqldbcompare.1
mysql-utilities-1.6.5/docs/man/mysqlrplsync.1
mysql-utilities-1.6.5/docs/man/mysqlserverinfo.1
mysql-utilities-1.6.5/docs/man/mysqlbinlogrotate.1
mysql-utilities-1.6.5/docs/man/mysqlrplshow.1
mysql-utilities-1.6.5/docs/man/mysqluserclone.1
mysql-utilities-1.6.5/CHANGES.txt
mysql-utilities-1.6.5/scripts/
mysql-utilities-1.6.5/scripts/mysqlrplms.py
mysql-utilities-1.6.5/scripts/mysqldbcompare.py
mysql-utilities-1.6.5/scripts/mysqlserverclone.py
mysql-utilities-1.6.5/scripts/mysqluc.py
mysql-utilities-1.6.5/scripts/mysqldiskusage.py
mysql-utilities-1.6.5/scripts/mysqlauditadmin.py
mysql-utilities-1.6.5/scripts/mysqluserclone.py
mysql-utilities-1.6.5/scripts/mysqlbinlogrotate.py
mysql-utilities-1.6.5/scripts/mysqlreplicate.py
mysql-utilities-1.6.5/scripts/mysqlfailover.py
mysql-utilities-1.6.5/scripts/mysqlbinlogmove.py
mysql-utilities-1.6.5/scripts/mysqlindexcheck.py
mysql-utilities-1.6.5/scripts/mysqldbexport.py
mysql-utilities-1.6.5/scripts/mysqlrplcheck.py
mysql-utilities-1.6.5/scripts/mysqlslavetrx.py
mysql-utilities-1.6.5/scripts/mysqlmetagrep.py
mysql-utilities-1.6.5/scripts/mysqlprocgrep.py
mysql-utilities-1.6.5/scripts/mysqlrplsync.py
mysql-utilities-1.6.5/scripts/mysqlbinlogpurge.py
mysql-utilities-1.6.5/scripts/mysqldiff.py
mysql-utilities-1.6.5/scripts/mysqlrplshow.py
mysql-utilities-1.6.5/scripts/mysqlfrm.py
mysql-utilities-1.6.5/scripts/mysqldbimport.py
mysql-utilities-1.6.5/scripts/mysqlauditgrep.py
mysql-utilities-1.6.5/scripts/mysqlgrants.py
mysql-utilities-1.6.5/scripts/mysqldbcopy.py
mysql-utilities-1.6.5/scripts/mysqlserverinfo.py
mysql-utilities-1.6.5/scripts/mysqlrpladmin.py
mysql-utilities-1.6.5/info.py
mysql-utilities-1.6.5/setup.py
mysql-utilities-1.6.5/LICENSE.txt
[root@localhost soft]# cd mysql-utilities-1.6.5/
[root@localhost mysql-utilities-1.6.5]# ll
total 132
-rw-r--r--. 1 7161 31415 37814 Jan 18  2017 CHANGES.txt
drwxr-xr-x. 3 7161 31415    16 Jan 18  2017 docs
-rw-r--r--. 1 7161 31415  6680 Jan 18  2017 info.py
-rw-r--r--. 1 7161 31415 17987 Jan 18  2017 LICENSE.txt
drwxr-xr-x. 4 7161 31415    56 Jan 18  2017 mysql
-rw-r--r--. 1 7161 31415   928 Jan 18  2017 PKG-INFO
-rw-r--r--. 1 7161 31415 34819 Jan 18  2017 README.txt
drwxr-xr-x. 2 7161 31415  4096 Jan 18  2017 scripts
-rw-r--r--. 1 7161 31415 14232 Jan 18  2017 setup.py
drwxr-xr-x. 2 7161 31415  4096 Jan 18  2017 unit_tests
[root@localhost mysql-utilities-1.6.5]# python ./setup.py build
checking mysql for packages to distribute
packages found: ['mysql', 'mysql.connector', 'mysql.connector.django', 'mysql.connector.fabric', 'mysql.connector.locales', 'mysql.connector.locales.eng', 'mysql.utilities', 'mysql.utilities.command', 'mysql.utilities.common']
scripts found: ['scripts/mysqlrplms.py', 'scripts/mysqldbcompare.py', 'scripts/mysqlserverclone.py', 'scripts/mysqluc.py', 'scripts/mysqldiskusage.py', 'scripts/mysqlauditadmin.py', 'scripts/mysqluserclone.py', 'scripts/mysqlbinlogrotate.py', 'scripts/mysqlreplicate.py', 'scripts/mysqlfailover.py', 'scripts/mysqlbinlogmove.py', 'scripts/mysqlindexcheck.py', 'scripts/mysqldbexport.py', 'scripts/mysqlrplcheck.py', 'scripts/mysqlslavetrx.py', 'scripts/mysqlmetagrep.py', 'scripts/mysqlprocgrep.py', 'scripts/mysqlrplsync.py', 'scripts/mysqlbinlogpurge.py', 'scripts/mysqldiff.py', 'scripts/mysqlrplshow.py', 'scripts/mysqlfrm.py', 'scripts/mysqldbimport.py', 'scripts/mysqlauditgrep.py', 'scripts/mysqlgrants.py', 'scripts/mysqldbcopy.py', 'scripts/mysqlserverinfo.py', 'scripts/mysqlrpladmin.py']
package set set(['mysql.utilities.command', 'mysql.utilities.common', 'mysql.connector.fabric', 'mysql.connector.locales', 'mysql.connector', 'mysql.utilities', 'mysql.connector.django', 'mysql', 'mysql.connector.locales.eng'])
running build
running build_py
creating build
creating build/lib
creating build/lib/mysql
creating build/lib/mysql/utilities
creating build/lib/mysql/utilities/command
copying mysql/utilities/command/dbexport.py -> build/lib/mysql/utilities/command
copying mysql/utilities/command/rpl_admin.py -> build/lib/mysql/utilities/command
copying mysql/utilities/command/__init__.py -> build/lib/mysql/utilities/command
copying mysql/utilities/command/userclone.py -> build/lib/mysql/utilities/command
copying mysql/utilities/command/binlog_admin.py -> build/lib/mysql/utilities/command
copying mysql/utilities/command/serverclone.py -> build/lib/mysql/utilities/command
copying mysql/utilities/command/grep.py -> build/lib/mysql/utilities/command
copying mysql/utilities/command/indexcheck.py -> build/lib/mysql/utilities/command
copying mysql/utilities/command/grants.py -> build/lib/mysql/utilities/command
copying mysql/utilities/command/check_rpl.py -> build/lib/mysql/utilities/command
copying mysql/utilities/command/setup_rpl.py -> build/lib/mysql/utilities/command
copying mysql/utilities/command/dbimport.py -> build/lib/mysql/utilities/command
copying mysql/utilities/command/failover_console.py -> build/lib/mysql/utilities/command
copying mysql/utilities/command/dbcopy.py -> build/lib/mysql/utilities/command
copying mysql/utilities/command/proc.py -> build/lib/mysql/utilities/command
copying mysql/utilities/command/rpl_sync_check.py -> build/lib/mysql/utilities/command
copying mysql/utilities/command/serverinfo.py -> build/lib/mysql/utilities/command
copying mysql/utilities/command/failover_daemon.py -> build/lib/mysql/utilities/command
copying mysql/utilities/command/dbcompare.py -> build/lib/mysql/utilities/command
copying mysql/utilities/command/read_frm.py -> build/lib/mysql/utilities/command
copying mysql/utilities/command/diskusage.py -> build/lib/mysql/utilities/command
copying mysql/utilities/command/utilitiesconsole.py -> build/lib/mysql/utilities/command
copying mysql/utilities/command/audit_log.py -> build/lib/mysql/utilities/command
copying mysql/utilities/command/diff.py -> build/lib/mysql/utilities/command
copying mysql/utilities/command/show_rpl.py -> build/lib/mysql/utilities/command
creating build/lib/mysql/utilities/common
copying mysql/utilities/common/pattern_matching.py -> build/lib/mysql/utilities/common
copying mysql/utilities/common/server.py -> build/lib/mysql/utilities/common
copying mysql/utilities/common/user.py -> build/lib/mysql/utilities/common
copying mysql/utilities/common/variables.py -> build/lib/mysql/utilities/common
copying mysql/utilities/common/ip_parser.py -> build/lib/mysql/utilities/common
copying mysql/utilities/common/replication_ms.py -> build/lib/mysql/utilities/common
copying mysql/utilities/common/audit_log_parser.py -> build/lib/mysql/utilities/common
copying mysql/utilities/common/__init__.py -> build/lib/mysql/utilities/common
copying mysql/utilities/common/lock.py -> build/lib/mysql/utilities/common
copying mysql/utilities/common/tools.py -> build/lib/mysql/utilities/common
copying mysql/utilities/common/topology.py -> build/lib/mysql/utilities/common
copying mysql/utilities/common/table.py -> build/lib/mysql/utilities/common
copying mysql/utilities/common/charsets.py -> build/lib/mysql/utilities/common
copying mysql/utilities/common/parser.py -> build/lib/mysql/utilities/common
copying mysql/utilities/common/messages.py -> build/lib/mysql/utilities/common
copying mysql/utilities/common/gtid.py -> build/lib/mysql/utilities/common
copying mysql/utilities/common/audit_log_reader.py -> build/lib/mysql/utilities/common
copying mysql/utilities/common/database.py -> build/lib/mysql/utilities/common
copying mysql/utilities/common/grants_info.py -> build/lib/mysql/utilities/common
copying mysql/utilities/common/options.py -> build/lib/mysql/utilities/common
copying mysql/utilities/common/my_print_defaults.py -> build/lib/mysql/utilities/common
copying mysql/utilities/common/utilities.py -> build/lib/mysql/utilities/common
copying mysql/utilities/common/options_parser.py -> build/lib/mysql/utilities/common
copying mysql/utilities/common/binary_log_file.py -> build/lib/mysql/utilities/common
copying mysql/utilities/common/daemon.py -> build/lib/mysql/utilities/common
copying mysql/utilities/common/binlog.py -> build/lib/mysql/utilities/common
copying mysql/utilities/common/frm_reader.py -> build/lib/mysql/utilities/common
copying mysql/utilities/common/sql_transform.py -> build/lib/mysql/utilities/common
copying mysql/utilities/common/dbcompare.py -> build/lib/mysql/utilities/common
copying mysql/utilities/common/console.py -> build/lib/mysql/utilities/common
copying mysql/utilities/common/topology_map.py -> build/lib/mysql/utilities/common
copying mysql/utilities/common/format.py -> build/lib/mysql/utilities/common
copying mysql/utilities/common/rpl_sync.py -> build/lib/mysql/utilities/common
copying mysql/utilities/common/replication.py -> build/lib/mysql/utilities/common
creating build/lib/mysql/connector
creating build/lib/mysql/connector/fabric
copying mysql/connector/fabric/__init__.py -> build/lib/mysql/connector/fabric
copying mysql/connector/fabric/caching.py -> build/lib/mysql/connector/fabric
copying mysql/connector/fabric/connection.py -> build/lib/mysql/connector/fabric
copying mysql/connector/fabric/balancing.py -> build/lib/mysql/connector/fabric
creating build/lib/mysql/connector/locales
copying mysql/connector/locales/__init__.py -> build/lib/mysql/connector/locales
copying mysql/connector/custom_types.py -> build/lib/mysql/connector
copying mysql/connector/__init__.py -> build/lib/mysql/connector
copying mysql/connector/charsets.py -> build/lib/mysql/connector
copying mysql/connector/errors.py -> build/lib/mysql/connector
copying mysql/connector/cursor_cext.py -> build/lib/mysql/connector
copying mysql/connector/abstracts.py -> build/lib/mysql/connector
copying mysql/connector/utils.py -> build/lib/mysql/connector
copying mysql/connector/constants.py -> build/lib/mysql/connector
copying mysql/connector/dbapi.py -> build/lib/mysql/connector
copying mysql/connector/pooling.py -> build/lib/mysql/connector
copying mysql/connector/network.py -> build/lib/mysql/connector
copying mysql/connector/conversion.py -> build/lib/mysql/connector
copying mysql/connector/connection.py -> build/lib/mysql/connector
copying mysql/connector/version.py -> build/lib/mysql/connector
copying mysql/connector/connection_cext.py -> build/lib/mysql/connector
copying mysql/connector/cursor.py -> build/lib/mysql/connector
copying mysql/connector/optionfiles.py -> build/lib/mysql/connector
copying mysql/connector/authentication.py -> build/lib/mysql/connector
copying mysql/connector/catch23.py -> build/lib/mysql/connector
copying mysql/connector/protocol.py -> build/lib/mysql/connector
copying mysql/connector/errorcode.py -> build/lib/mysql/connector
copying mysql/utilities/__init__.py -> build/lib/mysql/utilities
copying mysql/utilities/exception.py -> build/lib/mysql/utilities
creating build/lib/mysql/connector/django
copying mysql/connector/django/introspection.py -> build/lib/mysql/connector/django
copying mysql/connector/django/validation.py -> build/lib/mysql/connector/django
copying mysql/connector/django/__init__.py -> build/lib/mysql/connector/django
copying mysql/connector/django/schema.py -> build/lib/mysql/connector/django
copying mysql/connector/django/client.py -> build/lib/mysql/connector/django
copying mysql/connector/django/operations.py -> build/lib/mysql/connector/django
copying mysql/connector/django/compiler.py -> build/lib/mysql/connector/django
copying mysql/connector/django/features.py -> build/lib/mysql/connector/django
copying mysql/connector/django/creation.py -> build/lib/mysql/connector/django
copying mysql/connector/django/base.py -> build/lib/mysql/connector/django
copying mysql/__init__.py -> build/lib/mysql
creating build/lib/mysql/connector/locales/eng
copying mysql/connector/locales/eng/__init__.py -> build/lib/mysql/connector/locales/eng
copying mysql/connector/locales/eng/client_error.py -> build/lib/mysql/connector/locales/eng
running build_scripts
copying scripts/mysqldbimport.py -> scripts/mysqldbimport
copying scripts/mysqlbinlogpurge.py -> scripts/mysqlbinlogpurge
copying scripts/mysqlfrm.py -> scripts/mysqlfrm
copying scripts/mysqlserverclone.py -> scripts/mysqlserverclone
copying scripts/mysqlindexcheck.py -> scripts/mysqlindexcheck
copying scripts/mysqldiff.py -> scripts/mysqldiff
copying scripts/mysqlbinlogrotate.py -> scripts/mysqlbinlogrotate
copying scripts/mysqlrpladmin.py -> scripts/mysqlrpladmin
copying scripts/mysqlgrants.py -> scripts/mysqlgrants
copying scripts/mysqlrplcheck.py -> scripts/mysqlrplcheck
copying scripts/mysqlprocgrep.py -> scripts/mysqlprocgrep
copying scripts/mysqlauditgrep.py -> scripts/mysqlauditgrep
copying scripts/mysqlrplms.py -> scripts/mysqlrplms
copying scripts/mysqlslavetrx.py -> scripts/mysqlslavetrx
copying scripts/mysqlreplicate.py -> scripts/mysqlreplicate
copying scripts/mysqldbexport.py -> scripts/mysqldbexport
copying scripts/mysqlrplshow.py -> scripts/mysqlrplshow
copying scripts/mysqluc.py -> scripts/mysqluc
copying scripts/mysqlserverinfo.py -> scripts/mysqlserverinfo
copying scripts/mysqlauditadmin.py -> scripts/mysqlauditadmin
copying scripts/mysqlrplsync.py -> scripts/mysqlrplsync
copying scripts/mysqldbcompare.py -> scripts/mysqldbcompare
copying scripts/mysqldiskusage.py -> scripts/mysqldiskusage
copying scripts/mysqlfailover.py -> scripts/mysqlfailover
copying scripts/mysqluserclone.py -> scripts/mysqluserclone
copying scripts/mysqlbinlogmove.py -> scripts/mysqlbinlogmove
copying scripts/mysqlmetagrep.py -> scripts/mysqlmetagrep
copying scripts/mysqldbcopy.py -> scripts/mysqldbcopy
creating build/scripts-2.7
copying and adjusting scripts/mysqldbimport -> build/scripts-2.7
copying and adjusting scripts/mysqlbinlogpurge -> build/scripts-2.7
copying and adjusting scripts/mysqlfrm -> build/scripts-2.7
copying and adjusting scripts/mysqlserverclone -> build/scripts-2.7
copying and adjusting scripts/mysqlindexcheck -> build/scripts-2.7
copying and adjusting scripts/mysqldiff -> build/scripts-2.7
copying and adjusting scripts/mysqlbinlogrotate -> build/scripts-2.7
copying and adjusting scripts/mysqlrpladmin -> build/scripts-2.7
copying and adjusting scripts/mysqlgrants -> build/scripts-2.7
copying and adjusting scripts/mysqlrplcheck -> build/scripts-2.7
copying and adjusting scripts/mysqlprocgrep -> build/scripts-2.7
copying and adjusting scripts/mysqlauditgrep -> build/scripts-2.7
copying and adjusting scripts/mysqlrplms -> build/scripts-2.7
copying and adjusting scripts/mysqlslavetrx -> build/scripts-2.7
copying and adjusting scripts/mysqlreplicate -> build/scripts-2.7
copying and adjusting scripts/mysqldbexport -> build/scripts-2.7
copying and adjusting scripts/mysqlrplshow -> build/scripts-2.7
copying and adjusting scripts/mysqluc -> build/scripts-2.7
copying and adjusting scripts/mysqlserverinfo -> build/scripts-2.7
copying and adjusting scripts/mysqlauditadmin -> build/scripts-2.7
copying and adjusting scripts/mysqlrplsync -> build/scripts-2.7
copying and adjusting scripts/mysqldbcompare -> build/scripts-2.7
copying and adjusting scripts/mysqldiskusage -> build/scripts-2.7
copying and adjusting scripts/mysqlfailover -> build/scripts-2.7
copying and adjusting scripts/mysqluserclone -> build/scripts-2.7
copying and adjusting scripts/mysqlbinlogmove -> build/scripts-2.7
copying and adjusting scripts/mysqlmetagrep -> build/scripts-2.7
copying and adjusting scripts/mysqldbcopy -> build/scripts-2.7
changing mode of build/scripts-2.7/mysqldbimport from 644 to 755
changing mode of build/scripts-2.7/mysqlbinlogpurge from 644 to 755
changing mode of build/scripts-2.7/mysqlfrm from 644 to 755
changing mode of build/scripts-2.7/mysqlserverclone from 644 to 755
changing mode of build/scripts-2.7/mysqlindexcheck from 644 to 755
changing mode of build/scripts-2.7/mysqldiff from 644 to 755
changing mode of build/scripts-2.7/mysqlbinlogrotate from 644 to 755
changing mode of build/scripts-2.7/mysqlrpladmin from 644 to 755
changing mode of build/scripts-2.7/mysqlgrants from 644 to 755
changing mode of build/scripts-2.7/mysqlrplcheck from 644 to 755
changing mode of build/scripts-2.7/mysqlprocgrep from 644 to 755
changing mode of build/scripts-2.7/mysqlauditgrep from 644 to 755
changing mode of build/scripts-2.7/mysqlrplms from 644 to 755
changing mode of build/scripts-2.7/mysqlslavetrx from 644 to 755
changing mode of build/scripts-2.7/mysqlreplicate from 644 to 755
changing mode of build/scripts-2.7/mysqldbexport from 644 to 755
changing mode of build/scripts-2.7/mysqlrplshow from 644 to 755
changing mode of build/scripts-2.7/mysqluc from 644 to 755
changing mode of build/scripts-2.7/mysqlserverinfo from 644 to 755
changing mode of build/scripts-2.7/mysqlauditadmin from 644 to 755
changing mode of build/scripts-2.7/mysqlrplsync from 644 to 755
changing mode of build/scripts-2.7/mysqldbcompare from 644 to 755
changing mode of build/scripts-2.7/mysqldiskusage from 644 to 755
changing mode of build/scripts-2.7/mysqlfailover from 644 to 755
changing mode of build/scripts-2.7/mysqluserclone from 644 to 755
changing mode of build/scripts-2.7/mysqlbinlogmove from 644 to 755
changing mode of build/scripts-2.7/mysqlmetagrep from 644 to 755
changing mode of build/scripts-2.7/mysqldbcopy from 644 to 755
[root@localhost mysql-utilities-1.6.5]# python ./setup.py install
checking mysql for packages to distribute
packages found: ['mysql', 'mysql.connector', 'mysql.connector.django', 'mysql.connector.fabric', 'mysql.connector.locales', 'mysql.connector.locales.eng', 'mysql.utilities', 'mysql.utilities.command', 'mysql.utilities.common']
scripts found: ['scripts/mysqlrplms.py', 'scripts/mysqldbcompare.py', 'scripts/mysqlserverclone.py', 'scripts/mysqluc.py', 'scripts/mysqldiskusage.py', 'scripts/mysqlauditadmin.py', 'scripts/mysqluserclone.py', 'scripts/mysqlbinlogrotate.py', 'scripts/mysqlreplicate.py', 'scripts/mysqlfailover.py', 'scripts/mysqlbinlogmove.py', 'scripts/mysqlindexcheck.py', 'scripts/mysqldbexport.py', 'scripts/mysqlrplcheck.py', 'scripts/mysqlslavetrx.py', 'scripts/mysqlmetagrep.py', 'scripts/mysqlprocgrep.py', 'scripts/mysqlrplsync.py', 'scripts/mysqlbinlogpurge.py', 'scripts/mysqldiff.py', 'scripts/mysqlrplshow.py', 'scripts/mysqlfrm.py', 'scripts/mysqldbimport.py', 'scripts/mysqlauditgrep.py', 'scripts/mysqlgrants.py', 'scripts/mysqldbcopy.py', 'scripts/mysqlserverinfo.py', 'scripts/mysqlrpladmin.py']
package set set(['mysql.utilities.command', 'mysql.utilities.common', 'mysql.connector.fabric', 'mysql.connector.locales', 'mysql.connector', 'mysql.utilities', 'mysql.connector.django', 'mysql', 'mysql.connector.locales.eng'])
running install
running build
running build_py
running build_scripts
running install_lib
creating /usr/lib/python2.7/site-packages/mysql
creating /usr/lib/python2.7/site-packages/mysql/utilities
creating /usr/lib/python2.7/site-packages/mysql/utilities/command
copying build/lib/mysql/utilities/command/dbexport.py -> /usr/lib/python2.7/site-packages/mysql/utilities/command
copying build/lib/mysql/utilities/command/rpl_admin.py -> /usr/lib/python2.7/site-packages/mysql/utilities/command
copying build/lib/mysql/utilities/command/__init__.py -> /usr/lib/python2.7/site-packages/mysql/utilities/command
copying build/lib/mysql/utilities/command/userclone.py -> /usr/lib/python2.7/site-packages/mysql/utilities/command
copying build/lib/mysql/utilities/command/binlog_admin.py -> /usr/lib/python2.7/site-packages/mysql/utilities/command
copying build/lib/mysql/utilities/command/serverclone.py -> /usr/lib/python2.7/site-packages/mysql/utilities/command
copying build/lib/mysql/utilities/command/grep.py -> /usr/lib/python2.7/site-packages/mysql/utilities/command
copying build/lib/mysql/utilities/command/indexcheck.py -> /usr/lib/python2.7/site-packages/mysql/utilities/command
copying build/lib/mysql/utilities/command/grants.py -> /usr/lib/python2.7/site-packages/mysql/utilities/command
copying build/lib/mysql/utilities/command/check_rpl.py -> /usr/lib/python2.7/site-packages/mysql/utilities/command
copying build/lib/mysql/utilities/command/setup_rpl.py -> /usr/lib/python2.7/site-packages/mysql/utilities/command
copying build/lib/mysql/utilities/command/dbimport.py -> /usr/lib/python2.7/site-packages/mysql/utilities/command
copying build/lib/mysql/utilities/command/failover_console.py -> /usr/lib/python2.7/site-packages/mysql/utilities/command
copying build/lib/mysql/utilities/command/dbcopy.py -> /usr/lib/python2.7/site-packages/mysql/utilities/command
copying build/lib/mysql/utilities/command/proc.py -> /usr/lib/python2.7/site-packages/mysql/utilities/command
copying build/lib/mysql/utilities/command/rpl_sync_check.py -> /usr/lib/python2.7/site-packages/mysql/utilities/command
copying build/lib/mysql/utilities/command/serverinfo.py -> /usr/lib/python2.7/site-packages/mysql/utilities/command
copying build/lib/mysql/utilities/command/failover_daemon.py -> /usr/lib/python2.7/site-packages/mysql/utilities/command
copying build/lib/mysql/utilities/command/dbcompare.py -> /usr/lib/python2.7/site-packages/mysql/utilities/command
copying build/lib/mysql/utilities/command/read_frm.py -> /usr/lib/python2.7/site-packages/mysql/utilities/command
copying build/lib/mysql/utilities/command/diskusage.py -> /usr/lib/python2.7/site-packages/mysql/utilities/command
copying build/lib/mysql/utilities/command/utilitiesconsole.py -> /usr/lib/python2.7/site-packages/mysql/utilities/command
copying build/lib/mysql/utilities/command/audit_log.py -> /usr/lib/python2.7/site-packages/mysql/utilities/command
copying build/lib/mysql/utilities/command/diff.py -> /usr/lib/python2.7/site-packages/mysql/utilities/command
copying build/lib/mysql/utilities/command/show_rpl.py -> /usr/lib/python2.7/site-packages/mysql/utilities/command
creating /usr/lib/python2.7/site-packages/mysql/utilities/common
copying build/lib/mysql/utilities/common/pattern_matching.py -> /usr/lib/python2.7/site-packages/mysql/utilities/common
copying build/lib/mysql/utilities/common/server.py -> /usr/lib/python2.7/site-packages/mysql/utilities/common
copying build/lib/mysql/utilities/common/user.py -> /usr/lib/python2.7/site-packages/mysql/utilities/common
copying build/lib/mysql/utilities/common/variables.py -> /usr/lib/python2.7/site-packages/mysql/utilities/common
copying build/lib/mysql/utilities/common/ip_parser.py -> /usr/lib/python2.7/site-packages/mysql/utilities/common
copying build/lib/mysql/utilities/common/replication_ms.py -> /usr/lib/python2.7/site-packages/mysql/utilities/common
copying build/lib/mysql/utilities/common/audit_log_parser.py -> /usr/lib/python2.7/site-packages/mysql/utilities/common
copying build/lib/mysql/utilities/common/__init__.py -> /usr/lib/python2.7/site-packages/mysql/utilities/common
copying build/lib/mysql/utilities/common/lock.py -> /usr/lib/python2.7/site-packages/mysql/utilities/common
copying build/lib/mysql/utilities/common/tools.py -> /usr/lib/python2.7/site-packages/mysql/utilities/common
copying build/lib/mysql/utilities/common/topology.py -> /usr/lib/python2.7/site-packages/mysql/utilities/common
copying build/lib/mysql/utilities/common/table.py -> /usr/lib/python2.7/site-packages/mysql/utilities/common
copying build/lib/mysql/utilities/common/charsets.py -> /usr/lib/python2.7/site-packages/mysql/utilities/common
copying build/lib/mysql/utilities/common/parser.py -> /usr/lib/python2.7/site-packages/mysql/utilities/common
copying build/lib/mysql/utilities/common/messages.py -> /usr/lib/python2.7/site-packages/mysql/utilities/common
copying build/lib/mysql/utilities/common/gtid.py -> /usr/lib/python2.7/site-packages/mysql/utilities/common
copying build/lib/mysql/utilities/common/audit_log_reader.py -> /usr/lib/python2.7/site-packages/mysql/utilities/common
copying build/lib/mysql/utilities/common/database.py -> /usr/lib/python2.7/site-packages/mysql/utilities/common
copying build/lib/mysql/utilities/common/grants_info.py -> /usr/lib/python2.7/site-packages/mysql/utilities/common
copying build/lib/mysql/utilities/common/options.py -> /usr/lib/python2.7/site-packages/mysql/utilities/common
copying build/lib/mysql/utilities/common/my_print_defaults.py -> /usr/lib/python2.7/site-packages/mysql/utilities/common
copying build/lib/mysql/utilities/common/utilities.py -> /usr/lib/python2.7/site-packages/mysql/utilities/common
copying build/lib/mysql/utilities/common/options_parser.py -> /usr/lib/python2.7/site-packages/mysql/utilities/common
copying build/lib/mysql/utilities/common/binary_log_file.py -> /usr/lib/python2.7/site-packages/mysql/utilities/common
copying build/lib/mysql/utilities/common/daemon.py -> /usr/lib/python2.7/site-packages/mysql/utilities/common
copying build/lib/mysql/utilities/common/binlog.py -> /usr/lib/python2.7/site-packages/mysql/utilities/common
copying build/lib/mysql/utilities/common/frm_reader.py -> /usr/lib/python2.7/site-packages/mysql/utilities/common
copying build/lib/mysql/utilities/common/sql_transform.py -> /usr/lib/python2.7/site-packages/mysql/utilities/common
copying build/lib/mysql/utilities/common/dbcompare.py -> /usr/lib/python2.7/site-packages/mysql/utilities/common
copying build/lib/mysql/utilities/common/console.py -> /usr/lib/python2.7/site-packages/mysql/utilities/common
copying build/lib/mysql/utilities/common/topology_map.py -> /usr/lib/python2.7/site-packages/mysql/utilities/common
copying build/lib/mysql/utilities/common/format.py -> /usr/lib/python2.7/site-packages/mysql/utilities/common
copying build/lib/mysql/utilities/common/rpl_sync.py -> /usr/lib/python2.7/site-packages/mysql/utilities/common
copying build/lib/mysql/utilities/common/replication.py -> /usr/lib/python2.7/site-packages/mysql/utilities/common
copying build/lib/mysql/utilities/__init__.py -> /usr/lib/python2.7/site-packages/mysql/utilities
copying build/lib/mysql/utilities/exception.py -> /usr/lib/python2.7/site-packages/mysql/utilities
creating /usr/lib/python2.7/site-packages/mysql/connector
creating /usr/lib/python2.7/site-packages/mysql/connector/fabric
copying build/lib/mysql/connector/fabric/__init__.py -> /usr/lib/python2.7/site-packages/mysql/connector/fabric
copying build/lib/mysql/connector/fabric/caching.py -> /usr/lib/python2.7/site-packages/mysql/connector/fabric
copying build/lib/mysql/connector/fabric/connection.py -> /usr/lib/python2.7/site-packages/mysql/connector/fabric
copying build/lib/mysql/connector/fabric/balancing.py -> /usr/lib/python2.7/site-packages/mysql/connector/fabric
creating /usr/lib/python2.7/site-packages/mysql/connector/locales
copying build/lib/mysql/connector/locales/__init__.py -> /usr/lib/python2.7/site-packages/mysql/connector/locales
creating /usr/lib/python2.7/site-packages/mysql/connector/locales/eng
copying build/lib/mysql/connector/locales/eng/__init__.py -> /usr/lib/python2.7/site-packages/mysql/connector/locales/eng
copying build/lib/mysql/connector/locales/eng/client_error.py -> /usr/lib/python2.7/site-packages/mysql/connector/locales/eng
copying build/lib/mysql/connector/custom_types.py -> /usr/lib/python2.7/site-packages/mysql/connector
copying build/lib/mysql/connector/__init__.py -> /usr/lib/python2.7/site-packages/mysql/connector
copying build/lib/mysql/connector/charsets.py -> /usr/lib/python2.7/site-packages/mysql/connector
copying build/lib/mysql/connector/errors.py -> /usr/lib/python2.7/site-packages/mysql/connector
copying build/lib/mysql/connector/cursor_cext.py -> /usr/lib/python2.7/site-packages/mysql/connector
copying build/lib/mysql/connector/abstracts.py -> /usr/lib/python2.7/site-packages/mysql/connector
copying build/lib/mysql/connector/utils.py -> /usr/lib/python2.7/site-packages/mysql/connector
copying build/lib/mysql/connector/constants.py -> /usr/lib/python2.7/site-packages/mysql/connector
copying build/lib/mysql/connector/dbapi.py -> /usr/lib/python2.7/site-packages/mysql/connector
copying build/lib/mysql/connector/pooling.py -> /usr/lib/python2.7/site-packages/mysql/connector
copying build/lib/mysql/connector/network.py -> /usr/lib/python2.7/site-packages/mysql/connector
copying build/lib/mysql/connector/conversion.py -> /usr/lib/python2.7/site-packages/mysql/connector
copying build/lib/mysql/connector/connection.py -> /usr/lib/python2.7/site-packages/mysql/connector
copying build/lib/mysql/connector/version.py -> /usr/lib/python2.7/site-packages/mysql/connector
copying build/lib/mysql/connector/connection_cext.py -> /usr/lib/python2.7/site-packages/mysql/connector
copying build/lib/mysql/connector/cursor.py -> /usr/lib/python2.7/site-packages/mysql/connector
copying build/lib/mysql/connector/optionfiles.py -> /usr/lib/python2.7/site-packages/mysql/connector
copying build/lib/mysql/connector/authentication.py -> /usr/lib/python2.7/site-packages/mysql/connector
copying build/lib/mysql/connector/catch23.py -> /usr/lib/python2.7/site-packages/mysql/connector
copying build/lib/mysql/connector/protocol.py -> /usr/lib/python2.7/site-packages/mysql/connector
copying build/lib/mysql/connector/errorcode.py -> /usr/lib/python2.7/site-packages/mysql/connector
creating /usr/lib/python2.7/site-packages/mysql/connector/django
copying build/lib/mysql/connector/django/introspection.py -> /usr/lib/python2.7/site-packages/mysql/connector/django
copying build/lib/mysql/connector/django/validation.py -> /usr/lib/python2.7/site-packages/mysql/connector/django
copying build/lib/mysql/connector/django/__init__.py -> /usr/lib/python2.7/site-packages/mysql/connector/django
copying build/lib/mysql/connector/django/schema.py -> /usr/lib/python2.7/site-packages/mysql/connector/django
copying build/lib/mysql/connector/django/client.py -> /usr/lib/python2.7/site-packages/mysql/connector/django
copying build/lib/mysql/connector/django/operations.py -> /usr/lib/python2.7/site-packages/mysql/connector/django
copying build/lib/mysql/connector/django/compiler.py -> /usr/lib/python2.7/site-packages/mysql/connector/django
copying build/lib/mysql/connector/django/features.py -> /usr/lib/python2.7/site-packages/mysql/connector/django
copying build/lib/mysql/connector/django/creation.py -> /usr/lib/python2.7/site-packages/mysql/connector/django
copying build/lib/mysql/connector/django/base.py -> /usr/lib/python2.7/site-packages/mysql/connector/django
copying build/lib/mysql/__init__.py -> /usr/lib/python2.7/site-packages/mysql
byte-compiling /usr/lib/python2.7/site-packages/mysql/utilities/command/dbexport.py to dbexport.pyc
byte-compiling /usr/lib/python2.7/site-packages/mysql/utilities/command/rpl_admin.py to rpl_admin.pyc
byte-compiling /usr/lib/python2.7/site-packages/mysql/utilities/command/__init__.py to __init__.pyc
byte-compiling /usr/lib/python2.7/site-packages/mysql/utilities/command/userclone.py to userclone.pyc
byte-compiling /usr/lib/python2.7/site-packages/mysql/utilities/command/binlog_admin.py to binlog_admin.pyc
byte-compiling /usr/lib/python2.7/site-packages/mysql/utilities/command/serverclone.py to serverclone.pyc
byte-compiling /usr/lib/python2.7/site-packages/mysql/utilities/command/grep.py to grep.pyc
byte-compiling /usr/lib/python2.7/site-packages/mysql/utilities/command/indexcheck.py to indexcheck.pyc
byte-compiling /usr/lib/python2.7/site-packages/mysql/utilities/command/grants.py to grants.pyc
byte-compiling /usr/lib/python2.7/site-packages/mysql/utilities/command/check_rpl.py to check_rpl.pyc
byte-compiling /usr/lib/python2.7/site-packages/mysql/utilities/command/setup_rpl.py to setup_rpl.pyc
byte-compiling /usr/lib/python2.7/site-packages/mysql/utilities/command/dbimport.py to dbimport.pyc
byte-compiling /usr/lib/python2.7/site-packages/mysql/utilities/command/failover_console.py to failover_console.pyc
byte-compiling /usr/lib/python2.7/site-packages/mysql/utilities/command/dbcopy.py to dbcopy.pyc
byte-compiling /usr/lib/python2.7/site-packages/mysql/utilities/command/proc.py to proc.pyc
byte-compiling /usr/lib/python2.7/site-packages/mysql/utilities/command/rpl_sync_check.py to rpl_sync_check.pyc
byte-compiling /usr/lib/python2.7/site-packages/mysql/utilities/command/serverinfo.py to serverinfo.pyc
byte-compiling /usr/lib/python2.7/site-packages/mysql/utilities/command/failover_daemon.py to failover_daemon.pyc
byte-compiling /usr/lib/python2.7/site-packages/mysql/utilities/command/dbcompare.py to dbcompare.pyc
byte-compiling /usr/lib/python2.7/site-packages/mysql/utilities/command/read_frm.py to read_frm.pyc
byte-compiling /usr/lib/python2.7/site-packages/mysql/utilities/command/diskusage.py to diskusage.pyc
byte-compiling /usr/lib/python2.7/site-packages/mysql/utilities/command/utilitiesconsole.py to utilitiesconsole.pyc
byte-compiling /usr/lib/python2.7/site-packages/mysql/utilities/command/audit_log.py to audit_log.pyc
byte-compiling /usr/lib/python2.7/site-packages/mysql/utilities/command/diff.py to diff.pyc
byte-compiling /usr/lib/python2.7/site-packages/mysql/utilities/command/show_rpl.py to show_rpl.pyc
byte-compiling /usr/lib/python2.7/site-packages/mysql/utilities/common/pattern_matching.py to pattern_matching.pyc
byte-compiling /usr/lib/python2.7/site-packages/mysql/utilities/common/server.py to server.pyc
byte-compiling /usr/lib/python2.7/site-packages/mysql/utilities/common/user.py to user.pyc
byte-compiling /usr/lib/python2.7/site-packages/mysql/utilities/common/variables.py to variables.pyc
byte-compiling /usr/lib/python2.7/site-packages/mysql/utilities/common/ip_parser.py to ip_parser.pyc
byte-compiling /usr/lib/python2.7/site-packages/mysql/utilities/common/replication_ms.py to replication_ms.pyc
byte-compiling /usr/lib/python2.7/site-packages/mysql/utilities/common/audit_log_parser.py to audit_log_parser.pyc
byte-compiling /usr/lib/python2.7/site-packages/mysql/utilities/common/__init__.py to __init__.pyc
byte-compiling /usr/lib/python2.7/site-packages/mysql/utilities/common/lock.py to lock.pyc
byte-compiling /usr/lib/python2.7/site-packages/mysql/utilities/common/tools.py to tools.pyc
byte-compiling /usr/lib/python2.7/site-packages/mysql/utilities/common/topology.py to topology.pyc
byte-compiling /usr/lib/python2.7/site-packages/mysql/utilities/common/table.py to table.pyc
byte-compiling /usr/lib/python2.7/site-packages/mysql/utilities/common/charsets.py to charsets.pyc
byte-compiling /usr/lib/python2.7/site-packages/mysql/utilities/common/parser.py to parser.pyc
byte-compiling /usr/lib/python2.7/site-packages/mysql/utilities/common/messages.py to messages.pyc
byte-compiling /usr/lib/python2.7/site-packages/mysql/utilities/common/gtid.py to gtid.pyc
byte-compiling /usr/lib/python2.7/site-packages/mysql/utilities/common/audit_log_reader.py to audit_log_reader.pyc
byte-compiling /usr/lib/python2.7/site-packages/mysql/utilities/common/database.py to database.pyc
byte-compiling /usr/lib/python2.7/site-packages/mysql/utilities/common/grants_info.py to grants_info.pyc
byte-compiling /usr/lib/python2.7/site-packages/mysql/utilities/common/options.py to options.pyc
byte-compiling /usr/lib/python2.7/site-packages/mysql/utilities/common/my_print_defaults.py to my_print_defaults.pyc
byte-compiling /usr/lib/python2.7/site-packages/mysql/utilities/common/utilities.py to utilities.pyc
byte-compiling /usr/lib/python2.7/site-packages/mysql/utilities/common/options_parser.py to options_parser.pyc
byte-compiling /usr/lib/python2.7/site-packages/mysql/utilities/common/binary_log_file.py to binary_log_file.pyc
byte-compiling /usr/lib/python2.7/site-packages/mysql/utilities/common/daemon.py to daemon.pyc
byte-compiling /usr/lib/python2.7/site-packages/mysql/utilities/common/binlog.py to binlog.pyc
byte-compiling /usr/lib/python2.7/site-packages/mysql/utilities/common/frm_reader.py to frm_reader.pyc
byte-compiling /usr/lib/python2.7/site-packages/mysql/utilities/common/sql_transform.py to sql_transform.pyc
byte-compiling /usr/lib/python2.7/site-packages/mysql/utilities/common/dbcompare.py to dbcompare.pyc
byte-compiling /usr/lib/python2.7/site-packages/mysql/utilities/common/console.py to console.pyc
byte-compiling /usr/lib/python2.7/site-packages/mysql/utilities/common/topology_map.py to topology_map.pyc
byte-compiling /usr/lib/python2.7/site-packages/mysql/utilities/common/format.py to format.pyc
byte-compiling /usr/lib/python2.7/site-packages/mysql/utilities/common/rpl_sync.py to rpl_sync.pyc
byte-compiling /usr/lib/python2.7/site-packages/mysql/utilities/common/replication.py to replication.pyc
byte-compiling /usr/lib/python2.7/site-packages/mysql/utilities/__init__.py to __init__.pyc
byte-compiling /usr/lib/python2.7/site-packages/mysql/utilities/exception.py to exception.pyc
byte-compiling /usr/lib/python2.7/site-packages/mysql/connector/fabric/__init__.py to __init__.pyc
byte-compiling /usr/lib/python2.7/site-packages/mysql/connector/fabric/caching.py to caching.pyc
byte-compiling /usr/lib/python2.7/site-packages/mysql/connector/fabric/connection.py to connection.pyc
byte-compiling /usr/lib/python2.7/site-packages/mysql/connector/fabric/balancing.py to balancing.pyc
byte-compiling /usr/lib/python2.7/site-packages/mysql/connector/locales/__init__.py to __init__.pyc
byte-compiling /usr/lib/python2.7/site-packages/mysql/connector/locales/eng/__init__.py to __init__.pyc
byte-compiling /usr/lib/python2.7/site-packages/mysql/connector/locales/eng/client_error.py to client_error.pyc
byte-compiling /usr/lib/python2.7/site-packages/mysql/connector/custom_types.py to custom_types.pyc
byte-compiling /usr/lib/python2.7/site-packages/mysql/connector/__init__.py to __init__.pyc
byte-compiling /usr/lib/python2.7/site-packages/mysql/connector/charsets.py to charsets.pyc
byte-compiling /usr/lib/python2.7/site-packages/mysql/connector/errors.py to errors.pyc
byte-compiling /usr/lib/python2.7/site-packages/mysql/connector/cursor_cext.py to cursor_cext.pyc
byte-compiling /usr/lib/python2.7/site-packages/mysql/connector/abstracts.py to abstracts.pyc
byte-compiling /usr/lib/python2.7/site-packages/mysql/connector/utils.py to utils.pyc
byte-compiling /usr/lib/python2.7/site-packages/mysql/connector/constants.py to constants.pyc
byte-compiling /usr/lib/python2.7/site-packages/mysql/connector/dbapi.py to dbapi.pyc
byte-compiling /usr/lib/python2.7/site-packages/mysql/connector/pooling.py to pooling.pyc
byte-compiling /usr/lib/python2.7/site-packages/mysql/connector/network.py to network.pyc
byte-compiling /usr/lib/python2.7/site-packages/mysql/connector/conversion.py to conversion.pyc
byte-compiling /usr/lib/python2.7/site-packages/mysql/connector/connection.py to connection.pyc
byte-compiling /usr/lib/python2.7/site-packages/mysql/connector/version.py to version.pyc
byte-compiling /usr/lib/python2.7/site-packages/mysql/connector/connection_cext.py to connection_cext.pyc
byte-compiling /usr/lib/python2.7/site-packages/mysql/connector/cursor.py to cursor.pyc
byte-compiling /usr/lib/python2.7/site-packages/mysql/connector/optionfiles.py to optionfiles.pyc
byte-compiling /usr/lib/python2.7/site-packages/mysql/connector/authentication.py to authentication.pyc
byte-compiling /usr/lib/python2.7/site-packages/mysql/connector/catch23.py to catch23.pyc
byte-compiling /usr/lib/python2.7/site-packages/mysql/connector/protocol.py to protocol.pyc
byte-compiling /usr/lib/python2.7/site-packages/mysql/connector/errorcode.py to errorcode.pyc
byte-compiling /usr/lib/python2.7/site-packages/mysql/connector/django/introspection.py to introspection.pyc
byte-compiling /usr/lib/python2.7/site-packages/mysql/connector/django/validation.py to validation.pyc
byte-compiling /usr/lib/python2.7/site-packages/mysql/connector/django/__init__.py to __init__.pyc
byte-compiling /usr/lib/python2.7/site-packages/mysql/connector/django/schema.py to schema.pyc
byte-compiling /usr/lib/python2.7/site-packages/mysql/connector/django/client.py to client.pyc
byte-compiling /usr/lib/python2.7/site-packages/mysql/connector/django/operations.py to operations.pyc
byte-compiling /usr/lib/python2.7/site-packages/mysql/connector/django/compiler.py to compiler.pyc
byte-compiling /usr/lib/python2.7/site-packages/mysql/connector/django/features.py to features.pyc
byte-compiling /usr/lib/python2.7/site-packages/mysql/connector/django/creation.py to creation.pyc
byte-compiling /usr/lib/python2.7/site-packages/mysql/connector/django/base.py to base.pyc
byte-compiling /usr/lib/python2.7/site-packages/mysql/__init__.py to __init__.pyc
running install_scripts
copying build/scripts-2.7/mysqldbimport -> /usr/bin
copying build/scripts-2.7/mysqlbinlogpurge -> /usr/bin
copying build/scripts-2.7/mysqlfrm -> /usr/bin
copying build/scripts-2.7/mysqlserverclone -> /usr/bin
copying build/scripts-2.7/mysqlindexcheck -> /usr/bin
copying build/scripts-2.7/mysqldiff -> /usr/bin
copying build/scripts-2.7/mysqlbinlogrotate -> /usr/bin
copying build/scripts-2.7/mysqlrpladmin -> /usr/bin
copying build/scripts-2.7/mysqlgrants -> /usr/bin
copying build/scripts-2.7/mysqlrplcheck -> /usr/bin
copying build/scripts-2.7/mysqlprocgrep -> /usr/bin
copying build/scripts-2.7/mysqlauditgrep -> /usr/bin
copying build/scripts-2.7/mysqlrplms -> /usr/bin
copying build/scripts-2.7/mysqlslavetrx -> /usr/bin
copying build/scripts-2.7/mysqlreplicate -> /usr/bin
copying build/scripts-2.7/mysqldbexport -> /usr/bin
copying build/scripts-2.7/mysqlrplshow -> /usr/bin
copying build/scripts-2.7/mysqluc -> /usr/bin
copying build/scripts-2.7/mysqlserverinfo -> /usr/bin
copying build/scripts-2.7/mysqlauditadmin -> /usr/bin
copying build/scripts-2.7/mysqlrplsync -> /usr/bin
copying build/scripts-2.7/mysqldbcompare -> /usr/bin
copying build/scripts-2.7/mysqldiskusage -> /usr/bin
copying build/scripts-2.7/mysqlfailover -> /usr/bin
copying build/scripts-2.7/mysqluserclone -> /usr/bin
copying build/scripts-2.7/mysqlbinlogmove -> /usr/bin
copying build/scripts-2.7/mysqlmetagrep -> /usr/bin
copying build/scripts-2.7/mysqldbcopy -> /usr/bin
changing mode of /usr/bin/mysqldbimport to 755
changing mode of /usr/bin/mysqlbinlogpurge to 755
changing mode of /usr/bin/mysqlfrm to 755
changing mode of /usr/bin/mysqlserverclone to 755
changing mode of /usr/bin/mysqlindexcheck to 755
changing mode of /usr/bin/mysqldiff to 755
changing mode of /usr/bin/mysqlbinlogrotate to 755
changing mode of /usr/bin/mysqlrpladmin to 755
changing mode of /usr/bin/mysqlgrants to 755
changing mode of /usr/bin/mysqlrplcheck to 755
changing mode of /usr/bin/mysqlprocgrep to 755
changing mode of /usr/bin/mysqlauditgrep to 755
changing mode of /usr/bin/mysqlrplms to 755
changing mode of /usr/bin/mysqlslavetrx to 755
changing mode of /usr/bin/mysqlreplicate to 755
changing mode of /usr/bin/mysqldbexport to 755
changing mode of /usr/bin/mysqlrplshow to 755
changing mode of /usr/bin/mysqluc to 755
changing mode of /usr/bin/mysqlserverinfo to 755
changing mode of /usr/bin/mysqlauditadmin to 755
changing mode of /usr/bin/mysqlrplsync to 755
changing mode of /usr/bin/mysqldbcompare to 755
changing mode of /usr/bin/mysqldiskusage to 755
changing mode of /usr/bin/mysqlfailover to 755
changing mode of /usr/bin/mysqluserclone to 755
changing mode of /usr/bin/mysqlbinlogmove to 755
changing mode of /usr/bin/mysqlmetagrep to 755
changing mode of /usr/bin/mysqldbcopy to 755
running install_egg_info
Writing /usr/lib/python2.7/site-packages/mysql_utilities-1.6.5-py2.7.egg-info

安装完成后,在相应的python执行目录下,就能mysqlfrm等执行文件了。

[root@localhost mysql-utilities-1.6.5]# ll
total 140
drwxr-xr-x. 4 root root     34 Mar 19 15:34 build
-rw-r--r--. 1 7161 31415 37814 Jan 18  2017 CHANGES.txt
drwxr-xr-x. 3 7161 31415    16 Jan 18  2017 docs
-rw-r--r--. 1 7161 31415  6680 Jan 18  2017 info.py
-rw-r--r--. 1 root root   5579 Mar 19 15:34 info.pyc
-rw-r--r--. 1 7161 31415 17987 Jan 18  2017 LICENSE.txt
drwxr-xr-x. 4 7161 31415    75 Mar 19 15:34 mysql
-rw-r--r--. 1 7161 31415   928 Jan 18  2017 PKG-INFO
-rw-r--r--. 1 7161 31415 34819 Jan 18  2017 README.txt
drwxr-xr-x. 2 7161 31415  4096 Mar 19 15:34 scripts
-rw-r--r--. 1 7161 31415 14232 Jan 18  2017 setup.py
drwxr-xr-x. 2 7161 31415  4096 Jan 18  2017 unit_tests
[root@localhost mysql-utilities-1.6.5]# cd build
[root@localhost build]# ll
total 4
drwxr-xr-x. 3 root root   18 Mar 19 15:34 lib
drwxr-xr-x. 2 root root 4096 Mar 19 15:34 scripts-2.7
[root@localhost build]# cd scripts-2.7/
[root@localhost scripts-2.7]# ll
total 336
-rwxr-xr-x. 1 root root 11966 Mar 19 15:34 mysqlauditadmin
-rwxr-xr-x. 1 root root 12207 Mar 19 15:34 mysqlauditgrep
-rwxr-xr-x. 1 root root 15938 Mar 19 15:34 mysqlbinlogmove
-rwxr-xr-x. 1 root root  7993 Mar 19 15:34 mysqlbinlogpurge
-rwxr-xr-x. 1 root root  3761 Mar 19 15:34 mysqlbinlogrotate
-rwxr-xr-x. 1 root root 17957 Mar 19 15:34 mysqldbcompare
-rwxr-xr-x. 1 root root 16193 Mar 19 15:34 mysqldbcopy
-rwxr-xr-x. 1 root root 14790 Mar 19 15:34 mysqldbexport
-rwxr-xr-x. 1 root root 14160 Mar 19 15:34 mysqldbimport
-rwxr-xr-x. 1 root root 12368 Mar 19 15:34 mysqldiff
-rwxr-xr-x. 1 root root  7383 Mar 19 15:34 mysqldiskusage
-rwxr-xr-x. 1 root root 17246 Mar 19 15:34 mysqlfailover
-rwxr-xr-x. 1 root root 18219 Mar 19 15:34 mysqlfrm
-rwxr-xr-x. 1 root root 10954 Mar 19 15:34 mysqlgrants
-rwxr-xr-x. 1 root root  6459 Mar 19 15:34 mysqlindexcheck
-rwxr-xr-x. 1 root root  5355 Mar 19 15:34 mysqlmetagrep
-rwxr-xr-x. 1 root root  5972 Mar 19 15:34 mysqlprocgrep
-rwxr-xr-x. 1 root root  7692 Mar 19 15:34 mysqlreplicate
-rwxr-xr-x. 1 root root 16910 Mar 19 15:34 mysqlrpladmin
-rwxr-xr-x. 1 root root  6405 Mar 19 15:34 mysqlrplcheck
-rwxr-xr-x. 1 root root 15545 Mar 19 15:34 mysqlrplms
-rwxr-xr-x. 1 root root  6693 Mar 19 15:34 mysqlrplshow
-rwxr-xr-x. 1 root root 12063 Mar 19 15:34 mysqlrplsync
-rwxr-xr-x. 1 root root  8981 Mar 19 15:34 mysqlserverclone
-rwxr-xr-x. 1 root root  5959 Mar 19 15:34 mysqlserverinfo
-rwxr-xr-x. 1 root root  6412 Mar 19 15:34 mysqlslavetrx
-rwxr-xr-x. 1 root root  6956 Mar 19 15:34 mysqluc
-rwxr-xr-x. 1 root root  8046 Mar 19 15:34 mysqluserclone
]]>
http://www.jydba.net/index.php/archives/3565/feed 0
MySQL数据块损坏的恢复 http://www.jydba.net/index.php/archives/3563 http://www.jydba.net/index.php/archives/3563#respond Sat, 25 May 2024 08:37:44 +0000 http://www.jydba.net/?p=3563 数据页损坏
常规情况下如数据库出现坏块,如果数据库出现极端情况导致innodb_force_recovery=6,无法恢复,需要直接读取ibd 文件数据进行恢复,因此整体的恢复思路是把数据从ibd 读取出来,恢复到另外一个实例中

1.创建测试表

mysql> create table student(stu_id int(12),stu_name varchar(20));
Query OK, 0 rows affected (0.06 sec)
mysql> DELIMITER $
mysql> CREATE PROCEDURE proc_initData()
    -> BEGIN
    ->     DECLARE i INT DEFAULT 1;
    ->     WHILE i<=10000 DO ->         INSERT INTO student (stu_id,stu_name) VALUES(i,concat("张三",i));
    ->         SET i = i+1;
    ->     END WHILE;
    -> END $
Query OK, 0 rows affected (0.01 sec)

mysql> DELIMITER ;
mysql> CALL proc_initData();
Query OK, 1 row affected (4 min 3.81 sec)

mysql> commit;
Query OK, 0 rows affected (0.00 sec)

mysql> select count(*) from student;
+----------+
| count(*) |
+----------+
|    10000 |
+----------+
1 row in set (0.01 sec)

2.标记某个数据块为坏块

[root@localhost soft]# ./bcview /mysqldata/mysql/test/student.ibd 16 0 4
******************************************************************
This Tool Is Uesed For Find The Data In Binary format(Hexadecimal)
Usage:./bcview file blocksize offset cnt-bytes!
file: Is Your File Will To Find Data!
blocksize: Is N kb Block.Eg: 8 Is 8 Kb Blocksize(Oracle)!
                         Eg: 16 Is 16 Kb Blocksize(Innodb)!
offset:Is Every Block Offset Your Want Start!
cnt-bytes:Is After Offset,How Bytes Your Want Gets!
Edtor QQ:22389860!
Used gcc version 4.1.2 20080704 (Red Hat 4.1.2-46)
******************************************************************
----Current file size is :0.515625 Mb
----Current use set blockszie is 16 Kb
----Current file name is /mysqldata/mysql/test/student.ibd
current block:00000000--Offset:00000--cnt bytes:04--data is:808a1848
current block:00000001--Offset:00000--cnt bytes:04--data is:7e4a1bda
current block:00000002--Offset:00000--cnt bytes:04--data is:edb00808
current block:00000003--Offset:00000--cnt bytes:04--data is:572aacd7
current block:00000004--Offset:00000--cnt bytes:04--data is:c8d8b056
current block:00000005--Offset:00000--cnt bytes:04--data is:a216e84e
current block:00000006--Offset:00000--cnt bytes:04--data is:3c61ba87
current block:00000007--Offset:00000--cnt bytes:04--data is:f029a1f5
current block:00000008--Offset:00000--cnt bytes:04--data is:100e39cc
current block:00000009--Offset:00000--cnt bytes:04--data is:076fb5f1
current block:00000010--Offset:00000--cnt bytes:04--data is:7274b593
current block:00000011--Offset:00000--cnt bytes:04--data is:db3e0380
current block:00000012--Offset:00000--cnt bytes:04--data is:4ba9595f
current block:00000013--Offset:00000--cnt bytes:04--data is:614beb2e
current block:00000014--Offset:00000--cnt bytes:04--data is:6d3eafa2
current block:00000015--Offset:00000--cnt bytes:04--data is:02aa16e8
current block:00000016--Offset:00000--cnt bytes:04--data is:9d89e9d8
current block:00000017--Offset:00000--cnt bytes:04--data is:6df78bcf
current block:00000018--Offset:00000--cnt bytes:04--data is:2bacdd4d
current block:00000019--Offset:00000--cnt bytes:04--data is:5aec928c
current block:00000020--Offset:00000--cnt bytes:04--data is:f8645813
current block:00000021--Offset:00000--cnt bytes:04--data is:6fe5578f
current block:00000022--Offset:00000--cnt bytes:04--data is:9bfdc9da
current block:00000023--Offset:00000--cnt bytes:04--data is:02cf14da
current block:00000024--Offset:00000--cnt bytes:04--data is:428d4784
current block:00000025--Offset:00000--cnt bytes:04--data is:b2ef644d
current block:00000026--Offset:00000--cnt bytes:04--data is:7759cc93
current block:00000027--Offset:00000--cnt bytes:04--data is:a68e54f6
current block:00000028--Offset:00000--cnt bytes:04--data is:711ad7b5
current block:00000029--Offset:00000--cnt bytes:04--data is:d5c3ea4b
current block:00000030--Offset:00000--cnt bytes:04--data is:b0dfed41
current block:00000031--Offset:00000--cnt bytes:04--data is:ebb3250c
current block:00000032--Offset:00000--cnt bytes:04--data is:00000000
[root@localhost soft]# ./bctool /mysqldata/mysql/test/student.ibd 2 0 11111111
******************************************************************
This tool is uesed to check data ues binary format,no Big-Endian
or Little-Endian diff,this tool is base one byte on byte to change
!block is 16k.if want change other block eg:8k! please set blocks
0 and offset blocks*8192+offset!
usage:./bctool yfile blocks offset yourdata(XX)!
Warings:backup file frist!!!!!!!!!
Editor QQ:22389860
Ues gcc version 4.1.2 20080704 (Red Hat 4.1.2-46)
******************************************************************
11-11-11-11

重启mysql服务

2024-03-19T07:07:20.192633Z 0 [ERROR] InnoDB: Database page corruption on disk or a failed file read of page [page id: space=51, page number=2]. You may have to recover from a backup.
2024-03-19T07:07:20.192684Z 0 [Note] InnoDB: Page dump in ascii and hex (16384 bytes):
 len 16384; hex 11111111000000020000000000000000000000000089ae2b0003000000000000000000000033ffffffff2024-03-19T07:07:20.193910Z 0 [Note] Failed to start slave threads for channel ''
0000ffffffff000000000000000000010000000000000000ffffffff0000ffffffff000000000000ffffffff0000ffffffff000000000000ffffffff0000ffffffff000005d669d200000003ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00000000000000020000000000000000ffffffff0000ffffffff000000000000ffffffff0000ffffffff000000000000ffffffff0000ffffffff000005d669d20000000400000005000000060000000700000008000000090000000a0000000b0000000c0000000d0000000e0000000f000000100000001100000012000000130000001400000015000000160000001700000018000000190000001a0000001b0000001c0000001d0000001e0000001fffffffffffffffffffffffffffffffff00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002024-03-19T07:07:20.211011Z 0 [Note] Event Scheduler: Loaded 0 events

扫描数据字典文件
一般情况下表结构是存储在frm 文件中,drop table 会删除frm 文件,还好我们可以从innodb 系统表里读取一些信息恢复表结构。innodb 系统表有SYS_COLUMNS | SYS_FIELDS |SYS_INDEXES | SYS_TABLES。需要从系统表中恢复,而系统表是保存在$datadir/ibdata1 文件中的解析ibdata 文件,扫描出所有符合innodb 格式的数据页,结果会按照index_id 进行重新组织

[root@localhost undrop-for-innodb-master]# ./stream_parser -f /mysqldata/mysql/ibdata1
Opening file: /mysqldata/mysql/ibdata1
File information:

ID of device containing file:        64768
inode number:                      4591360
protection:                         100640 (regular file)
number of hard links:                    1
user ID of owner:                       27
group ID of owner:                      27
device ID (if special file):             0
blocksize for filesystem I/O:         4096
number of blocks allocated:         151560
Opening file: /mysqldata/mysql/ibdata1
File information:

ID of device containing file:        64768
inode number:                      4591360
protection:                         100640 (regular file)
number of hard links:                    1
user ID of owner:                       27
group ID of owner:                      27
device ID (if special file):             0
blocksize for filesystem I/O:         4096
number of blocks allocated:         151560
time of last access:            1710832037 Tue Mar 19 15:07:17 2024
time of last modification:      1710832037 Tue Mar 19 15:07:17 2024
time of last status change:     1710832037 Tue Mar 19 15:07:17 2024
total size, in bytes:             77594624 (74.000 MiB)

Size to process:                  77594624 (74.000 MiB)
time of last access:            1710832037 Tue Mar 19 15:07:17 2024
time of last modification:      1710832037 Tue Mar 19 15:07:17 2024
time of last status change:     1710832037 Tue Mar 19 15:07:17 2024
total size, in bytes:             77594624 (74.000 MiB)

Size to process:                  77594624 (74.000 MiB)
Opening file: /mysqldata/mysql/ibdata1
File information:

ID of device containing file:        64768
inode number:                      4591360
protection:                         100640 (regular file)
number of hard links:                    1
user ID of owner:                       27
group ID of owner:                      27
device ID (if special file):             0
blocksize for filesystem I/O:         4096
number of blocks allocated:         151560
Opening file: /mysqldata/mysql/ibdata1
File information:

ID of device containing file:        64768
inode number:                      4591360
protection:                         100640 (regular file)
number of hard links:                    1
user ID of owner:                       27
group ID of owner:                      27
device ID (if special file):             0
blocksize for filesystem I/O:         4096
number of blocks allocated:         151560
time of last access:            1710832037 Tue Mar 19 15:07:17 2024
time of last modification:      1710832037 Tue Mar 19 15:07:17 2024
time of last status change:     1710832037 Tue Mar 19 15:07:17 2024
total size, in bytes:             77594624 (74.000 MiB)

Size to process:                  77594624 (74.000 MiB)
time of last access:            1710832037 Tue Mar 19 15:07:17 2024
time of last modification:      1710832037 Tue Mar 19 15:07:17 2024
time of last status change:     1710832037 Tue Mar 19 15:07:17 2024
total size, in bytes:             77594624 (74.000 MiB)

Size to process:                  77594624 (74.000 MiB)
All workers finished in 0 sec

扫描数据文件

[root@localhost undrop-for-innodb-master]# ./stream_parser -f /mysqldata/mysql/test/student.ibd
Opening file: /mysqldata/mysql/test/student.ibd
File information:

ID of device containing file:        64768
inode number:                    139912091
protection:                         100640 (regular file)
number of hard links:                    1
user ID of owner:                       27
Opening file: /mysqldata/mysql/test/student.ibd
group ID of owner:                      27
device ID (if special file):             0
blocksize for filesystem I/O:         4096
File information:

number of blocks allocated:           1064
ID of device containing file:        64768
inode number:                    139912091
protection:                         100640 (regular file)
number of hard links:                    1
user ID of owner:                       27
group ID of owner:                      27
device ID (if special file):             0
blocksize for filesystem I/O:         4096
number of blocks allocated:           1064
time of last access:            1710832027 Tue Mar 19 15:07:07 2024
time of last modification:      1710832014 Tue Mar 19 15:06:54 2024
time of last status change:     1710832014 Tue Mar 19 15:06:54 2024
total size, in bytes:               540672 (528.000 kiB)

time of last access:            1710832027 Tue Mar 19 15:07:07 2024
time of last modification:      1710832014 Tue Mar 19 15:06:54 2024
Size to process:                    540672 (528.000 kiB)
time of last status change:     1710832014 Tue Mar 19 15:06:54 2024
total size, in bytes:               540672 (528.000 kiB)

Size to process:                    540672 (528.000 kiB)
Opening file: /mysqldata/mysql/test/student.ibd
File information:

ID of device containing file:        64768
inode number:                    139912091
protection:                         100640 (regular file)
number of hard links:                    1
user ID of owner:                       27
group ID of owner:                      27
device ID (if special file):             0
blocksize for filesystem I/O:         4096
number of blocks allocated:           1064
Opening file: /mysqldata/mysql/test/student.ibd
File information:

ID of device containing file:        64768
inode number:                    139912091
protection:                         100640 (regular file)
number of hard links:                    1
user ID of owner:                       27
group ID of owner:                      27
device ID (if special file):             0
blocksize for filesystem I/O:         4096
number of blocks allocated:           1064
time of last access:            1710832027 Tue Mar 19 15:07:07 2024
time of last modification:      1710832014 Tue Mar 19 15:06:54 2024
time of last status change:     1710832014 Tue Mar 19 15:06:54 2024
total size, in bytes:               540672 (528.000 kiB)

Size to process:                    540672 (528.000 kiB)
time of last access:            1710832027 Tue Mar 19 15:07:07 2024
time of last modification:      1710832014 Tue Mar 19 15:06:54 2024
time of last status change:     1710832014 Tue Mar 19 15:06:54 2024
total size, in bytes:               540672 (528.000 kiB)

Size to process:                    540672 (528.000 kiB)
All workers finished in 0 sec

获取table_id

[root@localhost undrop-for-innodb-master]# ./c_parser -4f pages-ibdata1/FIL_PAGE_INDEX/0000000000000001.page -t dictionary/SYS_TABLES.sql | grep student
SET FOREIGN_KEY_CHECKS=0;
LOAD DATA LOCAL INFILE '/undrop-for-innodb-master/dumps/default/SYS_TABLES' REPLACE INTO TABLE `SYS_TABLES` FIELDS TERMINATED BY '\t' OPTIONALLY ENCLOSED BY '"' LINES STARTING BY 'SYS_TABLES\t' (`NAME`, `ID`, `N_COLS`, `TYPE`, `MIX_ID`, `MIX_LEN`, `CLUSTER_NAME`, `SPACE`);
000000004808    A80000011B0110  SYS_TABLES      "test/student"  63      2       33      0       80      ""      51

获取index_id
[root@localhost undrop-for-innodb-master]# ./c_parser -4f pages-ibdata1/FIL_PAGE_INDEX/0000000000000003.page -t dictionary/SYS_INDEXES.sql | grep 63
SET FOREIGN_KEY_CHECKS=0;
LOAD DATA LOCAL INFILE '/undrop-for-innodb-master/dumps/default/SYS_INDEXES' REPLACE INTO TABLE `SYS_INDEXES` FIELDS TERMINATED BY '\t' OPTIONALLY ENCLOSED BY '"' LINES STARTING BY 'SYS_INDEXES\t' (`TABLE_ID`, `ID`, `NAME`, `N_FIELDS`, `TYPE`, `SPACE`, `PAGE_NO`);
000000004808    A80000011B0166  SYS_INDEXES     63      52      "GEN\_CLUST\_INDEX"     0       1       51      3

解析获得ddl 语句

[root@localhost scripts-2.7]# mysqlfrm --diagnostic /mysqldata/mysql/test/student.frm |grep -v "^#"

CREATE TABLE `test`.`student` (
  `stu_id` int(12) DEFAULT NULL,
  `stu_name` varchar(80) DEFAULT NULL
) ENGINE=InnoDB;

[root@localhost tmp]# vi student.sql
CREATE TABLE `student` (
  `stu_id` int(12) DEFAULT NULL,
  `stu_name` varchar(80) DEFAULT NULL
) ENGINE=InnoDB;

解析对应的page 页数据
请注意表结构中不要带有中文和schema_name

[root@localhost undrop-for-innodb-master]# ./c_parser -6f  pages-student.ibd/FIL_PAGE_INDEX/0000000000000052.page -t /tmp/student.sql > dumps/default/student 2> dumps/default/student.sql

[root@localhost undrop-for-innodb-master]# more dumps/default/student.sql
SET FOREIGN_KEY_CHECKS=0;
LOAD DATA LOCAL INFILE '/undrop-for-innodb-master/dumps/default/student' REPLACE INTO TABLE `student` FIELDS TERMINATED BY '\t' OPTIONALLY ENCLOSED BY '"' LINES STARTING BY 'student\t' (`stu_id`, `stu_name`);
[root@localhost undrop-for-innodb-master]# more dumps/default/student
-- Page id: 9, Format: COMPACT, Records list: Valid, Expected records: (376 376)
0000000039B4    0000000050CD    C5000001770110  student 1717    "张三1717"
0000000039B5    0000000050CE    C6000001780110  student 1718    "张三1718"
0000000039B6    0000000050CF    C7000001790110  student 1719    "张三1719"
0000000039B7    0000000050D0    C80000017A0110  student 1720    "张三1720"
0000000039B8    0000000050D1    C90000017B0110  student 1721    "张三1721"
0000000039B9    0000000050D2    CA000001540110  student 1722    "张三1722"
0000000039BA    0000000050D3    CB000001550110  student 1723    "张三1723"
0000000039BB    0000000050D4    CC000001560110  student 1724    "张三1724"
0000000039BC    0000000050D5    CD000001570110  student 1725    "张三1725"
0000000039BD    0000000050D6    CE000001580110  student 1726    "张三1726"
0000000039BE    0000000050D7    CF000001590110  student 1727    "张三1727"
0000000039BF    0000000050D8    D00000015A0110  student 1728    "张三1728"
0000000039C0    0000000050D9    D10000015B0110  student 1729    "张三1729"
0000000039C1    0000000050DA    D20000015C0110  student 1730    "张三1730"
0000000039C2    0000000050DB    D30000015D0110  student 1731    "张三1731"
0000000039C3    0000000050DC    D40000015E0110  student 1732    "张三1732"
0000000039C4    0000000050DD    D50000015F0110  student 1733    "张三1733"
0000000039C5    0000000050DE    D60000017C0110  student 1734    "张三1734"
0000000039C6    0000000050DF    D70000017D0110  student 1735    "张三1735"
0000000039C7    0000000050E0    D80000017E0110  student 1736    "张三1736"
0000000039C8    0000000050E1    D90000017F0110  student 1737    "张三1737"
0000000039C9    0000000050E2    DA000001610110  student 1738    "张三1738"
0000000039CA    0000000050E3    DB000001800110  student 1739    "张三1739"
0000000039CB    0000000050E4    DC000001630110  student 1740    "张三1740"
0000000039CC    0000000050E5    DD000001810110  student 1741    "张三1741"
0000000039CD    0000000050E6    DE000001820110  student 1742    "张三1742"
0000000039CE    0000000050E7    DF000001830110  student 1743    "张三1743"
0000000039CF    0000000050E8    E0000001840110  student 1744    "张三1744"
0000000039D0    0000000050E9    E1000001850110  student 1745    "张三1745"
0000000039D1    0000000050EA    E2000001860110  student 1746    "张三1746"
0000000039D2    0000000050EB    E3000001870110  student 1747    "张三1747"
0000000039D3    0000000050EC    E4000001880110  student 1748    "张三1748"
0000000039D4    0000000050ED    E5000001890110  student 1749    "张三1749"
0000000039D5    0000000050EE    E60000018A0110  student 1750    "张三1750"
0000000039D6    0000000050EF    E70000018B0110  student 1751    "张三1751"
0000000039D7    0000000050F0    E80000018C0110  student 1752    "张三1752"
0000000039D8    0000000050F1    E90000018D0110  student 1753    "张三1753"
0000000039D9    0000000050F2    EA0000018E0110  student 1754    "张三1754"
0000000039DA    0000000050F3    EB0000018F0110  student 1755    "张三1755"
0000000039DB    0000000050F4    EC000001900110  student 1756    "张三1756"
0000000039DC    0000000050F5    ED000001910110  student 1757    "张三1757"
0000000039DD    0000000050F6    EE000001920110  student 1758    "张三1758"
0000000039DE    0000000050F7    EF000001930110  student 1759    "张三1759"
0000000039DF    0000000050F8    F0000001940110  student 1760    "张三1760"
0000000039E0    0000000050F9    F1000001950110  student 1761    "张三1761"
0000000039E1    0000000050FA    F2000001960110  student 1762    "张三1762"
0000000039E2    0000000050FB    F3000001970110  student 1763    "张三1763"
0000000039E3    0000000050FC    F4000001990110  student 1764    "张三1764"
0000000039E4    0000000050FD    F50000019A0110  student 1765    "张三1765"
0000000039E5    0000000050FE    F60000019B0110  student 1766    "张三1766"
0000000039E6    0000000050FF    F70000019C0110  student 1767    "张三1767"
0000000039E7    000000005100    F80000019D0110  student 1768    "张三1768"
0000000039E8    000000005101    F90000019E0110  student 1769    "张三1769"
0000000039E9    000000005102    FA0000019F0110  student 1770    "张三1770"
0000000039EA    000000005103    FB000001A00110  student 1771    "张三1771"
0000000039EB    000000005104    FC000001A10110  student 1772    "张三1772"
0000000039EC    000000005105    FD000001A20110  student 1773    "张三1773"
0000000039ED    000000005106    FE000001A30110  student 1774    "张三1774"
0000000039EE    000000005107    FF000001A40110  student 1775    "张三1775"
0000000039EF    000000005108    800000010D0110  student 1776    "张三1776"
0000000039F0    000000005109    A1000001120110  student 1777    "张三1777"

数据导入

[root@localhost tmp]# scp student.sql root@10.138.130.250:/
The authenticity of host '10.138.130.250 (10.138.130.250)' can't be established.
ECDSA key fingerprint is 7f:1f:9a:0f:8b:d1:e0:17:32:08:12:73:d8:1d:9c:da.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '10.138.130.250' (ECDSA) to the list of known hosts.
root@10.138.130.250's password:
student.sql                                                                                                                                                                                              100%  116     0.1KB/s   00:00
[root@localhost tmp]# scp /undrop-for-innodb-master/dumps/default/student* root@10.138.130.250:/
root@10.138.130.250's password:
student                                                                                                                                                                                                  100% 1699KB   1.7MB/s   00:00
student.sql                                                                                                                                                                                              100%  235     0.2KB/s   00:00
[root@localhost tmp]#
mysql> source /mysqldata/student.sql
Query OK, 0 rows affected (0.00 sec)

Query OK, 25828 rows affected (0.28 sec)
Records: 25828  Deleted: 0  Skipped: 0  Warnings: 0

mysql> select count(*) from student;
+----------+
| count(*) |
+----------+
|    25828 |
+----------+
1 row in set (0.01 sec)

比损坏之前多了一万多条记录。

mysql> select count(distinct stu_id,stu_name) from student;
+---------------------------------+
| count(distinct stu_id,stu_name) |
+---------------------------------+
|                           10000 |
+---------------------------------+
1 row in set (0.03 sec)

mysql> select * from student where stu_id=1;
+--------+----------+
| stu_id | stu_name |
+--------+----------+
|      1 | 张三1    |
+--------+----------+
1 row in set (0.02 sec)

mysql> select * from student where stu_id=2;
+--------+----------+
| stu_id | stu_name |
+--------+----------+
|      2 | 张三2    |
+--------+----------+
1 row in set (0.01 sec)

mysql> select * from student where stu_id=100;
+--------+-----------+
| stu_id | stu_name  |
+--------+-----------+
|    100 | 张三100   |
+--------+-----------+
1 row in set (0.02 sec)

mysql> select * from student where stu_id=1800;
+--------+------------+
| stu_id | stu_name   |
+--------+------------+
|   1800 | 张三1800   |
|   1800 | 张三1800   |
+--------+------------+
2 rows in set (0.02 sec)

也就是标记为损坏的数据块所存储的记录在解析时出现了重复。将重复记录删除掉就可以恢复到损坏状态。

]]>
http://www.jydba.net/index.php/archives/3563/feed 0
MySQL数据文件被删除后不能正常启动的恢复 http://www.jydba.net/index.php/archives/3560 http://www.jydba.net/index.php/archives/3560#respond Tue, 14 May 2024 08:32:32 +0000 http://www.jydba.net/?p=3560 数据文件被删除后的恢复
常规情况下如数据库出现坏块,如果数据库出现极端情况导致innodb_force_recovery=6,无法恢复,需要直接读取ibd 文件数据进行恢复,因此整体的恢复思路是把数据从ibd 读取出来,恢复到另外一个实例中

1.创建测试表

mysql> create table student(stu_id int(12),stu_name varchar(20));
Query OK, 0 rows affected (0.06 sec)
mysql> DELIMITER $
mysql> CREATE PROCEDURE proc_initData()
    -> BEGIN
    ->     DECLARE i INT DEFAULT 1;
    ->     WHILE i< =10000 DO
    ->         INSERT INTO student (stu_id,stu_name) VALUES(i,concat("张三",i));
    ->         SET i = i+1;
    ->     END WHILE;
    -> END $
Query OK, 0 rows affected (0.01 sec)

mysql> DELIMITER ;
mysql> CALL proc_initData();
Query OK, 1 row affected (4 min 3.81 sec)

mysql> commit;
Query OK, 0 rows affected (0.00 sec)

mysql> select count(*) from student;
+----------+
| count(*) |
+----------+
|    10000 |
+----------+
1 row in set (0.01 sec)

2.将数据文件student.ibd模拟损坏其中一个数据块

[root@localhost test]# dd if=/dev/zero of=/mysqldata/mysql/test/student.ibd bs=16384 skip=2 count=1
1+0 records in
1+0 records out
16384 bytes (16 kB) copied, 0.00080267 s, 20.4 MB/s

[root@localhost undrop-for-innodb-master]# service mysqld start
Starting MySQL.. ERROR! The server quit without updating PID file (/mysqldata/mysql/mysqld.pid).

2024-03-15T07:53:59.455587Z 0 [ERROR] InnoDB: The size of tablespace file ./test/student.ibd is only 16384, should be at least 65536!
2024-03-15 15:53:59 0x7f53857fa700  InnoDB: Assertion failure in thread 139996698748672 in file fil0fil.cc line 793

3.设置恢复参数innodb_force_recovery
设置innodb_force_recovery=1-6分别尝试启动mysql服务。

[root@localhost undrop-for-innodb-master]# service mysqld start
Starting MySQL.. SUCCESS!
mysql> show tables;
+----------------+
| Tables_in_test |
+----------------+
| intable        |
| iuser          |
| student        |
| t2             |
+----------------+
4 rows in set (0.01 sec)

mysql> drop table student;
ERROR 1051 (42S02): Unknown table 'test.student'

4.在其它mysql实例中创建一个同名的表并将表的frm文件拷贝到被意外删除表相关文件的目录下后再执行删除

mysql> drop table student;
Query OK, 0 rows affected (0.16 sec)

2024-03-15T08:27:07.906624Z 0 [Warning] Insecure configuration for --secure-file-priv: Current value does not restrict location of generated files. Consider setting it to a valid, non-empty path.
2024-03-15T08:27:07.906835Z 0 [Note] /mysqlsoft/mysql/bin/mysqld (mysqld 5.7.26-log) starting as process 3036 ...
2024-03-15T08:27:07.916535Z 0 [Note] InnoDB: PUNCH HOLE support available
2024-03-15T08:27:07.916618Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2024-03-15T08:27:07.916719Z 0 [Note] InnoDB: Uses event mutexes
2024-03-15T08:27:07.916771Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2024-03-15T08:27:07.916831Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2024-03-15T08:27:07.917573Z 0 [Note] InnoDB: Number of pools: 1
2024-03-15T08:27:07.917926Z 0 [Note] InnoDB: Using CPU crc32 instructions
2024-03-15T08:27:07.922739Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2024-03-15T08:27:07.939838Z 0 [Note] InnoDB: Completed initialization of buffer pool
2024-03-15T08:27:07.945196Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
2024-03-15T08:27:07.987840Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
2024-03-15T08:27:08.275126Z 0 [ERROR] InnoDB: Operating system error number 2 in a file operation.
2024-03-15T08:27:08.275233Z 0 [ERROR] InnoDB: The error means the system cannot find the path specified.
2024-03-15T08:27:08.275297Z 0 [ERROR] InnoDB: If you are installing InnoDB, remember that you must create directories yourself, InnoDB does not create them.
2024-03-15T08:27:08.275331Z 0 [ERROR] InnoDB: Cannot open datafile for read-only: './test/student.ibd' OS error: 71
2024-03-15T08:27:08.275371Z 0 [ERROR] InnoDB: Operating system error number 2 in a file operation.
2024-03-15T08:27:08.275422Z 0 [ERROR] InnoDB: The error means the system cannot find the path specified.
2024-03-15T08:27:08.275450Z 0 [ERROR] InnoDB: If you are installing InnoDB, remember that you must create directories yourself, InnoDB does not create them.
2024-03-15T08:27:08.275481Z 0 [ERROR] InnoDB: Could not find a valid tablespace file for `test/student`. Please refer to http://dev.mysql.com/doc/refman/5.7/en/innodb-troubleshooting-datadict.html for how to resolve the issue.
2024-03-15T08:27:08.275521Z 0 [Warning] InnoDB: Ignoring tablespace `test/student` because it could not be opened.
2024-03-15T08:27:08.277095Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2024-03-15T08:27:08.277447Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2024-03-15T08:27:08.411733Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2024-03-15T08:27:08.414031Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
2024-03-15T08:27:08.414082Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
2024-03-15T08:27:08.414841Z 0 [Note] InnoDB: Waiting for purge to start
2024-03-15T08:27:08.465455Z 0 [Note] InnoDB: 5.7.26 started; log sequence number 6008194
2024-03-15T08:27:08.465540Z 0 [Note] InnoDB: !!! innodb_force_recovery is set to 1 !!!
2024-03-15T08:27:08.465938Z 0 [Note] InnoDB: Loading buffer pool(s) from /mysqldata/mysql/ib_buffer_pool
2024-03-15T08:27:08.466538Z 0 [Note] Plugin 'FEDERATED' is disabled.
2024-03-15T08:27:08.485021Z 0 [Note] InnoDB: Buffer pool(s) load completed at 240315 16:27:08
2024-03-15T08:27:08.555227Z 0 [Note] Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them.
2024-03-15T08:27:08.556469Z 0 [Warning] CA certificate ca.pem is self signed.
2024-03-15T08:27:08.559933Z 0 [Note] Server hostname (bind-address): '*'; port: 3306
2024-03-15T08:27:08.560137Z 0 [Note] IPv6 is available.
2024-03-15T08:27:08.560258Z 0 [Note]   - '::' resolves to '::';
2024-03-15T08:27:08.560370Z 0 [Note] Server socket created on IP: '::'.
2024-03-15T08:27:08.632833Z 0 [Note] Failed to start slave threads for channel ''
2024-03-15T08:27:08.652361Z 0 [Note] Event Scheduler: Loaded 0 events
2024-03-15T08:27:08.652743Z 0 [Note] /mysqlsoft/mysql/bin/mysqld: ready for connections.
Version: '5.7.26-log'  socket: '/mysqlsoft/mysql/mysql.sock'  port: 3306  Source distribution
2024-03-15T08:27:24.889709Z 2 [ERROR] Invalid (old?) table or database name 'mysql-keyring'
2024-03-15T08:36:28.778461Z 2 [ERROR] InnoDB: Failed to find tablespace for table `test`.`student` in the cache. Attempting to load the tablespace with space id 45
2024-03-15T08:36:28.789158Z 2 [ERROR] InnoDB: In file './test/student.ibd', tablespace id and flags are 47 and 33, but in the InnoDB data dictionary they are 45 and 33. Have you moved InnoDB .ibd files around without using the commands DISCARD TABLESPACE and IMPORT TABLESPACE? Please refer to http://dev.mysql.com/doc/refman/5.7/en/innodb-troubleshooting-datadict.html for how to resolve the issue.
2024-03-15T08:36:28.789251Z 2 [ERROR] InnoDB: Operating system error number 2 in a file operation.
2024-03-15T08:36:28.789297Z 2 [ERROR] InnoDB: The error means the system cannot find the path specified.
2024-03-15T08:36:28.789365Z 2 [ERROR] InnoDB: Could not find a valid tablespace file for `test/student`. Please refer to http://dev.mysql.com/doc/refman/5.7/en/innodb-troubleshooting-datadict.html for how to resolve the issue.
]]>
http://www.jydba.net/index.php/archives/3560/feed 0
MySQL Innodb 数据文件头损坏的恢复 http://www.jydba.net/index.php/archives/3556 http://www.jydba.net/index.php/archives/3556#respond Fri, 26 Apr 2024 01:44:00 +0000 http://www.jydba.net/?p=3556 一.数据头损坏
1:观察日志
数据库启动失败,同时查看日志文件中出现头文件校验时出现报错

[root@localhost soft]# service mysqld start

从日志文件可以看到mysql启动失败了,因为Space ID in fsp header is 39, but in the page header it is 38.

2024-03-11T07:32:33.414216Z 0 [ERROR] InnoDB: Space ID in fsp header is 39, but in the page header it is 38.
2024-03-11T07:32:33.414356Z 0 [ERROR] [FATAL] InnoDB: Tablespace id is 38 in the data dictionary but in file ./test/iuser.ibd it is 18446744073709551615!
2024-03-11 15:32:33 0x7efc05ffb700  InnoDB: Assertion failure in thread 139620897502976 in file ut0ut.cc line 942
InnoDB: We intentionally generate a memory trap.
InnoDB: Submit a detailed bug report to http://bugs.mysql.com.
InnoDB: If you get repeated assertion failures or crashes, even
InnoDB: immediately after the mysqld startup, there may be
InnoDB: corruption in the InnoDB tablespace. Please refer to
InnoDB: http://dev.mysql.com/doc/refman/5.7/en/forcing-innodb-recovery.html
InnoDB: about forcing recovery.
07:32:33 UTC - mysqld got signal 6 ;
This could be because you hit a bug. It is also possible that this binary
or one of the libraries it was linked against is corrupt, improperly built,
or misconfigured. This error can also be caused by malfunctioning hardware.
Attempting to collect some information that could help diagnose the problem.
As this is a crash and something is definitely wrong, the information
collection process might fail.

key_buffer_size=8388608
read_buffer_size=131072
max_used_connections=0
max_threads=151
thread_count=0
connection_count=0
It is possible that mysqld could use up to
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 68196 K  bytes of memory
Hope that's ok; if not, decrease some variables in the equation.

Thread pointer: 0x0
Attempting backtrace. You can use the following information to find out
where mysqld died. If you see no messages after this, something went
terribly wrong...
stack_bottom = 0 thread_stack 0x40000
/mysqlsoft/mysql/bin/mysqld(my_print_stacktrace+0x2c)[0xebd4ec]
/mysqlsoft/mysql/bin/mysqld(handle_fatal_signal+0x451)[0x7aa371]
/lib64/libpthread.so.0(+0xf130)[0x7efc4d9e7130]
/lib64/libc.so.6(gsignal+0x37)[0x7efc4c7ec5d7]
/lib64/libc.so.6(abort+0x148)[0x7efc4c7edcc8]
/mysqlsoft/mysql/bin/mysqld[0x77a965]
/mysqlsoft/mysql/bin/mysqld(_ZN2ib5fatalD1Ev+0x4d)[0x108763d]
/mysqlsoft/mysql/bin/mysqld[0x1136bf3]
/mysqlsoft/mysql/bin/mysqld[0x113727a]
/mysqlsoft/mysql/bin/mysqld(_Z6fil_ioRK9IORequestbRK9page_id_tRK11page_size_tmmPvS8_+0x262)[0x1141cc2]
/mysqlsoft/mysql/bin/mysqld[0x10f215a]
/mysqlsoft/mysql/bin/mysqld(_Z24buf_read_page_backgroundRK9page_id_tRK11page_size_tb+0x2b)[0x10f400b]
/mysqlsoft/mysql/bin/mysqld[0x10d7de5]
/mysqlsoft/mysql/bin/mysqld(buf_dump_thread+0x121)[0x10d8371]
/lib64/libpthread.so.0(+0x7df5)[0x7efc4d9dfdf5]
/lib64/libc.so.6(clone+0x6d)[0x7efc4c8ad60d]
The manual page at http://dev.mysql.com/doc/mysql/en/crashing.html contains
information that should help you find out what is causing the crash.

2:space id 说明
正常情况下Space ID 在fsp header 和page header 是一样的。Space id 在所有的页块中中都有存在。其中fsp header(file space header)占用的空间为(数据文件的第一个块的38-150 字节)。page header 占用的空间为每个块固有的前38 字节。而space id 在fsp header 中为38-41,在page header 为34-37.

3:查找正确的space id 值.
由于是某个页头损坏,space id 不正确,而space id 在每个页中都存在,只需要确认绝大部分的页头的的space id 为多少即可。可以看到页头space id 为00000026(16 进制),换成10 进制为38,也就是38 是正确的数字space id。

[root@localhost soft]# ./bcview /mysqldata/mysql/test/iuser.ibd 16 34 4
******************************************************************
This Tool Is Uesed For Find The Data In Binary format(Hexadecimal)
Usage:./bcview file blocksize offset cnt-bytes!
file: Is Your File Will To Find Data!
blocksize: Is N kb Block.Eg: 8 Is 8 Kb Blocksize(Oracle)!
                         Eg: 16 Is 16 Kb Blocksize(Innodb)!
offset:Is Every Block Offset Your Want Start!
cnt-bytes:Is After Offset,How Bytes Your Want Gets!
Edtor QQ:22389860!
Used gcc version 4.1.2 20080704 (Red Hat 4.1.2-46)
******************************************************************
----Current file size is :0.093750 Mb
----Current use set blockszie is 16 Kb
----Current file name is /mysqldata/mysql/test/iuser.ibd
current block:00000000--Offset:00034--cnt bytes:04--data is:00000026
current block:00000001--Offset:00034--cnt bytes:04--data is:00000026
current block:00000002--Offset:00034--cnt bytes:04--data is:00000026
current block:00000003--Offset:00034--cnt bytes:04--data is:00000026
current block:00000004--Offset:00034--cnt bytes:04--data is:00000000
current block:00000005--Offset:00034--cnt bytes:04--data is:00000000

4:查看fsp header 中的space id
由于fsp header 只存在第一个块中38-150,而space id 又存在与38-41 中,因此需要查看第一个块中偏移量为38 开始的后4 个字节内容根据脚本可以查看到具体的为00000027(10 进制为39)

[root@localhost soft]#  ./bcview /mysqldata/mysql/test/iuser.ibd 16 38 4
******************************************************************
This Tool Is Uesed For Find The Data In Binary format(Hexadecimal)
Usage:./bcview file blocksize offset cnt-bytes!
file: Is Your File Will To Find Data!
blocksize: Is N kb Block.Eg: 8 Is 8 Kb Blocksize(Oracle)!
                         Eg: 16 Is 16 Kb Blocksize(Innodb)!
offset:Is Every Block Offset Your Want Start!
cnt-bytes:Is After Offset,How Bytes Your Want Gets!
Edtor QQ:22389860!
Used gcc version 4.1.2 20080704 (Red Hat 4.1.2-46)
******************************************************************
----Current file size is :0.093750 Mb
----Current use set blockszie is 16 Kb
----Current file name is /mysqldata/mysql/test/iuser.ibd
current block:00000000--Offset:00038--cnt bytes:04--data is:00000027
current block:00000001--Offset:00038--cnt bytes:04--data is:00000000
current block:00000002--Offset:00038--cnt bytes:04--data is:ffffffff
current block:00000003--Offset:00038--cnt bytes:04--data is:000200d9
current block:00000004--Offset:00038--cnt bytes:04--data is:00000000
current block:00000005--Offset:00038--cnt bytes:04--data is:00000000

5:修改fsb header 中的space id

[root@localhost soft]# ./bctool /mysqldata/mysql/test/iuser.ibd 0 38 00000026
******************************************************************
This tool is uesed to check data ues binary format,no Big-Endian
or Little-Endian diff,this tool is base one byte on byte to change
!block is 16k.if want change other block eg:8k! please set blocks
0 and offset blocks*8192+offset!
usage:./bctool yfile blocks offset yourdata(XX)!
Warings:backup file frist!!!!!!!!!
Editor QQ:22389860
Ues gcc version 4.1.2 20080704 (Red Hat 4.1.2-46)
******************************************************************
0-0-0-26

再检查确认是否修改正确

[root@localhost soft]# ./bcview /mysqldata/mysql/test/iuser.ibd 16 38 4
******************************************************************
This Tool Is Uesed For Find The Data In Binary format(Hexadecimal)
Usage:./bcview file blocksize offset cnt-bytes!
file: Is Your File Will To Find Data!
blocksize: Is N kb Block.Eg: 8 Is 8 Kb Blocksize(Oracle)!
                         Eg: 16 Is 16 Kb Blocksize(Innodb)!
offset:Is Every Block Offset Your Want Start!
cnt-bytes:Is After Offset,How Bytes Your Want Gets!
Edtor QQ:22389860!
Used gcc version 4.1.2 20080704 (Red Hat 4.1.2-46)
******************************************************************
----Current file size is :0.093750 Mb
----Current use set blockszie is 16 Kb
----Current file name is /mysqldata/mysql/test/iuser.ibd
current block:00000000--Offset:00038--cnt bytes:04--data is:00000026
current block:00000001--Offset:00038--cnt bytes:04--data is:00000000
current block:00000002--Offset:00038--cnt bytes:04--data is:ffffffff
current block:00000003--Offset:00038--cnt bytes:04--data is:000200d9
current block:00000004--Offset:00038--cnt bytes:04--data is:00000000
current block:00000005--Offset:00038--cnt bytes:04--data is:00000000

6:启动恢复

[root@localhost soft]# service mysqld start
Starting MySQL.. SUCCESS!

2024-03-11T08:11:11.170599Z 0 [Warning] Insecure configuration for --secure-file-priv: Current value does not restrict location of generated files. Consider setting it to a valid, non-empty path.
2024-03-11T08:11:11.170822Z 0 [Note] /mysqlsoft/mysql/bin/mysqld (mysqld 5.7.26-log) starting as process 14764 ...
2024-03-11T08:11:11.181460Z 0 [Note] InnoDB: PUNCH HOLE support available
2024-03-11T08:11:11.181548Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2024-03-11T08:11:11.181574Z 0 [Note] InnoDB: Uses event mutexes
2024-03-11T08:11:11.181591Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2024-03-11T08:11:11.181622Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2024-03-11T08:11:11.182346Z 0 [Note] InnoDB: Number of pools: 1
2024-03-11T08:11:11.182638Z 0 [Note] InnoDB: Using CPU crc32 instructions
2024-03-11T08:11:11.187180Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2024-03-11T08:11:11.204123Z 0 [Note] InnoDB: Completed initialization of buffer pool
2024-03-11T08:11:11.209837Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
2024-03-11T08:11:11.251385Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
2024-03-11T08:11:11.471672Z 0 [Note] InnoDB: Removed temporary tablespace data file: "ibtmp1"
2024-03-11T08:11:11.471768Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2024-03-11T08:11:11.472040Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2024-03-11T08:11:11.570867Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2024-03-11T08:11:11.572707Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
2024-03-11T08:11:11.572759Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
2024-03-11T08:11:11.574109Z 0 [Note] InnoDB: Waiting for purge to start
2024-03-11T08:11:11.624691Z 0 [Note] InnoDB: 5.7.26 started; log sequence number 2950883
2024-03-11T08:11:11.626078Z 0 [Note] InnoDB: Loading buffer pool(s) from /mysqldata/mysql/ib_buffer_pool
2024-03-11T08:11:11.626717Z 0 [Note] Plugin 'FEDERATED' is disabled.
2024-03-11T08:11:11.649744Z 0 [Note] Recovering after a crash using /mysqldata/mysql/binlog
2024-03-11T08:11:11.649798Z 0 [Note] Starting crash recovery...
2024-03-11T08:11:11.649921Z 0 [Note] Crash recovery finished.
2024-03-11T08:11:11.736054Z 0 [Note] Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them.
2024-03-11T08:11:11.737385Z 0 [Warning] CA certificate ca.pem is self signed.
2024-03-11T08:11:11.740836Z 0 [Note] Server hostname (bind-address): '*'; port: 3306
2024-03-11T08:11:11.743232Z 0 [Note] IPv6 is available.
2024-03-11T08:11:11.743360Z 0 [Note]   - '::' resolves to '::';
2024-03-11T08:11:11.743427Z 0 [Note] Server socket created on IP: '::'.
2024-03-11T08:11:11.790698Z 0 [Note] Failed to start slave threads for channel ''
2024-03-11T08:11:11.811031Z 0 [Note] Event Scheduler: Loaded 0 events
2024-03-11T08:11:11.811400Z 0 [Note] /mysqlsoft/mysql/bin/mysqld: ready for connections.
Version: '5.7.26-log'  socket: '/mysqlsoft/mysql/mysql.sock'  port: 3306  Source distribution
2024-03-11T08:11:11.818280Z 0 [Note] InnoDB: Buffer pool(s) load completed at 240311 16:11:11
]]>
http://www.jydba.net/index.php/archives/3556/feed 0
恢复MySQL5.7中被Truncate掉的表 http://www.jydba.net/index.php/archives/3549 http://www.jydba.net/index.php/archives/3549#respond Sun, 11 Feb 2024 07:37:51 +0000 http://www.jydba.net/?p=3549 恢复MySQL被Truncate掉的表
innodb_file_per_table=ON 场景下,truncate 表后,.ibd 文件会收缩,需要扫描磁盘获取相应的数据页进行恢复。
下面以innodb_file_per_table=ON 场景下恢复为例
一.安装undrop-for-innodb软件
1:上传undrop-for-innodb-develop.zip

2:安装编译环境
yum install make gcc flex bison
3:解压

[root@localhost /]# unzip undrop-for-innodb-master.zip
Archive:  undrop-for-innodb-master.zip
ade0fbb31218f655eeff97f559d47c6545478734
   creating: undrop-for-innodb-master/
  inflating: undrop-for-innodb-master/LICENSE  
  inflating: undrop-for-innodb-master/Makefile  
  inflating: undrop-for-innodb-master/README.md  
  inflating: undrop-for-innodb-master/c_parser.c  
  inflating: undrop-for-innodb-master/check_data.c  
   creating: undrop-for-innodb-master/dictionary/
  inflating: undrop-for-innodb-master/dictionary/SYS_COLUMNS.sql  
  inflating: undrop-for-innodb-master/dictionary/SYS_FIELDS.sql  
  inflating: undrop-for-innodb-master/dictionary/SYS_INDEXES.sql  
  inflating: undrop-for-innodb-master/dictionary/SYS_TABLES.sql  
  inflating: undrop-for-innodb-master/fetch_data.sh  
   creating: undrop-for-innodb-master/include/
  inflating: undrop-for-innodb-master/include/bchange.c  
  inflating: undrop-for-innodb-master/include/bcmp.c  
  inflating: undrop-for-innodb-master/include/bfill.c  
  inflating: undrop-for-innodb-master/include/bmove.c  
  inflating: undrop-for-innodb-master/include/bmove512.c  
  inflating: undrop-for-innodb-master/include/bmove_upp.c  
  inflating: undrop-for-innodb-master/include/btr0btr.h  
  inflating: undrop-for-innodb-master/include/btr0btr.ic  
  inflating: undrop-for-innodb-master/include/btr0cur.h  
  inflating: undrop-for-innodb-master/include/btr0cur.ic  
  inflating: undrop-for-innodb-master/include/btr0types.h  
  inflating: undrop-for-innodb-master/include/buf0buf.h  
  inflating: undrop-for-innodb-master/include/buf0buf.ic  
  inflating: undrop-for-innodb-master/include/buf0flu.h  
  inflating: undrop-for-innodb-master/include/buf0flu.ic  
  inflating: undrop-for-innodb-master/include/buf0lru.h  
  inflating: undrop-for-innodb-master/include/buf0lru.ic  
  inflating: undrop-for-innodb-master/include/buf0rea.h  
  inflating: undrop-for-innodb-master/include/buf0types.h  
  inflating: undrop-for-innodb-master/include/check_data.h  
  inflating: undrop-for-innodb-master/include/ctype-bin.c  
  inflating: undrop-for-innodb-master/include/ctype-latin1.c  
  inflating: undrop-for-innodb-master/include/ctype-mb.c  
  inflating: undrop-for-innodb-master/include/ctype-simple.c  
  inflating: undrop-for-innodb-master/include/ctype-utf8.c  
  inflating: undrop-for-innodb-master/include/ctype.c  
  inflating: undrop-for-innodb-master/include/data0data.h  
  inflating: undrop-for-innodb-master/include/data0data.ic  
  inflating: undrop-for-innodb-master/include/data0type.h  
  inflating: undrop-for-innodb-master/include/data0type.ic  
  inflating: undrop-for-innodb-master/include/data0types.h  
  inflating: undrop-for-innodb-master/include/db0err.h  
  inflating: undrop-for-innodb-master/include/decimal.c  
  inflating: undrop-for-innodb-master/include/decimal.h  
  inflating: undrop-for-innodb-master/include/dict0dict.h  
  inflating: undrop-for-innodb-master/include/dict0dict.ic  
  inflating: undrop-for-innodb-master/include/dict0load.h  
  inflating: undrop-for-innodb-master/include/dict0load.ic  
  inflating: undrop-for-innodb-master/include/dict0mem.h  
  inflating: undrop-for-innodb-master/include/dict0mem.ic  
  inflating: undrop-for-innodb-master/include/dict0types.h  
  inflating: undrop-for-innodb-master/include/dyn0dyn.h  
  inflating: undrop-for-innodb-master/include/dyn0dyn.ic  
  inflating: undrop-for-innodb-master/include/fil0fil.h  
  inflating: undrop-for-innodb-master/include/fsp0fsp.h  
  inflating: undrop-for-innodb-master/include/fsp0fsp.ic  
  inflating: undrop-for-innodb-master/include/fut0fut.h  
  inflating: undrop-for-innodb-master/include/fut0fut.ic  
  inflating: undrop-for-innodb-master/include/fut0lst.h  
  inflating: undrop-for-innodb-master/include/fut0lst.ic  
  inflating: undrop-for-innodb-master/include/ha0ha.h  
  inflating: undrop-for-innodb-master/include/ha0ha.ic  
  inflating: undrop-for-innodb-master/include/hash0hash.h  
  inflating: undrop-for-innodb-master/include/hash0hash.ic  
  inflating: undrop-for-innodb-master/include/ib_config.h  
  inflating: undrop-for-innodb-master/include/ibuf0types.h  
  inflating: undrop-for-innodb-master/include/innochecksum.h  
  inflating: undrop-for-innodb-master/include/int2str.c  
  inflating: undrop-for-innodb-master/include/is_prefix.c  
  inflating: undrop-for-innodb-master/include/llstr.c  
  inflating: undrop-for-innodb-master/include/lock0types.h  
  inflating: undrop-for-innodb-master/include/longlong2str.c  
  inflating: undrop-for-innodb-master/include/m_ctype.h  
  inflating: undrop-for-innodb-master/include/m_string.h  
  inflating: undrop-for-innodb-master/include/mach0data.h  
  inflating: undrop-for-innodb-master/include/mach0data.ic  
  inflating: undrop-for-innodb-master/include/mem0dbg.h  
  inflating: undrop-for-innodb-master/include/mem0dbg.ic  
  inflating: undrop-for-innodb-master/include/mem0mem.h  
  inflating: undrop-for-innodb-master/include/mem0mem.ic  
  inflating: undrop-for-innodb-master/include/mem0pool.h  
  inflating: undrop-for-innodb-master/include/mem0pool.ic  
  inflating: undrop-for-innodb-master/include/mtr0log.h  
  inflating: undrop-for-innodb-master/include/mtr0log.ic  
  inflating: undrop-for-innodb-master/include/mtr0mtr.h  
  inflating: undrop-for-innodb-master/include/mtr0mtr.ic  
  inflating: undrop-for-innodb-master/include/mtr0types.h  
  inflating: undrop-for-innodb-master/include/my_alloc.h  
  inflating: undrop-for-innodb-master/include/my_attribute.h  
  inflating: undrop-for-innodb-master/include/my_base.h  
  inflating: undrop-for-innodb-master/include/my_config.h  
  inflating: undrop-for-innodb-master/include/my_dbug.h  
  inflating: undrop-for-innodb-master/include/my_global.h  
  inflating: undrop-for-innodb-master/include/my_list.h  
  inflating: undrop-for-innodb-master/include/my_pthread.h  
  inflating: undrop-for-innodb-master/include/my_strtoll10.c  
  inflating: undrop-for-innodb-master/include/my_sys.h  
  inflating: undrop-for-innodb-master/include/my_vsnprintf.c  
  inflating: undrop-for-innodb-master/include/my_xml.h  
  inflating: undrop-for-innodb-master/include/myisampack.h  
  inflating: undrop-for-innodb-master/include/mysql_def.h  
  inflating: undrop-for-innodb-master/include/os0file.h  
  inflating: undrop-for-innodb-master/include/os0proc.h  
  inflating: undrop-for-innodb-master/include/os0proc.ic  
  inflating: undrop-for-innodb-master/include/os0sync.h  
  inflating: undrop-for-innodb-master/include/os0sync.ic  
  inflating: undrop-for-innodb-master/include/os0thread.h  
  inflating: undrop-for-innodb-master/include/os0thread.ic  
  inflating: undrop-for-innodb-master/include/page0cur.h  
  inflating: undrop-for-innodb-master/include/page0cur.ic  
  inflating: undrop-for-innodb-master/include/page0page.h  
  inflating: undrop-for-innodb-master/include/page0page.ic  
  inflating: undrop-for-innodb-master/include/page0types.h  
  inflating: undrop-for-innodb-master/include/print_data.h  
  inflating: undrop-for-innodb-master/include/que0types.h  
  inflating: undrop-for-innodb-master/include/r_strinstr.c  
  inflating: undrop-for-innodb-master/include/raid.h  
  inflating: undrop-for-innodb-master/include/read0types.h  
  inflating: undrop-for-innodb-master/include/rem0cmp.h  
  inflating: undrop-for-innodb-master/include/rem0cmp.ic  
  inflating: undrop-for-innodb-master/include/rem0rec.h  
  inflating: undrop-for-innodb-master/include/rem0rec.ic  
  inflating: undrop-for-innodb-master/include/rem0types.h  
  inflating: undrop-for-innodb-master/include/row0types.h  
  inflating: undrop-for-innodb-master/include/srv0srv.h  
  inflating: undrop-for-innodb-master/include/str2int.c  
  inflating: undrop-for-innodb-master/include/str_alloc.c  
  inflating: undrop-for-innodb-master/include/strappend.c  
  inflating: undrop-for-innodb-master/include/strcend.c  
  inflating: undrop-for-innodb-master/include/strcont.c  
  inflating: undrop-for-innodb-master/include/strend.c  
  inflating: undrop-for-innodb-master/include/strfill.c  
  inflating: undrop-for-innodb-master/include/strinstr.c  
  inflating: undrop-for-innodb-master/include/strmake.c  
  inflating: undrop-for-innodb-master/include/strmov.c  
  inflating: undrop-for-innodb-master/include/strnlen.c  
  inflating: undrop-for-innodb-master/include/strnmov.c  
  inflating: undrop-for-innodb-master/include/strstr.c  
  inflating: undrop-for-innodb-master/include/strtod.c  
  inflating: undrop-for-innodb-master/include/strtol.c  
  inflating: undrop-for-innodb-master/include/strtoll.c  
  inflating: undrop-for-innodb-master/include/strtoul.c  
  inflating: undrop-for-innodb-master/include/strtoull.c  
  inflating: undrop-for-innodb-master/include/strxmov.c  
  inflating: undrop-for-innodb-master/include/strxnmov.c  
  inflating: undrop-for-innodb-master/include/sync0arr.h  
  inflating: undrop-for-innodb-master/include/sync0arr.ic  
  inflating: undrop-for-innodb-master/include/sync0rw.h  
  inflating: undrop-for-innodb-master/include/sync0rw.ic  
  inflating: undrop-for-innodb-master/include/sync0sync.h  
  inflating: undrop-for-innodb-master/include/sync0sync.ic  
  inflating: undrop-for-innodb-master/include/sync0types.h  
  inflating: undrop-for-innodb-master/include/tables_dict.h  
  inflating: undrop-for-innodb-master/include/trx0sys.h  
  inflating: undrop-for-innodb-master/include/trx0sys.ic  
  inflating: undrop-for-innodb-master/include/trx0trx.h  
  inflating: undrop-for-innodb-master/include/trx0trx.ic  
  inflating: undrop-for-innodb-master/include/trx0types.h  
  inflating: undrop-for-innodb-master/include/trx0undo.h  
  inflating: undrop-for-innodb-master/include/trx0undo.ic  
  inflating: undrop-for-innodb-master/include/trx0xa.h  
  inflating: undrop-for-innodb-master/include/typelib.h  
  inflating: undrop-for-innodb-master/include/univ.i  
  inflating: undrop-for-innodb-master/include/usr0types.h  
  inflating: undrop-for-innodb-master/include/ut0byte.h  
  inflating: undrop-for-innodb-master/include/ut0byte.ic  
  inflating: undrop-for-innodb-master/include/ut0dbg.h  
  inflating: undrop-for-innodb-master/include/ut0lst.h  
  inflating: undrop-for-innodb-master/include/ut0mem.h  
  inflating: undrop-for-innodb-master/include/ut0mem.ic  
  inflating: undrop-for-innodb-master/include/ut0rnd.h  
  inflating: undrop-for-innodb-master/include/ut0rnd.ic  
  inflating: undrop-for-innodb-master/include/ut0ut.h  
  inflating: undrop-for-innodb-master/include/ut0ut.ic  
  inflating: undrop-for-innodb-master/include/xml.c  
  inflating: undrop-for-innodb-master/innochecksum.c  
  inflating: undrop-for-innodb-master/print_data.c  
  inflating: undrop-for-innodb-master/recover_dictionary.sh  
   creating: undrop-for-innodb-master/sakila/
  inflating: undrop-for-innodb-master/sakila/actor.sql  
  inflating: undrop-for-innodb-master/sakila/address.sql  
  inflating: undrop-for-innodb-master/sakila/category.sql  
  inflating: undrop-for-innodb-master/sakila/city.sql  
  inflating: undrop-for-innodb-master/sakila/country.sql  
  inflating: undrop-for-innodb-master/sakila/customer.sql  
  inflating: undrop-for-innodb-master/sakila/film.sql  
  inflating: undrop-for-innodb-master/sakila/film_actor.sql  
  inflating: undrop-for-innodb-master/sakila/film_category.sql  
  inflating: undrop-for-innodb-master/sakila/inventory.sql  
  inflating: undrop-for-innodb-master/sakila/language.sql  
  inflating: undrop-for-innodb-master/sakila/payment.sql  
  inflating: undrop-for-innodb-master/sakila/rental.sql  
  inflating: undrop-for-innodb-master/sakila/sakila-db.tar.gz  
  inflating: undrop-for-innodb-master/sakila/staff.sql  
  inflating: undrop-for-innodb-master/sakila/store.sql  
  inflating: undrop-for-innodb-master/sql_parser.l  
  inflating: undrop-for-innodb-master/sql_parser.y  
  inflating: undrop-for-innodb-master/stream_parser.c  
  inflating: undrop-for-innodb-master/sys_parser.c  
  inflating: undrop-for-innodb-master/tables_dict.c  
  inflating: undrop-for-innodb-master/test.sh  

4:编译

[root@localhost /]# cd undrop-for-innodb-master
[root@localhost undrop-for-innodb-master]# ll
total 208
-rw-r--r--. 1 root root  6271 Oct  2  2015 check_data.c
-rw-r--r--. 1 root root 28689 Oct  2  2015 c_parser.c
drwxr-xr-x. 2 root root    92 Oct  2  2015 dictionary
-rw-r--r--. 1 root root  1978 Oct  2  2015 fetch_data.sh
drwxr-xr-x. 2 root root  4096 Oct  2  2015 include
-rw-r--r--. 1 root root  8936 Oct  2  2015 innochecksum.c
-rw-r--r--. 1 root root 18047 Oct  2  2015 LICENSE
-rw-r--r--. 1 root root  1816 Oct  2  2015 Makefile
-rw-r--r--. 1 root root 16585 Oct  2  2015 print_data.c
-rw-r--r--. 1 root root  3467 Oct  2  2015 README.md
-rwxr-xr-x. 1 root root  1536 Oct  2  2015 recover_dictionary.sh
drwxr-xr-x. 2 root root  4096 Oct  2  2015 sakila
-rw-r--r--. 1 root root  7244 Oct  2  2015 sql_parser.l
-rw-r--r--. 1 root root 25607 Oct  2  2015 sql_parser.y
-rw-r--r--. 1 root root 23004 Oct  2  2015 stream_parser.c
-rw-r--r--. 1 root root 14764 Oct  2  2015 sys_parser.c
-rw-r--r--. 1 root root  2237 Oct  2  2015 tables_dict.c
-rwxr-xr-x. 1 root root  6178 Oct  2  2015 test.sh
[root@localhost undrop-for-innodb-master]# make
cc -D_FILE_OFFSET_BITS=64 -Wall -g -O3 -pipe  -I./include -c stream_parser.c
stream_parser.c: In function ‘valid_innodb_page’:
stream_parser.c:151:31: warning: variable ‘oldcsumfield’ set but not used [-Wunused-but-set-variable]
     unsigned int page_n_heap, oldcsumfield;
                               ^
stream_parser.c: In function ‘process_ibpage’:
stream_parser.c:313:9: warning: variable ‘sem’ set but not used [-Wunused-but-set-variable]
     int sem = (page_type == FIL_PAGE_INDEX) 
         ^
stream_parser.c: In function ‘process_ibfile’:
stream_parser.c:333:13: warning: variable ‘prev_disk_offset’ set but not used [-Wunused-but-set-variable]
     off64_t prev_disk_offset = 0;
             ^
cc -D_FILE_OFFSET_BITS=64 -Wall -g -O3 -pipe  -I./include  -pthread -lm  stream_parser.o -o stream_parser
flex  sql_parser.l
bison  -o sql_parser.c sql_parser.y
sql_parser.y: warning: 6 shift/reduce conflicts [-Wconflicts-sr]
cc -D_FILE_OFFSET_BITS=64 -Wall -g -O3 -pipe  -I./include -c sql_parser.c 
sql_parser.y: In function ‘yyparse’:
sql_parser.y:166:39: warning: variable ‘none’ set but not used [-Wunused-but-set-variable]
         field_def_t trx_id, roll_ptr, none;
                                       ^
In file included from sql_parser.y:660:0:
sql_parser.y: At top level:
lex.yy.c:3085:17: warning: ‘yyunput’ defined but not used [-Wunused-function]
     static void yyunput (int c, register char * yy_bp )
                 ^
lex.yy.c:3126:16: warning: ‘input’ defined but not used [-Wunused-function]
     static int input  (void)
                ^
cc -D_FILE_OFFSET_BITS=64 -Wall -g -O3 -pipe  -I./include -c c_parser.c
In file included from c_parser.c:39:0:
decimal.c: In function ‘decimal_intg’:
decimal.c:1923:9: warning: variable ‘tmp_res’ set but not used [-Wunused-but-set-variable]
In file included from c_parser.c:35:0:
c_parser.c: At top level:
./include/ctype-latin1.c:359:5: warning: ‘my_mb_wc_latin1’ defined but not used [-Wunused-function]
 int my_mb_wc_latin1(CHARSET_INFO *cs  __attribute__((unused)),
     ^
./include/ctype-latin1.c:372:5: warning: ‘my_wc_mb_latin1’ defined but not used [-Wunused-function]
 int my_wc_mb_latin1(CHARSET_INFO *cs  __attribute__((unused)),
     ^
cc -D_FILE_OFFSET_BITS=64 -Wall -g -O3 -pipe  -I./include -c tables_dict.c
cc -D_FILE_OFFSET_BITS=64 -Wall -g -O3 -pipe  -I./include -c print_data.c
cc -D_FILE_OFFSET_BITS=64 -Wall -g -O3 -pipe  -I./include -c check_data.c
cc -D_FILE_OFFSET_BITS=64 -Wall -g -O3 -pipe   -I./include  sql_parser.o c_parser.o tables_dict.o print_data.o check_data.o -o c_parser -pthread -lm
cc -D_FILE_OFFSET_BITS=64 -Wall -g -O3 -pipe   -I./include -o innochecksum_changer innochecksum.c
[root@localhost undrop-for-innodb-master]# ll
total 2904
-rw-r--r--. 1 root root    6271 Oct  2  2015 check_data.c
-rw-r--r--. 1 root root   66088 Jan 17 16:59 check_data.o
-rwxr-xr-x. 1 root root  725572 Jan 17 16:59 c_parser
-rw-r--r--. 1 root root   28689 Oct  2  2015 c_parser.c
-rw-r--r--. 1 root root 1038536 Jan 17 16:59 c_parser.o
drwxr-xr-x. 2 root root      92 Oct  2  2015 dictionary
-rw-r--r--. 1 root root    1978 Oct  2  2015 fetch_data.sh
drwxr-xr-x. 2 root root    4096 Oct  2  2015 include
-rw-r--r--. 1 root root    8936 Oct  2  2015 innochecksum.c
-rwxr-xr-x. 1 root root   36399 Jan 17 16:59 innochecksum_changer
-rw-r--r--. 1 root root  134778 Jan 17 16:59 lex.yy.c
-rw-r--r--. 1 root root   18047 Oct  2  2015 LICENSE
-rw-r--r--. 1 root root    1816 Oct  2  2015 Makefile
-rw-r--r--. 1 root root   16585 Oct  2  2015 print_data.c
-rw-r--r--. 1 root root  127136 Jan 17 16:59 print_data.o
-rw-r--r--. 1 root root    3467 Oct  2  2015 README.md
-rwxr-xr-x. 1 root root    1536 Oct  2  2015 recover_dictionary.sh
drwxr-xr-x. 2 root root    4096 Oct  2  2015 sakila
-rw-r--r--. 1 root root  102053 Jan 17 16:59 sql_parser.c
-rw-r--r--. 1 root root    7244 Oct  2  2015 sql_parser.l
-rw-r--r--. 1 root root  287296 Jan 17 16:59 sql_parser.o
-rw-r--r--. 1 root root   25607 Oct  2  2015 sql_parser.y
-rwxr-xr-x. 1 root root   63657 Jan 17 16:59 stream_parser
-rw-r--r--. 1 root root   23004 Oct  2  2015 stream_parser.c
-rw-r--r--. 1 root root  114944 Jan 17 16:59 stream_parser.o
-rw-r--r--. 1 root root   14764 Oct  2  2015 sys_parser.c
-rw-r--r--. 1 root root    2237 Oct  2  2015 tables_dict.c
-rw-r--r--. 1 root root   40176 Jan 17 16:59 tables_dict.o
-rwxr-xr-x. 1 root root    6178 Oct  2  2015 test.sh
[root@localhost undrop-for-innodb-master]#  make sys_parser
/mysqlsoft/mysql/bin/mysql_config
cc -o sys_parser sys_parser.c `mysql_config --cflags` `mysql_config --libs`

5:验证
编译完成后在undrop-for-innodb 目录下生成stream_parser 和c_parser, sys_parser 文件。

[root@localhost undrop-for-innodb-master]# ll
total 2928
-rw-r--r--. 1 root root    6271 Oct  2  2015 check_data.c
-rw-r--r--. 1 root root   66088 Jan 17 16:59 check_data.o
-rwxr-xr-x. 1 root root  725572 Jan 17 16:59 c_parser
-rw-r--r--. 1 root root   28689 Oct  2  2015 c_parser.c
-rw-r--r--. 1 root root 1038536 Jan 17 16:59 c_parser.o
drwxr-xr-x. 2 root root      92 Oct  2  2015 dictionary
-rw-r--r--. 1 root root    1978 Oct  2  2015 fetch_data.sh
drwxr-xr-x. 2 root root    4096 Oct  2  2015 include
-rw-r--r--. 1 root root    8936 Oct  2  2015 innochecksum.c
-rwxr-xr-x. 1 root root   36399 Jan 17 16:59 innochecksum_changer
-rw-r--r--. 1 root root  134778 Jan 17 16:59 lex.yy.c
-rw-r--r--. 1 root root   18047 Oct  2  2015 LICENSE
-rw-r--r--. 1 root root    1816 Oct  2  2015 Makefile
-rw-r--r--. 1 root root   16585 Oct  2  2015 print_data.c
-rw-r--r--. 1 root root  127136 Jan 17 16:59 print_data.o
-rw-r--r--. 1 root root    3467 Oct  2  2015 README.md
-rwxr-xr-x. 1 root root    1536 Oct  2  2015 recover_dictionary.sh
drwxr-xr-x. 2 root root    4096 Oct  2  2015 sakila
-rw-r--r--. 1 root root  102053 Jan 17 16:59 sql_parser.c
-rw-r--r--. 1 root root    7244 Oct  2  2015 sql_parser.l
-rw-r--r--. 1 root root  287296 Jan 17 16:59 sql_parser.o
-rw-r--r--. 1 root root   25607 Oct  2  2015 sql_parser.y
-rwxr-xr-x. 1 root root   63657 Jan 17 16:59 stream_parser
-rw-r--r--. 1 root root   23004 Oct  2  2015 stream_parser.c
-rw-r--r--. 1 root root  114944 Jan 17 16:59 stream_parser.o
-rwxr-xr-x. 1 root root   20650 Jan 17 17:05 sys_parser
-rw-r--r--. 1 root root   14764 Oct  2  2015 sys_parser.c
-rw-r--r--. 1 root root    2237 Oct  2  2015 tables_dict.c
-rw-r--r--. 1 root root   40176 Jan 17 16:59 tables_dict.o
-rwxr-xr-x. 1 root root    6178 Oct  2  2015 test.sh

二.执行truncate table恢复操作
1:执行truncate table命令删除表中所有记录

mysql> select * from t2;
+------+
| i    |
+------+
|    3 |
|    7 |
|   11 |
|   15 |
|    2 |
|    6 |
|   10 |
|   14 |
+------+
8 rows in set (0.00 sec)

mysql> truncate table t2;
Query OK, 0 rows affected (0.27 sec)

mysql> select * from t2;
Empty set (0.00 sec)

2:确认硬盘分区

[root@localhost undrop-for-innodb-master]# more /mysqlsoft/mysql/my.cnf | grep datadir
datadir=/mysqldata/mysql

[root@localhost undrop-for-innodb-master]# df -h /mysqldata/mysql
Filesystem           Size  Used Avail Use% Mounted on
/dev/mapper/ol-root   72G   64G  8.0G  89% /

3:扫描硬盘分区
由于truncate 操作会把磁盘上对应的ibd 文件也一起删除,因此需要扫描磁盘,找到对应的数据页

[root@localhost undrop-for-innodb-master]# ./stream_parser -f /dev/mapper/ol-root -t 72G
Opening file: /dev/mapper/ol-root
File information:

Opening file: /dev/mapper/ol-root
File information:

Opening file: /dev/mapper/ol-root
File information:

ID of device containing file:            5
ID of device containing file:            5
ID of device containing file:            5
inode number:                        10610
inode number:                        10610
inode number:                        10610
protection:                          60660 protection:                          60660 protection:                          60660 (block device)
(block device)
(block device)
number of hard links:                    1
number of hard links:                    1
number of hard links:                    1
user ID of owner:                        0
user ID of owner:                        0
user ID of owner:                        0
group ID of owner:                       6
group ID of owner:                       6
group ID of owner:                       6
device ID (if special file):         64768
device ID (if special file):         64768
device ID (if special file):         64768
blocksize for filesystem I/O:         4096
blocksize for filesystem I/O:         4096
blocksize for filesystem I/O:         4096
number of blocks allocated:              0
number of blocks allocated:              0
number of blocks allocated:              0
time of last access:            1705593249 Thu Jan 18 23:54:09 2024
time of last access:            1705593249 Thu Jan 18 23:54:09 2024
time of last access:            1705593249 Thu Jan 18 23:54:09 2024
time of last modification:      1661337281 Wed Aug 24 18:34:41 2022
time of last modification:      1661337281 Wed Aug 24 18:34:41 2022
time of last modification:      1661337281 Wed Aug 24 18:34:41 2022
time of last status change:     1661337281 Wed Aug 24 18:34:41 2022
time of last status change:     1661337281 Wed Aug 24 18:34:41 2022
time of last status change:     1661337281 Wed Aug 24 18:34:41 2022
total size, in bytes:                    0 (0.000 exp(+0))

total size, in bytes:                    0 (0.000 exp(+0))

total size, in bytes:                    0 (0.000 exp(+0))

Size to process:               77309411328 (72.000 GiB)
Size to process:               77309411328 (72.000 GiB)
Size to process:               77309411328 (72.000 GiB)
Opening file: /dev/mapper/ol-root
File information:

ID of device containing file:            5
inode number:                        10610
protection:                          60660 (block device)
number of hard links:                    1
user ID of owner:                        0
group ID of owner:                       6
device ID (if special file):         64768
blocksize for filesystem I/O:         4096
number of blocks allocated:              0
time of last access:            1705593249 Thu Jan 18 23:54:09 2024
time of last modification:      1661337281 Wed Aug 24 18:34:41 2022
time of last status change:     1661337281 Wed Aug 24 18:34:41 2022
total size, in bytes:                    0 (0.000 exp(+0))

Size to process:               77309411328 (72.000 GiB)
Worker(1): 1.08% done. 2024-01-22 22:26:54 ETA(in 00:07:55). Processing speed: 38.325 MiB/sec
Worker(0): 1.08% done. 2024-01-22 22:26:55 ETA(in 00:07:55). Processing speed: 38.325 MiB/sec
Worker(2): 1.08% done. 2024-01-22 22:26:55 ETA(in 00:07:55). Processing speed: 38.328 MiB/sec
Worker(3): 1.08% done. 2024-01-22 22:26:55 ETA(in 00:07:55). Processing speed: 38.325 MiB/sec
Worker(1): 2.12% done. 2024-01-22 22:26:54 ETA(in 00:07:50). Processing speed: 38.325 MiB/sec
Worker(2): 2.12% done. 2024-01-22 22:26:55 ETA(in 00:07:50). Processing speed: 38.325 MiB/sec
Worker(3): 2.12% done. 2024-01-22 22:26:55 ETA(in 00:07:50). Processing speed: 38.325 MiB/sec
Worker(0): 2.12% done. 2024-01-22 22:26:55 ETA(in 00:07:50). Processing speed: 38.325 MiB/sec
Worker(1): 3.16% done. 2024-01-22 22:25:20 ETA(in 00:06:12). Processing speed: 47.907 MiB/sec
Worker(2): 3.16% done. 2024-01-22 22:25:21 ETA(in 00:06:12). Processing speed: 47.907 MiB/sec
Worker(3): 3.16% done. 2024-01-22 22:26:55 ETA(in 00:07:45). Processing speed: 38.325 MiB/sec
Worker(0): 3.16% done. 2024-01-22 22:26:55 ETA(in 00:07:45). Processing speed: 38.326 MiB/sec
Worker(1): 4.20% done. 2024-01-22 22:26:53 ETA(in 00:07:40). Processing speed: 38.328 MiB/sec
Worker(2): 4.20% done. 2024-01-22 22:25:21 ETA(in 00:06:08). Processing speed: 47.906 MiB/sec
Worker(3): 4.20% done. 2024-01-22 22:25:22 ETA(in 00:06:08). Processing speed: 47.906 MiB/sec
Worker(0): 4.20% done. 2024-01-22 22:26:55 ETA(in 00:07:40). Processing speed: 38.325 MiB/sec
Worker(1): 5.24% done. 2024-01-22 22:25:21 ETA(in 00:06:04). Processing speed: 47.907 MiB/sec
Worker(2): 5.24% done. 2024-01-22 22:26:53 ETA(in 00:07:35). Processing speed: 38.326 MiB/sec
Worker(3): 5.24% done. 2024-01-22 22:26:54 ETA(in 00:07:35). Processing speed: 38.325 MiB/sec
Worker(0): 5.24% done. 2024-01-22 22:26:55 ETA(in 00:07:35). Processing speed: 38.325 MiB/sec
Worker(1): 6.28% done. 2024-01-22 22:26:52 ETA(in 00:07:30). Processing speed: 38.325 MiB/sec
Worker(2): 6.28% done. 2024-01-22 22:25:22 ETA(in 00:06:00). Processing speed: 47.907 MiB/sec
Worker(3): 6.28% done. 2024-01-22 22:25:23 ETA(in 00:06:00). Processing speed: 47.906 MiB/sec
Worker(0): 6.28% done. 2024-01-22 22:26:55 ETA(in 00:07:30). Processing speed: 38.325 MiB/sec
Worker(1): 7.32% done. 2024-01-22 22:25:22 ETA(in 00:05:56). Processing speed: 47.911 MiB/sec
Worker(2): 7.32% done. 2024-01-22 22:26:52 ETA(in 00:07:25). Processing speed: 38.325 MiB/sec
Worker(3): 7.32% done. 2024-01-22 22:28:23 ETA(in 00:08:54). Processing speed: 31.938 MiB/sec
Worker(2): 8.36% done. 2024-01-22 22:23:54 ETA(in 00:04:24). Processing speed: 63.921 MiB/sec
Worker(0): 7.32% done. 2024-01-22 22:28:25 ETA(in 00:08:54). Processing speed: 31.943 MiB/sec
Worker(1): 8.36% done. 2024-01-22 22:26:51 ETA(in 00:07:20). Processing speed: 38.327 MiB/sec
Worker(3): 8.36% done. 2024-01-22 22:25:25 ETA(in 00:05:52). Processing speed: 47.906 MiB/sec
Worker(2): 9.40% done. 2024-01-22 22:26:50 ETA(in 00:07:15). Processing speed: 38.338 MiB/sec
Worker(0): 8.36% done. 2024-01-22 22:28:25 ETA(in 00:08:48). Processing speed: 31.945 MiB/sec
Worker(1): 9.40% done. 2024-01-22 22:28:19 ETA(in 00:08:42). Processing speed: 31.940 MiB/sec
Worker(3): 9.40% done. 2024-01-22 22:28:21 ETA(in 00:08:42). Processing speed: 31.938 MiB/sec
Worker(2): 10.44% done. 2024-01-22 22:28:17 ETA(in 00:08:36). Processing speed: 31.940 MiB/sec
Worker(0): 9.40% done. 2024-01-22 22:25:29 ETA(in 00:05:48). Processing speed: 47.945 MiB/sec
Worker(1): 10.44% done. 2024-01-22 22:26:52 ETA(in 00:07:10). Processing speed: 38.325 MiB/sec
Worker(3): 10.44% done. 2024-01-22 22:25:27 ETA(in 00:05:44). Processing speed: 47.910 MiB/sec
Worker(0): 10.44% done. 2024-01-22 22:25:29 ETA(in 00:05:44). Processing speed: 47.962 MiB/sec
Worker(2): 11.48% done. 2024-01-22 22:25:25 ETA(in 00:05:40). Processing speed: 47.910 MiB/sec
Worker(1): 11.48% done. 2024-01-22 22:25:26 ETA(in 00:05:40). Processing speed: 47.914 MiB/sec
Worker(3): 11.48% done. 2024-01-22 22:26:53 ETA(in 00:07:05). Processing speed: 38.333 MiB/sec
Worker(2): 12.52% done. 2024-01-22 22:25:25 ETA(in 00:05:36). Processing speed: 47.978 MiB/sec
Worker(0): 11.48% done. 2024-01-22 22:25:29 ETA(in 00:05:40). Processing speed: 47.907 MiB/sec
Worker(1): 12.52% done. 2024-01-22 22:26:51 ETA(in 00:07:00). Processing speed: 38.325 MiB/sec
Worker(3): 12.52% done. 2024-01-22 22:26:53 ETA(in 00:07:00). Processing speed: 38.331 MiB/sec
Worker(2): 13.56% done. 2024-01-22 22:31:01 ETA(in 00:11:04). Processing speed: 23.965 MiB/sec
Worker(0): 12.52% done. 2024-01-22 22:32:35 ETA(in 00:12:37). Processing speed: 21.295 MiB/sec
Worker(1): 13.56% done. 2024-01-22 22:31:04 ETA(in 00:11:05). Processing speed: 23.953 MiB/sec
Worker(3): 13.56% done. 2024-01-22 22:29:42 ETA(in 00:09:42). Processing speed: 27.375 MiB/sec
Worker(2): 14.60% done. 2024-01-22 22:25:29 ETA(in 00:05:28). Processing speed: 47.938 MiB/sec
Worker(0): 13.56% done. 2024-01-22 22:26:58 ETA(in 00:06:55). Processing speed: 38.328 MiB/sec
Worker(1): 14.60% done. 2024-01-22 22:25:31 ETA(in 00:05:28). Processing speed: 47.906 MiB/sec
Worker(3): 14.60% done. 2024-01-22 22:26:55 ETA(in 00:06:50). Processing speed: 38.325 MiB/sec
Worker(2): 15.64% done. 2024-01-22 22:25:29 ETA(in 00:05:24). Processing speed: 47.906 MiB/sec
Worker(1): 15.64% done. 2024-01-22 22:25:31 ETA(in 00:05:24). Processing speed: 47.906 MiB/sec
Worker(0): 14.60% done. 2024-01-22 22:28:21 ETA(in 00:08:12). Processing speed: 31.938 MiB/sec
Worker(2): 16.68% done. 2024-01-22 22:26:50 ETA(in 00:06:40). Processing speed: 38.325 MiB/sec
Worker(3): 15.64% done. 2024-01-22 22:26:55 ETA(in 00:06:45). Processing speed: 38.328 MiB/sec
Worker(1): 16.68% done. 2024-01-22 22:25:31 ETA(in 00:05:20). Processing speed: 47.912 MiB/sec
Worker(2): 17.72% done. 2024-01-22 22:24:10 ETA(in 00:03:57). Processing speed: 63.880 MiB/sec
Worker(1): 17.72% done. 2024-01-22 22:24:11 ETA(in 00:03:57). Processing speed: 63.909 MiB/sec
Worker(0): 15.64% done. 2024-01-22 22:26:59 ETA(in 00:06:45). Processing speed: 38.331 MiB/sec
Worker(3): 16.68% done. 2024-01-22 22:26:55 ETA(in 00:06:40). Processing speed: 38.335 MiB/sec
Worker(2): 18.76% done. 2024-01-22 22:25:29 ETA(in 00:05:12). Processing speed: 47.906 MiB/sec
Worker(1): 18.76% done. 2024-01-22 22:26:49 ETA(in 00:06:30). Processing speed: 38.325 MiB/sec
Worker(3): 17.72% done. 2024-01-22 22:25:35 ETA(in 00:05:16). Processing speed: 47.910 MiB/sec
Worker(0): 16.68% done. 2024-01-22 22:28:20 ETA(in 00:08:00). Processing speed: 31.940 MiB/sec
Worker(2): 19.80% done. 2024-01-22 22:25:29 ETA(in 00:05:08). Processing speed: 47.906 MiB/sec
Worker(1): 19.80% done. 2024-01-22 22:25:31 ETA(in 00:05:08). Processing speed: 47.906 MiB/sec
Worker(3): 18.76% done. 2024-01-22 22:26:54 ETA(in 00:06:30). Processing speed: 38.325 MiB/sec
Worker(2): 20.84% done. 2024-01-22 22:25:29 ETA(in 00:05:04). Processing speed: 47.953 MiB/sec
Worker(0): 17.72% done. 2024-01-22 22:27:00 ETA(in 00:06:35). Processing speed: 38.325 MiB/sec
Worker(1): 20.84% done. 2024-01-22 22:25:31 ETA(in 00:05:04). Processing speed: 47.906 MiB/sec
Worker(3): 19.80% done. 2024-01-22 22:25:36 ETA(in 00:05:08). Processing speed: 47.906 MiB/sec
Worker(2): 21.88% done. 2024-01-22 22:25:29 ETA(in 00:05:00). Processing speed: 47.906 MiB/sec
Worker(0): 18.76% done. 2024-01-22 22:28:19 ETA(in 00:07:48). Processing speed: 31.938 MiB/sec
Worker(1): 21.88% done. 2024-01-22 22:26:47 ETA(in 00:06:15). Processing speed: 38.325 MiB/sec
Worker(3): 20.84% done. 2024-01-22 22:26:53 ETA(in 00:06:20). Processing speed: 38.325 MiB/sec
Worker(2): 22.92% done. 2024-01-22 22:25:29 ETA(in 00:04:56). Processing speed: 47.906 MiB/sec
Worker(0): 19.80% done. 2024-01-22 22:27:01 ETA(in 00:06:25). Processing speed: 38.331 MiB/sec
Worker(1): 22.92% done. 2024-01-22 22:25:32 ETA(in 00:04:56). Processing speed: 47.906 MiB/sec
Worker(2): 23.96% done. 2024-01-22 22:25:29 ETA(in 00:04:52). Processing speed: 47.939 MiB/sec
Worker(3): 21.88% done. 2024-01-22 22:25:37 ETA(in 00:05:00). Processing speed: 47.911 MiB/sec
Worker(2): 25.00% done. 2024-01-22 22:24:16 ETA(in 00:03:36). Processing speed: 63.948 MiB/sec
Worker(1): 23.96% done. 2024-01-22 22:25:32 ETA(in 00:04:52). Processing speed: 47.914 MiB/sec
Worker(3): 22.92% done. 2024-01-22 22:25:37 ETA(in 00:04:56). Processing speed: 47.906 MiB/sec
Worker(0): 20.84% done. 2024-01-22 22:28:18 ETA(in 00:07:36). Processing speed: 31.938 MiB/sec
Worker(1): 25.00% done. 2024-01-22 22:24:19 ETA(in 00:03:36). Processing speed: 63.927 MiB/sec
Worker(2): 26.04% done. 2024-01-22 22:24:16 ETA(in 00:03:33). Processing speed: 63.875 MiB/sec
Worker(3): 23.96% done. 2024-01-22 22:26:51 ETA(in 00:06:05). Processing speed: 38.325 MiB/sec
Worker(1): 26.04% done. 2024-01-22 22:25:31 ETA(in 00:04:44). Processing speed: 47.906 MiB/sec
Worker(0): 21.88% done. 2024-01-22 22:27:02 ETA(in 00:06:15). Processing speed: 38.325 MiB/sec
Worker(2): 27.08% done. 2024-01-22 22:26:38 ETA(in 00:05:50). Processing speed: 38.331 MiB/sec
Worker(3): 25.00% done. 2024-01-22 22:25:38 ETA(in 00:04:48). Processing speed: 47.910 MiB/sec
Worker(1): 27.08% done. 2024-01-22 22:25:31 ETA(in 00:04:40). Processing speed: 47.906 MiB/sec
Worker(2): 28.12% done. 2024-01-22 22:25:28 ETA(in 00:04:36). Processing speed: 47.915 MiB/sec
Worker(0): 22.92% done. 2024-01-22 22:27:02 ETA(in 00:06:10). Processing speed: 38.328 MiB/sec
Worker(3): 26.04% done. 2024-01-22 22:26:50 ETA(in 00:05:55). Processing speed: 38.325 MiB/sec
Worker(1): 28.12% done. 2024-01-22 22:25:31 ETA(in 00:04:36). Processing speed: 47.906 MiB/sec
Worker(2): 29.16% done. 2024-01-22 22:25:28 ETA(in 00:04:32). Processing speed: 47.906 MiB/sec
Worker(0): 23.96% done. 2024-01-22 22:27:02 ETA(in 00:06:05). Processing speed: 38.325 MiB/sec
Worker(3): 27.07% done. 2024-01-22 22:25:39 ETA(in 00:04:40). Processing speed: 47.907 MiB/sec
Worker(1): 29.16% done. 2024-01-22 22:26:40 ETA(in 00:05:40). Processing speed: 38.325 MiB/sec
Worker(2): 30.20% done. 2024-01-22 22:25:28 ETA(in 00:04:28). Processing speed: 47.907 MiB/sec
Worker(0): 25.00% done. 2024-01-22 22:25:49 ETA(in 00:04:48). Processing speed: 47.912 MiB/sec
Worker(3): 28.11% done. 2024-01-22 22:26:49 ETA(in 00:05:45). Processing speed: 38.325 MiB/sec
Worker(1): 30.20% done. 2024-01-22 22:26:40 ETA(in 00:05:35). Processing speed: 38.326 MiB/sec
Worker(2): 31.24% done. 2024-01-22 22:26:35 ETA(in 00:05:30). Processing speed: 38.325 MiB/sec
Worker(0): 26.04% done. 2024-01-22 22:27:01 ETA(in 00:05:55). Processing speed: 38.334 MiB/sec
Worker(3): 29.16% done. 2024-01-22 22:24:31 ETA(in 00:03:24). Processing speed: 63.953 MiB/sec
Worker(0): 27.08% done. 2024-01-22 22:24:39 ETA(in 00:03:30). Processing speed: 63.940 MiB/sec
Worker(2): 32.28% done. 2024-01-22 22:26:35 ETA(in 00:05:25). Processing speed: 38.325 MiB/sec
Worker(1): 31.23% done. 2024-01-22 22:26:40 ETA(in 00:05:30). Processing speed: 38.325 MiB/sec
Worker(3): 30.20% done. 2024-01-22 22:25:39 ETA(in 00:04:28). Processing speed: 47.922 MiB/sec
Worker(2): 33.32% done. 2024-01-22 22:24:25 ETA(in 00:03:12). Processing speed: 63.881 MiB/sec
Worker(0): 28.12% done. 2024-01-22 22:26:59 ETA(in 00:05:45). Processing speed: 38.325 MiB/sec
Worker(1): 32.27% done. 2024-01-22 22:26:40 ETA(in 00:05:25). Processing speed: 38.325 MiB/sec
Worker(3): 31.24% done. 2024-01-22 22:26:46 ETA(in 00:05:30). Processing speed: 38.325 MiB/sec
Worker(2): 34.36% done. 2024-01-22 22:25:29 ETA(in 00:04:12). Processing speed: 47.949 MiB/sec
Worker(0): 29.16% done. 2024-01-22 22:26:59 ETA(in 00:05:40). Processing speed: 38.331 MiB/sec
Worker(1): 33.31% done. 2024-01-22 22:25:35 ETA(in 00:04:16). Processing speed: 47.906 MiB/sec
Worker(3): 32.27% done. 2024-01-22 22:24:34 ETA(in 00:03:15). Processing speed: 63.875 MiB/sec
Worker(2): 35.40% done. 2024-01-22 22:24:26 ETA(in 00:03:06). Processing speed: 63.896 MiB/sec
Worker(0): 30.20% done. 2024-01-22 22:25:51 ETA(in 00:04:28). Processing speed: 47.906 MiB/sec
Worker(1): 34.35% done. 2024-01-22 22:26:39 ETA(in 00:05:15). Processing speed: 38.325 MiB/sec
Worker(3): 33.31% done. 2024-01-22 22:26:44 ETA(in 00:05:20). Processing speed: 38.325 MiB/sec
Worker(2): 36.44% done. 2024-01-22 22:26:30 ETA(in 00:05:05). Processing speed: 38.325 MiB/sec
Worker(1): 35.39% done. 2024-01-22 22:25:36 ETA(in 00:04:08). Processing speed: 47.910 MiB/sec
Worker(0): 31.24% done. 2024-01-22 22:26:58 ETA(in 00:05:30). Processing speed: 38.325 MiB/sec
Worker(3): 34.35% done. 2024-01-22 22:25:40 ETA(in 00:04:12). Processing speed: 47.906 MiB/sec
Worker(2): 37.48% done. 2024-01-22 22:25:29 ETA(in 00:04:00). Processing speed: 47.906 MiB/sec
Worker(3): 35.40% done. 2024-01-22 22:24:37 ETA(in 00:03:06). Processing speed: 64.000 MiB/sec
Worker(1): 36.43% done. 2024-01-22 22:24:34 ETA(in 00:03:03). Processing speed: 63.875 MiB/sec
Worker(0): 32.28% done. 2024-01-22 22:24:46 ETA(in 00:03:15). Processing speed: 63.875 MiB/sec
Worker(3): 36.44% done. 2024-01-22 22:22:33 ETA(in 00:01:01). Processing speed: 192.000 MiB/sec
Worker(2): 38.52% done. 2024-01-22 22:24:29 ETA(in 00:02:57). Processing speed: 63.875 MiB/sec
Worker(3): 37.48% done. 2024-01-22 22:22:33 ETA(in 00:01:00). Processing speed: 192.000 MiB/sec
Worker(1): 37.47% done. 2024-01-22 22:23:33 ETA(in 00:02:00). Processing speed: 95.891 MiB/sec
Worker(3): 38.52% done. 2024-01-22 22:22:33 ETA(in 00:00:59). Processing speed: 192.000 MiB/sec
Worker(0): 33.32% done. 2024-01-22 22:24:46 ETA(in 00:03:12). Processing speed: 63.875 MiB/sec
Worker(3): 39.56% done. 2024-01-22 22:22:33 ETA(in 00:00:58). Processing speed: 192.000 MiB/sec
Worker(1): 38.51% done. 2024-01-22 22:23:33 ETA(in 00:01:58). Processing speed: 95.969 MiB/sec
Worker(2): 39.56% done. 2024-01-22 22:25:28 ETA(in 00:03:52). Processing speed: 47.906 MiB/sec
Worker(3): 40.60% done. 2024-01-22 22:22:33 ETA(in 00:00:57). Processing speed: 192.000 MiB/sec
Worker(0): 34.36% done. 2024-01-22 22:24:46 ETA(in 00:03:09). Processing speed: 63.875 MiB/sec
Worker(1): 39.56% done. 2024-01-22 22:23:33 ETA(in 00:01:56). Processing speed: 95.898 MiB/sec
Worker(3): 41.65% done. 2024-01-22 22:22:33 ETA(in 00:00:56). Processing speed: 192.000 MiB/sec
Worker(1): 40.60% done. 2024-01-22 22:22:35 ETA(in 00:00:57). Processing speed: 192.000 MiB/sec
Worker(3): 42.69% done. 2024-01-22 22:22:33 ETA(in 00:00:55). Processing speed: 192.000 MiB/sec
Worker(2): 40.60% done. 2024-01-22 22:23:32 ETA(in 00:01:54). Processing speed: 95.813 MiB/sec
Worker(1): 41.73% done. 2024-01-22 22:22:30 ETA(in 00:00:51). Processing speed: 208.000 MiB/sec
Worker(3): 43.73% done. 2024-01-22 22:22:33 ETA(in 00:00:54). Processing speed: 192.000 MiB/sec
Worker(0): 35.40% done. 2024-01-22 22:24:46 ETA(in 00:03:06). Processing speed: 63.885 MiB/sec
Worker(1): 42.77% done. 2024-01-22 22:23:30 ETA(in 00:01:49). Processing speed: 96.000 MiB/sec
Worker(2): 41.64% done. 2024-01-22 22:24:29 ETA(in 00:02:48). Processing speed: 63.875 MiB/sec
Worker(3): 44.77% done. 2024-01-22 22:23:27 ETA(in 00:01:46). Processing speed: 96.000 MiB/sec
Worker(0): 36.44% done. 2024-01-22 22:23:44 ETA(in 00:02:02). Processing speed: 95.898 MiB/sec
Worker(1): 43.81% done. 2024-01-22 22:22:35 ETA(in 00:00:53). Processing speed: 192.000 MiB/sec
Worker(3): 45.81% done. 2024-01-22 22:22:34 ETA(in 00:00:52). Processing speed: 192.000 MiB/sec
Worker(1): 44.89% done. 2024-01-22 22:22:33 ETA(in 00:00:50). Processing speed: 200.000 MiB/sec
Worker(3): 46.85% done. 2024-01-22 22:22:34 ETA(in 00:00:51). Processing speed: 192.000 MiB/sec
Worker(0): 37.48% done. 2024-01-22 22:22:43 ETA(in 00:01:00). Processing speed: 191.977 MiB/sec
Worker(2): 42.68% done. 2024-01-22 22:23:33 ETA(in 00:01:50). Processing speed: 95.813 MiB/sec
Worker(1): 46.93% done. 2024-01-22 22:22:10 ETA(in 00:00:26). Processing speed: 376.000 MiB/sec
Worker(3): 48.33% done. 2024-01-22 22:22:19 ETA(in 00:00:35). Processing speed: 272.000 MiB/sec
Worker(0): 38.52% done. 2024-01-22 22:25:43 ETA(in 00:03:56). Processing speed: 47.996 MiB/sec
Worker(1): 47.98% done. 2024-01-22 22:25:07 ETA(in 00:03:19). Processing speed: 48.000 MiB/sec
Worker(3): 49.37% done. 2024-01-22 22:25:02 ETA(in 00:03:14). Processing speed: 48.000 MiB/sec
Worker(0): 39.56% done. 2024-01-22 22:25:43 ETA(in 00:03:52). Processing speed: 47.996 MiB/sec
Worker(1): 49.02% done. 2024-01-22 22:25:07 ETA(in 00:03:15). Processing speed: 48.000 MiB/sec
Worker(2): 43.72% done. 2024-01-22 22:31:49 ETA(in 00:09:55). Processing speed: 17.420 MiB/sec
Worker(3): 50.41% done. 2024-01-22 22:28:16 ETA(in 00:06:20). Processing speed: 24.000 MiB/sec
Worker(1): 50.06% done. 2024-01-22 22:25:07 ETA(in 00:03:11). Processing speed: 48.000 MiB/sec
Worker(0): 40.60% done. 2024-01-22 22:26:41 ETA(in 00:04:45). Processing speed: 38.400 MiB/sec
Worker(3): 51.45% done. 2024-01-22 22:22:43 ETA(in 00:00:46). Processing speed: 192.000 MiB/sec
Worker(0): 41.64% done. 2024-01-22 22:22:53 ETA(in 00:00:56). Processing speed: 192.000 MiB/sec
Worker(1): 51.10% done. 2024-01-22 22:22:43 ETA(in 00:00:46). Processing speed: 192.000 MiB/sec
Worker(2): 44.76% done. 2024-01-22 22:24:36 ETA(in 00:02:39). Processing speed: 63.875 MiB/sec
Worker(3): 52.50% done. 2024-01-22 22:22:43 ETA(in 00:00:45). Processing speed: 192.000 MiB/sec
Worker(0): 42.69% done. 2024-01-22 22:22:53 ETA(in 00:00:55). Processing speed: 192.000 MiB/sec
Worker(1): 52.14% done. 2024-01-22 22:22:43 ETA(in 00:00:45). Processing speed: 192.000 MiB/sec
Worker(0): 44.12% done. 2024-01-22 22:22:38 ETA(in 00:00:39). Processing speed: 264.000 MiB/sec
Worker(3): 54.41% done. 2024-01-22 22:22:22 ETA(in 00:00:23). Processing speed: 352.000 MiB/sec
Worker(1): 53.18% done. 2024-01-22 22:22:43 ETA(in 00:00:44). Processing speed: 192.000 MiB/sec
Worker(2): 45.80% done. 2024-01-22 22:23:43 ETA(in 00:01:44). Processing speed: 95.813 MiB/sec
Worker(3): 56.23% done. 2024-01-22 22:22:24 ETA(in 00:00:24). Processing speed: 336.000 MiB/sec
Worker(0): 46.16% done. 2024-01-22 22:22:26 ETA(in 00:00:26). Processing speed: 376.000 MiB/sec
Worker(1): 54.79% done. 2024-01-22 22:22:28 ETA(in 00:00:28). Processing speed: 296.000 MiB/sec
Worker(3): 58.01% done. 2024-01-22 22:22:24 ETA(in 00:00:23). Processing speed: 328.000 MiB/sec
Worker(0): 48.02% done. 2024-01-22 22:22:28 ETA(in 00:00:27). Processing speed: 344.000 MiB/sec
Worker(1): 56.57% done. 2024-01-22 22:22:25 ETA(in 00:00:24). Processing speed: 328.000 MiB/sec
Worker(2): 46.84% done. 2024-01-22 22:23:43 ETA(in 00:01:42). Processing speed: 95.813 MiB/sec
Worker(1): 58.35% done. 2024-01-22 22:22:25 ETA(in 00:00:23). Processing speed: 328.000 MiB/sec
Worker(3): 59.87% done. 2024-01-22 22:22:23 ETA(in 00:00:21). Processing speed: 344.000 MiB/sec
Worker(0): 49.72% done. 2024-01-22 22:22:31 ETA(in 00:00:29). Processing speed: 312.000 MiB/sec
Worker(2): 47.88% done. 2024-01-22 22:22:52 ETA(in 00:00:50). Processing speed: 191.625 MiB/sec
Worker(0): 51.15% done. 2024-01-22 22:22:37 ETA(in 00:00:34). Processing speed: 264.000 MiB/sec
Worker(1): 60.39% done. 2024-01-22 22:22:22 ETA(in 00:00:19). Processing speed: 376.000 MiB/sec
Worker(3): 61.74% done. 2024-01-22 22:22:23 ETA(in 00:00:20). Processing speed: 344.000 MiB/sec
Worker(0): 53.02% done. 2024-01-22 22:22:29 ETA(in 00:00:25). Processing speed: 344.000 MiB/sec
Worker(1): 62.47% done. 2024-01-22 22:22:22 ETA(in 00:00:18). Processing speed: 384.000 MiB/sec
Worker(3): 63.22% done. 2024-01-22 22:22:28 ETA(in 00:00:24). Processing speed: 272.000 MiB/sec
Worker(2): 48.92% done. 2024-01-22 22:23:42 ETA(in 00:01:38). Processing speed: 95.813 MiB/sec
Worker(1): 63.90% done. 2024-01-22 22:22:30 ETA(in 00:00:25). Processing speed: 264.000 MiB/sec
Worker(0): 55.01% done. 2024-01-22 22:22:27 ETA(in 00:00:22). Processing speed: 368.000 MiB/sec
Worker(3): 65.08% done. 2024-01-22 22:22:23 ETA(in 00:00:18). Processing speed: 344.000 MiB/sec
Worker(2): 49.96% done. 2024-01-22 22:22:53 ETA(in 00:00:48). Processing speed: 191.937 MiB/sec
Worker(3): 66.73% done. 2024-01-22 22:22:26 ETA(in 00:00:20). Processing speed: 304.000 MiB/sec
Worker(0): 56.71% done. 2024-01-22 22:22:31 ETA(in 00:00:25). Processing speed: 312.000 MiB/sec
Worker(2): 51.17% done. 2024-01-22 22:22:46 ETA(in 00:00:40). Processing speed: 224.000 MiB/sec
Worker(1): 65.08% done. 2024-01-22 22:22:35 ETA(in 00:00:29). Processing speed: 216.000 MiB/sec
Worker(3): 68.47% done. 2024-01-22 22:22:25 ETA(in 00:00:18). Processing speed: 320.000 MiB/sec
Worker(2): 52.73% done. 2024-01-22 22:22:37 ETA(in 00:00:30). Processing speed: 288.000 MiB/sec
Worker(1): 66.77% done. 2024-01-22 22:22:26 ETA(in 00:00:19). Processing speed: 312.000 MiB/sec
Worker(0): 58.05% done. 2024-01-22 22:22:38 ETA(in 00:00:31). Processing speed: 248.000 MiB/sec
Worker(2): 54.60% done. 2024-01-22 22:22:32 ETA(in 00:00:24). Processing speed: 344.000 MiB/sec
Worker(1): 68.46% done. 2024-01-22 22:22:26 ETA(in 00:00:18). Processing speed: 312.000 MiB/sec
Worker(0): 59.35% done. 2024-01-22 22:22:39 ETA(in 00:00:31). Processing speed: 240.000 MiB/sec
Worker(3): 69.90% done. 2024-01-22 22:22:29 ETA(in 00:00:21). Processing speed: 264.000 MiB/sec
Worker(1): 70.28% done. 2024-01-22 22:22:25 ETA(in 00:00:16). Processing speed: 336.000 MiB/sec
Worker(3): 71.46% done. 2024-01-22 22:22:27 ETA(in 00:00:18). Processing speed: 288.000 MiB/sec
Worker(0): 60.92% done. 2024-01-22 22:22:34 ETA(in 00:00:25). Processing speed: 288.000 MiB/sec
Worker(2): 55.95% done. 2024-01-22 22:22:41 ETA(in 00:00:32). Processing speed: 248.000 MiB/sec
Worker(3): 72.94% done. 2024-01-22 22:22:28 ETA(in 00:00:18). Processing speed: 272.000 MiB/sec
Worker(0): 62.30% done. 2024-01-22 22:22:37 ETA(in 00:00:27). Processing speed: 256.000 MiB/sec
Worker(2): 57.64% done. 2024-01-22 22:22:35 ETA(in 00:00:25). Processing speed: 312.000 MiB/sec
Worker(1): 71.98% done. 2024-01-22 22:22:26 ETA(in 00:00:16). Processing speed: 312.000 MiB/sec
Worker(2): 59.59% done. 2024-01-22 22:22:31 ETA(in 00:00:20). Processing speed: 360.000 MiB/sec
Worker(1): 73.15% done. 2024-01-22 22:22:33 ETA(in 00:00:22). Processing speed: 216.000 MiB/sec
Worker(0): 63.69% done. 2024-01-22 22:22:37 ETA(in 00:00:26). Processing speed: 256.000 MiB/sec
Worker(3): 74.76% done. 2024-01-22 22:22:24 ETA(in 00:00:13). Processing speed: 336.000 MiB/sec
Worker(0): 65.21% done. 2024-01-22 22:22:34 ETA(in 00:00:22). Processing speed: 280.000 MiB/sec
Worker(1): 74.80% done. 2024-01-22 22:22:27 ETA(in 00:00:15). Processing speed: 304.000 MiB/sec
Worker(3): 76.19% done. 2024-01-22 22:22:28 ETA(in 00:00:16). Processing speed: 264.000 MiB/sec
Worker(2): 61.28% done. 2024-01-22 22:22:34 ETA(in 00:00:22). Processing speed: 312.000 MiB/sec
Worker(1): 76.62% done. 2024-01-22 22:22:25 ETA(in 00:00:12). Processing speed: 336.000 MiB/sec
Worker(0): 66.69% done. 2024-01-22 22:22:35 ETA(in 00:00:22). Processing speed: 272.000 MiB/sec
Worker(3): 77.71% done. 2024-01-22 22:22:27 ETA(in 00:00:14). Processing speed: 280.000 MiB/sec
Worker(2): 62.80% done. 2024-01-22 22:22:37 ETA(in 00:00:24). Processing speed: 280.000 MiB/sec
Worker(0): 68.21% done. 2024-01-22 22:22:34 ETA(in 00:00:20). Processing speed: 280.000 MiB/sec
Worker(3): 79.10% done. 2024-01-22 22:22:29 ETA(in 00:00:15). Processing speed: 256.000 MiB/sec
Worker(1): 78.40% done. 2024-01-22 22:22:26 ETA(in 00:00:12). Processing speed: 328.000 MiB/sec
Worker(2): 64.45% done. 2024-01-22 22:22:35 ETA(in 00:00:21). Processing speed: 304.000 MiB/sec
Worker(1): 79.92% done. 2024-01-22 22:22:28 ETA(in 00:00:13). Processing speed: 280.000 MiB/sec
Worker(0): 70.16% done. 2024-01-22 22:22:30 ETA(in 00:00:15). Processing speed: 360.000 MiB/sec
Worker(2): 65.84% done. 2024-01-22 22:22:39 ETA(in 00:00:24). Processing speed: 256.000 MiB/sec
Worker(3): 80.53% done. 2024-01-22 22:22:28 ETA(in 00:00:13). Processing speed: 264.000 MiB/sec
Worker(2): 67.10% done. 2024-01-22 22:22:42 ETA(in 00:00:26). Processing speed: 232.000 MiB/sec
Worker(1): 81.48% done. 2024-01-22 22:22:27 ETA(in 00:00:11). Processing speed: 288.000 MiB/sec
Worker(3): 82.23% done. 2024-01-22 22:22:26 ETA(in 00:00:10). Processing speed: 312.000 MiB/sec
Worker(0): 71.98% done. 2024-01-22 22:22:31 ETA(in 00:00:15). Processing speed: 336.000 MiB/sec
Worker(3): 84.01% done. 2024-01-22 22:22:25 ETA(in 00:00:08). Processing speed: 328.000 MiB/sec
Worker(0): 73.68% done. 2024-01-22 22:22:32 ETA(in 00:00:15). Processing speed: 312.000 MiB/sec
Worker(2): 68.62% done. 2024-01-22 22:22:37 ETA(in 00:00:20). Processing speed: 280.000 MiB/sec
Worker(1): 82.83% done. 2024-01-22 22:22:29 ETA(in 00:00:12). Processing speed: 248.000 MiB/sec
Worker(3): 85.53% done. 2024-01-22 22:22:27 ETA(in 00:00:09). Processing speed: 280.000 MiB/sec
Worker(2): 70.53% done. 2024-01-22 22:22:33 ETA(in 00:00:15). Processing speed: 352.000 MiB/sec
Worker(1): 84.13% done. 2024-01-22 22:22:30 ETA(in 00:00:12). Processing speed: 240.000 MiB/sec
Worker(0): 75.24% done. 2024-01-22 22:22:33 ETA(in 00:00:15). Processing speed: 288.000 MiB/sec
Worker(1): 85.43% done. 2024-01-22 22:22:30 ETA(in 00:00:11). Processing speed: 240.000 MiB/sec
Worker(0): 76.76% done. 2024-01-22 22:22:34 ETA(in 00:00:15). Processing speed: 280.000 MiB/sec
Worker(2): 72.31% done. 2024-01-22 22:22:34 ETA(in 00:00:15). Processing speed: 328.000 MiB/sec
Worker(3): 87.18% done. 2024-01-22 22:22:26 ETA(in 00:00:07). Processing speed: 304.000 MiB/sec
Worker(2): 73.83% done. 2024-01-22 22:22:37 ETA(in 00:00:17). Processing speed: 280.000 MiB/sec
Worker(3): 88.43% done. 2024-01-22 22:22:29 ETA(in 00:00:09). Processing speed: 232.000 MiB/sec
Worker(1): 87.25% done. 2024-01-22 22:22:26 ETA(in 00:00:06). Processing speed: 336.000 MiB/sec
Worker(0): 78.49% done. 2024-01-22 22:22:32 ETA(in 00:00:12). Processing speed: 320.000 MiB/sec
Worker(0): 80.10% done. 2024-01-22 22:22:33 ETA(in 00:00:12). Processing speed: 296.000 MiB/sec
Worker(1): 88.77% done. 2024-01-22 22:22:28 ETA(in 00:00:07). Processing speed: 280.000 MiB/sec
Worker(2): 75.09% done. 2024-01-22 22:22:40 ETA(in 00:00:19). Processing speed: 232.000 MiB/sec
Worker(3): 90.34% done. 2024-01-22 22:22:26 ETA(in 00:00:05). Processing speed: 352.000 MiB/sec
Worker(1): 90.60% done. 2024-01-22 22:22:27 ETA(in 00:00:05). Processing speed: 336.000 MiB/sec
Worker(3): 91.95% done. 2024-01-22 22:22:27 ETA(in 00:00:05). Processing speed: 296.000 MiB/sec
Worker(2): 76.52% done. 2024-01-22 22:22:38 ETA(in 00:00:16). Processing speed: 264.000 MiB/sec
Worker(0): 81.53% done. 2024-01-22 22:22:34 ETA(in 00:00:12). Processing speed: 264.000 MiB/sec
Worker(2): 78.17% done. 2024-01-22 22:22:36 ETA(in 00:00:13). Processing speed: 304.000 MiB/sec
Worker(3): 93.69% done. 2024-01-22 22:22:26 ETA(in 00:00:03). Processing speed: 320.000 MiB/sec
Worker(1): 92.29% done. 2024-01-22 22:22:27 ETA(in 00:00:04). Processing speed: 312.000 MiB/sec
Worker(0): 82.70% done. 2024-01-22 22:22:37 ETA(in 00:00:14). Processing speed: 216.000 MiB/sec
Worker(0): 84.27% done. 2024-01-22 22:22:34 ETA(in 00:00:10). Processing speed: 288.000 MiB/sec
Worker(1): 94.11% done. 2024-01-22 22:22:27 ETA(in 00:00:03). Processing speed: 336.000 MiB/sec
Worker(2): 79.56% done. 2024-01-22 22:22:38 ETA(in 00:00:14). Processing speed: 256.000 MiB/sec
Worker(3): 95.20% done. 2024-01-22 22:22:27 ETA(in 00:00:03). Processing speed: 280.000 MiB/sec
Worker(3): 96.68% done. 2024-01-22 22:22:27 ETA(in 00:00:02). Processing speed: 272.000 MiB/sec
Worker(2): 81.08% done. 2024-01-22 22:22:37 ETA(in 00:00:12). Processing speed: 280.000 MiB/sec
Worker(1): 95.68% done. 2024-01-22 22:22:27 ETA(in 00:00:02). Processing speed: 288.000 MiB/sec
Worker(0): 86.00% done. 2024-01-22 22:22:33 ETA(in 00:00:08). Processing speed: 320.000 MiB/sec
Worker(1): 97.32% done. 2024-01-22 22:22:27 ETA(in 00:00:01). Processing speed: 304.000 MiB/sec
Worker(2): 82.77% done. 2024-01-22 22:22:36 ETA(in 00:00:10). Processing speed: 312.000 MiB/sec
Worker(0): 88.00% done. 2024-01-22 22:22:32 ETA(in 00:00:06). Processing speed: 368.000 MiB/sec
Worker(0): 90.13% done. 2024-01-22 22:22:31 ETA(in 00:00:04). Processing speed: 392.000 MiB/sec
Worker(2): 84.90% done. 2024-01-22 22:22:34 ETA(in 00:00:07). Processing speed: 392.000 MiB/sec
Worker(1): 98.89% done. 2024-01-22 22:22:27 ETA(in 00:00:00). Processing speed: 287.969 MiB/sec
Worker(2): 87.24% done. 2024-01-22 22:22:33 ETA(in 00:00:05). Processing speed: 432.000 MiB/sec
Worker(0): 92.51% done. 2024-01-22 22:22:31 ETA(in 00:00:03). Processing speed: 440.000 MiB/sec
Worker(1): 99.93% done. 2024-01-22 22:22:28 ETA(in 00:00:00). Processing speed: 191.627 MiB/sec
Worker(2): 89.63% done. 2024-01-22 22:22:33 ETA(in 00:00:04). Processing speed: 440.000 MiB/sec
Worker(0): 94.90% done. 2024-01-22 22:22:31 ETA(in 00:00:02). Processing speed: 440.000 MiB/sec
Worker(0): 97.20% done. 2024-01-22 22:22:31 ETA(in 00:00:01). Processing speed: 424.000 MiB/sec
Worker(2): 91.97% done. 2024-01-22 22:22:33 ETA(in 00:00:03). Processing speed: 432.000 MiB/sec
Worker(0): 99.41% done. 2024-01-22 22:22:31 ETA(in 00:00:00). Processing speed: 408.000 MiB/sec
Worker(2): 94.36% done. 2024-01-22 22:22:33 ETA(in 00:00:02). Processing speed: 440.000 MiB/sec
Worker(2): 97.00% done. 2024-01-22 22:22:33 ETA(in 00:00:01). Processing speed: 488.000 MiB/sec
Worker(2): 98.65% done. 2024-01-22 22:22:33 ETA(in 00:00:00). Processing speed: 303.845 MiB/sec
Worker(2): 99.69% done. 2024-01-22 22:22:35 ETA(in 00:00:00). Processing speed: 95.820 MiB/sec
All workers finished in 221 sec

4:查找表数据对应的page 页
确认对应的索引页主键索引是61

mysql> select * from information_schema.INNODB_SYS_TABLES d where d.name='test/t2';
Empty set (0.14 sec)

mysql> select * from information_schema.INNODB_SYS_TABLES d where d.name like 'test/t2%';
+----------+--------------+------+--------+-------+-------------+------------+---------------+------------+
| TABLE_ID | NAME         | FLAG | N_COLS | SPACE | FILE_FORMAT | ROW_FORMAT | ZIP_PAGE_SIZE | SPACE_TYPE |
+----------+--------------+------+--------+-------+-------------+------------+---------------+------------+
|       53 | test/t2#P#p0 |   33 |      4 |    26 | Barracuda   | Dynamic    |             0 | Single     |
|       54 | test/t2#P#p1 |   33 |      4 |    27 | Barracuda   | Dynamic    |             0 | Single     |
|       55 | test/t2#P#p2 |   33 |      4 |    28 | Barracuda   | Dynamic    |             0 | Single     |
|       56 | test/t2#P#p3 |   33 |      4 |    29 | Barracuda   | Dynamic    |             0 | Single     |
+----------+--------------+------+--------+-------+-------------+------------+---------------+------------+
4 rows in set (0.00 sec)

mysql> show create table t2\G
*************************** 1. row ***************************
       Table: t2
Create Table: CREATE TABLE `t2` (
  `i` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4
/*!50100 PARTITION BY KEY (i)
PARTITIONS 4 */
1 row in set (0.00 sec)

表test/t2是一个分区表,所以相当于4个表查找index_id语句要根据table_id来执行四次。

mysql> select * from information_schema.innodb_sys_indexes where table_id=53;
+----------+-----------------+----------+------+----------+---------+-------+-----------------+
| INDEX_ID | NAME            | TABLE_ID | TYPE | N_FIELDS | PAGE_NO | SPACE | MERGE_THRESHOLD |
+----------+-----------------+----------+------+----------+---------+-------+-----------------+
|       44 | GEN_CLUST_INDEX |       53 |    1 |        0 |       3 |    26 |              50 |
+----------+-----------------+----------+------+----------+---------+-------+-----------------+
1 row in set (0.00 sec)

mysql> select * from information_schema.innodb_sys_indexes where table_id=54;
+----------+-----------------+----------+------+----------+---------+-------+-----------------+
| INDEX_ID | NAME            | TABLE_ID | TYPE | N_FIELDS | PAGE_NO | SPACE | MERGE_THRESHOLD |
+----------+-----------------+----------+------+----------+---------+-------+-----------------+
|       45 | GEN_CLUST_INDEX |       54 |    1 |        0 |       3 |    27 |              50 |
+----------+-----------------+----------+------+----------+---------+-------+-----------------+
1 row in set (0.00 sec)

mysql> select * from information_schema.innodb_sys_indexes where table_id=55;
+----------+-----------------+----------+------+----------+---------+-------+-----------------+
| INDEX_ID | NAME            | TABLE_ID | TYPE | N_FIELDS | PAGE_NO | SPACE | MERGE_THRESHOLD |
+----------+-----------------+----------+------+----------+---------+-------+-----------------+
|       46 | GEN_CLUST_INDEX |       55 |    1 |        0 |       3 |    28 |              50 |
+----------+-----------------+----------+------+----------+---------+-------+-----------------+
1 row in set (0.00 sec)

mysql> select * from information_schema.innodb_sys_indexes where table_id=56;
+----------+-----------------+----------+------+----------+---------+-------+-----------------+
| INDEX_ID | NAME            | TABLE_ID | TYPE | N_FIELDS | PAGE_NO | SPACE | MERGE_THRESHOLD |
+----------+-----------------+----------+------+----------+---------+-------+-----------------+
|       47 | GEN_CLUST_INDEX |       56 |    1 |        0 |       3 |    29 |              50 |
+----------+-----------------+----------+------+----------+---------+-------+-----------------+
1 row in set (0.00 sec)

5:解析磁盘页中删除表的记录

[root@localhost lib]# vi /tmp/t2.sql
CREATE TABLE `t2` (
  `i` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4
/*!50100 PARTITION BY KEY (i)
PARTITIONS 4 */;

因为表test/t2有四个分区所以需要解析四次

[root@localhost undrop-for-innodb-master]# ./c_parser -6f /undrop-for-innodb-master/pages-ol-root/FIL_PAGE_INDEX/0000000000000044.page -t /tmp/t2.sql > dumps/default/t2_1 2> dumps/default/t2_1_load.sql
[root@localhost undrop-for-innodb-master]# ./c_parser -6f /undrop-for-innodb-master/pages-ol-root/FIL_PAGE_INDEX/0000000000000045.page -t /tmp/t2.sql > dumps/default/t2_2 2> dumps/default/t2_2_load.sql
[root@localhost undrop-for-innodb-master]# ./c_parser -6f /undrop-for-innodb-master/pages-ol-root/FIL_PAGE_INDEX/0000000000000046.page -t /tmp/t2.sql > dumps/default/t2_3 2> dumps/default/t2_3_load.sql
[root@localhost undrop-for-innodb-master]# ./c_parser -6f /undrop-for-innodb-master/pages-ol-root/FIL_PAGE_INDEX/0000000000000047.page -t /tmp/t2.sql > dumps/default/t2_4 2> dumps/default/t2_4_load.sql

6:导入数据
因为表test/t2是分区表,生成使用load命令加载数据时生成的数据文件是t2与表名相同,并不会我所指定的文件名。所以要做修改

[root@localhost default]# cat t2_1_load.sql
SET FOREIGN_KEY_CHECKS=0;
LOAD DATA LOCAL INFILE '/undrop-for-innodb-master/dumps/default/t2' REPLACE INTO TABLE `t2` FIELDS TERMINATED BY '\t' OPTIONALLY ENCLOSED BY '"' LINES STARTING BY 't2\t' (`i`);
[root@localhost default]# cat t2_2_load.sql
SET FOREIGN_KEY_CHECKS=0;
LOAD DATA LOCAL INFILE '/undrop-for-innodb-master/dumps/default/t2' REPLACE INTO TABLE `t2` FIELDS TERMINATED BY '\t' OPTIONALLY ENCLOSED BY '"' LINES STARTING BY 't2\t' (`i`);

[root@localhost default]# cat t2_3_load.sql
SET FOREIGN_KEY_CHECKS=0;
LOAD DATA LOCAL INFILE '/undrop-for-innodb-master/dumps/default/t2' REPLACE INTO TABLE `t2` FIELDS TERMINATED BY '\t' OPTIONALLY ENCLOSED BY '"' LINES STARTING BY 't2\t' (`i`);

[root@localhost default]# cat t2_4_load.sql
SET FOREIGN_KEY_CHECKS=0;
LOAD DATA LOCAL INFILE '/undrop-for-innodb-master/dumps/default/t2' REPLACE INTO TABLE `t2` FIELDS TERMINATED BY '\t' OPTIONALLY ENCLOSED BY '"' LINES STARTING BY 't2\t' (`i`);

[root@localhost default]# vi t2_1_load.sql
SET FOREIGN_KEY_CHECKS=0;
LOAD DATA LOCAL INFILE '/undrop-for-innodb-master/dumps/default/t2_1' REPLACE INTO TABLE `t2` FIELDS TERMINATED BY '\t' OPTIONALLY ENCLOSED BY '"' LINES STARTING BY 't2\t' (`i`);

[root@localhost default]# vi t2_2_load.sql
SET FOREIGN_KEY_CHECKS=0;
LOAD DATA LOCAL INFILE '/undrop-for-innodb-master/dumps/default/t2_2' REPLACE INTO TABLE `t2` FIELDS TERMINATED BY '\t' OPTIONALLY ENCLOSED BY '"' LINES STARTING BY 't2\t' (`i`);

[root@localhost default]# vi t2_3_load.sql
SET FOREIGN_KEY_CHECKS=0;
LOAD DATA LOCAL INFILE '/undrop-for-innodb-master/dumps/default/t2_3' REPLACE INTO TABLE `t2` FIELDS TERMINATED BY '\t' OPTIONALLY ENCLOSED BY '"' LINES STARTING BY 't2\t' (`i`);

[root@localhost default]# vi t2_4_load.sql
SET FOREIGN_KEY_CHECKS=0;
LOAD DATA LOCAL INFILE '/undrop-for-innodb-master/dumps/default/t2_4' REPLACE INTO TABLE `t2` FIELDS TERMINATED BY '\t' OPTIONALLY ENCLOSED BY '"' LINES STARTING BY 't2\t' (`i`);


mysql> source /undrop-for-innodb-master/dumps/default/t2_1_load.sql
Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)
Records: 0  Deleted: 0  Skipped: 0  Warnings: 0

mysql> source /undrop-for-innodb-master/dumps/default/t2_2_load.sql
Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)
Records: 0  Deleted: 0  Skipped: 0  Warnings: 0

mysql> source /undrop-for-innodb-master/dumps/default/t2_3_load.sql
Query OK, 0 rows affected (0.00 sec)

Query OK, 4 rows affected (0.06 sec)
Records: 4  Deleted: 0  Skipped: 0  Warnings: 0

mysql> source /undrop-for-innodb-master/dumps/default/t2_4_load.sql
Query OK, 0 rows affected (0.00 sec)

Query OK, 4 rows affected (0.03 sec)
Records: 4  Deleted: 0  Skipped: 0  Warnings: 0

mysql> select * from t2;
+------+
| i    |
+------+
|    3 |
|    7 |
|   11 |
|   15 |
|    2 |
|    6 |
|   10 |
|   14 |
+------+
8 rows in set (0.00 sec)

到此数据已经恢复了。

]]>
http://www.jydba.net/index.php/archives/3549/feed 0
恢复MySQL5.7中被Drop掉的表 http://www.jydba.net/index.php/archives/3546 http://www.jydba.net/index.php/archives/3546#respond Sun, 11 Feb 2024 07:27:35 +0000 http://www.jydba.net/?p=3546 恢复MySQL 5.7被Drop掉的表
innodb_file_per_table=ON 场景下,drop 表后,.ibd 文件也被删除了,需要扫描磁盘获取相应的数据页进行恢复。而如果是innodb_file_per_table=OFF,则数据存放在共享表空间ibdata1里的,只要扫描该ibdata1 文件即可。下面以innodb_file_per_table=ON 场景下恢复为例
一.安装undrop-for-innodb软件
1:上传undrop-for-innodb-develop.zip

2:安装编译环境
yum install make gcc flex bison
3:解压

[root@localhost /]# unzip undrop-for-innodb-master.zip
Archive:  undrop-for-innodb-master.zip
ade0fbb31218f655eeff97f559d47c6545478734
   creating: undrop-for-innodb-master/
  inflating: undrop-for-innodb-master/LICENSE  
  inflating: undrop-for-innodb-master/Makefile  
  inflating: undrop-for-innodb-master/README.md  
  inflating: undrop-for-innodb-master/c_parser.c  
  inflating: undrop-for-innodb-master/check_data.c  
   creating: undrop-for-innodb-master/dictionary/
  inflating: undrop-for-innodb-master/dictionary/SYS_COLUMNS.sql  
  inflating: undrop-for-innodb-master/dictionary/SYS_FIELDS.sql  
  inflating: undrop-for-innodb-master/dictionary/SYS_INDEXES.sql  
  inflating: undrop-for-innodb-master/dictionary/SYS_TABLES.sql  
  inflating: undrop-for-innodb-master/fetch_data.sh  
   creating: undrop-for-innodb-master/include/
  inflating: undrop-for-innodb-master/include/bchange.c  
  inflating: undrop-for-innodb-master/include/bcmp.c  
  inflating: undrop-for-innodb-master/include/bfill.c  
  inflating: undrop-for-innodb-master/include/bmove.c  
  inflating: undrop-for-innodb-master/include/bmove512.c  
  inflating: undrop-for-innodb-master/include/bmove_upp.c  
  inflating: undrop-for-innodb-master/include/btr0btr.h  
  inflating: undrop-for-innodb-master/include/btr0btr.ic  
  inflating: undrop-for-innodb-master/include/btr0cur.h  
  inflating: undrop-for-innodb-master/include/btr0cur.ic  
  inflating: undrop-for-innodb-master/include/btr0types.h  
  inflating: undrop-for-innodb-master/include/buf0buf.h  
  inflating: undrop-for-innodb-master/include/buf0buf.ic  
  inflating: undrop-for-innodb-master/include/buf0flu.h  
  inflating: undrop-for-innodb-master/include/buf0flu.ic  
  inflating: undrop-for-innodb-master/include/buf0lru.h  
  inflating: undrop-for-innodb-master/include/buf0lru.ic  
  inflating: undrop-for-innodb-master/include/buf0rea.h  
  inflating: undrop-for-innodb-master/include/buf0types.h  
  inflating: undrop-for-innodb-master/include/check_data.h  
  inflating: undrop-for-innodb-master/include/ctype-bin.c  
  inflating: undrop-for-innodb-master/include/ctype-latin1.c  
  inflating: undrop-for-innodb-master/include/ctype-mb.c  
  inflating: undrop-for-innodb-master/include/ctype-simple.c  
  inflating: undrop-for-innodb-master/include/ctype-utf8.c  
  inflating: undrop-for-innodb-master/include/ctype.c  
  inflating: undrop-for-innodb-master/include/data0data.h  
  inflating: undrop-for-innodb-master/include/data0data.ic  
  inflating: undrop-for-innodb-master/include/data0type.h  
  inflating: undrop-for-innodb-master/include/data0type.ic  
  inflating: undrop-for-innodb-master/include/data0types.h  
  inflating: undrop-for-innodb-master/include/db0err.h  
  inflating: undrop-for-innodb-master/include/decimal.c  
  inflating: undrop-for-innodb-master/include/decimal.h  
  inflating: undrop-for-innodb-master/include/dict0dict.h  
  inflating: undrop-for-innodb-master/include/dict0dict.ic  
  inflating: undrop-for-innodb-master/include/dict0load.h  
  inflating: undrop-for-innodb-master/include/dict0load.ic  
  inflating: undrop-for-innodb-master/include/dict0mem.h  
  inflating: undrop-for-innodb-master/include/dict0mem.ic  
  inflating: undrop-for-innodb-master/include/dict0types.h  
  inflating: undrop-for-innodb-master/include/dyn0dyn.h  
  inflating: undrop-for-innodb-master/include/dyn0dyn.ic  
  inflating: undrop-for-innodb-master/include/fil0fil.h  
  inflating: undrop-for-innodb-master/include/fsp0fsp.h  
  inflating: undrop-for-innodb-master/include/fsp0fsp.ic  
  inflating: undrop-for-innodb-master/include/fut0fut.h  
  inflating: undrop-for-innodb-master/include/fut0fut.ic  
  inflating: undrop-for-innodb-master/include/fut0lst.h  
  inflating: undrop-for-innodb-master/include/fut0lst.ic  
  inflating: undrop-for-innodb-master/include/ha0ha.h  
  inflating: undrop-for-innodb-master/include/ha0ha.ic  
  inflating: undrop-for-innodb-master/include/hash0hash.h  
  inflating: undrop-for-innodb-master/include/hash0hash.ic  
  inflating: undrop-for-innodb-master/include/ib_config.h  
  inflating: undrop-for-innodb-master/include/ibuf0types.h  
  inflating: undrop-for-innodb-master/include/innochecksum.h  
  inflating: undrop-for-innodb-master/include/int2str.c  
  inflating: undrop-for-innodb-master/include/is_prefix.c  
  inflating: undrop-for-innodb-master/include/llstr.c  
  inflating: undrop-for-innodb-master/include/lock0types.h  
  inflating: undrop-for-innodb-master/include/longlong2str.c  
  inflating: undrop-for-innodb-master/include/m_ctype.h  
  inflating: undrop-for-innodb-master/include/m_string.h  
  inflating: undrop-for-innodb-master/include/mach0data.h  
  inflating: undrop-for-innodb-master/include/mach0data.ic  
  inflating: undrop-for-innodb-master/include/mem0dbg.h  
  inflating: undrop-for-innodb-master/include/mem0dbg.ic  
  inflating: undrop-for-innodb-master/include/mem0mem.h  
  inflating: undrop-for-innodb-master/include/mem0mem.ic  
  inflating: undrop-for-innodb-master/include/mem0pool.h  
  inflating: undrop-for-innodb-master/include/mem0pool.ic  
  inflating: undrop-for-innodb-master/include/mtr0log.h  
  inflating: undrop-for-innodb-master/include/mtr0log.ic  
  inflating: undrop-for-innodb-master/include/mtr0mtr.h  
  inflating: undrop-for-innodb-master/include/mtr0mtr.ic  
  inflating: undrop-for-innodb-master/include/mtr0types.h  
  inflating: undrop-for-innodb-master/include/my_alloc.h  
  inflating: undrop-for-innodb-master/include/my_attribute.h  
  inflating: undrop-for-innodb-master/include/my_base.h  
  inflating: undrop-for-innodb-master/include/my_config.h  
  inflating: undrop-for-innodb-master/include/my_dbug.h  
  inflating: undrop-for-innodb-master/include/my_global.h  
  inflating: undrop-for-innodb-master/include/my_list.h  
  inflating: undrop-for-innodb-master/include/my_pthread.h  
  inflating: undrop-for-innodb-master/include/my_strtoll10.c  
  inflating: undrop-for-innodb-master/include/my_sys.h  
  inflating: undrop-for-innodb-master/include/my_vsnprintf.c  
  inflating: undrop-for-innodb-master/include/my_xml.h  
  inflating: undrop-for-innodb-master/include/myisampack.h  
  inflating: undrop-for-innodb-master/include/mysql_def.h  
  inflating: undrop-for-innodb-master/include/os0file.h  
  inflating: undrop-for-innodb-master/include/os0proc.h  
  inflating: undrop-for-innodb-master/include/os0proc.ic  
  inflating: undrop-for-innodb-master/include/os0sync.h  
  inflating: undrop-for-innodb-master/include/os0sync.ic  
  inflating: undrop-for-innodb-master/include/os0thread.h  
  inflating: undrop-for-innodb-master/include/os0thread.ic  
  inflating: undrop-for-innodb-master/include/page0cur.h  
  inflating: undrop-for-innodb-master/include/page0cur.ic  
  inflating: undrop-for-innodb-master/include/page0page.h  
  inflating: undrop-for-innodb-master/include/page0page.ic  
  inflating: undrop-for-innodb-master/include/page0types.h  
  inflating: undrop-for-innodb-master/include/print_data.h  
  inflating: undrop-for-innodb-master/include/que0types.h  
  inflating: undrop-for-innodb-master/include/r_strinstr.c  
  inflating: undrop-for-innodb-master/include/raid.h  
  inflating: undrop-for-innodb-master/include/read0types.h  
  inflating: undrop-for-innodb-master/include/rem0cmp.h  
  inflating: undrop-for-innodb-master/include/rem0cmp.ic  
  inflating: undrop-for-innodb-master/include/rem0rec.h  
  inflating: undrop-for-innodb-master/include/rem0rec.ic  
  inflating: undrop-for-innodb-master/include/rem0types.h  
  inflating: undrop-for-innodb-master/include/row0types.h  
  inflating: undrop-for-innodb-master/include/srv0srv.h  
  inflating: undrop-for-innodb-master/include/str2int.c  
  inflating: undrop-for-innodb-master/include/str_alloc.c  
  inflating: undrop-for-innodb-master/include/strappend.c  
  inflating: undrop-for-innodb-master/include/strcend.c  
  inflating: undrop-for-innodb-master/include/strcont.c  
  inflating: undrop-for-innodb-master/include/strend.c  
  inflating: undrop-for-innodb-master/include/strfill.c  
  inflating: undrop-for-innodb-master/include/strinstr.c  
  inflating: undrop-for-innodb-master/include/strmake.c  
  inflating: undrop-for-innodb-master/include/strmov.c  
  inflating: undrop-for-innodb-master/include/strnlen.c  
  inflating: undrop-for-innodb-master/include/strnmov.c  
  inflating: undrop-for-innodb-master/include/strstr.c  
  inflating: undrop-for-innodb-master/include/strtod.c  
  inflating: undrop-for-innodb-master/include/strtol.c  
  inflating: undrop-for-innodb-master/include/strtoll.c  
  inflating: undrop-for-innodb-master/include/strtoul.c  
  inflating: undrop-for-innodb-master/include/strtoull.c  
  inflating: undrop-for-innodb-master/include/strxmov.c  
  inflating: undrop-for-innodb-master/include/strxnmov.c  
  inflating: undrop-for-innodb-master/include/sync0arr.h  
  inflating: undrop-for-innodb-master/include/sync0arr.ic  
  inflating: undrop-for-innodb-master/include/sync0rw.h  
  inflating: undrop-for-innodb-master/include/sync0rw.ic  
  inflating: undrop-for-innodb-master/include/sync0sync.h  
  inflating: undrop-for-innodb-master/include/sync0sync.ic  
  inflating: undrop-for-innodb-master/include/sync0types.h  
  inflating: undrop-for-innodb-master/include/tables_dict.h  
  inflating: undrop-for-innodb-master/include/trx0sys.h  
  inflating: undrop-for-innodb-master/include/trx0sys.ic  
  inflating: undrop-for-innodb-master/include/trx0trx.h  
  inflating: undrop-for-innodb-master/include/trx0trx.ic  
  inflating: undrop-for-innodb-master/include/trx0types.h  
  inflating: undrop-for-innodb-master/include/trx0undo.h  
  inflating: undrop-for-innodb-master/include/trx0undo.ic  
  inflating: undrop-for-innodb-master/include/trx0xa.h  
  inflating: undrop-for-innodb-master/include/typelib.h  
  inflating: undrop-for-innodb-master/include/univ.i  
  inflating: undrop-for-innodb-master/include/usr0types.h  
  inflating: undrop-for-innodb-master/include/ut0byte.h  
  inflating: undrop-for-innodb-master/include/ut0byte.ic  
  inflating: undrop-for-innodb-master/include/ut0dbg.h  
  inflating: undrop-for-innodb-master/include/ut0lst.h  
  inflating: undrop-for-innodb-master/include/ut0mem.h  
  inflating: undrop-for-innodb-master/include/ut0mem.ic  
  inflating: undrop-for-innodb-master/include/ut0rnd.h  
  inflating: undrop-for-innodb-master/include/ut0rnd.ic  
  inflating: undrop-for-innodb-master/include/ut0ut.h  
  inflating: undrop-for-innodb-master/include/ut0ut.ic  
  inflating: undrop-for-innodb-master/include/xml.c  
  inflating: undrop-for-innodb-master/innochecksum.c  
  inflating: undrop-for-innodb-master/print_data.c  
  inflating: undrop-for-innodb-master/recover_dictionary.sh  
   creating: undrop-for-innodb-master/sakila/
  inflating: undrop-for-innodb-master/sakila/actor.sql  
  inflating: undrop-for-innodb-master/sakila/address.sql  
  inflating: undrop-for-innodb-master/sakila/category.sql  
  inflating: undrop-for-innodb-master/sakila/city.sql  
  inflating: undrop-for-innodb-master/sakila/country.sql  
  inflating: undrop-for-innodb-master/sakila/customer.sql  
  inflating: undrop-for-innodb-master/sakila/film.sql  
  inflating: undrop-for-innodb-master/sakila/film_actor.sql  
  inflating: undrop-for-innodb-master/sakila/film_category.sql  
  inflating: undrop-for-innodb-master/sakila/inventory.sql  
  inflating: undrop-for-innodb-master/sakila/language.sql  
  inflating: undrop-for-innodb-master/sakila/payment.sql  
  inflating: undrop-for-innodb-master/sakila/rental.sql  
  inflating: undrop-for-innodb-master/sakila/sakila-db.tar.gz  
  inflating: undrop-for-innodb-master/sakila/staff.sql  
  inflating: undrop-for-innodb-master/sakila/store.sql  
  inflating: undrop-for-innodb-master/sql_parser.l  
  inflating: undrop-for-innodb-master/sql_parser.y  
  inflating: undrop-for-innodb-master/stream_parser.c  
  inflating: undrop-for-innodb-master/sys_parser.c  
  inflating: undrop-for-innodb-master/tables_dict.c  
  inflating: undrop-for-innodb-master/test.sh  

4:编译

[root@localhost /]# cd undrop-for-innodb-master
[root@localhost undrop-for-innodb-master]# ll
total 208
-rw-r--r--. 1 root root  6271 Oct  2  2015 check_data.c
-rw-r--r--. 1 root root 28689 Oct  2  2015 c_parser.c
drwxr-xr-x. 2 root root    92 Oct  2  2015 dictionary
-rw-r--r--. 1 root root  1978 Oct  2  2015 fetch_data.sh
drwxr-xr-x. 2 root root  4096 Oct  2  2015 include
-rw-r--r--. 1 root root  8936 Oct  2  2015 innochecksum.c
-rw-r--r--. 1 root root 18047 Oct  2  2015 LICENSE
-rw-r--r--. 1 root root  1816 Oct  2  2015 Makefile
-rw-r--r--. 1 root root 16585 Oct  2  2015 print_data.c
-rw-r--r--. 1 root root  3467 Oct  2  2015 README.md
-rwxr-xr-x. 1 root root  1536 Oct  2  2015 recover_dictionary.sh
drwxr-xr-x. 2 root root  4096 Oct  2  2015 sakila
-rw-r--r--. 1 root root  7244 Oct  2  2015 sql_parser.l
-rw-r--r--. 1 root root 25607 Oct  2  2015 sql_parser.y
-rw-r--r--. 1 root root 23004 Oct  2  2015 stream_parser.c
-rw-r--r--. 1 root root 14764 Oct  2  2015 sys_parser.c
-rw-r--r--. 1 root root  2237 Oct  2  2015 tables_dict.c
-rwxr-xr-x. 1 root root  6178 Oct  2  2015 test.sh
[root@localhost undrop-for-innodb-master]# make
cc -D_FILE_OFFSET_BITS=64 -Wall -g -O3 -pipe  -I./include -c stream_parser.c
stream_parser.c: In function ‘valid_innodb_page’:
stream_parser.c:151:31: warning: variable ‘oldcsumfield’ set but not used [-Wunused-but-set-variable]
     unsigned int page_n_heap, oldcsumfield;
                               ^
stream_parser.c: In function ‘process_ibpage’:
stream_parser.c:313:9: warning: variable ‘sem’ set but not used [-Wunused-but-set-variable]
     int sem = (page_type == FIL_PAGE_INDEX) 
         ^
stream_parser.c: In function ‘process_ibfile’:
stream_parser.c:333:13: warning: variable ‘prev_disk_offset’ set but not used [-Wunused-but-set-variable]
     off64_t prev_disk_offset = 0;
             ^
cc -D_FILE_OFFSET_BITS=64 -Wall -g -O3 -pipe  -I./include  -pthread -lm  stream_parser.o -o stream_parser
flex  sql_parser.l
bison  -o sql_parser.c sql_parser.y
sql_parser.y: warning: 6 shift/reduce conflicts [-Wconflicts-sr]
cc -D_FILE_OFFSET_BITS=64 -Wall -g -O3 -pipe  -I./include -c sql_parser.c 
sql_parser.y: In function ‘yyparse’:
sql_parser.y:166:39: warning: variable ‘none’ set but not used [-Wunused-but-set-variable]
         field_def_t trx_id, roll_ptr, none;
                                       ^
In file included from sql_parser.y:660:0:
sql_parser.y: At top level:
lex.yy.c:3085:17: warning: ‘yyunput’ defined but not used [-Wunused-function]
     static void yyunput (int c, register char * yy_bp )
                 ^
lex.yy.c:3126:16: warning: ‘input’ defined but not used [-Wunused-function]
     static int input  (void)
                ^
cc -D_FILE_OFFSET_BITS=64 -Wall -g -O3 -pipe  -I./include -c c_parser.c
In file included from c_parser.c:39:0:
decimal.c: In function ‘decimal_intg’:
decimal.c:1923:9: warning: variable ‘tmp_res’ set but not used [-Wunused-but-set-variable]
In file included from c_parser.c:35:0:
c_parser.c: At top level:
./include/ctype-latin1.c:359:5: warning: ‘my_mb_wc_latin1’ defined but not used [-Wunused-function]
 int my_mb_wc_latin1(CHARSET_INFO *cs  __attribute__((unused)),
     ^
./include/ctype-latin1.c:372:5: warning: ‘my_wc_mb_latin1’ defined but not used [-Wunused-function]
 int my_wc_mb_latin1(CHARSET_INFO *cs  __attribute__((unused)),
     ^
cc -D_FILE_OFFSET_BITS=64 -Wall -g -O3 -pipe  -I./include -c tables_dict.c
cc -D_FILE_OFFSET_BITS=64 -Wall -g -O3 -pipe  -I./include -c print_data.c
cc -D_FILE_OFFSET_BITS=64 -Wall -g -O3 -pipe  -I./include -c check_data.c
cc -D_FILE_OFFSET_BITS=64 -Wall -g -O3 -pipe   -I./include  sql_parser.o c_parser.o tables_dict.o print_data.o check_data.o -o c_parser -pthread -lm
cc -D_FILE_OFFSET_BITS=64 -Wall -g -O3 -pipe   -I./include -o innochecksum_changer innochecksum.c
[root@localhost undrop-for-innodb-master]# ll
total 2904
-rw-r--r--. 1 root root    6271 Oct  2  2015 check_data.c
-rw-r--r--. 1 root root   66088 Jan 17 16:59 check_data.o
-rwxr-xr-x. 1 root root  725572 Jan 17 16:59 c_parser
-rw-r--r--. 1 root root   28689 Oct  2  2015 c_parser.c
-rw-r--r--. 1 root root 1038536 Jan 17 16:59 c_parser.o
drwxr-xr-x. 2 root root      92 Oct  2  2015 dictionary
-rw-r--r--. 1 root root    1978 Oct  2  2015 fetch_data.sh
drwxr-xr-x. 2 root root    4096 Oct  2  2015 include
-rw-r--r--. 1 root root    8936 Oct  2  2015 innochecksum.c
-rwxr-xr-x. 1 root root   36399 Jan 17 16:59 innochecksum_changer
-rw-r--r--. 1 root root  134778 Jan 17 16:59 lex.yy.c
-rw-r--r--. 1 root root   18047 Oct  2  2015 LICENSE
-rw-r--r--. 1 root root    1816 Oct  2  2015 Makefile
-rw-r--r--. 1 root root   16585 Oct  2  2015 print_data.c
-rw-r--r--. 1 root root  127136 Jan 17 16:59 print_data.o
-rw-r--r--. 1 root root    3467 Oct  2  2015 README.md
-rwxr-xr-x. 1 root root    1536 Oct  2  2015 recover_dictionary.sh
drwxr-xr-x. 2 root root    4096 Oct  2  2015 sakila
-rw-r--r--. 1 root root  102053 Jan 17 16:59 sql_parser.c
-rw-r--r--. 1 root root    7244 Oct  2  2015 sql_parser.l
-rw-r--r--. 1 root root  287296 Jan 17 16:59 sql_parser.o
-rw-r--r--. 1 root root   25607 Oct  2  2015 sql_parser.y
-rwxr-xr-x. 1 root root   63657 Jan 17 16:59 stream_parser
-rw-r--r--. 1 root root   23004 Oct  2  2015 stream_parser.c
-rw-r--r--. 1 root root  114944 Jan 17 16:59 stream_parser.o
-rw-r--r--. 1 root root   14764 Oct  2  2015 sys_parser.c
-rw-r--r--. 1 root root    2237 Oct  2  2015 tables_dict.c
-rw-r--r--. 1 root root   40176 Jan 17 16:59 tables_dict.o
-rwxr-xr-x. 1 root root    6178 Oct  2  2015 test.sh
[root@localhost undrop-for-innodb-master]#  make sys_parser
/mysqlsoft/mysql/bin/mysql_config
cc -o sys_parser sys_parser.c `mysql_config --cflags` `mysql_config --libs`

5:验证
编译完成后在undrop-for-innodb 目录下生成stream_parser 和c_parser, sys_parser 文件。

[root@localhost undrop-for-innodb-master]# ll
total 2928
-rw-r--r--. 1 root root    6271 Oct  2  2015 check_data.c
-rw-r--r--. 1 root root   66088 Jan 17 16:59 check_data.o
-rwxr-xr-x. 1 root root  725572 Jan 17 16:59 c_parser
-rw-r--r--. 1 root root   28689 Oct  2  2015 c_parser.c
-rw-r--r--. 1 root root 1038536 Jan 17 16:59 c_parser.o
drwxr-xr-x. 2 root root      92 Oct  2  2015 dictionary
-rw-r--r--. 1 root root    1978 Oct  2  2015 fetch_data.sh
drwxr-xr-x. 2 root root    4096 Oct  2  2015 include
-rw-r--r--. 1 root root    8936 Oct  2  2015 innochecksum.c
-rwxr-xr-x. 1 root root   36399 Jan 17 16:59 innochecksum_changer
-rw-r--r--. 1 root root  134778 Jan 17 16:59 lex.yy.c
-rw-r--r--. 1 root root   18047 Oct  2  2015 LICENSE
-rw-r--r--. 1 root root    1816 Oct  2  2015 Makefile
-rw-r--r--. 1 root root   16585 Oct  2  2015 print_data.c
-rw-r--r--. 1 root root  127136 Jan 17 16:59 print_data.o
-rw-r--r--. 1 root root    3467 Oct  2  2015 README.md
-rwxr-xr-x. 1 root root    1536 Oct  2  2015 recover_dictionary.sh
drwxr-xr-x. 2 root root    4096 Oct  2  2015 sakila
-rw-r--r--. 1 root root  102053 Jan 17 16:59 sql_parser.c
-rw-r--r--. 1 root root    7244 Oct  2  2015 sql_parser.l
-rw-r--r--. 1 root root  287296 Jan 17 16:59 sql_parser.o
-rw-r--r--. 1 root root   25607 Oct  2  2015 sql_parser.y
-rwxr-xr-x. 1 root root   63657 Jan 17 16:59 stream_parser
-rw-r--r--. 1 root root   23004 Oct  2  2015 stream_parser.c
-rw-r--r--. 1 root root  114944 Jan 17 16:59 stream_parser.o
-rwxr-xr-x. 1 root root   20650 Jan 17 17:05 sys_parser
-rw-r--r--. 1 root root   14764 Oct  2  2015 sys_parser.c
-rw-r--r--. 1 root root    2237 Oct  2  2015 tables_dict.c
-rw-r--r--. 1 root root   40176 Jan 17 16:59 tables_dict.o
-rwxr-xr-x. 1 root root    6178 Oct  2  2015 test.sh

二.执行drop table恢复操作
1:删除表

mysql> use test
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed

mysql> desc articles;
+-------+------------------+------+-----+---------+----------------+
| Field | Type             | Null | Key | Default | Extra          |
+-------+------------------+------+-----+---------+----------------+
| id    | int(10) unsigned | NO   | PRI | NULL    | auto_increment |
| title | varchar(200)     | YES  | MUL | NULL    |                |
| body  | text             | YES  |     | NULL    |                |
+-------+------------------+------+-----+---------+----------------+
3 rows in set (0.00 sec)

mysql> select * from articles;
+----+-------------------+------------------------------------------+
| id | title             | body                                     |
+----+-------------------+------------------------------------------+
|  4 | 1001 MySQL Tricks | 1. Never run mysqld as root. 2. ...      |
|  5 | MySQL vs. YourSQL | In the following database comparison ... |
|  6 | MySQL Security    | When configured properly, MySQL ...      |
+----+-------------------+------------------------------------------+
3 rows in set (0.00 sec)

[root@localhost test]# ll
total 516
-rw-r-----. 1 mysql mysql  8618 Jan 18 23:44 articles.frm
-rw-r-----. 1 mysql mysql 98304 Jan 18 23:45 articles.ibd
-rw-r-----. 1 mysql mysql    67 Mar 15  2022 db.opt
-rw-r-----. 1 mysql mysql  8554 Mar 16  2022 t2.frm
-rw-r-----. 1 mysql mysql 98304 Mar 16  2022 t2#P#p0.ibd
-rw-r-----. 1 mysql mysql 98304 Mar 16  2022 t2#P#p1.ibd
-rw-r-----. 1 mysql mysql   375 Mar 16  2022 t2#P#p2.cfg
-rw-r-----. 1 mysql mysql 98304 Mar 16  2022 t2#P#p2.ibd
-rw-r-----. 1 mysql mysql   375 Mar 16  2022 t2#P#p3.cfg
-rw-r-----. 1 mysql mysql 98304 Mar 16  2022 t2#P#p3.ibd


mysql> drop table articles;
Query OK, 0 rows affected (0.35 sec)

[root@localhost test]# ll
total 408
-rw-r-----. 1 mysql mysql    67 Mar 15  2022 db.opt
-rw-r-----. 1 mysql mysql  8554 Mar 16  2022 t2.frm
-rw-r-----. 1 mysql mysql 98304 Mar 16  2022 t2#P#p0.ibd
-rw-r-----. 1 mysql mysql 98304 Mar 16  2022 t2#P#p1.ibd
-rw-r-----. 1 mysql mysql   375 Mar 16  2022 t2#P#p2.cfg
-rw-r-----. 1 mysql mysql 98304 Mar 16  2022 t2#P#p2.ibd
-rw-r-----. 1 mysql mysql   375 Mar 16  2022 t2#P#p3.cfg
-rw-r-----. 1 mysql mysql 98304 Mar 16  2022 t2#P#p3.ibd

2:关闭数据库
立刻关闭数据库,防止磁盘内的页被覆盖,影响数据的恢复成功率

mysql> shutdown;
Query OK, 0 rows affected (0.00 sec)

[root@localhost undrop-for-innodb-master]# ps -ef | grep mysqld
root     23505  3805  0 15:42 pts/3    00:00:00 grep --color=auto mysqld

3:确认硬盘分区

[root@localhost undrop-for-innodb-master]# more /mysqlsoft/mysql/my.cnf | grep datadir
datadir=/mysqldata/mysql

[root@localhost undrop-for-innodb-master]# df -h /mysqldata/mysql
Filesystem           Size  Used Avail Use% Mounted on
/dev/mapper/ol-root   72G   64G  8.0G  89% /

4:扫描硬盘分区
由于innodb_file_per_table=ON,一旦数据库drop 了某个表,该表对应的ibd 文件也会从磁盘中被删除,因此无法从ibdata 文件中恢复数据,只能从磁盘中进行恢复,因此需要扫描整个磁盘分区。

[root@localhost undrop-for-innodb-master]# ./stream_parser -f /dev/mapper/ol-root -t 72G
Opening file: /dev/mapper/ol-root
File information:

Opening file: /dev/mapper/ol-root
File information:

Opening file: /dev/mapper/ol-root
File information:

ID of device containing file:            5
ID of device containing file:            5
ID of device containing file:            5
inode number:                        10610
inode number:                        10610
inode number:                        10610
protection:                          60660 protection:                          60660 protection:                          60660 (block device)
(block device)
(block device)
number of hard links:                    1
number of hard links:                    1
number of hard links:                    1
user ID of owner:                        0
user ID of owner:                        0
user ID of owner:                        0
group ID of owner:                       6
group ID of owner:                       6
group ID of owner:                       6
device ID (if special file):         64768
device ID (if special file):         64768
device ID (if special file):         64768
blocksize for filesystem I/O:         4096
blocksize for filesystem I/O:         4096
blocksize for filesystem I/O:         4096
number of blocks allocated:              0
number of blocks allocated:              0
number of blocks allocated:              0
time of last access:            1661331760 Wed Aug 24 17:02:40 2022
time of last access:            1661331760 Wed Aug 24 17:02:40 2022
time of last access:            1661331760 Wed Aug 24 17:02:40 2022
time of last modification:      1661337281 Wed Aug 24 18:34:41 2022
time of last modification:      1661337281 Wed Aug 24 18:34:41 2022
time of last modification:      1661337281 Wed Aug 24 18:34:41 2022
time of last status change:     1661337281 Wed Aug 24 18:34:41 2022
time of last status change:     1661337281 Wed Aug 24 18:34:41 2022
time of last status change:     1661337281 Wed Aug 24 18:34:41 2022
total size, in bytes:                    0 (0.000 exp(+0))

total size, in bytes:                    0 (0.000 exp(+0))

total size, in bytes:                    0 (0.000 exp(+0))

Size to process:               77309411328 (72.000 GiB)
Size to process:               77309411328 (72.000 GiB)
Size to process:               77309411328 (72.000 GiB)
Opening file: /dev/mapper/ol-root
File information:

ID of device containing file:            5
inode number:                        10610
protection:                          60660 (block device)
number of hard links:                    1
user ID of owner:                        0
group ID of owner:                       6
device ID (if special file):         64768
blocksize for filesystem I/O:         4096
number of blocks allocated:              0
time of last access:            1661331760 Wed Aug 24 17:02:40 2022
time of last modification:      1661337281 Wed Aug 24 18:34:41 2022
time of last status change:     1661337281 Wed Aug 24 18:34:41 2022
total size, in bytes:                    0 (0.000 exp(+0))

Size to process:               77309411328 (72.000 GiB)
Worker(0): 1.08% done. 2024-01-18 23:58:28 ETA(in 00:07:55). Processing speed: 38.325 MiB/sec
Worker(2): 1.08% done. 2024-01-18 23:58:28 ETA(in 00:07:55). Processing speed: 38.328 MiB/sec
Worker(3): 1.08% done. 2024-01-19 00:00:04 ETA(in 00:09:30). Processing speed: 31.938 MiB/sec
Worker(1): 1.08% done. 2024-01-19 00:00:04 ETA(in 00:09:30). Processing speed: 31.938 MiB/sec
Worker(0): 2.12% done. 2024-01-18 23:58:28 ETA(in 00:07:50). Processing speed: 38.325 MiB/sec
Worker(2): 2.12% done. 2024-01-18 23:58:28 ETA(in 00:07:50). Processing speed: 38.325 MiB/sec
Worker(1): 2.12% done. 2024-01-18 23:56:54 ETA(in 00:06:16). Processing speed: 47.906 MiB/sec
Worker(3): 2.12% done. 2024-01-18 23:58:29 ETA(in 00:07:50). Processing speed: 38.325 MiB/sec
Worker(2): 3.16% done. 2024-01-19 00:00:02 ETA(in 00:09:18). Processing speed: 31.938 MiB/sec
Worker(1): 3.16% done. 2024-01-19 00:00:02 ETA(in 00:09:18). Processing speed: 31.938 MiB/sec
Worker(0): 3.16% done. 2024-01-19 00:00:02 ETA(in 00:09:18). Processing speed: 31.938 MiB/sec
Worker(3): 3.16% done. 2024-01-19 00:00:03 ETA(in 00:09:18). Processing speed: 31.938 MiB/sec
Worker(2): 4.20% done. 2024-01-18 23:56:56 ETA(in 00:06:08). Processing speed: 47.906 MiB/sec
Worker(1): 4.20% done. 2024-01-18 23:56:56 ETA(in 00:06:08). Processing speed: 47.910 MiB/sec
Worker(0): 4.20% done. 2024-01-19 00:00:02 ETA(in 00:09:12). Processing speed: 31.938 MiB/sec
Worker(3): 4.20% done. 2024-01-18 23:58:30 ETA(in 00:07:40). Processing speed: 38.325 MiB/sec
Worker(2): 5.24% done. 2024-01-18 23:56:56 ETA(in 00:06:04). Processing speed: 47.907 MiB/sec
Worker(1): 5.24% done. 2024-01-18 23:58:28 ETA(in 00:07:35). Processing speed: 38.326 MiB/sec
Worker(0): 5.24% done. 2024-01-18 23:58:30 ETA(in 00:07:35). Processing speed: 38.325 MiB/sec
Worker(3): 5.24% done. 2024-01-19 00:00:02 ETA(in 00:09:06). Processing speed: 31.938 MiB/sec
Worker(2): 6.28% done. 2024-01-18 23:58:27 ETA(in 00:07:30). Processing speed: 38.326 MiB/sec
Worker(1): 6.28% done. 2024-01-18 23:58:28 ETA(in 00:07:30). Processing speed: 38.325 MiB/sec
Worker(0): 6.28% done. 2024-01-18 23:58:30 ETA(in 00:07:30). Processing speed: 38.325 MiB/sec
Worker(3): 6.28% done. 2024-01-18 23:58:31 ETA(in 00:07:30). Processing speed: 38.325 MiB/sec
Worker(2): 7.32% done. 2024-01-18 23:56:57 ETA(in 00:05:56). Processing speed: 47.906 MiB/sec
Worker(1): 7.32% done. 2024-01-18 23:56:58 ETA(in 00:05:56). Processing speed: 47.911 MiB/sec
Worker(2): 8.36% done. 2024-01-18 23:56:57 ETA(in 00:05:52). Processing speed: 47.941 MiB/sec
Worker(3): 7.32% done. 2024-01-18 23:57:01 ETA(in 00:05:56). Processing speed: 47.906 MiB/sec
Worker(0): 7.32% done. 2024-01-18 23:58:30 ETA(in 00:07:25). Processing speed: 38.331 MiB/sec
Worker(1): 8.36% done. 2024-01-18 23:58:27 ETA(in 00:07:20). Processing speed: 38.327 MiB/sec
Worker(2): 9.40% done. 2024-01-18 23:58:25 ETA(in 00:07:15). Processing speed: 38.334 MiB/sec
Worker(3): 8.36% done. 2024-01-18 23:59:59 ETA(in 00:08:48). Processing speed: 31.938 MiB/sec
Worker(0): 8.36% done. 2024-01-18 23:59:59 ETA(in 00:08:48). Processing speed: 31.945 MiB/sec
Worker(1): 9.40% done. 2024-01-18 23:58:27 ETA(in 00:07:15). Processing speed: 38.328 MiB/sec
Worker(2): 10.44% done. 2024-01-18 23:58:25 ETA(in 00:07:10). Processing speed: 38.328 MiB/sec
Worker(3): 9.40% done. 2024-01-18 23:58:31 ETA(in 00:07:15). Processing speed: 38.325 MiB/sec
Worker(0): 9.40% done. 2024-01-18 23:58:31 ETA(in 00:07:15). Processing speed: 38.356 MiB/sec
Worker(1): 10.44% done. 2024-01-18 23:58:27 ETA(in 00:07:10). Processing speed: 38.325 MiB/sec
Worker(2): 11.48% done. 2024-01-18 23:56:59 ETA(in 00:05:40). Processing speed: 47.910 MiB/sec
Worker(0): 10.44% done. 2024-01-18 23:57:04 ETA(in 00:05:44). Processing speed: 47.962 MiB/sec
Worker(3): 10.44% done. 2024-01-18 23:57:04 ETA(in 00:05:44). Processing speed: 47.910 MiB/sec
Worker(1): 11.48% done. 2024-01-18 23:57:01 ETA(in 00:05:40). Processing speed: 47.914 MiB/sec
Worker(2): 12.52% done. 2024-01-18 23:55:34 ETA(in 00:04:12). Processing speed: 63.970 MiB/sec
Worker(0): 11.48% done. 2024-01-18 23:55:38 ETA(in 00:04:15). Processing speed: 63.876 MiB/sec
Worker(3): 11.48% done. 2024-01-18 23:57:04 ETA(in 00:05:40). Processing speed: 47.916 MiB/sec
Worker(2): 13.56% done. 2024-01-18 23:56:58 ETA(in 00:05:32). Processing speed: 47.930 MiB/sec
Worker(1): 12.52% done. 2024-01-18 23:58:26 ETA(in 00:07:00). Processing speed: 38.325 MiB/sec
Worker(0): 12.52% done. 2024-01-18 23:58:28 ETA(in 00:07:00). Processing speed: 38.331 MiB/sec
Worker(3): 12.52% done. 2024-01-18 23:59:54 ETA(in 00:08:24). Processing speed: 31.943 MiB/sec
Worker(1): 13.56% done. 2024-01-18 23:57:02 ETA(in 00:05:32). Processing speed: 47.906 MiB/sec
Worker(2): 14.60% done. 2024-01-18 23:56:58 ETA(in 00:05:28). Processing speed: 47.938 MiB/sec
Worker(2): 15.64% done. 2024-01-18 23:56:58 ETA(in 00:05:24). Processing speed: 47.906 MiB/sec
Worker(1): 14.60% done. 2024-01-18 23:57:02 ETA(in 00:05:28). Processing speed: 47.906 MiB/sec
Worker(3): 13.56% done. 2024-01-18 23:58:30 ETA(in 00:06:55). Processing speed: 38.325 MiB/sec
Worker(0): 13.56% done. 2024-01-19 00:02:41 ETA(in 00:11:05). Processing speed: 23.955 MiB/sec
Worker(1): 15.64% done. 2024-01-18 23:58:24 ETA(in 00:06:45). Processing speed: 38.325 MiB/sec
Worker(2): 16.68% done. 2024-01-18 23:58:19 ETA(in 00:06:40). Processing speed: 38.325 MiB/sec
Worker(3): 14.60% done. 2024-01-18 23:57:07 ETA(in 00:05:28). Processing speed: 47.906 MiB/sec
Worker(0): 14.60% done. 2024-01-18 23:58:31 ETA(in 00:06:50). Processing speed: 38.325 MiB/sec
Worker(2): 17.72% done. 2024-01-18 23:55:39 ETA(in 00:03:57). Processing speed: 63.880 MiB/sec
Worker(1): 16.68% done. 2024-01-18 23:57:03 ETA(in 00:05:20). Processing speed: 47.912 MiB/sec
Worker(3): 15.64% done. 2024-01-18 23:59:51 ETA(in 00:08:06). Processing speed: 31.940 MiB/sec
Worker(0): 15.64% done. 2024-01-18 23:57:09 ETA(in 00:05:24). Processing speed: 47.914 MiB/sec
Worker(2): 18.76% done. 2024-01-18 23:56:58 ETA(in 00:05:12). Processing speed: 47.906 MiB/sec
Worker(1): 17.72% done. 2024-01-18 23:55:43 ETA(in 00:03:57). Processing speed: 63.909 MiB/sec
Worker(3): 16.68% done. 2024-01-18 23:58:30 ETA(in 00:06:40). Processing speed: 38.335 MiB/sec
Worker(2): 19.80% done. 2024-01-18 23:56:58 ETA(in 00:05:08). Processing speed: 47.906 MiB/sec
Worker(1): 18.76% done. 2024-01-18 23:58:21 ETA(in 00:06:30). Processing speed: 38.325 MiB/sec
Worker(0): 16.68% done. 2024-01-18 23:59:51 ETA(in 00:08:00). Processing speed: 31.940 MiB/sec
Worker(2): 20.84% done. 2024-01-18 23:56:58 ETA(in 00:05:04). Processing speed: 47.953 MiB/sec
Worker(3): 17.72% done. 2024-01-18 23:57:10 ETA(in 00:05:16). Processing speed: 47.910 MiB/sec
Worker(1): 19.80% done. 2024-01-18 23:57:03 ETA(in 00:05:08). Processing speed: 47.906 MiB/sec
Worker(0): 17.72% done. 2024-01-18 23:58:31 ETA(in 00:06:35). Processing speed: 38.325 MiB/sec
Worker(2): 21.88% done. 2024-01-18 23:56:58 ETA(in 00:05:00). Processing speed: 47.906 MiB/sec
Worker(3): 18.76% done. 2024-01-18 23:57:10 ETA(in 00:05:12). Processing speed: 47.906 MiB/sec
Worker(1): 20.84% done. 2024-01-18 23:57:03 ETA(in 00:05:04). Processing speed: 47.906 MiB/sec
Worker(0): 18.76% done. 2024-01-18 23:58:31 ETA(in 00:06:30). Processing speed: 38.325 MiB/sec
Worker(2): 22.92% done. 2024-01-18 23:56:58 ETA(in 00:04:56). Processing speed: 47.906 MiB/sec
Worker(1): 21.88% done. 2024-01-18 23:57:03 ETA(in 00:05:00). Processing speed: 47.906 MiB/sec
Worker(3): 19.80% done. 2024-01-18 23:58:28 ETA(in 00:06:25). Processing speed: 38.325 MiB/sec
Worker(2): 23.96% done. 2024-01-18 23:56:58 ETA(in 00:04:52). Processing speed: 47.943 MiB/sec
Worker(0): 19.80% done. 2024-01-18 23:58:31 ETA(in 00:06:25). Processing speed: 38.331 MiB/sec
Worker(1): 22.92% done. 2024-01-18 23:57:03 ETA(in 00:04:56). Processing speed: 47.906 MiB/sec
Worker(3): 20.84% done. 2024-01-18 23:58:28 ETA(in 00:06:20). Processing speed: 38.325 MiB/sec
Worker(2): 25.00% done. 2024-01-18 23:55:45 ETA(in 00:03:36). Processing speed: 63.948 MiB/sec
Worker(1): 23.96% done. 2024-01-18 23:57:03 ETA(in 00:04:52). Processing speed: 47.914 MiB/sec
Worker(0): 20.84% done. 2024-01-18 23:59:48 ETA(in 00:07:36). Processing speed: 31.938 MiB/sec
Worker(3): 21.88% done. 2024-01-18 23:58:28 ETA(in 00:06:15). Processing speed: 38.329 MiB/sec
Worker(2): 26.04% done. 2024-01-18 23:58:09 ETA(in 00:05:55). Processing speed: 38.325 MiB/sec
Worker(1): 25.00% done. 2024-01-18 23:57:03 ETA(in 00:04:48). Processing speed: 47.945 MiB/sec
Worker(0): 21.88% done. 2024-01-18 23:58:32 ETA(in 00:06:15). Processing speed: 38.325 MiB/sec
Worker(3): 22.92% done. 2024-01-18 23:58:28 ETA(in 00:06:10). Processing speed: 38.325 MiB/sec
Worker(2): 27.08% done. 2024-01-18 23:56:58 ETA(in 00:04:40). Processing speed: 47.914 MiB/sec
Worker(1): 26.04% done. 2024-01-18 23:57:03 ETA(in 00:04:44). Processing speed: 47.906 MiB/sec
Worker(0): 22.92% done. 2024-01-18 23:57:17 ETA(in 00:04:56). Processing speed: 47.910 MiB/sec
Worker(3): 23.96% done. 2024-01-18 23:58:28 ETA(in 00:06:05). Processing speed: 38.325 MiB/sec
Worker(2): 28.12% done. 2024-01-18 23:58:08 ETA(in 00:05:45). Processing speed: 38.332 MiB/sec
Worker(1): 27.08% done. 2024-01-18 23:57:03 ETA(in 00:04:40). Processing speed: 47.906 MiB/sec
Worker(0): 23.96% done. 2024-01-18 23:58:31 ETA(in 00:06:05). Processing speed: 38.325 MiB/sec
Worker(3): 25.00% done. 2024-01-18 23:57:15 ETA(in 00:04:48). Processing speed: 47.910 MiB/sec
Worker(2): 29.16% done. 2024-01-18 23:56:59 ETA(in 00:04:32). Processing speed: 47.906 MiB/sec
Worker(1): 28.12% done. 2024-01-18 23:58:13 ETA(in 00:05:45). Processing speed: 38.325 MiB/sec
Worker(0): 25.00% done. 2024-01-18 23:57:18 ETA(in 00:04:48). Processing speed: 47.906 MiB/sec
Worker(3): 26.04% done. 2024-01-18 23:58:27 ETA(in 00:05:55). Processing speed: 38.325 MiB/sec
Worker(1): 29.16% done. 2024-01-18 23:57:04 ETA(in 00:04:32). Processing speed: 47.906 MiB/sec
Worker(2): 30.20% done. 2024-01-18 23:59:15 ETA(in 00:06:42). Processing speed: 31.938 MiB/sec
Worker(0): 26.04% done. 2024-01-18 23:58:30 ETA(in 00:05:55). Processing speed: 38.333 MiB/sec
Worker(3): 27.07% done. 2024-01-18 23:57:16 ETA(in 00:04:40). Processing speed: 47.907 MiB/sec
Worker(1): 30.20% done. 2024-01-18 23:58:12 ETA(in 00:05:35). Processing speed: 38.326 MiB/sec
Worker(2): 31.24% done. 2024-01-18 23:57:01 ETA(in 00:04:24). Processing speed: 47.906 MiB/sec
Worker(0): 27.08% done. 2024-01-18 23:57:19 ETA(in 00:04:40). Processing speed: 47.953 MiB/sec
Worker(3): 28.11% done. 2024-01-18 23:58:26 ETA(in 00:05:45). Processing speed: 38.325 MiB/sec
Worker(1): 31.23% done. 2024-01-18 23:58:12 ETA(in 00:05:30). Processing speed: 38.325 MiB/sec
Worker(2): 32.28% done. 2024-01-18 23:59:13 ETA(in 00:06:30). Processing speed: 31.938 MiB/sec
Worker(0): 28.12% done. 2024-01-18 23:58:29 ETA(in 00:05:45). Processing speed: 38.325 MiB/sec
Worker(3): 29.16% done. 2024-01-18 23:57:17 ETA(in 00:04:32). Processing speed: 47.965 MiB/sec
Worker(1): 32.27% done. 2024-01-18 23:57:06 ETA(in 00:04:20). Processing speed: 47.906 MiB/sec
Worker(2): 33.32% done. 2024-01-18 23:57:03 ETA(in 00:04:16). Processing speed: 47.911 MiB/sec
Worker(3): 30.20% done. 2024-01-18 23:57:17 ETA(in 00:04:28). Processing speed: 47.922 MiB/sec
Worker(0): 29.16% done. 2024-01-18 23:58:29 ETA(in 00:05:40). Processing speed: 38.325 MiB/sec
Worker(1): 33.31% done. 2024-01-18 23:57:06 ETA(in 00:04:16). Processing speed: 47.906 MiB/sec
Worker(2): 34.36% done. 2024-01-18 23:55:59 ETA(in 00:03:09). Processing speed: 63.932 MiB/sec
Worker(3): 31.24% done. 2024-01-18 23:57:17 ETA(in 00:04:24). Processing speed: 47.906 MiB/sec
Worker(2): 35.40% done. 2024-01-18 23:57:02 ETA(in 00:04:08). Processing speed: 47.922 MiB/sec
Worker(1): 34.35% done. 2024-01-18 23:57:06 ETA(in 00:04:12). Processing speed: 47.906 MiB/sec
Worker(0): 30.20% done. 2024-01-18 23:59:37 ETA(in 00:06:42). Processing speed: 31.942 MiB/sec
Worker(3): 32.27% done. 2024-01-18 23:59:29 ETA(in 00:06:30). Processing speed: 31.938 MiB/sec
Worker(2): 36.44% done. 2024-01-18 23:58:04 ETA(in 00:05:05). Processing speed: 38.325 MiB/sec
Worker(1): 35.39% done. 2024-01-18 23:58:09 ETA(in 00:05:10). Processing speed: 38.328 MiB/sec
Worker(0): 31.24% done. 2024-01-19 00:00:44 ETA(in 00:07:42). Processing speed: 27.377 MiB/sec
Worker(3): 33.31% done. 2024-01-18 23:57:19 ETA(in 00:04:16). Processing speed: 47.906 MiB/sec
Worker(1): 36.43% done. 2024-01-18 23:57:07 ETA(in 00:04:04). Processing speed: 47.906 MiB/sec
Worker(2): 37.48% done. 2024-01-18 23:58:04 ETA(in 00:05:00). Processing speed: 38.325 MiB/sec
Worker(1): 37.47% done. 2024-01-18 23:57:07 ETA(in 00:04:00). Processing speed: 47.945 MiB/sec
Worker(2): 38.52% done. 2024-01-18 23:57:04 ETA(in 00:03:56). Processing speed: 47.906 MiB/sec
Worker(3): 34.35% done. 2024-01-18 23:58:23 ETA(in 00:05:15). Processing speed: 38.325 MiB/sec
Worker(0): 32.28% done. 2024-01-18 23:59:38 ETA(in 00:06:30). Processing speed: 31.938 MiB/sec
Worker(1): 38.51% done. 2024-01-18 23:56:07 ETA(in 00:02:57). Processing speed: 63.979 MiB/sec
Worker(3): 35.40% done. 2024-01-18 23:56:17 ETA(in 00:03:06). Processing speed: 64.000 MiB/sec
Worker(2): 39.56% done. 2024-01-18 23:56:05 ETA(in 00:02:54). Processing speed: 63.875 MiB/sec
Worker(1): 39.56% done. 2024-01-18 23:56:07 ETA(in 00:02:54). Processing speed: 63.932 MiB/sec
Worker(0): 33.32% done. 2024-01-18 23:58:33 ETA(in 00:05:20). Processing speed: 38.325 MiB/sec
Worker(3): 36.44% done. 2024-01-18 23:55:15 ETA(in 00:02:02). Processing speed: 96.000 MiB/sec
Worker(2): 40.60% done. 2024-01-18 23:56:05 ETA(in 00:02:51). Processing speed: 63.875 MiB/sec
Worker(3): 37.48% done. 2024-01-18 23:55:15 ETA(in 00:02:00). Processing speed: 96.000 MiB/sec
Worker(1): 40.60% done. 2024-01-18 23:55:09 ETA(in 00:01:54). Processing speed: 96.000 MiB/sec
Worker(0): 34.36% done. 2024-01-18 23:57:29 ETA(in 00:04:12). Processing speed: 47.906 MiB/sec
Worker(3): 38.52% done. 2024-01-18 23:55:15 ETA(in 00:01:58). Processing speed: 96.000 MiB/sec
Worker(1): 41.64% done. 2024-01-18 23:55:09 ETA(in 00:01:52). Processing speed: 96.000 MiB/sec
Worker(2): 41.64% done. 2024-01-18 23:56:05 ETA(in 00:02:48). Processing speed: 63.875 MiB/sec
Worker(3): 39.56% done. 2024-01-18 23:55:15 ETA(in 00:01:56). Processing speed: 96.000 MiB/sec
Worker(1): 42.68% done. 2024-01-18 23:56:05 ETA(in 00:02:45). Processing speed: 64.000 MiB/sec
Worker(0): 35.40% done. 2024-01-18 23:57:29 ETA(in 00:04:08). Processing speed: 47.906 MiB/sec
Worker(3): 40.60% done. 2024-01-18 23:55:15 ETA(in 00:01:54). Processing speed: 96.000 MiB/sec
Worker(2): 42.68% done. 2024-01-18 23:57:57 ETA(in 00:04:35). Processing speed: 38.325 MiB/sec
Worker(1): 43.72% done. 2024-01-18 23:55:10 ETA(in 00:01:48). Processing speed: 96.000 MiB/sec
Worker(3): 41.65% done. 2024-01-18 23:54:18 ETA(in 00:00:56). Processing speed: 192.000 MiB/sec
Worker(1): 44.76% done. 2024-01-18 23:54:16 ETA(in 00:00:53). Processing speed: 192.000 MiB/sec
Worker(3): 42.69% done. 2024-01-18 23:54:18 ETA(in 00:00:55). Processing speed: 192.000 MiB/sec
Worker(0): 36.44% done. 2024-01-18 23:55:25 ETA(in 00:02:02). Processing speed: 95.898 MiB/sec
Worker(1): 46.37% done. 2024-01-18 23:53:57 ETA(in 00:00:33). Processing speed: 296.000 MiB/sec
Worker(3): 43.73% done. 2024-01-18 23:54:18 ETA(in 00:00:54). Processing speed: 192.000 MiB/sec
Worker(0): 37.48% done. 2024-01-18 23:54:24 ETA(in 00:01:00). Processing speed: 191.984 MiB/sec
Worker(2): 43.72% done. 2024-01-18 23:55:12 ETA(in 00:01:48). Processing speed: 95.813 MiB/sec
Worker(1): 48.32% done. 2024-01-18 23:53:51 ETA(in 00:00:26). Processing speed: 360.000 MiB/sec
Worker(3): 45.03% done. 2024-01-18 23:54:07 ETA(in 00:00:42). Processing speed: 240.000 MiB/sec
Worker(0): 38.52% done. 2024-01-18 23:54:24 ETA(in 00:00:59). Processing speed: 192.000 MiB/sec
Worker(0): 39.69% done. 2024-01-18 23:54:17 ETA(in 00:00:51). Processing speed: 216.000 MiB/sec
Worker(1): 49.54% done. 2024-01-18 23:54:07 ETA(in 00:00:41). Processing speed: 224.000 MiB/sec
Worker(3): 46.29% done. 2024-01-18 23:54:08 ETA(in 00:00:42). Processing speed: 232.000 MiB/sec
Worker(2): 44.76% done. 2024-01-18 23:55:12 ETA(in 00:01:46). Processing speed: 95.813 MiB/sec
Worker(3): 47.33% done. 2024-01-18 23:54:17 ETA(in 00:00:50). Processing speed: 192.000 MiB/sec
Worker(0): 40.73% done. 2024-01-18 23:54:23 ETA(in 00:00:56). Processing speed: 192.000 MiB/sec
Worker(1): 50.58% done. 2024-01-18 23:54:14 ETA(in 00:00:47). Processing speed: 192.000 MiB/sec
Worker(2): 45.80% done. 2024-01-18 23:55:12 ETA(in 00:01:44). Processing speed: 95.813 MiB/sec
Worker(3): 48.37% done. 2024-01-18 23:54:17 ETA(in 00:00:49). Processing speed: 192.000 MiB/sec
Worker(0): 41.77% done. 2024-01-18 23:54:23 ETA(in 00:00:55). Processing speed: 192.000 MiB/sec
Worker(1): 51.62% done. 2024-01-18 23:54:14 ETA(in 00:00:46). Processing speed: 192.000 MiB/sec
Worker(3): 49.41% done. 2024-01-18 23:54:17 ETA(in 00:00:48). Processing speed: 192.000 MiB/sec
Worker(0): 42.82% done. 2024-01-18 23:55:19 ETA(in 00:01:49). Processing speed: 96.000 MiB/sec
Worker(1): 52.66% done. 2024-01-18 23:55:00 ETA(in 00:01:30). Processing speed: 96.000 MiB/sec
Worker(2): 46.84% done. 2024-01-18 23:55:12 ETA(in 00:01:42). Processing speed: 95.813 MiB/sec
Worker(3): 50.46% done. 2024-01-18 23:54:17 ETA(in 00:00:47). Processing speed: 192.000 MiB/sec
Worker(0): 43.86% done. 2024-01-18 23:54:24 ETA(in 00:00:53). Processing speed: 192.000 MiB/sec
Worker(1): 53.70% done. 2024-01-18 23:54:15 ETA(in 00:00:44). Processing speed: 192.000 MiB/sec
Worker(3): 51.50% done. 2024-01-18 23:54:17 ETA(in 00:00:46). Processing speed: 192.000 MiB/sec
Worker(1): 54.75% done. 2024-01-18 23:54:15 ETA(in 00:00:43). Processing speed: 192.000 MiB/sec
Worker(0): 44.90% done. 2024-01-18 23:54:24 ETA(in 00:00:52). Processing speed: 192.000 MiB/sec
Worker(3): 52.54% done. 2024-01-18 23:54:17 ETA(in 00:00:45). Processing speed: 192.000 MiB/sec
Worker(2): 47.88% done. 2024-01-18 23:55:12 ETA(in 00:01:40). Processing speed: 95.813 MiB/sec
Worker(1): 55.79% done. 2024-01-18 23:54:15 ETA(in 00:00:42). Processing speed: 192.000 MiB/sec
Worker(3): 53.58% done. 2024-01-18 23:55:03 ETA(in 00:01:29). Processing speed: 96.000 MiB/sec
Worker(0): 45.94% done. 2024-01-18 23:55:17 ETA(in 00:01:43). Processing speed: 96.000 MiB/sec
Worker(2): 48.92% done. 2024-01-18 23:56:02 ETA(in 00:02:27). Processing speed: 63.875 MiB/sec
Worker(1): 56.83% done. 2024-01-18 23:54:57 ETA(in 00:01:22). Processing speed: 96.000 MiB/sec
Worker(3): 54.62% done. 2024-01-18 23:54:18 ETA(in 00:00:43). Processing speed: 192.000 MiB/sec
Worker(0): 46.98% done. 2024-01-18 23:54:25 ETA(in 00:00:50). Processing speed: 192.000 MiB/sec
Worker(1): 57.91% done. 2024-01-18 23:54:14 ETA(in 00:00:38). Processing speed: 200.000 MiB/sec
Worker(3): 55.71% done. 2024-01-18 23:54:16 ETA(in 00:00:40). Processing speed: 200.000 MiB/sec
Worker(2): 49.96% done. 2024-01-18 23:54:24 ETA(in 00:00:48). Processing speed: 191.937 MiB/sec
Worker(0): 48.02% done. 2024-01-18 23:54:25 ETA(in 00:00:49). Processing speed: 192.000 MiB/sec
Worker(1): 59.52% done. 2024-01-18 23:54:02 ETA(in 00:00:25). Processing speed: 296.000 MiB/sec
Worker(3): 56.79% done. 2024-01-18 23:54:16 ETA(in 00:00:39). Processing speed: 200.000 MiB/sec
Worker(2): 51.43% done. 2024-01-18 23:54:09 ETA(in 00:00:32). Processing speed: 272.000 MiB/sec
Worker(0): 49.07% done. 2024-01-18 23:54:25 ETA(in 00:00:48). Processing speed: 192.000 MiB/sec
Worker(1): 61.13% done. 2024-01-18 23:54:02 ETA(in 00:00:24). Processing speed: 296.000 MiB/sec
Worker(2): 52.95% done. 2024-01-18 23:54:08 ETA(in 00:00:30). Processing speed: 280.000 MiB/sec
Worker(3): 57.92% done. 2024-01-18 23:54:15 ETA(in 00:00:37). Processing speed: 208.000 MiB/sec
Worker(0): 50.24% done. 2024-01-18 23:54:20 ETA(in 00:00:42). Processing speed: 216.000 MiB/sec
Worker(2): 53.99% done. 2024-01-18 23:54:23 ETA(in 00:00:44). Processing speed: 192.000 MiB/sec
Worker(1): 62.17% done. 2024-01-18 23:54:15 ETA(in 00:00:36). Processing speed: 192.000 MiB/sec
Worker(3): 58.96% done. 2024-01-18 23:54:18 ETA(in 00:00:39). Processing speed: 192.000 MiB/sec
Worker(0): 51.28% done. 2024-01-18 23:54:25 ETA(in 00:00:46). Processing speed: 192.000 MiB/sec
Worker(2): 55.03% done. 2024-01-18 23:54:23 ETA(in 00:00:43). Processing speed: 192.000 MiB/sec
Worker(1): 63.21% done. 2024-01-18 23:54:15 ETA(in 00:00:35). Processing speed: 192.000 MiB/sec
Worker(0): 52.32% done. 2024-01-18 23:54:25 ETA(in 00:00:45). Processing speed: 192.000 MiB/sec
Worker(3): 60.01% done. 2024-01-18 23:54:18 ETA(in 00:00:38). Processing speed: 192.000 MiB/sec
Worker(1): 64.86% done. 2024-01-18 23:54:02 ETA(in 00:00:21). Processing speed: 304.000 MiB/sec
Worker(2): 56.42% done. 2024-01-18 23:54:12 ETA(in 00:00:31). Processing speed: 256.000 MiB/sec
Worker(0): 53.36% done. 2024-01-18 23:54:25 ETA(in 00:00:44). Processing speed: 192.000 MiB/sec
Worker(3): 61.05% done. 2024-01-18 23:54:18 ETA(in 00:00:37). Processing speed: 192.000 MiB/sec
Worker(0): 54.71% done. 2024-01-18 23:54:15 ETA(in 00:00:33). Processing speed: 248.000 MiB/sec
Worker(1): 66.25% done. 2024-01-18 23:54:06 ETA(in 00:00:24). Processing speed: 256.000 MiB/sec
Worker(3): 62.26% done. 2024-01-18 23:54:13 ETA(in 00:00:31). Processing speed: 224.000 MiB/sec
Worker(2): 57.94% done. 2024-01-18 23:54:09 ETA(in 00:00:27). Processing speed: 280.000 MiB/sec
Worker(2): 59.46% done. 2024-01-18 23:54:09 ETA(in 00:00:26). Processing speed: 280.000 MiB/sec
Worker(0): 56.05% done. 2024-01-18 23:54:15 ETA(in 00:00:32). Processing speed: 248.000 MiB/sec
Worker(1): 67.55% done. 2024-01-18 23:54:07 ETA(in 00:00:24). Processing speed: 240.000 MiB/sec
Worker(3): 63.78% done. 2024-01-18 23:54:06 ETA(in 00:00:23). Processing speed: 280.000 MiB/sec
Worker(1): 69.29% done. 2024-01-18 23:54:01 ETA(in 00:00:17). Processing speed: 320.000 MiB/sec
Worker(3): 65.47% done. 2024-01-18 23:54:04 ETA(in 00:00:20). Processing speed: 312.000 MiB/sec
Worker(0): 57.23% done. 2024-01-18 23:54:20 ETA(in 00:00:36). Processing speed: 216.000 MiB/sec
Worker(2): 60.85% done. 2024-01-18 23:54:12 ETA(in 00:00:28). Processing speed: 256.000 MiB/sec
Worker(0): 58.40% done. 2024-01-18 23:54:20 ETA(in 00:00:35). Processing speed: 216.000 MiB/sec
Worker(3): 67.25% done. 2024-01-18 23:54:03 ETA(in 00:00:18). Processing speed: 328.000 MiB/sec
Worker(1): 71.11% done. 2024-01-18 23:54:00 ETA(in 00:00:15). Processing speed: 336.000 MiB/sec
Worker(2): 62.02% done. 2024-01-18 23:54:17 ETA(in 00:00:32). Processing speed: 216.000 MiB/sec
Worker(2): 63.50% done. 2024-01-18 23:54:10 ETA(in 00:00:24). Processing speed: 272.000 MiB/sec
Worker(0): 60.13% done. 2024-01-18 23:54:08 ETA(in 00:00:22). Processing speed: 320.000 MiB/sec
Worker(3): 69.12% done. 2024-01-18 23:54:02 ETA(in 00:00:16). Processing speed: 344.000 MiB/sec
Worker(1): 72.24% done. 2024-01-18 23:54:10 ETA(in 00:00:24). Processing speed: 208.000 MiB/sec
Worker(0): 61.65% done. 2024-01-18 23:54:12 ETA(in 00:00:25). Processing speed: 280.000 MiB/sec
Worker(3): 70.77% done. 2024-01-18 23:54:04 ETA(in 00:00:17). Processing speed: 304.000 MiB/sec
Worker(2): 64.97% done. 2024-01-18 23:54:10 ETA(in 00:00:23). Processing speed: 272.000 MiB/sec
Worker(1): 73.58% done. 2024-01-18 23:54:06 ETA(in 00:00:19). Processing speed: 248.000 MiB/sec
Worker(0): 63.35% done. 2024-01-18 23:54:09 ETA(in 00:00:21). Processing speed: 312.000 MiB/sec
Worker(3): 72.37% done. 2024-01-18 23:54:05 ETA(in 00:00:17). Processing speed: 296.000 MiB/sec
Worker(2): 66.58% done. 2024-01-18 23:54:08 ETA(in 00:00:20). Processing speed: 296.000 MiB/sec
Worker(1): 75.19% done. 2024-01-18 23:54:03 ETA(in 00:00:15). Processing speed: 296.000 MiB/sec
Worker(0): 64.95% done. 2024-01-18 23:54:10 ETA(in 00:00:21). Processing speed: 296.000 MiB/sec
Worker(2): 68.36% done. 2024-01-18 23:54:06 ETA(in 00:00:17). Processing speed: 328.000 MiB/sec
Worker(1): 76.71% done. 2024-01-18 23:54:04 ETA(in 00:00:15). Processing speed: 280.000 MiB/sec
Worker(3): 73.98% done. 2024-01-18 23:54:05 ETA(in 00:00:16). Processing speed: 296.000 MiB/sec
Worker(3): 75.76% done. 2024-01-18 23:54:03 ETA(in 00:00:13). Processing speed: 328.000 MiB/sec
Worker(1): 78.05% done. 2024-01-18 23:54:06 ETA(in 00:00:16). Processing speed: 248.000 MiB/sec
Worker(0): 66.56% done. 2024-01-18 23:54:10 ETA(in 00:00:20). Processing speed: 296.000 MiB/sec
Worker(2): 70.18% done. 2024-01-18 23:54:06 ETA(in 00:00:16). Processing speed: 336.000 MiB/sec
Worker(3): 77.50% done. 2024-01-18 23:54:03 ETA(in 00:00:12). Processing speed: 320.000 MiB/sec
Worker(1): 79.57% done. 2024-01-18 23:54:04 ETA(in 00:00:13). Processing speed: 280.000 MiB/sec
Worker(0): 67.99% done. 2024-01-18 23:54:13 ETA(in 00:00:22). Processing speed: 264.000 MiB/sec
Worker(2): 71.92% done. 2024-01-18 23:54:07 ETA(in 00:00:16). Processing speed: 320.000 MiB/sec
Worker(3): 79.28% done. 2024-01-18 23:54:03 ETA(in 00:00:11). Processing speed: 328.000 MiB/sec
Worker(1): 81.22% done. 2024-01-18 23:54:03 ETA(in 00:00:11). Processing speed: 304.000 MiB/sec
Worker(2): 73.70% done. 2024-01-18 23:54:06 ETA(in 00:00:14). Processing speed: 328.000 MiB/sec
Worker(0): 69.29% done. 2024-01-18 23:54:15 ETA(in 00:00:23). Processing speed: 240.000 MiB/sec
Worker(2): 75.26% done. 2024-01-18 23:54:08 ETA(in 00:00:15). Processing speed: 288.000 MiB/sec
Worker(1): 82.91% done. 2024-01-18 23:54:03 ETA(in 00:00:10). Processing speed: 312.000 MiB/sec
Worker(3): 80.71% done. 2024-01-18 23:54:06 ETA(in 00:00:13). Processing speed: 264.000 MiB/sec
Worker(0): 70.81% done. 2024-01-18 23:54:12 ETA(in 00:00:19). Processing speed: 280.000 MiB/sec
Worker(1): 84.52% done. 2024-01-18 23:54:03 ETA(in 00:00:09). Processing speed: 296.000 MiB/sec
Worker(2): 76.91% done. 2024-01-18 23:54:08 ETA(in 00:00:14). Processing speed: 304.000 MiB/sec
Worker(3): 82.31% done. 2024-01-18 23:54:05 ETA(in 00:00:11). Processing speed: 296.000 MiB/sec
Worker(0): 72.37% done. 2024-01-18 23:54:11 ETA(in 00:00:17). Processing speed: 288.000 MiB/sec
Worker(3): 83.75% done. 2024-01-18 23:54:06 ETA(in 00:00:11). Processing speed: 264.000 MiB/sec
Worker(1): 86.43% done. 2024-01-18 23:54:02 ETA(in 00:00:07). Processing speed: 352.000 MiB/sec
Worker(0): 73.94% done. 2024-01-18 23:54:11 ETA(in 00:00:16). Processing speed: 288.000 MiB/sec
Worker(2): 78.30% done. 2024-01-18 23:54:10 ETA(in 00:00:15). Processing speed: 256.000 MiB/sec
Worker(2): 79.69% done. 2024-01-18 23:54:10 ETA(in 00:00:14). Processing speed: 256.000 MiB/sec
Worker(1): 88.38% done. 2024-01-18 23:54:01 ETA(in 00:00:05). Processing speed: 360.000 MiB/sec
Worker(3): 85.22% done. 2024-01-18 23:54:06 ETA(in 00:00:10). Processing speed: 272.000 MiB/sec
Worker(0): 75.33% done. 2024-01-18 23:54:13 ETA(in 00:00:17). Processing speed: 256.000 MiB/sec
Worker(2): 81.12% done. 2024-01-18 23:54:10 ETA(in 00:00:13). Processing speed: 264.000 MiB/sec
Worker(0): 77.15% done. 2024-01-18 23:54:09 ETA(in 00:00:12). Processing speed: 336.000 MiB/sec
Worker(1): 90.21% done. 2024-01-18 23:54:02 ETA(in 00:00:05). Processing speed: 336.000 MiB/sec
Worker(3): 86.44% done. 2024-01-18 23:54:08 ETA(in 00:00:11). Processing speed: 224.000 MiB/sec
Worker(0): 79.10% done. 2024-01-18 23:54:08 ETA(in 00:00:10). Processing speed: 360.000 MiB/sec
Worker(3): 88.04% done. 2024-01-18 23:54:05 ETA(in 00:00:07). Processing speed: 296.000 MiB/sec
Worker(1): 91.51% done. 2024-01-18 23:54:04 ETA(in 00:00:06). Processing speed: 240.000 MiB/sec
Worker(2): 82.60% done. 2024-01-18 23:54:09 ETA(in 00:00:11). Processing speed: 272.000 MiB/sec
Worker(0): 80.40% done. 2024-01-18 23:54:14 ETA(in 00:00:15). Processing speed: 240.000 MiB/sec
Worker(1): 92.98% done. 2024-01-18 23:54:03 ETA(in 00:00:04). Processing speed: 272.000 MiB/sec
Worker(3): 89.65% done. 2024-01-18 23:54:05 ETA(in 00:00:06). Processing speed: 296.000 MiB/sec
Worker(2): 84.29% done. 2024-01-18 23:54:08 ETA(in 00:00:09). Processing speed: 312.000 MiB/sec
Worker(1): 94.59% done. 2024-01-18 23:54:03 ETA(in 00:00:03). Processing speed: 296.000 MiB/sec
Worker(3): 91.12% done. 2024-01-18 23:54:06 ETA(in 00:00:06). Processing speed: 272.000 MiB/sec
Worker(2): 86.02% done. 2024-01-18 23:54:08 ETA(in 00:00:08). Processing speed: 320.000 MiB/sec
Worker(0): 81.88% done. 2024-01-18 23:54:12 ETA(in 00:00:12). Processing speed: 272.000 MiB/sec
Worker(2): 87.37% done. 2024-01-18 23:54:10 ETA(in 00:00:09). Processing speed: 248.000 MiB/sec
Worker(1): 96.33% done. 2024-01-18 23:54:03 ETA(in 00:00:02). Processing speed: 320.000 MiB/sec
Worker(0): 83.18% done. 2024-01-18 23:54:13 ETA(in 00:00:12). Processing speed: 240.000 MiB/sec
Worker(3): 92.86% done. 2024-01-18 23:54:05 ETA(in 00:00:04). Processing speed: 320.000 MiB/sec
Worker(2): 89.32% done. 2024-01-18 23:54:07 ETA(in 00:00:05). Processing speed: 360.000 MiB/sec
Worker(3): 94.60% done. 2024-01-18 23:54:05 ETA(in 00:00:03). Processing speed: 320.000 MiB/sec
Worker(1): 97.98% done. 2024-01-18 23:54:03 ETA(in 00:00:01). Processing speed: 304.000 MiB/sec
Worker(0): 84.22% done. 2024-01-18 23:54:17 ETA(in 00:00:15). Processing speed: 192.000 MiB/sec
Worker(0): 85.74% done. 2024-01-18 23:54:12 ETA(in 00:00:09). Processing speed: 280.000 MiB/sec
Worker(2): 91.28% done. 2024-01-18 23:54:07 ETA(in 00:00:04). Processing speed: 360.000 MiB/sec
Worker(3): 95.90% done. 2024-01-18 23:54:06 ETA(in 00:00:03). Processing speed: 240.000 MiB/sec
Worker(1): 99.02% done. 2024-01-18 23:54:03 ETA(in 00:00:00). Processing speed: 191.922 MiB/sec
Worker(2): 92.93% done. 2024-01-18 23:54:08 ETA(in 00:00:04). Processing speed: 304.000 MiB/sec
Worker(0): 87.56% done. 2024-01-18 23:54:10 ETA(in 00:00:06). Processing speed: 336.000 MiB/sec
Worker(0): 89.86% done. 2024-01-18 23:54:09 ETA(in 00:00:04). Processing speed: 424.000 MiB/sec
Worker(2): 95.14% done. 2024-01-18 23:54:07 ETA(in 00:00:02). Processing speed: 408.000 MiB/sec
Worker(2): 97.48% done. 2024-01-18 23:54:07 ETA(in 00:00:01). Processing speed: 432.000 MiB/sec
Worker(0): 92.17% done. 2024-01-18 23:54:09 ETA(in 00:00:03). Processing speed: 424.000 MiB/sec
Worker(0): 94.77% done. 2024-01-18 23:54:09 ETA(in 00:00:02). Processing speed: 480.000 MiB/sec
Worker(2): 98.74% done. 2024-01-18 23:54:08 ETA(in 00:00:01). Processing speed: 231.814 MiB/sec
Worker(0): 97.33% done. 2024-01-18 23:54:09 ETA(in 00:00:01). Processing speed: 472.000 MiB/sec
Worker(2): 99.78% done. 2024-01-18 23:54:08 ETA(in 00:00:00). Processing speed: 191.641 MiB/sec
Worker(0): 99.46% done. 2024-01-18 23:54:09 ETA(in 00:00:00). Processing speed: 391.986 MiB/sec
All workers finished in 222 sec

运行完成后,会在当前目录下生成pages-ol-root 文件目录, 目录下按照每个页为一个文件,分为索引页和数据较大的BLOB 页,我们访问系统表的话,是存在索引页中的

5:扫描数据字典文件
./stream_parser -f /mysqldata/mysql/ibdata1
一般情况下表结构是存储在frm 文件中,drop table 会删除frm 文件,还好我们可以从innodb 系统表里读取一些信息恢复表结构。innodb 系统表有SYS_COLUMNS | SYS_FIELDS |SYS_INDEXES | SYS_TABLES。需要从系统表中恢复,而系统表是保存在$datadir/ibdata1 文件中的解析ibdata 文件,扫描出所有符合innodb 格式的数据页,结果会按照index_id 进行重新组织

[root@localhost undrop-for-innodb-master]# ./stream_parser -f /mysqldata/mysql/ibdata1
Opening file: /mysqldata/mysql/ibdata1
File information:

ID of device containing file:        64768
inode number:                      4591360
protection:                         100640 Opening file: /mysqldata/mysql/ibdata1
(regular file)
number of hard links:                    1
user ID of owner:                       27
File information:

group ID of owner:                      27
device ID (if special file):             0
blocksize for filesystem I/O:         4096
number of blocks allocated:         151560
ID of device containing file:        64768
inode number:                      4591360
protection:                         100640 (regular file)
number of hard links:                    1
user ID of owner:                       27
group ID of owner:                      27
device ID (if special file):             0
blocksize for filesystem I/O:         4096
Opening file: /mysqldata/mysql/ibdata1
number of blocks allocated:         151560
File information:

ID of device containing file:        64768
inode number:                      4591360
protection:                         100640 (regular file)
number of hard links:                    1
user ID of owner:                       27
group ID of owner:                      27
device ID (if special file):             0
blocksize for filesystem I/O:         4096
number of blocks allocated:         151560
time of last access:            1705592841 Thu Jan 18 23:47:21 2024
Opening file: /mysqldata/mysql/ibdata1
time of last modification:      1705592841 Thu Jan 18 23:47:21 2024
File information:

time of last status change:     1705592841 Thu Jan 18 23:47:21 2024
time of last access:            1705592841 Thu Jan 18 23:47:21 2024
ID of device containing file:        64768
inode number:                      4591360
total size, in bytes:             77594624 (74.000 MiB)

time of last modification:      1705592841 Thu Jan 18 23:47:21 2024
protection:                         100640 (regular file)
number of hard links:                    1
user ID of owner:                       27
time of last status change:     1705592841 Thu Jan 18 23:47:21 2024
group ID of owner:                      27
device ID (if special file):             0
blocksize for filesystem I/O:         4096
number of blocks allocated:         151560
Size to process:                  77594624 (74.000 MiB)
total size, in bytes:             77594624 (74.000 MiB)

time of last access:            1705592841 Thu Jan 18 23:47:21 2024
Size to process:                  77594624 (74.000 MiB)
time of last modification:      1705592841 Thu Jan 18 23:47:21 2024
time of last status change:     1705592841 Thu Jan 18 23:47:21 2024
total size, in bytes:             77594624 (74.000 MiB)

Size to process:                  77594624 (74.000 MiB)
time of last access:            1705592841 Thu Jan 18 23:47:21 2024
time of last modification:      1705592841 Thu Jan 18 23:47:21 2024
time of last status change:     1705592841 Thu Jan 18 23:47:21 2024
total size, in bytes:             77594624 (74.000 MiB)

Size to process:                  77594624 (74.000 MiB)
All workers finished in 0 sec




[root@localhost undrop-for-innodb-master]# cd dictionary/
[root@localhost dictionary]# ll
total 16
-rw-r--r--. 1 root root 1845 Oct  2  2015 SYS_COLUMNS.sql
-rw-r--r--. 1 root root 1685 Oct  2  2015 SYS_FIELDS.sql
-rw-r--r--. 1 root root 1876 Oct  2  2015 SYS_INDEXES.sql
-rw-r--r--. 1 root root 1895 Oct  2  2015 SYS_TABLES.sql

[root@localhost undrop-for-innodb-master]# cd pages-ibdata1
[root@localhost pages-ibdata1]# ll
total 4
drwxr-xr-x. 2 root root 4096 Jan 19 00:03 FIL_PAGE_INDEX
drwxr-xr-x. 2 root root    6 Jan 19 00:03 FIL_PAGE_TYPE_BLOB

[root@localhost pages-ibdata1]# cd FIL_PAGE_INDEX
[root@localhost FIL_PAGE_INDEX]# ll
total 1312
-rw-r--r--. 1 root root  32768 Jan 19 00:03 0000000000000001.page
-rw-r--r--. 1 root root  16384 Jan 19 00:03 0000000000000002.page
-rw-r--r--. 1 root root  16384 Jan 19 00:03 0000000000000003.page
-rw-r--r--. 1 root root  16384 Jan 19 00:03 0000000000000004.page
-rw-r--r--. 1 root root  32768 Jan 19 00:03 0000000000000005.page
-rw-r--r--. 1 root root  16384 Jan 19 00:03 0000000000000011.page
-rw-r--r--. 1 root root  16384 Jan 19 00:03 0000000000000012.page
-rw-r--r--. 1 root root  16384 Jan 19 00:03 0000000000000013.page
-rw-r--r--. 1 root root  16384 Jan 19 00:03 0000000000000014.page
-rw-r--r--. 1 root root  32768 Jan 19 00:03 0000000000000015.page
-rw-r--r--. 1 root root  32768 Jan 19 00:03 0000000000000016.page
-rw-r--r--. 1 root root  16384 Jan 19 00:03 0000000000000017.page
-rw-r--r--. 1 root root 475136 Jan 19 00:03 0000000000000025.page
-rw-r--r--. 1 root root  49152 Jan 19 00:03 0000000000000026.page
-rw-r--r--. 1 root root  16384 Jan 19 00:03 0000000000000027.page
-rw-r--r--. 1 root root  16384 Jan 19 00:03 0000000000000047.page
-rw-r--r--. 1 root root  16384 Jan 19 00:03 18446744069414584320.page

6:解析数据字典表
被删除表的数据字典信息由于数据字典是存放在ibdata 文件中,通过上面的stream_parser 解析出来的数据页,是按照index_id 排序组织的,其中01 是SYS_TABLES,02 是SYS_COLUMNS,03 是SYS_INDEXES,04 是SYS_FIELDS。解析对应的page,获取对应的表结构信息。

这里有个地方需要注意,就是这个输出的文件路径./dumps/default,这是工具里代码固定的,因此在此步骤之前我们必须要创建这个目录$BASEDIR/dumps/default

[root@localhost undrop-for-innodb-master]# mkdir -p dumps/default

[root@localhost undrop-for-innodb-master]# ./c_parser -4Df pages-ibdata1/FIL_PAGE_INDEX/0000000000000001.page -t dictionary/SYS_TABLES.sql >./dumps/default/SYS_TABLES 2>./dumps/default/SYS_TABLES.sql;

[root@localhost undrop-for-innodb-master]# ./c_parser -4Df pages-ibdata1/FIL_PAGE_INDEX/0000000000000003.page -t dictionary/SYS_INDEXES.sql >./dumps/default/SYS_INDEXES 2>./dumps/default/SYS_INDEXES.sql;

[root@localhost undrop-for-innodb-master]# ./c_parser -4Df pages-ibdata1/FIL_PAGE_INDEX/0000000000000002.page -t dictionary/SYS_COLUMNS.sql>./dumps/default/SYS_COLUMNS 2>./dumps/default/SYS_COLUMNS.sql;

[root@localhost undrop-for-innodb-master]# ./c_parser -4Df pages-ibdata1/FIL_PAGE_INDEX/0000000000000004.page -t dictionary/SYS_FIELDS.sql >./dumps/default/SYS_FIELDS 2>./dumps/default/SYS_FIELDS.sql;

7:查看相应的数据字典信息
带有.sql 后缀的是根据表结构生成的load data 语句,其中load 语句中需要加载的文件就是不带.sql 的文本文件

[root@localhost undrop-for-innodb-master]# cd dumps/default/
[root@localhost default]# ll
total 32
-rw-r--r--. 1 root root 470 Jan 19 22:38 SYS_COLUMNS
-rw-r--r--. 1 root root 286 Jan 19 22:38 SYS_COLUMNS.sql
-rw-r--r--. 1 root root 200 Jan 19 22:38 SYS_FIELDS
-rw-r--r--. 1 root root 253 Jan 19 22:38 SYS_FIELDS.sql
-rw-r--r--. 1 root root 317 Jan 19 22:37 SYS_INDEXES
-rw-r--r--. 1 root root 291 Jan 19 22:37 SYS_INDEXES.sql
-rw-r--r--. 1 root root 580 Jan 19 22:34 SYS_TABLES
-rw-r--r--. 1 root root 300 Jan 19 22:34 SYS_TABLES.sql

[root@localhost default]# cat SYS_TABLES.sql
SET FOREIGN_KEY_CHECKS=0;
LOAD DATA LOCAL INFILE '/undrop-for-innodb-master/dumps/default/SYS_TABLES' REPLACE INTO TABLE `SYS_TABLES` FIELDS TERMINATED BY '\t' OPTIONALLY ENCLOSED BY '"' LINES STARTING BY 'SYS_TABLES\t' (`NAME`, `ID`, `N_COLS`, `TYPE`, `MIX_ID`, `MIX_LEN`, `CLUSTER_NAME`, `SPACE`);
[root@localhost default]# cat SYS_TABLES
-- Page id: 8, Format: REDUNDANT, Records list: Invalid, Expected records: (0 28)
000000000511    2D000001360182  SYS_TABLES      "test/t"        36      1       33      0       80      ""      22
000000000B10    2E0000013404D8  SYS_TABLES      "test/articles" 52      3       33      0       80      ""      33
-- Page id: 8, Found records: 2, Lost records: YES, Leaf page: YES
-- Page id: 8, Format: REDUNDANT, Records list: Invalid, Expected records: (0 28)
000000000511    2D000001360182  SYS_TABLES      "test/t"        36      1       33      0       80      ""      22
000000000B10    2E0000013404D8  SYS_TABLES      "test/articles" 52      3       33      0       80      ""      33
-- Page id: 8, Found records: 2, Lost records: YES, Leaf page: YES
[root@localhost default]# cat SYS_FIELDS.sql
SET FOREIGN_KEY_CHECKS=0;
LOAD DATA LOCAL INFILE '/undrop-for-innodb-master/dumps/default/SYS_FIELDS' REPLACE INTO TABLE `SYS_FIELDS` FIELDS TERMINATED BY '\t' OPTIONALLY ENCLOSED BY '"' LINES STARTING BY 'SYS_FIELDS\t' (`INDEX_ID`, `POS`, `COL_NAME`);
[root@localhost default]# cat SYS_FIELDS
-- Page id: 12, Format: REDUNDANT, Records list: Invalid, Expected records: (0 43)
000000000B10    2E0000013403C7  SYS_FIELDS      48      0       "id"
-- Page id: 12, Found records: 1, Lost records: YES, Leaf page: YES
[root@localhost default]# cat SYS_COLUMNS.sql
SET FOREIGN_KEY_CHECKS=0;
LOAD DATA LOCAL INFILE '/undrop-for-innodb-master/dumps/default/SYS_COLUMNS' REPLACE INTO TABLE `SYS_COLUMNS` FIELDS TERMINATED BY '\t' OPTIONALLY ENCLOSED BY '"' LINES STARTING BY 'SYS_COLUMNS\t' (`TABLE_ID`, `POS`, `NAME`, `MTYPE`, `PRTYPE`, `LEN`, `PREC`);
[root@localhost default]# cat SYS_COLUMNS
-- Page id: 10, Format: REDUNDANT, Records list: Invalid, Expected records: (0 133)
000000000582    5A0000016001BA  SYS_COLUMNS     48      0       "i"     6       1027    4       0
000000000585    5C0000016201BA  SYS_COLUMNS     49      0       "i"     6       1027    4       0
000000000B10    2E000001340439  SYS_COLUMNS     52      0       "id"    6       1283    4       0
000000000B10    2E00000134046E  SYS_COLUMNS     52      1       "title" 12      2953231 800     0
000000000B10    2E0000013404A3  SYS_COLUMNS     52      2       "body"  5       2949372 10      0
-- Page id: 10, Found records: 5, Lost records: YES, Leaf page: YES
[root@localhost default]# cat SYS_INDEXES.sql
SET FOREIGN_KEY_CHECKS=0;
LOAD DATA LOCAL INFILE '/undrop-for-innodb-master/dumps/default/SYS_INDEXES' REPLACE INTO TABLE `SYS_INDEXES` FIELDS TERMINATED BY '\t' OPTIONALLY ENCLOSED BY '"' LINES STARTING BY 'SYS_INDEXES\t' (`TABLE_ID`, `ID`, `NAME`, `N_FIELDS`, `TYPE`, `SPACE`, `PAGE_NO`);
[root@localhost default]# cat SYS_INDEXES
-- Page id: 11, Format: REDUNDANT, Records list: Invalid, Expected records: (0 33)
000000000582    5A0000016001EF  SYS_INDEXES     48      46      "GEN\_CLUST\_INDEX"     0       1       4294967295      4294967295
000000000B10    2E0000013403FC  SYS_INDEXES     52      48      "PRIMARY"       1       3       33      4294967295
-- Page id: 11, Found records: 2, Lost records: YES, Leaf page: YES

7:导入新的数据字典信息
注意这里需要是另外一个mysql 实例,因为为了避免数据文件被复写,我们此前已经将事故实例停止了服务。
1:创建数据字典表,该语句来自工具中的dictionary 目录

[root@localhost undrop-for-innodb-master]# cd dictionary/
[root@localhost dictionary]# ll
total 16
-rw-r--r--. 1 root root 1845 Oct  2  2015 SYS_COLUMNS.sql
-rw-r--r--. 1 root root 1685 Oct  2  2015 SYS_FIELDS.sql
-rw-r--r--. 1 root root 1876 Oct  2  2015 SYS_INDEXES.sql
-rw-r--r--. 1 root root 1895 Oct  2  2015 SYS_TABLES.sql

[root@localhost dictionary]# mysql -h10.13.13.25 -P3306 -uroot -pxxzx7817600
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.26-log Source distribution

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;
+------------------------+
| Database               |
+------------------------+
| information_schema     |
| employees              |
| mysql                  |
| #mysql50#mysql-keyring |
| performance_schema     |
| sys                    |
| test                   |
| undo                   |
+------------------------+
8 rows in set (0.01 sec)

mysql> create database dbrecover;
Query OK, 1 row affected (0.01 sec)

mysql> use dbrecover
Database changed

mysql> source /undrop-for-innodb-master/dictionary/SYS_TABLES.sql
Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.01 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected, 1 warning (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.01 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.01 sec)

Query OK, 0 rows affected, 1 warning (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

mysql> source /undrop-for-innodb-master/dictionary/SYS_INDEXES.sql
Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.01 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected, 1 warning (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.01 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected, 1 warning (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.01 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

mysql> source /undrop-for-innodb-master/dictionary/SYS_FIELDS.sql
Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.01 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected, 1 warning (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.01 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected, 1 warning (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

mysql> source /undrop-for-innodb-master/dictionary/SYS_COLUMNS.sql
Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected, 1 warning (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.01 sec)

Query OK, 0 rows affected (0.01 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected, 1 warning (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)


[root@localhost mysql]# mysqlshow -h10.13.13.25 -P3306 -uroot -pxxzx7817600 -vv dbrecover
mysqlshow: [Warning] Using a password on the command line interface can be insecure.
Database: dbrecover
+-------------+----------+------------+
|   Tables    | Columns  | Total Rows |
+-------------+----------+------------+
| sys_columns |        7 |          0 |
| sys_fields  |        3 |          0 |
| sys_indexes |        7 |          0 |
| sys_tables  |        8 |          0 |
+-------------+----------+------------+
4 rows in set.

2:导入前面dumps/default 目录生成的LOAD DATA 语句,用于恢复数据字典记录

mysql> source /undrop-for-innodb-master/dumps/default/SYS_TABLES.sql
Query OK, 0 rows affected (0.00 sec)

Query OK, 4 rows affected (0.04 sec)
Records: 4  Deleted: 0  Skipped: 0  Warnings: 0

mysql> source /undrop-for-innodb-master/dumps/default/SYS_COLUMNS.sql
Query OK, 0 rows affected (0.00 sec)

Query OK, 5 rows affected (0.01 sec)
Records: 5  Deleted: 0  Skipped: 0  Warnings: 0

mysql> source /undrop-for-innodb-master/dumps/default/SYS_INDEXES.sql
Query OK, 0 rows affected (0.00 sec)

Query OK, 2 rows affected (0.01 sec)
Records: 2  Deleted: 0  Skipped: 0  Warnings: 0

mysql> source /undrop-for-innodb-master/dumps/default/SYS_FIELDS.sql
Query OK, 0 rows affected (0.00 sec)

Query OK, 1 row affected (0.01 sec)
Records: 1  Deleted: 0  Skipped: 0  Warnings: 0

8:解析数据字典获取DDL 语句

[root@localhost undrop-for-innodb-master]# ./sys_parser -h10.13.13.25 -P3306 -uroot -pxxzx7817600 -d dbrcover test/articles
./sys_parser: error while loading shared libraries: libmysqlclient.so.20: cannot open shared object file: No such file or directory

[root@localhost lib]# ln -s /mysqlsoft/mysql/lib/libmysqlclient.so.20 /usr/lib64/libmysqlclient.so.20

[root@localhost undrop-for-innodb-master]# ./sys_parser -h10.13.13.25 -P3306 -uroot -pxxzx7817600 -d dbrecover test/articles
./sys_parser: invalid option -- 'P'
sys_parser [-h ] [-u ] [-p ] [-d ] databases/table
请注意:只能是3306 端口
[root@localhost undrop-for-innodb-master]# ./sys_parser -h10.13.13.25  -uroot -pxxzx7817600 -d dbrecover test/articles
CREATE TABLE `articles`(
        `id` INT NOT NULL,
        `title` VARCHAR(200) CHARACTER SET 'utf8mb4' COLLATE 'utf8mb4_general_ci',
        `body` TEXT,
        PRIMARY KEY (`id`)
) ENGINE=InnoDB;

9:查找drop 表数据对应的page 页
Mysql 是聚簇表,数据都在主键索引上,因此需要确认该primary key 对应的数据页。也有可能没有创建primary ke,数据库会自动隐藏主建。主建primary key 对应的页为56

[root@localhost dictionary]# mysql -h10.13.13.25 -P3306 -uroot -pxxzx7817600
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.26-log Source distribution

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> use dbrecover
Database changed

mysql> show tables;
+---------------------+
| Tables_in_dbrecover |
+---------------------+
| sys_columns         |
| sys_fields          |
| sys_indexes         |
| sys_tables          |
+---------------------+
4 rows in set (0.01 sec)

mysql> select * from SYS_TABLES;
+---------------+----+--------+------+--------+---------+--------------+-------+
| NAME          | ID | N_COLS | TYPE | MIX_ID | MIX_LEN | CLUSTER_NAME | SPACE |
+---------------+----+--------+------+--------+---------+--------------+-------+
| test/articles | 52 |      3 |   33 |      0 |      80 |              |    33 |
| test/t        | 36 |      1 |   33 |      0 |      80 |              |    22 |
+---------------+----+--------+------+--------+---------+--------------+-------+
2 rows in set (0.00 sec)

mysql> select * from SYS_INDEXES WHERE TABLE_ID=52;
+----------+----+---------+----------+------+-------+------------+
| TABLE_ID | ID | NAME    | N_FIELDS | TYPE | SPACE | PAGE_NO    |
+----------+----+---------+----------+------+-------+------------+
|       52 | 48 | PRIMARY |        1 |    3 |    33 | 4294967295 |
+----------+----+---------+----------+------+-------+------------+
1 row in set (0.00 sec)

10:解析磁盘页中删除表的记录
注意: 此处几个文件名程序把导出的两个数据文件的文件名关系是写死的, 以下dumps/default/articles 中的articles 是需要和表名一致,在articles_load.sql 中会引用此文件路经./tmp/articles.sql:恢复的表结构的语句

[root@localhost undrop-for-innodb-master]# vi /tmp/articles.sql
CREATE TABLE `articles`(
        `id` INT NOT NULL,
        `title` VARCHAR(200) CHARACTER SET 'utf8mb4' COLLATE 'utf8mb4_general_ci',
        `body` TEXT,
        PRIMARY KEY (`id`)
) ENGINE=InnoDB;


[root@localhost undrop-for-innodb-master]# ./c_parser -6f /undrop-for-innodb-master/pages-ol-root/FIL_PAGE_INDEX/0000000000000048.page -t /tmp/articles.sql>./dumps/default/articles 2>./dumps/default/articles_load.sql;
[root@localhost undrop-for-innodb-master]# ll dumps/default/
total 40
-rw-r--r--. 1 root root 437 Jan 20 00:16 articles
-rw-r--r--. 1 root root 239 Jan 20 00:16 articles_load.sql
-rw-r--r--. 1 root root 470 Jan 19 22:38 SYS_COLUMNS
-rw-r--r--. 1 root root 286 Jan 19 22:38 SYS_COLUMNS.sql
-rw-r--r--. 1 root root 200 Jan 19 22:38 SYS_FIELDS
-rw-r--r--. 1 root root 253 Jan 19 22:38 SYS_FIELDS.sql
-rw-r--r--. 1 root root 317 Jan 19 22:37 SYS_INDEXES
-rw-r--r--. 1 root root 291 Jan 19 22:37 SYS_INDEXES.sql
-rw-r--r--. 1 root root 580 Jan 19 22:34 SYS_TABLES
-rw-r--r--. 1 root root 300 Jan 19 22:34 SYS_TABLES.sql
[root@localhost undrop-for-innodb-master]# more ./dumps/default/articles
-- Page id: 3, Format: COMPACT, Records list: Valid, Expected records: (3 3)
000000000B0B    AB0000011E0110  articles        1       "1001 MySQL Tricks"     "1. Never run mysqld as root. 2. ... "
000000000B0B    AB0000011E011C  articles        2       "MySQL vs. YourSQL"     "In the following database comparison ..."
000000000B0B    AB0000011E0128  articles        3       "MySQL Security"        "When configured properly, MySQL ..."
-- Page id: 3, Found records: 3, Lost records: NO, Leaf page: YES
[root@localhost undrop-for-innodb-master]# more ./dumps/default/articles_load.sql
SET FOREIGN_KEY_CHECKS=0;
LOAD DATA LOCAL INFILE '/undrop-for-innodb-master/dumps/default/articles' REPLACE INTO TABLE `articles` FIELDS TERMINATED BY '\t' OPTIONALLY ENCLOSED BY '"' LINES STARTING BY 'articles\t' (`id`, `title`, `body`);

11:恢复表结构并导入数据

mysql> source /tmp/articles.sql
Query OK, 0 rows affected (0.01 sec)

mysql> source /undrop-for-innodb-master/dumps/default/articles_load.sql
Query OK, 0 rows affected (0.00 sec)

Query OK, 3 rows affected (0.01 sec)
Records: 3  Deleted: 0  Skipped: 0  Warnings: 0

mysql> select * from articles;
+----+-------------------+------------------------------------------+
| id | title             | body                                     |
+----+-------------------+------------------------------------------+
|  1 | 1001 MySQL Tricks | 1. Never run mysqld as root. 2. ...      |
|  2 | MySQL vs. YourSQL | In the following database comparison ... |
|  3 | MySQL Security    | When configured properly, MySQL ...      |
+----+-------------------+------------------------------------------+
3 rows in set (0.00 sec)

至此数据恢复了。

]]> http://www.jydba.net/index.php/archives/3546/feed 0 MySQL InnoDB监视器 http://www.jydba.net/index.php/archives/3543 http://www.jydba.net/index.php/archives/3543#respond Wed, 24 Jan 2024 07:58:49 +0000 http://www.jydba.net/?p=3543 InnoDB监视器
InnoDB监视器提供有关InnoDB内部状态的信息。此信息对性能调优很有用。

InnoDB监视器类型
InnoDB监视器有两种类型:
.标准的InnoDB Monitor显示以下类型的信息:
.主后台线程完成的工作
.线程的信号量等待
.关于最近的外键和死锁错误的数据
.锁等待事务
.由活动事务持有的表和记录锁
.待处理I/O操作及相关统计
.插入缓冲区和自适应哈希索引统计信息
.重做日志数据
.缓冲池统计信息
.行运算数据

.InnoDB锁监视器打印额外的锁信息作为标准InnoDB监视器输出的一部分。

启用InnoDB监视器
当InnoDB监控器为周期性输出启用时,InnoDB将输出写入mysqld服务器标准错误输出(stderr)。InnoDB将诊断输出发送到stderr,而不是stdout或固定大小的内存缓冲区,以避免潜在的缓冲区溢出。

在Windows上,stderr被定向到默认日志文件,除非另有配置。如果您希望将输出定向到控制台窗口而不是错误日志,请使用–console选项从控制台窗口的命令提示符启动服务器。

在Unix和类Unix系统上,stderr通常被定向到终端,除非另有配置。

当启用时,InnoDB监控大约每15秒打印一次数据。这些数据在性能调优中很有用。作为副作用,SHOW ENGINE INNODB STATUS的输出每15秒写入MySQL数据目录中的状态文件。文件名为innodb_status.pid,其中pid是服务器进程ID。InnoDB在服务器正常关闭时删除文件。如果发生了异常关机,则可能存在这些状态文件的实例,必须手动删除。在删除文件之前,检查它们是否包含有关异常关机原因的有用信息。一个innodb_status.pid只有启用了innodb-status-file配置选项,才会创建。默认关闭。

InnoDB监控器应该只在你真正想要查看监控器信息时才启用,因为输出的生成会导致一些性能下降。此外,如果监视器输出指向错误日志,如果您稍后忘记禁用监视器,则日志可能会变得相当大。

注意:
为了辅助故障诊断,在某些条件下,InnoDB临时启用了标准的InnoDB监视器输出。

InnoDB监视器输出以一个包含时间戳和监视器名称的报头开始。例如:

=====================================
2024-01-15 16:50:33 0x7f3e8c201700 INNODB MONITOR OUTPUT
=====================================

标准InnoDB监控器的首部(InnoDB监控器输出)也用于锁监控器,因为后者产生了相同的输出,但添加了额外的锁信息。

innodb_status_output和innodb_status_output_locks系统变量用于启用标准的InnoDB监视器和InnoDB锁监视器。

启用或禁用InnoDB监视器需要PROCESS特权。

启用标准InnoDB监视器
通过将innodb_status_output系统变量设置为ON来启用标准InnoDB监视器。

mysql> SET GLOBAL innodb_status_output=ON;
Query OK, 0 rows affected (0.00 sec)

mysql> show variables like '%innodb_status_output%';
+----------------------------+-------+
| Variable_name              | Value |
+----------------------------+-------+
| innodb_status_output       | ON    |
| innodb_status_output_locks | OFF   |
+----------------------------+-------+
2 rows in set (0.01 sec)

关闭标准的InnoDB Monitor,将innodb_status_output设置为OFF。

当您关闭服务器时,innodb_status_output变量被设置为默认的OFF值。

按需获取标准的InnoDB监控器输出
作为启用标准InnoDB监控器周期性输出的替代方案,您可以使用SHOW ENGINE INNODB STATUS SQL语句按需获取标准InnoDB监控器输出,该语句将输出获取到您的客户端程序。如果你使用的是mysql交互式客户端,将通常的分号语句结束符替换为\G,输出的可读性会更好:

mysql> SHOW ENGINE INNODB STATUS\G
*************************** 1. row ***************************
  Type: InnoDB
  Name:
Status:
=====================================
2024-01-15 16:50:33 0x7f3e8c201700 INNODB MONITOR OUTPUT
=====================================
Per second averages calculated from the last 8 seconds
-----------------
BACKGROUND THREAD
-----------------
srv_master_thread loops: 27 srv_active, 0 srv_shutdown, 427925 srv_idle
srv_master_thread log flush and writes: 427940
----------
SEMAPHORES
----------
OS WAIT ARRAY INFO: reservation count 15736
OS WAIT ARRAY INFO: signal count 1770
RW-shared spins 0, rounds 18523, OS waits 12422
RW-excl spins 0, rounds 32549, OS waits 1086
RW-sx spins 1768, rounds 50702, OS waits 1607
Spin rounds per wait: 18523.00 RW-shared, 32549.00 RW-excl, 28.68 RW-sx
------------
TRANSACTIONS
------------
Trx id counter 5697073
Purge done for trx's n:o < 5697071 undo n:o < 0 state: running but idle
History list length 70
LIST OF TRANSACTIONS FOR EACH SESSION:
---TRANSACTION 421390708152144, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
--------
FILE I/O
--------
I/O thread 0 state: waiting for i/o request (insert buffer thread)
I/O thread 1 state: waiting for i/o request (log thread)
I/O thread 2 state: waiting for i/o request (read thread)
I/O thread 3 state: waiting for i/o request (read thread)
I/O thread 4 state: waiting for i/o request (read thread)
I/O thread 5 state: waiting for i/o request (read thread)
I/O thread 6 state: waiting for i/o request (write thread)
I/O thread 7 state: waiting for i/o request (write thread)
I/O thread 8 state: waiting for i/o request (write thread)
I/O thread 9 state: waiting for i/o request (write thread)
Pending normal aio reads: [0, 0, 0, 0] , aio writes: [0, 0, 0, 0] ,
 ibuf aio reads:, log i/o's:, sync i/o's:
Pending flushes (fsync) log: 0; buffer pool: 0
141 OS file reads, 4062 OS file writes, 3289 OS fsyncs
0.00 reads/s, 0 avg bytes/read, 0.00 writes/s, 0.00 fsyncs/s
-------------------------------------
INSERT BUFFER AND ADAPTIVE HASH INDEX
-------------------------------------
Ibuf: size 1, free list len 1714, seg size 1716, 0 merges
merged operations:
 insert 0, delete mark 0, delete 0
discarded operations:
 insert 0, delete mark 0, delete 0
Hash table size 2365241, node heap has 0 buffer(s)
Hash table size 2365241, node heap has 0 buffer(s)
Hash table size 2365241, node heap has 0 buffer(s)
Hash table size 2365241, node heap has 0 buffer(s)
Hash table size 2365241, node heap has 0 buffer(s)
Hash table size 2365241, node heap has 0 buffer(s)
Hash table size 2365241, node heap has 0 buffer(s)
Hash table size 2365241, node heap has 0 buffer(s)
0.00 hash searches/s, 0.00 non-hash searches/s
---
LOG
---
Log sequence number 89430260246
Log flushed up to   89430260246
Pages flushed up to 89430260246
Last checkpoint at  89430260237
0 pending log flushes, 0 pending chkp writes
2662 log i/o's done, 0.00 log i/o's/second
----------------------
BUFFER POOL AND MEMORY
----------------------
Total large memory allocated 8795455488
Dictionary memory allocated 234968
Buffer pool size   524224
Free buffers       523545
Database pages     685
Old database pages 0
Modified db pages  0
Pending reads      0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 0, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 96, created 589, written 893
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
No buffer pool page gets since the last printout
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 685, unzip_LRU len: 0
I/O sum[0]:cur[0], unzip sum[0]:cur[0]
----------------------
INDIVIDUAL BUFFER POOL INFO
----------------------
---BUFFER POOL 0
Buffer pool size   65528
Free buffers       65456
Database pages     78
Old database pages 0
Modified db pages  0
Pending reads      0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 0, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 31, created 47, written 131
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
No buffer pool page gets since the last printout
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 78, unzip_LRU len: 0
I/O sum[0]:cur[0], unzip sum[0]:cur[0]
---BUFFER POOL 1
Buffer pool size   65528
Free buffers       65391
Database pages     137
Old database pages 0
Modified db pages  0
Pending reads      0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 0, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 11, created 126, written 367
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
No buffer pool page gets since the last printout
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 137, unzip_LRU len: 0
I/O sum[0]:cur[0], unzip sum[0]:cur[0]
---BUFFER POOL 2
Buffer pool size   65528
Free buffers       65413
Database pages     115
Old database pages 0
Modified db pages  0
Pending reads      0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 0, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 8, created 107, written 166
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
No buffer pool page gets since the last printout
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 115, unzip_LRU len: 0
I/O sum[0]:cur[0], unzip sum[0]:cur[0]
---BUFFER POOL 3
Buffer pool size   65528
Free buffers       65406
Database pages     122
Old database pages 0
Modified db pages  0
Pending reads      0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 0, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 13, created 109, written 182
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
No buffer pool page gets since the last printout
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 122, unzip_LRU len: 0
I/O sum[0]:cur[0], unzip sum[0]:cur[0]
---BUFFER POOL 4
Buffer pool size   65528
Free buffers       65463
Database pages     65
Old database pages 0
Modified db pages  0
Pending reads      0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 0, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 8, created 57, written 16
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
No buffer pool page gets since the last printout
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 65, unzip_LRU len: 0
I/O sum[0]:cur[0], unzip sum[0]:cur[0]
---BUFFER POOL 5
Buffer pool size   65528
Free buffers       65469
Database pages     59
Old database pages 0
Modified db pages  0
Pending reads      0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 0, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 9, created 50, written 11
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
No buffer pool page gets since the last printout
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 59, unzip_LRU len: 0
I/O sum[0]:cur[0], unzip sum[0]:cur[0]
---BUFFER POOL 6
Buffer pool size   65528
Free buffers       65470
Database pages     58
Old database pages 0
Modified db pages  0
Pending reads      0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 0, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 9, created 49, written 10
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
No buffer pool page gets since the last printout
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 58, unzip_LRU len: 0
I/O sum[0]:cur[0], unzip sum[0]:cur[0]
---BUFFER POOL 7
Buffer pool size   65528
Free buffers       65477
Database pages     51
Old database pages 0
Modified db pages  0
Pending reads      0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 0, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 7, created 44, written 10
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
No buffer pool page gets since the last printout
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 51, unzip_LRU len: 0
I/O sum[0]:cur[0], unzip sum[0]:cur[0]
--------------
ROW OPERATIONS
--------------
0 queries inside InnoDB, 0 queries in queue
0 read views open inside InnoDB
Process ID=10759, Main thread ID=139906706892544, state: sleeping
Number of rows inserted 5990, updated 0, deleted 0, read 1794460
0.00 inserts/s, 0.00 updates/s, 0.00 deletes/s, 0.00 reads/s
----------------------------
END OF INNODB MONITOR OUTPUT
============================

1 row in set (0.00 sec)

如果启用了InnoDB锁监视器, SHOW ENGINE INNODB STATUS输出还包括InnoDB锁监视器数据。

启用InnoDB锁监视器
InnoDB锁监控器数据与InnoDB标准监控器输出一起打印。InnoDB标准监控器和InnoDB锁监控器都必须启用,才能定期打印InnoDB锁监控器数据。

开启InnoDB锁监控,设置innodb_status_output_locks系统变量为ON。InnoDB标准监控器和InnoDB锁监控器都必须启用,以便定期打印InnoDB锁监控器数据:

mysql> SET GLOBAL innodb_status_output=ON;
Query OK, 0 rows affected (0.00 sec)

mysql> SET GLOBAL innodb_status_output_locks=ON;
Query OK, 0 rows affected (0.00 sec)

mysql> show variables like '%innodb_status_output%';
+----------------------------+-------+
| Variable_name              | Value |
+----------------------------+-------+
| innodb_status_output       | ON    |
| innodb_status_output_locks | ON    |
+----------------------------+-------+
2 rows in set (0.00 sec)

要禁用InnoDB锁监控,将innodb_status_output_locks设置为OFF。将innodb_status_output设置为OFF也禁用InnoDB标准监视器。

当你关闭服务器时,innodb_status_output和innodb_status_output_locks变量被设置为默认的OFF值。

注意:
为SHOW ENGINE INNODB STATUS输出启用InnoDB锁监视器,只需要启用innodb_status_output_locks。

InnoDB标准监视器和锁监视器输出
锁监视器与标准监视器相同,只是它包含了额外的锁信息。

为周期性输出启用任一监视器都会打开相同的输出流,但如果启用了Lock monitor,则该流将包含额外的信息。例如,如果您启用了标准监控和锁定监视器,它打开单个输出流。在禁用锁监视器之前,流包含额外的锁信息。

当使用SHOW ENGINE INNODB STATUS语句生成时,标准Monitor输出限制为1MB。此限制不适用于写入tserver标准错误输出(stderr)的输出。

标准监视器输出示例:

mysql> SHOW ENGINE INNODB STATUS\G
*************************** 1. row ***************************
  Type: InnoDB
  Name:
Status:
=====================================
2024-01-15 17:08:03 0x7f3e8c201700 INNODB MONITOR OUTPUT
=====================================
Per second averages calculated from the last 18 seconds
-----------------
BACKGROUND THREAD
-----------------
srv_master_thread loops: 27 srv_active, 0 srv_shutdown, 428975 srv_idle
srv_master_thread log flush and writes: 428990
----------
SEMAPHORES
----------
OS WAIT ARRAY INFO: reservation count 15736
OS WAIT ARRAY INFO: signal count 1770
RW-shared spins 0, rounds 18523, OS waits 12422
RW-excl spins 0, rounds 32549, OS waits 1086
RW-sx spins 1768, rounds 50702, OS waits 1607
Spin rounds per wait: 18523.00 RW-shared, 32549.00 RW-excl, 28.68 RW-sx
------------
TRANSACTIONS
------------
Trx id counter 5697073
Purge done for trx's n:o < 5697071 undo n:o < 0 state: running but idle
History list length 70
LIST OF TRANSACTIONS FOR EACH SESSION:
---TRANSACTION 421390708152144, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
--------
FILE I/O
--------
I/O thread 0 state: waiting for i/o request (insert buffer thread)
I/O thread 1 state: waiting for i/o request (log thread)
I/O thread 2 state: waiting for i/o request (read thread)
I/O thread 3 state: waiting for i/o request (read thread)
I/O thread 4 state: waiting for i/o request (read thread)
I/O thread 5 state: waiting for i/o request (read thread)
I/O thread 6 state: waiting for i/o request (write thread)
I/O thread 7 state: waiting for i/o request (write thread)
I/O thread 8 state: waiting for i/o request (write thread)
I/O thread 9 state: waiting for i/o request (write thread)
Pending normal aio reads: [0, 0, 0, 0] , aio writes: [0, 0, 0, 0] ,
 ibuf aio reads:, log i/o's:, sync i/o's:
Pending flushes (fsync) log: 0; buffer pool: 0
141 OS file reads, 4062 OS file writes, 3289 OS fsyncs
0.00 reads/s, 0 avg bytes/read, 0.00 writes/s, 0.00 fsyncs/s
-------------------------------------
INSERT BUFFER AND ADAPTIVE HASH INDEX
-------------------------------------
Ibuf: size 1, free list len 1714, seg size 1716, 0 merges
merged operations:
 insert 0, delete mark 0, delete 0
discarded operations:
 insert 0, delete mark 0, delete 0
Hash table size 2365241, node heap has 0 buffer(s)
Hash table size 2365241, node heap has 0 buffer(s)
Hash table size 2365241, node heap has 0 buffer(s)
Hash table size 2365241, node heap has 0 buffer(s)
Hash table size 2365241, node heap has 0 buffer(s)
Hash table size 2365241, node heap has 0 buffer(s)
Hash table size 2365241, node heap has 0 buffer(s)
Hash table size 2365241, node heap has 0 buffer(s)
0.00 hash searches/s, 0.00 non-hash searches/s
---
LOG
---
Log sequence number 89430260246
Log flushed up to   89430260246
Pages flushed up to 89430260246
Last checkpoint at  89430260237
0 pending log flushes, 0 pending chkp writes
2662 log i/o's done, 0.00 log i/o's/second
----------------------
BUFFER POOL AND MEMORY
----------------------
Total large memory allocated 8795455488
Dictionary memory allocated 234968
Buffer pool size   524224
Free buffers       523545
Database pages     685
Old database pages 0
Modified db pages  0
Pending reads      0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 0, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 96, created 589, written 893
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
No buffer pool page gets since the last printout
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 685, unzip_LRU len: 0
I/O sum[0]:cur[0], unzip sum[0]:cur[0]
----------------------
INDIVIDUAL BUFFER POOL INFO
----------------------
---BUFFER POOL 0
Buffer pool size   65528
Free buffers       65456
Database pages     78
Old database pages 0
Modified db pages  0
Pending reads      0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 0, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 31, created 47, written 131
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
No buffer pool page gets since the last printout
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 78, unzip_LRU len: 0
I/O sum[0]:cur[0], unzip sum[0]:cur[0]
---BUFFER POOL 1
Buffer pool size   65528
Free buffers       65391
Database pages     137
Old database pages 0
Modified db pages  0
Pending reads      0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 0, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 11, created 126, written 367
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
No buffer pool page gets since the last printout
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 137, unzip_LRU len: 0
I/O sum[0]:cur[0], unzip sum[0]:cur[0]
---BUFFER POOL 2
Buffer pool size   65528
Free buffers       65413
Database pages     115
Old database pages 0
Modified db pages  0
Pending reads      0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 0, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 8, created 107, written 166
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
No buffer pool page gets since the last printout
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 115, unzip_LRU len: 0
I/O sum[0]:cur[0], unzip sum[0]:cur[0]
---BUFFER POOL 3
Buffer pool size   65528
Free buffers       65406
Database pages     122
Old database pages 0
Modified db pages  0
Pending reads      0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 0, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 13, created 109, written 182
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
No buffer pool page gets since the last printout
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 122, unzip_LRU len: 0
I/O sum[0]:cur[0], unzip sum[0]:cur[0]
---BUFFER POOL 4
Buffer pool size   65528
Free buffers       65463
Database pages     65
Old database pages 0
Modified db pages  0
Pending reads      0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 0, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 8, created 57, written 16
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
No buffer pool page gets since the last printout
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 65, unzip_LRU len: 0
I/O sum[0]:cur[0], unzip sum[0]:cur[0]
---BUFFER POOL 5
Buffer pool size   65528
Free buffers       65469
Database pages     59
Old database pages 0
Modified db pages  0
Pending reads      0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 0, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 9, created 50, written 11
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
No buffer pool page gets since the last printout
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 59, unzip_LRU len: 0
I/O sum[0]:cur[0], unzip sum[0]:cur[0]
---BUFFER POOL 6
Buffer pool size   65528
Free buffers       65470
Database pages     58
Old database pages 0
Modified db pages  0
Pending reads      0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 0, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 9, created 49, written 10
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
No buffer pool page gets since the last printout
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 58, unzip_LRU len: 0
I/O sum[0]:cur[0], unzip sum[0]:cur[0]
---BUFFER POOL 7
Buffer pool size   65528
Free buffers       65477
Database pages     51
Old database pages 0
Modified db pages  0
Pending reads      0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 0, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 7, created 44, written 10
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
No buffer pool page gets since the last printout
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 51, unzip_LRU len: 0
I/O sum[0]:cur[0], unzip sum[0]:cur[0]
--------------
ROW OPERATIONS
--------------
0 queries inside InnoDB, 0 queries in queue
0 read views open inside InnoDB
Process ID=10759, Main thread ID=139906706892544, state: sleeping
Number of rows inserted 5990, updated 0, deleted 0, read 1794460
0.00 inserts/s, 0.00 updates/s, 0.00 deletes/s, 0.00 reads/s
----------------------------
END OF INNODB MONITOR OUTPUT
============================

1 row in set (0.00 sec)

标准监视器输出部分
.Status(状态)
本节显示时间戳、监视器名称和每秒平均值所基于的秒数。秒数是当前时间和最后一次打印InnoDB Monitor输出之间经过的时间。

.BACKGROUND THREAD(后台线程)
srv_master_thread行显示了主后台线程完成的工作。

.SEMAPHORES(信号量)
这部分是报告等待信号量的线程,以及线程需要旋转或等待互斥量或rw-lock信号量的统计数据。大量线程等待信号量可能是磁盘I/O的结果,或者是InnoDB内部的争用问题。竞争可能是由于大量的并行查询或操作系统线程调度问题造成的。在这种情况下,将innodb_thread_concurrency系统变量设置为小于默认值可能会有所帮助。Spin rounds per wait line显示了每个操作系统等待互斥量的旋转轮数。

互斥参数由SHOW ENGINE INNODB MUTEX报告。

mysql> SHOW ENGINE INNODB MUTEX\G
*************************** 1. row ***************************
  Type: InnoDB
  Name: rwlock: dict0dict.cc:2737
Status: waits=35
*************************** 2. row ***************************
  Type: InnoDB
  Name: rwlock: dict0dict.cc:1183
Status: waits=77
*************************** 3. row ***************************
  Type: InnoDB
  Name: rwlock: log0log.cc:838
Status: waits=32
*************************** 4. row ***************************
  Type: InnoDB
  Name: sum rwlock: buf0buf.cc:1460
Status: waits=13399
4 rows in set (0.04 sec)

.LATEST FOREIGN KEY ERROR(最新的外键错误)
本节提供有关最近的外键约束错误的信息。如果没有发生此类错误,则不存在该错误。内容包括失败的语句以及有关失败的约束以及被引用表和引用表的信息。

.LATEST DETECTED DEADLOCK(最近检测到的死锁)
本节提供有关最近死锁的信息。如果没有发生死锁,则不存在。内容显示了涉及到哪些事务,每个试图执行的语句,它们拥有和需要的锁,以及InnoDB决定回滚哪个事务以打破死锁。

.TRANSACTIONS(事务)
如果本节报告锁等待,则您的应用程序可能存在锁争用。输出还可以帮助跟踪事务死锁的原因。

.FILE I/O(文件IO)
本节提供了InnoDB用于执行各种类型I/O的线程的信息。前几个是专用于一般InnoDB处理的。内容还显示挂起的I/O操作信息和I/O性能统计信息。

这些线程的数量由innodb_read_io_threads和innodb_write_io_threads参数控制。

.INSERT BUFFER AND ADAPTIVE HASH INDEX
本节展示了InnoDB插入缓冲区(也称为更改缓冲区)和自适应哈希索引的状态。

.LOG
介绍InnoDB日志的相关信息。内容包括当前日志序列号,日志被刷新到磁盘的距离,以及InnoDB最后一次执行检查点的位置。该部分还显示有关挂起写和写性能统计信息的信息。

.BUFFER POOL AND MEMORY
本节提供了读取和写入页面的统计信息。您可以从这些数字中计算出查询当前正在执行多少数据文件I/O操作

.ROW OPERATIONS
本节显示主线程正在执行的操作,包括每种类型的行操作的数量和性能比率。

]]>
http://www.jydba.net/index.php/archives/3543/feed 0
MySQL InnoDB集成MySQL性能模式 http://www.jydba.net/index.php/archives/3540 http://www.jydba.net/index.php/archives/3540#respond Sat, 20 Jan 2024 07:52:21 +0000 http://www.jydba.net/?p=3540 InnoDB集成MySQL性能模式

你可以使用MySQL Performance Schema特性来分析某些内部InnoDB操作。这种类型的调优主要针对那些评估优化策略以克服性能瓶颈的专家用户。dba还可以使用此功能进行容量规划,以查看他们的典型工作负载在特定的CPU、RAM和磁盘存储组合上是否遇到任何性能瓶颈;如果是,则判断是否可以通过增加系统某些部分的容量来提高性能。

使用这个特性来检查InnoDB的性能:
.您必须熟悉如何使用Performance Schema特性。例如,您应该知道如何启用仪器和消费者,以及如何查询performance_schema表以检索数据。

.您应该熟悉用于InnoDB的性能模式工具。要查看与innodb相关的仪器,可以查询setup_instruments表中包含’innodb’的仪器名称。

mysql> use performance_schema
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> SELECT * FROM setup_instruments WHERE NAME LIKE '%innodb%';
+-------------------------------------------------------+---------+-------+
| NAME                                                  | ENABLED | TIMED |
+-------------------------------------------------------+---------+-------+
| wait/synch/mutex/innodb/commit_cond_mutex             | NO      | NO    |
| wait/synch/mutex/innodb/innobase_share_mutex          | NO      | NO    |
| wait/synch/mutex/innodb/autoinc_mutex                 | NO      | NO    |
..........
| memory/innodb/adaptive hash index                     | NO      | NO    |
| memory/innodb/buf_buf_pool                            | NO      | NO    |
| memory/innodb/dict_stats_bg_recalc_pool_t             | NO      | NO    |
| memory/innodb/dict_stats_index_map_t                  | NO      | NO    |
| memory/innodb/dict_stats_n_diff_on_level              | NO      | NO    |
| memory/innodb/other                                   | NO      | NO    |
| memory/innodb/row_log_buf                             | NO      | NO    |
| memory/innodb/row_merge_sort                          | NO      | NO    |
| memory/innodb/std                                     | NO      | NO    |
| memory/innodb/trx_sys_t::rw_trx_ids                   | NO      | NO    |
| memory/innodb/partitioning                            | NO      | NO    |
| memory/innodb/api0api                                 | NO      | NO    |
| memory/innodb/btr0btr                                 | NO      | NO    |
| memory/innodb/btr0bulk                                | NO      | NO    |
| memory/innodb/btr0cur                                 | NO      | NO    |
| memory/innodb/btr0pcur                                | NO      | NO    |
| memory/innodb/btr0sea                                 | NO      | NO    |
| memory/innodb/buf0buf                                 | NO      | NO    |
| memory/innodb/buf0dblwr                               | NO      | NO    |
| memory/innodb/buf0dump                                | NO      | NO    |
| memory/innodb/buf0flu                                 | NO      | NO    |
| memory/innodb/buf0lru                                 | NO      | NO    |
| memory/innodb/dict0dict                               | NO      | NO    |
| memory/innodb/dict0mem                                | NO      | NO    |
| memory/innodb/dict0stats                              | NO      | NO    |
| memory/innodb/dict0stats_bg                           | NO      | NO    |
| memory/innodb/eval0eval                               | NO      | NO    |
| memory/innodb/fil0fil                                 | NO      | NO    |
| memory/innodb/fsp0file                                | NO      | NO    |
| memory/innodb/fsp0space                               | NO      | NO    |
| memory/innodb/fsp0sysspace                            | NO      | NO    |
| memory/innodb/fts0ast                                 | NO      | NO    |
| memory/innodb/fts0config                              | NO      | NO    |
| memory/innodb/fts0fts                                 | NO      | NO    |
| memory/innodb/fts0opt                                 | NO      | NO    |
| memory/innodb/fts0pars                                | NO      | NO    |
| memory/innodb/fts0que                                 | NO      | NO    |
| memory/innodb/fts0sql                                 | NO      | NO    |
| memory/innodb/gis0sea                                 | NO      | NO    |
| memory/innodb/ha0ha                                   | NO      | NO    |
| memory/innodb/ha_innodb                               | NO      | NO    |
| memory/innodb/handler0alter                           | NO      | NO    |
| memory/innodb/hash0hash                               | NO      | NO    |
| memory/innodb/i_s                                     | NO      | NO    |
| memory/innodb/ibuf0ibuf                               | NO      | NO    |
| memory/innodb/lexyy                                   | NO      | NO    |
| memory/innodb/lock0lock                               | NO      | NO    |
| memory/innodb/log0log                                 | NO      | NO    |
| memory/innodb/log0recv                                | NO      | NO    |
| memory/innodb/mem0mem                                 | NO      | NO    |
| memory/innodb/os0event                                | NO      | NO    |
| memory/innodb/os0file                                 | NO      | NO    |
| memory/innodb/page0cur                                | NO      | NO    |
| memory/innodb/page0zip                                | NO      | NO    |
| memory/innodb/pars0lex                                | NO      | NO    |
| memory/innodb/read0read                               | NO      | NO    |
| memory/innodb/rem0rec                                 | NO      | NO    |
| memory/innodb/row0ftsort                              | NO      | NO    |
| memory/innodb/row0import                              | NO      | NO    |
| memory/innodb/row0log                                 | NO      | NO    |
| memory/innodb/row0merge                               | NO      | NO    |
| memory/innodb/row0mysql                               | NO      | NO    |
| memory/innodb/row0sel                                 | NO      | NO    |
| memory/innodb/row0trunc                               | NO      | NO    |
| memory/innodb/srv0conc                                | NO      | NO    |
| memory/innodb/srv0srv                                 | NO      | NO    |
| memory/innodb/srv0start                               | NO      | NO    |
| memory/innodb/sync0arr                                | NO      | NO    |
| memory/innodb/sync0debug                              | NO      | NO    |
| memory/innodb/sync0rw                                 | NO      | NO    |
| memory/innodb/sync0types                              | NO      | NO    |
| memory/innodb/trx0i_s                                 | NO      | NO    |
| memory/innodb/trx0purge                               | NO      | NO    |
| memory/innodb/trx0roll                                | NO      | NO    |
| memory/innodb/trx0rseg                                | NO      | NO    |
| memory/innodb/trx0sys                                 | NO      | NO    |
| memory/innodb/trx0trx                                 | NO      | NO    |
| memory/innodb/trx0undo                                | NO      | NO    |
| memory/innodb/usr0sess                                | NO      | NO    |
| memory/innodb/ut0list                                 | NO      | NO    |
| memory/innodb/ut0mem                                  | NO      | NO    |
| memory/innodb/ut0mutex                                | NO      | NO    |
| memory/innodb/ut0pool                                 | NO      | NO    |
| memory/innodb/ut0rbt                                  | NO      | NO    |
| memory/innodb/ut0wqueue                               | NO      | NO    |
+-------------------------------------------------------+---------+-------+
167 rows in set (0.00 sec)

关于已仪表化的InnoDB对象的附加信息,您可以查询Performance Schema实例表,它提供了关于已仪表化对象的附加信息。与InnoDB相关的实例表
包括:
.mutex_instances表
.rwlock_instances表
.cond_instances表
.file_instances表

注意:
与InnoDB缓冲池相关的互斥量和读写锁不在本章的讨论范围内;SHOW ENGINE INNODB MUTEX命令的输出结果也是如此。

例如,在执行文件I/O仪表化时,要查看Performance Schema所看到的已仪表化的InnoDB文件对象的信息,您可以发出以下查询:

mysql> SELECT * FROM file_instances WHERE EVENT_NAME LIKE '%innodb%'\G
*************************** 1. row ***************************
 FILE_NAME: /mysqldata/mysql/ibdata1
EVENT_NAME: wait/io/file/innodb/innodb_data_file
OPEN_COUNT: 3
*************************** 2. row ***************************
 FILE_NAME: /mysqldata/mysql/ib_logfile0
EVENT_NAME: wait/io/file/innodb/innodb_log_file
OPEN_COUNT: 2
*************************** 3. row ***************************
 FILE_NAME: /mysqldata/mysql/ib_logfile1
EVENT_NAME: wait/io/file/innodb/innodb_log_file
OPEN_COUNT: 2
......

你应该要熟悉存储InnoDB事件数据的performance_schema表。与innodb相关事件相关的表包括:
.等待事件表,存储等待事件。

.汇总表,提供随时间推移终止的事件的聚合信息。汇总表包括文件I/O汇总表,它聚合了关于I/O操作的信息。

.阶段事件表,存储InnoDB ALTER TABLE和缓冲池load操作事件数据。

使用性能模式监控InnoDB表的ALTER TABLE进度

你可以使用Performance Schema监控InnoDB表的ALTER TABLE进度。

有7个阶段事件表示ALTER TABLE的不同阶段。每个阶段事件报告整个ALTER TABLE操作在其不同阶段进行时的WORK_COMPLETED和WORK_ESTIMATED运行总数。WORK_ESTIMATEDe使用一个公式计算,该公式考虑了ALTER TABLE执行的所有工作,并且可能在ALTER TABLE处理期间进行修改。WORK_COMPLETED和WORK_ESTIMATED值是ALTER TABLE执行的所有工作的抽象表示。

按照发生的顺序,ALTER TABLE阶段的事件包括:
.stage/innodb/alter table (read PK and internal sort):当ALTER TABLE处于read -primary-key阶段时,这个阶段是活动的。它一开始将设置WORK_COMPLETED=0和WORK_ESTIMATED设置为主键中估计的页面数。当这个阶段完成时,WORK_ESTIMATED被更新为主键中的实际页面数。

.stage/innodb/alter table (merge sort):对于通过ALTER TABLE操作添加的每个索引,重复此阶段。

.stage/innodb/alter table (insert):对于通过ALTER TABLE操作添加的每个索引,重复此阶段。

.stage/innodb/alter table (log apply index):这个阶段包括应用运行ALTER TABLE时生成的DML日志。

.stage/innodb/alter table (flush):在此阶段开始之前,根据刷新列表的长度,使用更准确的估计值更新WORK_ESTIMATED。

.stage/innodb/alter table (log apply table):此阶段包括应用在ALTER TABLE运行时生成的并发DML日志。这个阶段的持续时间取决于表变化的程度。如果在表上没有运行并发的DML,则此阶段会瞬间完成。

.stage/innodb/alter table (end):包括在刷新阶段之后出现的任何剩余工作,例如当运行ALTER TABLE时重新应用在表上执行的DML。

注意:
InnoDB ALTER TABLE阶段事件目前不会对添加的空间索引进行计数。

使用Performance Schema(性能模式)监控ALTER TABLE操作

下面的例子演示了如何启用stage/innodb/alter table% stage事件仪器和相关的消费者表来监控alter table的进度。
1.启用stage/innodb/alter%仪器:

mysql> UPDATE setup_instruments SET ENABLED = 'YES' WHERE NAME LIKE 'stage/innodb/alter%';
Query OK, 7 rows affected (0.00 sec)
Rows matched: 7  Changed: 7  Warnings: 0

2.启用阶段事件消费者表,其中包括events_stages_current、events_stages_history和events_stages_history_long。

mysql> UPDATE setup_consumers SET ENABLED = 'YES' WHERE NAME LIKE '%stages%';
Query OK, 3 rows affected (0.00 sec)
Rows matched: 3  Changed: 3  Warnings: 0

3.执行ALTER TABLE操作。在本例中,将middle_name列添加到employees示例数据库的employees表中。

mysql> ALTER TABLE employees.employees ADD COLUMN middle_name varchar(14) AFTER first_name;
Query OK, 0 rows affected (1.80 sec)
Records: 0  Duplicates: 0  Warnings: 0

4.通过查询Performance Schema的events_stages_current表来检查ALTER TABLE操作的进度。所显示的阶段事件取决于当前正在进行的ALTER TABLE阶段。WORK_COMPLETED列显示完成的工作,WORK_ESTIMATED列提供了对剩余工作的估计。

mysql> use performance_schema
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> SELECT EVENT_NAME, WORK_COMPLETED, WORK_ESTIMATED FROM events_stages_current;
Empty set (0.00 sec)

mysql> SELECT EVENT_NAME, WORK_COMPLETED, WORK_ESTIMATED FROM events_stages_current;
+----------------------------------+----------------+----------------+
| EVENT_NAME                       | WORK_COMPLETED | WORK_ESTIMATED |
+----------------------------------+----------------+----------------+
| stage/innodb/alter table (flush) |            938 |           1793 |
+----------------------------------+----------------+----------------+
1 row in set (0.00 sec)

如果ALTER TABLE操作已经完成,events_stages_current表返回一个空集合。在这种情况下,您可以检查events_stages_history表来查看已完成操作的事件数据。例如:

mysql> SELECT EVENT_NAME, WORK_COMPLETED, WORK_ESTIMATED FROM events_stages_history;
+------------------------------------------------------+----------------+----------------+
| EVENT_NAME                                           | WORK_COMPLETED | WORK_ESTIMATED |
+------------------------------------------------------+----------------+----------------+
| stage/innodb/alter table (read PK and internal sort) |            886 |           1793 |
| stage/innodb/alter table (flush)                     |           1793 |           1793 |
| stage/innodb/alter table (log apply table)           |           2177 |           2177 |
| stage/innodb/alter table (end)                       |           2177 |           2177 |
| stage/innodb/alter table (log apply table)           |           2561 |           2561 |
+------------------------------------------------------+----------------+----------------+
5 rows in set (0.00 sec)

如上所示,在ALTER TABLE处理期间修改了WORK_ESTIMATED的值。初始阶段完成后的预计工作量为1793。当ALTER TABLE处理完成时,WORK_ESTIMATED被设置为实际值,即2561。

使用Performance Schema(性能模式)监控InnoDB互斥锁等待
互斥锁是代码中使用的一种同步机制,用于强制在给定时间内只有一个线程可以访问公共资源。当服务器上执行的两个或多个线程需要访问相同的资源时,线程之间会相互竞争。第一个获得互斥锁的线程会导致其他线程等待,直到锁被释放。

对于仪表化的InnoDB互斥锁,可以使用Performance Schema来监控互斥锁的等待。
例如,在Performance Schema表中收集的等待事件数据可以帮助识别等待时间最长或总等待时间最长的互斥锁。

下面的例子演示了如何启用InnoDB互斥锁等待工具,如何启用关联的消费者,以及如何查询等待事件数据。
1.要查看可用的InnoDB互斥锁等待工具,请查询Performance Schema setup_instruments表,如下所示。所有InnoDB互斥锁等待工具默认是禁用的。

mysql> SELECT * FROM performance_schema.setup_instruments WHERE NAME LIKE '%wait/synch/mutex/innodb%';
+-------------------------------------------------------+---------+-------+
| NAME                                                  | ENABLED | TIMED |
+-------------------------------------------------------+---------+-------+
| wait/synch/mutex/innodb/commit_cond_mutex             | NO      | NO    |
| wait/synch/mutex/innodb/innobase_share_mutex          | NO      | NO    |
| wait/synch/mutex/innodb/autoinc_mutex                 | NO      | NO    |
| wait/synch/mutex/innodb/buf_pool_mutex                | NO      | NO    |
| wait/synch/mutex/innodb/buf_pool_zip_mutex            | NO      | NO    |
| wait/synch/mutex/innodb/cache_last_read_mutex         | NO      | NO    |
| wait/synch/mutex/innodb/dict_foreign_err_mutex        | NO      | NO    |
| wait/synch/mutex/innodb/dict_sys_mutex                | NO      | NO    |
| wait/synch/mutex/innodb/recalc_pool_mutex             | NO      | NO    |
| wait/synch/mutex/innodb/file_format_max_mutex         | NO      | NO    |
| wait/synch/mutex/innodb/fil_system_mutex              | NO      | NO    |
| wait/synch/mutex/innodb/flush_list_mutex              | NO      | NO    |
| wait/synch/mutex/innodb/fts_bg_threads_mutex          | NO      | NO    |
| wait/synch/mutex/innodb/fts_delete_mutex              | NO      | NO    |
| wait/synch/mutex/innodb/fts_optimize_mutex            | NO      | NO    |
| wait/synch/mutex/innodb/fts_doc_id_mutex              | NO      | NO    |
| wait/synch/mutex/innodb/fts_pll_tokenize_mutex        | NO      | NO    |
| wait/synch/mutex/innodb/log_flush_order_mutex         | NO      | NO    |
| wait/synch/mutex/innodb/hash_table_mutex              | NO      | NO    |
| wait/synch/mutex/innodb/ibuf_bitmap_mutex             | NO      | NO    |
| wait/synch/mutex/innodb/ibuf_mutex                    | NO      | NO    |
| wait/synch/mutex/innodb/ibuf_pessimistic_insert_mutex | NO      | NO    |
| wait/synch/mutex/innodb/log_sys_mutex                 | NO      | NO    |
| wait/synch/mutex/innodb/log_sys_write_mutex           | NO      | NO    |
| wait/synch/mutex/innodb/log_cmdq_mutex                | NO      | NO    |
| wait/synch/mutex/innodb/mutex_list_mutex              | NO      | NO    |
| wait/synch/mutex/innodb/page_cleaner_mutex            | NO      | NO    |
| wait/synch/mutex/innodb/page_zip_stat_per_index_mutex | NO      | NO    |
| wait/synch/mutex/innodb/purge_sys_pq_mutex            | NO      | NO    |
| wait/synch/mutex/innodb/recv_sys_mutex                | NO      | NO    |
| wait/synch/mutex/innodb/recv_writer_mutex             | NO      | NO    |
| wait/synch/mutex/innodb/redo_rseg_mutex               | NO      | NO    |
| wait/synch/mutex/innodb/noredo_rseg_mutex             | NO      | NO    |
| wait/synch/mutex/innodb/rw_lock_list_mutex            | NO      | NO    |
| wait/synch/mutex/innodb/rw_lock_mutex                 | NO      | NO    |
| wait/synch/mutex/innodb/srv_dict_tmpfile_mutex        | NO      | NO    |
| wait/synch/mutex/innodb/srv_innodb_monitor_mutex      | NO      | NO    |
| wait/synch/mutex/innodb/srv_misc_tmpfile_mutex        | NO      | NO    |
| wait/synch/mutex/innodb/srv_monitor_file_mutex        | NO      | NO    |
| wait/synch/mutex/innodb/buf_dblwr_mutex               | NO      | NO    |
| wait/synch/mutex/innodb/trx_undo_mutex                | NO      | NO    |
| wait/synch/mutex/innodb/trx_pool_mutex                | NO      | NO    |
| wait/synch/mutex/innodb/trx_pool_manager_mutex        | NO      | NO    |
| wait/synch/mutex/innodb/srv_sys_mutex                 | NO      | NO    |
| wait/synch/mutex/innodb/lock_mutex                    | NO      | NO    |
| wait/synch/mutex/innodb/lock_wait_mutex               | NO      | NO    |
| wait/synch/mutex/innodb/trx_mutex                     | NO      | NO    |
| wait/synch/mutex/innodb/srv_threads_mutex             | NO      | NO    |
| wait/synch/mutex/innodb/rtr_active_mutex              | NO      | NO    |
| wait/synch/mutex/innodb/rtr_match_mutex               | NO      | NO    |
| wait/synch/mutex/innodb/rtr_path_mutex                | NO      | NO    |
| wait/synch/mutex/innodb/rtr_ssn_mutex                 | NO      | NO    |
| wait/synch/mutex/innodb/trx_sys_mutex                 | NO      | NO    |
| wait/synch/mutex/innodb/thread_mutex                  | NO      | NO    |
| wait/synch/mutex/innodb/sync_array_mutex              | NO      | NO    |
| wait/synch/mutex/innodb/zip_pad_mutex                 | NO      | NO    |
| wait/synch/mutex/innodb/row_drop_list_mutex           | NO      | NO    |
| wait/synch/mutex/innodb/master_key_id_mutex           | NO      | NO    |
+-------------------------------------------------------+---------+-------+
58 rows in set (0.00 sec)

2.一些InnoDB互斥锁实例是在服务器启动时创建的,并且只有在服务器启动时启用了相关的工具时才会被检测。为了确保所有InnoDB互斥锁实例都被仪表化和启用,请将以下性能模式仪表规则添加到您的MySQL配置文件:

performance-schema-instrument='wait/synch/mutex/innodb%=ON'

如果您不需要某等待事件的所有InnoDB互斥锁数据,您可以通过在MySQL配置文件中添加额外的性能模式仪表规则来禁用特定的仪表。例如,要禁用与全文搜索相关的InnoDB互斥锁等待事件工具,请添加以下规则:

performance-schema-instrument='wait/synch/mutex/innodb/fts%=OFF'

注意:
前缀较长的规则(如wait/sync /mutex/innodb/fts%)优先于前缀较短的规则(如wait/sync /mutex/innodb/ %)。

将performance-schema-instrument规则添加到配置文件后,重新启动服务器。除了那些与全文搜索相关的其它所有的InnoDB互斥锁都是启用的。要验证这一点,请查询setup_instruments表。对于您启用的仪器,ENABLED和TIMED列应该设置为YES。

[root@localhost mysql]# service mysqld restart
Shutting down MySQL.... SUCCESS!
Starting MySQL... SUCCESS!

mysql> SELECT * FROM performance_schema.setup_instruments WHERE NAME LIKE '%wait/synch/mutex/innodb%';
+-------------------------------------------------------+---------+-------+
| NAME                                                  | ENABLED | TIMED |
+-------------------------------------------------------+---------+-------+
| wait/synch/mutex/innodb/commit_cond_mutex             | YES     | YES   |
| wait/synch/mutex/innodb/innobase_share_mutex          | YES     | YES   |
| wait/synch/mutex/innodb/autoinc_mutex                 | YES     | YES   |
| wait/synch/mutex/innodb/buf_pool_mutex                | YES     | YES   |
| wait/synch/mutex/innodb/buf_pool_zip_mutex            | YES     | YES   |
| wait/synch/mutex/innodb/cache_last_read_mutex         | YES     | YES   |
| wait/synch/mutex/innodb/dict_foreign_err_mutex        | YES     | YES   |
| wait/synch/mutex/innodb/dict_sys_mutex                | YES     | YES   |
| wait/synch/mutex/innodb/recalc_pool_mutex             | YES     | YES   |
| wait/synch/mutex/innodb/file_format_max_mutex         | YES     | YES   |
| wait/synch/mutex/innodb/fil_system_mutex              | YES     | YES   |
| wait/synch/mutex/innodb/flush_list_mutex              | YES     | YES   |
| wait/synch/mutex/innodb/fts_bg_threads_mutex          | NO      | NO    |
| wait/synch/mutex/innodb/fts_delete_mutex              | NO      | NO    |
| wait/synch/mutex/innodb/fts_optimize_mutex            | NO      | NO    |
| wait/synch/mutex/innodb/fts_doc_id_mutex              | NO      | NO    |
| wait/synch/mutex/innodb/fts_pll_tokenize_mutex        | NO      | NO    |
| wait/synch/mutex/innodb/log_flush_order_mutex         | YES     | YES   |
| wait/synch/mutex/innodb/hash_table_mutex              | YES     | YES   |
| wait/synch/mutex/innodb/ibuf_bitmap_mutex             | YES     | YES   |
| wait/synch/mutex/innodb/ibuf_mutex                    | YES     | YES   |
| wait/synch/mutex/innodb/ibuf_pessimistic_insert_mutex | YES     | YES   |
| wait/synch/mutex/innodb/log_sys_mutex                 | YES     | YES   |
| wait/synch/mutex/innodb/log_sys_write_mutex           | YES     | YES   |
| wait/synch/mutex/innodb/log_cmdq_mutex                | YES     | YES   |
| wait/synch/mutex/innodb/mutex_list_mutex              | YES     | YES   |
| wait/synch/mutex/innodb/page_cleaner_mutex            | YES     | YES   |
| wait/synch/mutex/innodb/page_zip_stat_per_index_mutex | YES     | YES   |
| wait/synch/mutex/innodb/purge_sys_pq_mutex            | YES     | YES   |
| wait/synch/mutex/innodb/recv_sys_mutex                | YES     | YES   |
| wait/synch/mutex/innodb/recv_writer_mutex             | YES     | YES   |
| wait/synch/mutex/innodb/redo_rseg_mutex               | YES     | YES   |
| wait/synch/mutex/innodb/noredo_rseg_mutex             | YES     | YES   |
| wait/synch/mutex/innodb/rw_lock_list_mutex            | YES     | YES   |
| wait/synch/mutex/innodb/rw_lock_mutex                 | YES     | YES   |
| wait/synch/mutex/innodb/srv_dict_tmpfile_mutex        | YES     | YES   |
| wait/synch/mutex/innodb/srv_innodb_monitor_mutex      | YES     | YES   |
| wait/synch/mutex/innodb/srv_misc_tmpfile_mutex        | YES     | YES   |
| wait/synch/mutex/innodb/srv_monitor_file_mutex        | YES     | YES   |
| wait/synch/mutex/innodb/buf_dblwr_mutex               | YES     | YES   |
| wait/synch/mutex/innodb/trx_undo_mutex                | YES     | YES   |
| wait/synch/mutex/innodb/trx_pool_mutex                | YES     | YES   |
| wait/synch/mutex/innodb/trx_pool_manager_mutex        | YES     | YES   |
| wait/synch/mutex/innodb/srv_sys_mutex                 | YES     | YES   |
| wait/synch/mutex/innodb/lock_mutex                    | YES     | YES   |
| wait/synch/mutex/innodb/lock_wait_mutex               | YES     | YES   |
| wait/synch/mutex/innodb/trx_mutex                     | YES     | YES   |
| wait/synch/mutex/innodb/srv_threads_mutex             | YES     | YES   |
| wait/synch/mutex/innodb/rtr_active_mutex              | YES     | YES   |
| wait/synch/mutex/innodb/rtr_match_mutex               | YES     | YES   |
| wait/synch/mutex/innodb/rtr_path_mutex                | YES     | YES   |
| wait/synch/mutex/innodb/rtr_ssn_mutex                 | YES     | YES   |
| wait/synch/mutex/innodb/trx_sys_mutex                 | YES     | YES   |
| wait/synch/mutex/innodb/thread_mutex                  | YES     | YES   |
| wait/synch/mutex/innodb/sync_array_mutex              | YES     | YES   |
| wait/synch/mutex/innodb/zip_pad_mutex                 | YES     | YES   |
| wait/synch/mutex/innodb/row_drop_list_mutex           | YES     | YES   |
| wait/synch/mutex/innodb/master_key_id_mutex           | YES     | YES   |
+-------------------------------------------------------+---------+-------+
58 rows in set (0.00 sec)

3.通过更新setup_consumers表来启用等待事件消费者。默认情况下,等待事件消费者是禁用的

mysql> UPDATE performance_schema.setup_consumers SET enabled = 'YES' WHERE name like 'events_waits%';
Query OK, 0 rows affected (0.00 sec)
Rows matched: 3  Changed: 3  Warnings: 0

可以通过查询setup_consumers表来验证是否启用了等待事件消费者。应该启用events_waits_current、events_waits_history和events_waits_history_long消费者。

mysql> SELECT * FROM performance_schema.setup_consumers;
+----------------------------------+---------+
| NAME                             | ENABLED |
+----------------------------------+---------+
| events_stages_current            | NO      |
| events_stages_history            | NO      |
| events_stages_history_long       | NO      |
| events_statements_current        | YES     |
| events_statements_history        | YES     |
| events_statements_history_long   | NO      |
| events_transactions_current      | NO      |
| events_transactions_history      | NO      |
| events_transactions_history_long | NO      |
| events_waits_current             | YES     |
| events_waits_history             | YES     |
| events_waits_history_long        | YES     |
| global_instrumentation           | YES     |
| thread_instrumentation           | YES     |
| statements_digest                | YES     |
+----------------------------------+---------+
15 rows in set (0.00 sec)

4.启用仪器和使用者后,运行要监视的工作负载。在这个例子中,mysqlslap负载模拟客户端用于模拟工作负载。

[mysql@localhost mysql]$ mysqlslap  -uroot -p123456 mysql  --auto-generate-sql --concurrency=100 --iterations=10 --number-of-queries=1000 --number-char-cols=6 --number-int-cols=6;
mysqlslap: [Warning] Using a password on the command line interface can be insecure.
Benchmark
        Average number of seconds to run all queries: 11.287 seconds
        Minimum number of seconds to run all queries: 11.172 seconds
        Maximum number of seconds to run all queries: 12.000 seconds
        Number of clients running queries: 100
        Average number of queries per client: 10




5.查询wait事件数据。在这个例子中,从events_waits_summary_global_by_event_name表中查询等待事件数据,该表聚合了events_waits_current、events_waits_history和events_waits_history_long表中的数据。数据按事件名称(EVENT_NAME)汇总,这是产生事件的工具的名称。汇总数据包括:
.COUNT_STAR 汇总等待事件的数量。

.SUM_TIMER_WAIT 汇总的定时等待事件的总等待时间。

.MIN_TIMER_WAIT 汇总的定时等待事件的最小等待时间。

.AVG_TIMER_WAIT 汇总的定时等待事件的平均等待时间。

.MAX_TIMER_WAIT 汇总的定时等待事件的最大等待时间。

下面的查询返回工具名称(EVENT_NAME)、等待事件数(COUNT_STAR)和该工具事件的总等待时间(SUM_TIMER_WAIT)。因为等待的时间默认以皮秒(万亿分之一秒)为单位,所以等待时间除以1000000000以毫秒为单位。数据按汇总的等待事件数量降序排列(COUNT_STAR)。可以调整ORDER BY子句,按总等待时间对数据进行排序。

mysql> SELECT EVENT_NAME, COUNT_STAR, SUM_TIMER_WAIT/1000000000 SUM_TIMER_WAIT_MS
    -> FROM performance_schema.events_waits_summary_global_by_event_name
    -> WHERE SUM_TIMER_WAIT > 0 AND EVENT_NAME LIKE 'wait/synch/mutex/innodb/%'
    -> ORDER BY COUNT_STAR DESC;
+--------------------------------------------------+------------+-------------------+
| EVENT_NAME                                       | COUNT_STAR | SUM_TIMER_WAIT_MS |
+--------------------------------------------------+------------+-------------------+
| wait/synch/mutex/innodb/buf_pool_mutex           |   10169469 |         1019.8992 |
| wait/synch/mutex/innodb/flush_list_mutex         |    6774758 |         1142.6652 |
| wait/synch/mutex/innodb/buf_dblwr_mutex          |    3387219 |          254.6546 |
| wait/synch/mutex/innodb/log_sys_mutex            |    1306588 |          236.5495 |
| wait/synch/mutex/innodb/sync_array_mutex         |     892914 |          214.6077 |
| wait/synch/mutex/innodb/rw_lock_list_mutex       |     524623 |           17.1254 |
| wait/synch/mutex/innodb/fil_system_mutex         |     449955 |          103.0167 |
| wait/synch/mutex/innodb/dict_sys_mutex           |     432432 |           44.9851 |
| wait/synch/mutex/innodb/log_sys_write_mutex      |     426698 |           32.9908 |
| wait/synch/mutex/innodb/log_flush_order_mutex    |     424318 |           76.9258 |
| wait/synch/mutex/innodb/lock_wait_mutex          |     423173 |          154.4097 |
| wait/synch/mutex/innodb/row_drop_list_mutex      |     423165 |          115.7234 |
| wait/synch/mutex/innodb/trx_mutex                |     148083 |           14.0274 |
| wait/synch/mutex/innodb/recalc_pool_mutex        |      42731 |           16.2913 |
| wait/synch/mutex/innodb/redo_rseg_mutex          |      36442 |           72.2952 |
| wait/synch/mutex/innodb/trx_sys_mutex            |      32181 |          595.8351 |
| wait/synch/mutex/innodb/lock_mutex               |      20761 |           49.5238 |
| wait/synch/mutex/innodb/srv_innodb_monitor_mutex |       6939 |            2.3340 |
| wait/synch/mutex/innodb/trx_undo_mutex           |       6550 |            0.8013 |
| wait/synch/mutex/innodb/trx_pool_mutex           |       2272 |        15580.2291 |
| wait/synch/mutex/innodb/innobase_share_mutex     |       2015 |            0.2733 |
| wait/synch/mutex/innodb/trx_pool_manager_mutex   |       1138 |            0.2584 |
| wait/synch/mutex/innodb/file_format_max_mutex    |       1021 |            0.0499 |
| wait/synch/mutex/innodb/page_cleaner_mutex       |        567 |            0.0531 |
| wait/synch/mutex/innodb/purge_sys_pq_mutex       |         70 |            0.0063 |
| wait/synch/mutex/innodb/srv_sys_mutex            |         52 |            0.0071 |
| wait/synch/mutex/innodb/ibuf_mutex               |         29 |            0.0022 |
| wait/synch/mutex/innodb/thread_mutex             |         27 |            0.0045 |
| wait/synch/mutex/innodb/recv_sys_mutex           |         22 |            0.0023 |
| wait/synch/mutex/innodb/buf_pool_zip_mutex       |         22 |            0.0020 |
| wait/synch/mutex/innodb/recv_writer_mutex        |          1 |            0.0002 |
| wait/synch/mutex/innodb/autoinc_mutex            |          1 |            0.0001 |
+--------------------------------------------------+------------+-------------------+
32 rows in set (0.02 sec)

注意:
上述结果集包括启动过程中产生的等待事件数据。要排除这些数据,您可以在启动后和运行工作负载之前立即截断events_waits_summary_global_by_event_name表。但truncate操作本身产生的等待事件数据量可以忽略不计。

mysql> TRUNCATE performance_schema.events_waits_summary_global_by_event_name;
Query OK, 0 rows affected (0.00 sec)

mysql> SELECT EVENT_NAME, COUNT_STAR, SUM_TIMER_WAIT/1000000000 SUM_TIMER_WAIT_MS
    -> FROM performance_schema.events_waits_summary_global_by_event_name
    -> WHERE SUM_TIMER_WAIT > 0 AND EVENT_NAME LIKE 'wait/synch/mutex/innodb/%'
    -> ORDER BY COUNT_STAR DESC;
+-----------------------------------------------+------------+-------------------+
| EVENT_NAME                                    | COUNT_STAR | SUM_TIMER_WAIT_MS |
+-----------------------------------------------+------------+-------------------+
| wait/synch/mutex/innodb/buf_pool_mutex        |        264 |            0.0381 |
| wait/synch/mutex/innodb/flush_list_mutex      |        176 |            0.0316 |
| wait/synch/mutex/innodb/buf_dblwr_mutex       |         88 |            0.0079 |
| wait/synch/mutex/innodb/log_sys_mutex         |         33 |            0.0079 |
| wait/synch/mutex/innodb/sync_array_mutex      |         22 |            0.0042 |
| wait/synch/mutex/innodb/dict_sys_mutex        |         11 |            0.0009 |
| wait/synch/mutex/innodb/fil_system_mutex      |         11 |            0.0022 |
| wait/synch/mutex/innodb/log_flush_order_mutex |         11 |            0.0020 |
| wait/synch/mutex/innodb/log_sys_write_mutex   |         11 |            0.0010 |
| wait/synch/mutex/innodb/lock_wait_mutex       |         11 |            0.0073 |
| wait/synch/mutex/innodb/row_drop_list_mutex   |         11 |            0.0067 |
| wait/synch/mutex/innodb/recalc_pool_mutex     |          1 |            0.0008 |
+-----------------------------------------------+------------+-------------------+
12 rows in set (0.02 sec)

]]>
http://www.jydba.net/index.php/archives/3540/feed 0
MySQL 获取InnoDB表空间元数据 http://www.jydba.net/index.php/archives/3538 http://www.jydba.net/index.php/archives/3538#respond Mon, 15 Jan 2024 07:43:12 +0000 http://www.jydba.net/?p=3538 从INFORMATION_SCHEMA.FILES中获取InnoDB表空间元数据
INFORMATION_SCHEMA。FILES表提供了所有InnoDB表空间类型的元数据,包括file-per-table表空间、通用表空间、system表空间、临时表空间和undo表空间(如果存在)。

注意:
INNODB_SYS_TABLESPACES和INNODB_SYS_DATAFILES表也提供了关于InnoDB表空间的元数据,但数据仅限于file-per-table和通用表空间。

该查询从INFORMATION_SCHEMA.FILES表的字段中检索有关InnoDB系统表空间的元数据。与InnoDB无关的字段总是返回NULL,并且被排除在查询之外。

mysql> SELECT FILE_ID, FILE_NAME, FILE_TYPE, TABLESPACE_NAME, FREE_EXTENTS,
    -> TOTAL_EXTENTS, EXTENT_SIZE, INITIAL_SIZE, MAXIMUM_SIZE, AUTOEXTEND_SIZE, DATA_FREE, STATUS ENGINE
    -> FROM INFORMATION_SCHEMA.FILES WHERE TABLESPACE_NAME LIKE 'innodb_system' \G
*************************** 1. row ***************************
        FILE_ID: 0
      FILE_NAME: ./ibdata1
      FILE_TYPE: TABLESPACE
TABLESPACE_NAME: innodb_system
   FREE_EXTENTS: 2
  TOTAL_EXTENTS: 74
    EXTENT_SIZE: 1048576
   INITIAL_SIZE: 77594624
   MAXIMUM_SIZE: NULL
AUTOEXTEND_SIZE: 67108864
      DATA_FREE: 37748736
         ENGINE: NORMAL
1 row in set (0.01 sec)

对于InnoDB file-per-table和通用表空间,下面这个查询检索FILE_ID(等价于space ID)和FILE_NAME(包含路径信息)。file-per-table和通用表空间的文件扩展名是.ibd。

mysql> SELECT FILE_ID, FILE_NAME FROM INFORMATION_SCHEMA.FILES WHERE FILE_NAME LIKE '%.ibd%' ORDER BY FILE_ID;
+---------+----------------------------------------------------------+
| FILE_ID | FILE_NAME                                                |
+---------+----------------------------------------------------------+
|       5 | ./mysql/plugin.ibd                                       |
|       6 | ./mysql/servers.ibd                                      |
|       7 | ./mysql/help_topic.ibd                                   |
|       8 | ./mysql/help_category.ibd                                |
|       9 | ./mysql/help_relation.ibd                                |
|      10 | ./mysql/help_keyword.ibd                                 |
|      11 | ./mysql/time_zone_name.ibd                               |
|      12 | ./mysql/time_zone.ibd                                    |
|      13 | ./mysql/time_zone_transition.ibd                         |
|      14 | ./mysql/time_zone_transition_type.ibd                    |
|      15 | ./mysql/time_zone_leap_second.ibd                        |
|      16 | ./mysql/innodb_table_stats.ibd                           |
|      17 | ./mysql/innodb_index_stats.ibd                           |
|      18 | ./mysql/slave_relay_log_info.ibd                         |
|      19 | ./mysql/slave_master_info.ibd                            |
|      20 | ./mysql/slave_worker_info.ibd                            |
|      21 | ./mysql/gtid_executed.ibd                                |
|      22 | ./mysql/server_cost.ibd                                  |
|      23 | ./mysql/engine_cost.ibd                                  |
|      24 | ./sys/sys_config.ibd                                     |
|      37 | ./ts1.ibd                                                |
|      38 | ./ts2.ibd                                                |
|      51 | ./test/user.ibd                                          |
|      57 | ./mysql/test_index_1.ibd                                 |
|      58 | ./test/test_index_1.ibd                                  |
|      59 | ./employees/employees.ibd                                |
|      60 | ./employees/departments.ibd                              |
|      61 | ./employees/dept_manager.ibd                             |
|      62 | ./employees/dept_emp.ibd                                 |
|      63 | ./employees/titles.ibd                                   |
|      64 | ./employees/salaries.ibd                                 |
|     262 | ./test/bmsql_config.ibd                                  |
|     272 | ./test/bmsql_warehouse.ibd                               |
|     279 | ./test/bmsql_item.ibd                                    |
|     280 | ./test/bmsql_district.ibd                                |
|     281 | ./test/bmsql_customer.ibd                                |
|     283 | ./test/bmsql_history.ibd                                 |
|     284 | ./test/bmsql_new_order.ibd                               |
|     285 | ./test/bmsql_oorder.ibd                                  |
|     287 | ./test/bmsql_order_line.ibd                              |
|     289 | ./test/bmsql_stock.ibd                                   |
|     293 | ./ts01.ibd                                               |
|     294 | ./ts02.ibd                                               |
|     414 | ./employees/t.ibd                                        |
|     415 | ./employees/c.ibd                                        |
|     420 | ./test/ts03.ibd                                          |
|     423 | ./test/abc.ibd                                           |
|     425 | ./test/t3.ibd                                            |
|     426 | ./test/t4.ibd                                            |
|     427 | ./test/t7.ibd                                            |
|     428 | ./test/t8.ibd                                            |
|     472 | ./undo/opening_lines.ibd                                 |
|     473 | ./undo/FTS_00000000000001d9_BEING_DELETED.ibd            |
|     474 | ./undo/FTS_00000000000001d9_BEING_DELETED_CACHE.ibd      |
|     475 | ./undo/FTS_00000000000001d9_CONFIG.ibd                   |
|     476 | ./undo/FTS_00000000000001d9_DELETED.ibd                  |
|     477 | ./undo/FTS_00000000000001d9_DELETED_CACHE.ibd            |
|     478 | ./undo/FTS_00000000000001d9_00000000000002da_INDEX_1.ibd |
|     479 | ./undo/FTS_00000000000001d9_00000000000002da_INDEX_2.ibd |
|     480 | ./undo/FTS_00000000000001d9_00000000000002da_INDEX_3.ibd |
|     481 | ./undo/FTS_00000000000001d9_00000000000002da_INDEX_4.ibd |
|     482 | ./undo/FTS_00000000000001d9_00000000000002da_INDEX_5.ibd |
|     483 | ./undo/FTS_00000000000001d9_00000000000002da_INDEX_6.ibd |
|     484 | ./undo/t1.ibd                                            |
|     485 | ./ts3.ibd                                                |
|     487 | ./undo/big_table.ibd                                     |
|     489 | ./undo/key_block_size_4.ibd                              |
|     490 | ./ts4.ibd                                                |
|     491 | ./ts5.ibd                                                |
|     492 | ./ts6.ibd                                                |
|     494 | ./undo/t7.ibd                                            |
|     497 | ./undo/t8.ibd                                            |
|     498 | ./undo/employees.ibd                                     |
|     499 | ./undo/t9.ibd                                            |
|     500 | ./undo/t10.ibd                                           |
|     501 | ./undo/t11.ibd                                           |
|     503 | ./undo/t12.ibd                                           |
|     506 | ./undo/t13.ibd                                           |
|     507 | ./undo/t14.ibd                                           |
|     509 | ./test/parent.ibd                                        |
|     510 | ./test/child.ibd                                         |
|     523 | ./test/articles.ibd                                      |
|     524 | ./test/FTS_000000000000020c_BEING_DELETED.ibd            |
|     525 | ./test/FTS_000000000000020c_BEING_DELETED_CACHE.ibd      |
|     526 | ./test/FTS_000000000000020c_CONFIG.ibd                   |
|     527 | ./test/FTS_000000000000020c_DELETED.ibd                  |
|     528 | ./test/FTS_000000000000020c_DELETED_CACHE.ibd            |
|     529 | ./test/FTS_000000000000020c_0000000000000310_INDEX_1.ibd |
|     530 | ./test/FTS_000000000000020c_0000000000000310_INDEX_2.ibd |
|     531 | ./test/FTS_000000000000020c_0000000000000310_INDEX_3.ibd |
|     532 | ./test/FTS_000000000000020c_0000000000000310_INDEX_4.ibd |
|     533 | ./test/FTS_000000000000020c_0000000000000310_INDEX_5.ibd |
|     534 | ./test/FTS_000000000000020c_0000000000000310_INDEX_6.ibd |
|     535 | ./test/t1.ibd                                            |
+---------+----------------------------------------------------------+
94 rows in set (0.00 sec)

下面这个查询获取了InnoDB临时表空间的FILE_ID和FILE_NAME。临时表空间文件名以ibtmp为前缀。

mysql> SELECT FILE_ID, FILE_NAME FROM INFORMATION_SCHEMA.FILES WHERE FILE_NAME LIKE '%ibtmp%';
+---------+-----------+
| FILE_ID | FILE_NAME |
+---------+-----------+
|     537 | ./ibtmp1  |
+---------+-----------+
1 row in set (0.01 sec)

类似地,InnoDB的undo表空间文件名以undo为前缀。如果配置了单独的undo表空间,下面的查询返回了InnoDB undo表空间的FILE_ID和FILE_NAME。

mysql> SELECT FILE_ID, FILE_NAME FROM INFORMATION_SCHEMA.FILES WHERE FILE_NAME LIKE '%undo%';
+---------+----------------------------------------------------------+
| FILE_ID | FILE_NAME                                                |
+---------+----------------------------------------------------------+
|       1 | /mysqldata/mysql/undo/undo001                            |
|       2 | /mysqldata/mysql/undo/undo002                            |
|       3 | /mysqldata/mysql/undo/undo003                            |
+---------+----------------------------------------------------------+
3 rows in set (0.00 sec)
]]>
http://www.jydba.net/index.php/archives/3538/feed 0
MySQL InnoDB INFORMATION_SCHEMA临时表信息表 http://www.jydba.net/index.php/archives/3536 http://www.jydba.net/index.php/archives/3536#respond Sat, 13 Jan 2024 07:40:45 +0000 http://www.jydba.net/?p=3536 InnoDB INFORMATION_SCHEMA临时表信息表

INNODB_TEMP_TABLE_INFO表为用户提供了一个活动的InnoDB临时表的快照。这张表包含了除InnoDB内部使用的优化过的临时表之外的所有用户和系统创建的临时表的元数据,这些临时表在给定的InnoDB实例中是活动的。

mysql> SHOW TABLES FROM INFORMATION_SCHEMA LIKE 'INNODB_TEMP%';
+---------------------------------------------+
| Tables_in_information_schema (INNODB_TEMP%) |
+---------------------------------------------+
| INNODB_TEMP_TABLE_INFO                      |
+---------------------------------------------+
1 row in set (0.00 sec)

下面这个例子将展示了INNODB_TEMP_TABLE_INFO表的特征。
1.创建一个单列的简单InnoDB临时表:

mysql> CREATE TEMPORARY TABLE t1 (c1 INT PRIMARY KEY) ENGINE=INNODB;
Query OK, 0 rows affected (0.01 sec)

2.查询INNODB_TEMP_TABLE_INFO表查看临时表的元数据。

mysql> SELECT * FROM INFORMATION_SCHEMA.INNODB_TEMP_TABLE_INFO\G
*************************** 1. row ***************************
            TABLE_ID: 537
                NAME: #sql1d89_101_0
              N_COLS: 4
               SPACE: 444
PER_TABLE_TABLESPACE: FALSE
       IS_COMPRESSED: FALSE
1 row in set (0.00 sec)

TABLE_ID是临时表的唯一标识符。NAME列显示了系统生成的临时表的名称,前缀是“#sql”。列数(N_COLS)是4而不是1,因为InnoDB总是创建3个隐藏表列(DB_ROW_ID、DB_TRX_ID和DB_ROLL_PTR)。PER_TABLE_TABLESPACE和IS_COMPRESSED仅对压缩的临时表报告为TRUE。

3.创建一个压缩的临时表。在此之前,确保innodb_file_format设置为Barracuda,这是创建压缩行格式的表所必需的。

mysql> SET GLOBAL innodb_file_format="Barracuda";
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> CREATE TEMPORARY TABLE t2 (c1 INT) ROW_FORMAT=COMPRESSED ENGINE=INNODB;
Query OK, 0 rows affected (0.00 sec)

4.再次查询INNODB_TEMP_TABLE_INFO表。

mysql> SELECT * FROM INFORMATION_SCHEMA.INNODB_TEMP_TABLE_INFO\G
*************************** 1. row ***************************
            TABLE_ID: 538
                NAME: #sql1d89_101_1
              N_COLS: 4
               SPACE: 536
PER_TABLE_TABLESPACE: TRUE
       IS_COMPRESSED: TRUE
*************************** 2. row ***************************
            TABLE_ID: 537
                NAME: #sql1d89_101_0
              N_COLS: 4
               SPACE: 444
PER_TABLE_TABLESPACE: FALSE
       IS_COMPRESSED: FALSE
2 rows in set (0.00 sec)

对于压缩临时表,PER_TABLE_TABLESPACE和IS_COMPRESSED报告为TRUE。压缩临时表的空间ID是不同的,因为压缩临时表是在单独的per-table表空间中创建的。非压缩临时表共享一个表空间(默认情况下是ibtmp1),并且报告相同的空间ID。

5.重启MySQL并查询INNODB_TEMP_TABLE_INFO表。

[root@localhost mysql]# service mysqld restart
Shutting down MySQL.... SUCCESS!
Starting MySQL... SUCCESS!

mysql> SELECT * FROM INFORMATION_SCHEMA.INNODB_TEMP_TABLE_INFO\G
Empty set (0.00 sec)

返回一个空集合,因为INNODB_TEMP_TABLE_INFO表和其中的数据在服务器关闭时没有持久化到磁盘。

6.创建一个新的临时表。

mysql> CREATE TEMPORARY TABLE t1 (c1 INT PRIMARY KEY) ENGINE=INNODB;
Query OK, 0 rows affected (0.00 sec)

7.查询INNODB_TEMP_TABLE_INFO表查看临时表的元数据。

mysql> CREATE TEMPORARY TABLE t1 (c1 INT PRIMARY KEY) ENGINE=INNODB;
Query OK, 0 rows affected (0.00 sec)

mysql> SELECT * FROM INFORMATION_SCHEMA.INNODB_TEMP_TABLE_INFO\G
*************************** 1. row ***************************
            TABLE_ID: 539
                NAME: #sql216d_2_0
              N_COLS: 4
               SPACE: 537
PER_TABLE_TABLESPACE: FALSE
       IS_COMPRESSED: FALSE
1 row in set (0.00 sec)

空间ID是新的,因为它是在服务器重启时动态生成的。

]]>
http://www.jydba.net/index.php/archives/3536/feed 0
MySQL InnoDB INFORMATION_SCHEMA度量表 http://www.jydba.net/index.php/archives/3530 http://www.jydba.net/index.php/archives/3530#respond Wed, 10 Jan 2024 07:37:04 +0000 http://www.jydba.net/?p=3530 InnoDB INFORMATION_SCHEMA度量表
MySQL 5.6.2中引入了INNODB_METRICS表,它将所有InnoDB性能和资源相关的计数器合并到一个INFORMATION_SCHEMA表中。

mysql> SELECT * FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE NAME="dml_inserts" \G
*************************** 1. row ***************************
           NAME: dml_inserts
      SUBSYSTEM: dml
          COUNT: 17263004
      MAX_COUNT: 17263004
      MIN_COUNT: NULL
      AVG_COUNT: 0.8178722213173183
    COUNT_RESET: 17263004
MAX_COUNT_RESET: 17263004
MIN_COUNT_RESET: NULL
AVG_COUNT_RESET: NULL
   TIME_ENABLED: 2023-05-10 09:02:54
  TIME_DISABLED: NULL
   TIME_ELAPSED: 21107214
     TIME_RESET: NULL
         STATUS: enabled
           TYPE: status_counter
        COMMENT: Number of rows inserted

启用、禁用和重置计数器
可以使用以下配置选项启用、禁用和重置计数器:
.innodb_monitor_enable:启用一个或多个计数器。

SET GLOBAL innodb_monitor_enable = [counter-name|module_name|pattern|all];

.innodb_monitor_disable:禁用一个或多个计数器。

SET GLOBAL innodb_monitor_disable = [counter-name|module_name|pattern|all];

.innodb_monitor_reset:将一个或多个计数器的计数值重置为零。

SET GLOBAL innodb_monitor_reset = [counter-name|module_name|pattern|all];

.innodb_monitor_reset_all:重置一个或多个计数器的所有值。在使用innodb_monitor_reset_all之前,必须禁用计数器。

SET GLOBAL innodb_monitor_reset_all = [counter-name|module_name|pattern|all];

你也可以在启动时使用MySQL服务器配置文件启用计数器和计数器模块。例如,要启用log模块、metadata_table_handles_opened和metadata_table_handles_closed计数器,在my.cnf配置文件的[mysqld]部分输入以下代码。

[mysqld]
innodb_monitor_enable = module_recovery,metadata_table_handles_opened,metadata_table_handles_closed

当在你的配置文件中启用多个计数器或模块时,你必须指定innodb_monitor_enable配置选项,后面跟着用逗号分隔的计数器和模块名称,如上例所示。只有innodb_monitor_enable选项可以在你的配置文件中使用。禁用和重置配置选项仅支持在命令行上。

注意:
因为每个计数器都会在服务器上增加一定程度的运行时开销,所以通常在试验和基准测试期间在测试和开发服务器上启用更多的计数器,并且仅在生产服务器上启用计数器以诊断已知问题或监视可能成为特定服务器和工作负载瓶颈的方面。

计数器
INNODB_METRICS表中的计数器可能会发生变化,所以要获取最新的计数器列表,可以在运行中的MySQL服务器上查询。

默认启用的计数器与“SHOW ENGINE INNODB STATUS”使用的计数器对应。SHOW ENGINE INNODB STATUS使用的计数器在系统级别上总是“on”的,但是你可以根据需要禁用INNODB_METRICS表的这些计数器。另外,计数器状态不是持久的。除非另外指定,否则计数器在服务器重启时将恢复到默认的启用或禁用状态。

如果你运行的程序会受到INNODB_METRICS表中新增或更改的影响,建议你查看发布说明,并在升级之前查询INNODB_METRICS表中的新版本。

mysql> SELECT name, subsystem, status FROM INFORMATION_SCHEMA.INNODB_METRICS ORDER BY NAME;
+------------------------------------------+---------------------+----------+
| name                                     | subsystem           | status   |
+------------------------------------------+---------------------+----------+
| adaptive_hash_pages_added                | adaptive_hash_index | disabled |
| adaptive_hash_pages_removed              | adaptive_hash_index | disabled |
| adaptive_hash_rows_added                 | adaptive_hash_index | disabled |
| adaptive_hash_rows_deleted_no_hash_entry | adaptive_hash_index | disabled |
| adaptive_hash_rows_removed               | adaptive_hash_index | disabled |
| adaptive_hash_rows_updated               | adaptive_hash_index | disabled |
| adaptive_hash_searches                   | adaptive_hash_index | enabled  |
| adaptive_hash_searches_btree             | adaptive_hash_index | enabled  |
| buffer_data_reads                        | buffer              | enabled  |
| buffer_data_written                      | buffer              | enabled  |
| buffer_flush_adaptive                    | buffer              | disabled |
| buffer_flush_adaptive_avg_pass           | buffer              | disabled |
| buffer_flush_adaptive_avg_time_est       | buffer              | disabled |
| buffer_flush_adaptive_avg_time_slot      | buffer              | disabled |
| buffer_flush_adaptive_avg_time_thread    | buffer              | disabled |
| buffer_flush_adaptive_pages              | buffer              | disabled |
| buffer_flush_adaptive_total_pages        | buffer              | disabled |
| buffer_flush_avg_page_rate               | buffer              | disabled |
| buffer_flush_avg_pass                    | buffer              | disabled |
| buffer_flush_avg_time                    | buffer              | disabled |
| buffer_flush_background                  | buffer              | disabled |
| buffer_flush_background_pages            | buffer              | disabled |
| buffer_flush_background_total_pages      | buffer              | disabled |
| buffer_flush_batches                     | buffer              | disabled |
| buffer_flush_batch_num_scan              | buffer              | disabled |
| buffer_flush_batch_pages                 | buffer              | disabled |
| buffer_flush_batch_scanned               | buffer              | disabled |
| buffer_flush_batch_scanned_per_call      | buffer              | disabled |
| buffer_flush_batch_total_pages           | buffer              | disabled |
| buffer_flush_lsn_avg_rate                | buffer              | disabled |
| buffer_flush_nei***or                    | buffer              | disabled |
| buffer_flush_nei***or_pages              | buffer              | disabled |
| buffer_flush_nei***or_total_pages        | buffer              | disabled |
| buffer_flush_n_to_flush_by_age           | buffer              | disabled |
| buffer_flush_n_to_flush_requested        | buffer              | disabled |
| buffer_flush_pct_for_dirty               | buffer              | disabled |
| buffer_flush_pct_for_lsn                 | buffer              | disabled |
| buffer_flush_sync                        | buffer              | disabled |
| buffer_flush_sync_pages                  | buffer              | disabled |
| buffer_flush_sync_total_pages            | buffer              | disabled |
| buffer_flush_sync_waits                  | buffer              | disabled |
| buffer_LRU_batches_evict                 | buffer              | disabled |
| buffer_LRU_batches_flush                 | buffer              | disabled |
| buffer_LRU_batch_evict_pages             | buffer              | disabled |
| buffer_LRU_batch_evict_total_pages       | buffer              | disabled |
| buffer_LRU_batch_flush_avg_pass          | buffer              | disabled |
| buffer_LRU_batch_flush_avg_time_est      | buffer              | disabled |
| buffer_LRU_batch_flush_avg_time_slot     | buffer              | disabled |
| buffer_LRU_batch_flush_avg_time_thread   | buffer              | disabled |
| buffer_LRU_batch_flush_pages             | buffer              | disabled |
| buffer_LRU_batch_flush_total_pages       | buffer              | disabled |
| buffer_LRU_batch_num_scan                | buffer              | disabled |
| buffer_LRU_batch_scanned                 | buffer              | disabled |
| buffer_LRU_batch_scanned_per_call        | buffer              | disabled |
| buffer_LRU_get_free_loops                | buffer              | disabled |
| buffer_LRU_get_free_search               | Buffer              | disabled |
| buffer_LRU_get_free_waits                | buffer              | disabled |
| buffer_LRU_search_num_scan               | buffer              | disabled |
| buffer_LRU_search_scanned                | buffer              | disabled |
| buffer_LRU_search_scanned_per_call       | buffer              | disabled |
| buffer_LRU_single_flush_failure_count    | Buffer              | disabled |
| buffer_LRU_single_flush_num_scan         | buffer              | disabled |
| buffer_LRU_single_flush_scanned          | buffer              | disabled |
| buffer_LRU_single_flush_scanned_per_call | buffer              | disabled |
| buffer_LRU_unzip_search_num_scan         | buffer              | disabled |
| buffer_LRU_unzip_search_scanned          | buffer              | disabled |
| buffer_LRU_unzip_search_scanned_per_call | buffer              | disabled |
| buffer_pages_created                     | buffer              | enabled  |
| buffer_pages_read                        | buffer              | enabled  |
| buffer_pages_written                     | buffer              | enabled  |
| buffer_page_read_blob                    | buffer_page_io      | disabled |
| buffer_page_read_fsp_hdr                 | buffer_page_io      | disabled |
| buffer_page_read_ibuf_bitmap             | buffer_page_io      | disabled |
| buffer_page_read_ibuf_free_list          | buffer_page_io      | disabled |
| buffer_page_read_index_ibuf_leaf         | buffer_page_io      | disabled |
| buffer_page_read_index_ibuf_non_leaf     | buffer_page_io      | disabled |
| buffer_page_read_index_inode             | buffer_page_io      | disabled |
| buffer_page_read_index_leaf              | buffer_page_io      | disabled |
| buffer_page_read_index_non_leaf          | buffer_page_io      | disabled |
| buffer_page_read_other                   | buffer_page_io      | disabled |
| buffer_page_read_system_page             | buffer_page_io      | disabled |
| buffer_page_read_trx_system              | buffer_page_io      | disabled |
| buffer_page_read_undo_log                | buffer_page_io      | disabled |
| buffer_page_read_xdes                    | buffer_page_io      | disabled |
| buffer_page_read_zblob                   | buffer_page_io      | disabled |
| buffer_page_read_zblob2                  | buffer_page_io      | disabled |
| buffer_page_written_blob                 | buffer_page_io      | disabled |
| buffer_page_written_fsp_hdr              | buffer_page_io      | disabled |
| buffer_page_written_ibuf_bitmap          | buffer_page_io      | disabled |
| buffer_page_written_ibuf_free_list       | buffer_page_io      | disabled |
| buffer_page_written_index_ibuf_leaf      | buffer_page_io      | disabled |
| buffer_page_written_index_ibuf_non_leaf  | buffer_page_io      | disabled |
| buffer_page_written_index_inode          | buffer_page_io      | disabled |
| buffer_page_written_index_leaf           | buffer_page_io      | disabled |
| buffer_page_written_index_non_leaf       | buffer_page_io      | disabled |
| buffer_page_written_other                | buffer_page_io      | disabled |
| buffer_page_written_system_page          | buffer_page_io      | disabled |
| buffer_page_written_trx_system           | buffer_page_io      | disabled |
| buffer_page_written_undo_log             | buffer_page_io      | disabled |
| buffer_page_written_xdes                 | buffer_page_io      | disabled |
| buffer_page_written_zblob                | buffer_page_io      | disabled |
| buffer_page_written_zblob2               | buffer_page_io      | disabled |
| buffer_pool_bytes_data                   | buffer              | enabled  |
| buffer_pool_bytes_dirty                  | buffer              | enabled  |
| buffer_pool_pages_data                   | buffer              | enabled  |
| buffer_pool_pages_dirty                  | buffer              | enabled  |
| buffer_pool_pages_free                   | buffer              | enabled  |
| buffer_pool_pages_misc                   | buffer              | enabled  |
| buffer_pool_pages_total                  | buffer              | enabled  |
| buffer_pool_reads                        | buffer              | enabled  |
| buffer_pool_read_ahead                   | buffer              | enabled  |
| buffer_pool_read_ahead_evicted           | buffer              | enabled  |
| buffer_pool_read_requests                | buffer              | enabled  |
| buffer_pool_size                         | server              | enabled  |
| buffer_pool_wait_free                    | buffer              | enabled  |
| buffer_pool_write_requests               | buffer              | enabled  |
| compression_pad_decrements               | compression         | disabled |
| compression_pad_increments               | compression         | disabled |
| compress_pages_compressed                | compression         | disabled |
| compress_pages_decompressed              | compression         | disabled |
| ddl_background_drop_indexes              | ddl                 | disabled |
| ddl_background_drop_tables               | ddl                 | disabled |
| ddl_log_file_alter_table                 | ddl                 | disabled |
| ddl_online_create_index                  | ddl                 | disabled |
| ddl_pending_alter_table                  | ddl                 | disabled |
| ddl_sort_file_alter_table                | ddl                 | disabled |
| dml_deletes                              | dml                 | enabled  |
| dml_inserts                              | dml                 | enabled  |
| dml_reads                                | dml                 | disabled |
| dml_updates                              | dml                 | enabled  |
| file_num_open_files                      | file_system         | enabled  |
| ibuf_merges                              | change_buffer       | enabled  |
| ibuf_merges_delete                       | change_buffer       | enabled  |
| ibuf_merges_delete_mark                  | change_buffer       | enabled  |
| ibuf_merges_discard_delete               | change_buffer       | enabled  |
| ibuf_merges_discard_delete_mark          | change_buffer       | enabled  |
| ibuf_merges_discard_insert               | change_buffer       | enabled  |
| ibuf_merges_insert                       | change_buffer       | enabled  |
| ibuf_size                                | change_buffer       | enabled  |
| icp_attempts                             | icp                 | disabled |
| icp_match                                | icp                 | disabled |
| icp_no_match                             | icp                 | disabled |
| icp_out_of_range                         | icp                 | disabled |
| index_page_discards                      | index               | disabled |
| index_page_merge_attempts                | index               | disabled |
| index_page_merge_successful              | index               | disabled |
| index_page_reorg_attempts                | index               | disabled |
| index_page_reorg_successful              | index               | disabled |
| index_page_splits                        | index               | disabled |
| innodb_activity_count                    | server              | enabled  |
| innodb_background_drop_table_usec        | server              | disabled |
| innodb_checkpoint_usec                   | server              | disabled |
| innodb_dblwr_pages_written               | server              | enabled  |
| innodb_dblwr_writes                      | server              | enabled  |
| innodb_dict_lru_count                    | server              | disabled |
| innodb_dict_lru_usec                     | server              | disabled |
| innodb_ibuf_merge_usec                   | server              | disabled |
| innodb_log_flush_usec                    | server              | disabled |
| innodb_master_active_loops               | server              | disabled |
| innodb_master_idle_loops                 | server              | disabled |
| innodb_master_purge_usec                 | server              | disabled |
| innodb_master_thread_sleeps              | server              | disabled |
| innodb_mem_validate_usec                 | server              | disabled |
| innodb_page_size                         | server              | enabled  |
| innodb_rwlock_sx_os_waits                | server              | enabled  |
| innodb_rwlock_sx_spin_rounds             | server              | enabled  |
| innodb_rwlock_sx_spin_waits              | server              | enabled  |
| innodb_rwlock_s_os_waits                 | server              | enabled  |
| innodb_rwlock_s_spin_rounds              | server              | enabled  |
| innodb_rwlock_s_spin_waits               | server              | enabled  |
| innodb_rwlock_x_os_waits                 | server              | enabled  |
| innodb_rwlock_x_spin_rounds              | server              | enabled  |
| innodb_rwlock_x_spin_waits               | server              | enabled  |
| lock_deadlocks                           | lock                | enabled  |
| lock_rec_locks                           | lock                | disabled |
| lock_rec_lock_created                    | lock                | disabled |
| lock_rec_lock_removed                    | lock                | disabled |
| lock_rec_lock_requests                   | lock                | disabled |
| lock_rec_lock_waits                      | lock                | disabled |
| lock_row_lock_current_waits              | lock                | enabled  |
| lock_row_lock_time                       | lock                | enabled  |
| lock_row_lock_time_avg                   | lock                | enabled  |
| lock_row_lock_time_max                   | lock                | enabled  |
| lock_row_lock_waits                      | lock                | enabled  |
| lock_table_locks                         | lock                | disabled |
| lock_table_lock_created                  | lock                | disabled |
| lock_table_lock_removed                  | lock                | disabled |
| lock_table_lock_waits                    | lock                | disabled |
| lock_timeouts                            | lock                | enabled  |
| log_checkpoints                          | recovery            | disabled |
| log_lsn_buf_pool_oldest                  | recovery            | disabled |
| log_lsn_checkpoint_age                   | recovery            | disabled |
| log_lsn_current                          | recovery            | disabled |
| log_lsn_last_checkpoint                  | recovery            | disabled |
| log_lsn_last_flush                       | recovery            | disabled |
| log_max_modified_age_async               | recovery            | disabled |
| log_max_modified_age_sync                | recovery            | disabled |
| log_num_log_io                           | recovery            | disabled |
| log_padded                               | recovery            | enabled  |
| log_pending_checkpoint_writes            | recovery            | disabled |
| log_pending_log_flushes                  | recovery            | disabled |
| log_waits                                | recovery            | enabled  |
| log_writes                               | recovery            | enabled  |
| log_write_requests                       | recovery            | enabled  |
| metadata_table_handles_closed            | metadata            | disabled |
| metadata_table_handles_opened            | metadata            | disabled |
| metadata_table_reference_count           | metadata            | disabled |
| os_data_fsyncs                           | os                  | enabled  |
| os_data_reads                            | os                  | enabled  |
| os_data_writes                           | os                  | enabled  |
| os_log_bytes_written                     | os                  | enabled  |
| os_log_fsyncs                            | os                  | enabled  |
| os_log_pending_fsyncs                    | os                  | enabled  |
| os_log_pending_writes                    | os                  | enabled  |
| os_pending_reads                         | os                  | disabled |
| os_pending_writes                        | os                  | disabled |
| purge_del_mark_records                   | purge               | disabled |
| purge_dml_delay_usec                     | purge               | disabled |
| purge_invoked                            | purge               | disabled |
| purge_resume_count                       | purge               | disabled |
| purge_stop_count                         | purge               | disabled |
| purge_undo_log_pages                     | purge               | disabled |
| purge_upd_exist_or_extern_records        | purge               | disabled |
| trx_active_transactions                  | transaction         | disabled |
| trx_commits_insert_update                | transaction         | disabled |
| trx_nl_ro_commits                        | transaction         | disabled |
| trx_rollbacks                            | transaction         | disabled |
| trx_rollbacks_savepoint                  | transaction         | disabled |
| trx_rollback_active                      | transaction         | disabled |
| trx_ro_commits                           | transaction         | disabled |
| trx_rseg_current_size                    | transaction         | disabled |
| trx_rseg_history_len                     | transaction         | enabled  |
| trx_rw_commits                           | transaction         | disabled |
| trx_undo_slots_cached                    | transaction         | disabled |
| trx_undo_slots_used                      | transaction         | disabled |
+------------------------------------------+---------------------+----------+
235 rows in set (0.03 sec)

计数器模块
模块名与INNODB_METRICS表中的SUBSYSTEM列对应,但不完全相同。相对于单独启用、禁用或重置计数器,您可以使用模块名称来快速启用、禁用或重置特定子系统的所有计数器。例如,使用module_dml启用与dml子系统关联的所有计数器。

mysql> SELECT name, subsystem, status FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem ='dml';
+-------------+-----------+----------+
| name        | subsystem | status   |
+-------------+-----------+----------+
| dml_reads   | dml       | disabled |
| dml_inserts | dml       | enabled  |
| dml_deletes | dml       | enabled  |
| dml_updates | dml       | enabled  |
+-------------+-----------+----------+
4 rows in set (0.00 sec)

mysql> SET GLOBAL innodb_monitor_enable = module_dml;
Query OK, 0 rows affected (0.00 sec)

mysql> SELECT name, subsystem, status FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem ='dml';
+-------------+-----------+---------+
| name        | subsystem | status  |
+-------------+-----------+---------+
| dml_reads   | dml       | enabled |
| dml_inserts | dml       | enabled |
| dml_deletes | dml       | enabled |
| dml_updates | dml       | enabled |
+-------------+-----------+---------+
4 rows in set (0.00 sec)

下面是innodb_monitor_enable和相关的配置选项可以使用的module_name值以及相应的子系统名称。

.module_adaptive_hash (subsystem = adaptive_hash_index)
.module_buffer (subsystem = buffer)
.module_buffer_page (subsystem = buffer_page_io)
.module_compress (subsystem = compression)
.module_ddl (subsystem = ddl)
.module_dml (subsystem = dml)
.module_file (subsystem = file_system)
.module_ibuf_system (subsystem = change_buffer)
.module_icp (subsystem = icp)
.module_index (subsystem = index)
.module_innodb (subsystem = innodb)
.module_lock (subsystem = lock)
.module_log (subsystem = recovery)
.module_metadata (subsystem = metadata)
.module_os (subsystem = os)
.module_purge (subsystem = purge)
.module_trx (subsystem = transaction)

使用INNODB_METRICS表计数器
下面这个例子演示了启用、禁用、重置计数器,以及查询INNODB_METRICS表中的计数器数据。

1.创建一个简单的InnoDB表;

mysql> use test
Database changed
mysql> CREATE TABLE t1 (c1 INT) ENGINE=INNODB;
Query OK, 0 rows affected (0.01 sec)

2.启用dml_inserts计数器。
先禁用dml_inserts计数器并将所有计数清零

mysql> SET GLOBAL innodb_monitor_disable=dml_inserts;
Query OK, 0 rows affected (0.00 sec)

mysql> SELECT * FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE NAME="dml_inserts" \G
*************************** 1. row ***************************
           NAME: dml_inserts
      SUBSYSTEM: dml
          COUNT: 17263007
      MAX_COUNT: 17263007
      MIN_COUNT: NULL
      AVG_COUNT: 0.817808627174022
    COUNT_RESET: 0
MAX_COUNT_RESET: 0
MIN_COUNT_RESET: NULL
AVG_COUNT_RESET: 0
   TIME_ENABLED: 2023-05-10 09:02:54
  TIME_DISABLED: 2024-01-09 16:37:13
   TIME_ELAPSED: 21108859
     TIME_RESET: NULL
         STATUS: disabled
           TYPE: status_counter
        COMMENT: Number of rows inserted
1 row in set (0.00 sec)

mysql> SET GLOBAL innodb_monitor_reset_all=dml_inserts;
Query OK, 0 rows affected (0.05 sec)

mysql> SELECT * FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE NAME="dml_inserts" \G
*************************** 1. row ***************************
           NAME: dml_inserts
      SUBSYSTEM: dml
          COUNT: 0
      MAX_COUNT: NULL
      MIN_COUNT: NULL
      AVG_COUNT: NULL
    COUNT_RESET: 0
MAX_COUNT_RESET: NULL
MIN_COUNT_RESET: NULL
AVG_COUNT_RESET: NULL
   TIME_ENABLED: NULL
  TIME_DISABLED: NULL
   TIME_ELAPSED: NULL
     TIME_RESET: NULL
         STATUS: disabled
           TYPE: status_counter
        COMMENT: Number of rows inserted
1 row in set (0.00 sec)

再启用dml_inserts计数器

mysql> SET GLOBAL innodb_monitor_enable = dml_inserts;
Query OK, 0 rows affected (0.00 sec)

在INNODB_METRICS表的COMMENT列中找到的关于dml_inserts计数器的描述:

mysql> SELECT NAME, COMMENT FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE NAME="dml_inserts";
+-------------+-------------------------+
| NAME        | COMMENT                 |
+-------------+-------------------------+
| dml_inserts | Number of rows inserted |
+-------------+-------------------------+
1 row in set (0.00 sec)

3.查询INNODB_METRICS表中的dml_inserts计数器数据。因为没有执行DML操作,所以计数器值为零或NULL。TIME_ENABLED和TIME_ELAPSED值表示计数器上次启用的时间,以及从该时间起已经过去了多少秒。

mysql> SELECT * FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE NAME="dml_inserts" \G
*************************** 1. row ***************************
           NAME: dml_inserts
      SUBSYSTEM: dml
          COUNT: 0
      MAX_COUNT: 0
      MIN_COUNT: NULL
      AVG_COUNT: 0
    COUNT_RESET: 0
MAX_COUNT_RESET: 0
MIN_COUNT_RESET: NULL
AVG_COUNT_RESET: NULL
   TIME_ENABLED: 2024-01-09 16:40:33
  TIME_DISABLED: NULL
   TIME_ELAPSED: 150
     TIME_RESET: NULL
         STATUS: enabled
           TYPE: status_counter
        COMMENT: Number of rows inserted
1 row in set (0.00 sec)

4.向表中插入三行数据。

mysql> INSERT INTO t1 values(1);
Query OK, 1 row affected (0.01 sec)

mysql> INSERT INTO t1 values(2);
Query OK, 1 row affected (0.01 sec)

mysql> INSERT INTO t1 values(3);
Query OK, 1 row affected (0.00 sec)

5.再次查询INNODB_METRICS表获取dml_inserts计数器数据。现在有一些计数器的值已经递增,包括COUNT、MAX_COUNT、AVG_COUNT和COUNT_RESET。

mysql> SELECT * FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE NAME="dml_inserts"\G
*************************** 1. row ***************************
           NAME: dml_inserts
      SUBSYSTEM: dml
          COUNT: 3
      MAX_COUNT: 3
      MIN_COUNT: NULL
      AVG_COUNT: 0.00980392156862745
    COUNT_RESET: 3
MAX_COUNT_RESET: 3
MIN_COUNT_RESET: NULL
AVG_COUNT_RESET: NULL
   TIME_ENABLED: 2024-01-09 16:40:33
  TIME_DISABLED: NULL
   TIME_ELAPSED: 306
     TIME_RESET: NULL
         STATUS: enabled
           TYPE: status_counter
        COMMENT: Number of rows inserted
1 row in set (0.00 sec)

6.重置dml_inserts计数器,然后再次在INNODB_METRICS表中查询dml_inserts计数器数据。之前报告的%_RESET值,如COUNT_RESET和MAX_RESET,将重置为零。COUNT、MAX_COUNT和AVG_COUNT等值从计数器启用时开始收集数据,这些值不受重置的影响。

mysql> SET GLOBAL innodb_monitor_disable=dml_inserts;
Query OK, 0 rows affected (0.00 sec)

mysql> SELECT * FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE NAME="dml_inserts"\G
*************************** 1. row ***************************
           NAME: dml_inserts
      SUBSYSTEM: dml
          COUNT: 20
      MAX_COUNT: 20
      MIN_COUNT: NULL
      AVG_COUNT: 0.03424657534246575
    COUNT_RESET: 0
MAX_COUNT_RESET: 0
MIN_COUNT_RESET: NULL
AVG_COUNT_RESET: 0
   TIME_ENABLED: 2024-01-09 16:40:33
  TIME_DISABLED: 2024-01-09 16:50:17
   TIME_ELAPSED: 584
     TIME_RESET: NULL
         STATUS: disabled
           TYPE: status_counter
        COMMENT: Number of rows inserted
1 row in set (0.00 sec)

7.要重置所有计数器值,必须首先禁用计数器。禁用计数器将状态值设置为禁用。

mysql> SET GLOBAL innodb_monitor_disable=dml_inserts;
Query OK, 0 rows affected (0.00 sec)

mysql> SELECT * FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE NAME="dml_inserts"\G
*************************** 1. row ***************************
           NAME: dml_inserts
      SUBSYSTEM: dml
          COUNT: 20
      MAX_COUNT: 20
      MIN_COUNT: NULL
      AVG_COUNT: 0.03076923076923077
    COUNT_RESET: 0
MAX_COUNT_RESET: 0
MIN_COUNT_RESET: NULL
AVG_COUNT_RESET: 0
   TIME_ENABLED: 2024-01-09 16:40:33
  TIME_DISABLED: 2024-01-09 16:51:23
   TIME_ELAPSED: 650
     TIME_RESET: NULL
         STATUS: disabled
           TYPE: status_counter
        COMMENT: Number of rows inserted
1 row in set (0.01 sec)

注意:
计数器和模块名称支持通配符匹配。例如,可以指定dml_i%,而不是指定完整的dml_inserts计数器名称。还可以使用通配符匹配一次启用、禁用或重置多个计数器或模块。例如,指定dml_%来启用、禁用或重置所有以dml_%开头的计数器。

8.当计数器被禁用后,你可以使用innodb_monitor_reset_all选项重置所有计数器的值。所有值都设置为0或NULL。

mysql> SET GLOBAL innodb_monitor_reset_all=dml_inserts;
Query OK, 0 rows affected (0.05 sec)

mysql> SELECT * FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE NAME="dml_inserts"\G
*************************** 1. row ***************************
           NAME: dml_inserts
      SUBSYSTEM: dml
          COUNT: 0
      MAX_COUNT: NULL
      MIN_COUNT: NULL
      AVG_COUNT: NULL
    COUNT_RESET: 0
MAX_COUNT_RESET: NULL
MIN_COUNT_RESET: NULL
AVG_COUNT_RESET: NULL
   TIME_ENABLED: NULL
  TIME_DISABLED: NULL
   TIME_ELAPSED: NULL
     TIME_RESET: NULL
         STATUS: disabled
           TYPE: status_counter
        COMMENT: Number of rows inserted
1 row in set (0.00 sec)
]]>
http://www.jydba.net/index.php/archives/3530/feed 0
MySQL InnoDB INFORMATION_SCHEMA缓冲池表 http://www.jydba.net/index.php/archives/3527 http://www.jydba.net/index.php/archives/3527#respond Tue, 09 Jan 2024 07:12:07 +0000 http://www.jydba.net/?p=3527 InnoDB INFORMATION_SCHEMA缓冲池表
InnoDB INFORMATION_SCHEMA缓冲池表提供了缓冲池状态信息和InnoDB缓冲池中页的元数据。这些表是在MySQL 5.6.2中引入的,后来移植到MySQL 5.5 (MySQL 5.5.28)和MySQL 5.1 (MySQL 5.1.66)。

InnoDB INFORMATION_SCHEMA缓冲池表包括下面这些表:

mysql> show tables from information_schema like 'INNODB_BUFFER%';
+-----------------------------------------------+
| Tables_in_information_schema (INNODB_BUFFER%) |
+-----------------------------------------------+
| INNODB_BUFFER_PAGE_LRU                        |
| INNODB_BUFFER_PAGE                            |
| INNODB_BUFFER_POOL_STATS                      |
+-----------------------------------------------+
3 rows in set (0.00 sec)

.INNODB_BUFFER_PAGE:保存InnoDB缓冲池中每一页的信息。

.INNODB_BUFFER_PAGE_LRU:保存了关于InnoDB缓冲池中页的信息,特别是它们在LRU列表中的排序方式,该列表决定了当缓冲池满时从缓冲池中清除哪些页。INNODB_BUFFER_PAGE_LRU表和INNODB_BUFFER_PAGE表有相同的列,不同的是INNODB_BUFFER_PAGE_LRU表有一个LRU_POSITION列而不是BLOCK_ID列。

.INNODB_BUFFER_POOL_STATS:缓冲池状态信息。大部分相同的信息由SHOW ENGINE INNODB STATUS输出提供,或者可以通过使用INNODB缓冲池服务器状态变量获得。

警示:
查询INNODB_BUFFER_PAGE表或INNODB_BUFFER_PAGE_LRU表会引入显著的性能开销。不要在生产系统上查询这些表,除非您意识到您的查询可能产生的性能影响,并确定它是可接受的。为了避免影响性能,在测试实例上重现您想要调查的问题,并在测试实例上运行您的查询。

查询INNODB_BUFFER_PAGE表中的系统数据
该查询通过排除TABLE_NAME值为NULL或包含表名中有斜杠/或句点.的表名表示用户自定义表,提供了包含系统数据的页面的大致数量。

mysql> select count(*) from information_schema.innodb_buffer_page
    -> where table_name is null or (instr(table_name, '/') = 0 and instr(table_name, '.') = 0);
+----------+
| count(*) |
+----------+
|   451428 |
+----------+
1 row in set (1.80 sec)

该查询返回包含系统数据的大约页数、缓冲池页数和包含系统数据的大约百分比的页数。

mysql> select
    -> (select count(*) from information_schema.innodb_buffer_page
    -> where table_name is null or (instr(table_name, '/') = 0 and instr(table_name, '.') = 0)
    -> ) as system_pages,
    -> (
    -> select count(*)
    -> from information_schema.innodb_buffer_page
    -> ) as total_pages,
    -> (
    -> select round((system_pages/total_pages) * 100)
    -> ) as system_page_percentage;
+--------------+-------------+------------------------+
| system_pages | total_pages | system_page_percentage |
+--------------+-------------+------------------------+
|       451428 |      524224 |                     86 |
+--------------+-------------+------------------------+
1 row in set (3.35 sec)

通过查询PAGE_TYPE的值,可以确定缓冲池中系统数据的类型。例如,下面的查询返回包含系统数据的页的10个不同的PAGE_TYPE值:

mysql> select distinct page_type from information_schema.innodb_buffer_page
    -> where table_name is null or (instr(table_name, '/') = 0 and instr(table_name, '.') = 0);
+-------------------+
| page_type         |
+-------------------+
| SYSTEM            |
| INODE             |
| IBUF_INDEX        |
| INDEX             |
| IBUF_BITMAP       |
| TRX_SYSTEM        |
| FILE_SPACE_HEADER |
| UNKNOWN           |
| UNDO_LOG          |
| EXTENT_DESCRIPTOR |
+-------------------+
10 rows in set (2.02 sec)

查询INNODB_BUFFER_PAGE表中的用户数据
这个查询通过统计TABLE_NAME值不为NULL且不像’%INNODB_SYS_TABLES%’的页面,提供了包含用户数据的页面的近似计数。

mysql> select count(*) from information_schema.innodb_buffer_page
    -> where table_name is not null and table_name not like '%innodb_sys_tables%';
+----------+
| count(*) |
+----------+
|    91067 |
+----------+
1 row in set (1.67 sec)

该查询返回包含用户数据的页面的大致数量、缓冲池页面的总数以及包含用户数据的页面的大致百分比。

mysql> select
    -> (select count(*) from information_schema.innodb_buffer_page
    -> where table_name is not null and (instr(table_name, '/') > 0 or instr(table_name, '.') > 0)
    -> ) as user_pages,
    -> (
    -> select count(*)
    -> from information_schema.innodb_buffer_page
    -> ) as total_pages,
    -> (
    -> select round((user_pages/total_pages) * 100)
    -> ) as user_page_percentage;
+------------+-------------+----------------------+
| user_pages | total_pages | user_page_percentage |
+------------+-------------+----------------------+
|      72796 |      524224 |                   14 |
+------------+-------------+----------------------+
1 row in set (3.31 sec)

这个查询将使用缓冲池中的页的用户定义的表标识出来:

mysql> select distinct table_name from information_schema.innodb_buffer_page
    -> where table_name is not null and (instr(table_name, '/') > 0 or instr(table_name, '.') > 0)
    -> and table_name not like '`mysql`.`innodb_%';
+--------------------------------------------------------+
| table_name                                             |
+--------------------------------------------------------+
| `undo`.`opening_lines`                                 |
| `undo`.`FTS_00000000000001d9_00000000000002da_INDEX_3` |
| `mysql`.`help_category`                                |
| `mysql`.`help_topic`                                   |
| `undo`.`big_table`                                     |
| `undo`.`key_block_size_4`                              |
| `sys`.`sys_config`                                     |
| `test`.`FTS_000000000000020c_DELETED_CACHE`            |
| `undo`.`FTS_00000000000001d9_BEING_DELETED`            |
| `undo`.`FTS_00000000000001d9_00000000000002da_INDEX_4` |
| `mysql`.`help_relation`                                |
| `undo`.`t8`                                            |
| `test`.`FTS_000000000000020c_0000000000000310_INDEX_1` |
| `mysql`.`slave_relay_log_info`                         |
| `undo`.`FTS_00000000000001d9_BEING_DELETED_CACHE`      |
| `undo`.`FTS_00000000000001d9_00000000000002da_INDEX_5` |
| `mysql`.`help_keyword`                                 |
| `undo`.`employees`                                     |
| `undo`.`t13`                                           |
| `test`.`FTS_000000000000020c_0000000000000310_INDEX_2` |
| `mysql`.`time_zone_name`                               |
| `mysql`.`slave_master_info`                            |
| `test`.`t7`                                            |
| `test`.`user`                                          |
| `undo`.`FTS_00000000000001d9_CONFIG`                   |
| `undo`.`FTS_00000000000001d9_00000000000002da_INDEX_6` |
| `undo`.`t9`                                            |
| `undo`.`t14`                                           |
| `test`.`articles`                                      |
| `test`.`FTS_000000000000020c_0000000000000310_INDEX_3` |
| `mysql`.`time_zone`                                    |
| `mysql`.`slave_worker_info`                            |
| `test`.`t8`                                            |
| `undo`.`FTS_00000000000001d9_DELETED`                  |
| `undo`.`t1`                                            |
| `undo`.`t10`                                           |
| `test`.`t1`                                            |
| `test`.`FTS_000000000000020c_BEING_DELETED`            |
| `test`.`FTS_000000000000020c_0000000000000310_INDEX_4` |
| `mysql`.`plugin`                                       |
| `mysql`.`gtid_executed`                                |
| `mysql`.`time_zone_transition`                         |
| `undo`.`FTS_00000000000001d9_DELETED_CACHE`            |
| `undo`.`t2`                                            |
| `undo`.`t11`                                           |
| `test`.`parent`                                        |
| `test`.`FTS_000000000000020c_BEING_DELETED_CACHE`      |
| `test`.`FTS_000000000000020c_0000000000000310_INDEX_5` |
| `mysql`.`server_cost`                                  |
| `mysql`.`time_zone_transition_type`                    |
| `mysql`.`servers`                                      |
| `undo`.`FTS_00000000000001d9_00000000000002da_INDEX_1` |
| `undo`.`t7`                                            |
| `test`.`child`                                         |
| `test`.`FTS_000000000000020c_CONFIG`                   |
| `test`.`FTS_000000000000020c_0000000000000310_INDEX_6` |
| `mysql`.`engine_cost`                                  |
| `mysql`.`time_zone_leap_second`                        |
| `undo`.`FTS_00000000000001d9_00000000000002da_INDEX_2` |
| `undo`.`t12`                                           |
| `test`.`abc`                                           |
| `test`.`FTS_000000000000020c_DELETED`                  |
+--------------------------------------------------------+
62 rows in set (1.81 sec)

查询INNODB_BUFFER_PAGE表中的索引数据
有关索引页的信息,请使用索引的名称查询INDEX_NAME列。例如,下面的查询返回在employees.salaries表上定义的emp_no索引的页数和总数据大小:

mysql> select index_name, count(*) as pages,
    -> round(sum(if(compressed_size = 0, @@global.innodb_page_size, compressed_size))/1024/1024)
    -> as 'total data (mb)'
    -> from information_schema.innodb_buffer_page
    -> where index_name='emp_no' and table_name = '`employees`.`salaries`';
+------------+-------+-----------------+
| index_name | pages | total data (mb) |
+------------+-------+-----------------+
| emp_no     |    44 |               1 |
+------------+-------+-----------------+
1 row in set (1.75 sec)

该查询返回在employees.salaries表上定义的所有索引的页数和总数据大小:

mysql> select index_name, count(*) as pages,
    -> round(sum(if(compressed_size = 0, @@global.innodb_page_size, compressed_size))/1024/1024)
    -> as 'total data (mb)'
    -> from information_schema.innodb_buffer_page
    -> where table_name = '`employees`.`salaries`'
    -> group by index_name;
+------------+-------+-----------------+
| index_name | pages | total data (mb) |
+------------+-------+-----------------+
| emp_no     |    44 |               1 |
| idx_salary |    65 |               1 |
| PRIMARY    |  6086 |              95 |
+------------+-------+-----------------+
3 rows in set (1.73 sec)

查询INNODB_BUFFER_PAGE_LRU表中的LRU_POSITION数据
INNODB_BUFFER_PAGE_LRU表保存了InnoDB缓冲池中页的信息,特别是当缓冲池满时,它们是如何排序的,这决定了哪些页需要从缓冲池中移除。该表的定义与INNODB_BUFFER_PAGE表相同,不同之处在于该表有一个LRU_POSITION列而不是BLOCK_ID列。

该查询计算LRU链表中特定位置上employees.employees表所使用的页数:

mysql> select count(lru_position) from information_schema.innodb_buffer_page_lru
    -> where table_name='`employees`.`employees`' and lru_position < 6570;
+---------------------+
| count(lru_position) |
+---------------------+
|                  13 |
+---------------------+
1 row in set (0.58 sec)

查询INNODB_BUFFER_POOL_STATS表
INNODB_BUFFER_POOL_STATS表提供了类似于SHOW ENGINE INNODB STATUS和INNODB缓冲池状态变量的信息。

mysql> select * from information_schema.innodb_buffer_pool_stats \G
*************************** 1. row ***************************
                         POOL_ID: 0
                       POOL_SIZE: 65528
                    FREE_BUFFERS: 46471
                  DATABASE_PAGES: 17936
              OLD_DATABASE_PAGES: 6640
         MODIFIED_DATABASE_PAGES: 0
              PENDING_DECOMPRESS: 4480
                   PENDING_READS: 0
               PENDING_FLUSH_LRU: 0
              PENDING_FLUSH_LIST: 0
                PAGES_MADE_YOUNG: 16823
            PAGES_NOT_MADE_YOUNG: 19769
           PAGES_MADE_YOUNG_RATE: 0
       PAGES_MADE_NOT_YOUNG_RATE: 0
               NUMBER_PAGES_READ: 857
            NUMBER_PAGES_CREATED: 17087
            NUMBER_PAGES_WRITTEN: 24505
                 PAGES_READ_RATE: 0
               PAGES_CREATE_RATE: 0
              PAGES_WRITTEN_RATE: 0
                NUMBER_PAGES_GET: 3448729
                        HIT_RATE: 0
    YOUNG_MAKE_PER_THOUSAND_GETS: 0
NOT_YOUNG_MAKE_PER_THOUSAND_GETS: 0
         NUMBER_PAGES_READ_AHEAD: 768
       NUMBER_READ_AHEAD_EVICTED: 0
                 READ_AHEAD_RATE: 0
         READ_AHEAD_EVICTED_RATE: 0
                    LRU_IO_TOTAL: 0
                  LRU_IO_CURRENT: 0
                UNCOMPRESS_TOTAL: 0
              UNCOMPRESS_CURRENT: 0
*************************** 2. row ***************************
                         POOL_ID: 1
                       POOL_SIZE: 65528
                    FREE_BUFFERS: 47000
                  DATABASE_PAGES: 17515
              OLD_DATABASE_PAGES: 6485
         MODIFIED_DATABASE_PAGES: 0
              PENDING_DECOMPRESS: 4051
                   PENDING_READS: 0
               PENDING_FLUSH_LRU: 0
              PENDING_FLUSH_LIST: 0
                PAGES_MADE_YOUNG: 0
            PAGES_NOT_MADE_YOUNG: 0
           PAGES_MADE_YOUNG_RATE: 0
       PAGES_MADE_NOT_YOUNG_RATE: 0
               NUMBER_PAGES_READ: 864
            NUMBER_PAGES_CREATED: 16651
            NUMBER_PAGES_WRITTEN: 23771
                 PAGES_READ_RATE: 0
               PAGES_CREATE_RATE: 0
              PAGES_WRITTEN_RATE: 0
                NUMBER_PAGES_GET: 5410983
                        HIT_RATE: 0
    YOUNG_MAKE_PER_THOUSAND_GETS: 0
NOT_YOUNG_MAKE_PER_THOUSAND_GETS: 0
         NUMBER_PAGES_READ_AHEAD: 832
       NUMBER_READ_AHEAD_EVICTED: 0
                 READ_AHEAD_RATE: 0
         READ_AHEAD_EVICTED_RATE: 0
                    LRU_IO_TOTAL: 0
                  LRU_IO_CURRENT: 0
                UNCOMPRESS_TOTAL: 0
              UNCOMPRESS_CURRENT: 0
*************************** 3. row ***************************
                         POOL_ID: 2
                       POOL_SIZE: 65528
                    FREE_BUFFERS: 46659
                  DATABASE_PAGES: 17733
              OLD_DATABASE_PAGES: 6565
         MODIFIED_DATABASE_PAGES: 0
              PENDING_DECOMPRESS: 4544
                   PENDING_READS: 0
               PENDING_FLUSH_LRU: 0
              PENDING_FLUSH_LIST: 0
                PAGES_MADE_YOUNG: 0
            PAGES_NOT_MADE_YOUNG: 0
           PAGES_MADE_YOUNG_RATE: 0
       PAGES_MADE_NOT_YOUNG_RATE: 0
               NUMBER_PAGES_READ: 755
            NUMBER_PAGES_CREATED: 16978
            NUMBER_PAGES_WRITTEN: 23908
                 PAGES_READ_RATE: 0
               PAGES_CREATE_RATE: 0
              PAGES_WRITTEN_RATE: 0
                NUMBER_PAGES_GET: 3462987
                        HIT_RATE: 0
    YOUNG_MAKE_PER_THOUSAND_GETS: 0
NOT_YOUNG_MAKE_PER_THOUSAND_GETS: 0
         NUMBER_PAGES_READ_AHEAD: 640
       NUMBER_READ_AHEAD_EVICTED: 0
                 READ_AHEAD_RATE: 0
         READ_AHEAD_EVICTED_RATE: 0
                    LRU_IO_TOTAL: 0
                  LRU_IO_CURRENT: 0
                UNCOMPRESS_TOTAL: 0
              UNCOMPRESS_CURRENT: 0
*************************** 4. row ***************************
                         POOL_ID: 3
                       POOL_SIZE: 65528
                    FREE_BUFFERS: 46644
                  DATABASE_PAGES: 17751
              OLD_DATABASE_PAGES: 6572
         MODIFIED_DATABASE_PAGES: 0
              PENDING_DECOMPRESS: 4528
                   PENDING_READS: 0
               PENDING_FLUSH_LRU: 0
              PENDING_FLUSH_LIST: 0
                PAGES_MADE_YOUNG: 2251
            PAGES_NOT_MADE_YOUNG: 17746
           PAGES_MADE_YOUNG_RATE: 0
       PAGES_MADE_NOT_YOUNG_RATE: 0
               NUMBER_PAGES_READ: 802
            NUMBER_PAGES_CREATED: 16961
            NUMBER_PAGES_WRITTEN: 23848
                 PAGES_READ_RATE: 0
               PAGES_CREATE_RATE: 0
              PAGES_WRITTEN_RATE: 0
                NUMBER_PAGES_GET: 4188354
                        HIT_RATE: 0
    YOUNG_MAKE_PER_THOUSAND_GETS: 0
NOT_YOUNG_MAKE_PER_THOUSAND_GETS: 0
         NUMBER_PAGES_READ_AHEAD: 768
       NUMBER_READ_AHEAD_EVICTED: 0
                 READ_AHEAD_RATE: 0
         READ_AHEAD_EVICTED_RATE: 0
                    LRU_IO_TOTAL: 0
                  LRU_IO_CURRENT: 0
                UNCOMPRESS_TOTAL: 0
              UNCOMPRESS_CURRENT: 0
*************************** 5. row ***************************
                         POOL_ID: 4
                       POOL_SIZE: 65528
                    FREE_BUFFERS: 46660
                  DATABASE_PAGES: 17729
              OLD_DATABASE_PAGES: 6564
         MODIFIED_DATABASE_PAGES: 0
              PENDING_DECOMPRESS: 4550
                   PENDING_READS: 0
               PENDING_FLUSH_LRU: 0
              PENDING_FLUSH_LIST: 0
                PAGES_MADE_YOUNG: 0
            PAGES_NOT_MADE_YOUNG: 0
           PAGES_MADE_YOUNG_RATE: 0
       PAGES_MADE_NOT_YOUNG_RATE: 0
               NUMBER_PAGES_READ: 792
            NUMBER_PAGES_CREATED: 16937
            NUMBER_PAGES_WRITTEN: 24222
                 PAGES_READ_RATE: 0
               PAGES_CREATE_RATE: 0
              PAGES_WRITTEN_RATE: 0
                NUMBER_PAGES_GET: 4314265
                        HIT_RATE: 0
    YOUNG_MAKE_PER_THOUSAND_GETS: 0
NOT_YOUNG_MAKE_PER_THOUSAND_GETS: 0
         NUMBER_PAGES_READ_AHEAD: 768
       NUMBER_READ_AHEAD_EVICTED: 0
                 READ_AHEAD_RATE: 0
         READ_AHEAD_EVICTED_RATE: 0
                    LRU_IO_TOTAL: 0
                  LRU_IO_CURRENT: 0
                UNCOMPRESS_TOTAL: 0
              UNCOMPRESS_CURRENT: 0
*************************** 6. row ***************************
                         POOL_ID: 5
                       POOL_SIZE: 65528
                    FREE_BUFFERS: 46748
                  DATABASE_PAGES: 17642
              OLD_DATABASE_PAGES: 6532
         MODIFIED_DATABASE_PAGES: 0
              PENDING_DECOMPRESS: 4548
                   PENDING_READS: 0
               PENDING_FLUSH_LRU: 0
              PENDING_FLUSH_LIST: 0
                PAGES_MADE_YOUNG: 0
            PAGES_NOT_MADE_YOUNG: 0
           PAGES_MADE_YOUNG_RATE: 0
       PAGES_MADE_NOT_YOUNG_RATE: 0
               NUMBER_PAGES_READ: 790
            NUMBER_PAGES_CREATED: 16852
            NUMBER_PAGES_WRITTEN: 23741
                 PAGES_READ_RATE: 0
               PAGES_CREATE_RATE: 0
              PAGES_WRITTEN_RATE: 0
                NUMBER_PAGES_GET: 3449085
                        HIT_RATE: 0
    YOUNG_MAKE_PER_THOUSAND_GETS: 0
NOT_YOUNG_MAKE_PER_THOUSAND_GETS: 0
         NUMBER_PAGES_READ_AHEAD: 768
       NUMBER_READ_AHEAD_EVICTED: 0
                 READ_AHEAD_RATE: 0
         READ_AHEAD_EVICTED_RATE: 0
                    LRU_IO_TOTAL: 0
                  LRU_IO_CURRENT: 0
                UNCOMPRESS_TOTAL: 0
              UNCOMPRESS_CURRENT: 0
*************************** 7. row ***************************
                         POOL_ID: 6
                       POOL_SIZE: 65528
                    FREE_BUFFERS: 46821
                  DATABASE_PAGES: 17571
              OLD_DATABASE_PAGES: 6506
         MODIFIED_DATABASE_PAGES: 0
              PENDING_DECOMPRESS: 4544
                   PENDING_READS: 0
               PENDING_FLUSH_LRU: 0
              PENDING_FLUSH_LIST: 0
                PAGES_MADE_YOUNG: 0
            PAGES_NOT_MADE_YOUNG: 0
           PAGES_MADE_YOUNG_RATE: 0
       PAGES_MADE_NOT_YOUNG_RATE: 0
               NUMBER_PAGES_READ: 727
            NUMBER_PAGES_CREATED: 16844
            NUMBER_PAGES_WRITTEN: 24005
                 PAGES_READ_RATE: 0
               PAGES_CREATE_RATE: 0
              PAGES_WRITTEN_RATE: 0
                NUMBER_PAGES_GET: 3852166
                        HIT_RATE: 0
    YOUNG_MAKE_PER_THOUSAND_GETS: 0
NOT_YOUNG_MAKE_PER_THOUSAND_GETS: 0
         NUMBER_PAGES_READ_AHEAD: 704
       NUMBER_READ_AHEAD_EVICTED: 0
                 READ_AHEAD_RATE: 0
         READ_AHEAD_EVICTED_RATE: 0
                    LRU_IO_TOTAL: 0
                  LRU_IO_CURRENT: 0
                UNCOMPRESS_TOTAL: 0
              UNCOMPRESS_CURRENT: 0
*************************** 8. row ***************************
                         POOL_ID: 7
                       POOL_SIZE: 65528
                    FREE_BUFFERS: 46651
                  DATABASE_PAGES: 17749
              OLD_DATABASE_PAGES: 6571
         MODIFIED_DATABASE_PAGES: 0
              PENDING_DECOMPRESS: 4512
                   PENDING_READS: 0
               PENDING_FLUSH_LRU: 0
              PENDING_FLUSH_LIST: 0
                PAGES_MADE_YOUNG: 0
            PAGES_NOT_MADE_YOUNG: 0
           PAGES_MADE_YOUNG_RATE: 0
       PAGES_MADE_NOT_YOUNG_RATE: 0
               NUMBER_PAGES_READ: 804
            NUMBER_PAGES_CREATED: 16945
            NUMBER_PAGES_WRITTEN: 23958
                 PAGES_READ_RATE: 0
               PAGES_CREATE_RATE: 0
              PAGES_WRITTEN_RATE: 0
                NUMBER_PAGES_GET: 3606901
                        HIT_RATE: 0
    YOUNG_MAKE_PER_THOUSAND_GETS: 0
NOT_YOUNG_MAKE_PER_THOUSAND_GETS: 0
         NUMBER_PAGES_READ_AHEAD: 768
       NUMBER_READ_AHEAD_EVICTED: 0
                 READ_AHEAD_RATE: 0
         READ_AHEAD_EVICTED_RATE: 0
                    LRU_IO_TOTAL: 0
                  LRU_IO_CURRENT: 0
                UNCOMPRESS_TOTAL: 0
              UNCOMPRESS_CURRENT: 0
8 rows in set (0.00 sec)

为了比较,SHOW ENGINE INNODB STATUS输出和INNODB缓冲池状态变量输出如下所示,基于相同的数据集。

mysql> show engine innodb status \G
......

----------------------
BUFFER POOL AND MEMORY
----------------------
Total large memory allocated 8795455488
Dictionary memory allocated 519969
Buffer pool size   524224
Free buffers       373654
Database pages     141626
Old database pages 52435
Modified db pages  0
Pending reads      0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 19074, not young 37515
0.00 youngs/s, 0.00 non-youngs/s
Pages read 6391, created 135255, written 191958
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
No buffer pool page gets since the last printout
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 141626, unzip_LRU len: 35757
I/O sum[0]:cur[0], unzip sum[0]:cur[0]
----------------------
INDIVIDUAL BUFFER POOL INFO
----------------------
---BUFFER POOL 0
Buffer pool size   65528
Free buffers       46471
Database pages     17936
Old database pages 6640
Modified db pages  0
Pending reads      0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 16823, not young 19769
0.00 youngs/s, 0.00 non-youngs/s
Pages read 857, created 17087, written 24505
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
No buffer pool page gets since the last printout
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 17936, unzip_LRU len: 4480
I/O sum[0]:cur[0], unzip sum[0]:cur[0]
---BUFFER POOL 1
Buffer pool size   65528
Free buffers       47000
Database pages     17515
Old database pages 6485
Modified db pages  0
Pending reads      0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 0, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 864, created 16651, written 23771
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
No buffer pool page gets since the last printout
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 17515, unzip_LRU len: 4051
I/O sum[0]:cur[0], unzip sum[0]:cur[0]
---BUFFER POOL 2
Buffer pool size   65528
Free buffers       46659
Database pages     17733
Old database pages 6565
Modified db pages  0
Pending reads      0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 0, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 755, created 16978, written 23908
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
No buffer pool page gets since the last printout
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 17733, unzip_LRU len: 4544
I/O sum[0]:cur[0], unzip sum[0]:cur[0]
---BUFFER POOL 3
Buffer pool size   65528
Free buffers       46644
Database pages     17751
Old database pages 6572
Modified db pages  0
Pending reads      0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 2251, not young 17746
0.00 youngs/s, 0.00 non-youngs/s
Pages read 802, created 16961, written 23848
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
No buffer pool page gets since the last printout
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 17751, unzip_LRU len: 4528
I/O sum[0]:cur[0], unzip sum[0]:cur[0]
---BUFFER POOL 4
Buffer pool size   65528
Free buffers       46660
Database pages     17729
Old database pages 6564
Modified db pages  0
Pending reads      0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 0, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 792, created 16937, written 24222
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
No buffer pool page gets since the last printout
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 17729, unzip_LRU len: 4550
I/O sum[0]:cur[0], unzip sum[0]:cur[0]
---BUFFER POOL 5
Buffer pool size   65528
Free buffers       46748
Database pages     17642
Old database pages 6532
Modified db pages  0
Pending reads      0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 0, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 790, created 16852, written 23741
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
No buffer pool page gets since the last printout
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 17642, unzip_LRU len: 4548
I/O sum[0]:cur[0], unzip sum[0]:cur[0]
---BUFFER POOL 6
Buffer pool size   65528
Free buffers       46821
Database pages     17571
Old database pages 6506
Modified db pages  0
Pending reads      0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 0, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 727, created 16844, written 24005
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
No buffer pool page gets since the last printout
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 17571, unzip_LRU len: 4544
I/O sum[0]:cur[0], unzip sum[0]:cur[0]
---BUFFER POOL 7
Buffer pool size   65528
Free buffers       46651
Database pages     17749
Old database pages 6571
Modified db pages  0
Pending reads      0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 0, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 804, created 16945, written 23958
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
No buffer pool page gets since the last printout
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 17749, unzip_LRU len: 4512
I/O sum[0]:cur[0], unzip sum[0]:cur[0]
......


mysql> show status like 'Innodb_buffer%';
+---------------------------------------+--------------------------------------------------+
| Variable_name                         | Value                                            |
+---------------------------------------+--------------------------------------------------+
| Innodb_buffer_pool_dump_status        | Dumping of buffer pool not started               |
| Innodb_buffer_pool_load_status        | Buffer pool(s) load completed at 230510  9:02:54 |
| Innodb_buffer_pool_resize_status      |                                                  |
| Innodb_buffer_pool_pages_data         | 141626                                           |
| Innodb_buffer_pool_bytes_data         | 2466910208                                       |
| Innodb_buffer_pool_pages_dirty        | 0                                                |
| Innodb_buffer_pool_bytes_dirty        | 0                                                |
| Innodb_buffer_pool_pages_flushed      | 154983                                           |
| Innodb_buffer_pool_pages_free         | 373654                                           |
| Innodb_buffer_pool_pages_misc         | 8944                                             |
| Innodb_buffer_pool_pages_total        | 524224                                           |
| Innodb_buffer_pool_read_ahead_rnd     | 0                                                |
| Innodb_buffer_pool_read_ahead         | 6016                                             |
| Innodb_buffer_pool_read_ahead_evicted | 0                                                |
| Innodb_buffer_pool_read_requests      | 31733470                                         |
| Innodb_buffer_pool_reads              | 376                                              |
| Innodb_buffer_pool_wait_free          | 0                                                |
| Innodb_buffer_pool_write_requests     | 15535407                                         |
+---------------------------------------+--------------------------------------------------+
18 rows in set (0.01 sec)
]]>
http://www.jydba.net/index.php/archives/3527/feed 0
MySQL InnoDB INFORMATION_SCHEMA全文索引表 http://www.jydba.net/index.php/archives/3524 http://www.jydba.net/index.php/archives/3524#respond Thu, 04 Jan 2024 07:08:20 +0000 http://www.jydba.net/?p=3524 InnoDB INFORMATION_SCHEMA全文索引表
随着MySQL 5.6.4对InnoDB表的全文索引支持的引入,以下表被添加到INFORMATION_SCHEMA数据库中:

mysql> show tables from information_schema like 'INNODB_FT%';
+-------------------------------------------+
| Tables_in_information_schema (INNODB_FT%) |
+-------------------------------------------+
| INNODB_FT_CONFIG                          |
| INNODB_FT_BEING_DELETED                   |
| INNODB_FT_DELETED                         |
| INNODB_FT_DEFAULT_STOPWORD                |
| INNODB_FT_INDEX_TABLE                     |
| INNODB_FT_INDEX_CACHE                     |
+-------------------------------------------+
6 rows in set (0.00 sec)

.INNODB_FT_CONFIG:显示关于InnoDB表的全文索引和相关处理的元数据。

.INNODB_FT_BEING_DELETED:提供INNODB_FT_DELETED表的快照,仅在使用optimizer table执行维护时使用。当OPTIMIZE TABLE运行时,INNODB_FT_BEING_DELETED表被清空,doc_id从INNODB_FT_DELETED表中移除。因为INNODB_FT_BEING_DELETED的内容的生命周期通常很短,所以该表在监控或调试方面的用途有限。

.INNODB_FT_DELETED:从InnoDB表的全文索引中删除的记录。为了避免在DML操作中对InnoDB全文索引进行昂贵的索引重组,新删除的单词的信息被单独存储,在执行文本搜索时从搜索结果中过滤,并且只有在运行OPTIMIZE TABLE时才从主搜索索引中删除。

.INNODB_FT_DEFAULT_STOPWORD:保存在创建全文索引时默认使用的停用词列表。

.INNODB_FT_INDEX_TABLE:包含用于处理全文索引的文本搜索的倒排索引的数据。

.INNODB_FT_INDEX_CACHE:包含新插入的行在全文索引中的标记信息。为了避免DML操作过程中昂贵的索引重组,新索引词的信息被单独存储,并仅在优化表运行时、服务器关闭时或缓存大小超过innodb_ft_cache_size或innodb_ft_total_cache_size定义的限制时才与主搜索索引结合。

注意:
除了INNODB_FT_DEFAULT_STOPWORD表,你必须将innodb_ft_aux_table配置变量设置为包含全文索引的表名(database_name/table_name)。否则,InnoDB的全文索引INFORMATION_SCHEMA表显示为空。

InnoDB全文索引INFORMATION_SCHEMA表
这个例子使用一个带全文索引的表来演示全文索引INFORMATION_SCHEMA表中包含的数据。
1.创建一个包含全文索引的表并插入一些数据:

mysql> create table articles (
    -> id int unsigned auto_increment not null primary key,
    -> title varchar(200),
    -> body text,
    -> fulltext (title,body)
    -> ) engine=innodb;
Query OK, 0 rows affected (0.05 sec)

mysql> insert into articles (title,body) values
    -> ('MySQL Tutorial','DBMS stands for DataBase ...'),
    -> ('How To Use MySQL Well','After you went through a ...'),
    -> ('Optimizing MySQL','In this tutorial we will show ...'),
    -> ('1001 MySQL Tricks','1. Never run mysqld as root. 2. ...'),
    -> ('MySQL vs. YourSQL','In the following database comparison ...'),
    -> ('MySQL Security','When configured properly, MySQL ...');
Query OK, 6 rows affected (0.01 sec)
Records: 6  Duplicates: 0  Warnings: 0

2.设置innodb_ft_aux_table变量为FULLTEXT索引表的名称。如果没有设置这个变量,除了INNODB_FT_DEFAULT_STOPWORD表之外,InnoDB的FULLTEXT INFORMATION_SCHEMA表将显示为空。

mysql> set global innodb_ft_aux_table = 'test/articles';
Query OK, 0 rows affected (0.00 sec)

mysql> show variables like '%aux_table%';
+---------------------+---------------+
| Variable_name       | Value         |
+---------------------+---------------+
| innodb_ft_aux_table | test/articles |
+---------------------+---------------+
1 row in set (0.01 sec)

3.查询INNODB_FT_INDEX_CACHE表,它显示了在全文索引中新插入的行信息。为了避免DML操作期间昂贵的索引重组,新插入行的数据将保留在全文索引缓存中,直到优化表运行(或直到服务器关闭或超过缓存限制)。

mysql> select * from information_schema.innodb_ft_index_cache limit 5;
+------------+--------------+-------------+-----------+--------+----------+
| WORD       | FIRST_DOC_ID | LAST_DOC_ID | DOC_COUNT | DOC_ID | POSITION |
+------------+--------------+-------------+-----------+--------+----------+
| 1001       |            5 |           5 |         1 |      5 |        0 |
| after      |            3 |           3 |         1 |      3 |       22 |
| comparison |            6 |           6 |         1 |      6 |       44 |
| configured |            7 |           7 |         1 |      7 |       20 |
| database   |            2 |           6 |         2 |      2 |       31 |
+------------+--------------+-------------+-----------+--------+----------+
5 rows in set (0.00 sec)

4.启用innodb_optimize_fulltext_only,在包含全文索引的表上运行OPTIMIZE TABLE。此操作将全文索引缓存的内容刷新到主全文索引。innodb_optimize_fulltext_only改变了optimize_table语句在InnoDB表上的操作方式,并且是在对带有全文索引的InnoDB表进行维护操作时临时启用的。

mysql> SET GLOBAL innodb_optimize_fulltext_only=ON;
Query OK, 0 rows affected (0.00 sec)

mysql> show variables like 'innodb_optimize_fulltext_only';
+-------------------------------+-------+
| Variable_name                 | Value |
+-------------------------------+-------+
| innodb_optimize_fulltext_only | ON    |
+-------------------------------+-------+
1 row in set (0.01 sec)


mysql> optimize table articles;
+---------------+----------+----------+----------+
| Table         | Op       | Msg_type | Msg_text |
+---------------+----------+----------+----------+
| test.articles | optimize | status   | OK       |
+---------------+----------+----------+----------+
1 row in set (0.01 sec)

5.查询INNODB_FT_INDEX_TABLE表,查看主要全文索引中的数据信息,包括刚刚从全文索引缓存中刷新的数据信息。

mysql> select * from information_schema.innodb_ft_index_table limit 5;
+------------+--------------+-------------+-----------+--------+----------+
| WORD       | FIRST_DOC_ID | LAST_DOC_ID | DOC_COUNT | DOC_ID | POSITION |
+------------+--------------+-------------+-----------+--------+----------+
| 1001       |            5 |           5 |         1 |      5 |        0 |
| after      |            3 |           3 |         1 |      3 |       22 |
| comparison |            6 |           6 |         1 |      6 |       44 |
| configured |            7 |           7 |         1 |      7 |       20 |
| database   |            2 |           6 |         2 |      2 |       31 |
+------------+--------------+-------------+-----------+--------+----------+
5 rows in set (0.00 sec)

INNODB_FT_INDEX_CACHE表现在是空的,因为优化表操作刷新了全文索引缓存。

mysql> select * from information_schema.innodb_ft_index_cache limit 5;
Empty set (0.00 sec)

6.从test/articles表中删除一些记录。

mysql> delete from test.articles where id < 4;
Query OK, 3 rows affected (0.01 sec)

7.查询INNODB_FT_DELETED表。该表记录从全文索引中删除的行。为了避免DML操作期间昂贵的索引重组,新删除记录的信息被单独存储,在进行文本搜索时从搜索结果中过滤,在运行OPTIMIZE TABLE时从主搜索索引中删除。

mysql> select * from information_schema.innodb_ft_deleted;
+--------+
| DOC_ID |
+--------+
|      2 |
|      3 |
|      4 |
+--------+
3 rows in set (0.01 sec)

8.运行OPTIMIZE TABLE删除删除的记录。

mysql> optimize table articles;
+---------------+----------+----------+----------+
| Table         | Op       | Msg_type | Msg_text |
+---------------+----------+----------+----------+
| test.articles | optimize | status   | OK       |
+---------------+----------+----------+----------+
1 row in set (0.03 sec)

INNODB_FT_DELETED表现在应该是空的。

mysql> select * from information_schema.innodb_ft_deleted;
Empty set (0.00 sec)

9.查询INNODB_FT_CONFIG表。该表包含关于全文索引和相关处理的元数据:
.optimize_checkpoint_limit是optimize table运行结束的秒数。

.synced_doc_id是下一个要发布的DOC_ID。

.stopword_table_name是用户定义的停止词表的数据库/表名。如果没有用户定义的停用词表,该字段显示为空。

.use_stopword表示是否使用stopword表,stopword表在创建FULLTEXT索引时定义。

mysql> select * from information_schema.innodb_ft_config;
+---------------------------+-------+
| KEY                       | VALUE |
+---------------------------+-------+
| optimize_checkpoint_limit | 180   |
| synced_doc_id             | 8     |
| stopword_table_name       |       |
| use_stopword              | 1     |
+---------------------------+-------+
4 rows in set (0.00 sec)
]]>
http://www.jydba.net/index.php/archives/3524/feed 0
MySQL InnoDB INFORMATION_SCHEMA系统表 http://www.jydba.net/index.php/archives/3521 http://www.jydba.net/index.php/archives/3521#respond Tue, 02 Jan 2024 07:04:23 +0000 http://www.jydba.net/?p=3521 InnoDB INFORMATION_SCHEMA系统表
你可以使用InnoDB INFORMATION_SCHEMA系统表来提取由InnoDB管理的schema对象的元数据。这些信息来自InnoDB内部的系统表(也称为InnoDB数据字典),它不能像普通的InnoDB表那样直接查询。传统上,你可以使用InnoDB监视器技术来获取这类信息,设置InnoDB监视器并解析SHOW ENGINE InnoDB STATUS语句的输出。InnoDB INFORMATION_SCHEMA表接口允许你使用SQL查询这些数据。

除了INNODB_SYS_TABLESTATS没有对应的内部系统表外,InnoDB INFORMATION_SCHEMA系统表中的数据都是直接从InnoDB内部系统表中读取的,而不是从内存中缓存的元数据中读取。

InnoDB INFORMATION_SCHEMA系统表包括下面列出的表。INNODB_SYS_DATAFILES和INNODB_SYS_TABLESPACES是在MySQL 5.6.6中添加的,引入了对CREATE TABLE语句中的DATA DIRECTORY=’ DIRECTORY ‘子句的支持,它允许InnoDB file-per-table表空间(在MySQL数据目录之外的位置创建ibd文件。

mysql> SHOW TABLES FROM INFORMATION_SCHEMA LIKE 'INNODB_SYS%';
+--------------------------------------------+
| Tables_in_information_schema (INNODB_SYS%) |
+--------------------------------------------+
| INNODB_SYS_DATAFILES                       |
| INNODB_SYS_VIRTUAL                         |
| INNODB_SYS_INDEXES                         |
| INNODB_SYS_TABLES                          |
| INNODB_SYS_FIELDS                          |
| INNODB_SYS_TABLESPACES                     |
| INNODB_SYS_FOREIGN_COLS                    |
| INNODB_SYS_COLUMNS                         |
| INNODB_SYS_FOREIGN                         |
| INNODB_SYS_TABLESTATS                      |
+--------------------------------------------+
10 rows in set (0.00 sec)

表名表明所提供的数据类型:
.INNODB_SYS_TABLES提供关于InnoDB表的元数据,等价于InnoDB数据字典中的SYS_TABLES表中的信息。

.INNODB_SYS_COLUMNS提供关于InnoDB表列的元数据,等价于InnoDB数据字典中的SYS_COLUMNS表中的信息。

.INNODB_SYS_INDEXES提供有关InnoDB索引的元数据,等价于InnoDB数据字典中的SYS_INDEXES表中的信息。

.INNODB_SYS_FIELDS提供了InnoDB索引中关键列(字段)的元数据,等价于InnoDB数据字典中的SYS_FIELDS表中的信息。

.INNODB_SYS_TABLESTATS提供了关于InnoDB表的底层状态信息的视图,这些状态信息来源于内存中的数据结构。没有对应的内部InnoDB系统表。

.INNODB_SYS_DATAFILES提供了InnoDB file-per-table件和一般表空间的数据文件路径信息,等价于InnoDB数据字典中的SYS_DATAFILES表中的信息。

.INNODB_SYS_TABLESPACES提供了关于InnoDB file-per-table和一般表空间的元数据,等价于InnoDB数据字典中的SYS_TABLESPACES表中的信息。

.INNODB_SYS_FOREIGN提供了定义在InnoDB表上的外键的元数据,等价于InnoDB数据字典中的SYS_FOREIGN表中的信息。

.INNODB_SYS_FOREIGN_COLS提供了定义在InnoDB表中的外键列的元数据,等价于InnoDB数据字典中的SYS_FOREIGN_COLS表中的信息。

InnoDB INFORMATION_SCHEMA系统表可以通过TABLE_ID、INDEX_ID和SPACE等字段连接在一起,让你可以轻松地检索到你想要研究或监控的对象的所有可用数据。

这个例子使用一个简单的表(t1)和一个索引(i1)来展示在InnoDB INFORMATION_SCHEMA系统表中发现的元数据的类型。
1.创建表t1:

mysql> use test;
Database changed
mysql> create table t1 (
    -> col1 int,
    -> col2 char(10),
    -> col3 varchar(10))
    -> engine = innodb;
Query OK, 0 rows affected (0.04 sec)

mysql> create index i1 on t1(col1);
Query OK, 0 rows affected (0.02 sec)
Records: 0  Duplicates: 0  Warnings: 0

2.创建表t1后,查询innodb_sys_tables来定位test/t1的元数据:

mysql> select * from information_schema.innodb_sys_tables where name='test/t1' \G
*************************** 1. row ***************************
     TABLE_ID: 509
         NAME: test/t1
         FLAG: 33
       N_COLS: 6
        SPACE: 508
  FILE_FORMAT: Barracuda
   ROW_FORMAT: Dynamic
ZIP_PAGE_SIZE: 0
   SPACE_TYPE: Single
1 row in set (0.01 sec)

表t1的TABLE_ID是509。FLAG字段提供了有关表格式和存储特性的位级别信息。有6列,其中3列是由InnoDB创建的隐藏列(DB_ROW_ID, DB_TRX_ID和DB_ROLL_PTR)。表空间的ID是508(值为0表示表驻留在system表空间中)。FILE_FORMAT是Barracuda格式,ROW_FORMAT是Dynamic格式。ZIP_PAGE_SIZE只适用于行格式压缩的表。

3.使用innodb_sys_tables中的table_id信息,查询innodb_sys_columns表中关于表的列的信息。

mysql> select * from information_schema.innodb_sys_columns where table_id = 509 \G
*************************** 1. row ***************************
TABLE_ID: 509
    NAME: col1
     POS: 0
   MTYPE: 6
  PRTYPE: 1027
     LEN: 4
*************************** 2. row ***************************
TABLE_ID: 509
    NAME: col2
     POS: 1
   MTYPE: 13
  PRTYPE: 2949374
     LEN: 40
*************************** 3. row ***************************
TABLE_ID: 509
    NAME: col3
     POS: 2
   MTYPE: 12
  PRTYPE: 2949135
     LEN: 40
3 rows in set (0.00 sec)

除了TABLE_ID和NAME列之外,INNODB_SYS_COLUMNS还提供了每列的序号位置(POS)(从0开始,顺序递增),列的MTYPE或“主类型”(6 = INT,13 = CHAR, 12 = VARCHAR), PRTYPE或“精确类型”(一个二进制值,用比特表示MySQL的数据类型,字符集代码和可空性),以及列的长度(LEN)。

4.再次使用innodb_sys_tables中的table_id信息,查询innodb_sys_indexes,获取与表t1相关的索引信息。

mysql> select * from information_schema.innodb_sys_indexes where table_id = 509 \G
*************************** 1. row ***************************
       INDEX_ID: 758
           NAME: GEN_CLUST_INDEX
       TABLE_ID: 509
           TYPE: 1
       N_FIELDS: 0
        PAGE_NO: 3
          SPACE: 508
MERGE_THRESHOLD: 50
*************************** 2. row ***************************
       INDEX_ID: 759
           NAME: i1
       TABLE_ID: 509
           TYPE: 0
       N_FIELDS: 1
        PAGE_NO: 4
          SPACE: 508
MERGE_THRESHOLD: 50
2 rows in set (0.01 sec)

INNODB_SYS_INDEXES返回两个索引的数据第一个索引是GEN_CLUST_INDEX,如果表没有用户定义的聚集索引,它是由InnoDB创建的聚集索引。第二个索引(i1)是用户定义的辅助索引。

INDEX_ID是索引的标识符,在一个实例中的所有数据库中都是唯一的。TABLE_ID标识了索引关联的表。索引TYPE值指示索引类型(1 =集群索引,0 =辅助索引)。n_fields值是组成索引的字段数目。PAGE_NO是索引B-tree的根页号,SPACE是索引所在的表空间ID。非零值表示索引不在系统表空间中。MERGE_THRESHOLD定义索引页中数据量的百分比阈值。当删除一行或者更新操作缩短一行时,如果索引页中的数据量低于这个值(默认值为50%),InnoDB会尝试将索引页与相邻的索引页合并。

5.使用innodb_sys_indexes中的index_id信息,查询innodb_sys_fields中索引i1的字段信息。

mysql> select * from information_schema.innodb_sys_fields where index_id = 759 \G
*************************** 1. row ***************************
INDEX_ID: 759
    NAME: col1
     POS: 0
1 row in set (0.01 sec)

INNODB_SYS_FIELDS提供了索引字段的名称及其在索引中的序号位置。如果索引(i1)定义在多个字段上,INNODB_SYS_FIELDS将为每个被索引的字段提供元数据。

6.使用innodb_sys_tables中的space信息,查询innodb_sys_tables]表获得关于表的表空间信息。

mysql> select * from information_schema.innodb_sys_tablespaces where space = 508 \G
*************************** 1. row ***************************
         SPACE: 508
          NAME: test/t1
          FLAG: 33
   FILE_FORMAT: Barracuda
    ROW_FORMAT: Dynamic
     PAGE_SIZE: 16384
 ZIP_PAGE_SIZE: 0
    SPACE_TYPE: Single
 FS_BLOCK_SIZE: 4096
     FILE_SIZE: 114688
ALLOCATED_SIZE: 114688
1 row in set (0.05 sec)

除了表空间的SPACE ID和关联表的NAME之外,INNODB_SYS_TABLESPACES还提供了表空间的FLAG数据,这是有关表空间格式和存储特性的位级别信息。还提供了表空间FILE_FORMAT、ROW_FORMAT、PAGE_SIZE和其他几个表空间元数据项。

7.再次使用INNODB_SYS_TABLES中的SPACE信息,查询INNODB_SYS_DATAFILES表空间数据文件的位置。

mysql> select * from information_schema.innodb_sys_datafiles where space = 508 \G
*************************** 1. row ***************************
SPACE: 508
 PATH: ./test/t1.ibd
1 row in set (0.00 sec)

该数据文件位于MySQL的data目录下的test目录中。如果使用CREATE TABLE语句的data directory子句在MySQL数据目录之外的位置创建一个file-per-table表空间,那么表空间路径将是一个完全限定的目录路径。

8.最后一步,在表t1 (TABLE_ID = 509)中插入一行,然后查看INNODB_SYS_TABLESTATS表中的数据。MySQL优化器使用该表中的数据来计算查询InnoDB表时使用的索引。该信息来源于内存中的数据结构。没有对应的内部InnoDB系统表。

mysql> insert into t1 values(5, 'abc', 'def');
Query OK, 1 row affected (0.00 sec)

mysql> select * from information_schema.innodb_sys_tablestats where table_id = 509 \G
*************************** 1. row ***************************
         TABLE_ID: 509
             NAME: test/t1
STATS_INITIALIZED: Initialized
         NUM_ROWS: 1
 CLUST_INDEX_SIZE: 1
 OTHER_INDEX_SIZE: 1
 MODIFIED_COUNTER: 1
          AUTOINC: 0
        REF_COUNT: 2
1 row in set (0.00 sec)

STATS_INITIALIZED字段表示是否收集了表的统计信息。NUM_ROWS是表中当前估计的行数。cluster_index_size和OTHER_INDEX_SIZE字段分别报告磁盘上为表存储集群索引和辅助索引的页数。MODIFIED_COUNTER值显示了由DML操作和来自外键的级联操作修改的行数。AUTOINC值是任何基于自动递增操作的下一个数字。在表t1中没有定义autoincrement列,因此值为0。REF_COUNT值是一个计数器。当计数器变为0时,表示表元数据可以从表缓存中移除。

外键信息_schema系统表
INNODB_SYS_FOREIGN和INNODB_SYS_FOREIGN_COLS表提供了有关外键关系的数据。这个例子使用具有外键关系的父表和子表来展示在INNODB_SYS_FOREIGN和INNODB_SYS_FOREIGN_COLS表中找到的数据。

1.创建包含父表和子表的测试数据库:

mysql> create table parent (id int not null,
    -> primary key (id)) engine=innodb;
Query OK, 0 rows affected (0.03 sec)

mysql> create table child (id int, parent_id int,
    -> index par_ind (parent_id),
    -> constraint fk1
    -> foreign key (parent_id) references parent(id)
    -> on delete cascade) engine=innodb;
Query OK, 0 rows affected (0.01 sec)

2.在创建父表和子表之后,查询INNODB_SYS_FOREIGN并找到test/child和test/parent外键关系的外键数据:

mysql> select * from information_schema.innodb_sys_foreign \G
*************************** 1. row ***************************
      ID: test/fk1
FOR_NAME: test/child
REF_NAME: test/parent
  N_COLS: 1
    TYPE: 1

元数据包括外键ID (fk1),它是根据在子表上定义的约束命名的。FOR_NAME是定义外键的子表的名称。REF_NAME是父表(被引用的表)的名称。N_COLS是外键索引中的列数。TYPE是一个数值,表示提供有关外键列的附加信息的位标志。在本例中,TYPE值为1,表示为外键指定了ON DELETE CASCADE选项。有关类型值的更多信息,请参阅INNODB_SYS_FOREIGN表定义。

3.使用外键ID,查询INNODB_SYS_FOREIGN_COLS来查看这个外键对应的列的数据。

mysql> select * from information_schema.innodb_sys_foreign_cols where id = 'test/fk1' \G
*************************** 1. row ***************************
          ID: test/fk1
FOR_COL_NAME: parent_id
REF_COL_NAME: id
         POS: 0
1 row in set (0.00 sec)

FOR_COL_NAME是子表中外键列的名称,REF_COL_NAME是父表中被引用的列的名称。POS值是键字段在外键索引中的顺序位置,从0开始。

连接InnoDB INFORMATION_SCHEMA系统表
这个例子展示了连接三个InnoDB INFORMATION_SCHEMA系统表(INNODB_SYS_TABLES、INNODB_SYS_TABLESPACES和INNODB_SYS_TABLESTATS)来收集employees sample数据库中表的文件格式、行格式、页面大小和索引大小信息。

mysql> select a.name, a.file_format, a.row_format,
    -> @page_size :=
    -> if(a.row_format='compressed',
    -> b.zip_page_size, b.page_size)
    -> as page_size,
    -> round((@page_size * c.clust_index_size)
    -> /(1024*1024)) as pk_mb,
    -> round((@page_size * c.other_index_size)
    -> /(1024*1024)) as secidx_mb
    -> from information_schema.innodb_sys_tables a
    -> inner join information_schema.innodb_sys_tablespaces b on a.name = b.name
    -> inner join information_schema.innodb_sys_tablestats c on b.name = c.name
    -> where a.name like 'employees/%'
    -> order by a.name desc;
+------------------------+-------------+------------+-----------+-------+-----------+
| name                   | file_format | row_format | page_size | pk_mb | secidx_mb |
+------------------------+-------------+------------+-----------+-------+-----------+
| employees/titles       | Barracuda   | Dynamic    |     16384 |     0 |         0 |
| employees/t            | Barracuda   | Dynamic    |     16384 |     0 |         0 |
| employees/salaries     | Barracuda   | Dynamic    |     16384 |     0 |         0 |
| employees/employees    | Barracuda   | Dynamic    |     16384 |     0 |         0 |
| employees/dept_manager | Barracuda   | Dynamic    |     16384 |     0 |         0 |
| employees/dept_emp     | Barracuda   | Dynamic    |     16384 |     0 |         0 |
| employees/departments  | Barracuda   | Dynamic    |     16384 |     0 |         0 |
| employees/c            | Barracuda   | Dynamic    |     16384 |     0 |         0 |
+------------------------+-------------+------------+-----------+-------+-----------+
8 rows in set (0.05 sec)

IF()控制流函数用于处理压缩表。如果表被压缩,则使用ZIP_PAGE_SIZE而不是PAGE_SIZE计算索引大小。cluster_index_size和OTHER_INDEX_SIZE以字节为单位,它们除以1024*1024,就得到了以兆字节(MBs)为单位的索引长度。使用ROUND()函数将MB值四舍五入为0个小数空格。

]]>
http://www.jydba.net/index.php/archives/3521/feed 0
MySQL使用InnoDB事务和锁信息识别阻塞事务 http://www.jydba.net/index.php/archives/3514 http://www.jydba.net/index.php/archives/3514#respond Sat, 21 Oct 2023 00:22:55 +0000 http://www.jydba.net/?p=3514 使用InnoDB事务和锁信息识别阻塞事务
有时识别哪些事务阻塞了另一个事务是有帮助的。包含InnoDB事务和数据锁信息的表使您能够确定哪个事务正在等待另一个事务,以及正在请求哪些资源。

假设有三个会话同时运行。每个会话对应于一个MySQL线程,并依次执行一个事务。考虑当这些会话发出以下语句,但还没有提交事务时,系统的状态:

.会话a

mysql> begin;
Query OK, 0 rows affected (0.00 sec)

mysql> select a from abc for update;
select sleep(100);+---+
| a |
+---+
| 1 |
+---+
1 row in set (0.01 sec)

mysql> select sleep(100);
+------------+
| sleep(100) |
+------------+
|          0 |
+------------+
1 row in set (1 min 40.00 sec)

.会话b

mysql> select a from abc for update;

.会话c

mysql> select a from abc for update;

在这种情况下,使用以下查询来查看哪些事务正在等待,哪些事务正在阻塞它们:

mysql> SELECT
    -> r.trx_id waiting_trx_id,
    -> r.trx_mysql_thread_id waiting_thread,
    -> r.trx_query waiting_query,
    -> b.trx_id blocking_trx_id,
    -> b.trx_mysql_thread_id blocking_thread,
    -> b.trx_query blocking_query
    -> FROM information_schema.innodb_lock_waits w
    -> INNER JOIN information_schema.innodb_trx b
    -> ON b.trx_id = w.blocking_trx_id
    -> INNER JOIN information_schema.innodb_trx r
    -> ON r.trx_id = w.requesting_trx_id;
+----------------+----------------+------------------------------+-----------------+-----------------+------------------------------+
| waiting_trx_id | waiting_thread | waiting_query                | blocking_trx_id | blocking_thread | blocking_query               |
+----------------+----------------+------------------------------+-----------------+-----------------+------------------------------+
| 5686612        |            174 | select a from abc for update | 5686611         |             173 | select a from abc for update |
| 5686612        |            174 | select a from abc for update | 5686610         |             172 | select sleep(100)            |
| 5686611        |            173 | select a from abc for update | 5686610         |             172 | select sleep(100)            |
+----------------+----------------+------------------------------+-----------------+-----------------+------------------------------+
3 rows in set, 1 warning (0.01 sec)

或者,更简单地,使用sys schema的innodb_lock_waits视图:

mysql> SELECT
    -> waiting_trx_id,
    -> waiting_pid,
    -> waiting_query,
    -> blocking_trx_id,
    -> blocking_pid,
    -> blocking_query
    -> FROM sys.innodb_lock_waits;
+----------------+-------------+------------------------------+-----------------+--------------+------------------------------+
| waiting_trx_id | waiting_pid | waiting_query                | blocking_trx_id | blocking_pid | blocking_query               |
+----------------+-------------+------------------------------+-----------------+--------------+------------------------------+
| 5686611        |         173 | select a from abc for update | 5686610         |          172 | select sleep(100)            |
| 5686612        |         174 | select a from abc for update | 5686611         |          173 | select a from abc for update |
| 5686612        |         174 | select a from abc for update | 5686610         |          172 | select sleep(100)            |
+----------------+-------------+------------------------------+-----------------+--------------+------------------------------+
3 rows in set, 3 warnings (0.08 sec)

在上面的查询结果中,你可以通过“等待查询”或“阻塞查询”列来识别会话。如你所见:
.会话b(trx_id 568661,线程号173)和会话c(trx id 5686612,线程号174)都在等待会话a(trx id 5686610,线程号172

.会话c正等待会话b和会话a

你可以在表INNODB_TRX、INNODB_LOCKS和INNODB_LOCK_WAITS中看到底层的数据。

下表是INFORMATION_SCHEMA.INNODB_TRX的一些示例内容。

mysql> select trx_id,trx_state,trx_started,trx_requested_lock_id,trx_wait_started,trx_weight,trx_mysql_thread_id,trx_query from information_schema.innodb_trx;
+-----------------+-----------+---------------------+-----------------------+---------------------+------------+---------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------+
| trx_id          | trx_state | trx_started         | trx_requested_lock_id | trx_wait_started    | trx_weight | trx_mysql_thread_id | trx_query                                                                                                                                              |
+-----------------+-----------+---------------------+-----------------------+---------------------+------------+---------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------+
| 5686614         | RUNNING   | 2023-12-11 16:39:57 | NULL                  | NULL                |          2 |                 172 | select sleep(100)                                                                                                                                      |
| 5686612         | LOCK WAIT | 2023-12-11 16:07:07 | 5686612:423:3:2       | 2023-12-11 16:40:07 |          2 |                 174 | select a from abc for update                                                                                                                           |
| 5686611         | LOCK WAIT | 2023-12-11 16:07:04 | 5686611:423:3:2       | 2023-12-11 16:40:04 |          2 |                 173 | select a from abc for update                                                                                                                           |
| 421200136110592 | RUNNING   | 2023-12-11 16:07:52 | NULL                  | NULL                |          0 |                 176 | select trx_id,trx_state,trx_started,trx_requested_lock_id,trx_wait_started,trx_weight,trx_mysql_thread_id,trx_query from information_schema.innodb_trx |
+-----------------+-----------+---------------------+-----------------------+---------------------+------------+---------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------+
4 rows in set (0.00 sec)

mysql> select lock_id,lock_trx_id,lock_mode,lock_type,lock_table,lock_index,lock_data from information_schema.innodb_locks;
+-----------------+-------------+-----------+-----------+--------------+------------+-----------+
| lock_id         | lock_trx_id | lock_mode | lock_type | lock_table   | lock_index | lock_data |
+-----------------+-------------+-----------+-----------+--------------+------------+-----------+
| 5686612:423:3:2 | 5686612     | X         | RECORD    | `test`.`abc` | PRIMARY    | 1         |
| 5686611:423:3:2 | 5686611     | X         | RECORD    | `test`.`abc` | PRIMARY    | 1         |
| 5686614:423:3:2 | 5686614     | X         | RECORD    | `test`.`abc` | PRIMARY    | 1         |
+-----------------+-------------+-----------+-----------+--------------+------------+-----------+
3 rows in set, 1 warning (0.00 sec)

mysql> select requesting_trx_id,requested_lock_id,blocking_trx_id,blocking_lock_id from information_schema.innodb_lock_waits;
+-------------------+-------------------+-----------------+------------------+
| requesting_trx_id | requested_lock_id | blocking_trx_id | blocking_lock_id |
+-------------------+-------------------+-----------------+------------------+
| 5686612           | 5686612:423:3:2   | 5686611         | 5686611:423:3:2  |
| 5686612           | 5686612:423:3:2   | 5686614         | 5686614:423:3:2  |
| 5686611           | 5686611:423:3:2   | 5686614         | 5686614:423:3:2  |
+-------------------+-------------------+-----------------+------------------+
3 rows in set, 1 warning (0.00 sec)

InnoDB锁和锁等待信息

当一个事务更新表中的一行,或者用SELECT FOR UPDATE锁住它时,InnoDB会为该行建立一个锁的列表或队列。类似地,InnoDB在表上维护了一个表级锁的列表。如果第二个事务想要更新一行数据或者在不兼容的模式下锁定一个已经被前一个事务锁定的表,InnoDB会向相应的队列添加一个锁请求。为了让事务获得锁,必须删除先前进入锁队列的所有不兼容的锁请求(当持有或请求这些锁的事务提交或回滚这些锁时)。

一个事务可以对不同的行或表有任意数量的锁请求。在任何给定的时间,一个事务可以请求一个由另一个事务持有的锁,在这种情况下,它被另一个事务阻塞。请求事务必须等待持有阻塞锁的事务提交或回滚。如果事务没有等待锁,则它处于运行状态。如果事务正在等待锁,则它处于锁等待状态。(INFORMATION_SCHEMA INNODB_TRX表表示事务状态值。)

INNODB_LOCKS表为每个锁等待事务保存了一个或多个行,表示任何阻止其进行的锁请求。该表还包含一行,描述给定行或表的待决锁队列中的每个锁。INNODB_LOCK_WAITS表显示了一个事务持有的哪些锁是其他事务请求的阻塞锁。

InnoDB事务与锁信息的持久化与一致性
由事务和锁表(INNODB_TRX、INNODB_LOCKS和INNODB_LOCK_WAITS)暴露的数据代表了快速变化的数据。这与用户表不同,用户表中的数据只有在应用程序发起更新时才会发生变化。底层数据是内部系统管理的数据,可以非常快速地更改。

出于性能方面的原因,以及为了尽量减少事务和锁定表之间的误导性连接,每当发出对任何表的SELECT请求时,InnoDB都会将所需的事务和锁定信息收集到中间缓冲区中。仅当从上一次读取缓冲区以来已经超过0.1秒时,才会刷新该缓冲区。填充这三张表所需的数据以原子性和一致性的方式获取,并保存在这个全局内部缓冲区中,形成一个即时点的“快照”。如果在0.1秒内发生多次表访问(当MySQL处理这些表之间的联结时,几乎肯定会发生这种情况),则使用相同的快照来满足查询。

当您将这些表中的任何一张联结到一个查询中时,都会返回正确的结果,因为这三张表的数据来自同一个快照。因为对这些表的每次查询都不会刷新缓冲区,如果您在十分之一秒内对这些表发出单独的查询,那么每次查询的结果都是相同的。另一方面,如果两次对相同或不同表的单独查询间隔超过十分之一秒,可能会得到不同的结果,因为数据来自不同的快照。

因为在收集事务和锁定数据时,InnoDB必须暂时停止,对这些表过于频繁的查询可能会对其他用户的性能产生负面影响。

因为这些表包含敏感信息(至少INNODB_LOCKS.LOCK_DATA和INNODB_TRX.TRX_QUERY),出于安全考虑,只有具有进程权限的用户才能从中选择。

如前所述,填充事务和锁表(INNODB_TRX, INNODB_LOCKS和INNODB_LOCK_WAITS)的数据会被自动获取并保存到一个提供“时间点”快照的中间缓冲区中。当从同一个快照中查询时,所有三个表的数据是一致的。然而,底层数据变化如此之快,以至于其他类似的快速变化的数据可能并不同步。因此,在比较InnoDB事务和锁定表中的数据与PROCESSLIST表中的数据时,你应该小心。PROCESSLIST表中的数据与锁定和事务的数据并不来自同一个快照。即使你只执行了一个SELECT操作(例如,关联INNODB_TRX和PROCESSLIST),这些表的内容通常也不一致。INNODB_TRX可以引用PROCESSLIST中不存在的行,或者INNODB_TRX中显示的当前正在执行的事务的SQL查询。TRX_QUERY可能与PROCESSLIST.INFO中的不同。

]]>
http://www.jydba.net/index.php/archives/3514/feed 0
MySQL InnoDB与联机DDL http://www.jydba.net/index.php/archives/3510 http://www.jydba.net/index.php/archives/3510#respond Tue, 19 Sep 2023 00:32:54 +0000 http://www.jydba.net/?p=3510 InnoDB与联机DDL
InnoDB联机DDL特性允许就地表更改或并发DML,或两者兼而有之。这个特性的好处包括:
.改进了繁忙的生产环境中的响应性和可用性,在这些环境中,使表在几分钟或几小时内不可用是不现实的。

.使用LOCK子句在DDL操作期间调整性能和并发性之间的平衡的能力。
.LOCK=EXCLUSIVE完全阻塞对表的访问

.LOCK=SHARED允许查询,但不允许DML。

.LOCK=NONE允许对表进行完整的查询和DML访问。

.LOCK=DEFAULT或省略LOCK子句允许尽可能多的并发,具体取决于DDL操作的类型。

.避免了与复制表和重建二级索引相关的磁盘空间使用和I/O开销。

联机DDL概述
联机DDL特性增强了许多DDL操作,这些操作以前需要表复制或阻塞表上的DML操作,或者两者兼而有之。除了大多数ALTER TABLE分区子句之外,分区后的InnoDB表的在线DDL操作遵循与普通InnoDB表相同的规则。一些因素会影响在线DDL操作的性能、空间使用和语义。
.”In-Place?”列显示哪些操作允许使用ALGORITHM=INPLACE子句。

.”Rebuilds Table?”列显示重建表的操作。对于使用INPLACE算法的操作,将就地重建表。对于不支持INPLACE算法的操作,使用表复制方法重建表。

.”Permits Concurrent DML?”列显示哪些操作是完全在线执行的。您可以指定LOCK=NONE来断言在DDL操作期间允许并发DML。MySQL在可能的情况下自动允许并发DML。

在所有在线DDL操作期间都允许并发查询。可以指定LOCK=SHARED来断言在DDL操作期间允许并发查询。MySQL在可能的情况下自动允许并发查询。

.“Notes”列提供额外的信息,并解释与其他列的“Yes/No”值相关的异常和依赖关系。星号表示异常或依赖。

下面的小节提供了各种在线DDL操作的基本语法和用法说明。
添加或删除二级索引
.添加二级索引:

CREATE INDEX name ON table (col_list);

ALTER TABLE table ADD INDEX name (col_list);

.删除二级索引:

DROP INDEX name ON table;

ALTER TABLE table DROP INDEX name;

尽管在CREATE INDEX或DROP INDEX命令中不需要更改语法,但有一些因素会影响此操作的性能、空间使用和语义。

在InnoDB表上创建和删除二级索引会跳过表复制行为。

在创建或删除索引时,表仍然可用于读写操作。CREATE INDEX或DROP INDEX语句仅在所有访问表的事务完成后才完成,因此索引的初始状态反映了表的最新内容。以前,在创建或删除索引时修改表通常会导致死锁,从而取消表上的INSERT、UPDATE或DELETE语句。

在线DDL支持添加二级索引,这意味着通常可以加快创建和加载表及其关联索引的整体过程,方法是创建不带任何二级索引的表,然后在加载数据后添加二级索引。

修改列属性
.修改列的默认值:

ALTER TABLE tbl ALTER COLUMN col SET DEFAULT literal;
ALTER TABLE tbl ALTER COLUMN col DROP DEFAULT;

列的默认值存储在表的.frm文件中,而不是InnoDB数据字典中。

.更改列的自动增量值:
ALTER TABLE table AUTO_INCREMENT=next_value;

特别是在使用复制或分片的分布式系统中,有时需要将表的自动递增计数器重置为特定值。插入到表中的下一行使用指定的值作为其自动递增列。您也可以在数据仓库环境中使用此技术,您可以定期清空所有表并重新加载它们,并且可以从1重新启动自动递增序列。

.重命名列
ALTER TABLE tbl CHANGE old_col_name new_col_name datatype;

当您保持相同的数据类型和[NOT] NULL属性时,仅更改列名,此操作始终可以在线执行。

还可以重命名属于外键约束的列。外键定义会自动更新,以使用新的列名。重命名参与外键的列仅适用于ALTER TABLE的in-place模式。如果使用了ALGORITHM=COPY子句,或者其他条件导致命令在后台使用了ALGORITHM=COPY,那么ALTER TABLE语句就会失败。

.使用in-place ALTER TABLE语句扩展VARCHAR的大小:
ALTER TABLE t13 ALGORITHM=INPLACE, CHANGE COLUMN c1 c1 VARCHAR(50);

VARCHAR列所需的长度字节数必须保持不变。对于0到255的VARCHAR值,需要一个长度字节来编码该值。对于256字节或更多的VARCHAR值,需要两个长度字节。因此,in-place ALTER TABLE只支持将VARCHAR大小从0增加到255字节,或将VARCHAR大小从等于或大于256字节的值增加。In-place ALTER TABLE不支持将VARCHAR大小从小于256字节增加到等于或大于256字节。在这种情况下,所需长度字节的数量将从1变为2,只有表复制(ALGORITHM= copy)才支持这种情况。例如,试图使用in-place ALTER TABLE将VARCHAR列的大小从255更改为256将会返回错误:

mysql> ALTER TABLE t13 ALGORITHM=INPLACE, CHANGE COLUMN c1 c1 VARCHAR(256);
ERROR 1846 (0A000): ALGORITHM=INPLACE is not supported. Reason: Cannot change column type INPLACE. Try ALGORITHM=COPY.

mysql> ALTER TABLE t13 ALGORITHM=COPY, CHANGE COLUMN c1 c1 VARCHAR(256);
Query OK, 0 rows affected (0.02 sec)
Records: 0  Duplicates: 0  Warnings: 0

不支持使用in-place ALTER TABLE减少VARCHAR大小。减少VARCHAR的大小需要表的复制(ALGORITHM=COPY)。

mysql> ALTER TABLE t13 ALGORITHM=INPLACE, CHANGE COLUMN c1 c1 VARCHAR(20);
ERROR 1846 (0A000): ALGORITHM=INPLACE is not supported. Reason: Cannot change column type INPLACE. Try ALGORITHM=COPY.

mysql> ALTER TABLE t13 ALGORITHM=COPY, CHANGE COLUMN c1 c1 VARCHAR(20);
Query OK, 0 rows affected (0.02 sec)
Records: 0  Duplicates: 0  Warnings: 0

添加或删除外键
.添加或删除外键约束:

ALTER TABLE tbl1 ADD CONSTRAINT fk_name FOREIGN KEY index (col1) REFERENCES tbl2(col2) referential_actions;

ALTER TABLE tbl DROP FOREIGN KEY fk_name;

删除外键可以在启用或禁用foreign_key_checks选项的情况下在线执行。在线创建外键需要禁用foreign_key_checks。

如果你不知道某张表上的外键约束的名称,执行下面的语句,并在每个外键的约束子句中找到约束名称:

SHOW CREATE TABLE table\G

或者,查询INFORMATION_SCHEMA.TABLE_CONSTRAINTS表,使用CONSTRAINT_NAME和CONSTRAINT_TYPE列来标识外键的名称。

你也可以在一条语句中删除外键及其关联索引:

ALTER TABLE table DROP FOREIGN KEY constraint, DROP INDEX index;

如果外键已经存在于被修改的表中(也就是说,它是一个包含FOREIGN KEY …REFERENCE子句的子表),其他的限制适用于在线DDL操作,即使是那些不直接涉及外键列的操作:

.如果对父表的更改通过使用CASCADE或SET NULL参数的on UPDATE或on DELETE子句引起子表的相关更改,则子表上的ALTER TABLE可以等待另一个事务提交。

.同样,如果一张表是外键关系中的父表,即使它不包含任何外键子句,如果INSERT、UPDATE或DELETE语句导致子表中的ON UPDATE或ON DELETE操作,它也可以等待ALTER TABLE完成。

维护CREATE TABLE语句
当你的数据库模式随着新列、数据类型、约束、索引等的变化而变化时,请确保CREATE TABLE语句与最新的表定义保持一致。即使有了在线DDL的性能改进,在开始时创建稳定的数据库结构比创建模式的一部分然后发出ALTER TABLE语句更有效。

对有大量行记录表的二级索引这条准则除外。通常最有效的做法是:先指定除二级索引之外的所有详细信息,然后加载数据,再创建二级索引。如果您知道初始数据是干净的,并且在加载过程中不需要一致性检查,则可以对外键使用相同的技术(首先加载数据,然后设置外键)。

无论CREATE TABLE、CREATE INDEX、ALTER TABLE和类似的语句是如何将一个表组合在一起的,您都可以通过执行语句SHOW CREATE TABLE TABLE \G(为了整洁的格式化,需要大写\G)来捕获重建表所需的SQL。上述输出显示了numeric precision、NOT NULL和CHARACTER SET等子句,这些子句有时是在后台添加的,用户可能希望在新系统上克隆表或设置相同类型的外键列时省去这些子句。

联机DDL性能、并发性和空间需求
联机DDL提高了MySQL操作的几个方面,如性能、并发性、可用性和可伸缩性:
.由于表上的查询和DML操作可以在DDL进行时继续进行,因此访问表的应用程序响应更快。在整个MySQL服务器中减少锁和等待其他资源会带来更大的可伸缩性,即使对于不涉及修改表的操作也是如此。

.对于in-place操作,通过避免重新构建表所需的磁盘I/O和CPU周期,可以最小化数据库的总体负载,并在DDL操作期间保持良好的性能和高吞吐量。

.对于in-place操作,由于读入缓冲池的数据比复制所有数据要少,因此可以避免从内存中清除频繁访问的数据,这在以前可能会在DDL操作之后导致暂时的性能下降。

如果联机操作需要临时排序文件,InnoDB默认在临时文件目录下创建它们,而不是在包含原始表的目录下。如果这个目录不够大,无法容纳这样的文件,您可能需要将tmpdir系统变量设置为另一个目录。另外,您可以使用innodb_tmpdir配置选项为InnoDB在线ALTER TABLE操作定义一个单独的临时目录。

联机DDL的锁选项
当DDL操作改变InnoDB表时,表可能被锁住,也可能不被锁住,这取决于DDL操作的内部工作原理和ALTER table语句的LOCK子句。默认情况下,MySQL在DDL操作期间使用尽可能少的锁;您可以指定这个子句,使锁定比通常情况下更加严格(从而限制并发DML或DML和查询),或者确保某个操作允许某种预期程度的锁定。如果LOCK子句指定的锁级别不适用于特定类型的DDL操作,例如在创建或删除主键时指定LOCK=SHARED或LOCK=NONE,那么该子句就会像断言一样工作,导致语句失败并报错。下面列出了LOCK子句的不同可能性,从最宽松的到最严格的:

.对于LOCK=NONE的DDL操作,查询和并发DML都是允许的。如果不能使用所请求的锁类型执行DDL操作,则该子句会使ALTER TABLE失败,因此,如果保持表完全可用是至关重要的,则指定LOCK=NONE,如果不可能则可以取消DDL。例如,您可以在DDLs中对涉及客户注册或购买的表使用此子句,以避免错误地发出昂贵的ALTER TABLE语句,从而使这些表不可用。

.对于LOCK=SHARED的DDL操作,任何对表的写操作(即DML操作)都会被阻塞,但是可以读取表中的数据。如果请求的锁类型不能执行这种DDL操作,则该子句会使ALTER TABLE失败,因此,如果保持表对查询可用非常重要,则指定LOCK=SHARED,如果不可能,则可以取消DDL。例如,您可以在DDL中为数据仓库中的表使用这个子句,在DDL中可以延迟数据加载操作直到DDL完成,但是不能长时间延迟查询。

.对于使用LOCK=DEFAULT或省略LOCK子句的DDL操作,MySQL针对此类操作使用可用的最低级别的锁,允许并发查询、DML或两者同时使用。当您根据表的工作负载进行预先计划、预先测试的更改,并且知道不会导致任何可用性问题时,将使用此设置。

.对于LOCK=EXCLUSIVE的DDL操作,查询和DML操作都被阻塞。如果请求的锁类型不能执行这种DDL操作,这个子句会使ALTER TABLE失败,因此,如果主要关注的是在尽可能短的时间内完成DDL,则指定LOCK=EXCLUSIVE,并且可以使应用程序在尝试访问表时等待。如果服务器应该是空闲的,您也可以使用LOCK=EXCLUSIVE,以避免对表的意外访问。

在大多数情况下,表上的联机DDL操作等待正在访问表的当前执行的事务提交或回滚,因为在准备DDL语句时,它需要在短时间内独占访问表。同样,联机DDL操作在完成之前需要对表进行短时间的独占访问。因此,联机DDL语句也会等待DDL正在提交或回滚时启动的事务完成。因此,对于执行插入、更新、删除的长时间运行的事务或对表执行SELECT .. FOR UPDATE操作,联机DDL操作可能会超时等待对表的独占访问。

当表处于外键关系中,并且事务在外键关系中的另一个表上显式运行时,可能发生表上的在线DDL操作不等待当前执行的事务完成的情况。在这种情况下,事务在它正在更新的表上持有一个排他的元数据锁,但只持有另一张表上共享的InnoDB表锁(外键检查所需)。共享的InnoDB表锁允许在线DDL操作继续进行,当需要一个互斥的InnoDB表锁时会在提交阶段阻塞操作。当其他事务等待在线DDL操作提交时,此场景可能导致死锁。(参见Bug #48652和Bug #77390)

因为需要一些处理工作来记录并发DML操作所做的更改,然后在最后应用这些更改,所以在线DDL操作可能比阻止其他会话访问表的旧式机制花费更长的时间。原始性能的降低与使用表的应用程序更好的响应性是平衡的。在评估更改表结构的理想技术时,要根据诸如网页加载时间等因素,考虑最终用户对性能的感知。

当CREATE INDEX或ALTER TABLE语句执行完毕时,一个新创建的InnoDB二级索引只包含表中已提交的数据。它不包含任何未提交的值、值的旧版本或标记为删除但尚未从旧索引中删除的值。

In-PlaceDDL操作与Table-Copy DDL操作的性能
在线DDL操作的原始性能在很大程度上取决于该操作是in-place执行,还是需要复制和重建整个表。

in-place DDL带来的性能提升适用于二级索引上的操作,而不是主键索引。InnoDB表中的行存储在一个基于主键组织的聚集索引中,形成了一些数据库系统所称的“索引组织表”。因为表结构与主键紧密联系在一起,所以重新定义主键仍然需要复制数据。

当对主键的操作使用ALGORITHM=INPLACE时,即使数据仍然被复制,它也比使用ALGORITHM=COPY更有效,因为:
.ALGORITHM=INPLACE不需要undo日志记录或相关的重做日志记录。这些操作增加了使用ALGORITHM=COPY的DDL语句的开销。

.二级索引项是预先排序的,因此可以按顺序加载。

.没有使用更改缓冲区,因为没有随机访问插入到二级索引中。

为了判断在线DDL操作的相对性能,你可以使用当前版本和更早版本的MySQL在一个大的InnoDB表上运行这样的操作。还可以在最新的MySQL版本下运行所有性能测试,通过设置old_alter_table系统变量,模拟“before”结果的DDL行为。在会话中发出语句set old_alter_table=1,并测量DDL性能以记录“之前”的数字。然后设置old_alter_table=0以重新启用更新、更快的行为,并再次运行DDL操作以记录“之后”的数字。

要了解DDL操作是in-place进行更改还是执行表复制的基本概念,请查看命令完成后显示的“受影响的行”值。例如,在执行不同类型的DDL操作后,您可能会看到以下行:
.更改列的默认值(超快,完全不影响表数据):

Query OK, 0 rows affected (0.07 sec)

.添加索引(需要时间,但是0行受影响表明表没有被复制):

Query OK, 0 rows affected (21.42 sec)

.更改列的数据类型(需要花费大量时间,并且需要重建表中的所有行):

Query OK, 1671168 rows affected (1 min 35.54 sec)

更改列的数据类型需要重建表中的所有行,VARCHAR大小的更改除外,这可以使用在线ALTER table执行。

例如,在一个大表上运行DDL操作之前,你可能会检查操作的快慢,如下所示:
1.克隆表结构。

2.用少量数据填充克隆表。

3.在克隆表上运行DDL操作。

4.检查“受影响的行”值是否为零。非零值意味着操作需要重建整个表,这可能需要特殊的规划。例如,您可以在计划的停机期间执行DDL操作,或者每次在每个复制从服务器上执行一个。

为了更深入地了解MySQL处理过程中的归约,可以查看DDL操作前后与InnoDB相关的performance_schema和INFORMATION_SCHEMA表,查看物理读、写、内存分配等的数量。

联机DDL操作的空间要求
联机DDL操作对空间的要求如下:
.存放临时日志文件的空间
对于每个创建的索引或修改的表,都有一个这样的日志文件。此日志文件存储在DDL操作期间在表中插入、更新或删除的数据。临时日志文件在需要时通过innodb_sort_buffer_size的值进行扩展,直到达到innodb_online_alter_log_max_size指定的最大值。如果临时日志文件的大小超过上限,那么ALTER TABLE操作将失败,所有未提交的并发DML操作将回滚。因此,如果该选项的值较大,就允许在联机DDL操作期间发生更多的DML,
但也会延长DDL操作结束时表被锁定以应用日志中的数据的时间。

如果操作花费的时间太长,并发的DML修改表的时间太长,导致临时在线日志的大小超过innodb_online_alter_log_max_size配置选项的值,则在线DDL操作失败,并出现DB_ONLINE_LOG_TOO_BIG错误。

.临时排序文件的空间
重建表的在线DDL操作在创建索引时将临时排序文件写入MySQL临时目录(Unix上为$TMPDIR, Windows上为%TEMP%,或由–tmpdir配置变量指定的目录)。每个临时排序文件都足够大,可以容纳新二级索引定义的所有列,以及聚集索引的主键的列,一旦合并到最终表或索引中,这些列就会被删除。此类操作需要的临时空间相当于存储表中数据和索引数据所需要的空间大小。如果重建表的联机DDL操作使用了数据目录(datadir)所在的文件系统上的所有可用磁盘空间,则会导致错误。

从MySQL 5.7.11开始,你可以使用innodb_tmpdir配置选项为联机DDL操作定义一个单独的临时目录。innodb_tmpdir选项的引入是为了避免在联机ALTER TABLE操作重建表时创建大型临时排序文件时可能发生的临时目录溢出。

.中间表文件的空间
一些重建表的联机DDL操作在与原始表相同的目录中创建临时中间表文件,而不是在原地重建表。中间表文件可能需要与原始表大小相等的空间。

联机DDL SQL语法
通常,当对InnoDB表使用ALTER TABLE语句时,不需要做任何特殊的事情来启用联机DDL。一些变体需要使用配置或与ALTER TABLE子句的特定组合。

通过使用ALTER TABLE语句的LOCK和ALGORITHM子句,可以控制特定联机DDL操作的各个方面。这些子句位于语句的末尾,用逗号与表和列的规范分隔。LOCK子句用于微调对表的并发访问程度。ALGORITHM子句主要用于性能比较并作为在现有DDL代码遇到任何问题时对旧表复制行为的回退。例如:
.为了避免意外地使表不可读、不可写或不可读和不可写,可以在ALTER table语句中指定一个子句,例如LOCK=NONE(允许读写)或LOCK=SHARED(允许读)。如果请求的并发级别不可用,操作将立即停止。

.为了比较性能,除了设置old_alter_table配置选项外,还可以运行一个ALGORITHM=INPLACE语句和另一个算法ALGORITHM=COPY的语句。

.为了避免复制表的ALTER TABLE操作占用服务器资源,可以使用ALGORITHM=INPLACE子名。如果不能使用in-place机制,该语句将立即停止。

使用联机DDL简化DDL语句
在引入联机DDL之前,将许多DDL操作组合到单个ALTER TABLE语句中是一种常见的做法。因为每个ALTER TABLE语句都涉及复制和重建表,所以一次对同一个表进行多次更改会更加高效,因为这些更改可以通过对表的一次重建操作完成。缺点是涉及DDL操作的SQL代码很难在不同的脚本中维护和重用。如果每次的具体更改都不同,则可能需要为每个稍有不同的场景构建一个新的复杂的ALTER TABLE。

对于可以in-place完成的DDL操作,现在,您可以将它们分离为单独的ALTER TABLE语句,以便于编写脚本和维护,而不会牺牲效率。例如,你可以用这样一个复杂的语句:

ALTER TABLE t1 ADD INDEX i1(c1), ADD UNIQUE INDEX i2(c2),
CHANGE c4_old_name c4_new_name INTEGER UNSIGNED;

将其分解为可以独立测试和执行的更简单的部分,例如:

ALTER TABLE t1 ADD INDEX i1(c1);
ALTER TABLE t1 ADD UNIQUE INDEX i2(c2);
ALTER TABLE t1 CHANGE c4_old_name c4_new_name INTEGER UNSIGNED NOT NULL;

你可能仍然要使用由多个部分组成的ALTER TABLE语句:
.必须按特定顺序执行的操作,例如创建索引,然后使用该索引的外键约束。

.所有操作都使用相同的特定LOCK子句,希望作为一个组成功或失败。

.不能in-place执行的操作,即仍然复制和重建表的操作。

.指定ALGORITHM=COPY或old_alter_table=1的操作,如果需要在特定场景中实现精确的向后兼容性,可以强制表复制行为。

联机DDL实现详细信息
InnoDB表的每个ALTER TABLE操作都受以下几个方面的控制:
.是否对表的物理表示有任何更改,或者是否纯粹是对元数据的更改,而无需触及表本身。

.表中的数据量是保持不变、增加还是减少

.表数据的更改是否涉及聚集索引、二级索引或两者。

.被修改的表与其他表之间是否存在外键关系。机制差异取决于foreign_key_checks配置选项是启用还是禁用。

.表是否被分区。ALTER TABLE的分区子句被转换为涉及一个或多个表的低级操作,这些操作遵循联机DDL的常规规则。

.是否必须复制表数据,表是否可以“in-place”重组,或者两者的组合。

.需要多大程度的锁定,取决于底层数据库操作的性质,或者取决于在ALTER TABLE语句中指定的LOCK子句。

联机DDL错误条件
以下是联机DDL操作可能失败的主要原因:
.如果LOCK子句指定了低级别锁(SHARED或NONE)将与特定类型的DDL操作不兼容。

.如果在等待获得表上的排他锁时发生超时,在DDL操作的初始和最后阶段可能需要短暂的超时。

.MySQL在创建索引时将临时排序文件写入磁盘,如果tmpdir或innodb_tmpdir文件系统耗尽了磁盘空间。

.如果ALTER TABLE花费了很长时间,并且并发的DML对表的修改太多,那么临时在线日志的大小超过了innodb_online_alter_log_max_size配置选项的值。这种情况会导致DB_ONLINE_LOG_TOO_BIG错误。

.如果并发DML对原表定义允许的表进行更改,但新表定义不允许。只有在最后,当MySQL试图应用并发DML语句中的所有更改时,操作才会失败。例如,用户可以在创建唯一索引时向列中插入重复的值,或者在创建主键索引时向列中插入NULL值。并发DML所做的更改优先,并且有效地回滚了ALTER TABLE操作。

尽管配置选项innodb_file_per_table对InnoDB表的表示有显著的影响,但是不管这个选项是启用还是禁用,不管表物理位置是在它自己的.ibd文件中还是在系统表空间中,所有的在线DDL操作都是一样的。

InnoDB有两种类型的索引:代表表中所有数据的聚集索引,以及可选的加速查询的二级索引。因为聚集索引包含其b树节点中的数据值,所以添加或删除聚集索引需要复制数据,并创建表的新副本。而二级索引只包含索引键和主键的值。可以在不复制聚集索引中的数据的情况下创建或删除这种类型的索引。因为每个二级索引都包含主键值的副本(用于在需要时访问聚集索引),所以当更改主键的定义时,也会重新创建所有二级索引。

删除二级索引很简单。只有内部的InnoDB系统表和MySQL数据字典表被更新,以反映索引不再存在的事实。InnoDB将用于索引的存储空间返回到包含它的表空间,以便新的索引或额外的表行可以使用该空间。

为了给已存在的表添加二级索引,InnoDB会扫描表,并使用内存缓冲区和临时文件,根据二级索引键列的值对行进行排序。B树是按键值顺序构建的,这比按随机顺序将行插入索引更高效。因为b树节点在填充时是分裂的,以这种方式构建索引会导致索引的填充因子更高,从而使后续访问更高效。

联机DDL和崩溃恢复
虽然在执行ALTER TABLE语句时服务器崩溃不会丢失数据,但是集群索引和二级索引的崩溃恢复过程是不同的。

如果服务器在创建InnoDB二索引时崩溃,在恢复时,MySQL删除所有部分创建的索引。您必须重新运行ALTER TABLE或CREATE INDEX语句。

当在创建InnoDB集群索引时发生崩溃时,恢复会更加复杂,因为表中的数据必须复制到一个全新的集群索引中。请记住,所有InnoDB表都存储为集群索引。

MySQL通过将原始InnoDB表中的现有数据复制到具有所需索引结构的临时表中来创建新的集群索引。一旦数据被完全复制到这个临时表中,原始表将被重命名为一个不同的临时表名。包含新聚集索引的临时表将使用原始表的名称重命名,原始表将从数据库中删除。

如果在创建新的聚集索引时发生系统崩溃,则不会丢失数据,但是必须使用该过程中存在的临时表来完成恢复过程。由于在此操作期间很少重新创建聚集索引或重新定义大型表上的主键,也很少遇到系统崩溃的情况,因此本手册不提供有关从此场景中恢复的信息。

分区表的联机DDL
大多数ALTER TABLE分区子句不会像常规的非分区InnoDB表那样使用相同的内部联机DDL API。因此,对ALTER TABLE分区子句的联机支持各不相同。

下表显示了每个ALTER TABLE分区语句的联机状态。不管使用的是哪种联机DDL API, MySQL都会尽可能地减少数据复制和锁定。
.”In-Place”列显示哪些操作允许使用ALGORITHM=INPLACE子句。

.”Permits Concurrent DML?”列显示哪些操作是完全联机执行的。您可以指定LOCK=NONE来断言在DDL操作期间允许并发DML。MySQL在可能的情况下自动允许并发DML。

对于支持ALGORITHM={COPY|INPLACE}的操作,可以指定LOCK=SHARED来断言DDL操作期间允许并发查询。MySQL在可能的情况下自动允许并发查询。

.“Notes”列提供了其他信息,并解释了与其他列的“Yes/No”值相关的异常和依赖关系。星号表示异常或依赖项。

使用ALGORITHM=COPY或只允许”ALGORITHM=DEFAULT, LOCK=DEFAULT”的ALTER TABLE分区选项,将使用COPY算法对表进行重新分区。换句话说,使用新的分区方案创建了一个新的分区表。新创建的表包含ALTER table语句应用的任何更改,表数据被复制到新的表结构中。

对分区表执行非分区联机ALTER TABLE操作遵循适用于常规表的相同规则。但是,ALTER TABLE在每个表分区上执行在线操作,由于在多个分区上执行操作,这会导致对系统资源的需求增加。

联机DDL限制
联机DDL操作存在以下限制:
.在TEMPORARY表上创建索引时复制表,而不是使用快速索引创建。这已经被报告为MySQL Bug #39833。

.当用户试图删除外键所需的索引时,InnoDB会处理错误。

.如果表上有ON…CASCADE或ON…SET NULLT约束,ALTER TABLE子句LOCK=NONE是不允许的。

.根据联机DDL操作的内部工作原理和ALTER TABLE语句的LOCK子句,联机DDL操作在DDL操作的初始阶段和最终阶段可能需要在短时间内对表进行排他访问。因此,如果有一个执行插入、更新、删除或对表执行SELECT … FOR UPDATE的长时间运行的事务并且如果在ALTER TABLE进行中启动了类似的长时间运行的事务,则联机DDL操作可能需要等待才能完成。

.当运行一个联机DDL操作时,运行ALTER TABLE语句的线程应用一个来自其他连接线程在同一个表上并发运行的DML操作的“在线日志”。当应用DML操作时,可能会遇到重复键条目错误(错误1062(23000):重复条目),即使重复条目只是临时的,并且会被“在线日志”中的稍后条目恢复。这类似于InnoDB中的外键约束检查,其中约束必须在事务期间保持。

.将InnoDB表的OPTIMIZE TABLE映射到ALTER TABLE以重建表并更新索引统计信息和释放聚集索引中的未使用空间。创建辅助索引的效率不高,因为键是按照它们在主键中出现的顺序插入的。通过添加在线DDL支持,可以重建常规的和分区的InnoDB表。

.在MySQL 5.6之前创建的InnoDB表,对于包括时间列(日期,日期时间或时间戳)的表不支持ALTER TABLE…ALGORITHM=INPLACE且不能使用ALTER TABLE…ALGORITHM=COPY进行重建。在这种情况下,ALTER TABLE…ALGORITHM=INPLACE操作返回如下错误:

ERROR 1846 (0A000): ALGORITHM=INPLACE is not supported.
Reason: Cannot change column type INPLACE. Try ALGORITHM=COPY.

.这些限制通常适用于涉及表复制的大型表上的在线DDL操作:
.不存在暂停在线DDL操作或限制在线DDL操作的I/O或CPU使用的机制DDL操作。

.如果操作失败,回滚在线DDL操作的代价可能很高。

.长时间运行在线DDL操作可能导致复制滞后。在线DDL操作必须在主节点上运行完之后才能在从节点上运行。此外,在主服务器上并发处理的DML只有在从服务器上的DDL操作完成后才会在从服务器上处理(Bug #73196)。

]]>
http://www.jydba.net/index.php/archives/3510/feed 0
MySQL InnoDB行存储和行格式 http://www.jydba.net/index.php/archives/3508 http://www.jydba.net/index.php/archives/3508#respond Thu, 14 Sep 2023 03:42:41 +0000 http://www.jydba.net/?p=3508 InnoDB行存储和行格式
本节讨论InnoDB的特性,如表压缩、可变长度列值的页外存储和大索引键前缀(innodb_large_prefix)是如何由InnoDB表的行格式控制的。它还讨论了选择正确行格式的注意事项,以及MySQL版本之间行格式的兼容性。

InnoDB行存储概述
行和关联列的存储影响查询和DML操作的性能。由于单个磁盘页面中容纳了更多的行,查询和索引查找可以更快地工作,InnoDB缓冲池中所需的缓存内存更少,为数字和短字符串列写更新值所需的I/O也更少。

每个InnoDB表中的数据被划分为多个页。组成每个表的页面排列在称为b-树索引的树状数据结构中。表数据和二级索引都使用这种类型的结构。表示整个表的b树索引称为聚集索引,它是根据主键列组织的。索引数据结构的节点包含该行中所有列的值(对于聚集索引)或索引列和主键列的值(对于辅助索引)。

变长列是此规则的例外。像BLOB和VARCHAR这样的列太长而不能放在b树页上,它们存储在单独分配的磁盘页上,称为溢出页。我们称这样的列为页外列。这些列的值存储在溢出页的单链表中,每个这样的列都有自己的一个或多个溢出页列表。在某些情况下,长列值的全部或前缀存储在b树中,以避免浪费存储空间并消除读取单独页面的需要。

下面的章节描述了如何配置InnoDB表的行格式来控制如何存储可变长度列的值。行格式配置还决定了表压缩特性和大索引键前缀特性(innodb_large_prefix)的可用性。

指定表的行格式
默认的行格式由innodb_default_row_format定义,默认值为DYNAMIC。当没有显式定义ROW_FORMAT表选项或指定ROW_FORMAT= default时,使用默认行格式。

mysql> show variables like 'innodb_default_row_format';
+---------------------------+---------+
| Variable_name             | Value   |
+---------------------------+---------+
| innodb_default_row_format | dynamic |
+---------------------------+---------+
1 row in set (0.02 sec)

表的行格式可以在CREATE table或ALTER table语句中使用ROW_FORMAT表选项显式定义。例如:

mysql> CREATE TABLE t9 (c1 INT) ROW_FORMAT=DYNAMIC;
Query OK, 0 rows affected (0.03 sec)

显式定义的ROW_FORMAT设置覆盖隐式默认值。指定ROW_FORMAT=DEFAULT相当于使用隐式默认值。

innodb_default_row_format选项可以动态设置:

mysql> SET GLOBAL innodb_default_row_format=DYNAMIC;

有效的innodb_default_row_format选项包括DYNAMIC、COMPACT和REDUNDANT。COMPRESSED行格式不支持在系统表空间中使用,不能被定义为默认行格式。它只能在CREATE TABLE或ALTER TABLE语句中显式指定。尝试将innodb_default_row_format设置为COMPRESSED会返回一个错误:

mysql> SET GLOBAL innodb_default_row_format=COMPRESSED;
ERROR 1231 (42000): Variable 'innodb_default_row_format' can't be set to the value of 'COMPRESSED'

当没有明确指定ROW_FORMAT选项或使用ROW_FORMAT=DEFAULT时,新创建的表使用innodb_default_row_format定义的行格式。例如,下面的CREATE TABLE语句使用innodb_default_row_format定义的行格式。

mysql> CREATE TABLE t10 (c1 INT);
Query OK, 0 rows affected (0.02 sec)

mysql> CREATE TABLE t11 (c1 INT) ROW_FORMAT=DEFAULT;
Query OK, 0 rows affected (0.01 sec)


mysql> show variables like 'innodb_default_row_format';
+---------------------------+---------+
| Variable_name             | Value   |
+---------------------------+---------+
| innodb_default_row_format | dynamic |
+---------------------------+---------+
1 row in set (0.02 sec)

mysql> SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES WHERE NAME='undo/t10'\G
*************************** 1. row ***************************
     TABLE_ID: 498
         NAME: undo/t10
         FLAG: 33
       N_COLS: 4
        SPACE: 500
  FILE_FORMAT: Barracuda
   ROW_FORMAT: Dynamic
ZIP_PAGE_SIZE: 0
   SPACE_TYPE: Single
1 row in set (0.00 sec)

mysql> SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES WHERE NAME='undo/t11'\G
*************************** 1. row ***************************
     TABLE_ID: 499
         NAME: undo/t11
         FLAG: 33
       N_COLS: 4
        SPACE: 501
  FILE_FORMAT: Barracuda
   ROW_FORMAT: Dynamic
ZIP_PAGE_SIZE: 0
   SPACE_TYPE: Single
1 row in set (0.00 sec)

当没有显式指定ROW_FORMAT选项或使用ROW_FORMAT=DEFAULT时,任何重建表的操作都会将表的行格式静默地更改为innodb_default_row_format定义的格式。

表重建操作包括使用ALGORITHM=COPY的ALTER TABLE操作和使用ALGORITHM= INPLACE的ALTER TABLE操作。OPTIMIZE TABLE也是一个表重建操作。

下面的示例演示了一个表重建操作,该操作静默地更改在没有显式定义行格式的情况下创建的表的行格式。

mysql> SELECT @@innodb_default_row_format;
+-----------------------------+
| @@innodb_default_row_format |
+-----------------------------+
| dynamic                     |
+-----------------------------+
1 row in set (0.00 sec)

mysql> CREATE TABLE t12 (c1 INT);
Query OK, 0 rows affected (0.01 sec)

mysql> SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES WHERE NAME LIKE 'undo/t12' \G
*************************** 1. row ***************************
     TABLE_ID: 500
         NAME: undo/t12
         FLAG: 33
       N_COLS: 4
        SPACE: 502
  FILE_FORMAT: Barracuda
   ROW_FORMAT: Dynamic
ZIP_PAGE_SIZE: 0
   SPACE_TYPE: Single
1 row in set (0.01 sec)

mysql> SET GLOBAL innodb_default_row_format=COMPACT;
Query OK, 0 rows affected (0.00 sec)

mysql> ALTER TABLE t12 ADD COLUMN (c2 INT);
Query OK, 0 rows affected (0.02 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql> SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES WHERE NAME LIKE 'undo/t12' \G
*************************** 1. row ***************************
     TABLE_ID: 501
         NAME: undo/t12
         FLAG: 1
       N_COLS: 5
        SPACE: 503
  FILE_FORMAT: Antelope
   ROW_FORMAT: Compact
ZIP_PAGE_SIZE: 0
   SPACE_TYPE: Single
1 row in set (0.00 sec)

在将现有表的行格式从REDUNDANT或COMPACT更改为DYNAMIC之前,请考虑以下潜在问题。
.如果启用了innodb_large_prefix配置选项,则REDUNDANT和COMPACT行格式支持的最大索引键前缀长度为767字节,而DYNAMIC和COMPRESSED行格式支持的索引键前缀长度为3072字节。在复制环境中,如果innodb_default_row_format在主服务器上被设置为DYNAMIC,在从服务器上被设置为COMPACT,那么下面的DDL语句(没有明确定义行格式)在主服务器上成功,在从服务器上失败:

CREATE TABLE t1 (c1 INT PRIMARY KEY, c2 VARCHAR(5000), KEY i1(c2(3070)));

.导入一个没有显式定义行格式的表,如果源服务器上的innodb_default_row_format设置与目标服务器上的设置不同,则会导致模式不匹配错误。

要查看表的行格式,可以发出SHOW TABLE STATUS语句或查询INFORMATION_SCHEMA.TABLES。

mysql> SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES WHERE NAME LIKE 'undo/t12' \G
*************************** 1. row ***************************
     TABLE_ID: 501
         NAME: undo/t12
         FLAG: 1
       N_COLS: 5
        SPACE: 503
  FILE_FORMAT: Antelope
   ROW_FORMAT: Compact
ZIP_PAGE_SIZE: 0
   SPACE_TYPE: Single
1 row in set (0.00 sec)

mysql> SHOW TABLE STATUS\G
*************************** 1. row ***************************
           Name: big_table
         Engine: InnoDB
        Version: 10
     Row_format: Dynamic
           Rows: 3370592
 Avg_row_length: 205
    Data_length: 694140928
Max_data_length: 0
   Index_length: 0
      Data_free: 3145728
 Auto_increment: 3326977
    Create_time: 2023-07-06 18:05:18
    Update_time: NULL
     Check_time: NULL
      Collation: utf8mb4_general_ci
       Checksum: NULL
 Create_options:
        Comment:

InnoDB表的行格式决定了它的物理行结构。

DYNAMIC和COMPRESSED行格式
当创建一个ROW_FORMAT=DYNAMIC或ROW_FORMAT=COMPRESSED的表时,InnoDB可以存储长可变长度的列值(对于VARCHAR, VARBINARY, BLOB和TEXT类型)完全溢出页,集群索引记录只包含一个指向溢出页的20字节指针。InnoDB也将长度大于或等于768字节的固定长度字段编码为可变长度字段。例如,如果字符集的最大字节长度大于3,那么CHAR(255)列可以超过768字节,就像utf8mb4一样。

是否有列存储在页外取决于页大小和行的总大小。当行太长时,InnoDB选择最长的列作为页外存储,直到聚集索引记录适合B-tree页。小于或等于40字节的TEXT和BLOB列始终内联存储。

如果适合的话,DYNAMIC行格式保持了在索引节点中存储整行的效率(就像COMPACT和REDUNDANT格式一样),但是DYNAMIC行格式避免了用长列的大量数据字节填充b树节点的问题。DYNAMIC格式基于这样的思想:如果长数据值的一部分存储在页外,那么将所有值存储在页外通常是最有效的。使用DYNAMIC格式,较短的列可能会保留在B-tree节点中,从而最大限度地减少任何给定行所需的溢出页数。

对于页外存储,COMPRESSED行格式使用了与DYNAMIC行格式类似的内部细节,同时对表和索引数据进行了额外的存储和性能考虑,并使用了更小的页面大小。对于COMPRESSED行格式,KEY_BLOCK_SIZE选项控制在聚集索引中存储多少列数据,以及在溢出页上放置多少列数据。

DYNAMIC和COMPRESSED行格式都支持最多3072字节的索引键前缀。该特性由innodb_large_prefix配置选项控制,默认情况下是启用的。

mysql> select @@innodb_large_prefix;
+-----------------------+
| @@innodb_large_prefix |
+-----------------------+
|                     1 |
+-----------------------+
1 row in set (0.00 sec)

mysql> show variables like 'innodb_large_prefix';
+---------------------+-------+
| Variable_name       | Value |
+---------------------+-------+
| innodb_large_prefix | ON    |
+---------------------+-------+
1 row in set (0.01 sec)

使用COMPRESSED行格式的表可以在file-per-table表空间或一般表空间中创建。system表空间不支持COMPRESSED行格式。为了在file-per-table表空间中存储压缩表,innodb_file_per_table必须启用,innodb_file_format必须设置为Barracuda。innodb_file_per_table和innodb_file_format配置选项不适用于一般表空间。一般表空间支持所有的行格式,但需要注意的是,由于物理页大小不同,压缩表和未压缩表不能在同一通用表空间
中共存。

mysql> show variables like 'innodb_file_per_table';
+-----------------------+-------+
| Variable_name         | Value |
+-----------------------+-------+
| innodb_file_per_table | ON    |
+-----------------------+-------+
1 row in set (0.00 sec)

mysql>  show variables like 'innodb_file_format';
+--------------------+-----------+
| Variable_name      | Value     |
+--------------------+-----------+
| innodb_file_format | Barracuda |
+--------------------+-----------+
1 row in set (0.01 sec)

DYNAMIC表可以存储在file-per-table表空间、通用表空间和系统表空间中。要在系统表空间中存储DYNAMIC表,必须使用CREATE TABLE或ALTER TABLE语句并使用选项tablespace [=] innodb_system。innodb_file_per_table和innodb_file_format配置选项不适用于一般表空间,也不适用于使用TABLESPACE [=] innodb_system表选项在system表空间中存储DYNAMIC表。

可以通过禁用innodb_file_per_table并使用常规的CREATE TABLE或ALTER TABLE语句向系统表空间添加一个DYNAMIC表。innodb_file_format设置将被忽略。DYNAMIC表总是使用Barracuda文件格式。

DYNAMIC和COMPRESSED行格式是COMPACT行格式的变体,因此处理CHAR存储的方式与COMPACT行格式相同。

COMPACT and REDUNDANT行格式
早期版本的InnoDB使用一种未命名的文件格式(现在称为Antelope)来处理数据库文件。对于这种文件格式,表定义为ROW_FORMAT=COMPACT或ROW_FORMAT=REDUNDANT。使用这些行格式,InnoDB将可变长度列(VARCHAR, VARBINARY, BLOB和TEXT类型)的前768字节存储在b树节点的索引记录中,其余的存储在溢出页上。InnoDB还将长度大于或等于768字节的固定长度字段编码为可变长度字段,可以存储在页外。例如,如果字符集的最大字节长度大于3,那么CHAR(255)列可以超过768字节,就像utf8mb4一样。

对于Antelope文件格式,如果列的值为768字节或更少,则不需要溢出页,并且可能会节省一些I/O,因为该值位于b树节点中。这对于相对较短的blob很有效,但可能导致B树节点填充数据而不是键值,从而降低了它们的效率。具有许多BLOB列的表可能会导致B树节点的数据太满,而包含的行太少,从而使整个索引的效率低于行更短或列值存储在页外的情况。

]]>
http://www.jydba.net/index.php/archives/3508/feed 0
MySQL InnoDB页面压缩 http://www.jydba.net/index.php/archives/3501 http://www.jydba.net/index.php/archives/3501#respond Fri, 04 Aug 2023 08:51:22 +0000 http://www.jydba.net/?p=3501 InnoDB页面压缩
innoDB支持页面级别的表压缩,这些表位于file-per-table表空间中。这个特性被称为透明页面压缩。通过使用CREATE TABLE或ALTER TABLE指定compression属性,可以启用页面压缩。支持的压缩算法包括Zlib和LZ4。

支持平台
页面压缩需要稀疏文件和穿孔支持。在带有NTFS的Windows上,以及以下支持mysql的Linux平台子集上支持页面压缩,其中内核级别提供了hole punch支持:
. RHEL 7 and derived distributions that use kernel version 3.10.0-123 or higher
. OEL 5.10 (UEK2) kernel version 2.6.39 or higher
. OEL 6.5 (UEK3) kernel version 3.8.13 or higher
. OEL 7.0 kernel version 3.8.13 or higher
. SLE11 kernel version 3.0-x
. SLE12 kernel version 3.12-x
. OES11 kernel version 3.0-x
. Ubuntu 14.0.4 LTS kernel version 3.13 or higher
. Ubuntu 12.0.4 LTS kernel version 3.2 or higher
. Debian 7 kernel version 3.2 or higher

对于给定的Linux发行版,所有可用的文件系统可能都不支持打孔。

页面压缩工作原理
在写入一页时,使用指定的压缩算法对其进行压缩。压缩后的数据被写入磁盘,在磁盘上打孔机制从页的末尾释放空块。如果压缩失败,数据会原样写入。

Linux上的打孔尺寸
在Linux系统中,文件系统块长度是用于打孔的单位长度。因此,只有当页面数据可以压缩到小于或等于InnoDB页面大小减去文件系统块大小时,页面压缩才有效。例如,如果innodb_page_size=16K,文件系统块大小为4K,则页面数据必须压缩到小于或等于12K,才能穿孔。

Windows上的打孔尺寸
在Windows系统上,用于稀疏文件的底层基础设施是基于NTFS压缩。冲孔尺寸为NTFS压缩单元,是NTFS集群尺寸的16倍。集群大小及其压缩单位如下表所示:

Windows NTFS集群大小和压缩单元
集群大小 压缩单元
512 Bytes 8 KB
1 KB 16 KB
2 KB 32 KB
4 KB 64 KB

在Windows系统上,只有当页面数据可以压缩到小于或等于InnoDB页面大小减去压缩单位大小时,页面压缩才有效。

NTFS集群的默认大小是4K,其中压缩单位大小是64K。这意味着页面压缩对于开箱即用的Windows NTFS配置没有任何好处,因为innodb_page_size的最大值也是64K。

为了让页面压缩在Windows上工作,创建文件系统时必须使用小于4K的集群大小,并且innodb_page_size必须至少是压缩单元大小的两倍。例如,为了让页面压缩在Windows上工作,你可以构建一个512字节的集群文件系统(压缩单位是8KB),并将InnoDB初始化为16K或更高的值。

启用页面压缩
要启用页面压缩,请在CREATE TABLE语句中指定compression属性。例如:

mysql> CREATE TABLE t7 (c1 INT) COMPRESSION="zlib";
Query OK, 0 rows affected (0.03 sec)

您还可以在ALTER TABLE语句中启用页面压缩。但是,ALTER TABLE…COMPRESSION只更新表空间的COMPRESSION属性。在设置新的压缩算法之后,对表空间的写入将使用新的设置,但是要将新的压缩算法应用到现有页面,必须使用OPTIMIZE table重建表。
mysql>  CREATE TABLE t8 (c1 INT);
Query OK, 0 rows affected (0.01 sec)

mysql>  ALTER TABLE t8 COMPRESSION="zlib";
Query OK, 0 rows affected (0.01 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql> OPTIMIZE TABLE t8;
+---------+----------+----------+-------------------------------------------------------------------+
| Table   | Op       | Msg_type | Msg_text                                                          |
+---------+----------+----------+-------------------------------------------------------------------+
| undo.t8 | optimize | note     | Table does not support optimize, doing recreate + analyze instead |
| undo.t8 | optimize | status   | OK                                                                |
+---------+----------+----------+-------------------------------------------------------------------+
2 rows in set (0.02 sec)

对于Innodb存储引擎不能支持optimize table,Myisam存储引擎支持optimize table。

禁用页面压缩
要禁用页面压缩,请使用ALTER TABLE设置compression =None。在设置COMPRESSION=None后,写入表空间不再使用页面压缩。要解压缩现有页面,必须在设置COMPRESSION=None后使用OPTIMIZE TABLE重新构建表。

mysql> ALTER TABLE t8 COMPRESSION="None";
Query OK, 0 rows affected (0.00 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql> OPTIMIZE TABLE t8;
+---------+----------+----------+-------------------------------------------------------------------+
| Table   | Op       | Msg_type | Msg_text                                                          |
+---------+----------+----------+-------------------------------------------------------------------+
| undo.t8 | optimize | note     | Table does not support optimize, doing recreate + analyze instead |
| undo.t8 | optimize | status   | OK                                                                |
+---------+----------+----------+-------------------------------------------------------------------+
2 rows in set (0.02 sec)

mysql> show create table t8;
+-------+------------------------------------------------------------------------------------------------------------+
| Table | Create Table                                                                                               |
+-------+------------------------------------------------------------------------------------------------------------+
| t8    | CREATE TABLE `t8` (
  `c1` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMPRESSION='None' |
+-------+------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

页面压缩元数据
页面压缩元数据可以在INFORMATION_SCHEMA.INNODB_SYS_TABLESPACES表中找到。在下列列中:
.FS_BLOCK_SIZE:文件系统块大小,打孔时使用的单位大小。

.FILE_SIZE:文件的外观大小,表示未压缩时文件的最大大小。

.ALLOCATED_SIZE:文件的实际大小,即在磁盘上分配的空间量。

在类unix系统上,使用ls -l tablespace_name.ibd以字节为单位给出了明显的文件长度(相当于FILE_SIZE)。要查看磁盘上实际分配的空间大小(相当于ALLOCATED_SIZE),可以使用du –block-size=1 tablespace_name.ibd。–block-size=1选项以字节(而不是块)打印分配的空间,以便与ls -l的输出进行比较。

使用SHOW CREATE TABLE查看当前页面压缩设置(Zlib、Lz4或None)。一个表可能包含具有不同压缩设置的混合页面。

在下面的示例中,从INFORMATION_SCHEMA.INNODB_SYS_TABLESPACES表中检索employees表的页面压缩元数据。

# Create the employees table with Zlib page compression
mysql> CREATE TABLE employees (
    -> emp_no INT NOT NULL,
    -> birth_date DATE NOT NULL,
    -> first_name VARCHAR(14) NOT NULL,
    -> last_name VARCHAR(16) NOT NULL,
    -> gender ENUM ('M','F') NOT NULL,
    -> hire_date DATE NOT NULL,
    -> PRIMARY KEY (emp_no)
    -> ) COMPRESSION="zlib";
Query OK, 0 rows affected (0.01 sec)

# Insert data
mysql> insert into employees values(1,'1985-02-28','yong','jing','M','2023-08-04');
Query OK, 1 row affected (0.00 sec)

mysql> commit;
Query OK, 0 rows affected (0.00 sec)


# Query page compression metadata in INFORMATION_SCHEMA.INNODB_SYS_TABLESPACES

mysql> SELECT SPACE, NAME, FS_BLOCK_SIZE, FILE_SIZE, ALLOCATED_SIZE FROM
    -> INFORMATION_SCHEMA.INNODB_SYS_TABLESPACES WHERE NAME='undo/employees'\G
*************************** 1. row ***************************
         SPACE: 498
          NAME: undo/employees
 FS_BLOCK_SIZE: 4096
     FILE_SIZE: 98304
ALLOCATED_SIZE: 61440
1 row in set (0.01 sec)

employees表的页面压缩元数据显示,表面文件大小为98304字节,而实际文件大小(使用页面压缩)为61440字节。文件系统块大小为4096字节,即穿孔时使用的块大小。

页面压缩限制和使用说明
.如果文件系统块大小(或Windows上的压缩单位大小)* 2>innodb_page_size禁用页面压缩。

.对于驻留在共享表空间中的表,包括system表空间、临时表空间和一般表空间,不支持页面压缩。

.undo日志表空间不支持页面压缩。

.重做日志页面不支持页面压缩。

.用于空间索引的R树页面不能被压缩。

.属于压缩表(ROW_FORMAT= compressed)的页面保持原样。

.在恢复过程中,更新后的页面将以未压缩的形式输出。

.在不支持所用压缩算法的服务器上加载页压缩表空间会导致I/O错误。

.在降级到不支持页面压缩的MySQL早期版本之前,请解压使用页面压缩特性的表。要解压一张表,运行ALTER table…compression=None和
optimize table。

.如果所使用的压缩算法在Linux和Windows服务器上可用,则可以在Linux和Windows服务器之间复制页压缩表空间。

.在将页面压缩的表空间文件从一台主机移动到另一台主机时保持页面压缩需要一个保留稀疏文件的实用程序。

.与其他平台相比,使用NVMFS的Fusion-io硬件可以实现更好的页面压缩,因为NVMFS旨在利用打孔功能。

.在InnoDB页面大小较大和文件系统块相对较小的情况下使用页面压缩特性可能会导致写入放大。例如,InnoDB页的最大大小为64KB,而文件系统块的大小为4KB,这可能会提高压缩性能,但也可能会增加对缓冲池的需求,从而导致I/O增加和潜在的写放大。

]]>
http://www.jydba.net/index.php/archives/3501/feed 0
MySQL InnoDB表压缩 http://www.jydba.net/index.php/archives/3499 http://www.jydba.net/index.php/archives/3499#respond Fri, 04 Aug 2023 08:46:21 +0000 http://www.jydba.net/?p=3499 InnoDB表压缩
InnoDB表压缩,它支持在file_per_table表空间或普通表空间中的InnoDB表。使用ROW_FORMAT=COMPRESSED属性与CREATE Table或ALTER Table一起启用表压缩。

表压缩概述
InnoDB表压缩,它支持在file_per_table表空间或普通表空间中的InnoDB表。使用ROW_FORMAT=COMPRESSED属性与CREATE Table或ALTER Table一起启用表压缩。

表压缩概述
由于处理器和缓存内存的速度比磁盘存储设备提高得更快,因此许多工作负载都是磁盘绑定的。数据压缩可以实现更小的数据库大小、更少的I/O和更高的吞吐量,而增加CPU利用率的代价很小。压缩对于读密集型应用程序尤其有价值,因为系统有足够的RAM将经常使用的数据保存在内存中。

使用ROW_FORMAT=COMPRESSED创建的InnoDB表可以在磁盘上使用比配置的innodb_page_size值更小的页面大小。更小的页面需要更少的I/O来读写磁盘,这对于SSD设备来说特别有价值。

压缩后的页面大小通过CREATE TABLE或ALTER TABLE KEY_BLOCK_SIZE参数指定。不同的页面大小要求将表放在file-per-table表空间或通用表空间中,而不是放在系统表空间中,因为系统表空间不能存储压缩表。

无论KEY_BLOCK_SIZE值如何,压缩级别都是相同的。当您为KEY_BLOCK_SIZE指定较小的值时,您将获得越来越小的页面所带来的I/O好处。但是,如果指定的值太小,则在数据值无法压缩到足以容纳每个页中的多行时,会有重新组织页的额外开销。表的KEY_BLOCK_SIZE可以有多小是有严格限制的,这取决于每个索引的键列的长度。如果指定的值太小,CREATE TABLE或ALTER TABLE语句将失败。

在缓冲池中,压缩数据保存在小页面中,页面大小基于KEY_BLOCK_SIZE值。为了提取或更新列值,MySQL还使用未压缩的数据在缓冲池中创建一个未压缩的页面。在缓冲池中,对未压缩页面的任何更新也会被重新写回等效的压缩页面。您可能需要调整缓冲池的大小,以容纳压缩和未压缩页面的附加数据,尽管在需要空间时将未压缩页面从缓冲池中取出,然后在下一次访问时再次解压缩。

创建压缩表
压缩表可以在file-per-table表空间中创建,也可以在一般表空间中创建。InnoDB系统表空间不支持表压缩。系统表空间(空间0,.ibdata文件)可以包含用户创建的表,但它也包含内部系统数据,这些数据从未被压缩过。因此,压缩只适用于存储在file-per-table或一般表空间中的表(和索引)。

在file-per-table表空间中创建压缩表
要在file-per-table表空间中创建压缩表,innodb_file_per_table必须启用(MySQL 5.6.6默认设置),innodb_file_format必须设置为Barracuda。您可以在MySQL配置文件(my.cnf或my.ini)中设置这些参数,也可以使用set语句动态设置这些参数

在配置了innodb_file_per_table和innodb_file_format选项后,在CREATE TABLE或ALTER TABLE语句中指定ROW_FORMAT=COMPRESSED或KEY_BLOCK_SIZE子句,或两者都指定,以在file-per-table表空间中创建压缩表。

例如,你可以使用以下语句:

mysql> SET GLOBAL innodb_file_per_table=1;
Query OK, 0 rows affected (0.00 sec)

mysql> SET GLOBAL innodb_file_format=Barracuda;
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> CREATE TABLE t1
    -> (c1 INT PRIMARY KEY)
    -> ROW_FORMAT=COMPRESSED
    -> KEY_BLOCK_SIZE=8;
Query OK, 0 rows affected (0.01 sec)

在通用表空间中创建压缩表
要在通用表空间中创建压缩表,必须为通用表空间定义FILE_BLOCK_SIZE,该值在创建表空间时指定。FILE_BLOCK_SIZE值必须是相对于innodb_page_size值的有效压缩页大小,并且由CREATE table或ALTER table KEY_BLOCK_SIZE子句定义的压缩表的页大小必须等于FILE_BLOCK_SIZE/1024。例如,innodb_page_size=16384, FILE_BLOCK_SIZE=8192,则表的KEY_BLOCK_SIZE必须为8。

下面的示例演示创建一个通用表空间和添加一个压缩表。本例innodb_page_size的默认值为16K。FILE_BLOCK_SIZE为8192要求压缩表的KEY_BLOCK_SIZE为8。

mysql> show variables like 'innodb_page_size';
+------------------+-------+
| Variable_name    | Value |
+------------------+-------+
| innodb_page_size | 16384 |
+------------------+-------+
1 row in set (0.02 sec)

mysql> CREATE TABLESPACE ts3 ADD DATAFILE 'ts3.ibd' FILE_BLOCK_SIZE = 8192 Engine=InnoDB;
Query OK, 0 rows affected (0.01 sec)

mysql> CREATE TABLE t2 (c1 INT PRIMARY KEY) TABLESPACE ts3 ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=8;
Query OK, 0 rows affected (0.01 sec)

注意:
.如果指定ROW_FORMAT=COMPRESSED,则可以省略KEY_BLOCK_SIZE;KEY_BLOCK_SIZE默认为innodb_page_size值的一半。

.如果你指定了一个有效的KEY_BLOCK_SIZE值,你可以忽略ROW_FORMAT=COMPRESSED;自动启用压缩功能。

.要确定KEY_BLOCK_SIZE的最佳值,通常需要为该子句创建具有不同值的同一表的多个副本,然后测量生成的.ibd文件的大小,并查看每个文件在实际工作负载下的性能如何。对于一般的表空间,请记住,删除表并不会减少一般表空间.ibd文件的大小,也不会将磁盘空间返回给操作系统。

.KEY_BLOCK_SIZE值被视为提示;如果需要,InnoDB可以使用不同的大小。对于file-per-table表空间,KEY_BLOCK_SIZE只能小于或等于innodb_page_size值。如果指定的值大于innodb_page_size,则忽略指定的值,并发出警告,并将KEY_BLOCK_SIZE设置为innodb_page_size值的一半。如果innodb_strict_mode=ON,指定无效的KEY_BLOCK_SIZE值将返回错误。对于一般的表空间,有效的KEY_BLOCK_SIZE值取决于表空间的FILE_BLOCK_SIZE设置。

.32k和64k页面大小不支持压缩。

.InnoDB数据页的默认未压缩大小是16KB。根据选项值的组合,MySQL使用1KB、2KB、4KB、8KB或16KB的页大小来存放表空间数据文件(.ibd文件)。实际的压缩算法不受KEY_BLOCK_SIZE值的影响;该值决定每个压缩块的大小,进而影响每个压缩页中可以装入多少行。

.当在file-per-table表空间中创建压缩表时,将KEY_BLOCK_SIZE设置为InnoDB页面大小通常不会导致太多压缩。例如,设置KEY_BLOCK_SIZE=16通常不会导致太多的压缩,因为正常的InnoDB页面大小是16KB。此设置对于具有许多长BLOB、VARCHAR或TEXT列的表可能仍然有用,因为这些值通常可以很好地压缩,因此可能需要更少的溢出页。对于一般的表空间,KEY_BLOCK_SIZE值等于InnoDB页面大小是不允许的。

.表的所有索引(包括聚集索引)使用相同的页面大小进行压缩,这在CREATE table或ALTER table语句中指定。表属性如ROW_FORMAT和KEY_BLOCK_SIZE不是InnoDB表的CREATE INDEX语法的一部分,如果指定了,它们将被忽略(尽管,如果指定了,它们将出现在SHOW CREATE Table语句的输出中)。

压缩表的限制
.5.1之前的MySQL版本不能处理压缩表。

.压缩表不能存储在InnoDB系统表空间中。

.一般表空间可以包含多个表,但是压缩表和未压缩表不能在同一个表空间中共存。

.压缩适用于整个表及其所有关联索引,而不是单独的行,尽管子句名为ROW_FORMAT。

InnoDB表压缩调优
大多数情况下,InnoDB数据存储和压缩中描述的内部优化可以确保系统在压缩数据下运行良好。但是,由于压缩的效率取决于数据的性质,因此您可以做出影响压缩表性能的决定:
.要压缩哪些表。

.要使用的压缩页面大小。

.是否根据运行时性能特征(例如系统压缩和解压缩数据所花费的时间)调整缓冲池的大小。工作负载更像数据仓库(主要是查询)还是OLTP系统(查询和DML的混合)。

.如果系统在压缩表上执行DML操作,并且数据分布的方式在运行时导致代价高昂的压缩失败,那么您可能需要调整其他高级配置选项。

何时使用压缩
一般来说,压缩在包含合理数量的字符串列的表上效果最好,并且数据的读取次数远远多于写入次数。因为没有保证的方法来预测压缩是否有利于特定情况,所以总是使用在代表性配置上运行的特定工作负载和数据集进行测试。在决定压缩哪些表时,请考虑以下因素。

数据特性与压缩
在压缩数据文件时,决定压缩效率的一个关键因素是数据本身的性质。回想一下,压缩的工作原理是识别数据块中重复的字节串。完全随机的数据是最糟糕的情况。典型的数据通常有重复的值,因此压缩效果很好。无论是定义在CHAR、VARCHAR、TEXT还是BLOB列中的字符串,通常压缩效果都很好。另一方面,主要包含二进制数据(整数或浮点数)或之前压缩过的数据(例如JPEG或PNG图像)的表通常不能很好地压缩,或者显著压缩,或者根本压缩不了。

你可以选择是否为每个InnoDB表开启压缩。一张表及其所有索引使用相同的(压缩的)页面大小。可能是包含表中所有列数据的主键(聚集)索引比辅助索引压缩更有效。对于那些行很长的情况,使用压缩可能会导致长列值被存储在“页外”,那些溢出的页面可以很好地压缩。考虑到这些因素,对于许多应用程序,有些表的压缩比其他表的压缩更有效,并且您可能会发现只有在压缩了一部分表的情况下,您的工作负载才能达到最佳性能。

要确定是否要压缩一个特定的表,可以进行实验。通过使用对未压缩表的.ibd文件副本实现LZ77压缩的实用程序(如gzip或WinZip),您可以粗略估计数据压缩的效率。与基于文件的压缩工具相比,MySQL压缩表的压缩更少,因为MySQL根据页面大小(默认为16KB)分块压缩数据。除了用户数据之外,页面格式还包括一些未压缩的内部系统数据。基于文件的压缩工具可以检查更大的数据块,因此可能会在一个巨大的文件中发现更多重复的字符串比MySQL在单个页面中所能找到的多。

在特定表上测试压缩的另一种方法是将一些数据从未压缩的表复制到一个类似的、压缩的表(具有相同的索引)中,并查看生成的.ibd文件的大小。
例如:

mysql> use undo
Database changed
mysql> SET GLOBAL innodb_file_per_table=1;
Query OK, 0 rows affected (0.00 sec)

mysql> SET GLOBAL innodb_file_format=Barracuda;
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> SET GLOBAL autocommit=0;
Query OK, 0 rows affected (0.00 sec)

mysql> CREATE TABLE big_table AS SELECT * FROM information_schema.columns;
Query OK, 3249 rows affected, 1 warning (0.52 sec)
Records: 3249  Duplicates: 0  Warnings: 1

mysql> INSERT INTO big_table SELECT * FROM big_table;
Query OK, 3249 rows affected (0.05 sec)
Records: 3249  Duplicates: 0  Warnings: 0

mysql> INSERT INTO big_table SELECT * FROM big_table;
Query OK, 6498 rows affected (0.10 sec)
Records: 6498  Duplicates: 0  Warnings: 0

mysql> INSERT INTO big_table SELECT * FROM big_table;
Query OK, 12996 rows affected (0.20 sec)
Records: 12996  Duplicates: 0  Warnings: 0

mysql> INSERT INTO big_table SELECT * FROM big_table;
Query OK, 25992 rows affected (0.51 sec)
Records: 25992  Duplicates: 0  Warnings: 0

mysql> INSERT INTO big_table SELECT * FROM big_table;
Query OK, 51984 rows affected (0.78 sec)
Records: 51984  Duplicates: 0  Warnings: 0

mysql> INSERT INTO big_table SELECT * FROM big_table;
Query OK, 103968 rows affected (1.40 sec)
Records: 103968  Duplicates: 0  Warnings: 0

mysql> INSERT INTO big_table SELECT * FROM big_table;
Query OK, 207936 rows affected (2.84 sec)
Records: 207936  Duplicates: 0  Warnings: 0

mysql> INSERT INTO big_table SELECT * FROM big_table;
Query OK, 415872 rows affected (5.72 sec)
Records: 415872  Duplicates: 0  Warnings: 0

mysql> INSERT INTO big_table SELECT * FROM big_table;
Query OK, 831744 rows affected (11.46 sec)
Records: 831744  Duplicates: 0  Warnings: 0

mysql> INSERT INTO big_table SELECT * FROM big_table;
Query OK, 1663488 rows affected (22.86 sec)
Records: 1663488  Duplicates: 0  Warnings: 0

mysql> commit;
Query OK, 0 rows affected (0.00 sec)

mysql> ALTER TABLE big_table ADD id int unsigned NOT NULL PRIMARY KEY auto_increment;
Query OK, 0 rows affected (48.18 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql> SHOW CREATE TABLE big_table\G
*************************** 1. row ***************************
       Table: big_table
Create Table: CREATE TABLE `big_table` (
  `TABLE_CATALOG` varchar(512) CHARACTER SET utf8 NOT NULL DEFAULT '',
  `TABLE_SCHEMA` varchar(64) CHARACTER SET utf8 NOT NULL DEFAULT '',
  `TABLE_NAME` varchar(64) CHARACTER SET utf8 NOT NULL DEFAULT '',
  `COLUMN_NAME` varchar(64) CHARACTER SET utf8 NOT NULL DEFAULT '',
  `ORDINAL_POSITION` bigint(21) unsigned NOT NULL DEFAULT '0',
  `COLUMN_DEFAULT` longtext CHARACTER SET utf8,
  `IS_NULLABLE` varchar(3) CHARACTER SET utf8 NOT NULL DEFAULT '',
  `DATA_TYPE` varchar(64) CHARACTER SET utf8 NOT NULL DEFAULT '',
  `CHARACTER_MAXIMUM_LENGTH` bigint(21) unsigned DEFAULT NULL,
  `CHARACTER_OCTET_LENGTH` bigint(21) unsigned DEFAULT NULL,
  `NUMERIC_PRECISION` bigint(21) unsigned DEFAULT NULL,
  `NUMERIC_SCALE` bigint(21) unsigned DEFAULT NULL,
  `DATETIME_PRECISION` bigint(21) unsigned DEFAULT NULL,
  `CHARACTER_SET_NAME` varchar(32) CHARACTER SET utf8 DEFAULT NULL,
  `COLLATION_NAME` varchar(32) CHARACTER SET utf8 DEFAULT NULL,
  `COLUMN_TYPE` longtext CHARACTER SET utf8 NOT NULL,
  `COLUMN_KEY` varchar(3) CHARACTER SET utf8 NOT NULL DEFAULT '',
  `EXTRA` varchar(30) CHARACTER SET utf8 NOT NULL DEFAULT '',
  `PRIVILEGES` varchar(80) CHARACTER SET utf8 NOT NULL DEFAULT '',
  `COLUMN_COMMENT` varchar(1024) CHARACTER SET utf8 NOT NULL DEFAULT '',
  `GENERATION_EXPRESSION` longtext CHARACTER SET utf8 NOT NULL,
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3326977 DEFAULT CHARSET=utf8mb4
1 row in set (0.00 sec)

mysql> select count(id) from big_table;
+-----------+
| count(id) |
+-----------+
|   3326976 |
+-----------+
1 row in set (1.09 sec)


mysql> \! ls -l /mysqldata/mysql/undo/big_table.ibd
-rw-r-----. 1 mysql mysql 708837376 Jul  6 18:06 /mysqldata/mysql/undo/big_table.ibd


mysql> CREATE TABLE key_block_size_4 LIKE big_table;
Query OK, 0 rows affected (0.02 sec)

mysql> ALTER TABLE key_block_size_4 key_block_size=4 row_format=compressed;
Query OK, 0 rows affected (0.02 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql> INSERT INTO key_block_size_4 SELECT * FROM big_table;
Query OK, 3326976 rows affected (2 min 52.11 sec)
Records: 3326976  Duplicates: 0  Warnings: 0

mysql> commit;
Query OK, 0 rows affected (0.00 sec)

mysql> \! ls -l /mysqldata/mysql/undo/key_block_size_4.ibd
-rw-r-----. 1 mysql mysql 155189248 Jul  6 18:11 /mysqldata/mysql/undo/key_block_size_4.ibd

这个实验产生了以下数字,当然,根据您的表结构和数据,这些数字可能会有很大的不同:
-rw-r-----. 1 mysql mysql 708837376 Jul  6 18:06 /mysqldata/mysql/undo/big_table.ibd
-rw-r-----. 1 mysql mysql 155189248 Jul  6 18:11 /mysqldata/mysql/undo/key_block_size_4.ibd

要查看压缩对您的特定工作负载是否有效:
.对于简单的测试,使用一个没有其他压缩表的MySQL实例,并对INFORMATION_SCHEMA.INNODB_CMP表进行查询。

.对于涉及多个压缩表的工作负载的更复杂的测试,可以对INFORMATION_SCHEMA.INNODB_CMP_PER_INDEX表进行查询。因为收集INNODB_CMP_PER_INDEX表中的统计信息非常昂贵,所以你必须在查询这张表之前启用配置选项innodb_cmp_per_index_enabled,并且你可以将这样的测试限制在开发服务器或非关键的从服务器上。

.对正在测试的压缩表运行一些典型的SQL语句。

.通过查询INFORMATION_SCHEMA.INNODB_CMP或INFORMATION_SCHEMA.INNODB_CMP_PER_INDEX表,并比较COMPRESS_OPS和COMPRESS_OPS_OK,可以查看成功压缩操作与总体压缩操作的比率。

.如果成功完成的压缩操作的百分比很高,则该表可能是压缩的一个很好的候选者。

.如果压缩失败的比例很高,您可以调整innodb_compression_level、innodb_compression_failure_threshold_pct和innodb_compression_pad_pct_max选项,并尝试进一步的测试。

数据库压缩与应用程序压缩
决定压缩应用程序中的数据还是表中的数据;不要对同一数据同时使用两种压缩方式。当压缩应用程序中的数据并将结果存储在压缩表中时,几乎不可能节省额外的空间,而双重压缩只会浪费CPU周期。

在数据库中压缩
当启用时,MySQL表压缩是自动的,并且适用于所有列和索引值。这些列仍然可以使用LIKE之类的操作符进行测试,即使索引值被压缩了,排序操作仍然可以使用索引。因为索引通常占数据库总大小的很大一部分,所以压缩可以显著节省存储、I/O或处理器时间。压缩和解压缩操作发生在数据库服务器上,这可能是一个强大的系统,其大小可以处理预期的负载。

应用程序压缩
如果在应用程序中压缩文本等数据,在将其插入数据库之前,通过压缩某些列而不压缩其他列,可以为压缩效果不好的数据节省开销。这种方法使用CPU周期在客户机机器上而不是数据库服务器上进行压缩和解压缩,这可能适用于具有许多客户机的分布式应用程序,或者客户机机器有空闲CPU周期的情况。

混合方法
当然,也可以结合使用这两种方法。对于某些应用程序,可能适合使用一些压缩表和一些非压缩表。最好从外部压缩一些数据(并将其存储在未压缩的表中),并允许MySQL压缩应用程序中的其他表。与往常一样,预先设计和真实的测试对于做出正确的决定是有价值的。

工作负载特征和压缩
除了选择要压缩的表(和页面大小)之外,工作负载是性能的另一个关键决定因素。如果应用程序主要是读操作,而不是更新操作,那么在索引页耗尽MySQL为压缩数据维护的每页“修改日志”的空间后,需要重新组织和重新压缩的页面就会更少。如果更新主要是更改非索引的列,或者那些包含blob或大字符串的列,它们恰巧存储在“页外”,那么压缩的开销是可以接受的。如果对表的唯一更改是使用单调递增主键的插入,并且辅助索引很少,那么就不需要重新组织和重新压缩索引页。由于MySQL可以通过修改未压缩的数据“就地”删除压缩页上的行,因此表上的删除操作是相对高效的。

对于某些环境,加载数据所需的时间可能与运行时检索同样重要。特别是在数据仓库环境中,许多表可能是只读的或大多数情况下是只读的。在这些情况下,以增加加载时间为代价进行压缩可能是可接受的,也可能是不可接受的,除非由此减少磁盘读取或存储成本的节省非常显著。

基本上,当CPU时间可以用于压缩和解压缩数据时,压缩工作得最好。因此,如果您的工作负载是I/O绑定的,而不是cpu绑定的,您可能会发现压缩可以提高整体性能。当您使用不同的压缩配置测试应用程序性能时,请在与生产系统的计划配置类似的平台上进行测试。

配置特点及压缩
从磁盘读写数据库页面是系统性能最慢的方面。压缩试图通过使用CPU时间来压缩和解压缩数据来减少I/O,当I/O相对于处理器周期来说是一种稀缺资源时,这种方法最有效。

当运行在具有快速多核cpu的多用户环境中时,情况尤其如此。当压缩表的一页在内存中时,MySQL通常会使用额外的内存,通常是16KB,在缓冲池中用于页面的未压缩副本。自适应LRU算法试图平衡压缩页和未压缩页之间的内存使用,以考虑工作负载是以I/ o绑定方式还是cpu绑定方式运行。尽管如此,在使用压缩表时,为缓冲池提供更多内存的配置往往比内存高度受限的配置运行得更好。

选择压缩页面大小
压缩页大小的最佳设置取决于表及其索引包含的数据的类型和分布。压缩后的页面大小应该总是大于最大记录大小,否则操作可能会失败,正如b树页面压缩中提到的那样。

将压缩页的大小设置得太大会浪费一些空间,但并不需要经常压缩页。如果压缩页大小设置得太小,插入或更新可能需要耗时的重新压缩,并且b树节点可能需要更频繁地分割,导致数据文件更大和索引效率更低。

通常,您可以将压缩页面大小设置为8K或4K字节。考虑到InnoDB表的最大行大小大约是8K, KEY_BLOCK_SIZE=8通常是一个安全的选择。

在运行时监控InnoDB表压缩
应用程序的整体性能、CPU和I/O利用率以及磁盘文件的大小都可以很好地反映压缩对应用程序的有效性。基于“InnoDB表的压缩调优”中的性能调优建议,并展示如何发现在初始测试中可能不会出现的问题。

为了更深入地了解压缩表的性能考虑因素,你可以使用INFORMATION_SCHEMA方案中的表来监控运行时的压缩性能。这些表反映了内存的内部使用情况和总体的压缩率。

INNODB_CMP表报告了每个压缩页大小(KEY_BLOCK_SIZE)的压缩活动信息。这些表中的信息是系统范围的:它总结了数据库中所有压缩表的压缩统计信息。当没有其他压缩表被访问时,通过检查这些表,可以使用这些数据来帮助决定是否要压缩表。它在服务器上的开销相对较低,所以你可以定期在生产服务器上查询它,以检查压缩特性的整体效率。

INNODB_CMP_PER_INDEX表报告了关于单个表和索引的压缩活动的信息。这些信息更有针对性,对于评估压缩效率和诊断一次一个表或索引的性能问题更有用。(因为每个InnoDB表都表示为一个聚集索引,MySQL在这个上下文中没有对表和索引做很大的区分。)INNODB_CMP_PER_INDEX表确实涉及大量的开销,因此它更适合于开发服务器,在那里你可以单独比较不同工作负载、数据和压缩设置的影响。为了防止意外造成这种监控开销,用户必须在查询INNODB_CMP_PER_INDEX表之前启用innodb_cmp_per_index_enabled配置选项。

要考虑的主要统计数据是执行压缩和解压缩操作的数量和时间。由于MySQL在修改后会在b树节点满到无法包含压缩后的数据时拆分b树节点,因此需要将“成功”的压缩操作的数量与此类操作的总体数量进行比较。根据INNODB_CMP和INNODB_CMP_PER_INDEX表中的信息以及应用程序的整体性能和硬件资源利用率,您可以更改硬件配置,调整缓冲池的大小,选择不同的页面大小,或者选择不同的表集进行压缩。

如果压缩和解压缩所需的CPU时间非常多,那么在相同的数据、应用程序工作负载和压缩表集的情况下,改用更快的CPU或多核CPU可以帮助提高性能。增加缓冲池的大小也可能有助于提高性能,这样更多未压缩的页可以驻留在内存中,减少了对仅以压缩形式存在于内存中的页进行压缩的需求。

总体上大量的压缩操作(与应用程序中的插入、更新和删除操作的数量以及数据库的大小相比)可能表明某些压缩表的更新过于频繁,无法进行有效的压缩。如果是这样,请选择更大的页面大小,或者对要压缩的表更有选择性。

如果“成功”的压缩操作数量(COMPRESS_OPS_OK)占压缩操作总数(COMPRESS_OPS)的比例很高,那么系统可能性能良好。如果这个比率很低,那么MySQL会频繁地重组、重新压缩和分裂b树节点。在这种情况下,请避免压缩某些表,或者增大某些已压缩表的KEY_BLOCK_SIZE。如果你关闭了表的压缩,导致应用程序中的“压缩失败”数量超过了总数的1%或2%,那么你可以关闭表的压缩。(在数据加载等临时操作期间,这样的失败率是可以接受的)。

如何压缩InnoDB表
本节描述一些关于InnoDB表压缩的内部实现细节。这里提供的信息可能对性能调优有帮助,但对于压缩的基本使用来说没有必要知道。

压缩算法
有些操作系统在文件系统级别实现压缩。文件通常被划分为固定大小的块,然后被压缩为可变大小的块,这很容易导致碎片。每次数据块中的某些内容被修改时,整个数据块都会被重新压缩,然后再写入磁盘。这些特性使得这种压缩技术不适合在更新密集型数据库系统中使用。

MySQL在著名的zlib库的帮助下实现了压缩,该库实现了LZ77压缩算法。该压缩算法成熟、稳定,在CPU利用率和数据压缩方面都是有效的。该算法是“无损”的,因此原始未压缩的数据总是可以从压缩的形式中重构出来。LZ77压缩的工作原理是找出在要压缩的数据中重复出现的数据序列。数据中值的模式决定了它的压缩效果,但典型的用户数据通常会压缩50%或更多。

InnoDB只支持zlib库到1.2.3版本。

与应用程序执行的压缩或其他一些数据库管理系统的压缩特性不同,InnoDB压缩同时适用于用户数据和索引。在许多情况下,索引占数据库总大小的40-50%或更多,因此这种差异是显著的。当数据集的压缩工作正常时,InnoDB数据文件的大小(file-per-table表空间或一般的表空间.idb文件)是未压缩大小的25%到50%,甚至可能更小。根据工作负载的不同,这个较小的数据库可以反过来减少I/O,增加吞吐量,但在增加CPU利用率方面代价不大。您可以通过修改innodb_compression_level配置选项来调整压缩级别和CPU开销之间的平衡。

InnoDB数据存储和压缩
InnoDB表中的所有用户数据都存储在由b树索引(聚集索引)组成的页中。在其他一些数据库系统中,这种类型的索引被称为“索引组织表”。索引节点中的每一行包含(用户指定的或系统生成的)主键和表中所有其他列的值。

InnoDB表中的辅助索引也是b树,包含成对的值:索引键和指向聚集索引中的某一行的指针。指针实际上是表的主键的值,如果需要索引键和主键以外的列,则用于访问聚集索引。辅助索引记录必须始终能够放置在单个b树页上。

b树节点(集群索引和辅助索引)的压缩与用于存储长VARCHAR、BLOB或TEXT列的溢出页的压缩处理不同,以下各节将对此进行解释。

压缩b树页面
由于b树页经常更新,因此需要特殊处理。重要的是尽量减少b树节点拆分的次数,以及尽量减少解压缩和重新压缩它们的内容的需要。

MySQL使用的一种技术是在b树节点中以未压缩的形式维护一些系统信息,从而方便某些就地更新。例如,这允许在不进行任何压缩操作的情况下删除标记的行。

此外,当索引页发生变化时,MySQL试图避免不必要的解压缩和重压缩。在每个B-tree页面中,系统保存一个未压缩的“修改日志”来记录对页面所做的更改。小记录的更新和插入可以写入该修改日志,而不需要完全重建整个页面。

当修改日志的空间耗尽时,InnoDB解压缩页面,应用更改并重新压缩页面。如果重新压缩失败(这种情况称为压缩失败),则分割b树节点,并重复该过程,直到更新或插入成功。

为了避免在写密集的应用(比如OLTP应用)中频繁发生压缩失败,MySQL有时会在页面中预留一些空白空间(填充),这样修改日志就会很快填满,并且在有足够空间避免拆分页面时重新压缩页面。随着系统跟踪页面拆分的频率,每个页面中剩余的填充空间的大小也会变化。在一个繁忙的服务器上对压缩表进行频繁的写操作,你可以调整innodb_compression_failure_threshold_pct和innodb_compression_pad_pct_max配置选项来微调这种机制。

一般来说,MySQL要求InnoDB表中的每个B-tree页至少能容纳两条记录。对于压缩表,这个要求已经放宽了。b树节点的叶子页(无论是主键还是辅助索引)只需要容纳一条记录,但该记录必须以未压缩的形式容纳到每个页面的修改日志中。如果innodb_strict_mode是ON, MySQL会在CREATE TABLE或CREATE INDEX时检查最大行大小。如果行不合适,则会发出以下错误消息:error HY000: Too big row。

如果你在innodb_strict_mode关闭时创建表,并且后续的INSERT或UPDATE语句试图创建一个不适合压缩页面大小的索引项,操作将失败,ERROR 42000:Row size too large。(此错误消息没有指出哪个索引的记录太大,也没有提到该索引记录的长度或该特定索引页上的最大记录大小。)要解决这个问题,用ALTER table重建表并选择一个更大的压缩页大小(KEY_BLOCK_SIZE),缩短任何列前缀索引,或完全禁用压缩ROW_FORMAT=DYNAMIC或ROW_FORMAT=COMPACT。

Innodb_strict_mode不适用于普通表空间,普通表空间也支持压缩表。一般表空间的表空间管理规则是严格执行的,独立于innodb_strict_mode。

压缩BLOB、VARCHAR和TEXT列
在InnoDB表中,不属于主键的BLOB、VARCHAR和TEXT列可能会存储在单独分配的溢出页上。我们把这些列称为页外列。其值存储在溢出页的单链表上。

对于以ROW_FORMAT=DYNAMIC或ROW_FORMAT=COMPRESSED创建的表,BLOB、TEXT或VARCHAR列的值可以完全存储在页外,这取决于它们的长度和整行的长度。对于存储在页外的列,聚集索引记录只包含指向溢出页的20字节指针,每个列一个。是否有列存储在页外取决于页大小和行总大小。当一行太长,不能完全装入聚集索引页时,MySQL选择最长的列进行页外存储,直到该行装入聚集索引页为止。如上所述,如果压缩页中某一行不适合它自己,就会发生错误。

对于以ROW_FORMAT=DYNAMIC或ROW_FORMAT=COMPRESSED创建的表,小于或等于40字节的TEXT和BLOB列总是行内存储。

在旧版本的MySQL中创建的表使用羚羊文件格式,它只支持ROW_FORMAT= redundancy和ROW_FORMAT=COMPACT。在这些格式中,MySQL将BLOB、VARCHAR和TEXT列的前768字节与主键一起存储在聚集索引记录中。768字节的前缀后面是一个20字节的指针,指向包含该列剩余值的溢出页。

在表采用压缩格式时,写入溢出页的所有数据都“按原样”压缩;也就是说,MySQL对整个数据项应用zlib压缩算法。除了数据之外,压缩溢出页面还包含一个未压缩的头部和尾部,其中包含一个页面校验和和指向下一个溢出页面的链接。因此,如果数据是高度可压缩的,那么较长的BLOB、TEXT或VARCHAR列可以显著节省存储空间,文本数据通常就是这种情况。图像数据,如JPEG,通常已经被压缩,因此不能从存储在压缩表中获得太多好处;双重压缩可能会浪费CPU周期,但节省的空间很少或根本没有。

溢出页的大小与其他页相同。一个包含10列且存储在页外的行会占用10个溢出页,即使所有列的总长度只有8K字节。在未压缩的表中,10个未压缩的溢出页占用160K字节。在一个页面大小为8K的压缩表中,它们只占用80K字节。因此,对于with的表,使用压缩表格式通常更有效长列值。

对于file-per_table表空间,使用16K的压缩页大小可以减少BLOB、VARCHAR或TEXT列的存储和I/O成本,因为这些数据通常压缩得很好,因此可能需要更少的溢出页,即使b树节点本身占用与未压缩形式相同的页。一般的表空间不支持16K的压缩页大小(KEY_BLOCK_SIZE)。

压缩和InnoDB缓冲池
在一个压缩的InnoDB表中,每个压缩页(无论是1K、2K、4K还是8K)对应一个16K字节的未压缩页(如果设置了innodb_page_size,则更小)。为了访问页面中的数据,MySQL会从磁盘中读取压缩过的页面(如果它不在缓冲池中),然后将页面解压缩为原始形式。本节描述了InnoDB如何管理压缩表的页的缓冲池。

为了尽量减少I/O和减少解压缩页面的需要,缓冲池有时同时包含数据库页面的压缩形式和未压缩形式。为了给其他需要的数据库页面腾出空间,MySQL可以从缓冲池中移除未压缩的页面,而将压缩的页面留在内存中。或者,如果页有一段时间没有被访问,则可能将该页的压缩格式写入磁盘,以便为其他数据释放空间。因此,在任何给定的时间,缓冲池可能同时包含页的压缩形式和未压缩形式,或者只包含页的压缩形式,或者两者都不包含。

MySQL使用最近最少使用(least-recently-used, LRU)列表来跟踪哪些页应该保存在内存中,哪些页应该清除,这样热的(频繁访问的)数据就倾向于保存在内存中。当访问压缩表时,MySQL使用自适应LRU算法来实现内存中压缩页和未压缩页的适当平衡。该算法对系统是I/O密集型运行还是cpu密集型运行非常敏感。目标是避免在CPU繁忙时花费过多的处理时间来解压缩页,并避免在CPU有空闲周期可用于解压缩已压缩页(可能已经在内存中)时进行过多的I/O操作。当系统处于I/O绑定时,该算法倾向于移除一个页面的未压缩副本,而不是两个副本,以便为其他磁盘页面腾出更多空间成为内存驻留。当系统使用CPU 绑定时,MySQL倾向于同时移除压缩和未压缩的页面,这样就可以将更多的内存用于“热”页面,从而减少
只对压缩格式的数据进行解压的需求。

压缩和重做日志文件
在将压缩页面写入数据文件之前,MySQL将页面的一个副本写入重做日志(如果它从上次写入数据库以来已经被重新压缩过)。这样做是为了确保重做日志对于崩溃恢复是可用的,即使在zlib库升级的情况下,该更改也会引入与压缩数据的兼容性问题。因此,在使用压缩时,日志文件的大小可能会增加,或者需要更频繁的检查点。日志文件大小或检查点频率的增加量,取决于以需要重新组织和重新压缩的方式修改压缩页的次数。

压缩表需要Barracuda文件格式。要在一个以文件为表的表空间中创建一个压缩表,必须启用innodb_file_per_table,并且必须将innodb_file_format设置为Barracuda。在普通表空间中创建压缩表时,不依赖于innodb_file_format设置。

OLTP工作负载压缩
传统上,InnoDB压缩特性主要被推荐用于只读或以读为主的工作负载,例如在数据仓库配置中。SSD存储设备速度很快,但相对较小和昂贵,这使得压缩对于OLTP工作负载也很有吸引力:高流量、交互式的网站可以通过对频繁插入、更新和删除操作的应用程序使用压缩表来减少它们的存储需求和每秒I/O操作(IOPS)。

MySQL 5.6引入的配置选项允许你针对特定的MySQL实例调整压缩的工作方式,重点是写密集型操作的性能和可伸缩性:
.Innodb_compression_level允许你提高或降低压缩程度。值越高,存储设备上的数据就越多,但压缩时的CPU开销也越大。当存储空间不是很重要,或者你希望数据不是特别可压缩时,较小的值可以减少CPU开销。

.innodb_compression_failure_threshold_pct压缩表更新失败的截止点。当超过这个阈值时,MySQL开始在每个新的压缩页面中留下额外的空闲空间,动态调整空闲空间的数量,直到innodb_compression_pad_pct_max指定的页面大小的百分比

.innodb_compression_pad_pct_max允许您调整每个页面中保留的最大空间大小,以记录对压缩行的更改,而不需要再次压缩整个页面。该值越高,在不重新压缩页面的情况下可以记录的更改越多。MySQL为每个压缩表中的页面使用的空闲空间是可变的,只有当压缩操作在运行时“失败”时,需要执行昂贵的操作来分割压缩页面。

.Innodb_compression_pad_pct_max允许您调整每个页面中保留的最大空间大小,以记录对压缩行的更改,而不需要再次压缩整个页面。该值越高,在不重新压缩页面的情况下可以记录的更改越多。MySQL为每个压缩表中的页面使用的空闲空间是可变的,只有当压缩操作在运行时“失败”时,需要执行昂贵的操作来分割压缩页面。

.innodb_log_compressed_pages允许你禁止将重新压缩的页面的图像写入重做日志。当对压缩数据进行更改时,可能会发生重新压缩。默认启用此选项是为了防止在恢复过程中使用不同版本的zlib压缩算法时发生损坏。如果你确定zlib版本不会改变,禁用innodb_log_compressed_pages来减少修改压缩数据的工作负载的重做日志生成。

因为在处理压缩数据时,有时需要在内存中同时保存一个页面的压缩版本和未压缩版本,所以在使用oltp风格的工作负载时,要准备好增加innodb_buffer_pool_size配置选项的值。

SQL压缩语法警告和错误
在使用file-per-tabl表空间和通用表空间的表压缩特性时可能遇到的语法警告和错误。

针对每个表文件的表空间的SQL压缩语法警告和错误
当innodb_strict_mode被启用时(默认),在CREATE TABLE或ALTER TABLE语句中指定ROW_FORMAT=COMPRESSED或KEY_BLOCK_SIZE,如果innodb_file_per_table被禁用或者innodb_file_format被设置为Antelope而不是Barracuda会产生如下错误。

ERROR 1031 (HY000): Table storage engine for 't1' doesn't have this option

如果当前配置不允许使用压缩表,则不会创建该表。

当innodb_strict_mode被禁用时,在CREATE TABLE或ALTER TABLE语句中指定ROW_FORMAT=COMPRESSED或KEY_BLOCK_SIZE,如果innodb_file_per_table被禁用会产生如下警告。

mysql> SHOW WARNINGS;
+---------+------+---------------------------------------------------------------+
| Level | Code | Message |
+---------+------+---------------------------------------------------------------+
| Warning | 1478 | InnoDB: KEY_BLOCK_SIZE requires innodb_file_per_table. |
| Warning | 1478 | InnoDB: ignoring KEY_BLOCK_SIZE=4. |
| Warning | 1478 | InnoDB: ROW_FORMAT=COMPRESSED requires innodb_file_per_table. |
| Warning | 1478 | InnoDB: assuming ROW_FORMAT=DYNAMIC. |
+---------+------+---------------------------------------------------------------+

如果innodb_file_format设置为Antelope而不是Barracuda,则会发出类似的警告。

这些消息只是警告,而不是错误,而且创建表时没有压缩,就像没有指定选项一样。

“非严格”行为允许您将mysqldump文件导入到不支持压缩表的数据库中,即使源数据库包含压缩表。在这种情况下,MySQL会在ROW_FORMAT=COMPACT中创建表,而不是阻止操作。

要将转储文件导入到一个新的数据库中,并重新创建原始数据库中的表,请确保服务器对innodb_file_format和innodb_file_per_table配置参数有适当的设置。

只有在ROW_FORMAT指定为COMPRESSED或省略时,属性KEY_BLOCK_SIZE才允许使用。使用任何其他ROW_FORMAT指定KEY_BLOCK_SIZE都会产生一个警告,用户可以通过SHOW WARNINGS查看。但是,该表没有被压缩。忽略指定的KEY_BLOCK_SIZE)。

Level   Code Message
Warning 1478 InnoDB: ignoring KEY_BLOCK_SIZE=n unless ROW_FORMAT=COMPRESSED.

如果运行时启用了innodb_strict_mode, KEY_BLOCK_SIZE和任何ROW_FORMAT的组合都会产生一个错误,而不是一个警告,并且表不会被创建。

当innodb_strict_mode关闭时,MySQL创建或修改表,但忽略某些设置,如下所示。你可以在MySQL错误日志中看到警告消息。当innodb_strict_mode开启时,这些指定的选项组合将产生错误,表不会被创建或修改。要查看错误条件的完整描述,请执行SHOW ERRORS语句:示例:

mysql> show variables like 'innodb_strict_mode';
+--------------------+-------+
| Variable_name      | Value |
+--------------------+-------+
| innodb_strict_mode | ON    |
+--------------------+-------+
1 row in set (0.02 sec)

mysql> CREATE TABLE x (id INT PRIMARY KEY, c INT)  ENGINE=INNODB KEY_BLOCK_SIZE=33333;
ERROR 1005 (HY000): Can't create table 'test.x' (errno: 1478)

mysql> SHOW ERRORS;
+-------+------+-------------------------------------------+
| Level | Code | Message |
+-------+------+-------------------------------------------+
| Error | 1478 | InnoDB: invalid KEY_BLOCK_SIZE=33333. |
| Error | 1005 | Can't create table 'test.x' (errno: 1478) |
+-------+------+-------------------------------------------+

当innodb_strict_mode开启时,MySQL会拒绝无效的ROW_FORMAT或KEY_BLOCK_SIZE参数并抛出错误。当innodb_strict_mode关闭时,MySQL会对忽略的无效参数发出警告而不是错误。innodb_strict_mode默认开启。

当innodb_strict_mode开启时,MySQL拒绝无效的ROW_FORMAT或KEY_BLOCK_SIZE参数。为了兼容MySQL的早期版本,默认不会启用严格模式。相反,MySQL会对被忽略的无效参数发出警告(而不是错误)。

使用SHOW TABLE STATUS是不可能看到选定的KEY_BLOCK_SIZE的。语句SHOW CREATE TABLE显示KEY_BLOCK_SIZE(即使在创建表时忽略了它)。MySQL无法显示表的实际压缩页大小。

通用表空间的SQL压缩语法警告和错误
.如果在创建表空间时没有为普通表空间定义FILE_BLOCK_SIZE,则该表空间不能包含压缩表。如果试图添加压缩表,则返回错误,如下面的例子所示:

mysql> CREATE TABLESPACE ts4 ADD DATAFILE 'ts4.ibd' Engine=InnoDB;
Query OK, 0 rows affected (0.00 sec)


mysql> CREATE TABLE t4 (c1 INT PRIMARY KEY) TABLESPACE ts4 ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=8;
ERROR 1478 (HY000): InnoDB: Tablespace `ts4` cannot contain a COMPRESSED table

.试图将无效KEY_BLOCK_SIZE设置的表添加到普通表空间会返回错误,如下面的例子所示:

mysql> CREATE TABLESPACE `ts5` ADD DATAFILE 'ts5.ibd' FILE_BLOCK_SIZE = 8192 Engine=InnoDB;
Query OK, 0 rows affected (0.01 sec)

mysql> CREATE TABLE t5 (c1 INT PRIMARY KEY) TABLESPACE ts5 ROW_FORMAT=COMPRESSED  KEY_BLOCK_SIZE=4;
ERROR 1478 (HY000): InnoDB: Tablespace `ts5` uses block size 8192 and cannot contain a table with physical page size 4096

对于普通表空间,表的KEY_BLOCK_SIZE必须等于表空间的FILE_BLOCK_SIZE除以1024。例如,表空间的FILE_BLOCK_SIZE为8192,则表的KEY_BLOCK_SIZE必须为8。

.尝试将一个未压缩行格式的表添加到配置为存储压缩表的一般表空间会返回一个错误,如下面的例子所示:

mysql> CREATE TABLESPACE `ts6` ADD DATAFILE 'ts6.ibd' FILE_BLOCK_SIZE = 8192 Engine=InnoDB;
Query OK, 0 rows affected (0.01 sec)

mysql> CREATE TABLE t6 (c1 INT PRIMARY KEY) TABLESPACE ts6 ROW_FORMAT=COMPACT;
ERROR 1478 (HY000): InnoDB: Tablespace `ts6` uses block size 8192 and cannot contain a table with physical page size 16384

innodb_strict_mode不适用于一般表空间。一般表空间的表空间管理规则是严格执行的,独立于innodb_strict_mode。

]]>
http://www.jydba.net/index.php/archives/3499/feed 0
MySQL InnoDB全文索引 http://www.jydba.net/index.php/archives/3496 http://www.jydba.net/index.php/archives/3496#respond Fri, 16 Jun 2023 07:52:43 +0000 http://www.jydba.net/?p=3496 InnoDB全文索引
FULLTEXT索引是在基于文本的列(CHAR、VARCHAR或TEXT列)上创建的,以帮助加快对这些列中包含的数据的查询和DML操作,从而省略定义为停止词的任何单词。FULLTEXT索引定义为CREATE TABLE语句的一部分,或者使用ALTER TABLE或CREATE index将其添加到现有表中。全文搜索使用MATCH()…对语法。

InnoDB全文索引设计
InnoDB FULLTEXT索引采用倒排索引设计。倒排索引存储一个单词列表,对于每个单词,存储该单词出现在其中的文档列表。为了支持邻近搜索,每个字的位置信息也以字节偏移量的形式存储。

InnoDB全文索引表
当创建一个InnoDB FULLTEXT索引时,会创建一组索引表,示例如下:

mysql> CREATE TABLE opening_lines (
    -> id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY,
    -> opening_line TEXT(500),
    -> author VARCHAR(200),
    -> title VARCHAR(200),
    -> FULLTEXT idx (opening_line)
    -> ) ENGINE=InnoDB;
Query OK, 0 rows affected (0.05 sec)

mysql> SELECT table_id, name, space from INFORMATION_SCHEMA.INNODB_SYS_TABLES WHERE name LIKE 'undo/%';
+----------+----------------------------------------------------+-------+
| table_id | name                                               | space |
+----------+----------------------------------------------------+-------+
|      453 | undo/FTS_00000000000001bf_00000000000002bb_INDEX_1 |   452 |
|      454 | undo/FTS_00000000000001bf_00000000000002bb_INDEX_2 |   453 |
|      455 | undo/FTS_00000000000001bf_00000000000002bb_INDEX_3 |   454 |
|      456 | undo/FTS_00000000000001bf_00000000000002bb_INDEX_4 |   455 |
|      457 | undo/FTS_00000000000001bf_00000000000002bb_INDEX_5 |   456 |
|      458 | undo/FTS_00000000000001bf_00000000000002bb_INDEX_6 |   457 |
|      448 | undo/FTS_00000000000001bf_BEING_DELETED            |   447 |
|      449 | undo/FTS_00000000000001bf_BEING_DELETED_CACHE      |   448 |
|      450 | undo/FTS_00000000000001bf_CONFIG                   |   449 |
|      451 | undo/FTS_00000000000001bf_DELETED                  |   450 |
|      452 | undo/FTS_00000000000001bf_DELETED_CACHE            |   451 |
|      447 | undo/opening_lines                                 |   446 |
+----------+----------------------------------------------------+-------+
12 rows in set (0.00 sec)

前六个表表示倒排索引,称为辅助索引表。在对传入文档进行标记时,将单个单词(也称为“标记”)与位置信息和相关文档ID (DOC_ID)一起插入到索引表中。根据单词第一个字符的字符集排序权重,将单词完全排序并在六个索引表中进行分区。

倒排索引被划分为六个辅助索引表,以支持并行索引创建。默认情况下,两个线程对单词和相关数据进行标记、排序和插入索引表。线程的数量可以使用innodb_ft_sort_pll_degree选项进行配置。考虑在大型表上创建FULLTEXT索引时增加线程数。

辅助索引表名的前缀是FTS_,后缀是INDEX_*。每个索引表通过索引表名称中的十六进制值与被索引表相关联,该值与被索引表的table_id相匹配。例如,test/opening_lines表的table_id为447,其十六进制值为0x1bf。如前面的示例所示,“1bf”十六进制值出现在与test/opening_lines表相关联的索引表的名称中。

表示FULLTEXT索引的index_id的十六进制值也出现在辅助索引表名中。例如,在辅助表名undo/FTS_00000000000001bf_00000000000002bb_INDEX_1中,十六进制值2bb的十进制值为699。opening_lines表(idx)上定义的索引可以通过查询INFORMATION_SCHEMA来识别。INNODB_SYS_INDEXES表的值(699)。

mysql> SELECT index_id, name, table_id, space from INFORMATION_SCHEMA.INNODB_SYS_INDEXES WHERE index_id=699;
+----------+------+----------+-------+
| index_id | name | table_id | space |
+----------+------+----------+-------+
|      699 | idx  |      447 |   446 |
+----------+------+----------+-------+
1 row in set (0.00 sec)

如果主表是在每个表文件的表空间中创建的,则索引表存储在它们自己的表空间中。

前面示例中显示的其他索引表被称为公共索引表,用于删除处理和存储FULLTEXT索引的内部状态。与为每个全文索引创建的倒排索引表不同,这组表对于在特定表上创建的所有全文索引都是通用的。

即使删除全文索引,也会保留常见的辅助表。当全文索引被删除时,为索引创建的FTS_DOC_ID列将被保留,因为删除FTS_DOC_ID列将需要重建表。管理FTS_DOC_ID列需要使用普通的辅助表。
.FTS_*_DELETED and FTS_*_DELETED_CACHE

包含已删除但其数据尚未从全文索引中删除的文档的文档id (DOC_ID)。FTS_*_DELETED_CACHE是FTS_*_DELETED表的内存版本。

.FTS_*_BEING_DELETED and FTS_*_BEING_DELETED_CACHE
包含要删除的文档的文档id (DOC_ID),这些文档的数据目前正在从全文索引中删除。FTS_*_BEING_DELETED_CACHE表是FTS_*_BEING_DELETED表的内存版本。

.FTS_*_CONFIG
存储关于FULLTEXT索引的内部状态的信息。最重要的是,它存储FTS_SYNCED_DOC_ID,它标识已解析并刷新到磁盘的文档。在崩溃恢复的情况下,FTS_SYNCED_DOC_ID值用于标识尚未刷新到磁盘的文档,以便可以重新解析文档并将其添加回FULLTEXT索引缓存。要查看该表中的数据,请查询INFORMATION_SCHEMA.INNODB_FT_CONFIG表。

InnoDB全文索引缓存
插入文档时,将对其进行标记,并将单个单词和相关数据插入到FULLTEXT索引中。这个过程,即使对于小文档,也可能导致对辅助索引表进行大量小的插入,从而使对这些表的并发访问成为争用点。为了避免这个问题,InnoDB使用FULLTEXT索引缓存来临时缓存索引表中最近插入的行。这个内存缓存结构保存插入,直到缓存满,然后将它们批量刷新到磁盘(到辅助索引表)。可以查询INFORMATION_SCHEMA.INNODB_FT_INDEX_CACHE表用于查看最近插入的行的标记化数据。

缓存和批处理刷新行为避免了对辅助索引表的频繁更新,这可能在繁忙的插入和更新期间导致并发访问问题。批处理技术还避免了对同一个单词的多次插入,并最大限度地减少了重复条目。不是逐个刷新每个单词,而是将相同单词的插入合并并作为单个条目刷新到磁盘,从而提高了插入效率,同时使辅助索引表尽可能小。

innodb_ft_cache_size变量用于配置全文索引缓存大小(以每个表为基础),它影响全文索引缓存刷新的频率。您还可以使用innodb_ft_total_cache_size选项为给定实例中的所有表定义全局全文索引缓存大小限制。

全文索引缓存存储与辅助索引表相同的信息。但是,全文索引缓存仅为最近插入的行缓存标记化的数据。查询时,已经刷新到磁盘(全文辅助表)的数据不会被带回到全文索引缓存中。直接查询辅助索引表中的数据,并且在返回之前,将辅助索引表中的结果与全文索引缓存中的结果合并。

InnoDB全文索引文档ID和FTS_DOC_ID列
InnoDB使用一个唯一的文档标识符,即文档ID (DOC_ID),将全文索引中的单词映射到该单词出现的文档记录。映射需要索引表上的FTS_DOC_ID列。如果没有定义FTS_DOC_ID列,InnoDB会在创建全文索引时自动添加一个隐藏的FTS_DOC_ID列。下面的示例演示了这种行为。

下面的表定义不包含FTS_DOC_ID列:

mysql> CREATE TABLE opening_lines (
    -> id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY,
    -> opening_line TEXT(500),
    -> author VARCHAR(200),
    -> title VARCHAR(200)
    -> ) ENGINE=InnoDB;
Query OK, 0 rows affected (0.01 sec)

当使用create FULLTEXT index语法在表上创建全文索引时,会返回一个警告,报告InnoDB正在重建表以添加FTS_DOC_ID列。

mysql> CREATE FULLTEXT INDEX idx ON opening_lines(opening_line);
Query OK, 0 rows affected, 1 warning (0.10 sec)
Records: 0  Duplicates: 0  Warnings: 1

mysql> SHOW WARNINGS;
+---------+------+--------------------------------------------------+
| Level   | Code | Message                                          |
+---------+------+--------------------------------------------------+
| Warning |  124 | InnoDB rebuilding table to add column FTS_DOC_ID |
+---------+------+--------------------------------------------------+
1 row in set (0.00 sec)

当使用ALTER TABLE向没有FTS_DOC_ID列的表添加全文索引时,也会返回相同的警告。如果你在create TABLE时间创建一个全文索引,并且没有指定FTS_DOC_ID列,InnoDB会添加一个隐藏的FTS_DOC_ID列,没有警告。

在CREATE TABLE时定义一个FTS_DOC_ID列比在一个已经加载了数据的表上创建一个全文索引要便宜。如果在加载数据之前在表上定义了FTS_DOC_ID列,则不必重新构建表及其索引来添加新列。如果你不关心CREATE FULLTEXT INDEX的性能,可以省略FTS_DOC_ID列,让InnoDB为你创建它。InnoDB创建一个隐藏的FTS_DOC_ID列,并在FTS_DOC_ID列上创建一个唯一的索引(FTS_DOC_ID_INDEX)。如果你想创建自己的FTS_DOC_ID列,该列必须定义为BIGINT UNSIGNED NOT NULL,并命名为FTS_DOC_ID(全大写),如下所示:

FTS_DOC_ID列不需要定义为AUTO_INCREMENT列,但是AUTO_INCREMENT可以使加载数据更容易。

mysql> CREATE TABLE opening_lines (
    -> FTS_DOC_ID BIGINT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY,
    -> opening_line TEXT(500),
    -> author VARCHAR(200),
    -> title VARCHAR(200)
    -> ) ENGINE=InnoDB;
Query OK, 0 rows affected (0.01 sec)

如果选择自己定义FTS_DOC_ID列,则负责管理该列,以避免空值或重复值。FTS_DOC_ID的值不能重复使用,这意味着FTS_DOC_ID的值必须不断增加。

可选地,您可以在FTS_DOC_ID列上创建所需的惟一FTS_DOC_ID_INDEX(全部大写)。

mysql> CREATE UNIQUE INDEX FTS_DOC_ID_INDEX on opening_lines(FTS_DOC_ID);
Query OK, 0 rows affected (0.01 sec)
Records: 0  Duplicates: 0  Warnings: 0

如果你没有创建FTS_DOC_ID_INDEX, InnoDB会自动创建它。

在MySQL 5.7.13之前,已使用的FTS_DOC_ID值与新的FTS_DOC_ID值之间允许的最大差值为10000。在MySQL 5.7.13及以后版本中,允许的间隙是65535。

为了避免重新构建表,在删除全文索引时保留FTS_DOC_ID列。

InnoDB全文索引删除处理
删除具有全文索引列的记录可能会导致辅助索引表中出现大量小的删除,从而使对这些表的并发访问成为争用点。为了避免这个问题,被删除文档的文档ID (DOC_ID)记录在一个特殊的FTS_*_DELETED表中,当一条记录从索引表中删除时,被索引的记录保留在全文索引中。在返回查询结果之前,使用FTS_*_DELETED表中的信息过滤已删除的Document id。这种设计的好处是,删除是快速和廉价的。缺点是在删除记录后索引的大小不会立即减小。要删除已删除记录的全文索引项,可以在已索引的表上运行OPTIMIZE TABLE命令(innodb_optimize_fulltext_only= on)重建全文索引。

InnoDB全文索引事务处理
InnoDB FULLTEXT索引由于其缓存和批处理行为而具有特殊的事务处理特性。具体来说,FULLTEXT索引上的更新和插入是在事务提交时处理的,这意味着FULLTEXT搜索只能看到提交的数据。下面的示例演示了这种行为。FULLTEXT搜索只在提交插入的行之后返回结果。

mysql> BEGIN;
Query OK, 0 rows affected (0.00 sec)

mysql> INSERT INTO opening_lines(opening_line,author,title) VALUES
    -> ('Call me Ishmael.','Herman Melville','Moby-Dick'),
    -> ('A screaming comes across the sky.','Thomas Pynchon','Gravity\'s Rainbow'),
    -> ('I am an invisible man.','Ralph Ellison','Invisible Man'),
    -> ('Where now? Who now? When now?','Samuel Beckett','The Unnamable'),
    -> ('It was love at first sight.','Joseph Heller','Catch-22'),
    -> ('All this happened, more or less.','Kurt Vonnegut','Slaughterhouse-Five'),
    -> ('Mrs. Dalloway said she would buy the flowers herself.','Virginia Woolf','Mrs. Dalloway'),
    -> ('It was a pleasure to burn.','Ray Bradbury','Fahrenheit 451');
Query OK, 8 rows affected (0.00 sec)
Records: 8  Duplicates: 0  Warnings: 0

mysql> SELECT COUNT(*) FROM opening_lines WHERE MATCH(opening_line) AGAINST('Ishmael');
+----------+
| COUNT(*) |
+----------+
|        0 |
+----------+
1 row in set (0.01 sec)

mysql> COMMIT;
Query OK, 0 rows affected (0.00 sec)

mysql> SELECT COUNT(*) FROM opening_lines WHERE MATCH(opening_line) AGAINST('Ishmael');
+----------+
| COUNT(*) |
+----------+
|        1 |
+----------+
1 row in set (0.00 sec)

]]>
http://www.jydba.net/index.php/archives/3496/feed 0
MySQL InnoDB的AUTO_INCREMENT处理 http://www.jydba.net/index.php/archives/3493 http://www.jydba.net/index.php/archives/3493#respond Wed, 10 May 2023 01:58:51 +0000 http://www.jydba.net/?p=3493 InnoDB的AUTO_INCREMENT处理
InnoDB提供了一种可配置的锁机制,可以显著提高将行添加到具有AUTO_INCREMENT列的表中的SQL语句的可伸缩性和性能。要在InnoDB表中使用AUTO_INCREMENT机制,必须将一个AUTO_INCREMENT列定义为索引的一部分,这样就可以在表上执行相当于索引SELECT MAX(ai_col)的查找以获得最大列值。通常,这是通过使某一列成为某些表索引的第一列来实现的。

本节描述AUTO_INCREMENT锁模式的行为,不同AUTO_INCREMENT锁模式设置的使用影响,以及InnoDB如何初始化AUTO_INCREMENT计数器。
.InnoDB AUTO_INCREMENT锁模式
.InnoDB AUTO_INCREMENT锁模式使用影响
.InnoDB AUTO_INCREMENT计数器初始化

InnoDB AUTO_INCREMENT锁模式
用于生成自动增量值的AUTO_INCREMENT锁模式的行为,以及每种锁模式如何影响复制。自动增量锁模式在启动时使用innodb_autoinc_lock_mode配置参数配置。

以下术语用于描述innodb_autoinc_lock_mode设置:
.“INSERT-like”语句

所有在表中生成新行的语句,包括INSERT, INSERT… SELECT,REPLACE,REPLACE… SELECT和LOAD DATA。包括“简单插入”、“批量插入”和“混合模式”插入。

.“简单插入”
可以提前确定要插入的行数的语句(在初始处理语句时)。这包括没有嵌套子查询的单行和多行INSERT和REPLACE语句,但不包括INSERT … ON DUPLICATE KEY UPDATE。

.“混合模式插入”
这些是“简单插入”语句,它们为一些(但不是全部)新行指定自动增量值。下面是一个例子,其中c1是表t1的AUTO_INCREMENT列:

INSERT INTO t1 (c1,c2) VALUES (1,'a'), (NULL,'b'), (5,'c'), (NULL,'d');

另一种“混合模式插入”是INSERT…ON DUPLICATE KEY UPDATE,在最坏的情况下,它实际上是INSERT,然后是UPDATE,其中AUTO_INCREMENT列的分配值可能在更新阶段使用,也可能不使用。

innodb_autoinc_lock_mode配置参数有三种可能的设置。“传统”、“连续”、“交错”锁模式的取值分别为0、1、2。
.innodb_autoinc_lock_mode = 0(“传统”锁模式)

传统的锁模式提供了与MySQL 5.1中引入innodb_autoinc_lock_mode配置参数之前相同的行为。传统的锁模式选项是为了向后兼容、性能测试和解决“混合模式插入”的问题而提供的,因为可能存在语义上的差异。

在这种锁模式下,所有“INSERT-like”语句都获得一个特殊的表级AUTO-INC锁,用于向具有AUTO_INCREMENT列的表中插入数据。该锁通常保持到语句的末尾(而不是事务的末尾),以确保对给定的INSERT语句序列按可预测和可重复的顺序分配自动递增值,并确保任何给定语句分配的自动递增值是连续的。

在基于语句的复制的情况下,这意味着当从服务器上复制SQL语句时,自动递增列的值与主服务器上相同。多个INSERT语句的执行结果是确定的,从服务器复制的数据与主服务器相同。如果多个INSERT语句生成的自动递增值是交错的,则两个并发INSERT语句的结果将是不确定的,并且不能使用基于语句的复制可靠地将其传播到从服务器。

为了更清楚地说明这一点,考虑一个使用这个表的例子:

CREATE TABLE t1 (
  c1 INT(11) NOT NULL AUTO_INCREMENT,
  c2 VARCHAR(10) DEFAULT NULL,
  PRIMARY KEY (c1)
) ENGINE=InnoDB;

假设有两个事务正在运行,每个事务将行插入到表中AUTO_INCREMENT列。一个事务正在使用INSERT…SELECT语句,该语句插入1000行,另一个是使用一个简单的INSERT语句插入一行:

Tx1: INSERT INTO t1 (c2) SELECT 1000 rows from another table ...
Tx2: INSERT INTO t1 (c2) VALUES ('xxx');

InnoDB无法预先告诉Tx1中的INSERT语句从SELECT中检索了多少行,并且它会在语句执行过程中每次分配一个自动递增值。使用一直保持到语句末尾的表级锁,一次只能执行一条引用table t1的INSERT语句,并且不同语句生成的自动递增编号不会交叉。由Tx1 INSERT…SELECT语句生成的自动递增值是连续的,而Tx2中INSERT语句使用的(单个)自动递增值比Tx1中使用的所有自动递增值是小或还是大,这取决于首先执行哪条语句。

只要SQL语句以二进制日志中相同的顺序执行(在使用基于语句的复制时,或在恢复场景中),结果就与Tx1和Tx2第一次运行时相同。因此,表级别的锁一直保持到语句结束,使得使用自动递增的INSERT语句可以安全地与基于语句的复制一起使用。然而,当多个事务同时执行insert语句时,这些表级锁限制了并发性和可伸缩性。

在前面的示例中,如果没有表级锁,那么Tx2中用于插入的自动递增列的值完全取决于语句执行的时间。如果Tx2的插入是在Tx1的插入运行时执行的(而不是在它开始之前或完成之后),那么两个INSERT语句分配的特定的自动递增值是不确定的,并且可能在不同的运行中有所不同。

在连续锁模式下,对于预先知道行数的“simple insert”语句InnoDB可以避免使用表级的AUTO-INC锁来处理,并保持执行的确定性和基于语句的复制的安全性。

如果你不使用二进制日志来重放SQL语句作为恢复或复制的一部分,那么交错锁模式可以用来消除所有表级的AUTO-INC锁,以获得更大的并发性和性能,但代价是允许语句分配的自动递增编号之间有间隙,并且可能通过交错并发执行语句分配编号。

.innodb_autoinc_lock_mode = 1 (“连续”锁模式)

这是默认的锁定模式。在这种模式下,“批量插入”使用特殊的AUTO-INC表级锁,并一直保持到语句结束。这适用于所有的INSERT…SELECT,REPLACE … SELECT和LOAD DATA语句。一次只能执行一个持有AUTO-INC锁的语句。如果批量插入操作的源表与目标表不同,则在源表中选择的第一行获得共享锁之后,在目标表上获得AUTO-INC锁。如果批量插入操作的源和目标是同一个表,那么在对所有选定行使用共享锁之后,会使用AUTO-INC锁。

“简单插入”(需要插入的行数是预先知道的)通过在互斥量(轻量级锁)的控制下获取所需的自动递增值的数量来避免表级的AUTO-INC锁,该互斥量只在分配过程中保持,直到语句完成。除非AUTO-INC锁被另一个事务持有,否则不会使用表级的AUTO-INC锁。如果另一个事务持有AUTO-INC锁,则“简单插入”会等待AUTO-INC锁,就像“批量插入”一样。

这种锁模式确保,如果INSERT语句的行数事先不知道(并且随着语句的执行分配了自动递增号),任何“类INSERT”语句分配的所有自动递增值都是连续的,并且基于语句的复制操作是安全的。

简而言之,这种锁模式显著提高了可伸缩性,同时可以安全地与基于语句的复制一起使用。此外,与“传统”锁模式一样,任何给定语句分配的自动递增数字都是连续的。与“传统”模式相比,任何使用自动递增的语句在语义上都没有变化,但有一个重要的例外。

例外情况是“混合模式插入”,在这种情况下,用户在多行“简单插入”中为某些(但不是全部)行显式地提供AUTO_INCREMENT列的值。对于这样的插入,InnoDB分配的自动增量值比要插入的行数要多。然而,所有自动赋值的值都是连续生成的(因而高于)最近执行的前一个语句自动递增生成的值。“多余”的数字会丢失。

.innodb_autoinc_lock_mode = 2(“交错”锁模式)

在这种锁模式下,没有“INSERT-like”语句使用表级AUTO-INC锁,并且多个语句可以同时执行。这是最快和最具可伸缩性的锁模式,但是当重放来自二进制日志中SQL语句执行基于语句的复制或恢复场景时,它并不安全。

在这种锁模式下,自动增量值保证在所有并发执行的“INSERT-like”语句中是唯一且单调递增的。但是,因为多个语句可以同时生成数字(也就是说,数字的分配是跨语句交叉的),任何给定语句插入的行生成的值都可能不是连续的。

如果唯一执行的语句是“简单插入”,其中要插入的行数是提前知道的,那么除了“混合模式插入”之外,为单个语句生成的行数没有间隔。然而,当执行“批量插入”时,任何给定语句分配的自动增量值可能存在间隙。

InnoDB AUTO_INCREMENT锁模式使用影响
.对复制使用自动增量

如果使用基于语句的复制,请将innodb_autoinc_lock_mode设置为0或1,并在主服务器和从服务器上使用相同的值。如果使用innodb_autoinc_lock_mode = 2 (” interleaved “),或者配置主、从不使用相同的锁模式,则不能确保从上的自动增量值与主上的相同。

如果您使用的是基于行或混合格式的复制,那么所有的自动增量锁模式都是安全的,因为基于行的复制对SQL语句的执行顺序不敏感(对于基于语句的复制来说不安全的任何语句混合格式使用基于行的复制来进行处理)。

.“丢失”自动增量值和序列间隙

在所有锁模式(0、1和2)中,如果生成自动递增值的事务回滚,则这些自动递增值将“丢失”。一旦为自动递增的列生成了值,无论“INSERT-like”语句是否完成,以及包含它的事务是否回滚,它都不能回滚。这些丢失的值不会被重用。因此,存储在表的AUTO_INCREMENT列中的值可能会有差距。

.为AUTO_INCREMENT列指定NULL或0
在所有的锁模式下(0、1和2),如果用户为INSERT语句中的AUTO_INCREMENT列指定了NULL或0,InnoDB将该行视为未指定值,并为其生成一个新值。

.给AUTO_INCREMENT列赋一个负值
在所有锁模式(0、1和2)中,如果给AUTO_INCREMENT列赋一个负值,则不会定义自动递增机制的行为。

.如果AUTO_INCREMENT值大于指定整数类型的最大整数
在所有锁模式(0、1和2)中,如果值大于可以存储在指定整数类型中的最大整数,则不定义自动递增机制的行为。

.“bulk inserts”的自动增量值存在间隔
当innodb_autoinc_lock_mode设置为0(“传统”)或1(“连续”)时,任何给定语句生成的自动增量值都是连续的,没有间隔,因为表级AUTOINC锁一直保持到语句结束,并且一次只能执行一个这样的语句。

当innodb_autoinc_lock_mode设置为2(“交错”)时,“bulk inserts”生成的自动增量值可能会有间隙,但仅当有并发执行“类似插入”语句时才会如此。

对于锁模式1或2,因为对于批量插入,可能不知道每个语句所需的自动增量值的确切数量,并且可能会高估因此连续语句之间可能会出现间隙。

.“混合模式插入”分配的自动增量值

考虑一个“混合模式插入”,其中一个“简单插入”指定了一些结果行(但不是全部)的自动增量值。这样的语句在锁模式0、1和2中的行为不同。例如,假设c1是表t1的AUTO_INCREMENT列,并且最近自动生成的序列号是100。

mysql> CREATE TABLE t1
    -> (
    ->   c1 INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
    ->   c2 CHAR(1)
    -> ) ENGINE = INNODB;
Query OK, 0 rows affected (0.01 sec)

mysql> insert into t1 values(100,'x');
Query OK, 1 row affected (0.00 sec)

mysql> select * from t1;
+-----+------+
| c1  | c2   |
+-----+------+
| 100 | x    |
+-----+------+
1 row in set (0.00 sec)

现在,考虑下面的“混合模式插入”语句:

mysql> INSERT INTO t1 (c1,c2) VALUES (1,'a'), (NULL,'b'), (5,'c'), (NULL,'d');
Query OK, 4 rows affected (0.00 sec)
Records: 4  Duplicates: 0  Warnings: 0

mysql> SELECT c1, c2 FROM t1 ORDER BY c2;
+-----+------+
| c1  | c2   |
+-----+------+
|   1 | a    |
| 101 | b    |
|   5 | c    |
| 102 | d    |
| 100 | x    |
+-----+------+
5 rows in set (0.00 sec)

下一个可用的自动递增值是103,因为自动递增值是每次分配一个,而不是在语句执行开始时一次性分配的。无论是否有并发执行的“INSERT-like”语句(任何类型),该结果都为true。

当innodb_autoinc_lock_mode设置为1(“连续”)时,这四个新行也是:

mysql> SELECT c1, c2 FROM t1 ORDER BY c2;
+-----+------+
| c1  | c2   |
+-----+------+
|   1 | a    |
| 101 | b    |
|   5 | c    |
| 102 | d    |
| 100 | x    |
+-----+------+
5 rows in set (0.01 sec)

然而,在本例中,下一个可用的自动增量值是105,而不是103,因为在处理语句时分配了四个自动增量值,但只使用了两个。无论是否并发执行“INSERT-like”语句(任何类型),这个结果都为真。

mysql> show create table t1;
+-------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table                                                                                                                                                                      |
+-------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| t1    | CREATE TABLE `t1` (
  `c1` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `c2` char(1) DEFAULT NULL,
  PRIMARY KEY (`c1`)
) ENGINE=InnoDB AUTO_INCREMENT=105 DEFAULT CHARSET=utf8mb4 |
+-------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

innodb_autoinc_lock_mode设置为模式2(“交错”),这四个新行是:

mysql> show variables like 'innodb_autoinc_lock_mode';
+--------------------------+-------+
| Variable_name            | Value |
+--------------------------+-------+
| innodb_autoinc_lock_mode | 2     |
+--------------------------+-------+
1 row in set (0.00 sec)

mysql> SELECT c1, c2 FROM t1 ORDER BY c2;
+-----+------+
| c1  | c2   |
+-----+------+
|   1 | a    |
|   x | b    |
|   5 | c    |
|   y | d    |
| 100 | x    |
+-----+------+
5 rows in set (0.00 sec)

x和y的值是唯一的,且大于之前生成的任何行。但是,x和y的具体值取决于并发执行语句生成的自动增量值的数量。

最后,考虑以下语句,当最近生成的序列号为4时发出:

mysql> truncate table t1;
Query OK, 0 rows affected (0.01 sec)

mysql> insert into t1 values(4,'x');
Query OK, 1 row affected (0.00 sec)

mysql> SELECT c1, c2 FROM t1 ORDER BY c2;
+----+------+
| c1 | c2   |
+----+------+
|  4 | x    |
+----+------+
1 row in set (0.00 sec)

mysql> show create table t1;
+-------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table                                                                                                                                                                    |
+-------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| t1    | CREATE TABLE `t1` (
  `c1` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `c2` char(1) DEFAULT NULL,
  PRIMARY KEY (`c1`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 |
+-------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

mysql> INSERT INTO t1 (c1,c2) VALUES (1,'a'), (NULL,'b'), (5,'c'), (NULL,'d');
ERROR 1062 (23000): Duplicate entry '5' for key 'PRIMARY'

对于任何innodb_autoinc_lock_mode设置,该语句都会生成一个ERROR 1062 (23000): Duplicate entry ‘5’ for key ‘PRIMARY’,因为5被分配给行(NULL, ‘b’),并且行(5,’c’)的插入失败。

.修改INSERT语句序列中间的AUTO_INCREMENT列值

在所有锁模式(0、1和2)中,在INSERT语句序列的中间修改AUTO_INCREMENT列值可能会导致“重复条目”错误。例如,如果您执行更新操作,将AUTO_INCREMENT列的值更改为大于当前最大自动递增值的值,则后续的插入操作如果没有指定未使用的自动递增值,可能会遇到“重复条目”错误。下面的例子演示了这种行为。

mysql> drop table t1;
Query OK, 0 rows affected (0.02 sec)

mysql> create table t1
    -> (c1 int not null auto_increment,
    -> primary key(c1)
    -> ) engine=innodb;
Query OK, 0 rows affected (0.01 sec)

mysql> INSERT INTO t1 VALUES(0), (0), (3);
Query OK, 3 rows affected (0.01 sec)
Records: 3  Duplicates: 0  Warnings: 0

mysql> SELECT c1 FROM t1;
+----+
| c1 |
+----+
|  1 |
|  2 |
|  3 |
+----+
3 rows in set (0.00 sec)

mysql> UPDATE t1 SET c1 = 4 WHERE c1 = 1;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql> SELECT c1 FROM t1;
+----+
| c1 |
+----+
|  2 |
|  3 |
|  4 |
+----+
3 rows in set (0.00 sec)

mysql> INSERT INTO t1 VALUES(0);
ERROR 1062 (23000): Duplicate entry '4' for key 'PRIMARY'

< ?pre>
InnoDB AUTO_INCREMENT计数器初始化

如果你为InnoDB表指定了一个AUTO_INCREMENT列,那么InnoDB数据字典中的表句柄中就会包含一个特殊的计数器,叫做自动递增计数器(auto-increment counter),用于为这一列赋值。这个计数器只存储在主内存中,而不是磁盘中。

为了在服务器重启后初始化一个自动递增计数器,InnoDB在第一次向包含AUTO_INCREMENT列的表中插入数据时,执行等价于下面的语句。
SELECT MAX(ai_col) FROM table_name FOR UPDATE;

InnoDB递增语句检索到的值,并将其分配给列和表的autoincrement计数器。缺省情况下,加1。这个默认值可以通过auto_increment_increment配置设置覆盖。

mysql> show variables like 'auto_increment_increment';
+--------------------------+-------+
| Variable_name            | Value |
+--------------------------+-------+
| auto_increment_increment | 1     |
+--------------------------+-------+
1 row in set (0.02 sec)

如果表为空,InnoDB使用值1。这个默认值可以被auto_increment_offset配置设置覆盖。

mysql> show variables like 'auto_increment_offset';
+-----------------------+-------+
| Variable_name         | Value |
+-----------------------+-------+
| auto_increment_offset | 1     |
+-----------------------+-------+
1 row in set (0.00 sec)

如果SHOW TABLE STATUS语句在自动递增计数器初始化之前检查了表,InnoDB会初始化该值,但不会递增。该值被存储起来,供后续插入使用。此初始化使用表上的普通排它锁定读取,锁持续到事务结束。InnoDB为新创建的表初始化自增计数器的过程与此相同。

在自动递增计数器被初始化之后,如果你没有显式地为AUTO_INCREMENT列指定一个值,InnoDB会递增计数器并将新值赋值给列。如果插入显式指定列值的行,且该值大于当前计数器值,则计数器设置为指定的列值。

只要服务器在运行,InnoDB就会使用内存中的自动递增计数器。当服务器停止并重新启动时,InnoDB会在第一次插入表时重新初始化每个表的计数器,如前所述。

服务器重启也会取消CREATE table和ALTER table语句中的AUTO_INCREMENT = N 表选项的影响,你可以在InnoDB表中使用它来设置初始的计数器值或改变当前的计数器值。

]]>
http://www.jydba.net/index.php/archives/3493/feed 0
MySQL参数名不正确导致启动时报The server quit without updating PID file pre http://www.jydba.net/index.php/archives/3491 http://www.jydba.net/index.php/archives/3491#respond Wed, 10 May 2023 01:51:07 +0000 http://www.jydba.net/?p=3491 在MySQL参数文件my.cnf中配置参数innodb_autoinc_lock_mode在,配置后重启服务时出现以下错误:

[root@localhost mysql]# service mysqld restart
Shutting down MySQL.... SUCCESS!
Starting MySQL..... ERROR! The server quit without updating PID file (/mysqldata/mysql/mysqld.pid).

由于查看参数文件my.cnf,发现参数变成了nnodb_autoinc_lock_mode=2,这是由于复制粘贴造成少了一个i字母

[mysql@localhost mysql]$ cat my.cnf
......
nnodb_autoinc_lock_mode=2
......

修改正确

[mysql@localhost mysql]$ vi my.cnf
......
innodb_autoinc_lock_mode=2
......

再重启服务

[root@localhost mysql]# service mysqld restart
 ERROR! MySQL server PID file could not be found!
Starting MySQL... SUCCESS!
]]>
http://www.jydba.net/index.php/archives/3491/feed 0
Oracle Linux 6.7 安装MySQL 8.0.33 http://www.jydba.net/index.php/archives/3489 http://www.jydba.net/index.php/archives/3489#respond Mon, 08 May 2023 08:35:16 +0000 http://www.jydba.net/?p=3489 在Oracle Linux 6.7中安装MySQL 8.0.33 mysql安装位置:/mysqlsoft/mysql,数据库文件数据位置:/mysqldata/mysql
1.首先下载安装介质

mysql-8.0.33-linux-glibc2.12-x86_64.tar.xz

2. 在根目录下创建文件夹mysqlsoft和数据库数据文件/mysqldata/mysql

[root@sjbf /]# mkdir -p /mysqlsoft
[root@sjbf /]# mkdir -p /mysqldata/mysql

3.上传介质mysql-8.0.33-linux-glibc2.28-x86_64.tar.gz到/mysqlsoft目录中并解压

[root@sjbf /]# cd /mysqlsoft
[root@sjbf mysqlsoft]# ll
total 527224
-rw-r--r-- 1 root root 539869923 May  5 09:50 mysql-8.0.33-linux-glibc2.12-x86_64.tar.xz

[root@sjbf mysqlsoft]# tar xvJf mysql-8.0.33-linux-glibc2.12-x86_64.tar.xz

[root@sjbf mysqlsoft]# ll
total 600560
drwxr-xr-x 9 root root      4096 May  6 03:49 mysql-8.0.33-linux-glibc2.12-x86_64
-rw-r--r-- 1 root root 614964216 May  5 15:28 mysql-8.0.33-linux-glibc2.12-x86_64.tar.xz

建议一般不要修改默认文件名,通过软连接来完成

[root@sjbf mysqlsoft]# ln -s mysql-8.0.33-linux-glibc2.12-x86_6 mysql
[root@sjbf mysqlsoft]# ll
total 600560
lrwxrwxrwx 1 root root        34 May  6 03:53 mysql -> mysql-8.0.33-linux-glibc2.12-x86_6
drwxr-xr-x 9 root root      4096 May  6 03:49 mysql-8.0.33-linux-glibc2.12-x86_64
-rw-r--r-- 1 root root 614964216 May  5 15:28 mysql-8.0.33-linux-glibc2.12-x86_64.tar.xz



[root@sjbf mysqlsoft]# cd mysql
[root@sjbf mysql]# ll
total 312
drwxr-xr-x  2 7161 31415   4096 Mar 17 02:46 bin
drwxr-xr-x  2 7161 31415   4096 Mar 17 02:46 docs
drwxr-xr-x  3 7161 31415   4096 Mar 17 02:46 include
drwxr-xr-x  6 7161 31415   4096 Mar 17 02:46 lib
-rw-r--r--  1 7161 31415 284945 Mar 17 01:22 LICENSE
drwxr-xr-x  4 7161 31415   4096 Mar 17 02:46 man
-rw-r--r--  1 7161 31415    666 Mar 17 01:22 README
drwxr-xr-x 28 7161 31415   4096 Mar 17 02:46 share
drwxr-xr-x  2 7161 31415   4096 Mar 17 02:46 support-files

4. 创建mysql用户与用户组

[root@sjbf /]# groupadd mysql
[root@sjbf /]# useradd -r -g mysql -s /bin/false mysql
[root@sjbf /]# id mysql
uid=492(mysql) gid=54323(mysql) groups=54323(mysql)

因为用户只用于所有权目的,而不是登录目的,useradd命令使用-r与-s /bin/false选项来创建一个用户没有登录服务器主机的权限。

5.修改/mysqlsoft/mysql与/mysqldata/mysql目录权限

[root@sjbf /]# chown -R mysql:mysql /mysqlsoft/mysql
[root@sjbf /]# chown -R mysql:mysql /mysqldata/mysql
[root@sjbf /]# chmod -R 775 /mysqlsoft/mysql
[root@sjbf /]# chmod -R 775 /mysqldata/mysql

6. MySQL对于libaio库有依赖性。台果这个libaio库没有安装那么数据目录初始化与后续的数据库服务启动将会失败,安装libaio库执行以下操作:
查询是否安装了libaio库

[root@sjbf /]# yum search libaio
Loaded plugins: aliases, changelog, kabi, presto, refresh-packagekit, security, tmprepo, ulninfo, verify, versionlock
Loading support for kernel ABI
=========================================================================================================== N/S Matched: libaio ===========================================================================================================
libaio.i686 : Linux-native asynchronous I/O access library
libaio.x86_64 : Linux-native asynchronous I/O access library
libaio-devel.i686 : Development files for Linux-native asynchronous I/O access
libaio-devel.x86_64 : Development files for Linux-native asynchronous I/O access

  Name and summary matches only, use "search all" for everything.

如果没有安装,可以执行下面的命令来安装

[root@sjbf /]# yum install libaio
Loaded plugins: aliases, changelog, kabi, presto, refresh-packagekit, security, tmprepo, ulninfo, verify, versionlock
Loading support for kernel ABI
Setting up Install Process
Package libaio-0.3.107-10.el6.x86_64 already installed and latest version
Nothing to do

7.配置mysql参数
只是设置几个简单的mysql运行参数

[root@sjbf mysql]# vi my.cnf
[mysqld]
basedir=/mysqlsoft/mysql
datadir=/mysqldata/mysql
bind-address=0.0.0.0
user=mysql
port=3306
mysqlx_port=33060
log-error=/mysqldata/mysql/mysql.err
pid-file=/mysqldata/mysql/mysqld.pid
socket = /mysqlsoft/mysql/mysql.sock
mysqlx_socket=/mysqlsoft/mysql/mysqlx.sock
character-set-server=utf8
default-storage-engine=INNODB

注意:log-error 一定要配置,因为如果mysql启动错误,可以从日志文件中找到错误原因。其次bind-address配置0.0.0.0是为了监听所有的连接。还有就是socket参数所指定的mysql.sock文件的路径最好设置为/tmp/mysql.sock,因为unix socket文件的缺省位置在/tmp目录中。

8.初始化mysql

[root@sjbf bin]# ./mysqld --user=mysql  --defaults-file=/mysqlsoft/mysql/my.cnf --basedir=/mysqlsoft/mysql --datadir=/mysqldata/mysql --initialize
2023-05-05T20:21:18.355164Z 0 [System] [MY-013169] [Server] /mysqlsoft/mysql-8.0.33-linux-glibc2.12-x86_64/bin/mysqld (mysqld 8.0.33) initializing of server in progress as process 26730
2023-05-05T20:21:18.412269Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2023-05-05T20:21:25.831475Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2023-05-05T20:21:42.025674Z 0 [ERROR] [MY-000067] [Server] unknown variable 'defaults-file=/mysqlsoft/mysql/my.cnf'.
2023-05-05T20:21:42.025812Z 0 [ERROR] [MY-013236] [Server] The designated data directory /mysqldata/mysql/ is unusable. You can remove all files that the server added to it.
2023-05-05T20:21:42.025914Z 0 [ERROR] [MY-010119] [Server] Aborting
2023-05-05T20:21:53.091946Z 0 [System] [MY-010910] [Server] /mysqlsoft/mysql-8.0.33-linux-glibc2.12-x86_64/bin/mysqld: Shutdown complete (mysqld 8.0.33)  MySQL Community Server - GPL.

调整一下参数顺序

[root@sjbf bin]# ./mysqld --defaults-file=/mysqlsoft/mysql/my.cnf --initialize --user=mysql --basedir=/mysqlsoft/mysql --datadir=/mysqldata/mysql



[root@sjbf mysql]# cat mysql.err
2023-05-05T20:26:01.800998Z 0 [System] [MY-013169] [Server] /mysqlsoft/mysql-8.0.33-linux-glibc2.12-x86_64/bin/mysqld (mysqld 8.0.33) initializing of server in progress as process 27188
2023-05-05T20:26:01.805553Z 0 [Warning] [MY-013242] [Server] --character-set-server: 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
2023-05-05T20:26:01.870227Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2023-05-05T20:26:09.160682Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2023-05-05T20:26:25.588664Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: #uVfq!szm7y/

其中[Note] A temporary password is generated for root@localhost:#uVfq!szm7y/ 的root@localhost: 后面跟的是mysql数据库登录的临时密码,各人安装生成的临时密码不一样。可以看到到日志文件没有报错,而且有了临时密码,表示初始化成功。

9. 如果想服务能够部署自动支持安全连接,使用mysql_ssl_rsa_setup工具来创建缺省SSL与RSA文件

[root@sjbf bin]# ./mysql_ssl_rsa_setup --datadir=/mysqldata/mysql

10.启动mysql服务

[root@sjbf /]# sh /mysqlsoft/mysql/support-files/mysql.server start
/mysqlsoft/mysql/support-files/mysql.server: line 239: my_print_defaults: command not found
/mysqlsoft/mysql/support-files/mysql.server: line 259: cd: /usr/local/mysql: No such file or directory
Starting MySQLCouldn't find MySQL server (/usr/local/mysql/bin/mysqld_safe)[FAILED]

启动mysql服务命令会报错,因为没有修改mysql的配置文件修改Mysql配置文件,修改前为以下内容

if test -z "$basedir"
then
  basedir=/usr/local/mysql
  bindir=/usr/local/mysql/bin
  if test -z "$datadir"
  then
    datadir=/usr/local/mysql/data
  fi
  sbindir=/usr/local/mysql/bin
  libexecdir=/usr/local/mysql/bin
else
  bindir="$basedir/bin"
  if test -z "$datadir"
  then
    datadir="$basedir/data"
  fi
  sbindir="$basedir/sbin"
  libexecdir="$basedir/libexec"
fi

修改后的内容如下

if test -z "$basedir"
then
  basedir=/mysqlsoft/mysql
  bindir=/mysqlsoft/mysql/bin
  if test -z "$datadir"
  then
    datadir=/mysqldata/mysql
  fi
  sbindir=/mysqlsoft/mysql/bin
  libexecdir=/mysqlsoft/mysql/bin
else
  bindir="$basedir/bin"
  if test -z "$datadir"
  then
    datadir="$basedir/data"
  fi
  sbindir="$basedir/sbin"
  libexecdir="$basedir/libexec"
fi

[root@sjbf /]# cp /mysqlsoft/mysql/support-files/mysql.server  /etc/init.d/mysqld
[root@sjbf /]# chmod 755 /etc/init.d/mysqld

启动MySQL

[root@sjbf /]# service mysqld start
Starting MySQL......[  OK  ]

11.配置环境变量

[root@sjbf /]#
# /etc/profile

# System wide environment and startup programs, for login setup
# Functions and aliases go in /etc/bashrc

# It's NOT a good idea to change this file unless you know what you
# are doing. It's much better to create a custom.sh shell script in
# /etc/profile.d/ to make custom changes to your environment, as this
# will prevent the need for merging in future updates.

export MYSQL_HOME=/mysqlsoft/mysql/
export PATH=$PATH:$MYSQL_HOME/bin

12.登录Mysql
初始化成功后,查看初始化密码

[root@sjbf ~]# cat /mysqldata/mysql/mysql.err | grep password
2023-05-05T20:26:25.588664Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: #uVfq!szm7y/

并输入刚刚复制的密码,但是 却提示不能通过mysql.sock文件实现连接

[root@sjbf bin]# ./mysqladmin -u root -p password
Enter password:
mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)'
Check that mysqld is running and that the socket: '/tmp/mysql.sock' exists!

这里就奇怪了,因为在my.cnf文件中设置的socket文件路径为/mysqlsoft/mysql/mysql.sock,但mysql所使用的文件不是启动服务所生成的。

使用-S选项来指定生成的mysql.sock文件进行登录是可以成功登录的

[root@sjbf ~]# mysql -S /mysqlsoft/mysql/mysql.sock -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.33

Copyright (c) 2000, 2023, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

为了方便登录不每次指定-S参数可以在my.cnf文件中指定socket参数

[client]
socket = /mysqlsoft/mysql/mysql.sock

[root@sjbf tmp]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.0.33

Copyright (c) 2000, 2023, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

13.重置root用户密码

[root@sjbf tmp]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.0.33

Copyright (c) 2000, 2023, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> set password=password("123456");
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'password("123456")' at line 1

用5.7的方法修改密码会报错

mysql> ALTER user 'root'@'localhost' IDENTIFIED BY '123456';
Query OK, 0 rows affected (0.14 sec)

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.03 sec)

mysql> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed

mysql> select host,user from user;
+-----------+------------------+
| host      | user             |
+-----------+------------------+
| localhost | mysql.infoschema |
| localhost | mysql.session    |
| localhost | mysql.sys        |
| localhost | root             |
+-----------+------------------+
4 rows in set (0.00 sec)

14.设置允许远程登录mysql
如果要远程访问数据库,只需要把拥有全部权限的root账号对应的记录的Host字段改为%就可以了

mysql> update user set host='%' where user='root';
Query OK, 1 row affected (0.13 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql> flush privileges;
Query OK, 0 rows affected (0.03 sec)

mysql> ALTER USER 'root'@'%' IDENTIFIED BY '123456' PASSWORD EXPIRE NEVER;
Query OK, 0 rows affected (0.09 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.02 sec)

mysql> grant all privileges on *.* to 'root'@'%';
Query OK, 0 rows affected (0.14 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.04 sec)

测试远程登录

[root@sjbf tmp]# mysql -h 10.13.10.99 -P 3306 -uroot -p123456
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 16
Server version: 8.0.33 MySQL Community Server - GPL

Copyright (c) 2000, 2023, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.



mysql> select host,user,plugin from user;
+-----------+------------------+-----------------------+
| host      | user             | plugin                |
+-----------+------------------+-----------------------+
| %         | root             | caching_sha2_password |
| localhost | mysql.infoschema | caching_sha2_password |
| localhost | mysql.session    | caching_sha2_password |
| localhost | mysql.sys        | caching_sha2_password |
+-----------+------------------+-----------------------+
4 rows in set (0.00 sec)

[root@sjbf tmp]# mysql -h 10.13.10.99 -P 3306 -uroot -p123456 --ssl-cert=/mysqldata/mysql/client-cert.pem --ssl-key=/mysqldata/mysql/client-key.pem
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 17
Server version: 8.0.33 MySQL Community Server - GPL

Copyright (c) 2000, 2023, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>
]]>
http://www.jydba.net/index.php/archives/3489/feed 0
在Oracle Linux 6.7操作系统上初始化MySQL 8.0.33时报’unknown variable ‘defaults-file’错误 http://www.jydba.net/index.php/archives/3487 http://www.jydba.net/index.php/archives/3487#respond Mon, 08 May 2023 08:22:39 +0000 http://www.jydba.net/?p=3487 在Oracle Linux 6.7操作系统上初始化MySQL 8.0.33时报’unknown variable ‘defaults-file’错误

[root@sjbf bin]# ./mysqld --user=mysql  --defaults-file=/mysqlsoft/mysql/my.cnf --basedir=/mysqlsoft/mysql --datadir=/mysqldata/mysql --initialize
2023-05-05T20:21:18.355164Z 0 [System] [MY-013169] [Server] /mysqlsoft/mysql-8.0.33-linux-glibc2.12-x86_64/bin/mysqld (mysqld 8.0.33) initializing of server in progress as process 26730
2023-05-05T20:21:18.412269Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2023-05-05T20:21:25.831475Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2023-05-05T20:21:42.025674Z 0 [ERROR] [MY-000067] [Server] =/mysqlsoft/mysql/my.cnf'.
2023-05-05T20:21:42.025812Z 0 [ERROR] [MY-013236] [Server] The designated data directory /mysqldata/mysql/ is unusable. You can remove all files that the server added to it.
2023-05-05T20:21:42.025914Z 0 [ERROR] [MY-010119] [Server] Aborting
2023-05-05T20:21:53.091946Z 0 [System] [MY-010910] [Server] /mysqlsoft/mysql-8.0.33-linux-glibc2.12-x86_64/bin/mysqld: Shutdown complete (mysqld 8.0.33)  MySQL Community Server - GPL.

把defaults-file参数调整为mysqld命令的第一个参数执行成功

[root@sjbf bin]# ./mysqld --defaults-file=/mysqlsoft/mysql/my.cnf --initialize --user=mysql --basedir=/mysqlsoft/mysql --datadir=/mysqldata/mysql

[root@sjbf mysql]# tail -f mysql.err
2023-05-05T20:26:01.800998Z 0 [System] [MY-013169] [Server] /mysqlsoft/mysql-8.0.33-linux-glibc2.12-x86_64/bin/mysqld (mysqld 8.0.33) initializing of server in progress as process 27188
2023-05-05T20:26:01.805553Z 0 [Warning] [MY-013242] [Server] --character-set-server: 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
2023-05-05T20:26:01.870227Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2023-05-05T20:26:09.160682Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2023-05-05T20:26:25.588664Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: #uVfq!szm7y/
]]>
http://www.jydba.net/index.php/archives/3487/feed 0
MySQL 5.7 将表从MyISAM存储引擎转换为InnoDB存储引擎 http://www.jydba.net/index.php/archives/3477 http://www.jydba.net/index.php/archives/3477#respond Fri, 28 Apr 2023 00:12:21 +0000 http://www.jydba.net/?p=3477 将表从MyISAM存储引擎转换为InnoDB存储引擎
如果你想将MyISAM表转换为InnoDB,以获得更好的可靠性和可伸缩性,那么在转换之前,请查看以下指南和技巧。
.调整MyISAM和InnoDB的内存使用
.处理过长或过短的事务
.处理死锁
.规划存储布局
.转换现有表
.克隆表的结构
.传送现有数据
.储存需求
.为每个表定义一个主键
.应用程序性能考虑
.了解与InnoDB表关联的文件

调整MyISAM和InnoDB的内存使用
当用户将MyISAM表转换为InnoDB表时,降低key_buffer_size配置选项的值,以释放缓存结果不再需要的内存。增加innodb_buffer_pool_size配置选项的值,该选项的作用类似于为InnoDB表分配缓存内存。InnoDB缓冲池缓存了表数据和索引数据,加快了查询的查找速度,并将查询结果保存在内存中以供重用。

在繁忙的服务器上,在关闭查询缓存的情况下运行基准测试。InnoDB缓冲池提供了类似的好处,所以查询缓存可能不必要地占用内存。

处理过长或过短的事务
因为MyISAM表不支持事务,所以您可能没有太注意自动提交配置选项以及COMMIT和ROLLBACK语句。这些关键字对于允许多个会话并发地读写InnoDB表非常重要,在写工作负载繁重的情况下提供大量的可伸缩性优势。

当事务处于打开状态时,系统会保留事务开始时看到的数据快照,如果系统插入、更新和删除数百万行,而事务继续运行,这可能会导致大量开销。因此,要注意避免事务运行时间过长:

.如果您使用mysql会话进行交互实验,当完成后请始终COMMIT(完成更改)或ROLLBACK(撤销更改)。关闭交互式会话,而不是让它们长时间开放,以避免意外地使事务长时间开放。

.确保应用程序中的任何错误处理程序也ROLLBACK未完成的更改或COMMIT已完成的更改。

.ROLLBACK是一个相对昂贵的操作,因为INSERT, UPDATE和DELETE操作在COMMIT之前被写入InnoDB表,并且期望大多数更改被成功提交并且很少回滚。在对大量数据进行实验时,避免对大量行进行更改,然后回滚这些更改。

.当使用INSERT语句顺序加载大量数据时,请定期提交结果,以避免事务持续数小时。在典型的数据仓库加载操作中,如果出现问题,您将截断表(使用truncate table)并从头开始,而不是执行ROLLBACK。

前面的技巧可以节省内存和磁盘空间,避免在太长的事务中浪费。当事务比应有的时间短时,问题是I/O过多。对于每次COMMIT, MySQL确保每个更改都被安全地记录到磁盘上,这涉及到一些I/O。

.对于大多数InnoDB表的操作,你应该设置autocommit=0。从效率的角度来看,当发出大量连续的INSERT、UPDATE或DELETE语句时,这避免了不必要的I/O。从安全的角度来看,如果你在mysql命令行或应用程序的异常处理中犯了错误,这允许你发出回滚语句来恢复丢失或混淆的数据。

.autocommit=1适合InnoDB表的情况是,当运行一系列查询以生成报告或分析统计数据时。在这种情况下,不存在与COMMIT或ROLLBACK相关的I/O惩罚, InnoDB可以自动优化只读工作负载。

.如果您进行了一系列相关的更改,请在最后使用COMMIT命令一次完成所有更改。例如,如果将相关的信息片段插入到几个表中,则在进行所有更改后执行一次COMMIT。或者,如果您运行了许多连续的INSERT语句,请在加载完所有数据后执行单个COMMIT;如果您要执行数百万条INSERT语句,也许可以通过每10,000或100,000条记录发出COMMIT来拆分巨大的事务,这样事务就不会变得太大。

.请记住,即使是SELECT语句也会打开一个事务,因此在交互式mysql会话中运行一些报告或调试查询后,发出COMMIT或关闭mysql会话。

处理死锁
你可能会在MySQL错误日志中看到提到“死锁”的警告消息,或者在SHOW ENGINE INNODB STATUS的输出中看到。尽管死锁的名字听起来很可怕,但对于InnoDB表来说,死锁并不是一个严重的问题,通常不需要任何纠正措施。当两个事务开始修改多个表,以不同的顺序访问表时,它们可能会达到一种状态,即每个事务都在等待另一个事务,而不能继续进行。当启用死锁检测(默认)时,MySQL立即检测到这种情况,并取消(回滚)“较小的”事务,允许另一个事务继续进行。如果使用innodb_deadlock_detect配置选项禁用了死锁检测,InnoDB依赖innodb_lock_wait_timeout设置在死锁发生的情况下回滚事务。

无论哪种方式,应用程序都需要错误处理逻辑来重新启动由于死锁而被强制取消的事务。当您像以前一样重新发出相同的SQL语句时,最初的计时问题将不再适用。要么是其他事务已经完成,您的事务可以继续,要么是其他事务仍在进行中,您的事务等待它完成。

如果死锁警告不断发生,则可以检查应用程序代码以重新排序
以一致的方式进行SQL操作,或者缩短事务。你可以使用innodb_print_all_deadlocks选项来测试,在MySQL错误日志中查看所有死锁警告,而不仅仅是SHOW ENGINE INNODB STATUS输出中的最后一个警告。

规划存储布局
为了从InnoDB表中获得最佳性能,您可以调整一些与存储布局相关的参数。

当您转换大型、频繁访问和保存重要数据的MyISAM表时,请调查并考虑innodb_file_per_table、innodb_file_format和innodb_page_size配置选项,以及CREATE TABLE语句的ROW_FORMAT和KEY_BLOCK_SIZE子句。

在最初的实验中,最重要的设置是innodb_file_per_table。当启用这个设置时,MySQL 5.6.6默认会在file-per–table表空间中隐式创建新的InnoDB表。与InnoDB系统表空间不同的是,在表被截断或删除时,操作系统可以通过file-per-table表空间回收磁盘空间。file-per-table表空间还支持Barracuda文件格式和相关特性,如表压缩、变长列的高效页外存储和大索引前缀。

您也可以将InnoDB表存储在共享的通用表空间中。通用表空间支持Barracuda文件格式,可以包含多个表。

转换现有表
使用ALTER table命令将一个非InnoDB表转换为InnoDB表。
ALTER TABLE table_name ENGINE=InnoDB;

不要将MySQL数据库中的MySQL系统表从MyISAM转换为InnoDB类型。这是一个不受支持的操作。类型。

克隆表的结构
你可能会为一个MyISAM表克隆一个InnoDB表,而不是使用ALTER table执行转换,以便在切换之前并行测试新旧表。

用相同的列和索引定义创建一个空的InnoDB表。使用SHOW CREATE TABLE table_name\G查看完整的CREATE TABLE语句。将ENGINE子句更改为引擎= INNODB。

转换现有表
为了将大量数据转移到上一节创建的空InnoDB表中,使用insert into innodb_table SELECT * FROM myisam_table ORDER BY primary_key_columns来插入记录。

也可以在插入数据后为InnoDB表创建索引。以前,创建新的二级索引对于InnoDB来说是一个很慢的操作,但是现在您可以在加载数据之后创建索引,而创建索引的开销相对较小。

如果你在副键上有UNIQUE约束,你可以通过在导入操作中暂时关闭唯一性检查来加速表的导入:

SET unique_checks=0;
... import operation ...
SET unique_checks=1;

对于大型表,这节省了磁盘I/O,因为InnoDB可以使用它的更改缓冲区来批量写入二级索引记录。确保数据不包含重复键。Unique_checks允许但不要求存储引擎忽略重复的键。

为了更好地控制插入过程,您可以将大表分段插入:

INSERT INTO newtable SELECT * FROM oldtable WHERE yourkey > something AND yourkey < = somethingelse;

插入所有记录后,可以重命名表。

在转换大表的过程中,增加InnoDB缓冲池的大小以减少磁盘I/O,最大不超过物理内存的80%。你也可以增加InnoDB日志文件的大小。

储存需求
如果您打算在转换过程中为InnoDB表中的数据创建多个临时副本,建议您以文件/表的方式创建表,以便在删除表时回收磁盘空间。当innodb_file_per_table配置选项被启用(默认)时,新创建的InnoDB表将隐式地创建在file-per-table表空间中。

无论您是直接转换MyISAM表还是创建一个克隆的InnoDB表,都要确保在转换过程中有足够的磁盘空间来容纳新旧表。InnoDB表比MyISAM表需要更多的磁盘空间。如果ALTER TABLE操作耗尽了空间,它将启动回滚,如果是磁盘绑定,则回滚可能需要数小时。对于插入,InnoDB使用insert buffer将辅助索引记录批量合并到索引中。这节省了大量的磁盘I/O。对于回滚,没有使用这种机制,回滚可能比插入时间长30倍。

在回滚失控的情况下,如果您的数据库中没有有价值的数据,那么建议终止数据库进程,而不是等待数百万个磁盘I/O操作完成。

为每个表定义一个主键
主键子句是影响MySQL查询性能以及表和索引空间使用的一个关键因素。主键唯一地标识表中的一行。表中的每一行都必须有一个主键值,并且任何两行都不能有相同的主键值。

这些是主键的指导原则,后面是更详细的解释。
.为每个表声明一个主键。通常,在WHERE子句中查询单行时,它是最重要的一列。

.在原始的CREATE TABLE语句中声明PRIMARY KEY子句,而不是稍后通过ALTER TABLE语句添加它。

.仔细选择列及其数据类型。首选数字列,而不是字符或字符串列。

.如果没有其他稳定的、唯一的、非空的数字列可供使用,请考虑使用自动递增列。

.如果怀疑主键列的值是否会改变,自动递增列也是一个不错的选择。更改主键列的值是一项代价高昂的操作,可能涉及重新安排表内和每个辅助索引内的数据。

考虑为任何还没有主键的表添加一个主键。根据表的最大投影大小,使用最小的实际数值类型。这可以使每一行稍微紧凑一些,对于大型表可以节省大量空间。如果表有辅助索引,那么节省的空间会成倍增加,因为主键值在每个辅助索引项中都是重复的。除了减少磁盘上的数据大小,小主键还可以让缓冲池容纳更多的数据,加快各种操作并提高并发性。

如果表中某些较长的列已经有了主键,比如VARCHAR,可以考虑添加一个新的unsigned AUTO_INCREMENT列,并切换主键到该列,即使该列在查询中没有被引用。这种设计改变可以在二级索引中节省大量空间。用户可以将之前的主键列指定为UNIQUE NOT NULL,以实施与主键子句相同的约束,即防止所有这些列中出现重复值或NULL值。

如果您将相关信息分散到多个表中,通常每个表使用相同的列作为其主键。例如,人事数据库可能有几个表,每个表都有一个员工编号的主键。销售数据库中可能有一些表的主键是客户编号,还有一些表的主键是订单编号。因为使用主键的查找非常快,所以可以为这样的表构造高效的连接查询。

应用程序性能考虑
InnoDB的可靠性和可扩展性比等价的MyISAM表需要更多的磁盘存储空间。您可以稍微改变列和索引的定义,以便更好地利用空间,减少处理结果集时的I/O和内存消耗,以及更好地利用索引查找的查询优化计划。

如果你设置了一个数字ID作为主键,使用这个值与其他表中的相关值进行交叉引用,尤其是在连接查询中。例如,与其接受一个国家名作为输入并进行查询以搜索相同的名称,不如进行一次查找以确定国家ID,然后进行其他查询(或单个连接查询)以跨几个表查找相关信息。与其将顾客或商品编号存储为数字字符串(可能会占用几个字节),不如将其转换为数字ID以便存储和查询。一个4字节的unsigned INT列可以索引超过40亿个元素。

]]>
http://www.jydba.net/index.php/archives/3477/feed 0
MySQL 5.7移动或复制InnoDB表 http://www.jydba.net/index.php/archives/3475 http://www.jydba.net/index.php/archives/3475#respond Thu, 27 Apr 2023 00:20:18 +0000 http://www.jydba.net/?p=3475 移动或复制InnoDB表
将部分或全部InnoDB表移动或复制到不同的服务器或实例的技术。例如,您可以将整个MySQL实例移动到一个更大、更快的服务器上;你可以将整个MySQL实例克隆到一个新的复制从服务器上;您可以将单个表复制到另一个实例以开发和测试应用程序,或者复制到数据仓库服务器以生成报告。

在Windows上,InnoDB总是在内部以小写形式存储数据库和表名。要将二进制格式的数据库从Unix移动到Windows或从Windows移动到Unix,请使用小写名称创建所有数据库和表。实现这一点的一个方便的方法是在创建任何数据库或表之前,在my.cnf或my.ini文件的[mysqld]部分添加以下一行:

[mysqld]
lower_case_table_names=1
mysql> show variables like 'lower_case_table%';
+------------------------+-------+
| Variable_name          | Value |
+------------------------+-------+
| lower_case_table_names | 1     |
+------------------------+-------+
1 row in set (0.01 sec)

传输表空间
传输表空间特性使用FLUSH TABLES…FOR EXPORT准备好从一个服务器实例复制到另一个服务器实例的InnoDB表。为了使用这个特性,InnoDB表创建时必须将innodb_file_per_table设置为ON,这样每个InnoDB表都有自己的表空间。

MySQL企业备份
MySQL企业备份产品允许您备份正在运行的MySQL数据库,最小化操作中断,同时生成数据库的一致快照。当MySQL Enterprise Backup正在复制表时,可以继续读写。此外,MySQL Enterprise Backup可以创建压缩备份文件,并备份表的子集。结合MySQL二进制日志,您可以执行时间点恢复。MySQL企业备份是MySQL企业订阅的一部分。

拷贝数据文件(冷备份方式)
你可以通过复制“冷备份”中列出的所有相关文件来移动InnoDB数据库。

InnoDB数据和日志文件在所有平台上都是二进制兼容的,具有相同的浮点数格式。如果浮点格式不同,但在表中没有使用FLOAT或DOUBLE数据类型,则过程是相同的:只需复制相关文件。

当移动或复制file-per-table的.ibd文件时,源系统和目标系统上的数据库目录名称必须相同。存储在InnoDB共享表空间中的表定义包含了数据库名称。存储在表空间文件中的事务id和日志序列号也因数据库而异。

要将.ibd文件和相关的表从一个数据库移动到另一个数据库,使用RENAME table语句:

RENAME TABLE db1.tbl_name TO db2.tbl_name;

如果你有一个.ibd文件的“干净”备份,你可以将它恢复到它最初的MySQL安装目录,如下所示:
1.在复制.ibd文件后,不能删除或截断表,因为这样做会更改存储在表空间中的表ID。

2.执行ALTER TABLE语句删除当前的.ibd文件:

ALTER TABLE tbl_name DISCARD TABLESPACE;

3.将备份的.ibd文件复制到适当的数据库目录。

4.执行ALTER TABLE语句,告诉InnoDB对表使用新的.ibd文件:

ALTER TABLE tbl_name IMPORT TABLESPACE;

ALTER TABLE…IMPORT TABLESPACE特性不会对导入的数据强制执行外键约束。

在这种情况下,“干净的”.ibd文件备份是指满足以下要求的备份:
.在.ibd文件中没有未提交修改的事务。
.在.ibd文件中没有未合并的插入缓冲区项。
.Purge已经从.ibd文件中删除了所有已删除标记的索引记录。
.Mysqld已将.ibd文件的所有修改页从缓冲池刷新到该文件。

您可以使用以下方法对.ibd文件进行干净备份:
1.停止mysqld服务器上的所有活动并提交所有事务。
2.等待,直到SHOW ENGINE INNODB STATUS显示数据库中没有活动事务,并且INNODB的主线程状态为Waiting for server activity。然后,您可以复制.ibd文件。

另一种复制。ibd文件的方法是使用MySQL企业备份产品:
1.使用MySQL Enterprise Backup备份InnoDB安装。
2.在备份机上启动第二个mysqld服务器,并让它清理备份中的.ibd文件。

导出和导入(mysqldump)
您可以使用mysqldump将表转储到一台机器上,然后在另一台机器上导入转储文件。使用此方法,格式是否不同或表是否包含浮点数据都无关紧要。

提高此方法性能的一种方法是在导入数据时关闭自动提交模式,假设表空间有足够的空间容纳导入事务生成的大回滚段。只有在导入整个表或表的一个段后才执行提交操作

]]>
http://www.jydba.net/index.php/archives/3475/feed 0
MySQL 5.7 InnoDB Tablespace Encryption http://www.jydba.net/index.php/archives/3468 http://www.jydba.net/index.php/archives/3468#respond Fri, 10 Mar 2023 08:54:50 +0000 http://www.jydba.net/?p=3468 InnoDB Tablespace Encryption

InnoDB支持对存储file-per-table表空间中的InnoDB表中的数据进行加密。该特性为物理表空间数据文件提供静态加密。

InnoDB表空间加密使用两层加密密钥架构,由主加密密钥和表空间密钥组成。当一个InnoDB表被加密时,表空间密钥被加密并存储在表空间头中。当应用程序或经过认证的用户想要访问加密的表空间数据时,InnoDB使用一个主加密密钥来解密表空间密钥。表空间密钥的解密版本永远不会改变,但主加密密钥可以根据需要改变。此操作称为主键旋转。

InnoDB表空间加密特性依赖于keyring插件进行主加密密钥管理。

所有MySQL版本都提供了keyring_file插件,该插件将主加密密钥数据存储在keyring_file_data配置选项指定的位置的keyring文件中。

非企业版MySQL中的InnoDB表空间加密特性使用keyring_file插件进行加密密钥管理,这并不是一个符合法规的解决方案。安全标准,如PCI,FIPS和其他要求使用密钥管理系统来保护、管理和保护密钥库或硬件安全模块(hsm)中的加密密钥。

MySQL企业版提供了keyring_okv插件,其中包括一个KMIP客户端(KMIP 1.1),它与Oracle密钥库(OKV)一起工作,提供加密密钥管理。当InnoDB表空间加密使用OKV进行加密密钥管理时,该特性被称为“MySQL企业”透明数据加密(TDE)。

一个安全、健壮的加密密钥管理解决方案(如OKV)对于安全性和符合各种安全标准至关重要。在其他好处中,使用密钥库可确保密钥安全存储,永远不会丢失,并且只有授权的密钥管理员知道。密钥库还维护加密密钥历史记录

InnoDB表空间加密支持AES (Advanced encryption Standard)块加密算法。它采用ECB (Electronic Codebook)块加密方式对表空间密钥进行加密CBC (Cipher Block chainaining)块加密方式,用于数据加密

InnoDB表空间加密前提条件

必须安装和配置keyring插件(keyring_file插件或keyring_okv插件)。Keyring插件安装在启动时使用–early-plugin-load选项执行。提前加载可以确保插件在InnoDB存储引擎初始化之前可用。

一次只能启用一个keyring插件。不支持启用多个密匙环插件。

一旦在MySQL实例中创建了加密表,在创建加密表时加载的keyring插件必须在InnoDB初始化之前使用–early-plugin-load选项继续加载。如果不这样做,会导致启动和恢复InnoDB时出现错误。

启用加密模块

mysql> INSTALL PLUGIN keyring_file soname 'keyring_file.so';
Query OK, 0 rows affected (0.09 sec)

创建密钥文件目录

[mysql@localhost ~]$ mkdir -p /mysqldata/mysql/mysql-keyring/
[mysql@localhost ~]$ chown -R mysql:mysql /mysqldata/mysql/mysql-keyring/
[mysql@localhost ~]$ chmod -R 775 /mysqldata/mysql/mysql-keyring/

设置加密key存放路径

mysql> set global keyring_file_data='/mysqldata/mysql/mysql-keyring/keyring';
Query OK, 0 rows affected (0.00 sec)

永久启用设置
上诉两个步骤都是临时的,重启服务都会失效,我们把配置写到配置文件里,确保重启服务后也能生效

[mysqld]
early-plugin-load=keyring_file.so
keyring_file_data=/mysqldata/mysql/mysql-keyring/keyring

查看key的存放路径

mysql> show global variables like '%keyring_file_data%';
+-------------------+----------------------------------------+
| Variable_name     | Value                                  |
+-------------------+----------------------------------------+
| keyring_file_data | /mysqldata/mysql/mysql-keyring/keyring |
+-------------------+----------------------------------------+
1 row in set (0.02 sec)

要验证keyring插件是否处于活动状态,请使用SHOW PLUGINS语句或查询INFORMATION_SCHEMA.PLUGINS表。例如:

mysql> show plugins;
+----------------------------+----------+--------------------+-----------------+---------+
| Name                       | Status   | Type               | Library         | License |
+----------------------------+----------+--------------------+-----------------+---------+
| keyring_file               | ACTIVE   | KEYRING            | keyring_file.so | GPL     |
| binlog                     | ACTIVE   | STORAGE ENGINE     | NULL            | GPL     |
| mysql_native_password      | ACTIVE   | AUTHENTICATION     | NULL            | GPL     |
| sha256_password            | ACTIVE   | AUTHENTICATION     | NULL            | GPL     |
| CSV                        | ACTIVE   | STORAGE ENGINE     | NULL            | GPL     |
| MEMORY                     | ACTIVE   | STORAGE ENGINE     | NULL            | GPL     |
| InnoDB                     | ACTIVE   | STORAGE ENGINE     | NULL            | GPL     |
| INNODB_TRX                 | ACTIVE   | INFORMATION SCHEMA | NULL            | GPL     |
| INNODB_LOCKS               | ACTIVE   | INFORMATION SCHEMA | NULL            | GPL     |
| INNODB_LOCK_WAITS          | ACTIVE   | INFORMATION SCHEMA | NULL            | GPL     |
| INNODB_CMP                 | ACTIVE   | INFORMATION SCHEMA | NULL            | GPL     |
| INNODB_CMP_RESET           | ACTIVE   | INFORMATION SCHEMA | NULL            | GPL     |
| INNODB_CMPMEM              | ACTIVE   | INFORMATION SCHEMA | NULL            | GPL     |
| INNODB_CMPMEM_RESET        | ACTIVE   | INFORMATION SCHEMA | NULL            | GPL     |
| INNODB_CMP_PER_INDEX       | ACTIVE   | INFORMATION SCHEMA | NULL            | GPL     |
| INNODB_CMP_PER_INDEX_RESET | ACTIVE   | INFORMATION SCHEMA | NULL            | GPL     |
| INNODB_BUFFER_PAGE         | ACTIVE   | INFORMATION SCHEMA | NULL            | GPL     |
| INNODB_BUFFER_PAGE_LRU     | ACTIVE   | INFORMATION SCHEMA | NULL            | GPL     |
| INNODB_BUFFER_POOL_STATS   | ACTIVE   | INFORMATION SCHEMA | NULL            | GPL     |
| INNODB_TEMP_TABLE_INFO     | ACTIVE   | INFORMATION SCHEMA | NULL            | GPL     |
| INNODB_METRICS             | ACTIVE   | INFORMATION SCHEMA | NULL            | GPL     |
| INNODB_FT_DEFAULT_STOPWORD | ACTIVE   | INFORMATION SCHEMA | NULL            | GPL     |
| INNODB_FT_DELETED          | ACTIVE   | INFORMATION SCHEMA | NULL            | GPL     |
| INNODB_FT_BEING_DELETED    | ACTIVE   | INFORMATION SCHEMA | NULL            | GPL     |
| INNODB_FT_CONFIG           | ACTIVE   | INFORMATION SCHEMA | NULL            | GPL     |
| INNODB_FT_INDEX_CACHE      | ACTIVE   | INFORMATION SCHEMA | NULL            | GPL     |
| INNODB_FT_INDEX_TABLE      | ACTIVE   | INFORMATION SCHEMA | NULL            | GPL     |
| INNODB_SYS_TABLES          | ACTIVE   | INFORMATION SCHEMA | NULL            | GPL     |
| INNODB_SYS_TABLESTATS      | ACTIVE   | INFORMATION SCHEMA | NULL            | GPL     |
| INNODB_SYS_INDEXES         | ACTIVE   | INFORMATION SCHEMA | NULL            | GPL     |
| INNODB_SYS_COLUMNS         | ACTIVE   | INFORMATION SCHEMA | NULL            | GPL     |
| INNODB_SYS_FIELDS          | ACTIVE   | INFORMATION SCHEMA | NULL            | GPL     |
| INNODB_SYS_FOREIGN         | ACTIVE   | INFORMATION SCHEMA | NULL            | GPL     |
| INNODB_SYS_FOREIGN_COLS    | ACTIVE   | INFORMATION SCHEMA | NULL            | GPL     |
| INNODB_SYS_TABLESPACES     | ACTIVE   | INFORMATION SCHEMA | NULL            | GPL     |
| INNODB_SYS_DATAFILES       | ACTIVE   | INFORMATION SCHEMA | NULL            | GPL     |
| INNODB_SYS_VIRTUAL         | ACTIVE   | INFORMATION SCHEMA | NULL            | GPL     |
| MyISAM                     | ACTIVE   | STORAGE ENGINE     | NULL            | GPL     |
| MRG_MYISAM                 | ACTIVE   | STORAGE ENGINE     | NULL            | GPL     |
| PERFORMANCE_SCHEMA         | ACTIVE   | STORAGE ENGINE     | NULL            | GPL     |
| ARCHIVE                    | ACTIVE   | STORAGE ENGINE     | NULL            | GPL     |
| BLACKHOLE                  | ACTIVE   | STORAGE ENGINE     | NULL            | GPL     |
| FEDERATED                  | DISABLED | STORAGE ENGINE     | NULL            | GPL     |
| partition                  | ACTIVE   | STORAGE ENGINE     | NULL            | GPL     |
| ngram                      | ACTIVE   | FTPARSER           | NULL            | GPL     |
+----------------------------+----------+--------------------+-----------------+---------+

mysql> SELECT PLUGIN_NAME, PLUGIN_STATUS
    -> FROM INFORMATION_SCHEMA.PLUGINS
    -> WHERE PLUGIN_NAME LIKE 'keyring%';
+--------------+---------------+
| PLUGIN_NAME  | PLUGIN_STATUS |
+--------------+---------------+
| keyring_file | ACTIVE        |
+--------------+---------------+
1 row in set (0.00 sec)

必须启用innodb_file_per_table选项(默认值)。InnoDB表空间加密只支持每表一个文件的表空间。或者,您可以指定TABLESPACE=’innodb_file_per_table’选项,用于创建加密表或修改现有表以启用加密。

mysql> show variables like '%innodb_file_per_table%';
+-----------------------+-------+
| Variable_name         | Value |
+-----------------------+-------+
| innodb_file_per_table | ON    |
+-----------------------+-------+
1 row in set (0.01 sec)

在对生产数据使用InnoDB表空间加密特性之前,请确保已采取措施防止丢失主加密密钥。如果主加密密钥丢失,则无法恢复加密表空间文件中存储的数据。如果您正在使用keyring_file插件,建议您在创建第一个加密表之后以及主密钥旋转前后立即创建keyring文件的备份。keyring文件位置由keyring_file_data配置选项定义。如果您正在使用keyring_okv插件,请确保您已经执行了必要的keyring_okv插件和Oracle密钥库(OKV)配置。

开启和关闭InnoDB表空间加密

要为一个新的InnoDB表启用加密,在create table语句中指定encryption选项。

mysql> CREATE TABLE t1 (c1 INT) ENCRYPTION='Y';
Query OK, 0 rows affected (0.01 sec)

要对现有的InnoDB表启用加密,请在alter table语句中指定encryption选项。

mysql> alter table abc encryption='y';
Query OK, 1 row affected (0.04 sec)
Records: 1  Duplicates: 0  Warnings: 0

mysql> show create table abc;
+-------+-------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table                                                                                                            |
+-------+-------------------------------------------------------------------------------------------------------------------------+
| abc   | CREATE TABLE `abc` (
  `a` int(11) NOT NULL,
  PRIMARY KEY (`a`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ENCRYPTION='y' |
+-------+-------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

使用alter table设置encryption =’N’来禁用InnoDB表的加密功能

mysql> alter table abc encryption='n';
Query OK, 1 row affected (0.02 sec)
Records: 1  Duplicates: 0  Warnings: 0

mysql> show create table abc;
+-------+-------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table                                                                                                            |
+-------+-------------------------------------------------------------------------------------------------------------------------+
| abc   | CREATE TABLE `abc` (
  `a` int(11) NOT NULL,
  PRIMARY KEY (`a`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ENCRYPTION='n' |
+-------+-------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

InnoDB表空间加密和主密钥轮换
主加密密钥应该定期轮换,只要您怀疑密钥可能已被泄露。

主密钥轮换是一个原子的实例级操作。每次轮换主加密密钥时,MySQL实例中的所有表空间密钥都将重新加密并保存回各自的表空间头中。作为原子操作,一旦启动轮换操作,所有表空间密钥都必须重新加密成功。如果主密钥轮换因服务器故障而中断,InnoDB将在服务器重启时前滚该操作。

轮换主加密密钥只会更改主加密密钥并重新加密表空间密钥。它不解密或重新加密相关的表空间数据

轮换主加密密钥,执行以下命令:

[root@localhost ~]# cd /mysqldata/mysql/mysql-keyring/
[root@localhost mysql-keyring]# ll
total 4
-rw-r-----. 1 mysql mysql 155 Mar  3 17:20 keyring

mysql> ALTER INSTANCE ROTATE INNODB MASTER KEY;
Query OK, 0 rows affected (0.00 sec)

[root@localhost mysql-keyring]# ll
total 4
-rw-r-----. 1 mysql mysql 283 Mar 10 15:58 keyring

alter instance rotate innodb master key支持并发DML。但是,它不能与create table … encryption或alter table … encryption操作一起并发执行,采用锁来防止这些语句并发执行时可能产生的冲突。如果一个冲突的语句正在运行,那么它必须在另一个语句运行之前完成。

InnoDB表空间加密与恢复
ALTER INSTANCE ROTATE INNODB MASTER KEY语句仅在主数据库和从数据库所运行的MySQL版本支持表空间加密特性的复制环境中被支持。

成功的ALTER INSTANCE ROTATE INNODB MASTER KEY语句被写入二进制日志,用于在slave上复制。

如果一个ALTER INSTANCE ROTATE INNODB MASTER KEY语句失败,它不会被记录到二进制日志中,也不会被复制到slave上。

如果keyring插件安装在主节点上而从节点没有安装,复制ALTER INSTANCE ROTATE INNODB MASTER KEY操作失败。

如果keyring_file插件同时安装在主服务器和从服务器上,但是从服务器上没有keyring文件,假设keyring文件数据没有缓存在内存中,复制的ALTER INSTANCE ROTATE INNODB MASTER KEY语句将在从服务器上创建keyring文件。如果可用的话,ALTER INSTANCE INNODB MASTER KEY使用缓存在内存中的keyring文件数据。

识别使用InnoDB表空间加密的表
当在CREATE TABLE或ALTER TABLE语句中指定了ENCRYPTION选项时,它将记录在INFORMATION_SCHEMA.TABLES的CREATE_OPTIONS字段中。可以查询该字段以识别MySQL实例中的加密表。

mysql> SELECT TABLE_SCHEMA, TABLE_NAME, CREATE_OPTIONS FROM INFORMATION_SCHEMA.TABLES
    -> WHERE CREATE_OPTIONS LIKE '%ENCRYPTION="Y"%';
+--------------+------------+-------------------------------------------------------+
| TABLE_SCHEMA | TABLE_NAME | CREATE_OPTIONS                                        |
+--------------+------------+-------------------------------------------------------+
| test         | t1         | ENCRYPTION="Y"                                        |
| test         | ts02       | row_format=COMPRESSED KEY_BLOCK_SIZE=4 ENCRYPTION="Y" |
| test         | ts03       | COMPRESSION="zlib" ENCRYPTION="Y"                     |
+--------------+------------+-------------------------------------------------------+
3 rows in set (0.42 sec)

InnoDB表空间加密使用说明
a.如果服务器在正常运行期间退出或停止,建议使用之前配置的相同加密设置重新启动服务器。

b.第一个主加密密钥是在对第一个新表或现有表进行加密时生成的。

c.主密钥轮换会重新加密表空间密钥,但不会改变表空间密钥本身。要更改表空间密钥,必须使用alter table tbl_name encryption禁用并重新启用表加密,这是一个ALGORITHM=COPY操作来重建表。

d.Keyring_file插件使用说明
如果keyring文件为空或缺失,第一次执行ALTER INSTANCE ROTATE INNODB MASTER KEY将创建一个主加密密钥。

卸载keyring_file插件不会删除现有的keyring文件。

建议不要将keyring文件与表空间数据文件放在同一个目录下。keyring文件的位置由keyring_file_data选项指定。

在运行时修改keyring_file_data选项或使用新的keyring_file_data设置重新启动服务器可能导致以前加密的表不可访问,从而导致数据丢失。

InnoDB表空间加密限制
.系统目前只支持AES (Advanced Encryption Standard)加密算法。InnoDB表空间加密使用ECB (Electronic Codebook)块加密方式对表空间密钥进行加密,使用CBC (Cipher block Chaining)块加密方式对数据进行加密。

.修改表的ENCRYPTION属性是一个ALGORITHM=COPY操作。不支持ALGORITHM=INPLACE。

.InnoDB表空间加密只支持存储在file-per-table表空间中的InnoDB表。存储在其他InnoDB表空间类型中的表不支持加密,包括普通表空间、系统表空间、undo log表空间和临时表空间。

.不能将加密表从file-per-table表空间移动或复制到不支持的InnoDB表空间类型。

.表空间加密只适用于表空间中的数据。重做日志、undo日志或二进制日志中的数据不加密。

.目前不支持直接从keyring_file插件迁移到keyring_okv插件,反之亦然。更改密匙环插件需要解密表,卸载当前的密匙环插件,安装和配置其他密匙环插件,并重新加密表。

]]>
http://www.jydba.net/index.php/archives/3468/feed 0
龙芯麒麟源码编译MySQL生成软件包进行安装 http://www.jydba.net/index.php/archives/3448 http://www.jydba.net/index.php/archives/3448#respond Fri, 13 Jan 2023 00:51:55 +0000 http://www.jydba.net/?p=3448 查看是否已安装mariadb,若是已安装,需要卸载

[root@localhost yum.repos.d]# rpm -qa|grep mariadb
mariadb-10.3.9-8.p01.ky10.mips64el
mariadb-common-10.3.9-8.p01.ky10.mips64el
mariadb-errmessage-10.3.9-8.p01.ky10.mips64el
mariadb-connector-c-3.0.6-6.ky10.mips64el
mariadb-server-10.3.9-8.p01.ky10.mips64el

要是有,卸载:# yum remove mariadb

[root@localhost yum.repos.d]# yum remove mariadb
Warning: failed loading '/etc/yum.repos.d/kylin.repo', skipping.
Dependencies resolved.
=================================================================================================================================================================================================
 Package                                         Architecture                              Version                                              Repository                                  Size
=================================================================================================================================================================================================
Removing:
 mariadb                                         mips64el                                  3:10.3.9-8.p01.ky10                                  @anaconda                                   38 M
Removing dependent packages:
 mariadb-server                                  mips64el                                  3:10.3.9-8.p01.ky10                                  @anaconda                                   92 M
Removing unused dependencies:
 perl-DBD-MySQL                                  mips64el                                  4.046-6.ky10                                         @anaconda                                  327 k

Transaction Summary
=================================================================================================================================================================================================
Remove  3 Packages

Freed space: 129 M
Is this ok [y/N]: y
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                                                                         1/1
  Running scriptlet: mariadb-3:10.3.9-8.p01.ky10.mips64el                                                                                                                                    1/1
  Erasing          : mariadb-3:10.3.9-8.p01.ky10.mips64el                                                                                                                                    1/3
  Running scriptlet: mariadb-server-3:10.3.9-8.p01.ky10.mips64el                                                                                                                             2/3
  Erasing          : mariadb-server-3:10.3.9-8.p01.ky10.mips64el                                                                                                                             2/3
  Running scriptlet: mariadb-server-3:10.3.9-8.p01.ky10.mips64el                                                                                                                             2/3
  Erasing          : perl-DBD-MySQL-4.046-6.ky10.mips64el                                                                                                                                    3/3
  Running scriptlet: perl-DBD-MySQL-4.046-6.ky10.mips64el                                                                                                                                    3/3
  Verifying        : mariadb-3:10.3.9-8.p01.ky10.mips64el                                                                                                                                    1/3
  Verifying        : mariadb-server-3:10.3.9-8.p01.ky10.mips64el                                                                                                                             2/3
  Verifying        : perl-DBD-MySQL-4.046-6.ky10.mips64el                                                                                                                                    3/3

Removed:
  mariadb-3:10.3.9-8.p01.ky10.mips64el                         mariadb-server-3:10.3.9-8.p01.ky10.mips64el                         perl-DBD-MySQL-4.046-6.ky10.mips64el

Complete!

[root@localhost soft]# mkdir /mnt/cdrom
[root@localhost soft]# mount -o loop -t iso9660 Kylin-Server-10-SP1-Release-Build18-20210809-mips64el.iso /mnt/cdrom
mount: /mnt/cdrom: WARNING: source write-protected, mounted read-only.
[root@localhost soft]# cd /mnt/cdrom
[root@localhost cdrom]# ls
boot  boot.catalog  EFI  images  LICENSE  manual  Packages  repodata  TRANS.TBL

[root@localhost yum.repos.d]# cat kylin.repo
[ks10-local-iso]
name = Kylin Linux Advanced Server 10 - local
baseurl = file:///mnt/cdrom/
gpgcheck = 1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-kylin
enabled = 1

(2)下载源码包并解压

# wget https://cdn.mysql.com/archives/mysql-5.7/mysql-5.7.29.tar.gz
# tar -zxvf mysql-5.7.29.tar.gz

(3)yum安装编译所需要的工具和库

# yum install gcc gcc-c++ cmake ncurses-devel bison openssl-devel rpcgen

上面的软件要一个一个安装,一起可能有问题

[root@localhost yum.repos.d]# yum -y install gcc* gcc-c++ ncurses* ncurses-devel* cmake* bison* libgcrypt* perl* make* openssl-devel* rpcgen*
Last metadata expiration check: 0:01:56 ago on 2022年11月15日 星期二 23时22分05秒.
Package gcc-8.3.1-4.5.p03.ky10.mips64el is already installed.
Package ncurses-6.1-14.ky10.mips64el is already installed.
Package ncurses-base-6.1-14.ky10.noarch is already installed.
Package ncurses-libs-6.1-14.ky10.mips64el is already installed.
Package cmake-3.12.1-5.ky10.mips64el is already installed.
Package cmake-data-3.12.1-5.ky10.noarch is already installed.
Package cmake-filesystem-3.12.1-5.ky10.mips64el is already installed.
Package cmake-help-3.12.1-5.ky10.noarch is already installed.
Package cmake-rpm-macros-3.12.1-5.ky10.noarch is already installed.
Package libgcrypt-1.8.3-5.ky10.mips64el is already installed.
Package perl-4:5.28.0-434.ky10.mips64el is already installed.
Package perl-Algorithm-Diff-1.1903-14.ky10.noarch is already installed.
Package perl-Algorithm-Diff-help-1.1903-14.ky10.noarch is already installed.
Package perl-Archive-Tar-2.30-421.ky10.noarch is already installed.
Package perl-Authen-SASL-help-2.16-16.ky10.noarch is already installed.
Package perl-B-Debug-1.26-4.ky10.noarch is already installed.
Package perl-B-Debug-help-1.26-4.ky10.noarch is already installed.
Package perl-Business-ISBN-Data-help-20191107-2.ky10.noarch is already installed.
Package perl-Business-ISBN-help-3.005-1.ky10.noarch is already installed.
Package perl-CGI-help-4.46-1.ky10.noarch is already installed.
Package perl-CPAN-Meta-2.150010-419.ky10.noarch is already installed.
Package perl-CPAN-Meta-Requirements-2.140-419.ky10.noarch is already installed.
Package perl-CPAN-Meta-Requirements-help-2.140-419.ky10.noarch is already installed.
Package perl-CPAN-Meta-YAML-0.018-420.ky10.noarch is already installed.
Package perl-CPAN-Meta-YAML-help-0.018-420.ky10.noarch is already installed.
Package perl-CPAN-Meta-help-2.150010-419.ky10.noarch is already installed.
Package perl-Capture-Tiny-help-0.48-4.ky10.noarch is already installed.
Package perl-Carp-1.50-418.ky10.noarch is already installed.
Package perl-Carp-help-1.50-418.ky10.noarch is already installed.
Package perl-Class-Inspector-help-1.32-5.ky10.noarch is already installed.
Package perl-Class-Method-Modifiers-help-2.12-12.ky10.noarch is already installed.
Package perl-Class-XSAccessor-help-1.19-18.ky10.noarch is already installed.
Package perl-Compress-Bzip2-help-2.26-10.ky10.noarch is already installed.
Package perl-Compress-Raw-Bzip2-2.081-8.ky10.mips64el is already installed.
Package perl-Compress-Raw-Bzip2-help-2.081-8.ky10.noarch is already installed.
Package perl-Compress-Raw-Zlib-2.081-6.ky10.mips64el is already installed.
Package perl-Compress-Raw-Zlib-help-2.081-6.ky10.noarch is already installed.
Package perl-Config-General-help-2.63-1.ky10.noarch is already installed.
Package perl-Config-Perl-V-0.30-5.ky10.noarch is already installed.
Package perl-Config-Perl-V-help-0.30-5.ky10.noarch is already installed.
Package perl-Crypt-OpenSSL-Random-help-0.15-4.ky10.noarch is already installed.
Package perl-Crypt-PasswdMD5-help-1.4.0-14.ky10.noarch is already installed.
Package perl-DBD-MySQL-help-4.046-6.ky10.mips64el is already installed.
Package perl-DBD-SQLite-1.58-4.ky10.mips64el is already installed.
Package perl-DBD-SQLite-help-1.58-4.ky10.mips64el is already installed.
Package perl-DBI-1.642-2.ky10.mips64el is already installed.
Package perl-DBI-help-1.642-2.ky10.noarch is already installed.
Package perl-DB_File-1.842-2.ky10.mips64el is already installed.
Package perl-DB_File-help-1.842-2.ky10.noarch is already installed.
Package perl-Data-Dumper-2.172-3.ky10.mips64el is already installed.
Package perl-Data-Dumper-help-2.172-3.ky10.noarch is already installed.
Package perl-Data-Section-help-0.200007-6.ky10.noarch is already installed.
Package perl-Date-Calc-help-6.4-12.ky10.noarch is already installed.
Package perl-Devel-CheckLib-help-1.13-5.ky10.noarch is already installed.
Package perl-Devel-GlobalDestruction-help-0.14-8.ky10.noarch is already installed.
Package perl-Devel-PPPort-3.42-4.ky10.mips64el is already installed.
Package perl-Devel-PPPort-help-3.42-4.ky10.noarch is already installed.
Package perl-Devel-Size-help-0.82-4.ky10.noarch is already installed.
Package perl-Digest-1.17-419.ky10.noarch is already installed.
Package perl-Digest-MD5-2.55-419.ky10.mips64el is already installed.
Package perl-Digest-MD5-help-2.55-419.ky10.noarch is already installed.
Package perl-Digest-SHA-1:6.02-7.ky10.mips64el is already installed.
Package perl-Digest-SHA-help-1:6.02-7.ky10.noarch is already installed.
Package perl-Digest-SHA3-help-1.04-4.ky10.mips64el is already installed.
Package perl-Digest-help-1.17-419.ky10.noarch is already installed.
Package perl-Encode-4:2.98-9.ky10.mips64el is already installed.
Package perl-Encode-Locale-help-1.05-12.ky10.noarch is already installed.
Package perl-Encode-devel-4:2.98-9.ky10.mips64el is already installed.
Package perl-Encode-help-4:2.98-9.ky10.noarch is already installed.
Package perl-Env-1.04-397.ky10.noarch is already installed.
Package perl-Env-help-1.04-397.ky10.noarch is already installed.
Package perl-Error-1:0.17026-4.ky10.noarch is already installed.
Package perl-Error-help-1:0.17026-4.ky10.noarch is already installed.
Package perl-Exporter-5.73-420.ky10.noarch is already installed.
Package perl-Exporter-Tiny-help-1.002001-5.ky10.noarch is already installed.
Package perl-Exporter-help-5.73-420.ky10.noarch is already installed.
Package perl-ExtUtils-Command-1:7.42-2.ky10.noarch is already installed.
Package perl-ExtUtils-Config-help-0.008-19.ky10.noarch is already installed.
Package perl-ExtUtils-Helpers-0.026-13.ky10.noarch is already installed.
Package perl-ExtUtils-Install-2.14-419.ky10.noarch is already installed.
Package perl-ExtUtils-Install-help-2.14-419.ky10.noarch is already installed.
Package perl-ExtUtils-InstallPaths-help-0.012-9.ky10.noarch is already installed.
Package perl-ExtUtils-MakeMaker-1:7.42-2.ky10.noarch is already installed.
Package perl-ExtUtils-MakeMaker-help-1:7.42-2.ky10.noarch is already installed.
Package perl-ExtUtils-Manifest-1:1.71-4.ky10.noarch is already installed.
Package perl-ExtUtils-Manifest-help-1:1.71-4.ky10.noarch is already installed.
Package perl-ExtUtils-ParseXS-2:3.35-1.ky10.noarch is already installed.
Package perl-ExtUtils-ParseXS-help-2:3.35-1.ky10.noarch is already installed.
Package perl-Fedora-VSP-help-0.001-10.ky10.noarch is already installed.
Package perl-File-BaseDir-help-0.08-6.ky10.noarch is already installed.
Package perl-File-DesktopEntry-help-0.22-11.ky10.noarch is already installed.
Package perl-File-Fetch-0.56-4.ky10.noarch is already installed.
Package perl-File-Fetch-help-0.56-4.ky10.noarch is already installed.
Package perl-File-HomeDir-1.004-4.ky10.noarch is already installed.
Package perl-File-HomeDir-help-1.004-4.ky10.noarch is already installed.
Package perl-File-Path-2.16-4.ky10.noarch is already installed.
Package perl-File-Path-help-2.16-4.ky10.noarch is already installed.
Package perl-File-ReadBackwards-help-1.05-1.ky10.noarch is already installed.
Package perl-File-Remove-help-1.58-2.ky10.noarch is already installed.
Package perl-File-ShareDir-Install-help-0.13-4.ky10.noarch is already installed.
Package perl-File-ShareDir-help-1.116-4.ky10.noarch is already installed.
Package perl-File-Slurp-help-9999.19-22.ky10.noarch is already installed.
Package perl-File-Sync-help-0.11-20.ky10.noarch is already installed.
Package perl-File-Temp-1:0.230.800-4.ky10.noarch is already installed.
Package perl-File-Temp-help-1:0.230.800-4.ky10.noarch is already installed.
Package perl-File-Which-1.22-6.ky10.noarch is already installed.
Package perl-File-Which-help-1.22-6.ky10.noarch is already installed.
Package perl-Filter-2:1.59-2.ky10.mips64el is already installed.
Package perl-Filter-Simple-1:0.94-1.ky10.noarch is already installed.
Package perl-Filter-Simple-help-1:0.94-1.ky10.noarch is already installed.
Package perl-Font-TTF-help-1.06-9.ky10.noarch is already installed.
Package perl-GD-Barcode-help-1.15-30.ky10.noarch is already installed.
Package perl-GD-help-2.71-1.p01.ky10.noarch is already installed.
Package perl-GSSAPI-help-0.28-26.ky10.mips64el is already installed.
Package perl-Getopt-Long-2.50-419.ky10.noarch is already installed.
Package perl-Getopt-Long-help-2.50-419.ky10.noarch is already installed.
Package perl-Git-2.27.0-4.ky10.noarch is already installed.
Package perl-HTML-Parser-help-3.72-16.ky10.mips64el is already installed.
Package perl-HTML-Tagset-help-3.20-37.ky10.noarch is already installed.
Package perl-HTTP-Cookies-help-6.04-5.ky10.noarch is already installed.
Package perl-HTTP-Daemon-help-6.01-26.ky10.noarch is already installed.
Package perl-HTTP-Date-help-6.02-21.ky10.noarch is already installed.
Package perl-HTTP-Message-help-6.18-4.ky10.noarch is already installed.
Package perl-HTTP-Negotiate-help-6.01-22.ky10.noarch is already installed.
Package perl-HTTP-Tiny-0.076-3.ky10.noarch is already installed.
Package perl-HTTP-Tiny-help-0.076-3.ky10.noarch is already installed.
Package perl-IO-Compress-2.081-6.ky10.noarch is already installed.
Package perl-IO-Compress-help-2.081-6.ky10.noarch is already installed.
Package perl-IO-HTML-help-1.001-13.ky10.noarch is already installed.
Package perl-IO-Socket-INET6-help-2.72-15.ky10.noarch is already installed.
Package perl-IO-Socket-IP-0.39-420.ky10.noarch is already installed.
Package perl-IO-Socket-IP-help-0.39-420.ky10.noarch is already installed.
Package perl-IO-Socket-SSL-help-2.066-4.ky10.noarch is already installed.
Package perl-IO-stringy-help-2.111-12.ky10.noarch is already installed.
Package perl-IPC-Cmd-2:1.04-4.ky10.noarch is already installed.
Package perl-IPC-Cmd-help-2:1.04-4.ky10.noarch is already installed.
Package perl-IPC-SysV-2.07-5.ky10.mips64el is already installed.
Package perl-IPC-SysV-help-2.07-5.ky10.noarch is already installed.
Package perl-IPC-System-Simple-1.25-19.ky10.noarch is already installed.
Package perl-IPC-System-Simple-help-1.25-19.ky10.noarch is already installed.
Package perl-JSON-PP-1:4.04-2.ky10.noarch is already installed.
Package perl-JSON-PP-help-1:4.04-2.ky10.noarch is already installed.
Package perl-JSON-XS-help-1:3.04-6.ky10.noarch is already installed.
Package perl-JSON-help-2.97.001-6.ky10.noarch is already installed.
Package perl-LWP-MediaTypes-help-6.02-17.ky10.noarch is already installed.
Package perl-List-MoreUtils-XS-help-0.428-7.ky10.noarch is already installed.
Package perl-List-MoreUtils-help-0.428-5.ky10.noarch is already installed.
Package perl-Locale-Codes-3.58-2.ky10.noarch is already installed.
Package perl-Locale-Codes-help-3.58-2.ky10.noarch is already installed.
Package perl-Locale-Maketext-1:1.28-1.ky10.noarch is already installed.
Package perl-Locale-Maketext-help-1:1.28-1.ky10.noarch is already installed.
Package perl-MIME-Base64-3.15-418.ky10.mips64el is already installed.
Package perl-MIME-Base64-help-3.15-418.ky10.noarch is already installed.
Package perl-MRO-Compat-help-0.13-9.ky10.noarch is already installed.
Package perl-Math-BigInt-1:1.9998.13-5.ky10.noarch is already installed.
Package perl-Math-BigInt-FastCalc-0.500.700-4.ky10.mips64el is already installed.
Package perl-Math-BigInt-FastCalc-help-0.500.700-4.ky10.noarch is already installed.
Package perl-Math-BigInt-help-1:1.9998.13-5.ky10.noarch is already installed.
Package perl-Math-BigRat-0.2614-2.ky10.noarch is already installed.
Package perl-Math-BigRat-help-0.2614-2.ky10.noarch is already installed.
Package perl-Module-Build-Tiny-help-0.039-17.ky10.noarch is already installed.
Package perl-Module-Build-help-2:0.42.24-12.ky10.noarch is already installed.
Package perl-Module-CoreList-1:5.20180920-2.ky10.noarch is already installed.
Package perl-Module-CoreList-help-1:5.20180920-2.ky10.noarch is already installed.
Package perl-Module-Install-AuthorRequires-help-0.02-18.ky10.noarch is already installed.
Package perl-Module-Install-AuthorTests-help-0.002-18.ky10.noarch is already installed.
Package perl-Module-Install-ReadmeFromPod-help-0.30-12.ky10.noarch is already installed.
Package perl-Module-Install-ReadmeMarkdownFromPod-help-0.04-10.ky10.noarch is already installed.
Package perl-Module-Install-Repository-help-0.06-23.ky10.noarch is already installed.
Package perl-Module-Load-1:0.32-418.ky10.noarch is already installed.
Package perl-Module-Load-Conditional-0.68-418.ky10.noarch is already installed.
Package perl-Module-Load-Conditional-help-0.68-418.ky10.noarch is already installed.
Package perl-Module-Load-help-1:0.32-418.ky10.noarch is already installed.
Package perl-Module-Manifest-Skip-help-0.23-16.ky10.noarch is already installed.
Package perl-Module-Metadata-1.000036-3.ky10.noarch is already installed.
Package perl-Module-Metadata-help-1.000036-3.ky10.noarch is already installed.
Package perl-Module-Package-Au-help-2-16.ky10.noarch is already installed.
Package perl-Module-Package-help-0.30-22.ky10.noarch is already installed.
Package perl-Module-Runtime-help-0.016-5.ky10.noarch is already installed.
Package perl-Module-ScanDeps-help-1.27-6.p01.ky10.noarch is already installed.
Package perl-Moo-help-2.003004-8.ky10.noarch is already installed.
Package perl-Mozilla-CA-help-1:20180117-6.ky10.noarch is already installed.
Package perl-NTLM-help-1.09-20.ky10.noarch is already installed.
Package perl-Net-Daemon-1:0.48-2.ky10.noarch is already installed.
Package perl-Net-Daemon-help-1:0.48-2.ky10.noarch is already installed.
Package perl-Net-HTTP-help-6.18-4.ky10.noarch is already installed.
Package perl-Net-LibIDN-help-0.12-33.ky10.noarch is already installed.
Package perl-Net-SNMP-help-6.0.1-23.ky10.noarch is already installed.
Package perl-Net-SSLeay-help-1.88-5.ky10.noarch is already installed.
Package perl-NetAddr-IP-help-4.079-10.ky10.mips64el is already installed.
Package perl-Package-Constants-help-1:0.06-1.ky10.noarch is already installed.
Package perl-Package-Generator-help-1.106-14.ky10.noarch is already installed.
Package perl-Params-Check-1:0.38-418.ky10.noarch is already installed.
Package perl-Params-Check-help-1:0.38-418.ky10.noarch is already installed.
Package perl-Params-Util-help-1.07-26.ky10.noarch is already installed.
Package perl-Parse-Yapp-help-1.21-5.ky10.noarch is already installed.
Package perl-Path-Class-help-0.37-14.ky10.noarch is already installed.
Package perl-Path-Tiny-help-0.108-2.ky10.noarch is already installed.
Package perl-PathTools-3.75-4.ky10.mips64el is already installed.
Package perl-PathTools-help-3.75-4.ky10.noarch is already installed.
Package perl-Perl-OSType-1.010-421.ky10.noarch is already installed.
Package perl-Perl-OSType-help-1.010-421.ky10.noarch is already installed.
Package perl-PerlIO-via-QuotedPrint-0.08-397.ky10.noarch is already installed.
Package perl-PerlIO-via-QuotedPrint-help-0.08-397.ky10.noarch is already installed.
Package perl-Pod-Checker-4:1.73-398.ky10.noarch is already installed.
Package perl-Pod-Checker-help-4:1.73-398.ky10.noarch is already installed.
Package perl-Pod-Escapes-1:1.07-419.ky10.noarch is already installed.
Package perl-Pod-Escapes-help-1:1.07-419.ky10.noarch is already installed.
Package perl-Pod-Markdown-help-3.101-2.ky10.noarch is already installed.
Package perl-Pod-Parser-1.63-397.ky10.noarch is already installed.
Package perl-Pod-Parser-help-1.63-397.ky10.noarch is already installed.
Package perl-Pod-Perldoc-1:3.28-3.ky10.noarch is already installed.
Package perl-Pod-Perldoc-help-1:3.28-3.ky10.noarch is already installed.
Package perl-Pod-Simple-1:3.35-418.ky10.noarch is already installed.
Package perl-Pod-Simple-help-1:3.35-418.ky10.noarch is already installed.
Package perl-Pod-Usage-4:1.69-418.ky10.noarch is already installed.
Package perl-Pod-Usage-help-4:1.69-418.ky10.noarch is already installed.
Package perl-Readonly-help-2.05-8.ky10.noarch is already installed.
Package perl-Role-Tiny-help-2.001004-2.ky10.noarch is already installed.
Package perl-SGMLSpm-1.03ii-45.ky10.noarch is already installed.
Package perl-SGMLSpm-help-1.03ii-45.ky10.noarch is already installed.
Package perl-SNMP_Session-help-1.13-20.ky10.noarch is already installed.
Package perl-Scalar-List-Utils-3:1.52-2.ky10.mips64el is already installed.
Package perl-Scalar-List-Utils-help-3:1.52-2.ky10.noarch is already installed.
Package perl-Socket-4:2.029-2.ky10.mips64el is already installed.
Package perl-Socket-MsgHdr-help-0.05-5.ky10.noarch is already installed.
Package perl-Socket-help-4:2.029-2.ky10.noarch is already installed.
Package perl-Socket6-help-0.28-9.ky10.mips64el is already installed.
Package perl-Software-License-help-0.103013-7.ky10.noarch is already installed.
Package perl-Storable-1:3.15-2.ky10.mips64el is already installed.
Package perl-Storable-help-1:3.15-2.ky10.noarch is already installed.
Package perl-String-ShellQuote-help-1.04-26.ky10.noarch is already installed.
Package perl-Sub-Exporter-Progressive-help-0.001013-8.ky10.noarch is already installed.
Package perl-Sub-Exporter-help-0.987-18.ky10.noarch is already installed.
Package perl-Sub-Install-help-0.928-18.ky10.noarch is already installed.
Package perl-Sub-Name-help-0.21-10.ky10.mips64el is already installed.
Package perl-Sub-Quote-help-2.005001-4.ky10.noarch is already installed.
Package perl-Sys-CPU-help-0.61-19.ky10.noarch is already installed.
Package perl-Sys-MemInfo-help-0.99-9.ky10.noarch is already installed.
Package perl-Sys-Syslog-0.35-420.ky10.mips64el is already installed.
Package perl-Sys-Syslog-help-0.35-420.ky10.noarch is already installed.
Package perl-Term-ANSIColor-4.06-511.ky10.noarch is already installed.
Package perl-Term-ANSIColor-help-4.06-511.ky10.noarch is already installed.
Package perl-Term-Cap-1.17-510.ky10.noarch is already installed.
Package perl-Term-Cap-help-1.17-510.ky10.noarch is already installed.
Package perl-TermReadKey-2.38-2.ky10.mips64el is already installed.
Package perl-TermReadKey-help-2.38-2.ky10.noarch is already installed.
Package perl-Test-Deep-help-1.128-4.ky10.noarch is already installed.
Package perl-Test-FailWarnings-help-0.008-15.ky10.noarch is already installed.
Package perl-Test-Fatal-help-0.014-13.ky10.noarch is already installed.
Package perl-Test-Harness-1:3.43_01-3.ky10.noarch is already installed.
Package perl-Test-Harness-help-1:3.43_01-3.ky10.noarch is already installed.
Package perl-Test-InDistDir-help-1.112071-10.ky10.noarch is already installed.
Package perl-Test-LeakTrace-help-0.16-10.ky10.noarch is already installed.
Package perl-Test-NoWarnings-help-1.04-17.ky10.noarch is already installed.
Package perl-Test-Pod-Coverage-help-1.10-14.ky10.noarch is already installed.
Package perl-Test-Pod-help-1.52-4.ky10.noarch is already installed.
Package perl-Test-Requires-help-0.10-15.ky10.noarch is already installed.
Package perl-Test-Simple-2:1.302140-3.ky10.noarch is already installed.
Package perl-Test-Simple-help-2:1.302140-3.ky10.noarch is already installed.
Package perl-Text-Balanced-2.03-420.ky10.noarch is already installed.
Package perl-Text-Balanced-help-2.03-420.ky10.noarch is already installed.
Package perl-Text-Diff-1.45-7.ky10.noarch is already installed.
Package perl-Text-Diff-help-1.45-7.ky10.noarch is already installed.
Package perl-Text-Glob-help-0.11-7.ky10.noarch is already installed.
Package perl-Text-ParseWords-3.30-419.ky10.noarch is already installed.
Package perl-Text-ParseWords-help-3.30-419.ky10.noarch is already installed.
Package perl-Text-Tabs+Wrap-2013.0523-419.ky10.noarch is already installed.
Package perl-Text-Tabs+Wrap-help-2013.0523-419.ky10.noarch is already installed.
Package perl-Text-Template-help-1.53-4.ky10.noarch is already installed.
Package perl-Text-WrapI18N-help-0.06-33.ky10.noarch is already installed.
Package perl-Thread-Queue-3.13-3.ky10.noarch is already installed.
Package perl-Thread-Queue-help-3.13-3.ky10.noarch is already installed.
Package perl-Time-HiRes-1.9760-2.ky10.mips64el is already installed.
Package perl-Time-HiRes-help-1.9760-2.ky10.noarch is already installed.
Package perl-Time-Local-2:1.280-6.ky10.noarch is already installed.
Package perl-Time-Local-help-2:1.280-6.ky10.noarch is already installed.
Package perl-TimeDate-help-1:2.30-17.ky10.noarch is already installed.
Package perl-Types-Serialiser-help-1.0-18.ky10.noarch is already installed.
Package perl-URI-help-1.76-3.ky10.noarch is already installed.
Package perl-Unicode-Collate-1.25-4.ky10.mips64el is already installed.
Package perl-Unicode-Collate-help-1.25-4.ky10.noarch is already installed.
Package perl-Unicode-Normalize-1.26-419.ky10.mips64el is already installed.
Package perl-Unicode-Normalize-help-1.26-419.ky10.noarch is already installed.
Package perl-Unicode-UTF8-help-0.62-8.ky10.noarch is already installed.
Package perl-XML-LibXML-help-1:2.0132-5.ky10.mips64el is already installed.
Package perl-XML-NamespaceSupport-help-1.12-7.ky10.noarch is already installed.
Package perl-XML-Parser-1:2.44-3.ky10.mips64el is already installed.
Package perl-XML-Parser-help-1:2.44-3.ky10.noarch is already installed.
Package perl-XML-SAX-Base-help-1.09-7.ky10.noarch is already installed.
Package perl-XML-SAX-help-1.00-5.ky10.noarch is already installed.
Package perl-XML-Writer-help-0.625-14.ky10.noarch is already installed.
Package perl-XML-XPath-help-1.42-6.ky10.noarch is already installed.
Package perl-YAML-Tiny-help-1.73-4.ky10.noarch is already installed.
Package perl-YAML-help-1.26-5.ky10.noarch is already installed.
Package perl-autodie-2.29-398.ky10.noarch is already installed.
Package perl-autodie-help-2.29-398.ky10.noarch is already installed.
Package perl-bignum-0.50-4.ky10.noarch is already installed.
Package perl-bignum-help-0.50-4.ky10.noarch is already installed.
Package perl-common-sense-help-3.7.4-14.ky10.noarch is already installed.
Package perl-constant-1.33-421.ky10.noarch is already installed.
Package perl-constant-help-1.33-421.ky10.noarch is already installed.
Package perl-devel-4:5.28.0-434.ky10.mips64el is already installed.
Package perl-experimental-0.020-2.ky10.noarch is already installed.
Package perl-experimental-help-0.020-2.ky10.noarch is already installed.
Package perl-gettext-help-1.07-13.ky10.noarch is already installed.
Package perl-inc-latest-help-2:0.500-12.ky10.noarch is already installed.
Package perl-libintl-perl-help-1.29-6.ky10.noarch is already installed.
Package perl-libnet-3.11-420.ky10.noarch is already installed.
Package perl-libnet-help-3.11-420.ky10.noarch is already installed.
Package perl-libs-4:5.28.0-434.ky10.mips64el is already installed.
Package perl-libwww-perl-help-6.35-2.ky10.noarch is already installed.
Package perl-libxml-perl-help-0.08-36.ky10.noarch is already installed.
Package perl-parent-1:0.237-4.ky10.noarch is already installed.
Package perl-parent-help-1:0.237-4.ky10.noarch is already installed.
Package perl-perlfaq-5.20180915-5.ky10.noarch is already installed.
Package perl-perlfaq-help-5.20180915-5.ky10.noarch is already installed.
Package perl-podlators-1:4.11-5.ky10.noarch is already installed.
Package perl-podlators-help-1:4.11-5.ky10.noarch is already installed.
Package perl-strictures-help-2.000006-7.ky10.noarch is already installed.
Package perl-threads-1:2.22-419.ky10.mips64el is already installed.
Package perl-threads-help-1:2.22-419.ky10.noarch is already installed.
Package perl-threads-shared-1.59-2.ky10.mips64el is already installed.
Package perl-threads-shared-help-1.59-2.ky10.noarch is already installed.
Package perl-version-8:0.99.24-3.ky10.mips64el is already installed.
Package perl-version-help-8:0.99.24-3.ky10.noarch is already installed.
Package make-1:4.2.1-15.ky10.mips64el is already installed.

创建mysql用户与用户组

[root@localhost /]# groupadd mysql
groupadd:“mysql”组已存在
[root@localhost /]# id mysql
用户id=27(mysql) 组id=27(mysql) 组=27(mysql)

解压MySQL源码包

[root@localhost soft]# tar -zxvf  mysql-boost-5.7.39.tar.gz
[root@localhost soft]# ls -lrt
总用量 3643996
drwxr-xr-x 34 7161 31415       4096  6月  8 16:48 mysql-5.7.39
-rw-------  1 root root    53243335 11月 15 22:24 mysql-boost-5.7.39.tar.gz

[root@localhost /]# mv mysql-5.7.39 mysql5_7

[root@localhost /]# cd mysql5_7/
[root@localhost mysql5_7]# ls -lrt
总用量 560
-rw-r--r--  1 7161 31415     88  6月  8 16:37 VERSION
-rw-r--r--  1 7161 31415    566  6月  8 16:37 README
-rw-r--r--  1 7161 31415 255074  6月  8 16:37 LICENSE
-rw-r--r--  1 7161 31415    333  6月  8 16:37 INSTALL
-rw-r--r--  1 7161 31415  67369  6月  8 16:37 Doxyfile-perfschema
-rw-r--r--  1 7161 31415  25144  6月  8 16:37 configure.cmake
-rw-r--r--  1 7161 31415  14554  6月  8 16:37 config.h.cmake
-rw-r--r--  1 7161 31415  29939  6月  8 16:37 CMakeLists.txt
drwxr-xr-x  2 7161 31415   4096  6月  8 16:47 source_downloads
drwxr-xr-x  2 7161 31415   4096  6月  8 16:47 libservices
drwxr-xr-x  3 7161 31415   4096  6月  8 16:47 libmysqld
drwxr-xr-x  4 7161 31415   4096  6月  8 16:47 libmysql
drwxr-xr-x  3 7161 31415   4096  6月  8 16:47 libbinlogstandalone
drwxr-xr-x  5 7161 31415   4096  6月  8 16:47 libbinlogevents
drwxr-xr-x  5 7161 31415   4096  6月  8 16:47 include
drwxr-xr-x  8 7161 31415   4096  6月  8 16:47 extra
drwxr-xr-x  2 7161 31415   4096  6月  8 16:47 Docs
drwxr-xr-x  2 7161 31415   4096  6月  8 16:47 dbug
drwxr-xr-x  4 7161 31415   4096  6月  8 16:47 cmake
drwxr-xr-x  6 7161 31415   4096  6月  8 16:47 client
drwxr-xr-x  2 7161 31415   4096  6月  8 16:47 BUILD
drwxr-xr-x  2 7161 31415   4096  6月  8 16:47 sql-common
drwxr-xr-x  2 7161 31415   4096  6月  8 16:47 regex
drwxr-xr-x  4 7161 31415   4096  6月  8 16:47 rapid
drwxr-xr-x 18 7161 31415   4096  6月  8 16:47 plugin
drwxr-xr-x 10 7161 31415   4096  6月  8 16:47 packaging
drwxr-xr-x  2 7161 31415   4096  6月  8 16:47 mysys_ssl
drwxr-xr-x  2 7161 31415   4096  6月  8 16:47 mysys
drwxr-xr-x 10 7161 31415   4096  6月  8 16:47 mysql-test
drwxr-xr-x  2 7161 31415   4096  6月  8 16:47 testclients
drwxr-xr-x  4 7161 31415   4096  6月  8 16:47 support-files
drwxr-xr-x  2 7161 31415   4096  6月  8 16:47 strings
drwxr-xr-x  2 7161 31415   4096  6月  8 16:47 win
drwxr-xr-x  3 7161 31415   4096  6月  8 16:47 vio
drwxr-xr-x  5 7161 31415   4096  6月  8 16:47 unittest
drwxr-xr-x  8 7161 31415  28672  6月  8 16:47 sql
drwxr-xr-x  4 7161 31415   4096  6月  8 16:47 scripts
drwxr-xr-x 13 7161 31415   4096  6月  8 16:48 storage
drwxr-xr-x  2 7161 31415   4096  6月  8 16:48 man
drwxr-xr-x  3 7161 31415   4096  6月  8 16:48 boost

创建编译目录

[root@localhost mysql5_7]# mkdir bld
[root@localhost mysql5_7]# cd bld
[root@localhost bld]# pwd
/mysql5_7/bld
[root@localhost bld]# cd /
[root@localhost /]# ls -lrt
总用量 52088
drwxr-xr-x    2 root  root      4096  3月 27  2020 srv
lrwxrwxrwx    1 root  root         8  3月 27  2020 sbin -> usr/sbin
drwxr-xr-x    2 root  root      4096  3月 27  2020 media
lrwxrwxrwx    1 root  root         9  3月 27  2020 lib64 -> usr/lib64
lrwxrwxrwx    1 root  root         7  3月 27  2020 lib -> usr/lib
lrwxrwxrwx    1 root  root         7  3月 27  2020 bin -> usr/bin
drwx------.   2 root  root     16384 11月 15 12:13 lost+found
drwxr-xr-x   12 root  root      4096 11月 15 12:21 usr
drwxrwxrwx    2 root  root      4096 11月 15 12:28 box
drwx--x--x    3 root  root      4096 11月 15 12:32 sudo
dr-xr-xr-x.   6 root  root      4096 11月 15 12:33 boot
drwxr-xr-x   24 root  root      4096 11月 15 12:42 var
drwxr-xr-x    7 root  root      4096 11月 15 12:42 opt
dr-xr-xr-x  233 root  root         0 11月 15 19:09 proc
drwxr-xr-x.   4 root  root      4096 11月 15 21:09 backup
dr-xr-xr-x   13 root  root         0 11月 15 22:35 sys
drwxr-xr-x    3 root  root      4096 11月 15 22:55 mnt
drwxr-xr-x   17 root  root      5080 11月 15 22:55 dev
drwxrwxr-x    3 mysql mysql     4096 11月 15 23:37 mysqlsoft
drwx------    5 root  root      4096 11月 18 19:40 soft
drwxr-xr-x    3 root  root      4096 11月 18 21:06 home
drwxr-xr-x   45 root  root      1360 11月 18 21:06 run
drwxrwxr-x    5 mysql mysql     4096 11月 18 21:24 mysqldata
drwxr-xr-x  157 root  root     12288 11月 18 21:31 etc
dr-xr-x---   17 root  root      4096 11月 18 21:58 root
-rw-------    1 root  root  53243335 11月 18 22:24 mysql-boost-5.7.39.tar.gz
drwxrwxrwt   14 root  root       320 11月 18 22:26 tmp
drwxr-xr-x   35  7161 31415     4096 11月 18 22:26 mysql5_7

创建MySQL安装目录

[root@localhost /]# mkdir -p mysql57soft/msyql
[root@localhost /]# mkdir -p msyql57data/mysql
[root@localhost /]# chown -R mysql:mysql mysql57*
[root@localhost /]# ls -lrt
总用量 52096
drwxr-xr-x    2 root  root      4096  3月 27  2020 srv
lrwxrwxrwx    1 root  root         8  3月 27  2020 sbin -> usr/sbin
drwxr-xr-x    2 root  root      4096  3月 27  2020 media
lrwxrwxrwx    1 root  root         9  3月 27  2020 lib64 -> usr/lib64
lrwxrwxrwx    1 root  root         7  3月 27  2020 lib -> usr/lib
lrwxrwxrwx    1 root  root         7  3月 27  2020 bin -> usr/bin
drwx------.   2 root  root     16384 11月 15 12:13 lost+found
drwxr-xr-x   12 root  root      4096 11月 15 12:21 usr
drwxrwxrwx    2 root  root      4096 11月 15 12:28 box
drwx--x--x    3 root  root      4096 11月 15 12:32 sudo
dr-xr-xr-x.   6 root  root      4096 11月 15 12:33 boot
drwxr-xr-x   24 root  root      4096 11月 15 12:42 var
drwxr-xr-x    7 root  root      4096 11月 15 12:42 opt
dr-xr-xr-x  235 root  root         0 11月 15 19:09 proc
drwxr-xr-x.   4 root  root      4096 11月 15 21:09 backup
dr-xr-xr-x   13 root  root         0 11月 15 22:35 sys
drwxr-xr-x    3 root  root      4096 11月 15 22:55 mnt
drwxr-xr-x   17 root  root      5080 11月 15 22:55 dev
drwxrwxr-x    3 mysql mysql     4096 11月 15 23:37 mysqlsoft
drwx------    5 root  root      4096 11月 18 19:40 soft
drwxr-xr-x    3 root  root      4096 11月 18 21:06 home
drwxr-xr-x   45 root  root      1360 11月 18 21:06 run
drwxrwxr-x    5 mysql mysql     4096 11月 18 21:24 mysqldata
drwxr-xr-x  157 root  root     12288 11月 18 21:31 etc
dr-xr-x---   17 root  root      4096 11月 18 21:58 root
-rw-------    1 root  root  53243335 11月 18 22:24 mysql-boost-5.7.39.tar.gz
drwxrwxrwt   14 root  root       320 11月 18 22:26 tmp
drwxr-xr-x   35  7161 31415     4096 11月 18 22:26 mysql5_7
drwx------    3 mysql mysql     4096 11月 18 22:30 mysql57soft
drwx------    3 root  root      4096 11月 18 22:30 msyql57data

[root@localhost /]# cd mysql5_7/
[root@localhost mysql5_7]# ls -lrt
总用量 564
-rw-r--r--  1 7161 31415     88  6月  8 16:37 VERSION
-rw-r--r--  1 7161 31415    566  6月  8 16:37 README
-rw-r--r--  1 7161 31415 255074  6月  8 16:37 LICENSE
-rw-r--r--  1 7161 31415    333  6月  8 16:37 INSTALL
-rw-r--r--  1 7161 31415  67369  6月  8 16:37 Doxyfile-perfschema
-rw-r--r--  1 7161 31415  25144  6月  8 16:37 configure.cmake
-rw-r--r--  1 7161 31415  14554  6月  8 16:37 config.h.cmake
-rw-r--r--  1 7161 31415  29939  6月  8 16:37 CMakeLists.txt
drwxr-xr-x  2 7161 31415   4096  6月  8 16:47 source_downloads
drwxr-xr-x  2 7161 31415   4096  6月  8 16:47 libservices
drwxr-xr-x  3 7161 31415   4096  6月  8 16:47 libmysqld
drwxr-xr-x  4 7161 31415   4096  6月  8 16:47 libmysql
drwxr-xr-x  3 7161 31415   4096  6月  8 16:47 libbinlogstandalone
drwxr-xr-x  5 7161 31415   4096  6月  8 16:47 libbinlogevents
drwxr-xr-x  5 7161 31415   4096  6月  8 16:47 include
drwxr-xr-x  8 7161 31415   4096  6月  8 16:47 extra
drwxr-xr-x  2 7161 31415   4096  6月  8 16:47 Docs
drwxr-xr-x  2 7161 31415   4096  6月  8 16:47 dbug
drwxr-xr-x  4 7161 31415   4096  6月  8 16:47 cmake
drwxr-xr-x  6 7161 31415   4096  6月  8 16:47 client
drwxr-xr-x  2 7161 31415   4096  6月  8 16:47 BUILD
drwxr-xr-x  2 7161 31415   4096  6月  8 16:47 sql-common
drwxr-xr-x  2 7161 31415   4096  6月  8 16:47 regex
drwxr-xr-x  4 7161 31415   4096  6月  8 16:47 rapid
drwxr-xr-x 18 7161 31415   4096  6月  8 16:47 plugin
drwxr-xr-x 10 7161 31415   4096  6月  8 16:47 packaging
drwxr-xr-x  2 7161 31415   4096  6月  8 16:47 mysys_ssl
drwxr-xr-x  2 7161 31415   4096  6月  8 16:47 mysys
drwxr-xr-x 10 7161 31415   4096  6月  8 16:47 mysql-test
drwxr-xr-x  2 7161 31415   4096  6月  8 16:47 testclients
drwxr-xr-x  4 7161 31415   4096  6月  8 16:47 support-files
drwxr-xr-x  2 7161 31415   4096  6月  8 16:47 strings
drwxr-xr-x  2 7161 31415   4096  6月  8 16:47 win
drwxr-xr-x  3 7161 31415   4096  6月  8 16:47 vio
drwxr-xr-x  5 7161 31415   4096  6月  8 16:47 unittest
drwxr-xr-x  8 7161 31415  28672  6月  8 16:47 sql
drwxr-xr-x  4 7161 31415   4096  6月  8 16:47 scripts
drwxr-xr-x 13 7161 31415   4096  6月  8 16:48 storage
drwxr-xr-x  2 7161 31415   4096  6月  8 16:48 man
drwxr-xr-x  3 7161 31415   4096  6月  8 16:48 boost
drwx------  2 root root    4096 11月 18 22:26 bld
[root@localhost mysql5_7]# cd bld
[root@localhost bld]# ls -lrt
总用量 0
[root@localhost bld]# pwd
/mysql5_7/bld

编译安装
预编译

cmake .. -DCMAKE_INSTALL_PREFIX=/mysql57soft/mysql  -DMYSQL_DATADIR=/mysql57data/mysql  -DSYSCONFDIR=/mysql57soft/mysql/mysql.sock  -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/mysql5_7/boost/boost_1_59_0 -DWITH_INNOBASE_STORAGE_ENGINE=1  -DWITH_PARTITION_STORAGE_ENGINE=1  -DWITH_FEDERATED_STORAGE_ENGINE=1  -DWITH_BLACKHOLE_STORAGE_ENGINE=1  -DWITH_MYISAM_STORAGE_ENGINE=1  -DENABLED_LOCAL_INFILE=1  -DENABLE_DTRACE=0  -DDEFAULT_CHARSET=utf8mb4  -DDEFAULT_COLLATION=utf8mb4_general_ci  -DWITH_EMBEDDED_SERVER=1

编译打包

cmake --build . --config relwithdebinfo --target package

[ 96%] Building CXX object sql/CMakeFiles/sql.dir/mf_iocache.cc.o
[ 96%] Building CXX object sql/CMakeFiles/sql.dir/mysqld.cc.o
[ 96%] Building CXX object sql/CMakeFiles/sql.dir/mysqld_thd_manager.cc.o
[ 96%] Building CXX object sql/CMakeFiles/sql.dir/protocol_callback.cc.o
[ 96%] Built target mysqlserver
[ 96%] Building CXX object sql/CMakeFiles/sql.dir/signal_handler.cc.o
Scanning dependencies of target mysqltest_embedded
[ 96%] Building CXX object libmysqld/examples/CMakeFiles/mysqltest_embedded.dir/__/__/client/mysqltest.cc.o
[ 96%] Building CXX object sql/CMakeFiles/sql.dir/sql_audit.cc.o
[ 96%] Building CXX object sql/CMakeFiles/sql.dir/sql_client.cc.o
Scanning dependencies of target mysql_embedded
[ 96%] Building CXX object libmysqld/examples/CMakeFiles/mysql_embedded.dir/__/__/client/completion_hash.cc.o
[ 96%] Building CXX object libmysqld/examples/CMakeFiles/mysql_embedded.dir/__/__/client/mysql.cc.o
[ 96%] Linking CXX executable mysqltest_embedded
[ 96%] Building CXX object libmysqld/examples/CMakeFiles/mysql_embedded.dir/__/__/client/readline.cc.o
[ 96%] Linking CXX executable mysql_embedded
[ 96%] Built target mysqltest_embedded
Scanning dependencies of target mysql_client_test_embedded
[ 96%] Building C object libmysqld/examples/CMakeFiles/mysql_client_test_embedded.dir/__/__/testclients/mysql_client_test.c.o
[ 96%] Built target mysql_embedded
[ 96%] Building CXX object sql/CMakeFiles/sql.dir/srv_session.cc.o
[ 96%] Building CXX object sql/CMakeFiles/sql.dir/srv_session_service.cc.o
[ 96%] Building CXX object sql/CMakeFiles/sql.dir/srv_session_info_service.cc.o
[ 96%] Building CXX object sql/CMakeFiles/sql.dir/auth/sha2_password_common.cc.o
[ 97%] Building CXX object sql/CMakeFiles/sql.dir/mysqld_daemon.cc.o
[ 97%] Linking CXX static library ../archive_output_directory/libsql.a
[ 97%] Built target sql
Scanning dependencies of target mysqld
Scanning dependencies of target pfs_connect_attr-t
[ 97%] Building CXX object sql/CMakeFiles/mysqld.dir/main.cc.o
[ 97%] Building CXX object storage/perfschema/unittest/CMakeFiles/pfs_connect_attr-t.dir/__/__/__/sql/sql_builtin.cc.o
[ 97%] Linking CXX executable mysqld
[ 97%] Building CXX object storage/perfschema/unittest/CMakeFiles/pfs_connect_attr-t.dir/pfs_connect_attr-t.cc.o
[ 98%] Building C object storage/perfschema/unittest/CMakeFiles/pfs_connect_attr-t.dir/__/__/__/mysys/string.c.o
[ 98%] Linking CXX executable pfs_connect_attr-t
[100%] Linking CXX executable mysql_client_test_embedded
[100%] Built target mysqld
[100%] Built target pfs_connect_attr-t
[100%] Built target mysql_client_test_embedded
Run CPack packaging tool...
CPack: Create package using TGZ
CPack: Install projects
CPack: - Run preinstall target for: MySQL
CPack: - Install project: MySQL
CPack: Create package
CPack: - package: /mysql5_7/bld/mysql-5.7.39-linux-mips64el.tar.gz generated.

使用编译的软件包安装MySQL

[root@localhost/] tar -zxvf  /mysql5_7/bld/mysql-5.7.39-linux-mips64el.tar.gz
[root@localhost/] chown -R mysql:mysql mysql_5_7_39
[msyql@localhost/]cd mysql_5_7_39

配置mysql参数,只是设置几个简单的mysql运行参数

[mysql@localhost mysql_5_7_39]$ vi my.cnf
[mysqld]
basedir=/mysql57soft/mysql
datadir=/mysql57data/mysql
bind-address=0.0.0.0
user=mysql
port=3307
log-error=/mysql57data/mysql/mysql.err
pid-file=/mysql57data/mysql/mysqld.pid
socket = /mysql_5_7_39/mysql.sock
character-set-server=utf8mb4
default-storage-engine=INNODB
explicit_defaults_for_timestamp = true
########innodb settings########
innodb_page_size = 8192
innodb_buffer_pool_size = 2G
innodb_buffer_pool_instances = 1
innodb_buffer_pool_load_at_startup = 1
innodb_buffer_pool_dump_at_shutdown = 1
innodb_lru_scan_depth = 2000
innodb_lock_wait_timeout = 5
innodb_io_capacity = 4000
innodb_io_capacity_max = 8000
innodb_flush_method = O_DIRECT
innodb_file_format = Barracuda
innodb_file_format_max = Barracuda
innodb_log_group_home_dir =/mysql57data/redolog/
innodb_undo_directory =/mysql57data/undolog/
innodb_undo_logs = 128
innodb_undo_tablespaces = 3
innodb_flush_nei***ors = 1
innodb_log_file_size = 1G
innodb_log_buffer_size = 16777216
innodb_purge_threads = 4
innodb_large_prefix = 1
innodb_thread_concurrency = 64
innodb_print_all_deadlocks = 1
innodb_strict_mode = 1
innodb_sort_buffer_size = 67108864

[client]
port=3307
socket = /mysql_5_7_39/mysql.sock

[root@localhost bin]# ./mysqld  --defaults-file=/mysql_5_7_39/my.cnf --initialize --basedir=/mysql_5_7_39 --datadir=/mysql57data/mysql --user=mysql

[mysql@localhost mysql]$ tail -f mysql.err
 100 200 300 400 500 600 700 800 900 1000
 100 200 300 400 500 600 700 800 900 1000
2022-11-18T16:11:40.704291Z 0 [Warning] InnoDB: New log files created, LSN=39537
2022-11-18T16:11:40.837945Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2022-11-18T16:11:40.903126Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: afe493ab-675b-11ed-8fe7-0023a0002161.
2022-11-18T16:11:40.905754Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2022-11-18T16:11:41.512271Z 0 [Warning] A deprecated TLS version TLSv1 is enabled. Please use TLSv1.2 or higher.
2022-11-18T16:11:41.512309Z 0 [Warning] A deprecated TLS version TLSv1.1 is enabled. Please use TLSv1.2 or higher.
2022-11-18T16:11:41.513362Z 0 [Warning] CA certificate ca.pem is self signed.
2022-11-18T16:11:41.752239Z 1 [Note] A temporary password is generated for root@localhost: g)Pnh/m(24IZ

其中[Note] A temporary password is generated for root@localhost:后面跟的是mysql数据库登录的临时密码,各人安装生成的临时密码不一样。可以看到到日志文件没有报错,而且有了临时密码,表示初始化成功。

如果想服务能够部署自动支持安全连接,使用mysql_ssl_rsa_setup工具来创建缺省SSL与RSA文件

[root@localhost bin]# ./mysql_ssl_rsa_setup --datadir=/mysql57data/mysql

[root@localhost bin]# mysqld_safe --defaults-file=/mysql_5_7_39/my.cnf --user=mysql &
[2] 98394
[root@localhost bin]# 2022-11-18T16:23:50.107056Z mysqld_safe Logging to '/mysql57data/mysql/mysql.err'.
2022-11-18T16:23:50.154854Z mysqld_safe Starting mysqld daemon with databases from /mysql57data/mysql

[root@localhost bin]# netstat -ltnp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:3306            0.0.0.0:*               LISTEN      98228/mysqld
tcp        0      0 0.0.0.0:3307            0.0.0.0:*               LISTEN      98924/mysqld
tcp        0      0 0.0.0.0:111             0.0.0.0:*               LISTEN      3919/rpcbind
tcp        0      0 192.168.122.1:53        0.0.0.0:*               LISTEN      4934/dnsmasq
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      4530/sshd: /usr/sbi
tcp        0      0 127.0.0.1:631           0.0.0.0:*               LISTEN      4521/cupsd
tcp6       0      0 :::111                  :::*                    LISTEN      3919/rpcbind
tcp6       0      0 :::22                   :::*                    LISTEN      4530/sshd: /usr/sbi
tcp6       0      0 ::1:631                 :::*                    LISTEN      4521/cupsd

配置环境变量

[root@localhost /]# vi /etc/profile
export MYSQL_HOME=/mysql57soft/mysql/
export PATH=$PATH:$MYSQL_HOME/bin

[root@localhost /]# vi /etc/profile
[root@localhost /]# source /etc/profile

配置自动启动MySQL

[root@localhost /]# cp /mysql57soft/mysql/support-files/mysql.server  /etc/init.d/mysqld
[root@localhost /]# chmod 755 /etc/init.d/mysqld
[root@localhost ~]# systemctl enable mysqld
mysqld.service is not a native service, redirecting to /sbin/chkconfig.
Executing /sbin/chkconfig mysqld on

启动MySQL

[root@localhost /]# service mysqld start
Starting MySQL... SUCCESS!

登录MySQL

[root@localhost tmp]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.39

Copyright (c) 2000, 2022, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>
]]>
http://www.jydba.net/index.php/archives/3448/feed 0
龙芯源码编译MySQL http://www.jydba.net/index.php/archives/3443 http://www.jydba.net/index.php/archives/3443#respond Wed, 21 Dec 2022 00:25:33 +0000 http://www.jydba.net/?p=3443 在龙芯+麒麟操作系统环境使用源码编译MySQL5.7.39,其操作步骤如下:
查看是否已安装mariadb,若是已安装,需要卸载

[root@localhost yum.repos.d]# rpm -qa|grep mariadb
mariadb-10.3.9-8.p01.ky10.mips64el
mariadb-common-10.3.9-8.p01.ky10.mips64el
mariadb-errmessage-10.3.9-8.p01.ky10.mips64el
mariadb-connector-c-3.0.6-6.ky10.mips64el
mariadb-server-10.3.9-8.p01.ky10.mips64el

要是有,卸载:# yum remove mariadb

[root@localhost yum.repos.d]# yum remove mariadb
Warning: failed loading '/etc/yum.repos.d/kylin.repo', skipping.
Dependencies resolved.
=================================================================================================================================================================================================
 Package                                         Architecture                              Version                                              Repository                                  Size
=================================================================================================================================================================================================
Removing:
 mariadb                                         mips64el                                  3:10.3.9-8.p01.ky10                                  @anaconda                                   38 M
Removing dependent packages:
 mariadb-server                                  mips64el                                  3:10.3.9-8.p01.ky10                                  @anaconda                                   92 M
Removing unused dependencies:
 perl-DBD-MySQL                                  mips64el                                  4.046-6.ky10                                         @anaconda                                  327 k

Transaction Summary
=================================================================================================================================================================================================
Remove  3 Packages

Freed space: 129 M
Is this ok [y/N]: y
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                                                                         1/1
  Running scriptlet: mariadb-3:10.3.9-8.p01.ky10.mips64el                                                                                                                                    1/1
  Erasing          : mariadb-3:10.3.9-8.p01.ky10.mips64el                                                                                                                                    1/3
  Running scriptlet: mariadb-server-3:10.3.9-8.p01.ky10.mips64el                                                                                                                             2/3
  Erasing          : mariadb-server-3:10.3.9-8.p01.ky10.mips64el                                                                                                                             2/3
  Running scriptlet: mariadb-server-3:10.3.9-8.p01.ky10.mips64el                                                                                                                             2/3
  Erasing          : perl-DBD-MySQL-4.046-6.ky10.mips64el                                                                                                                                    3/3
  Running scriptlet: perl-DBD-MySQL-4.046-6.ky10.mips64el                                                                                                                                    3/3
  Verifying        : mariadb-3:10.3.9-8.p01.ky10.mips64el                                                                                                                                    1/3
  Verifying        : mariadb-server-3:10.3.9-8.p01.ky10.mips64el                                                                                                                             2/3
  Verifying        : perl-DBD-MySQL-4.046-6.ky10.mips64el                                                                                                                                    3/3

Removed:
  mariadb-3:10.3.9-8.p01.ky10.mips64el                         mariadb-server-3:10.3.9-8.p01.ky10.mips64el                         perl-DBD-MySQL-4.046-6.ky10.mips64el

Complete!

[root@localhost soft]# mkdir /mnt/cdrom
[root@localhost soft]# mount -o loop -t iso9660 Kylin-Server-10-SP1-Release-Build18-20210809-mips64el.iso /mnt/cdrom
mount: /mnt/cdrom: WARNING: source write-protected, mounted read-only.
[root@localhost soft]# cd /mnt/cdrom
[root@localhost cdrom]# ls
boot  boot.catalog  EFI  images  LICENSE  manual  Packages  repodata  TRANS.TBL

[root@localhost yum.repos.d]# cat kylin.repo
[ks10-local-iso]
name = Kylin Linux Advanced Server 10 - local
baseurl = file:///mnt/cdrom/
gpgcheck = 1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-kylin
enabled = 1

(2)下载源码包并解压

# wget https://cdn.mysql.com/archives/mysql-5.7/mysql-5.7.29.tar.gz
# tar -zxvf mysql-5.7.29.tar.gz

(3)yum安装编译所需要的工具和库

# yum install gcc gcc-c++ cmake ncurses-devel bison openssl-devel rpcgen

上面的软件要一个一个安装,一起可能有问题

[root@localhost yum.repos.d]# yum -y install gcc* gcc-c++ ncurses* ncurses-devel* cmake* bison* libgcrypt* perl* make* openssl-devel* rpcgen*
Last metadata expiration check: 0:01:56 ago on 2022年11月15日 星期二 23时22分05秒.
Package gcc-8.3.1-4.5.p03.ky10.mips64el is already installed.
Package ncurses-6.1-14.ky10.mips64el is already installed.
Package ncurses-base-6.1-14.ky10.noarch is already installed.
Package ncurses-libs-6.1-14.ky10.mips64el is already installed.
Package cmake-3.12.1-5.ky10.mips64el is already installed.
Package cmake-data-3.12.1-5.ky10.noarch is already installed.
Package cmake-filesystem-3.12.1-5.ky10.mips64el is already installed.
Package cmake-help-3.12.1-5.ky10.noarch is already installed.
Package cmake-rpm-macros-3.12.1-5.ky10.noarch is already installed.
Package libgcrypt-1.8.3-5.ky10.mips64el is already installed.
Package perl-4:5.28.0-434.ky10.mips64el is already installed.
Package perl-Algorithm-Diff-1.1903-14.ky10.noarch is already installed.
Package perl-Algorithm-Diff-help-1.1903-14.ky10.noarch is already installed.
Package perl-Archive-Tar-2.30-421.ky10.noarch is already installed.
Package perl-Authen-SASL-help-2.16-16.ky10.noarch is already installed.
Package perl-B-Debug-1.26-4.ky10.noarch is already installed.
Package perl-B-Debug-help-1.26-4.ky10.noarch is already installed.
Package perl-Business-ISBN-Data-help-20191107-2.ky10.noarch is already installed.
Package perl-Business-ISBN-help-3.005-1.ky10.noarch is already installed.
Package perl-CGI-help-4.46-1.ky10.noarch is already installed.
Package perl-CPAN-Meta-2.150010-419.ky10.noarch is already installed.
Package perl-CPAN-Meta-Requirements-2.140-419.ky10.noarch is already installed.
Package perl-CPAN-Meta-Requirements-help-2.140-419.ky10.noarch is already installed.
Package perl-CPAN-Meta-YAML-0.018-420.ky10.noarch is already installed.
Package perl-CPAN-Meta-YAML-help-0.018-420.ky10.noarch is already installed.
Package perl-CPAN-Meta-help-2.150010-419.ky10.noarch is already installed.
Package perl-Capture-Tiny-help-0.48-4.ky10.noarch is already installed.
Package perl-Carp-1.50-418.ky10.noarch is already installed.
Package perl-Carp-help-1.50-418.ky10.noarch is already installed.
Package perl-Class-Inspector-help-1.32-5.ky10.noarch is already installed.
Package perl-Class-Method-Modifiers-help-2.12-12.ky10.noarch is already installed.
Package perl-Class-XSAccessor-help-1.19-18.ky10.noarch is already installed.
Package perl-Compress-Bzip2-help-2.26-10.ky10.noarch is already installed.
Package perl-Compress-Raw-Bzip2-2.081-8.ky10.mips64el is already installed.
Package perl-Compress-Raw-Bzip2-help-2.081-8.ky10.noarch is already installed.
Package perl-Compress-Raw-Zlib-2.081-6.ky10.mips64el is already installed.
Package perl-Compress-Raw-Zlib-help-2.081-6.ky10.noarch is already installed.
Package perl-Config-General-help-2.63-1.ky10.noarch is already installed.
Package perl-Config-Perl-V-0.30-5.ky10.noarch is already installed.
Package perl-Config-Perl-V-help-0.30-5.ky10.noarch is already installed.
Package perl-Crypt-OpenSSL-Random-help-0.15-4.ky10.noarch is already installed.
Package perl-Crypt-PasswdMD5-help-1.4.0-14.ky10.noarch is already installed.
Package perl-DBD-MySQL-help-4.046-6.ky10.mips64el is already installed.
Package perl-DBD-SQLite-1.58-4.ky10.mips64el is already installed.
Package perl-DBD-SQLite-help-1.58-4.ky10.mips64el is already installed.
Package perl-DBI-1.642-2.ky10.mips64el is already installed.
Package perl-DBI-help-1.642-2.ky10.noarch is already installed.
Package perl-DB_File-1.842-2.ky10.mips64el is already installed.
Package perl-DB_File-help-1.842-2.ky10.noarch is already installed.
Package perl-Data-Dumper-2.172-3.ky10.mips64el is already installed.
Package perl-Data-Dumper-help-2.172-3.ky10.noarch is already installed.
Package perl-Data-Section-help-0.200007-6.ky10.noarch is already installed.
Package perl-Date-Calc-help-6.4-12.ky10.noarch is already installed.
Package perl-Devel-CheckLib-help-1.13-5.ky10.noarch is already installed.
Package perl-Devel-GlobalDestruction-help-0.14-8.ky10.noarch is already installed.
Package perl-Devel-PPPort-3.42-4.ky10.mips64el is already installed.
Package perl-Devel-PPPort-help-3.42-4.ky10.noarch is already installed.
Package perl-Devel-Size-help-0.82-4.ky10.noarch is already installed.
Package perl-Digest-1.17-419.ky10.noarch is already installed.
Package perl-Digest-MD5-2.55-419.ky10.mips64el is already installed.
Package perl-Digest-MD5-help-2.55-419.ky10.noarch is already installed.
Package perl-Digest-SHA-1:6.02-7.ky10.mips64el is already installed.
Package perl-Digest-SHA-help-1:6.02-7.ky10.noarch is already installed.
Package perl-Digest-SHA3-help-1.04-4.ky10.mips64el is already installed.
Package perl-Digest-help-1.17-419.ky10.noarch is already installed.
Package perl-Encode-4:2.98-9.ky10.mips64el is already installed.
Package perl-Encode-Locale-help-1.05-12.ky10.noarch is already installed.
Package perl-Encode-devel-4:2.98-9.ky10.mips64el is already installed.
Package perl-Encode-help-4:2.98-9.ky10.noarch is already installed.
Package perl-Env-1.04-397.ky10.noarch is already installed.
Package perl-Env-help-1.04-397.ky10.noarch is already installed.
Package perl-Error-1:0.17026-4.ky10.noarch is already installed.
Package perl-Error-help-1:0.17026-4.ky10.noarch is already installed.
Package perl-Exporter-5.73-420.ky10.noarch is already installed.
Package perl-Exporter-Tiny-help-1.002001-5.ky10.noarch is already installed.
Package perl-Exporter-help-5.73-420.ky10.noarch is already installed.
Package perl-ExtUtils-Command-1:7.42-2.ky10.noarch is already installed.
Package perl-ExtUtils-Config-help-0.008-19.ky10.noarch is already installed.
Package perl-ExtUtils-Helpers-0.026-13.ky10.noarch is already installed.
Package perl-ExtUtils-Install-2.14-419.ky10.noarch is already installed.
Package perl-ExtUtils-Install-help-2.14-419.ky10.noarch is already installed.
Package perl-ExtUtils-InstallPaths-help-0.012-9.ky10.noarch is already installed.
Package perl-ExtUtils-MakeMaker-1:7.42-2.ky10.noarch is already installed.
Package perl-ExtUtils-MakeMaker-help-1:7.42-2.ky10.noarch is already installed.
Package perl-ExtUtils-Manifest-1:1.71-4.ky10.noarch is already installed.
Package perl-ExtUtils-Manifest-help-1:1.71-4.ky10.noarch is already installed.
Package perl-ExtUtils-ParseXS-2:3.35-1.ky10.noarch is already installed.
Package perl-ExtUtils-ParseXS-help-2:3.35-1.ky10.noarch is already installed.
Package perl-Fedora-VSP-help-0.001-10.ky10.noarch is already installed.
Package perl-File-BaseDir-help-0.08-6.ky10.noarch is already installed.
Package perl-File-DesktopEntry-help-0.22-11.ky10.noarch is already installed.
Package perl-File-Fetch-0.56-4.ky10.noarch is already installed.
Package perl-File-Fetch-help-0.56-4.ky10.noarch is already installed.
Package perl-File-HomeDir-1.004-4.ky10.noarch is already installed.
Package perl-File-HomeDir-help-1.004-4.ky10.noarch is already installed.
Package perl-File-Path-2.16-4.ky10.noarch is already installed.
Package perl-File-Path-help-2.16-4.ky10.noarch is already installed.
Package perl-File-ReadBackwards-help-1.05-1.ky10.noarch is already installed.
Package perl-File-Remove-help-1.58-2.ky10.noarch is already installed.
Package perl-File-ShareDir-Install-help-0.13-4.ky10.noarch is already installed.
Package perl-File-ShareDir-help-1.116-4.ky10.noarch is already installed.
Package perl-File-Slurp-help-9999.19-22.ky10.noarch is already installed.
Package perl-File-Sync-help-0.11-20.ky10.noarch is already installed.
Package perl-File-Temp-1:0.230.800-4.ky10.noarch is already installed.
Package perl-File-Temp-help-1:0.230.800-4.ky10.noarch is already installed.
Package perl-File-Which-1.22-6.ky10.noarch is already installed.
Package perl-File-Which-help-1.22-6.ky10.noarch is already installed.
Package perl-Filter-2:1.59-2.ky10.mips64el is already installed.
Package perl-Filter-Simple-1:0.94-1.ky10.noarch is already installed.
Package perl-Filter-Simple-help-1:0.94-1.ky10.noarch is already installed.
Package perl-Font-TTF-help-1.06-9.ky10.noarch is already installed.
Package perl-GD-Barcode-help-1.15-30.ky10.noarch is already installed.
Package perl-GD-help-2.71-1.p01.ky10.noarch is already installed.
Package perl-GSSAPI-help-0.28-26.ky10.mips64el is already installed.
Package perl-Getopt-Long-2.50-419.ky10.noarch is already installed.
Package perl-Getopt-Long-help-2.50-419.ky10.noarch is already installed.
Package perl-Git-2.27.0-4.ky10.noarch is already installed.
Package perl-HTML-Parser-help-3.72-16.ky10.mips64el is already installed.
Package perl-HTML-Tagset-help-3.20-37.ky10.noarch is already installed.
Package perl-HTTP-Cookies-help-6.04-5.ky10.noarch is already installed.
Package perl-HTTP-Daemon-help-6.01-26.ky10.noarch is already installed.
Package perl-HTTP-Date-help-6.02-21.ky10.noarch is already installed.
Package perl-HTTP-Message-help-6.18-4.ky10.noarch is already installed.
Package perl-HTTP-Negotiate-help-6.01-22.ky10.noarch is already installed.
Package perl-HTTP-Tiny-0.076-3.ky10.noarch is already installed.
Package perl-HTTP-Tiny-help-0.076-3.ky10.noarch is already installed.
Package perl-IO-Compress-2.081-6.ky10.noarch is already installed.
Package perl-IO-Compress-help-2.081-6.ky10.noarch is already installed.
Package perl-IO-HTML-help-1.001-13.ky10.noarch is already installed.
Package perl-IO-Socket-INET6-help-2.72-15.ky10.noarch is already installed.
Package perl-IO-Socket-IP-0.39-420.ky10.noarch is already installed.
Package perl-IO-Socket-IP-help-0.39-420.ky10.noarch is already installed.
Package perl-IO-Socket-SSL-help-2.066-4.ky10.noarch is already installed.
Package perl-IO-stringy-help-2.111-12.ky10.noarch is already installed.
Package perl-IPC-Cmd-2:1.04-4.ky10.noarch is already installed.
Package perl-IPC-Cmd-help-2:1.04-4.ky10.noarch is already installed.
Package perl-IPC-SysV-2.07-5.ky10.mips64el is already installed.
Package perl-IPC-SysV-help-2.07-5.ky10.noarch is already installed.
Package perl-IPC-System-Simple-1.25-19.ky10.noarch is already installed.
Package perl-IPC-System-Simple-help-1.25-19.ky10.noarch is already installed.
Package perl-JSON-PP-1:4.04-2.ky10.noarch is already installed.
Package perl-JSON-PP-help-1:4.04-2.ky10.noarch is already installed.
Package perl-JSON-XS-help-1:3.04-6.ky10.noarch is already installed.
Package perl-JSON-help-2.97.001-6.ky10.noarch is already installed.
Package perl-LWP-MediaTypes-help-6.02-17.ky10.noarch is already installed.
Package perl-List-MoreUtils-XS-help-0.428-7.ky10.noarch is already installed.
Package perl-List-MoreUtils-help-0.428-5.ky10.noarch is already installed.
Package perl-Locale-Codes-3.58-2.ky10.noarch is already installed.
Package perl-Locale-Codes-help-3.58-2.ky10.noarch is already installed.
Package perl-Locale-Maketext-1:1.28-1.ky10.noarch is already installed.
Package perl-Locale-Maketext-help-1:1.28-1.ky10.noarch is already installed.
Package perl-MIME-Base64-3.15-418.ky10.mips64el is already installed.
Package perl-MIME-Base64-help-3.15-418.ky10.noarch is already installed.
Package perl-MRO-Compat-help-0.13-9.ky10.noarch is already installed.
Package perl-Math-BigInt-1:1.9998.13-5.ky10.noarch is already installed.
Package perl-Math-BigInt-FastCalc-0.500.700-4.ky10.mips64el is already installed.
Package perl-Math-BigInt-FastCalc-help-0.500.700-4.ky10.noarch is already installed.
Package perl-Math-BigInt-help-1:1.9998.13-5.ky10.noarch is already installed.
Package perl-Math-BigRat-0.2614-2.ky10.noarch is already installed.
Package perl-Math-BigRat-help-0.2614-2.ky10.noarch is already installed.
Package perl-Module-Build-Tiny-help-0.039-17.ky10.noarch is already installed.
Package perl-Module-Build-help-2:0.42.24-12.ky10.noarch is already installed.
Package perl-Module-CoreList-1:5.20180920-2.ky10.noarch is already installed.
Package perl-Module-CoreList-help-1:5.20180920-2.ky10.noarch is already installed.
Package perl-Module-Install-AuthorRequires-help-0.02-18.ky10.noarch is already installed.
Package perl-Module-Install-AuthorTests-help-0.002-18.ky10.noarch is already installed.
Package perl-Module-Install-ReadmeFromPod-help-0.30-12.ky10.noarch is already installed.
Package perl-Module-Install-ReadmeMarkdownFromPod-help-0.04-10.ky10.noarch is already installed.
Package perl-Module-Install-Repository-help-0.06-23.ky10.noarch is already installed.
Package perl-Module-Load-1:0.32-418.ky10.noarch is already installed.
Package perl-Module-Load-Conditional-0.68-418.ky10.noarch is already installed.
Package perl-Module-Load-Conditional-help-0.68-418.ky10.noarch is already installed.
Package perl-Module-Load-help-1:0.32-418.ky10.noarch is already installed.
Package perl-Module-Manifest-Skip-help-0.23-16.ky10.noarch is already installed.
Package perl-Module-Metadata-1.000036-3.ky10.noarch is already installed.
Package perl-Module-Metadata-help-1.000036-3.ky10.noarch is already installed.
Package perl-Module-Package-Au-help-2-16.ky10.noarch is already installed.
Package perl-Module-Package-help-0.30-22.ky10.noarch is already installed.
Package perl-Module-Runtime-help-0.016-5.ky10.noarch is already installed.
Package perl-Module-ScanDeps-help-1.27-6.p01.ky10.noarch is already installed.
Package perl-Moo-help-2.003004-8.ky10.noarch is already installed.
Package perl-Mozilla-CA-help-1:20180117-6.ky10.noarch is already installed.
Package perl-NTLM-help-1.09-20.ky10.noarch is already installed.
Package perl-Net-Daemon-1:0.48-2.ky10.noarch is already installed.
Package perl-Net-Daemon-help-1:0.48-2.ky10.noarch is already installed.
Package perl-Net-HTTP-help-6.18-4.ky10.noarch is already installed.
Package perl-Net-LibIDN-help-0.12-33.ky10.noarch is already installed.
Package perl-Net-SNMP-help-6.0.1-23.ky10.noarch is already installed.
Package perl-Net-SSLeay-help-1.88-5.ky10.noarch is already installed.
Package perl-NetAddr-IP-help-4.079-10.ky10.mips64el is already installed.
Package perl-Package-Constants-help-1:0.06-1.ky10.noarch is already installed.
Package perl-Package-Generator-help-1.106-14.ky10.noarch is already installed.
Package perl-Params-Check-1:0.38-418.ky10.noarch is already installed.
Package perl-Params-Check-help-1:0.38-418.ky10.noarch is already installed.
Package perl-Params-Util-help-1.07-26.ky10.noarch is already installed.
Package perl-Parse-Yapp-help-1.21-5.ky10.noarch is already installed.
Package perl-Path-Class-help-0.37-14.ky10.noarch is already installed.
Package perl-Path-Tiny-help-0.108-2.ky10.noarch is already installed.
Package perl-PathTools-3.75-4.ky10.mips64el is already installed.
Package perl-PathTools-help-3.75-4.ky10.noarch is already installed.
Package perl-Perl-OSType-1.010-421.ky10.noarch is already installed.
Package perl-Perl-OSType-help-1.010-421.ky10.noarch is already installed.
Package perl-PerlIO-via-QuotedPrint-0.08-397.ky10.noarch is already installed.
Package perl-PerlIO-via-QuotedPrint-help-0.08-397.ky10.noarch is already installed.
Package perl-Pod-Checker-4:1.73-398.ky10.noarch is already installed.
Package perl-Pod-Checker-help-4:1.73-398.ky10.noarch is already installed.
Package perl-Pod-Escapes-1:1.07-419.ky10.noarch is already installed.
Package perl-Pod-Escapes-help-1:1.07-419.ky10.noarch is already installed.
Package perl-Pod-Markdown-help-3.101-2.ky10.noarch is already installed.
Package perl-Pod-Parser-1.63-397.ky10.noarch is already installed.
Package perl-Pod-Parser-help-1.63-397.ky10.noarch is already installed.
Package perl-Pod-Perldoc-1:3.28-3.ky10.noarch is already installed.
Package perl-Pod-Perldoc-help-1:3.28-3.ky10.noarch is already installed.
Package perl-Pod-Simple-1:3.35-418.ky10.noarch is already installed.
Package perl-Pod-Simple-help-1:3.35-418.ky10.noarch is already installed.
Package perl-Pod-Usage-4:1.69-418.ky10.noarch is already installed.
Package perl-Pod-Usage-help-4:1.69-418.ky10.noarch is already installed.
Package perl-Readonly-help-2.05-8.ky10.noarch is already installed.
Package perl-Role-Tiny-help-2.001004-2.ky10.noarch is already installed.
Package perl-SGMLSpm-1.03ii-45.ky10.noarch is already installed.
Package perl-SGMLSpm-help-1.03ii-45.ky10.noarch is already installed.
Package perl-SNMP_Session-help-1.13-20.ky10.noarch is already installed.
Package perl-Scalar-List-Utils-3:1.52-2.ky10.mips64el is already installed.
Package perl-Scalar-List-Utils-help-3:1.52-2.ky10.noarch is already installed.
Package perl-Socket-4:2.029-2.ky10.mips64el is already installed.
Package perl-Socket-MsgHdr-help-0.05-5.ky10.noarch is already installed.
Package perl-Socket-help-4:2.029-2.ky10.noarch is already installed.
Package perl-Socket6-help-0.28-9.ky10.mips64el is already installed.
Package perl-Software-License-help-0.103013-7.ky10.noarch is already installed.
Package perl-Storable-1:3.15-2.ky10.mips64el is already installed.
Package perl-Storable-help-1:3.15-2.ky10.noarch is already installed.
Package perl-String-ShellQuote-help-1.04-26.ky10.noarch is already installed.
Package perl-Sub-Exporter-Progressive-help-0.001013-8.ky10.noarch is already installed.
Package perl-Sub-Exporter-help-0.987-18.ky10.noarch is already installed.
Package perl-Sub-Install-help-0.928-18.ky10.noarch is already installed.
Package perl-Sub-Name-help-0.21-10.ky10.mips64el is already installed.
Package perl-Sub-Quote-help-2.005001-4.ky10.noarch is already installed.
Package perl-Sys-CPU-help-0.61-19.ky10.noarch is already installed.
Package perl-Sys-MemInfo-help-0.99-9.ky10.noarch is already installed.
Package perl-Sys-Syslog-0.35-420.ky10.mips64el is already installed.
Package perl-Sys-Syslog-help-0.35-420.ky10.noarch is already installed.
Package perl-Term-ANSIColor-4.06-511.ky10.noarch is already installed.
Package perl-Term-ANSIColor-help-4.06-511.ky10.noarch is already installed.
Package perl-Term-Cap-1.17-510.ky10.noarch is already installed.
Package perl-Term-Cap-help-1.17-510.ky10.noarch is already installed.
Package perl-TermReadKey-2.38-2.ky10.mips64el is already installed.
Package perl-TermReadKey-help-2.38-2.ky10.noarch is already installed.
Package perl-Test-Deep-help-1.128-4.ky10.noarch is already installed.
Package perl-Test-FailWarnings-help-0.008-15.ky10.noarch is already installed.
Package perl-Test-Fatal-help-0.014-13.ky10.noarch is already installed.
Package perl-Test-Harness-1:3.43_01-3.ky10.noarch is already installed.
Package perl-Test-Harness-help-1:3.43_01-3.ky10.noarch is already installed.
Package perl-Test-InDistDir-help-1.112071-10.ky10.noarch is already installed.
Package perl-Test-LeakTrace-help-0.16-10.ky10.noarch is already installed.
Package perl-Test-NoWarnings-help-1.04-17.ky10.noarch is already installed.
Package perl-Test-Pod-Coverage-help-1.10-14.ky10.noarch is already installed.
Package perl-Test-Pod-help-1.52-4.ky10.noarch is already installed.
Package perl-Test-Requires-help-0.10-15.ky10.noarch is already installed.
Package perl-Test-Simple-2:1.302140-3.ky10.noarch is already installed.
Package perl-Test-Simple-help-2:1.302140-3.ky10.noarch is already installed.
Package perl-Text-Balanced-2.03-420.ky10.noarch is already installed.
Package perl-Text-Balanced-help-2.03-420.ky10.noarch is already installed.
Package perl-Text-Diff-1.45-7.ky10.noarch is already installed.
Package perl-Text-Diff-help-1.45-7.ky10.noarch is already installed.
Package perl-Text-Glob-help-0.11-7.ky10.noarch is already installed.
Package perl-Text-ParseWords-3.30-419.ky10.noarch is already installed.
Package perl-Text-ParseWords-help-3.30-419.ky10.noarch is already installed.
Package perl-Text-Tabs+Wrap-2013.0523-419.ky10.noarch is already installed.
Package perl-Text-Tabs+Wrap-help-2013.0523-419.ky10.noarch is already installed.
Package perl-Text-Template-help-1.53-4.ky10.noarch is already installed.
Package perl-Text-WrapI18N-help-0.06-33.ky10.noarch is already installed.
Package perl-Thread-Queue-3.13-3.ky10.noarch is already installed.
Package perl-Thread-Queue-help-3.13-3.ky10.noarch is already installed.
Package perl-Time-HiRes-1.9760-2.ky10.mips64el is already installed.
Package perl-Time-HiRes-help-1.9760-2.ky10.noarch is already installed.
Package perl-Time-Local-2:1.280-6.ky10.noarch is already installed.
Package perl-Time-Local-help-2:1.280-6.ky10.noarch is already installed.
Package perl-TimeDate-help-1:2.30-17.ky10.noarch is already installed.
Package perl-Types-Serialiser-help-1.0-18.ky10.noarch is already installed.
Package perl-URI-help-1.76-3.ky10.noarch is already installed.
Package perl-Unicode-Collate-1.25-4.ky10.mips64el is already installed.
Package perl-Unicode-Collate-help-1.25-4.ky10.noarch is already installed.
Package perl-Unicode-Normalize-1.26-419.ky10.mips64el is already installed.
Package perl-Unicode-Normalize-help-1.26-419.ky10.noarch is already installed.
Package perl-Unicode-UTF8-help-0.62-8.ky10.noarch is already installed.
Package perl-XML-LibXML-help-1:2.0132-5.ky10.mips64el is already installed.
Package perl-XML-NamespaceSupport-help-1.12-7.ky10.noarch is already installed.
Package perl-XML-Parser-1:2.44-3.ky10.mips64el is already installed.
Package perl-XML-Parser-help-1:2.44-3.ky10.noarch is already installed.
Package perl-XML-SAX-Base-help-1.09-7.ky10.noarch is already installed.
Package perl-XML-SAX-help-1.00-5.ky10.noarch is already installed.
Package perl-XML-Writer-help-0.625-14.ky10.noarch is already installed.
Package perl-XML-XPath-help-1.42-6.ky10.noarch is already installed.
Package perl-YAML-Tiny-help-1.73-4.ky10.noarch is already installed.
Package perl-YAML-help-1.26-5.ky10.noarch is already installed.
Package perl-autodie-2.29-398.ky10.noarch is already installed.
Package perl-autodie-help-2.29-398.ky10.noarch is already installed.
Package perl-bignum-0.50-4.ky10.noarch is already installed.
Package perl-bignum-help-0.50-4.ky10.noarch is already installed.
Package perl-common-sense-help-3.7.4-14.ky10.noarch is already installed.
Package perl-constant-1.33-421.ky10.noarch is already installed.
Package perl-constant-help-1.33-421.ky10.noarch is already installed.
Package perl-devel-4:5.28.0-434.ky10.mips64el is already installed.
Package perl-experimental-0.020-2.ky10.noarch is already installed.
Package perl-experimental-help-0.020-2.ky10.noarch is already installed.
Package perl-gettext-help-1.07-13.ky10.noarch is already installed.
Package perl-inc-latest-help-2:0.500-12.ky10.noarch is already installed.
Package perl-libintl-perl-help-1.29-6.ky10.noarch is already installed.
Package perl-libnet-3.11-420.ky10.noarch is already installed.
Package perl-libnet-help-3.11-420.ky10.noarch is already installed.
Package perl-libs-4:5.28.0-434.ky10.mips64el is already installed.
Package perl-libwww-perl-help-6.35-2.ky10.noarch is already installed.
Package perl-libxml-perl-help-0.08-36.ky10.noarch is already installed.
Package perl-parent-1:0.237-4.ky10.noarch is already installed.
Package perl-parent-help-1:0.237-4.ky10.noarch is already installed.
Package perl-perlfaq-5.20180915-5.ky10.noarch is already installed.
Package perl-perlfaq-help-5.20180915-5.ky10.noarch is already installed.
Package perl-podlators-1:4.11-5.ky10.noarch is already installed.
Package perl-podlators-help-1:4.11-5.ky10.noarch is already installed.
Package perl-strictures-help-2.000006-7.ky10.noarch is already installed.
Package perl-threads-1:2.22-419.ky10.mips64el is already installed.
Package perl-threads-help-1:2.22-419.ky10.noarch is already installed.
Package perl-threads-shared-1.59-2.ky10.mips64el is already installed.
Package perl-threads-shared-help-1.59-2.ky10.noarch is already installed.
Package perl-version-8:0.99.24-3.ky10.mips64el is already installed.
Package perl-version-help-8:0.99.24-3.ky10.noarch is already installed.
Package make-1:4.2.1-15.ky10.mips64el is already installed.

创建mysql用户与用户组

[root@localhost /]# groupadd mysql
groupadd:“mysql”组已存在
[root@localhost /]# id mysql
用户id=27(mysql) 组id=27(mysql) 组=27(mysql)

创建并修改/mysqlsoft/mysql与/mysqldata/mysql目录权限

[root@localhost /]# mkdir -p /mysqlsoft/mysql
[root@localhost /]# mkdir -p /mysqldata/mysql
[root@localhost /]# chown -R mysql:mysql /mysqlsoft
[root@localhost /]# chown -R mysql:mysql /mysqldata
[root@localhost /]# chmod -R 775 /mysqlsoft
[root@localhost /]# chmod -R 775 /mysqldata

解压MySQL源码包

[root@localhost soft]# tar -zxvf  mysql-boost-5.7.39.tar.gz
[root@localhost soft]# ls -lrt
总用量 3643996
drwxr-xr-x 34 7161 31415       4096  6月  8 16:48 mysql-5.7.39
-rw-------  1 root root    53243335 11月 15 22:24 mysql-boost-5.7.39.tar.gz

编译安装

[root@localhost mysql-5.7.39]# cmake . -DCMAKE_INSTALL_PREFIX=/mysqlsoft/mysql  -DMYSQL_DATADIR=/mysqldata/mysql  -DSYSCONFDIR=/mysqlsoft/mysql/mysql.sock  -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/soft/mysql-5.7.39/boost/boost_1_59_0 -DWITH_INNOBASE_STORAGE_ENGINE=1  -DWITH_PARTITION_STORAGE_ENGINE=1  -DWITH_FEDERATED_STORAGE_ENGINE=1  -DWITH_BLACKHOLE_STORAGE_ENGINE=1  -DWITH_MYISAM_STORAGE_ENGINE=1  -DENABLED_LOCAL_INFILE=1  -DENABLE_DTRACE=0  -DDEFAULT_CHARSET=utf8mb4  -DDEFAULT_COLLATION=utf8mb4_general_ci  -DWITH_EMBEDDED_SERVER=1
CMake Deprecation Warning at CMakeLists.txt:35 (CMAKE_POLICY):
  The OLD behavior for policy CMP0018 will be removed from a future version
  of CMake.

  The cmake-policies(7) manual explains that the OLD behaviors of all
  policies are deprecated and that a policy should be set to OLD only under
  specific short-term circumstances.  Projects should be ported to the NEW
  behavior and not rely on setting a policy to OLD.


CMake Deprecation Warning at CMakeLists.txt:41 (CMAKE_POLICY):
  The OLD behavior for policy CMP0022 will be removed from a future version
  of CMake.

  The cmake-policies(7) manual explains that the OLD behaviors of all
  policies are deprecated and that a policy should be set to OLD only under
  specific short-term circumstances.  Projects should be ported to the NEW
  behavior and not rely on setting a policy to OLD.


CMake Deprecation Warning at CMakeLists.txt:48 (CMAKE_POLICY):
  The OLD behavior for policy CMP0045 will be removed from a future version
  of CMake.

  The cmake-policies(7) manual explains that the OLD behaviors of all
  policies are deprecated and that a policy should be set to OLD only under
  specific short-term circumstances.  Projects should be ported to the NEW
  behavior and not rely on setting a policy to OLD.


CMake Deprecation Warning at CMakeLists.txt:49 (CMAKE_POLICY):
  The OLD behavior for policy CMP0042 will be removed from a future version
  of CMake.

  The cmake-policies(7) manual explains that the OLD behaviors of all
  policies are deprecated and that a policy should be set to OLD only under
  specific short-term circumstances.  Projects should be ported to the NEW
  behavior and not rely on setting a policy to OLD.


-- Running cmake version 3.12.1
-- Found Git: /usr/bin/git (found version "2.27.0")
-- Configuring with MAX_INDEXES = 64U
CMake Warning (dev) at CMakeLists.txt:146 (PROJECT):
  Policy CMP0048 is not set: project() command manages VERSION variables.
  Run "cmake --help-policy CMP0048" for policy details.  Use the cmake_policy
  command to set the policy and suppress this warning.

  The following variable(s) would be set to empty:

    CMAKE_PROJECT_VERSION
    CMAKE_PROJECT_VERSION_MAJOR
    CMAKE_PROJECT_VERSION_MINOR
    CMAKE_PROJECT_VERSION_PATCH
This warning is for project developers.  Use -Wno-dev to suppress it.

-- CMAKE_GENERATOR: Unix Makefiles
-- SIZEOF_VOIDP 8
-- MySQL 5.7.39
-- Packaging as: mysql-5.7.39-Linux-mips64el
-- DTRACE is disabled
-- Local boost dir /soft/mysql-5.7.39/boost/boost_1_59_0
-- Found /soft/mysql-5.7.39/boost/boost_1_59_0/boost/version.hpp
-- BOOST_VERSION_NUMBER is #define BOOST_VERSION 105900
-- BOOST_INCLUDE_DIR /soft/mysql-5.7.39/boost/boost_1_59_0
-- NUMA library missing or required version not available
-- ZLIB_VERSION (bundled) is 1.2.12
-- ZLIB_INCLUDE_DIR /soft/mysql-5.7.39/extra/zlib/zlib-1.2.12
-- ZLIB_LIBRARY zlib
-- OPENSSL_INCLUDE_DIR = /usr/include
-- OPENSSL_LIBRARY = /usr/lib64/libssl.so
-- CRYPTO_LIBRARY = /usr/lib64/libcrypto.so
-- OPENSSL_MAJOR_VERSION = 1
-- OPENSSL_MINOR_VERSION = 01
-- OPENSSL_FIX_VERSION = 01
-- SSL_LIBRARIES = /usr/lib64/libssl.so;/usr/lib64/libcrypto.so;dl
-- AWK_EXECUTABLE is /usr/bin/gawk
-- Found Git: /usr/bin/git
-- LIBEVENT_VERSION_STRING 2.1.11-stable
-- LIBEVENT_VERSION (bundled) 2.1.11
-- WITH_PROTOBUF=bundled
-- protobuf version is 2.6
-- You need to set WITH_CURL. This variable needs to point to curl library.
-- Creating LDAP authentication SASL client library.
-- Required SASL header is missing.Skipping the LDAP SASL client authentication plugin.
-- Library mysqlclient depends on OSLIBS -lpthread;m;rt;/usr/lib64/libssl.so;/usr/lib64/libcrypto.so;dl
-- MERGE_CONVENIENCE_LIBRARIES TARGET mysqlclient
-- MERGE_CONVENIENCE_LIBRARIES LIBS clientlib;dbug;strings;vio;mysys;mysys_ssl;zlib
-- MERGE_CONVENIENCE_LIBRARIES MYLIBS clientlib;dbug;strings;vio;mysys;mysys_ssl;zlib
-- RPC_INCLUDE_DIRS /usr/include/tirpc
-- Using Boost headers from /soft/mysql-5.7.39/boost/boost_1_59_0
-- Performing Test CXX_HAVE_SIGN_COMPARE
-- Performing Test CXX_HAVE_SIGN_COMPARE - Success
-- Performing Test CXX_HAVE_UNUSED_VARIABLE
-- Performing Test CXX_HAVE_UNUSED_VARIABLE - Success
-- MYSQLX - Text log of protobuf messages enabled
-- Performing Test HAVE_UNUSED_PARAMETER
-- Performing Test HAVE_UNUSED_PARAMETER - Success
-- Googletest was not found. gtest-based unit tests will be disabled. You can run cmake . -DENABLE_DOWNLOADS=1 to automatically download and build required components from source.
-- If you are inside a firewall, you may need to use an https proxy: export https_proxy=http://example.com:80
-- Performing Test HAVE_MISLEADING_INDENTATION
-- Performing Test HAVE_MISLEADING_INDENTATION - Success
-- Performing Test HAVE_NO_BUILTIN_MEMCMP
-- Performing Test HAVE_NO_BUILTIN_MEMCMP - Success
-- executable target mysqld debug_target /soft/debug/sql/mysqld
CMake Warning at cmake/bison.cmake:27 (MESSAGE):
  Bison executable not found in PATH
Call Stack (most recent call first):
  sql/CMakeLists.txt:603 (INCLUDE)


CMake Warning at cmake/bison.cmake:27 (MESSAGE):
  Bison executable not found in PATH
Call Stack (most recent call first):
  libmysqld/CMakeLists.txt:215 (INCLUDE)


-- Library mysqlserver depends on OSLIBS -lpthread;m;rt;/usr/lib64/libssl.so;/usr/lib64/libcrypto.so;dl;crypt
-- MERGE_CONVENIENCE_LIBRARIES TARGET mysqlserver
-- MERGE_CONVENIENCE_LIBRARIES LIBS dbug;strings;regex;mysys;mysys_ssl;vio;zlib;/usr/lib64/libssl.so;/usr/lib64/libcrypto.so;dl;crypt;archive_embedded;blackhole_embedded;csv_embedded;federated_embedded;heap_embedded;innobase_embedded;lz4_lib;myisam_embedded;myisammrg_embedded;partition_embedded;ngram_parser_embedded;sql_embedded
-- MERGE_CONVENIENCE_LIBRARIES MYLIBS dbug;strings;regex;mysys;mysys_ssl;vio;zlib;archive_embedded;blackhole_embedded;csv_embedded;federated_embedded;heap_embedded;innobase_embedded;lz4_lib;myisam_embedded;myisammrg_embedded;partition_embedded;ngram_parser_embedded;sql_embedded
-- library target mysqlserver debug_target /soft/debug/archive_output_directory/libmysqld.a
-- INSTALL mysqlclient.pc lib/pkgconfig
-- Skipping deb packaging on unsupported platform .
-- CMAKE_BUILD_TYPE: RelWithDebInfo
-- COMPILE_DEFINITIONS: _GNU_SOURCE;_FILE_OFFSET_BITS=64;HAVE_CONFIG_H;HAVE_TLSv13
-- CMAKE_C_FLAGS: -fPIC -fabi-version=2 -fno-omit-frame-pointer -fno-strict-aliasing -ffp-contract=off  -Wall -Wextra -Wformat-security -Wvla -Wimplicit-fallthrough=2 -Wwrite-strings -Wdeclaration-after-statement
-- CMAKE_CXX_FLAGS: -fPIC -std=gnu++03 -fabi-version=2 -fno-omit-frame-pointer -fno-strict-aliasing -ffp-contract=off  -Wall -Wextra -Wformat-security -Wvla -Wimplicit-fallthrough=2 -Woverloaded-virtual -Wno-unused-parameter
-- CMAKE_CXX_FLAGS_DEBUG: -DENABLED_DEBUG_SYNC -DSAFE_MUTEX
-- CMAKE_CXX_FLAGS_RELWITHDEBINFO: -ffunction-sections -fdata-sections
-- CMAKE_CXX_FLAGS_RELEASE: -ffunction-sections -fdata-sections
-- CMAKE_CXX_FLAGS_MINSIZEREL: -ffunction-sections -fdata-sections
-- CMAKE_C_LINK_FLAGS:
-- CMAKE_CXX_LINK_FLAGS:
-- CMAKE_EXE_LINKER_FLAGS
-- CMAKE_MODULE_LINKER_FLAGS
-- CMAKE_SHARED_LINKER_FLAGS
-- Configuring done
-- Generating done
-- Build files have been written to: /soft/mysql-5.7.39




[root@localhost mysql-5.7.39]# make -j 4


[root@localhost mysql-5.7.39]# make install

-- Installing: /mysqlsoft/mysql/mysql-test/./std_data/funcs_1/memory_tb3.txt
-- Installing: /mysqlsoft/mysql/mysql-test/./std_data/funcs_1/myisam_tb3.txt
-- Installing: /mysqlsoft/mysql/mysql-test/./std_data/funcs_1/ndb_tb3.txt
-- Installing: /mysqlsoft/mysql/mysql-test/./std_data/funcs_1/t3.txt
-- Installing: /mysqlsoft/mysql/mysql-test/./std_data/funcs_1/myisam_tb2.txt
-- Installing: /mysqlsoft/mysql/mysql-test/./std_data/funcs_1/myisam_tb4.txt
-- Installing: /mysqlsoft/mysql/mysql-test/./std_data/funcs_1/memory_tb4.txt
-- Installing: /mysqlsoft/mysql/mysql-test/./std_data/funcs_1/memory_tb2.txt
-- Installing: /mysqlsoft/mysql/mysql-test/./std_data/server8k-cert.pem
-- Installing: /mysqlsoft/mysql/mysql-test/./std_data/latin1.xml
-- Installing: /mysqlsoft/mysql/mysql-test/./std_data/bug16266.000001
-- Installing: /mysqlsoft/mysql/mysql-test/./std_data/replicated-bin.index
-- Installing: /mysqlsoft/mysql/mysql-test/./std_data/.mylogin.cnf
-- Installing: /mysqlsoft/mysql/mysql-test/./std_data/slave-relay-bin.000001
-- Installing: /mysqlsoft/mysql/mysql-test/./std_data/wl6219_55_innodb.frm
-- Installing: /mysqlsoft/mysql/mysql-test/./std_data/data_50722.zip
-- Installing: /mysqlsoft/mysql/mysql-test/./std_data/bug46565.ARZ
-- Installing: /mysqlsoft/mysql/mysql-test/./std_data/server-key-verify-pass.pem
-- Installing: /mysqlsoft/mysql/mysql-test/./std_data/server-key.pem
-- Installing: /mysqlsoft/mysql/mysql-test/./std_data/bug46565.frm
-- Installing: /mysqlsoft/mysql/mysql-test/./std_data/bug37631.MYI
-- Installing: /mysqlsoft/mysql/mysql-test/./std_data/server-cert-verify-fail.pem
-- Installing: /mysqlsoft/mysql/mysql-test/./std_data/bug21542698.dat
-- Installing: /mysqlsoft/mysql/mysql-test/./std_data/loaddata7.dat
-- Installing: /mysqlsoft/mysql/mysql-test/./std_data/expired-ca.pem
-- Installing: /mysqlsoft/mysql/mysql-test/./std_data/binlog_truncated_event.000001
-- Installing: /mysqlsoft/mysql/mysql-test/./std_data/loaddata_pair.dat
-- Installing: /mysqlsoft/mysql/./README-test
-- Up-to-date: /mysqlsoft/mysql/mysql-test/mtr
-- Up-to-date: /mysqlsoft/mysql/mysql-test/mysql-test-run
-- Installing: /mysqlsoft/mysql/mysql-test/lib/My/SafeProcess/my_safe_process
-- Up-to-date: /mysqlsoft/mysql/mysql-test/lib/My/SafeProcess/my_safe_process
-- Installing: /mysqlsoft/mysql/mysql-test/lib/My/SafeProcess/Base.pm
-- Installing: /mysqlsoft/mysql/support-files/mysqld_multi.server
-- Installing: /mysqlsoft/mysql/support-files/mysql-log-rotate
-- Installing: /mysqlsoft/mysql/support-files/magic
-- Installing: /mysqlsoft/mysql/share/aclocal/mysql.m4
-- Installing: /mysqlsoft/mysql/support-files/mysql.server

配置mysql参数,只是设置几个简单的mysql运行参数

[mysql@localhost mysql]$ cat my.cnf
[mysqld]
basedir=/mysqlsoft/mysql
datadir=/mysqldata/mysql
bind-address=0.0.0.0
user=mysql
port=3306
log-error=/mysqldata/mysql/mysql.err
pid-file=/mysqldata/mysql/mysqld.pid
socket = /mysqlsoft/mysql/mysql.sock
character-set-server=utf8mb4
default-storage-engine=INNODB
explicit_defaults_for_timestamp = true
########innodb settings########
innodb_page_size = 8192
innodb_buffer_pool_size = 4G
innodb_buffer_pool_instances = 2
innodb_buffer_pool_load_at_startup = 1
innodb_buffer_pool_dump_at_shutdown = 1
innodb_lru_scan_depth = 2000
innodb_lock_wait_timeout = 5
innodb_io_capacity = 4000
innodb_io_capacity_max = 8000
innodb_flush_method = O_DIRECT
innodb_file_format = Barracuda
innodb_file_format_max = Barracuda
innodb_log_group_home_dir =/msyqldata/redolog/
innodb_undo_directory =/mysqldata/undolog/
innodb_undo_logs = 128
innodb_undo_tablespaces = 3
innodb_flush_nei***ors = 1
innodb_log_file_size = 1G
innodb_log_buffer_size = 16777216
innodb_purge_threads = 4
innodb_large_prefix = 1
innodb_thread_concurrency = 64
innodb_print_all_deadlocks = 1
innodb_strict_mode = 1
innodb_sort_buffer_size = 67108864

[root@localhost bin]# ./mysqld  --defaults-file=/mysqlsoft/mysql/my.cnf --initialize --basedir=/mysqlsoft/mysql --datadir=/mysqldata/mysql --user=mysql

[mysql@localhost mysql]$ tail -f mysql.err
 100 200 300 400 500 600 700 800 900 1000
 100 200 300 400 500 600 700 800 900 1000
2022-11-18T13:26:36.602330Z 0 [Warning] InnoDB: New log files created, LSN=39537
2022-11-18T13:26:36.741745Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2022-11-18T13:26:36.806980Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: a0976fe4-6744-11ed-8ede-0023a0002161.
2022-11-18T13:26:36.809665Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2022-11-18T13:26:37.348420Z 0 [Warning] A deprecated TLS version TLSv1 is enabled. Please use TLSv1.2 or higher.
2022-11-18T13:26:37.348462Z 0 [Warning] A deprecated TLS version TLSv1.1 is enabled. Please use TLSv1.2 or higher.
2022-11-18T13:26:37.350930Z 0 [Warning] CA certificate ca.pem is self signed.
2022-11-18T13:26:37.589677Z 1 [Note] A temporary password is generated for root@localhost: KuOS*vY&V1Dx


其中[Note] A temporary password is generated for root@localhost:后面跟的是mysql数据库登录的临时密码,各人安装生成的临时密码不一样。可以看到到日志文件没有报错,而且有了临时密码,表示初始化成功。

如果想服务能够部署自动支持安全连接,使用mysql_ssl_rsa_setup工具来创建缺省SSL与RSA文件

[root@localhost bin]#  ./mysql_ssl_rsa_setup --datadir=/mysqldata/mysql

配置环境变量

[root@localhost /]# vi /etc/profile
export MYSQL_HOME=/mysqlsoft/mysql/
export PATH=$PATH:$MYSQL_HOME/bin

[root@localhost /]# vi /etc/profile
[root@localhost /]# source /etc/profile

配置自动启动MySQL

[root@localhost /]# cp /mysqlsoft/mysql/support-files/mysql.server  /etc/init.d/mysqld
[root@localhost /]# chmod 755 /etc/init.d/mysqld
[root@localhost ~]# systemctl enable mysqld
mysqld.service is not a native service, redirecting to /sbin/chkconfig.
Executing /sbin/chkconfig mysqld on

启动MySQL

[root@localhost /]# service mysqld start
Starting MySQL... SUCCESS!

登录MySQL并修改root用户密码

[root@localhost tmp]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.39

Copyright (c) 2000, 2022, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>
]]>
http://www.jydba.net/index.php/archives/3443/feed 0
benchmarksql 5.0压测MySQL http://www.jydba.net/index.php/archives/3439 http://www.jydba.net/index.php/archives/3439#respond Fri, 09 Dec 2022 00:15:55 +0000 http://www.jydba.net/?p=3439 在Oracle Linux 7.6使用benchmarksql 5.0压测MySQL 5.7

一.下载&编译安装

1.先要确定服务器是否安装了 JDK1.8

[root@localhost /]# java -version
java version "1.7.0_75"
OpenJDK Runtime Environment (rhel-2.5.4.2.0.1.el7_0-x86_64 u75-b13)
OpenJDK 64-Bit Server VM (build 24.75-b04, mixed mode)

因为自带jdk存储在/usr/lib/jvm下,需要将其删除。

[root@localhost lib]# mv jvm jvmold
[root@localhost lib]# java -version
-bash: /usr/bin/java: ???

2.安装JDK1.8

[root@localhost /]# tar -zxvf jdk-linux-x64.tar.gz

[root@localhost /]# mkdir /usr/java
[root@localhost /]# mv jdk1.8.0_131 /usr/java/
[root@localhost /]# vi /etc/profile
....
export JAVA_HOME=/usr/java/jdk1.8.0_131
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib:$CLASSPATH
export JAVA_PATH=${JAVA_HOME}/bin:${JRE_HOME}/bin
export PATH=$PATH:${JAVA_PATH}

[root@localhost /]# source /etc/profile
[root@localhost /]# java -version
java version "1.8.0_131"
Java(TM) SE Runtime Environment (build 1.8.0_131-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)

[root@localhost /]# unzip benchmarksql-5.0.zip
[root@localhost /]# cd benchmarksql-5.0/

修改benchmarksql源码

修改jTPCCConfig.java文件

[root@localhost benchmarksql-5.0]# vi src/client/jTPCCConfig.java
/*
* jTPCCConfig - Basic configuration parameters for jTPCC
*
* Copyright (C) 2003, Raul Barbosa
* Copyright (C) 2004-2016, Denis Lussier
* Copyright (C) 2016, Jan Wieck
*
*/

import java.text.*;

public interface jTPCCConfig
{
public final static String JTPCCVERSION = "5.0";

public final static int DB_UNKNOWN = 0,
DB_FIREBIRD = 1,
DB_ORACLE = 2,
DB_POSTGRES = 3,
DB_MYSQL =4;

public final static int NEW_ORDER = 1,
PAYMENT = 2,
ORDER_STATUS = 3,
DELIVERY = 4,
STOCK_LEVEL = 5;

public final static String[] nameTokens = {"BAR", "OUGHT", "ABLE", "PRI", "PRES", "ESE", "ANTI", "CALLY", "ATION", "EING"};

public final static SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

public final static int configCommitCount = 10000; // commit every n records in LoadData

public final static int configWhseCount = 10;
public final static int configItemCount = 100000; // tpc-c std = 100,000
public final static int configDistPerWhse = 10; // tpc-c std = 10
public final static int configCustPerDist = 3000; // tpc-c std = 3,000
}

修改benchmarksql-5.0/src/client/jTPCC.java,增加mysql相关部分

[root@localhost benchmarksql-5.0]# vi src/client/jTPCC.java
/*
* jTPCC - Open Source Java implementation of a TPC-C like benchmark
*
* Copyright (C) 2003, Raul Barbosa
* Copyright (C) 2004-2016, Denis Lussier
* Copyright (C) 2016, Jan Wieck
*
*/

import org.apache.log4j.*;

import java.io.*;
import java.nio.file.*;
import java.sql.*;
import java.util.*;
import java.util.regex.Pattern;
import java.text.*;

public class jTPCC implements jTPCCConfig
{
private static org.apache.log4j.Logger log = Logger.getLogger(jTPCC.class);
private static String resultDirName = null;
private static BufferedWriter resultCSV = null;
private static BufferedWriter runInfoCSV = null;
private static int runID = 0;

private int dbType = DB_UNKNOWN;
private int currentlyDisplayedTerminal;

private jTPCCTerminal[] terminals;
private String[] terminalNames;
private boolean terminalsBlockingExit = false;
private long terminalsStarted = 0, sessionCount = 0, transactionCount = 0;
private Object counterLock = new Object();

private long newOrderCounter = 0, sessionStartTimestamp, sessionEndTimestamp, sessionNextTimestamp=0, sessionNextKounter=0;
private long sessionEndTargetTime = -1, fastNewOrderCounter, recentTpmC=0, recentTpmTotal=0;
private boolean signalTerminalsRequestEndSent = false, databaseDriverLoaded = false;

private FileOutputStream fileOutputStream;
private PrintStream printStreamReport;
private String sessionStart, sessionEnd;
private int limPerMin_Terminal;

private double tpmC;
private jTPCCRandom rnd;
private OSCollector osCollector = null;

public static void main(String args[])
{
PropertyConfigurator.configure("log4j.properties");
new jTPCC();
}

private String getProp (Properties p, String pName)
{
String prop = p.getProperty(pName);
log.info("Term-00, " + pName + "=" + prop);
return(prop);
}

public jTPCC()
{

// load the ini file
Properties ini = new Properties();
try {
ini.load( new FileInputStream(System.getProperty("prop")));
} catch (IOException e) {
errorMessage("Term-00, could not load properties file");
}

log.info("Term-00, ");
log.info("Term-00, +-------------------------------------------------------------+");
log.info("Term-00, BenchmarkSQL v" + JTPCCVERSION);
log.info("Term-00, +-------------------------------------------------------------+");
log.info("Term-00, (c) 2003, Raul Barbosa");
log.info("Term-00, (c) 2004-2016, Denis Lussier");
log.info("Term-00, (c) 2016, Jan Wieck");
log.info("Term-00, +-------------------------------------------------------------+");
log.info("Term-00, ");
String iDB = getProp(ini,"db");
String iDriver = getProp(ini,"driver");
String iConn = getProp(ini,"conn");
String iUser = getProp(ini,"user");
String iPassword = ini.getProperty("password");

log.info("Term-00, ");
String iWarehouses = getProp(ini,"warehouses");
String iTerminals = getProp(ini,"terminals");

String iRunTxnsPerTerminal = ini.getProperty("runTxnsPerTerminal");
String iRunMins = ini.getProperty("runMins");
if (Integer.parseInt(iRunTxnsPerTerminal) ==0 && Integer.parseInt(iRunMins)!=0){
log.info("Term-00, runMins" + "=" + iRunMins);
}else if(Integer.parseInt(iRunTxnsPerTerminal) !=0 && Integer.parseInt(iRunMins)==0){
log.info("Term-00, runTxnsPerTerminal" + "=" + iRunTxnsPerTerminal);
}else{
errorMessage("Term-00, Must indicate either transactions per terminal or number of run minutes!");
};
String limPerMin = getProp(ini,"limitTxnsPerMin");
String iTermWhseFixed = getProp(ini,"terminalWarehouseFixed");
log.info("Term-00, ");
String iNewOrderWeight = getProp(ini,"newOrderWeight");
String iPaymentWeight = getProp(ini,"paymentWeight");
String iOrderStatusWeight = getProp(ini,"orderStatusWeight");
String iDeliveryWeight = getProp(ini,"deliveryWeight");
String iStockLevelWeight = getProp(ini,"stockLevelWeight");

log.info("Term-00, ");
String resultDirectory = getProp(ini, "resultDirectory");
String osCollectorScript = getProp(ini, "osCollectorScript");

log.info("Term-00, ");

if (iDB.equals("firebird"))
dbType = DB_FIREBIRD;
else if (iDB.equals("oracle"))
dbType = DB_ORACLE;
else if (iDB.equals("postgres"))
dbType = DB_POSTGRES;
else if (iDB.equals("mysql"))
dbType = DB_MYSQL;
else
{
log.error("unknown database type '" + iDB + "'");
return;

修改benchmarksql-5.0/src/client/jTPCCConnection.java, SQL子查询增加”AS L”别名,如下所示:

[root@localhost benchmarksql-5.0]# vi src/client/jTPCCConnection.java
switch (dbType)
{
case jTPCCConfig.DB_POSTGRES:
stmtStockLevelSelectLow = dbConn.prepareStatement(
"SELECT count(*) AS low_stock FROM (" +
" SELECT s_w_id, s_i_id, s_quantity " +
" FROM bmsql_stock " +
" WHERE s_w_id = ? AND s_quantity < ? AND s_i_id IN (" +
" SELECT ol_i_id " +
" FROM bmsql_district " +
" JOIN bmsql_order_line ON ol_w_id = d_w_id " +
" AND ol_d_id = d_id " +
" AND ol_o_id >= d_next_o_id - 20 " +
" AND ol_o_id < d_next_o_id " +
" WHERE d_w_id = ? AND d_id = ? " +
" ) " +
" ) AS L");
break;

default:
stmtStockLevelSelectLow = dbConn.prepareStatement(
"SELECT count(*) AS low_stock FROM (" +
" SELECT s_w_id, s_i_id, s_quantity " +
" FROM bmsql_stock " +
" WHERE s_w_id = ? AND s_quantity < ? AND s_i_id IN (" +
" SELECT ol_i_id " +
" FROM bmsql_district " +
" JOIN bmsql_order_line ON ol_w_id = d_w_id " +
" AND ol_d_id = d_id " +
" AND ol_o_id >= d_next_o_id - 20 " +
" AND ol_o_id < d_next_o_id " +
" WHERE d_w_id = ? AND d_id = ? " +
" ) " +
" )AS L"); // " )");
break;
}

[root@localhost benchmarksql-5.0]# ant
Buildfile: /benchmarksql-5.0/build.xml

init:
[mkdir] Created dir: /benchmarksql-5.0/build

compile:
[javac] Compiling 11 source files to /benchmarksql-5.0/build
[javac] /benchmarksql-5.0/src/client/jTPCCRandom.java:143: : EUC_CN [javac] * be able to represent 128 different characters. '#@!%%???'
[javac] ^
[javac] /benchmarksql-5.0/src/client/jTPCCRandom.java:143: : EUC_CN [javac] * be able to represent 128 different characters. '#@!%%???'
[javac] ^
[javac] /benchmarksql-5.0/src/client/jTPCCRandom.java:143: : EUC_CN [javac] * be able to represent 128 different characters. '#@!%%???'
[javac] ^
[javac] 3

BUILD FAILED
/benchmarksql-5.0/build.xml:24: Compile failed; see the compiler error output for details.

Total time: 1 second

修改字符集

[root@localhost benchmarksql-5.0]# cat /etc/oracle-release
Oracle Linux Server release 7.6
[root@localhost benchmarksql-5.0]# locale
LANG=zh_CN.gb2312
LC_CTYPE="zh_CN.gb2312"
LC_NUMERIC="zh_CN.gb2312"
LC_TIME="zh_CN.gb2312"
LC_COLLATE="zh_CN.gb2312"
LC_MONETARY="zh_CN.gb2312"
LC_MESSAGES="zh_CN.gb2312"
LC_PAPER="zh_CN.gb2312"
LC_NAME="zh_CN.gb2312"
LC_ADDRESS="zh_CN.gb2312"
LC_TELEPHONE="zh_CN.gb2312"
LC_MEASUREMENT="zh_CN.gb2312"
LC_IDENTIFICATION="zh_CN.gb2312"
LC_ALL=
[root@localhost benchmarksql-5.0]# cat /etc/sysconfig/i18n
cat: /etc/sysconfig/i18n: ???
[root@localhost benchmarksql-5.0]# cat cat /etc/locale.conf
cat: cat: ???
#LANG="en_US.UTF-8"
LANG="zh_CN.gb2312"
[root@localhost benchmarksql-5.0]# cat /etc/locale.conf
#LANG="en_US.UTF-8"
LANG="zh_CN.gb2312"
[root@localhost benchmarksql-5.0]# vi /etc/locale.conf
LANG="en_US.UTF-8"
#LANG="zh_CN.gb2312"

[root@localhost benchmarksql-5.0]# ant
Buildfile: /benchmarksql-5.0/build.xml

init:

compile:
[javac] Compiling 11 source files to /benchmarksql-5.0/build

dist:
[mkdir] Created dir: /benchmarksql-5.0/dist
[jar] Building jar: /benchmarksql-5.0/dist/BenchmarkSQL-5.0.jar

BUILD SUCCESSFUL
Total time: 2 seconds

添加mysql java connector驱动,mysql-connector-java-5.1.49.zip 需自行下载。

[root@localhost benchmarksql-5.0]# cd lib
[root@localhost lib]# ls
apache-log4j-extras-1.1.jar firebird log4j-1.2.17.jar oracle postgres
[root@localhost lib]# ls -lrt
total 820
drwxr-xr-x. 2 root root 43 May 26 2016 postgres
drwxr-xr-x. 2 root root 40 May 26 2016 oracle
-rwxr-xr-x. 1 root root 489883 May 26 2016 log4j-1.2.17.jar
drwxr-xr-x. 2 root root 58 May 26 2016 firebird
-rwxr-xr-x. 1 root root 346729 May 26 2016 apache-log4j-extras-1.1.jar
[root@localhost lib]# mkdir mysql

[root@localhost /]# unzip mysql-connector-java-5.1.49.zip

[root@localhost mysql-connector-java-5.1.49]# cp mysql-connector-java-5.1.49.jar /benchmarksql-5.0/lib/mysql/

[root@localhost mysql]# pwd
/benchmarksql-5.0/lib/mysql
[root@localhost mysql]# ls -lrt
total 984
-rw-r--r--. 1 root root 1006904 Nov 11 16:39 mysql-connector-java-5.1.49.jar

修改benchmarksql-5.0/run/runDatabaseBuild.sh,去掉extraHistID

[root@localhost benchmarksql-5.0]# vi run/runDatabaseBuild.sh
#!/bin/sh

if [ $# -lt 1 ] ; then
echo "usage: $(basename $0) PROPS [OPT VAL [...]]" >&2
exit 2
fi

PROPS="$1"
shift
if [ ! -f "${PROPS}" ] ; then
echo "${PROPS}: no such file or directory" >&2
exit 1
fi
DB="$(grep '^db=' $PROPS | sed -e 's/^db=//')"

BEFORE_LOAD="tableCreates"
#AFTER_LOAD="indexCreates foreignKeys extraHistID buildFinish"
AFTER_LOAD="indexCreates foreignKeys buildFinish"

for step in ${BEFORE_LOAD} ; do
./runSQL.sh "${PROPS}" $step
done

./runLoader.sh "${PROPS}" $*

for step in ${AFTER_LOAD} ; do
./runSQL.sh "${PROPS}" $step
done

修改funcs.sh 增加 mysql 数据库类型的驱动类文件目录。

[root@localhost benchmarksql-5.0]# vi run/funcs.sh
# ----
# $1 is the properties file
# ----
PROPS=$1
if [ ! -f ${PROPS} ] ; then
echo "${PROPS}: no such file" >&2
exit 1
fi

# ----
# getProp()
#
# Get a config value from the properties file.
# ----
function getProp()
{
grep "^${1}=" ${PROPS} | sed -e "s/^${1}=//"
}

# ----
# getCP()
#
# Determine the CLASSPATH based on the database system.
# ----
function setCP()
{
case "$(getProp db)" in
firebird)
cp="../lib/firebird/*:../lib/*"
;;
oracle)
cp="../lib/oracle/*"
if [ ! -z "${ORACLE_HOME}" -a -d ${ORACLE_HOME}/lib ] ; then
cp="${cp}:${ORACLE_HOME}/lib/*"
fi
cp="${cp}:../lib/*"
;;
postgres)
cp="../lib/postgres/*:../lib/*"
;;
mysql)
cp="../lib/mysql/*:../lib/*"
;;
esac
myCP=".:${cp}:../dist/*"
export myCP
}

# ----
# Make sure that the properties file does have db= and the value
# is a database, we support.
# ----
case "$(getProp db)" in
firebird|oracle|postgres|mysql)
;;
"") echo "ERROR: missing db= config option in ${PROPS}" >&2
exit 1
;;
*) echo "ERROR: unsupported database type 'db=$(getProp db)' in ${PROPS}" >&2
exit 1
;;
esac
"run/funcs.sh" 63L, 1177C written

配置测试文件,输入连接地址与用户名

[root@localhost run]# vi props.mysql
db=mysql
driver=com.mysql.jdbc.Driver
conn=jdbc:mysql://127.0.0.1:3306/test?useServerPrepStmts=true&useConfigs=maxPerformance&rewriteBatchedStatements=true
user=root
password=xxzx7817600
warehouses=100
loadWorkers=40
terminals=32
//To run specified transactions per terminal- runMins must equal zero
runTxnsPerTerminal=0
//To run for specified minutes- runTxnsPerTerminal must equal zero
runMins=10
//Number of total transactions per minute
limitTxnsPerMin=0
//Set to true to run in 4.x compatible mode. Set to false to use the
//entire configured database evenly.
terminalWarehouseFixed=true
//The following five values must add up to 100
//The default percentages of 45, 43, 4, 4 & 4 match the TPC-C spec
newOrderWeight=45
paymentWeight=43
orderStatusWeight=4
deliveryWeight=4
stockLevelWeight=4
// Directory name to create for collecting detailed result data.
// Comment this out to suppress.
resultDirectory=my_result_%tY-%tm-%td_%tH%tM%tS
osCollectorScript=./misc/os_collector_linux.py
osCollectorInterval=1
//osCollectorSSHAddr=user@dbhost
//osCollectorDevices=net_eth0 blk_sda

[mysql@localhost run]$ ./runDatabaseBuild.sh prop.mysql
# ------------------------------------------------------------
# Loading SQL file ./sql.common/tableCreates.sql
# ------------------------------------------------------------
Fri Nov 11 16:57:18 CST 2022 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
Unknown database 'benchmarksql'
Starting BenchmarkSQL LoadData

driver=com.mysql.jdbc.Driver
conn=jdbc:mysql://127.0.0.1:3306/test?useServerPrepStmts=true&useConfigs=maxPerformance&rewriteBatchedStatements=true
user=root
password=***********
warehouses=100
loadWorkers=40
fileLocation (not defined)
csvNullValue (not defined - using default 'NULL')

Fri Nov 11 16:57:19 CST 2022 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
ERROR: Unknown database 'benchmarksql'
# ------------------------------------------------------------
# Loading SQL file ./sql.common/indexCreates.sql
# ------------------------------------------------------------
Fri Nov 11 16:57:20 CST 2022 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
Unknown database 'benchmarksql'
# ------------------------------------------------------------
# Loading SQL file ./sql.common/foreignKeys.sql
# ------------------------------------------------------------
Fri Nov 11 16:57:22 CST 2022 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
Unknown database 'benchmarksql'
# ------------------------------------------------------------
# Loading SQL file ./sql.common/buildFinish.sql
# ------------------------------------------------------------
Fri Nov 11 16:57:23 CST 2022 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
Unknown database 'benchmarksql'

不建议在没有服务器身份验证的情况下建立SSL连接。根据MySQL 5.5。45+, 5.6.26+和5.7。6+要求如果未设置显式选项,默认情况下必须建立SSL连接。为了符合不使用SSL的现有应用程序,verifyServerCertificate属性设置为“false”。您需要通过设置useSSL=false显式禁用SSL,或者设置useSSL=true并为服务器证书验证提供信任库。

解决方案:
在url后面加上?useSSL=false即可

jdbc:mysql://localhost:3306/userDb?useSSL=false
----------------
[mysql@localhost run]$ vi prop.mysql
db=mysql
driver=com.mysql.jdbc.Driver
conn=jdbc:mysql://127.0.0.1:3306/test?useSSL=false&useServerPrepStmts=true&useConfigs=maxPerformance&rewriteBatchedStatements=true
user=root
password=xxzx7817600
warehouses=100
loadWorkers=40
terminals=32
//To run specified transactions per terminal- runMins must equal zero
runTxnsPerTerminal=0
//To run for specified minutes- runTxnsPerTerminal must equal zero
runMins=10
//Number of total transactions per minute
limitTxnsPerMin=0
//Set to true to run in 4.x compatible mode. Set to false to use the
//entire configured database evenly.
terminalWarehouseFixed=true
//The following five values must add up to 100
//The default percentages of 45, 43, 4, 4 & 4 match the TPC-C spec
newOrderWeight=45
paymentWeight=43
orderStatusWeight=4
deliveryWeight=4
stockLevelWeight=4
// Directory name to create for collecting detailed result data.
// Comment this out to suppress.
resultDirectory=my_result_%tY-%tm-%td_%tH%tM%tS
osCollectorScript=./misc/os_collector_linux.py
osCollectorInterval=1
//osCollectorSSHAddr=user@dbhost
//osCollectorDevices=net_eth0 blk_sda

[mysql@localhost run]$ ./runDatabaseBuild.sh props.mysql
# ------------------------------------------------------------
# Loading SQL file ./sql.common/tableCreates.sql
# ------------------------------------------------------------
create table bmsql_config (
cfg_name varchar(30) primary key,
cfg_value varchar(50)
);
create table bmsql_warehouse (
w_id integer not null,
w_ytd decimal(12,2),
w_tax decimal(4,4),
w_name varchar(10),
w_street_1 varchar(20),
w_street_2 varchar(20),
w_city varchar(20),
w_state char(2),
w_zip char(9)
);
create table bmsql_district (
d_w_id integer not null,
d_id integer not null,
d_ytd decimal(12,2),
d_tax decimal(4,4),
d_next_o_id integer,
d_name varchar(10),
d_street_1 varchar(20),
d_street_2 varchar(20),
d_city varchar(20),
d_state char(2),
d_zip char(9)
);
create table bmsql_customer (
c_w_id integer not null,
c_d_id integer not null,
c_id integer not null,
c_discount decimal(4,4),
c_credit char(2),
c_last varchar(16),
c_first varchar(16),
c_credit_lim decimal(12,2),
c_balance decimal(12,2),
c_ytd_payment decimal(12,2),
c_payment_cnt integer,
c_delivery_cnt integer,
c_street_1 varchar(20),
c_street_2 varchar(20),
c_city varchar(20),
c_state char(2),
c_zip char(9),
c_phone char(16),
c_since timestamp,
c_middle char(2),
c_data varchar(500)
);
create sequence bmsql_hist_id_seq;
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'sequence bmsql_hist_id_seq' at line 1
create table bmsql_history (
hist_id integer,
h_c_id integer,
h_c_d_id integer,
h_c_w_id integer,
h_d_id integer,
h_w_id integer,
h_date timestamp,
h_amount decimal(6,2),
h_data varchar(24)
);
create table bmsql_new_order (
no_w_id integer not null,
no_d_id integer not null,
no_o_id integer not null
);
create table bmsql_oorder (
o_w_id integer not null,
o_d_id integer not null,
o_id integer not null,
o_c_id integer,
o_carrier_id integer,
o_ol_cnt integer,
o_all_local integer,
o_entry_d timestamp
);
create table bmsql_order_line (
ol_w_id integer not null,
ol_d_id integer not null,
ol_o_id integer not null,
ol_number integer not null,
ol_i_id integer not null,
ol_delivery_d timestamp,
ol_amount decimal(6,2),
ol_supply_w_id integer,
ol_quantity integer,
ol_dist_info char(24)
);
create table bmsql_item (
i_id integer not null,
i_name varchar(24),
i_price decimal(5,2),
i_data varchar(50),
i_im_id integer
);
create table bmsql_stock (
s_w_id integer not null,
s_i_id integer not null,
s_quantity integer,
s_ytd integer,
s_order_cnt integer,
s_remote_cnt integer,
s_data varchar(50),
s_dist_01 char(24),
s_dist_02 char(24),
s_dist_03 char(24),
s_dist_04 char(24),
s_dist_05 char(24),
s_dist_06 char(24),
s_dist_07 char(24),
s_dist_08 char(24),
s_dist_09 char(24),
s_dist_10 char(24)
);
Starting BenchmarkSQL LoadData

driver=com.mysql.jdbc.Driver
conn=jdbc:mysql://127.0.0.1:3306/test?useSSL=false&useServerPrepStmts=true&useConfigs=maxPerformance&rewriteBatchedStatements=true
user=root
password=***********
warehouses=100
loadWorkers=40
fileLocation (not defined)
csvNullValue (not defined - using default 'NULL')

Worker 000: Loading ITEM
Worker 001: Loading Warehouse 1
Worker 002: Loading Warehouse 2
Worker 003: Loading Warehouse 3
Worker 004: Loading Warehouse 4
Worker 005: Loading Warehouse 5
Worker 006: Loading Warehouse 6
Worker 007: Loading Warehouse 7
Worker 008: Loading Warehouse 8
Worker 010: Loading Warehouse 10
Worker 009: Loading Warehouse 9
Worker 011: Loading Warehouse 11
Worker 012: Loading Warehouse 12
Worker 013: Loading Warehouse 13
Worker 014: Loading Warehouse 14
Worker 015: Loading Warehouse 15
Worker 016: Loading Warehouse 16
Worker 017: Loading Warehouse 17
Worker 018: Loading Warehouse 18
Worker 019: Loading Warehouse 19
Worker 020: Loading Warehouse 20
Worker 021: Loading Warehouse 21
Worker 022: Loading Warehouse 22
Worker 023: Loading Warehouse 23
Worker 024: Loading Warehouse 24
Worker 025: Loading Warehouse 25
Worker 026: Loading Warehouse 26
Worker 027: Loading Warehouse 27
Worker 028: Loading Warehouse 28
Worker 029: Loading Warehouse 29
Worker 030: Loading Warehouse 30
Worker 032: Loading Warehouse 31
Worker 031: Loading Warehouse 32
Worker 033: Loading Warehouse 33
Worker 034: Loading Warehouse 34
Worker 035: Loading Warehouse 35
Worker 036: Loading Warehouse 36
Worker 037: Loading Warehouse 37
Worker 038: Loading Warehouse 38
Worker 039: Loading Warehouse 39
Worker 000: Loading ITEM done
Worker 000: Loading Warehouse 40
# ------------------------------------------------------------
# Loading SQL file ./sql.common/indexCreates.sql
# ------------------------------------------------------------
alter table bmsql_warehouse add constraint bmsql_warehouse_pkey
primary key (w_id);
alter table bmsql_district add constraint bmsql_district_pkey
primary key (d_w_id, d_id);
alter table bmsql_customer add constraint bmsql_customer_pkey
primary key (c_w_id, c_d_id, c_id);
create index bmsql_customer_idx1
on bmsql_customer (c_w_id, c_d_id, c_last, c_first);
alter table bmsql_oorder add constraint bmsql_oorder_pkey
primary key (o_w_id, o_d_id, o_id);
create unique index bmsql_oorder_idx1
on bmsql_oorder (o_w_id, o_d_id, o_carrier_id, o_id);
alter table bmsql_new_order add constraint bmsql_new_order_pkey
primary key (no_w_id, no_d_id, no_o_id);
alter table bmsql_order_line add constraint bmsql_order_line_pkey
primary key (ol_w_id, ol_d_id, ol_o_id, ol_number);
alter table bmsql_stock add constraint bmsql_stock_pkey
primary key (s_w_id, s_i_id);
alter table bmsql_item add constraint bmsql_item_pkey
primary key (i_id);
# ------------------------------------------------------------
# Loading SQL file ./sql.common/foreignKeys.sql
# ------------------------------------------------------------
alter table bmsql_district add constraint d_warehouse_fkey
foreign key (d_w_id)
references bmsql_warehouse (w_id);
alter table bmsql_customer add constraint c_district_fkey
foreign key (c_w_id, c_d_id)
references bmsql_district (d_w_id, d_id);
alter table bmsql_history add constraint h_customer_fkey
foreign key (h_c_w_id, h_c_d_id, h_c_id)
references bmsql_customer (c_w_id, c_d_id, c_id);
alter table bmsql_history add constraint h_district_fkey
foreign key (h_w_id, h_d_id)
references bmsql_district (d_w_id, d_id);
alter table bmsql_new_order add constraint no_order_fkey
foreign key (no_w_id, no_d_id, no_o_id)
references bmsql_oorder (o_w_id, o_d_id, o_id);
alter table bmsql_oorder add constraint o_customer_fkey
foreign key (o_w_id, o_d_id, o_c_id)
references bmsql_customer (c_w_id, c_d_id, c_id);
alter table bmsql_order_line add constraint ol_order_fkey
foreign key (ol_w_id, ol_d_id, ol_o_id)
references bmsql_oorder (o_w_id, o_d_id, o_id);
alter table bmsql_order_line add constraint ol_stock_fkey
foreign key (ol_supply_w_id, ol_i_id)
references bmsql_stock (s_w_id, s_i_id);
alter table bmsql_stock add constraint s_warehouse_fkey
foreign key (s_w_id)
references bmsql_warehouse (w_id);
alter table bmsql_stock add constraint s_item_fkey
foreign key (s_i_id)
references bmsql_item (i_id);
# ------------------------------------------------------------
# Loading SQL file ./sql.common/buildFinish.sql
# ------------------------------------------------------------
-- ----
-- Extra commands to run after the tables are created, loaded,
-- indexes built and extra's created.
-- ----

[mysql@localhost run]$ ./runBenchmark.sh props.mysql
09:25:48,374 [main] INFO jTPCC : Term-00,
09:25:48,379 [main] INFO jTPCC : Term-00, +-------------------------------------------------------------+
09:25:48,379 [main] INFO jTPCC : Term-00, BenchmarkSQL v5.0
09:25:48,379 [main] INFO jTPCC : Term-00, +-------------------------------------------------------------+
09:25:48,379 [main] INFO jTPCC : Term-00, (c) 2003, Raul Barbosa
09:25:48,379 [main] INFO jTPCC : Term-00, (c) 2004-2016, Denis Lussier
09:25:48,384 [main] INFO jTPCC : Term-00, (c) 2016, Jan Wieck
09:25:48,385 [main] INFO jTPCC : Term-00, +-------------------------------------------------------------+
09:25:48,385 [main] INFO jTPCC : Term-00,
09:25:48,385 [main] INFO jTPCC : Term-00, db=mysql
09:25:48,385 [main] INFO jTPCC : Term-00, driver=com.mysql.jdbc.Driver
09:25:48,385 [main] INFO jTPCC : Term-00, conn=jdbc:mysql://127.0.0.1:3306/test?useSSL=false
09:25:48,385 [main] INFO jTPCC : Term-00, user=root
09:25:48,386 [main] INFO jTPCC : Term-00,
09:25:48,386 [main] INFO jTPCC : Term-00, warehouses=40
09:25:48,386 [main] INFO jTPCC : Term-00, terminals=10
09:25:48,388 [main] INFO jTPCC : Term-00, runMins=10
09:25:48,388 [main] INFO jTPCC : Term-00, limitTxnsPerMin=0
09:25:48,388 [main] INFO jTPCC : Term-00, terminalWarehouseFixed=true
09:25:48,389 [main] INFO jTPCC : Term-00,
09:25:48,389 [main] INFO jTPCC : Term-00, newOrderWeight=45
09:25:48,389 [main] INFO jTPCC : Term-00, paymentWeight=43
09:25:48,389 [main] INFO jTPCC : Term-00, orderStatusWeight=4
09:25:48,389 [main] INFO jTPCC : Term-00, deliveryWeight=4
09:25:48,389 [main] INFO jTPCC : Term-00, stockLevelWeight=4
09:25:48,389 [main] INFO jTPCC : Term-00,
09:25:48,389 [main] INFO jTPCC : Term-00, resultDirectory=my_result_%tY-%tm-%td_%tH%tM%tS
09:25:48,390 [main] INFO jTPCC : Term-00, osCollectorScript=./misc/os_collector_linux.py
09:25:48,390 [main] INFO jTPCC : Term-00,
09:25:48,529 [main] INFO jTPCC : Term-00, copied props.mysql to my_result_2022-11-14_092548/run.properties
09:25:48,529 [main] INFO jTPCC : Term-00, created my_result_2022-11-14_092548/data/runInfo.csv for runID 5
09:25:48,530 [main] INFO jTPCC : Term-00, writing per transaction results to my_result_2022-11-14_092548/data/result.csv
09:25:48,531 [main] INFO jTPCC : Term-00, osCollectorScript=./misc/os_collector_linux.py
09:25:48,532 [main] INFO jTPCC : Term-00, osCollectorInterval=1
09:25:48,532 [main] INFO jTPCC : Term-00, osCollectorSSHAddr=null
09:25:48,532 [main] INFO jTPCC : Term-00, osCollectorDevices=null
09:25:48,684 [main] INFO jTPCC : Term-00,
09:25:49,097 [main] INFO jTPCC : Term-00, C value for C_LAST during load: 182
09:25:49,098 [main] INFO jTPCC : Term-00, C value for C_LAST this run: 253
09:25:49,098 [main] INFO jTPCC : Term-00,
Term-00, Running Average tpmTOTAL: 32447.84 Current tpmTOTAL: 2146668 Memory Usage: 143MB / 203MB
09:35:49,526 [Thread-6] INFO jTPCC : Term-00,
09:35:49,526 [Thread-6] INFO jTPCC : Term-00,
09:35:49,527 [Thread-6] INFO jTPCC : Term-00, Measured tpmC (NewOrders) = 14913.98
09:35:49,527 [Thread-6] INFO jTPCC : Term-00, Measured tpmTOTAL = 32102.08
09:35:49,527 [Thread-6] INFO jTPCC : Term-00, Session Start = 2022-11-14 09:25:49
09:35:49,528 [Thread-6] INFO jTPCC : Term-00, Session End = 2022-11-14 09:35:49
09:35:49,528 [Thread-6] INFO jTPCC : Term-00, Transaction Count = 321069

]]>
http://www.jydba.net/index.php/archives/3439/feed 0
sysbench 测试MySQL http://www.jydba.net/index.php/archives/3432 http://www.jydba.net/index.php/archives/3432#respond Mon, 14 Nov 2022 01:02:23 +0000 http://www.jydba.net/?p=3432 sysbench 测试MySQL
1. 安装sysbench

https://github.com/akopytov/sysbench.git # 通过git clone得到源码

sftp> cd /soft
sftp> pwd
/soft
sftp> ls
boost_1_59_0          boost_1_59_0.zip      docker-17.03.0-ce.tgz
employees_db          employees_db-full-1.0.6.tar.bz2
libpcap-1.10.1        libpcap-1.10.1.tar.gz mysql-5.7.26
mysql-5.7.26.tar.gz   mysql-utilities-1.6.5 mysql-utilities-1.6.5.tar.gz
ngrep                 ngrep-master.zip      sg3_utils-1.41-1.x86_64.rpm
sg3_utils-libs-1.41-1.x86_64.rpm
sftp> lcd F:\
sftp> put sysbench-master.zip
Uploading sysbench-master.zip to /soft/sysbench-master.zip
  100% 2220KB   2220KB/s 00:00:00
F:/sysbench-master.zip: 2274128 bytes transferred in 0 seconds (2220 KB/s)

[root@localhost soft]# unzip sysbench-master.zip
[root@localhost soft]# mv sysbench-master sysbench

[root@localhost sysbench]# ./autogen.sh
autoreconf: Entering directory `.'
autoreconf: configure.ac: not using Gettext
autoreconf: running: aclocal -I m4
autoreconf: configure.ac: tracing
autoreconf: running: libtoolize --copy
libtoolize: putting auxiliary files in AC_CONFIG_AUX_DIR, `config'.
libtoolize: copying file `config/ltmain.sh'
libtoolize: putting macros in AC_CONFIG_MACRO_DIR, `m4'.
libtoolize: copying file `m4/libtool.m4'
libtoolize: copying file `m4/ltoptions.m4'
libtoolize: copying file `m4/ltsugar.m4'
libtoolize: copying file `m4/ltversion.m4'
libtoolize: copying file `m4/lt~obsolete.m4'
autoreconf: running: /usr/bin/autoconf
autoreconf: running: /usr/bin/autoheader
autoreconf: running: automake --add-missing --copy --no-force
configure.ac:59: installing 'config/ar-lib'
configure.ac:45: installing 'config/compile'
configure.ac:27: installing 'config/config.guess'
configure.ac:27: installing 'config/config.sub'
configure.ac:32: installing 'config/install-sh'
configure.ac:32: installing 'config/missing'
src/Makefile.am: installing 'config/depcomp'
parallel-tests: installing 'config/test-driver'
autoreconf: Leaving directory `.'

关联mysql的头文件和库

[root@localhost sysbench]# ./configure  --with-mysql-includes=/mysqlsoft/mysql/include/  --with-mysql-libs=/mysqlsoft/mysql/lib/
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking for style of include used by make... GNU
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking dependency style of gcc... gcc3
checking how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking minix/config.h usability... no
checking minix/config.h presence... no
checking for minix/config.h... no
checking whether it is safe to define __EXTENSIONS__... yes
checking for gcc... (cached) gcc
checking whether we are using the GNU C compiler... (cached) yes
checking whether gcc accepts -g... (cached) yes
checking for gcc option to accept ISO C89... (cached) none needed
checking dependency style of gcc... (cached) gcc3
checking for gcc option to accept ISO C99... -std=gnu99
checking how to run the C preprocessor... gcc -E
checking whether gcc -std=gnu99 and cc understand -c and -o together... yes
checking for a sed that does not truncate output... /usr/bin/sed
checking for C compiler vendor... gnu
checking for gcc architecture flag...
checking for x86 cpuid 0 output... d:756e6547:6c65746e:49656e69
checking for x86 cpuid 1 output... 306e7:2040800:9e982203:1fabfbff
checking whether C compiler accepts -march=ivybridge... no
checking whether C compiler accepts -march=core-avx-i... yes
checking for gcc architecture flag... -march=core-avx-i
checking for ar... ar
checking the archiver (ar) interface... ar
checking how to print strings... printf
checking for a sed that does not truncate output... (cached) /usr/bin/sed
checking for fgrep... /usr/bin/grep -F
checking for ld used by gcc -std=gnu99... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 1572864
checking whether the shell understands some XSI constructs... yes
checking whether the shell understands "+="... yes
checking how to convert x86_64-unknown-linux-gnu file names to x86_64-unknown-linux-gnu format... func_convert_file_noop
checking how to convert x86_64-unknown-linux-gnu file names to toolchain format... func_convert_file_noop
checking for /usr/bin/ld option to reload object files... -r
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for dlltool... no
checking how to associate runtime and link libraries... printf %s\n
checking for archiver @FILE support... @
checking for strip... strip
checking for ranlib... ranlib
checking command to parse /usr/bin/nm -B output from gcc -std=gnu99 object... ok
checking for sysroot... no
checking for mt... mt
checking if mt is a manifest tool... no
checking for dlfcn.h... yes
checking for objdir... .libs
checking if gcc -std=gnu99 supports -fno-rtti -fno-exceptions... no
checking for gcc -std=gnu99 option to produce PIC... -fPIC -DPIC
checking if gcc -std=gnu99 PIC flag -fPIC -DPIC works... yes
checking if gcc -std=gnu99 static flag -static works... no
checking if gcc -std=gnu99 supports -c -o file.o... yes
checking if gcc -std=gnu99 supports -c -o file.o... (cached) yes
checking whether the gcc -std=gnu99 linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
checking for pkg-config... yes
checking for C compiler vendor... (cached) gnu
checking whether to compile with MySQL support... yes
checking whether to compile with PostgreSQL support... no
checking for pkg-config... /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking whether to build with system or bundled LuaJIT... bundled
checking whether to build with system or bundled Concurrency Kit... bundled
checking whether SHM_HUGETLB is declared... yes
checking whether O_SYNC is declared... yes
checking for the pthreads library -lpthreads... no
checking whether pthreads work without any flags... no
checking whether pthreads work with -Kthread... no
checking whether pthreads work with -kthread... no
checking for the pthreads library -llthread... no
checking whether pthreads work with -pthread... yes
checking for joinable pthread attribute... PTHREAD_CREATE_JOINABLE
checking if more special flags are required for pthreads... no
checking for sqrt in -lm... yes
checking MySQL includes... (cached) /mysqlsoft/mysql/include/
checking MySQL libraries... (cached) /mysqlsoft/mysql/lib/
checking for library containing mysql_real_connect... -lmysqlclient
checking if mysql.h defines MYSQL_OPT_SSL_MODE... yes
checking libaio.h usability... no
checking libaio.h presence... no
checking for libaio.h... no
checking for ANSI C header files... (cached) yes
checking errno.h usability... yes
checking errno.h presence... yes
checking for errno.h... yes
checking fcntl.h usability... yes
checking fcntl.h presence... yes
checking for fcntl.h... yes
checking math.h usability... yes
checking math.h presence... yes
checking for math.h... yes
checking pthread.h usability... yes
checking pthread.h presence... yes
checking for pthread.h... yes
checking sched.h usability... yes
checking sched.h presence... yes
checking for sched.h... yes
checking signal.h usability... yes
checking signal.h presence... yes
checking for signal.h... yes
checking for stdlib.h... (cached) yes
checking for string.h... (cached) yes
checking sys/aio.h usability... no
checking sys/aio.h presence... no
checking for sys/aio.h... no
checking sys/ipc.h usability... yes
checking sys/ipc.h presence... yes
checking for sys/ipc.h... yes
checking sys/time.h usability... yes
checking sys/time.h presence... yes
checking for sys/time.h... yes
checking sys/mman.h usability... yes
checking sys/mman.h presence... yes
checking for sys/mman.h... yes
checking sys/shm.h usability... yes
checking sys/shm.h presence... yes
checking for sys/shm.h... yes
checking thread.h usability... no
checking thread.h presence... no
checking for thread.h... no
checking for unistd.h... (cached) yes
checking limits.h usability... yes
checking limits.h presence... yes
checking for limits.h... yes
checking libgen.h usability... yes
checking libgen.h presence... yes
checking for libgen.h... yes
checking for off_t... yes
checking whether time.h and sys/time.h may both be included... yes
checking for thread local storage (TLS) class... __thread
checking for __attribute__((format))... yes
checking for __attribute__((unused))... yes
checking for special C compiler options needed for large files... no
checking for _FILE_OFFSET_BITS value needed for large files... no
checking size of size_t... 8
checking size of bool... 1
checking for stdlib.h... (cached) yes
checking for unistd.h... (cached) yes
checking for sys/param.h... yes
checking for getpagesize... yes
checking for working mmap... yes
checking whether strerror_r is declared... yes
checking for strerror_r... yes
checking whether strerror_r returns char *... yes
checking for library containing clock_gettime... none required
checking for alarm... yes
checking for clock_gettime... yes
checking for directio... no
checking for fdatasync... yes
checking for gettimeofday... yes
checking for isatty... yes
checking for memalign... yes
checking for memset... yes
checking for posix_memalign... yes
checking for pthread_cancel... yes
checking for pthread_yield... yes
checking for setvbuf... yes
checking for sqrt... yes
checking for strdup... yes
checking for thr_setconcurrency... no
checking for valloc... yes
checking for pthread_once... yes
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating third_party/luajit/Makefile
config.status: creating third_party/concurrency_kit/Makefile
config.status: creating src/Makefile
config.status: creating src/drivers/Makefile
config.status: creating src/drivers/mysql/Makefile
config.status: creating src/drivers/pgsql/Makefile
config.status: creating src/tests/Makefile
config.status: creating src/tests/cpu/Makefile
config.status: creating src/tests/fileio/Makefile
config.status: creating src/tests/memory/Makefile
config.status: creating src/tests/threads/Makefile
config.status: creating src/tests/mutex/Makefile
config.status: creating src/lua/Makefile
config.status: creating src/lua/internal/Makefile
config.status: creating tests/Makefile
config.status: creating tests/include/config.sh
config.status: creating snap/snapcraft.yaml
config.status: creating config/config.h
config.status: executing depfiles commands
config.status: executing libtool commands
===============================================================================
sysbench version   : 1.1.0
CC                 : gcc -std=gnu99
CFLAGS             : -O3 -funroll-loops -ggdb3  -march=core-avx-i -Wall -Wextra -Wpointer-arith -Wbad-function-cast -Wstrict-prototypes -Wnested-externs -Wno-format-zero-length -Wundef -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wcast-align -Wvla   -pthread
CPPFLAGS           : -D_GNU_SOURCE   -I$(top_srcdir)/src -I$(abs_top_builddir)/third_party/luajit/inc -I$(abs_top_builddir)/third_party/concurrency_kit/include
LDFLAGS            : -L/usr/local/lib
LIBS               : -lm

prefix             : /usr/local
bindir             : ${prefix}/bin
libexecdir         : ${prefix}/libexec
mandir             : ${prefix}/share/man
datadir            : ${prefix}/share

MySQL support      : yes
PostgreSQL support : no

LuaJIT             : bundled
LUAJIT_CFLAGS      : -I$(abs_top_builddir)/third_party/luajit/inc
LUAJIT_LIBS        : $(abs_top_builddir)/third_party/luajit/lib/libluajit-5.1.a -ldl
LUAJIT_LDFLAGS     : -rdynamic

Concurrency Kit    : bundled
CK_CFLAGS          : -I$(abs_top_builddir)/third_party/concurrency_kit/include
CK_LIBS            : $(abs_top_builddir)/third_party/concurrency_kit/lib/libck.a
configure flags    :
===============================================================================

源码编译
make -j 4 # -j 4 表示用几个cpu核心进行编译

[root@localhost sysbench]# make -j 4

安装
make install # 默认安装到 /usr/local/bin , 如果有自定义目录,configure增加参数 –prefix=自定义目录

[root@localhost sysbench]# make install

添加LD_LIBRARY_PATH

[root@localhost ~]# echo "export LD_LIBRARY_PATH=/mysqlsoft/mysql/lib/:$LD_LIBRARY_PATH" >> ~/.bashrc
[root@localhost ~]# source ~/.bashrc
[root@localhost ~]# sysbench --version
sysbench 1.1.0
< ?pre>

3. 测试
[mysql@localhost lua]$ ./sysbench oltp_read_write.lua --mysql-host=127.0.0.1 --mysql-port=3306 --mysql-db=test --mysql-user=root --mysql-password=abcd1234 --table_size=250000 --tables=125 --threads=32 --events=0 --report-interval=1 --time=600 prepare
./sysbench: error while loading shared libraries: libmysqlclient.so.20: cannot open shared object file: No such file or directory

字面意思就是打不到共享库文件libmysqlclient.so.20.

查找一下本地有没有这个文件

[root@localhost ~]# find / -name 'libmysqlclient*'
/soft/mysql-5.7.26/libmysql/libmysqlclient.so.20.3.13
/soft/mysql-5.7.26/libmysql/libmysqlclient.so.20
/soft/mysql-5.7.26/libmysql/libmysqlclient.so
/soft/mysql-5.7.26/packaging/deb-in/libmysqlclient-dev.install.in
/soft/mysql-5.7.26/packaging/deb-in/libmysqlclient-dev.lintian-overrides.in
/soft/mysql-5.7.26/packaging/deb-in/libmysqlclient20-dbgsym.install.in
/soft/mysql-5.7.26/packaging/deb-in/libmysqlclient20.install.in
/soft/mysql-5.7.26/packaging/deb-in/libmysqlclient20.lintian-overrides.in
/soft/mysql-5.7.26/archive_output_directory/libmysqlclient.a
/mysqlsoft/mysql/lib/libmysqlclient.a
/mysqlsoft/mysql/lib/libmysqlclient.so.20.3.13
/mysqlsoft/mysql/lib/libmysqlclient.so.20
/mysqlsoft/mysql/lib/libmysqlclient.so

在/mysqlsoft/mysql/lib/下面有这个文件,解决方法是先建立一个软链接到/usr/local/lib

[root@localhost ~]# ln -s /mysqlsoft/mysql/lib/libmysqlclient.so.20 /usr/local/lib/libmysqlclient.so.20

接着在/etc/ld.so.cnf中加入/usr/loca/lib这一行

[root@localhost ~]# vi /etc/ld.so.conf
include ld.so.conf.d/*.conf
/usr/loca/lib

执行/sbin/ldconfig -v更新下配置就可以了

[root@localhost ~]# /sbin/ldconfig -v
..........省略...........
        libfreeblpriv3.so -> libfreeblpriv3.so
        libncurses++.so.5 -> libncurses++.so.5.9
        libfreebl3.so -> libfreebl3.so
        libmenuw.so.5 -> libmenuw.so.5.9
        libgcc_s.so.1 -> libgcc_s-4.8.5-20150702.so.1
        libmenu.so.5 -> libmenu.so.5.9
        libdtrace-ctf.so.1 -> libdtrace-ctf.so.1.5.0
        libuuid.so.1 -> libuuid.so.1.3.0
/lib/sse2: (hwcap: 0x0000000004000000)
/lib64/sse2: (hwcap: 0x0000000004000000)
/lib64/tls: (hwcap: 0x8000000000000000)


重新运行生成测试数据脚本

[mysql@localhost lua]$ ./sysbench oltp_read_write.lua --mysql-host=127.0.0.1 --mysql-port=3306 --mysql-db=test --mysql-user=root --mysql-password=abcd1234 --table_size=250000 --tables=25 --threads=32 --events=0 --report-interval=1 --time=600 prepare
sysbench 1.1.0 (using bundled LuaJIT 2.1.0-beta3)

Initializing worker threads...

Creating table 'sbtest14'...Creating table 'sbtest10'...Creating table 'sbtest11'...Creating table 'sbtest9'...Creating table 'sbtest4'...Creating table 'sbtest6'...Creating table 'sbtest24'...Creating table 'sbtest3'...Creating table 'sbtest1'...Creating table 'sbtest25'...Creating table 'sbtest5'...Creating table 'sbtest15'...Creating table 'sbtest7'...Creating table 'sbtest16'...Creating table 'sbtest2'...Creating table 'sbtest8'...












Creating table 'sbtest18'...

Creating table 'sbtest13'...


Creating table 'sbtest23'...
Creating table 'sbtest17'...
Creating table 'sbtest20'...
Creating table 'sbtest21'...
Creating table 'sbtest12'...
Creating table 'sbtest19'...
Creating table 'sbtest22'...
Inserting 250000 records into 'sbtest13'
Inserting 250000 records into 'sbtest23'
Inserting 250000 records into 'sbtest3'
Inserting 250000 records into 'sbtest16'
Inserting 250000 records into 'sbtest11'
Inserting 250000 records into 'sbtest2'
Inserting 250000 records into 'sbtest10'
Inserting 250000 records into 'sbtest22'
Inserting 250000 records into 'sbtest9'
Inserting 250000 records into 'sbtest5'
Inserting 250000 records into 'sbtest7'
Inserting 250000 records into 'sbtest14'
Inserting 250000 records into 'sbtest15'
Inserting 250000 records into 'sbtest25'
Inserting 250000 records into 'sbtest18'
Inserting 250000 records into 'sbtest24'
Inserting 250000 records into 'sbtest21'
Inserting 250000 records into 'sbtest1'
Inserting 250000 records into 'sbtest17'
Inserting 250000 records into 'sbtest20'
Inserting 250000 records into 'sbtest8'
Inserting 250000 records into 'sbtest4'
Inserting 250000 records into 'sbtest19'
Inserting 250000 records into 'sbtest12'
Inserting 250000 records into 'sbtest6'
Creating a secondary index on 'sbtest2'...
Creating a secondary index on 'sbtest4'...
Creating a secondary index on 'sbtest3'...
Creating a secondary index on 'sbtest25'...
Creating a secondary index on 'sbtest11'...
Creating a secondary index on 'sbtest16'...
Creating a secondary index on 'sbtest13'...
Creating a secondary index on 'sbtest20'...
Creating a secondary index on 'sbtest7'...
Creating a secondary index on 'sbtest12'...
Creating a secondary index on 'sbtest17'...
Creating a secondary index on 'sbtest10'...
Creating a secondary index on 'sbtest6'...
Creating a secondary index on 'sbtest8'...
Creating a secondary index on 'sbtest1'...
Creating a secondary index on 'sbtest5'...
Creating a secondary index on 'sbtest9'...
Creating a secondary index on 'sbtest18'...
Creating a secondary index on 'sbtest19'...
Creating a secondary index on 'sbtest15'...
Creating a secondary index on 'sbtest24'...
Creating a secondary index on 'sbtest21'...
Creating a secondary index on 'sbtest14'...
Creating a secondary index on 'sbtest23'...
Creating a secondary index on 'sbtest22'...

运行测试脚本

[mysql@localhost lua]$ ./sysbench oltp_read_write.lua --mysql-host=127.0.0.1 --mysql-port=3306 --mysql-db=test --mysql-user=root --mysql-password=abcd1234 --table_size=250000 --tables=25 --threads=32 --events=0 --report-interval=1 --time=600 --percentile=95 --report-interval=1 run
sysbench 1.1.0 (using bundled LuaJIT 2.1.0-beta3)

Running the test with following options:
Number of threads: 32
Report intermediate results every 1 second(s)
Initializing random number generator from current time


Initializing worker threads...

Threads started!

[ 1s ] thds: 32 tps: 420.88 qps: 8842.27 (r/w/o: 6223.49/1745.85/872.93) lat (ms,95%): 132.49 err/s: 0.00 reconn/s: 0.00
[ 2s ] thds: 32 tps: 440.30 qps: 8782.91 (r/w/o: 6165.15/1739.17/878.59) lat (ms,95%): 132.49 err/s: 0.00 reconn/s: 0.00
[ 3s ] thds: 32 tps: 446.97 qps: 9031.33 (r/w/o: 6325.53/1809.87/895.93) lat (ms,95%): 127.81 err/s: 0.00 reconn/s: 0.00
[ 4s ] thds: 32 tps: 460.97 qps: 9095.42 (r/w/o: 6349.60/1826.88/918.94) lat (ms,95%): 132.49 err/s: 0.00 reconn/s: 0.00
[ 5s ] thds: 32 tps: 449.06 qps: 8969.11 (r/w/o: 6266.78/1801.22/901.11) lat (ms,95%): 123.28 err/s: 0.00 reconn/s: 0.00
[ 6s ] thds: 32 tps: 450.00 qps: 9064.95 (r/w/o: 6361.97/1802.99/900.00) lat (ms,95%): 118.92 err/s: 0.00 reconn/s: 0.00
[ 7s ] thds: 32 tps: 449.53 qps: 9007.52 (r/w/o: 6333.33/1776.13/898.05) lat (ms,95%): 123.28 err/s: 0.00 reconn/s: 0.00
[ 8s ] thds: 32 tps: 446.41 qps: 8827.02 (r/w/o: 6163.60/1769.61/893.81) lat (ms,95%): 121.08 err/s: 0.00 reconn/s: 0.00
[ 9s ] thds: 32 tps: 414.03 qps: 8322.70 (r/w/o: 5808.49/1686.14/828.07) lat (ms,95%): 127.81 err/s: 0.00 reconn/s: 0.00
[ 10s ] thds: 32 tps: 415.00 qps: 8302.07 (r/w/o: 5824.05/1648.01/830.01) lat (ms,95%): 132.49 err/s: 0.00 reconn/s: 0.00
[ 11s ] thds: 32 tps: 440.56 qps: 8794.13 (r/w/o: 6155.79/1757.23/881.11) lat (ms,95%): 121.08 err/s: 0.00 reconn/s: 0.00
[ 12s ] thds: 32 tps: 392.43 qps: 7793.52 (r/w/o: 5465.98/1542.69/784.86) lat (ms,95%): 132.49 err/s: 0.00 reconn/s: 0.00
[ 13s ] thds: 32 tps: 216.97 qps: 4355.35 (r/w/o: 3034.55/886.87/433.94) lat (ms,95%): 363.18 err/s: 0.00 reconn/s: 0.00
[ 14s ] thds: 32 tps: 192.01 qps: 3796.14 (r/w/o: 2662.10/750.03/384.01) lat (ms,95%): 397.39 err/s: 0.00 reconn/s: 0.00
[ 15s ] thds: 32 tps: 86.00 qps: 1767.09 (r/w/o: 1249.06/346.02/172.01) lat (ms,95%): 511.33 err/s: 0.00 reconn/s: 0.00
[ 16s ] thds: 32 tps: 71.00 qps: 1421.09 (r/w/o: 994.07/285.02/142.01) lat (ms,95%): 977.74 err/s: 0.00 reconn/s: 0.00
[ 17s ] thds: 32 tps: 115.98 qps: 2316.68 (r/w/o: 1620.78/463.94/231.97) lat (ms,95%): 646.19 err/s: 0.00 reconn/s: 0.00
[ 18s ] thds: 32 tps: 115.96 qps: 2267.18 (r/w/o: 1575.43/459.83/231.92) lat (ms,95%): 682.06 err/s: 0.00 reconn/s: 0.00
[ 19s ] thds: 32 tps: 120.06 qps: 2454.22 (r/w/o: 1727.86/486.24/240.12) lat (ms,95%): 493.24 err/s: 0.00 reconn/s: 0.00
[ 20s ] thds: 32 tps: 91.00 qps: 1779.97 (r/w/o: 1234.98/362.99/182.00) lat (ms,95%): 694.45 err/s: 0.00 reconn/s: 0.00
[ 21s ] thds: 32 tps: 47.99 qps: 966.87 (r/w/o: 678.91/191.97/95.99) lat (ms,95%): 1069.86 err/s: 0.00 reconn/s: 0.00
[ 22s ] thds: 32 tps: 65.01 qps: 1283.20 (r/w/o: 895.14/258.04/130.02) lat (ms,95%): 1149.76 err/s: 0.00 reconn/s: 0.00
[ 23s ] thds: 32 tps: 30.99 qps: 659.69 (r/w/o: 478.77/118.94/61.97) lat (ms,95%): 1032.01 err/s: 0.00 reconn/s: 0.00
[ 24s ] thds: 32 tps: 90.03 qps: 1850.71 (r/w/o: 1295.50/375.14/180.07) lat (ms,95%): 1352.03 err/s: 0.00 reconn/s: 0.00
[ 25s ] thds: 32 tps: 77.01 qps: 1500.11 (r/w/o: 1041.07/305.02/154.01) lat (ms,95%): 773.68 err/s: 0.00 reconn/s: 0.00
[ 26s ] thds: 32 tps: 90.00 qps: 1741.99 (r/w/o: 1212.00/350.00/180.00) lat (ms,95%): 450.77 err/s: 0.00 reconn/s: 0.00
[ 27s ] thds: 32 tps: 31.00 qps: 685.98 (r/w/o: 493.99/130.00/62.00) lat (ms,95%): 1453.01 err/s: 0.00 reconn/s: 0.00
[ 28s ] thds: 32 tps: 56.00 qps: 1068.04 (r/w/o: 736.03/220.01/112.00) lat (ms,95%): 1376.60 err/s: 0.00 reconn/s: 0.00
[ 29s ] thds: 32 tps: 36.00 qps: 752.99 (r/w/o: 535.00/146.00/72.00) lat (ms,95%): 1304.21 err/s: 0.00 reconn/s: 0.00
[ 30s ] thds: 32 tps: 32.00 qps: 621.99 (r/w/o: 432.00/126.00/64.00) lat (ms,95%): 1589.90 err/s: 0.00 reconn/s: 0.00
[ 31s ] thds: 32 tps: 26.00 qps: 541.01 (r/w/o: 379.01/110.00/52.00) lat (ms,95%): 1903.57 err/s: 0.00 reconn/s: 0.00
[ 32s ] thds: 32 tps: 23.00 qps: 429.00 (r/w/o: 296.00/87.00/46.00) lat (ms,95%): 1739.68 err/s: 0.00 reconn/s: 0.00
[ 33s ] thds: 32 tps: 16.00 qps: 347.00 (r/w/o: 253.00/62.00/32.00) lat (ms,95%): 1938.16 err/s: 0.00 reconn/s: 0.00
[ 34s ] thds: 32 tps: 54.00 qps: 1120.99 (r/w/o: 778.99/234.00/108.00) lat (ms,95%): 2539.17 err/s: 0.00 reconn/s: 0.00
[ 35s ] thds: 32 tps: 363.96 qps: 7212.21 (r/w/o: 5042.45/1441.84/727.92) lat (ms,95%): 164.45 err/s: 0.00 reconn/s: 0.00
[ 36s ] thds: 32 tps: 362.04 qps: 7243.81 (r/w/o: 5077.57/1442.16/724.08) lat (ms,95%): 164.45 err/s: 0.00 reconn/s: 0.00
[ 37s ] thds: 32 tps: 352.90 qps: 7110.99 (r/w/o: 4988.59/1416.60/705.80) lat (ms,95%): 158.63 err/s: 0.00 reconn/s: 0.00
[ 38s ] thds: 32 tps: 363.75 qps: 7270.06 (r/w/o: 5074.59/1467.97/727.50) lat (ms,95%): 155.80 err/s: 0.00 reconn/s: 0.00
[ 39s ] thds: 32 tps: 372.75 qps: 7467.08 (r/w/o: 5229.56/1493.02/744.50) lat (ms,95%): 155.80 err/s: 0.00 reconn/s: 0.00
[ 40s ] thds: 32 tps: 296.80 qps: 5913.04 (r/w/o: 4137.23/1181.21/594.60) lat (ms,95%): 186.54 err/s: 0.00 reconn/s: 0.00
[ 41s ] thds: 32 tps: 356.77 qps: 7188.59 (r/w/o: 5033.92/1441.13/713.55) lat (ms,95%): 158.63 err/s: 0.00 reconn/s: 0.00
[ 42s ] thds: 32 tps: 377.95 qps: 7489.91 (r/w/o: 5230.24/1503.78/755.89) lat (ms,95%): 142.39 err/s: 0.00 reconn/s: 0.00
[ 43s ] thds: 32 tps: 382.97 qps: 7599.32 (r/w/o: 5316.52/1518.86/763.93) lat (ms,95%): 153.02 err/s: 0.00 reconn/s: 0.00
[ 44s ] thds: 32 tps: 378.08 qps: 7641.59 (r/w/o: 5358.11/1526.32/757.16) lat (ms,95%): 144.97 err/s: 0.00 reconn/s: 0.00
[ 45s ] thds: 32 tps: 388.08 qps: 7789.51 (r/w/o: 5458.05/1554.30/777.15) lat (ms,95%): 142.39 err/s: 0.00 reconn/s: 0.00
[ 46s ] thds: 32 tps: 398.74 qps: 7983.89 (r/w/o: 5595.42/1590.98/797.49) lat (ms,95%): 132.49 err/s: 0.00 reconn/s: 0.00
[ 47s ] thds: 32 tps: 402.27 qps: 8038.38 (r/w/o: 5607.75/1626.09/804.54) lat (ms,95%): 132.49 err/s: 0.00 reconn/s: 0.00
[ 48s ] thds: 32 tps: 411.50 qps: 8199.11 (r/w/o: 5753.06/1623.04/823.01) lat (ms,95%): 130.13 err/s: 0.00 reconn/s: 0.00
[ 49s ] thds: 32 tps: 409.49 qps: 8186.82 (r/w/o: 5725.87/1641.97/818.98) lat (ms,95%): 125.52 err/s: 0.00 reconn/s: 0.00
[ 50s ] thds: 32 tps: 406.97 qps: 8123.41 (r/w/o: 5686.59/1622.88/813.94) lat (ms,95%): 127.81 err/s: 0.00 reconn/s: 0.00
[ 51s ] thds: 32 tps: 420.95 qps: 8411.07 (r/w/o: 5877.35/1692.81/840.91) lat (ms,95%): 121.08 err/s: 0.00 reconn/s: 0.00
[ 52s ] thds: 32 tps: 423.08 qps: 8431.50 (r/w/o: 5904.05/1680.30/847.15) lat (ms,95%): 123.28 err/s: 0.00 reconn/s: 0.00
[ 53s ] thds: 32 tps: 417.95 qps: 8478.98 (r/w/o: 5939.28/1703.79/835.90) lat (ms,95%): 125.52 err/s: 0.00 reconn/s: 0.00
[ 54s ] thds: 32 tps: 427.01 qps: 8537.15 (r/w/o: 5990.11/1693.03/854.02) lat (ms,95%): 121.08 err/s: 0.00 reconn/s: 0.00
[ 55s ] thds: 32 tps: 316.04 qps: 6210.76 (r/w/o: 4339.53/1239.15/632.08) lat (ms,95%): 200.47 err/s: 0.00 reconn/s: 0.00
[ 56s ] thds: 32 tps: 224.00 qps: 4544.02 (r/w/o: 3193.02/903.00/448.00) lat (ms,95%): 287.38 err/s: 0.00 reconn/s: 0.00
[ 57s ] thds: 32 tps: 194.00 qps: 3862.91 (r/w/o: 2691.94/782.98/387.99) lat (ms,95%): 350.33 err/s: 0.00 reconn/s: 0.00
[ 58s ] thds: 32 tps: 168.00 qps: 3388.08 (r/w/o: 2376.06/676.02/336.01) lat (ms,95%): 411.96 err/s: 0.00 reconn/s: 0.00
[ 59s ] thds: 32 tps: 114.99 qps: 2200.90 (r/w/o: 1529.93/440.98/229.99) lat (ms,95%): 569.67 err/s: 0.00 reconn/s: 0.00
[ 60s ] thds: 32 tps: 59.00 qps: 1226.05 (r/w/o: 868.04/240.01/118.01) lat (ms,95%): 580.02 err/s: 0.00 reconn/s: 0.00
[ 61s ] thds: 32 tps: 43.00 qps: 880.00 (r/w/o: 626.00/168.00/86.00) lat (ms,95%): 1533.66 err/s: 0.00 reconn/s: 0.00
[ 62s ] thds: 32 tps: 35.00 qps: 661.00 (r/w/o: 451.00/140.00/70.00) lat (ms,95%): 1903.57 err/s: 0.00 reconn/s: 0.00
[ 63s ] thds: 32 tps: 33.00 qps: 684.00 (r/w/o: 477.00/141.00/66.00) lat (ms,95%): 1427.08 err/s: 0.00 reconn/s: 0.00
[ 64s ] thds: 32 tps: 14.00 qps: 355.00 (r/w/o: 247.00/80.00/28.00) lat (ms,95%): 1803.47 err/s: 0.00 reconn/s: 0.00
[ 65s ] thds: 32 tps: 30.00 qps: 520.01 (r/w/o: 364.01/96.00/60.00) lat (ms,95%): 2585.31 err/s: 0.00 reconn/s: 0.00
[ 66s ] thds: 32 tps: 33.00 qps: 642.98 (r/w/o: 450.99/126.00/66.00) lat (ms,95%): 1618.78 err/s: 0.00 reconn/s: 0.00
[ 67s ] thds: 32 tps: 23.00 qps: 495.01 (r/w/o: 352.00/98.00/45.00) lat (ms,95%): 3208.88 err/s: 0.00 reconn/s: 0.00
[ 68s ] thds: 32 tps: 20.00 qps: 353.00 (r/w/o: 238.00/74.00/41.00) lat (ms,95%): 2159.29 err/s: 0.00 reconn/s: 0.00
[ 69s ] thds: 32 tps: 18.00 qps: 399.00 (r/w/o: 294.00/69.00/36.00) lat (ms,95%): 2159.29 err/s: 0.00 reconn/s: 0.00
[ 70s ] thds: 32 tps: 17.00 qps: 311.00 (r/w/o: 210.00/67.00/34.00) lat (ms,95%): 2985.89 err/s: 0.00 reconn/s: 0.00
[ 71s ] thds: 32 tps: 15.00 qps: 345.99 (r/w/o: 247.99/68.00/30.00) lat (ms,95%): 2632.28 err/s: 0.00 reconn/s: 0.00
[ 72s ] thds: 32 tps: 23.00 qps: 513.01 (r/w/o: 353.00/114.00/46.00) lat (ms,95%): 3040.14 err/s: 0.00 reconn/s: 0.00
[ 73s ] thds: 32 tps: 75.00 qps: 1474.01 (r/w/o: 1027.01/298.00/149.00) lat (ms,95%): 2362.72 err/s: 0.00 reconn/s: 0.00
[ 74s ] thds: 32 tps: 408.91 qps: 8116.21 (r/w/o: 5673.75/1624.64/817.82) lat (ms,95%): 137.35 err/s: 0.00 reconn/s: 0.00
[ 75s ] thds: 32 tps: 405.08 qps: 8147.58 (r/w/o: 5716.11/1620.31/811.16) lat (ms,95%): 130.13 err/s: 0.00 reconn/s: 0.00
[ 76s ] thds: 32 tps: 415.01 qps: 8294.11 (r/w/o: 5793.08/1671.02/830.01) lat (ms,95%): 123.28 err/s: 0.00 reconn/s: 0.00
[ 77s ] thds: 32 tps: 410.97 qps: 8212.34 (r/w/o: 5758.54/1631.87/821.93) lat (ms,95%): 125.52 err/s: 0.00 reconn/s: 0.00
[ 78s ] thds: 32 tps: 425.00 qps: 8493.92 (r/w/o: 5948.94/1695.98/848.99) lat (ms,95%): 125.52 err/s: 0.00 reconn/s: 0.00
[ 79s ] thds: 32 tps: 420.04 qps: 8408.77 (r/w/o: 5883.54/1685.15/840.08) lat (ms,95%): 125.52 err/s: 0.00 reconn/s: 0.00
[ 80s ] thds: 32 tps: 420.99 qps: 8447.77 (r/w/o: 5902.84/1701.95/842.98) lat (ms,95%): 116.80 err/s: 0.00 reconn/s: 0.00
[ 81s ] thds: 32 tps: 423.49 qps: 8470.71 (r/w/o: 5933.79/1690.95/845.97) lat (ms,95%): 118.92 err/s: 0.00 reconn/s: 0.00
[ 82s ] thds: 32 tps: 428.53 qps: 8574.58 (r/w/o: 6006.41/1710.11/858.06) lat (ms,95%): 118.92 err/s: 0.00 reconn/s: 0.00
[ 83s ] thds: 32 tps: 423.99 qps: 8455.88 (r/w/o: 5920.92/1686.98/847.99) lat (ms,95%): 123.28 err/s: 0.00 reconn/s: 0.00
[ 84s ] thds: 32 tps: 427.01 qps: 8547.17 (r/w/o: 5985.12/1709.03/853.02) lat (ms,95%): 118.92 err/s: 0.00 reconn/s: 0.00
[ 85s ] thds: 32 tps: 432.84 qps: 8644.74 (r/w/o: 6036.73/1742.34/865.67) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 86s ] thds: 32 tps: 424.06 qps: 8545.31 (r/w/o: 6006.92/1689.26/849.13) lat (ms,95%): 118.92 err/s: 0.00 reconn/s: 0.00
[ 87s ] thds: 32 tps: 439.04 qps: 8763.83 (r/w/o: 6126.58/1759.17/878.08) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 88s ] thds: 32 tps: 425.73 qps: 8453.71 (r/w/o: 5899.31/1702.93/851.47) lat (ms,95%): 114.72 err/s: 0.00 reconn/s: 0.00
[ 89s ] thds: 32 tps: 439.30 qps: 8777.91 (r/w/o: 6155.14/1744.17/878.59) lat (ms,95%): 108.68 err/s: 0.00 reconn/s: 0.00
[ 90s ] thds: 32 tps: 423.96 qps: 8585.13 (r/w/o: 6026.39/1710.83/847.91) lat (ms,95%): 114.72 err/s: 0.00 reconn/s: 0.00
[ 91s ] thds: 32 tps: 446.07 qps: 8862.44 (r/w/o: 6175.00/1797.29/890.14) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 92s ] thds: 32 tps: 420.96 qps: 8506.29 (r/w/o: 5970.50/1691.86/843.93) lat (ms,95%): 118.92 err/s: 0.00 reconn/s: 0.00
[ 93s ] thds: 32 tps: 447.03 qps: 8906.66 (r/w/o: 6223.46/1790.13/893.07) lat (ms,95%): 116.80 err/s: 0.00 reconn/s: 0.00
[ 94s ] thds: 32 tps: 425.02 qps: 8528.49 (r/w/o: 5974.35/1703.10/851.05) lat (ms,95%): 114.72 err/s: 0.00 reconn/s: 0.00
[ 95s ] thds: 32 tps: 446.98 qps: 8904.52 (r/w/o: 6240.67/1769.91/893.95) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 96s ] thds: 32 tps: 397.01 qps: 7899.15 (r/w/o: 5536.11/1569.03/794.02) lat (ms,95%): 130.13 err/s: 0.00 reconn/s: 0.00
[ 97s ] thds: 32 tps: 158.00 qps: 3164.01 (r/w/o: 2212.01/636.00/316.00) lat (ms,95%): 493.24 err/s: 0.00 reconn/s: 0.00
[ 98s ] thds: 32 tps: 169.99 qps: 3335.72 (r/w/o: 2322.81/672.94/339.97) lat (ms,95%): 623.33 err/s: 0.00 reconn/s: 0.00
[ 99s ] thds: 32 tps: 364.97 qps: 7267.36 (r/w/o: 5083.56/1453.87/729.94) lat (ms,95%): 186.54 err/s: 0.00 reconn/s: 0.00
[ 100s ] thds: 32 tps: 161.02 qps: 3277.33 (r/w/o: 2305.23/650.07/322.03) lat (ms,95%): 419.45 err/s: 0.00 reconn/s: 0.00
[ 101s ] thds: 32 tps: 106.01 qps: 2091.14 (r/w/o: 1465.10/414.03/212.01) lat (ms,95%): 623.33 err/s: 0.00 reconn/s: 0.00
[ 102s ] thds: 32 tps: 86.00 qps: 1720.00 (r/w/o: 1202.00/346.00/172.00) lat (ms,95%): 746.32 err/s: 0.00 reconn/s: 0.00
[ 103s ] thds: 32 tps: 49.00 qps: 978.95 (r/w/o: 684.96/195.99/97.99) lat (ms,95%): 893.56 err/s: 0.00 reconn/s: 0.00
[ 104s ] thds: 32 tps: 60.00 qps: 1250.08 (r/w/o: 888.06/242.02/120.01) lat (ms,95%): 1280.93 err/s: 0.00 reconn/s: 0.00
[ 105s ] thds: 32 tps: 62.00 qps: 1269.00 (r/w/o: 875.00/270.00/124.00) lat (ms,95%): 960.30 err/s: 0.00 reconn/s: 0.00
[ 106s ] thds: 32 tps: 38.00 qps: 719.01 (r/w/o: 517.01/126.00/76.00) lat (ms,95%): 1304.21 err/s: 0.00 reconn/s: 0.00
[ 107s ] thds: 32 tps: 40.00 qps: 849.99 (r/w/o: 601.99/168.00/80.00) lat (ms,95%): 1280.93 err/s: 0.00 reconn/s: 0.00
[ 108s ] thds: 32 tps: 34.00 qps: 603.00 (r/w/o: 407.00/128.00/68.00) lat (ms,95%): 1938.16 err/s: 0.00 reconn/s: 0.00
[ 109s ] thds: 32 tps: 43.00 qps: 863.01 (r/w/o: 610.01/167.00/86.00) lat (ms,95%): 1589.90 err/s: 0.00 reconn/s: 0.00
[ 110s ] thds: 32 tps: 33.00 qps: 672.98 (r/w/o: 460.99/146.00/66.00) lat (ms,95%): 1678.14 err/s: 0.00 reconn/s: 0.00
[ 111s ] thds: 32 tps: 45.00 qps: 905.99 (r/w/o: 635.00/181.00/90.00) lat (ms,95%): 1506.29 err/s: 0.00 reconn/s: 0.00
[ 112s ] thds: 32 tps: 403.96 qps: 8150.26 (r/w/o: 5710.48/1631.85/807.93) lat (ms,95%): 215.44 err/s: 0.00 reconn/s: 0.00
[ 113s ] thds: 32 tps: 420.64 qps: 8397.85 (r/w/o: 5880.00/1676.57/841.28) lat (ms,95%): 123.28 err/s: 0.00 reconn/s: 0.00
[ 114s ] thds: 32 tps: 422.35 qps: 8403.06 (r/w/o: 5878.94/1679.41/844.71) lat (ms,95%): 125.52 err/s: 0.00 reconn/s: 0.00
[ 115s ] thds: 32 tps: 425.99 qps: 8500.75 (r/w/o: 5956.82/1692.95/850.97) lat (ms,95%): 121.08 err/s: 0.00 reconn/s: 0.00
[ 116s ] thds: 32 tps: 424.80 qps: 8544.93 (r/w/o: 5961.16/1733.18/850.60) lat (ms,95%): 116.80 err/s: 0.00 reconn/s: 0.00
[ 117s ] thds: 32 tps: 431.22 qps: 8580.33 (r/w/o: 6001.03/1716.87/862.43) lat (ms,95%): 121.08 err/s: 0.00 reconn/s: 0.00
[ 118s ] thds: 32 tps: 424.89 qps: 8539.75 (r/w/o: 5990.42/1699.55/849.78) lat (ms,95%): 118.92 err/s: 0.00 reconn/s: 0.00
[ 119s ] thds: 32 tps: 442.95 qps: 8876.97 (r/w/o: 6208.28/1782.79/885.90) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 120s ] thds: 32 tps: 434.19 qps: 8659.88 (r/w/o: 6066.72/1725.77/867.39) lat (ms,95%): 114.72 err/s: 0.00 reconn/s: 0.00
[ 121s ] thds: 32 tps: 425.77 qps: 8521.47 (r/w/o: 5963.83/1705.09/852.55) lat (ms,95%): 118.92 err/s: 0.00 reconn/s: 0.00
[ 122s ] thds: 32 tps: 427.10 qps: 8543.91 (r/w/o: 5993.34/1696.38/854.19) lat (ms,95%): 114.72 err/s: 0.00 reconn/s: 0.00
[ 123s ] thds: 32 tps: 422.06 qps: 8469.29 (r/w/o: 5915.90/1709.26/844.13) lat (ms,95%): 123.28 err/s: 0.00 reconn/s: 0.00
[ 124s ] thds: 32 tps: 437.56 qps: 8684.22 (r/w/o: 6078.86/1731.25/874.12) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 125s ] thds: 32 tps: 434.44 qps: 8817.95 (r/w/o: 6166.26/1782.81/868.88) lat (ms,95%): 110.66 err/s: 0.00 reconn/s: 0.00
[ 126s ] thds: 32 tps: 437.97 qps: 8667.40 (r/w/o: 6072.58/1717.88/876.94) lat (ms,95%): 114.72 err/s: 0.00 reconn/s: 0.00
[ 127s ] thds: 32 tps: 446.95 qps: 8913.91 (r/w/o: 6224.24/1795.78/893.89) lat (ms,95%): 116.80 err/s: 0.00 reconn/s: 0.00
[ 128s ] thds: 32 tps: 431.13 qps: 8700.71 (r/w/o: 6117.90/1720.54/862.27) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 129s ] thds: 32 tps: 444.03 qps: 8874.52 (r/w/o: 6209.36/1777.10/888.05) lat (ms,95%): 114.72 err/s: 0.00 reconn/s: 0.00
[ 130s ] thds: 32 tps: 439.98 qps: 8677.59 (r/w/o: 6048.72/1751.92/876.96) lat (ms,95%): 110.66 err/s: 0.00 reconn/s: 0.00
[ 131s ] thds: 32 tps: 442.61 qps: 8922.13 (r/w/o: 6270.47/1764.44/887.22) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 132s ] thds: 32 tps: 431.41 qps: 8659.25 (r/w/o: 6045.76/1749.67/863.82) lat (ms,95%): 121.08 err/s: 0.00 reconn/s: 0.00
[ 133s ] thds: 32 tps: 444.97 qps: 8906.38 (r/w/o: 6257.56/1758.88/889.94) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 134s ] thds: 32 tps: 434.82 qps: 8629.48 (r/w/o: 6028.54/1731.29/869.65) lat (ms,95%): 118.92 err/s: 0.00 reconn/s: 0.00
[ 135s ] thds: 32 tps: 325.15 qps: 6502.92 (r/w/o: 4555.04/1297.58/650.29) lat (ms,95%): 219.36 err/s: 0.00 reconn/s: 0.00
[ 136s ] thds: 32 tps: 197.00 qps: 3920.05 (r/w/o: 2749.03/777.01/394.00) lat (ms,95%): 344.08 err/s: 0.00 reconn/s: 0.00
[ 137s ] thds: 32 tps: 166.00 qps: 3322.02 (r/w/o: 2317.02/673.01/332.00) lat (ms,95%): 612.21 err/s: 0.00 reconn/s: 0.00
[ 138s ] thds: 32 tps: 161.00 qps: 3236.99 (r/w/o: 2272.99/642.00/322.00) lat (ms,95%): 467.30 err/s: 0.00 reconn/s: 0.00
[ 139s ] thds: 32 tps: 115.00 qps: 2266.06 (r/w/o: 1583.04/453.01/230.01) lat (ms,95%): 590.56 err/s: 0.00 reconn/s: 0.00
[ 140s ] thds: 32 tps: 65.94 qps: 1379.65 (r/w/o: 979.04/268.74/131.87) lat (ms,95%): 746.32 err/s: 0.00 reconn/s: 0.00
[ 141s ] thds: 32 tps: 80.05 qps: 1572.02 (r/w/o: 1089.71/322.21/160.10) lat (ms,95%): 1129.24 err/s: 0.00 reconn/s: 0.00
[ 142s ] thds: 32 tps: 62.02 qps: 1207.38 (r/w/o: 840.26/243.08/124.04) lat (ms,95%): 943.16 err/s: 0.00 reconn/s: 0.00
[ 143s ] thds: 32 tps: 21.00 qps: 484.89 (r/w/o: 356.92/85.98/41.99) lat (ms,95%): 1258.08 err/s: 0.00 reconn/s: 0.00
[ 144s ] thds: 32 tps: 52.01 qps: 994.21 (r/w/o: 682.14/208.04/104.02) lat (ms,95%): 1589.90 err/s: 0.00 reconn/s: 0.00
[ 145s ] thds: 32 tps: 65.00 qps: 1286.00 (r/w/o: 895.00/261.00/130.00) lat (ms,95%): 1129.24 err/s: 0.00 reconn/s: 0.00
[ 146s ] thds: 32 tps: 49.00 qps: 1026.01 (r/w/o: 734.01/194.00/98.00) lat (ms,95%): 1013.60 err/s: 0.00 reconn/s: 0.00
[ 147s ] thds: 32 tps: 49.00 qps: 954.00 (r/w/o: 662.00/194.00/98.00) lat (ms,95%): 1032.01 err/s: 0.00 reconn/s: 0.00
[ 148s ] thds: 32 tps: 36.00 qps: 673.00 (r/w/o: 457.00/144.00/72.00) lat (ms,95%): 1129.24 err/s: 0.00 reconn/s: 0.00
[ 149s ] thds: 32 tps: 285.00 qps: 5838.91 (r/w/o: 4107.93/1160.98/569.99) lat (ms,95%): 759.88 err/s: 0.00 reconn/s: 0.00
[ 150s ] thds: 32 tps: 431.01 qps: 8534.14 (r/w/o: 5949.10/1723.03/862.01) lat (ms,95%): 125.52 err/s: 0.00 reconn/s: 0.00
[ 151s ] thds: 32 tps: 418.99 qps: 8429.71 (r/w/o: 5910.80/1680.94/837.97) lat (ms,95%): 125.52 err/s: 0.00 reconn/s: 0.00
[ 152s ] thds: 32 tps: 435.97 qps: 8661.40 (r/w/o: 6056.58/1732.88/871.94) lat (ms,95%): 118.92 err/s: 0.00 reconn/s: 0.00
[ 153s ] thds: 32 tps: 423.04 qps: 8415.83 (r/w/o: 5884.58/1685.17/846.08) lat (ms,95%): 123.28 err/s: 0.00 reconn/s: 0.00
[ 154s ] thds: 32 tps: 429.00 qps: 8617.08 (r/w/o: 6040.06/1719.02/858.01) lat (ms,95%): 118.92 err/s: 0.00 reconn/s: 0.00
[ 155s ] thds: 32 tps: 420.99 qps: 8442.80 (r/w/o: 5911.86/1688.96/841.98) lat (ms,95%): 118.92 err/s: 0.00 reconn/s: 0.00
[ 156s ] thds: 32 tps: 434.00 qps: 8754.04 (r/w/o: 6128.03/1758.01/868.00) lat (ms,95%): 116.80 err/s: 0.00 reconn/s: 0.00
[ 157s ] thds: 32 tps: 427.00 qps: 8528.95 (r/w/o: 5966.97/1707.99/854.00) lat (ms,95%): 121.08 err/s: 0.00 reconn/s: 0.00
[ 158s ] thds: 32 tps: 438.87 qps: 8697.43 (r/w/o: 6095.20/1725.49/876.74) lat (ms,95%): 121.08 err/s: 0.00 reconn/s: 0.00
[ 159s ] thds: 32 tps: 425.13 qps: 8604.65 (r/w/o: 6017.85/1735.53/851.26) lat (ms,95%): 114.72 err/s: 0.00 reconn/s: 0.00
[ 160s ] thds: 32 tps: 435.89 qps: 8634.77 (r/w/o: 6046.44/1716.56/871.78) lat (ms,95%): 116.80 err/s: 0.00 reconn/s: 0.00
[ 161s ] thds: 32 tps: 432.07 qps: 8660.41 (r/w/o: 6052.99/1745.28/862.14) lat (ms,95%): 118.92 err/s: 0.00 reconn/s: 0.00
[ 162s ] thds: 32 tps: 443.03 qps: 8727.68 (r/w/o: 6092.47/1747.14/888.07) lat (ms,95%): 114.72 err/s: 0.00 reconn/s: 0.00
[ 163s ] thds: 32 tps: 427.70 qps: 8692.99 (r/w/o: 6112.77/1724.81/855.41) lat (ms,95%): 118.92 err/s: 0.00 reconn/s: 0.00
[ 164s ] thds: 32 tps: 429.30 qps: 8623.98 (r/w/o: 6032.18/1733.20/858.60) lat (ms,95%): 118.92 err/s: 0.00 reconn/s: 0.00
[ 165s ] thds: 32 tps: 448.95 qps: 8934.08 (r/w/o: 6253.36/1783.82/896.91) lat (ms,95%): 108.68 err/s: 0.00 reconn/s: 0.00
[ 166s ] thds: 32 tps: 422.05 qps: 8482.93 (r/w/o: 5961.65/1676.18/845.09) lat (ms,95%): 114.72 err/s: 0.00 reconn/s: 0.00
[ 167s ] thds: 32 tps: 438.71 qps: 8749.14 (r/w/o: 6097.91/1775.81/875.41) lat (ms,95%): 114.72 err/s: 0.00 reconn/s: 0.00
[ 168s ] thds: 32 tps: 438.26 qps: 8761.25 (r/w/o: 6137.68/1747.05/876.53) lat (ms,95%): 118.92 err/s: 0.00 reconn/s: 0.00
[ 169s ] thds: 32 tps: 443.03 qps: 8753.58 (r/w/o: 6095.40/1771.12/887.06) lat (ms,95%): 114.72 err/s: 0.00 reconn/s: 0.00
[ 170s ] thds: 32 tps: 424.94 qps: 8679.79 (r/w/o: 6129.15/1699.76/850.88) lat (ms,95%): 114.72 err/s: 0.00 reconn/s: 0.00
[ 171s ] thds: 32 tps: 449.07 qps: 8890.40 (r/w/o: 6197.97/1795.28/897.14) lat (ms,95%): 106.75 err/s: 0.00 reconn/s: 0.00
[ 172s ] thds: 32 tps: 429.59 qps: 8561.89 (r/w/o: 6002.31/1699.39/860.19) lat (ms,95%): 118.92 err/s: 0.00 reconn/s: 0.00
[ 173s ] thds: 32 tps: 416.38 qps: 8465.72 (r/w/o: 5927.40/1705.55/832.76) lat (ms,95%): 134.90 err/s: 0.00 reconn/s: 0.00
[ 174s ] thds: 32 tps: 397.80 qps: 7907.96 (r/w/o: 5531.17/1581.19/795.59) lat (ms,95%): 164.45 err/s: 0.00 reconn/s: 0.00
[ 175s ] thds: 32 tps: 342.15 qps: 6691.89 (r/w/o: 4677.02/1330.57/684.30) lat (ms,95%): 215.44 err/s: 0.00 reconn/s: 0.00
[ 176s ] thds: 32 tps: 257.98 qps: 5235.61 (r/w/o: 3677.72/1041.92/515.96) lat (ms,95%): 325.98 err/s: 0.00 reconn/s: 0.00
[ 177s ] thds: 32 tps: 238.04 qps: 4708.83 (r/w/o: 3285.58/947.17/476.08) lat (ms,95%): 253.35 err/s: 0.00 reconn/s: 0.00
[ 178s ] thds: 32 tps: 137.00 qps: 2781.03 (r/w/o: 1959.02/548.01/274.00) lat (ms,95%): 493.24 err/s: 0.00 reconn/s: 0.00
[ 179s ] thds: 32 tps: 104.99 qps: 2092.87 (r/w/o: 1462.91/419.97/209.99) lat (ms,95%): 707.07 err/s: 0.00 reconn/s: 0.00
[ 180s ] thds: 32 tps: 67.00 qps: 1263.07 (r/w/o: 869.05/260.01/134.01) lat (ms,95%): 831.46 err/s: 0.00 reconn/s: 0.00
[ 181s ] thds: 32 tps: 35.00 qps: 815.95 (r/w/o: 595.96/149.99/70.00) lat (ms,95%): 1149.76 err/s: 0.00 reconn/s: 0.00
[ 182s ] thds: 32 tps: 59.00 qps: 1077.08 (r/w/o: 732.05/227.02/118.01) lat (ms,95%): 1129.24 err/s: 0.00 reconn/s: 0.00
[ 183s ] thds: 32 tps: 46.00 qps: 942.96 (r/w/o: 661.97/188.99/92.00) lat (ms,95%): 1129.24 err/s: 0.00 reconn/s: 0.00
[ 184s ] thds: 32 tps: 41.00 qps: 877.04 (r/w/o: 626.03/169.01/82.00) lat (ms,95%): 1235.62 err/s: 0.00 reconn/s: 0.00
[ 185s ] thds: 32 tps: 46.00 qps: 909.00 (r/w/o: 622.00/195.00/92.00) lat (ms,95%): 1533.66 err/s: 0.00 reconn/s: 0.00
[ 186s ] thds: 32 tps: 47.00 qps: 952.99 (r/w/o: 687.99/171.00/94.00) lat (ms,95%): 1327.91 err/s: 0.00 reconn/s: 0.00
[ 187s ] thds: 32 tps: 38.00 qps: 681.00 (r/w/o: 460.00/145.00/76.00) lat (ms,95%): 1304.21 err/s: 0.00 reconn/s: 0.00
[ 188s ] thds: 32 tps: 250.88 qps: 5211.60 (r/w/o: 3663.31/1046.52/501.77) lat (ms,95%): 816.63 err/s: 0.00 reconn/s: 0.00
[ 189s ] thds: 32 tps: 424.19 qps: 8348.83 (r/w/o: 5829.67/1672.77/846.39) lat (ms,95%): 125.52 err/s: 0.00 reconn/s: 0.00
[ 190s ] thds: 32 tps: 419.00 qps: 8383.92 (r/w/o: 5862.95/1680.98/839.99) lat (ms,95%): 118.92 err/s: 0.00 reconn/s: 0.00
[ 191s ] thds: 32 tps: 436.91 qps: 8757.17 (r/w/o: 6133.72/1749.63/873.82) lat (ms,95%): 118.92 err/s: 0.00 reconn/s: 0.00
[ 192s ] thds: 32 tps: 408.09 qps: 8137.78 (r/w/o: 5690.24/1631.36/816.18) lat (ms,95%): 127.81 err/s: 0.00 reconn/s: 0.00
[ 193s ] thds: 32 tps: 431.98 qps: 8735.52 (r/w/o: 6118.66/1752.90/863.95) lat (ms,95%): 110.66 err/s: 0.00 reconn/s: 0.00
[ 194s ] thds: 32 tps: 426.02 qps: 8428.45 (r/w/o: 5910.31/1667.09/851.05) lat (ms,95%): 118.92 err/s: 0.00 reconn/s: 0.00
[ 195s ] thds: 32 tps: 436.99 qps: 8836.73 (r/w/o: 6195.81/1765.95/874.97) lat (ms,95%): 116.80 err/s: 0.00 reconn/s: 0.00
[ 196s ] thds: 32 tps: 430.94 qps: 8607.82 (r/w/o: 6012.17/1733.76/861.88) lat (ms,95%): 114.72 err/s: 0.00 reconn/s: 0.00
[ 197s ] thds: 32 tps: 443.97 qps: 8820.33 (r/w/o: 6174.53/1757.87/887.93) lat (ms,95%): 114.72 err/s: 0.00 reconn/s: 0.00
[ 198s ] thds: 32 tps: 430.10 qps: 8566.95 (r/w/o: 5997.37/1710.39/859.20) lat (ms,95%): 118.92 err/s: 0.00 reconn/s: 0.00
[ 199s ] thds: 32 tps: 422.00 qps: 8554.08 (r/w/o: 5990.06/1719.02/845.01) lat (ms,95%): 116.80 err/s: 0.00 reconn/s: 0.00
[ 200s ] thds: 32 tps: 438.92 qps: 8751.31 (r/w/o: 6133.82/1739.66/877.83) lat (ms,95%): 114.72 err/s: 0.00 reconn/s: 0.00
[ 201s ] thds: 32 tps: 434.09 qps: 8669.80 (r/w/o: 6057.26/1745.36/867.18) lat (ms,95%): 110.66 err/s: 0.00 reconn/s: 0.00
[ 202s ] thds: 32 tps: 430.93 qps: 8631.61 (r/w/o: 6052.03/1716.72/862.86) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 203s ] thds: 32 tps: 437.06 qps: 8685.22 (r/w/o: 6070.85/1740.24/874.12) lat (ms,95%): 114.72 err/s: 0.00 reconn/s: 0.00
[ 204s ] thds: 32 tps: 434.97 qps: 8675.32 (r/w/o: 6063.52/1742.86/868.93) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 205s ] thds: 32 tps: 443.97 qps: 8898.37 (r/w/o: 6232.56/1776.87/888.94) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 206s ] thds: 32 tps: 431.02 qps: 8721.31 (r/w/o: 6112.22/1747.06/862.03) lat (ms,95%): 118.92 err/s: 0.00 reconn/s: 0.00
[ 207s ] thds: 32 tps: 455.54 qps: 9126.79 (r/w/o: 6395.54/1820.16/911.08) lat (ms,95%): 108.68 err/s: 0.00 reconn/s: 0.00
[ 208s ] thds: 32 tps: 445.41 qps: 8766.02 (r/w/o: 6131.61/1744.60/889.81) lat (ms,95%): 114.72 err/s: 0.00 reconn/s: 0.00
[ 209s ] thds: 32 tps: 442.95 qps: 8923.90 (r/w/o: 6249.23/1787.78/886.89) lat (ms,95%): 118.92 err/s: 0.00 reconn/s: 0.00
[ 210s ] thds: 32 tps: 456.05 qps: 9112.97 (r/w/o: 6359.68/1841.20/912.10) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 211s ] thds: 32 tps: 450.05 qps: 9037.01 (r/w/o: 6352.71/1784.20/900.10) lat (ms,95%): 118.92 err/s: 0.00 reconn/s: 0.00
[ 212s ] thds: 32 tps: 446.06 qps: 8813.26 (r/w/o: 6150.88/1770.25/892.13) lat (ms,95%): 121.08 err/s: 0.00 reconn/s: 0.00
[ 213s ] thds: 32 tps: 254.98 qps: 5113.60 (r/w/o: 3592.72/1010.92/509.96) lat (ms,95%): 404.61 err/s: 0.00 reconn/s: 0.00
[ 214s ] thds: 32 tps: 168.96 qps: 3423.17 (r/w/o: 2386.42/698.83/337.92) lat (ms,95%): 530.08 err/s: 0.00 reconn/s: 0.00
[ 215s ] thds: 32 tps: 195.04 qps: 3927.76 (r/w/o: 2748.53/789.15/390.08) lat (ms,95%): 520.62 err/s: 0.00 reconn/s: 0.00
[ 216s ] thds: 32 tps: 135.02 qps: 2668.30 (r/w/o: 1862.21/536.06/270.03) lat (ms,95%): 475.79 err/s: 0.00 reconn/s: 0.00
[ 217s ] thds: 32 tps: 103.00 qps: 2022.02 (r/w/o: 1433.01/383.00/206.00) lat (ms,95%): 669.89 err/s: 0.00 reconn/s: 0.00
[ 218s ] thds: 32 tps: 52.00 qps: 1046.99 (r/w/o: 733.00/210.00/104.00) lat (ms,95%): 960.30 err/s: 0.00 reconn/s: 0.00
[ 219s ] thds: 32 tps: 47.00 qps: 881.00 (r/w/o: 599.00/188.00/94.00) lat (ms,95%): 1453.01 err/s: 0.00 reconn/s: 0.00
[ 220s ] thds: 32 tps: 61.00 qps: 1279.00 (r/w/o: 911.00/246.00/122.00) lat (ms,95%): 1069.86 err/s: 0.00 reconn/s: 0.00
[ 221s ] thds: 32 tps: 23.00 qps: 487.00 (r/w/o: 342.00/99.00/46.00) lat (ms,95%): 1191.92 err/s: 0.00 reconn/s: 0.00
[ 222s ] thds: 32 tps: 30.00 qps: 613.00 (r/w/o: 431.00/122.00/60.00) lat (ms,95%): 1869.60 err/s: 0.00 reconn/s: 0.00
[ 223s ] thds: 32 tps: 40.00 qps: 714.01 (r/w/o: 489.00/145.00/80.00) lat (ms,95%): 2493.86 err/s: 0.00 reconn/s: 0.00
[ 224s ] thds: 32 tps: 41.00 qps: 829.01 (r/w/o: 584.01/163.00/82.00) lat (ms,95%): 1648.20 err/s: 0.00 reconn/s: 0.00
[ 225s ] thds: 32 tps: 30.00 qps: 617.99 (r/w/o: 430.00/128.00/60.00) lat (ms,95%): 2009.23 err/s: 0.00 reconn/s: 0.00
[ 226s ] thds: 32 tps: 92.98 qps: 1847.54 (r/w/o: 1289.68/371.91/185.95) lat (ms,95%): 1533.66 err/s: 0.00 reconn/s: 0.00
[ 227s ] thds: 32 tps: 441.10 qps: 8902.10 (r/w/o: 6242.47/1777.42/882.21) lat (ms,95%): 127.81 err/s: 0.00 reconn/s: 0.00
[ 228s ] thds: 32 tps: 431.60 qps: 8604.07 (r/w/o: 5999.47/1741.40/863.20) lat (ms,95%): 125.52 err/s: 0.00 reconn/s: 0.00
[ 229s ] thds: 32 tps: 437.83 qps: 8775.64 (r/w/o: 6159.64/1740.33/875.66) lat (ms,95%): 118.92 err/s: 0.00 reconn/s: 0.00
[ 230s ] thds: 32 tps: 443.53 qps: 8808.48 (r/w/o: 6159.33/1762.10/887.06) lat (ms,95%): 116.80 err/s: 0.00 reconn/s: 0.00
[ 231s ] thds: 32 tps: 440.03 qps: 8920.62 (r/w/o: 6244.43/1796.12/880.06) lat (ms,95%): 110.66 err/s: 0.00 reconn/s: 0.00
[ 232s ] thds: 32 tps: 457.02 qps: 9038.34 (r/w/o: 6320.24/1806.07/912.03) lat (ms,95%): 108.68 err/s: 0.00 reconn/s: 0.00
[ 233s ] thds: 32 tps: 449.00 qps: 9010.02 (r/w/o: 6334.01/1776.00/900.00) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 234s ] thds: 32 tps: 459.01 qps: 9214.26 (r/w/o: 6433.18/1863.05/918.03) lat (ms,95%): 116.80 err/s: 0.00 reconn/s: 0.00
[ 235s ] thds: 32 tps: 456.94 qps: 9134.79 (r/w/o: 6394.16/1826.76/913.88) lat (ms,95%): 106.75 err/s: 0.00 reconn/s: 0.00
[ 236s ] thds: 32 tps: 448.10 qps: 8913.41 (r/w/o: 6234.72/1783.48/895.22) lat (ms,95%): 110.66 err/s: 0.00 reconn/s: 0.00
[ 237s ] thds: 32 tps: 444.81 qps: 8983.83 (r/w/o: 6300.86/1792.34/890.63) lat (ms,95%): 116.80 err/s: 0.00 reconn/s: 0.00
[ 238s ] thds: 32 tps: 474.07 qps: 9357.31 (r/w/o: 6532.91/1877.26/947.13) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 239s ] thds: 32 tps: 452.02 qps: 9025.36 (r/w/o: 6327.25/1793.07/905.04) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 240s ] thds: 32 tps: 458.97 qps: 9312.31 (r/w/o: 6509.52/1884.86/917.93) lat (ms,95%): 104.84 err/s: 0.00 reconn/s: 0.00
[ 241s ] thds: 32 tps: 469.99 qps: 9402.71 (r/w/o: 6594.80/1867.94/939.97) lat (ms,95%): 110.66 err/s: 0.00 reconn/s: 0.00
[ 242s ] thds: 32 tps: 446.07 qps: 8993.38 (r/w/o: 6288.96/1813.28/891.14) lat (ms,95%): 106.75 err/s: 0.00 reconn/s: 0.00
[ 243s ] thds: 32 tps: 471.85 qps: 9319.07 (r/w/o: 6518.95/1856.42/943.70) lat (ms,95%): 108.68 err/s: 0.00 reconn/s: 0.00
[ 244s ] thds: 32 tps: 438.15 qps: 8863.00 (r/w/o: 6216.10/1769.60/877.30) lat (ms,95%): 116.80 err/s: 0.00 reconn/s: 0.00
[ 245s ] thds: 32 tps: 466.00 qps: 9214.07 (r/w/o: 6448.05/1834.01/932.01) lat (ms,95%): 114.72 err/s: 0.00 reconn/s: 0.00
[ 246s ] thds: 32 tps: 445.95 qps: 9029.00 (r/w/o: 6317.30/1819.80/891.90) lat (ms,95%): 108.68 err/s: 0.00 reconn/s: 0.00
[ 247s ] thds: 32 tps: 463.02 qps: 9192.39 (r/w/o: 6430.27/1837.08/925.04) lat (ms,95%): 110.66 err/s: 0.00 reconn/s: 0.00
[ 248s ] thds: 32 tps: 448.00 qps: 8982.97 (r/w/o: 6289.98/1795.99/897.00) lat (ms,95%): 108.68 err/s: 0.00 reconn/s: 0.00
[ 249s ] thds: 32 tps: 458.94 qps: 9148.77 (r/w/o: 6403.14/1827.75/917.88) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 250s ] thds: 32 tps: 443.08 qps: 8800.65 (r/w/o: 6168.16/1746.33/886.17) lat (ms,95%): 114.72 err/s: 0.00 reconn/s: 0.00
[ 251s ] thds: 32 tps: 347.95 qps: 7000.07 (r/w/o: 4904.35/1399.81/695.91) lat (ms,95%): 248.83 err/s: 0.00 reconn/s: 0.00
[ 252s ] thds: 32 tps: 354.01 qps: 7116.24 (r/w/o: 4966.17/1443.05/707.02) lat (ms,95%): 227.40 err/s: 0.00 reconn/s: 0.00
[ 253s ] thds: 32 tps: 181.02 qps: 3519.43 (r/w/o: 2477.31/679.08/363.04) lat (ms,95%): 467.30 err/s: 0.00 reconn/s: 0.00
[ 254s ] thds: 32 tps: 221.97 qps: 4457.40 (r/w/o: 3113.58/899.88/443.94) lat (ms,95%): 363.18 err/s: 0.00 reconn/s: 0.00
[ 255s ] thds: 32 tps: 173.02 qps: 3453.46 (r/w/o: 2424.33/683.09/346.05) lat (ms,95%): 404.61 err/s: 0.00 reconn/s: 0.00
[ 256s ] thds: 32 tps: 99.00 qps: 1967.93 (r/w/o: 1378.95/390.99/197.99) lat (ms,95%): 623.33 err/s: 0.00 reconn/s: 0.00
[ 257s ] thds: 32 tps: 46.00 qps: 995.02 (r/w/o: 708.02/195.00/92.00) lat (ms,95%): 893.56 err/s: 0.00 reconn/s: 0.00
[ 258s ] thds: 32 tps: 85.00 qps: 1623.01 (r/w/o: 1123.01/330.00/170.00) lat (ms,95%): 1280.93 err/s: 0.00 reconn/s: 0.00
[ 259s ] thds: 32 tps: 36.00 qps: 808.00 (r/w/o: 584.00/152.00/72.00) lat (ms,95%): 960.30 err/s: 0.00 reconn/s: 0.00
[ 260s ] thds: 32 tps: 71.00 qps: 1311.95 (r/w/o: 892.97/276.99/141.99) lat (ms,95%): 1561.52 err/s: 0.00 reconn/s: 0.00
[ 261s ] thds: 32 tps: 43.00 qps: 879.95 (r/w/o: 626.97/166.99/86.00) lat (ms,95%): 1213.57 err/s: 0.00 reconn/s: 0.00
[ 262s ] thds: 32 tps: 49.00 qps: 970.05 (r/w/o: 669.04/203.01/98.01) lat (ms,95%): 1327.91 err/s: 0.00 reconn/s: 0.00
[ 263s ] thds: 32 tps: 23.99 qps: 571.83 (r/w/o: 408.88/114.97/47.99) lat (ms,95%): 1089.30 err/s: 0.00 reconn/s: 0.00
[ 264s ] thds: 32 tps: 19.01 qps: 384.12 (r/w/o: 270.08/76.02/38.01) lat (ms,95%): 1618.78 err/s: 0.00 reconn/s: 0.00
[ 265s ] thds: 32 tps: 17.00 qps: 336.00 (r/w/o: 247.00/55.00/34.00) lat (ms,95%): 2449.36 err/s: 0.00 reconn/s: 0.00
[ 266s ] thds: 32 tps: 109.99 qps: 2150.81 (r/w/o: 1481.87/448.96/219.98) lat (ms,95%): 2778.39 err/s: 0.00 reconn/s: 0.00
[ 267s ] thds: 32 tps: 436.94 qps: 8725.82 (r/w/o: 6109.17/1742.76/873.88) lat (ms,95%): 125.52 err/s: 0.00 reconn/s: 0.00
[ 268s ] thds: 32 tps: 434.10 qps: 8742.95 (r/w/o: 6129.37/1745.39/868.19) lat (ms,95%): 118.92 err/s: 0.00 reconn/s: 0.00
[ 269s ] thds: 32 tps: 451.79 qps: 9034.80 (r/w/o: 6305.07/1826.15/903.58) lat (ms,95%): 114.72 err/s: 0.00 reconn/s: 0.00
[ 270s ] thds: 32 tps: 439.90 qps: 8808.91 (r/w/o: 6185.53/1743.59/879.79) lat (ms,95%): 114.72 err/s: 0.00 reconn/s: 0.00
[ 271s ] thds: 32 tps: 453.28 qps: 8949.54 (r/w/o: 6243.87/1802.12/903.56) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 272s ] thds: 32 tps: 447.02 qps: 9079.37 (r/w/o: 6377.26/1805.07/897.04) lat (ms,95%): 108.68 err/s: 0.00 reconn/s: 0.00
[ 273s ] thds: 32 tps: 460.99 qps: 9101.73 (r/w/o: 6361.81/1820.95/918.97) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 274s ] thds: 32 tps: 462.03 qps: 9244.63 (r/w/o: 6466.44/1851.13/927.06) lat (ms,95%): 110.66 err/s: 0.00 reconn/s: 0.00
[ 275s ] thds: 32 tps: 446.92 qps: 8997.47 (r/w/o: 6302.93/1800.69/893.85) lat (ms,95%): 108.68 err/s: 0.00 reconn/s: 0.00
[ 276s ] thds: 32 tps: 465.01 qps: 9314.25 (r/w/o: 6502.18/1882.05/930.03) lat (ms,95%): 110.66 err/s: 0.00 reconn/s: 0.00
[ 277s ] thds: 32 tps: 452.03 qps: 9001.56 (r/w/o: 6307.39/1791.11/903.06) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 278s ] thds: 32 tps: 461.97 qps: 9271.45 (r/w/o: 6501.61/1844.89/924.95) lat (ms,95%): 110.66 err/s: 0.00 reconn/s: 0.00
[ 279s ] thds: 32 tps: 455.03 qps: 9070.50 (r/w/o: 6359.35/1801.10/910.05) lat (ms,95%): 110.66 err/s: 0.00 reconn/s: 0.00
[ 280s ] thds: 32 tps: 453.91 qps: 9108.15 (r/w/o: 6366.71/1833.63/907.82) lat (ms,95%): 108.68 err/s: 0.00 reconn/s: 0.00
[ 281s ] thds: 32 tps: 448.11 qps: 8999.18 (r/w/o: 6305.53/1798.44/895.22) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 282s ] thds: 32 tps: 459.96 qps: 9245.14 (r/w/o: 6466.40/1858.83/919.91) lat (ms,95%): 106.75 err/s: 0.00 reconn/s: 0.00
[ 283s ] thds: 32 tps: 453.03 qps: 9010.68 (r/w/o: 6283.47/1822.14/905.07) lat (ms,95%): 110.66 err/s: 0.00 reconn/s: 0.00
[ 284s ] thds: 32 tps: 457.97 qps: 9133.39 (r/w/o: 6411.57/1803.88/917.94) lat (ms,95%): 110.66 err/s: 0.00 reconn/s: 0.00
[ 285s ] thds: 32 tps: 449.06 qps: 8962.21 (r/w/o: 6251.84/1815.25/895.12) lat (ms,95%): 116.80 err/s: 0.00 reconn/s: 0.00
[ 286s ] thds: 32 tps: 464.00 qps: 9270.07 (r/w/o: 6510.05/1829.01/931.01) lat (ms,95%): 108.68 err/s: 0.00 reconn/s: 0.00
[ 287s ] thds: 32 tps: 462.00 qps: 9237.01 (r/w/o: 6467.00/1846.00/924.00) lat (ms,95%): 108.68 err/s: 0.00 reconn/s: 0.00
[ 288s ] thds: 32 tps: 449.01 qps: 9027.14 (r/w/o: 6342.10/1787.03/898.01) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 289s ] thds: 32 tps: 474.84 qps: 9391.89 (r/w/o: 6535.83/1909.37/946.69) lat (ms,95%): 108.68 err/s: 0.00 reconn/s: 0.00
[ 290s ] thds: 32 tps: 438.14 qps: 8922.92 (r/w/o: 6273.05/1770.58/879.29) lat (ms,95%): 118.92 err/s: 0.00 reconn/s: 0.00
[ 291s ] thds: 32 tps: 463.99 qps: 9216.73 (r/w/o: 6443.81/1845.95/926.97) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 292s ] thds: 32 tps: 448.01 qps: 8943.27 (r/w/o: 6248.19/1798.05/897.03) lat (ms,95%): 116.80 err/s: 0.00 reconn/s: 0.00
[ 293s ] thds: 32 tps: 356.99 qps: 7107.77 (r/w/o: 4987.84/1405.95/713.98) lat (ms,95%): 196.89 err/s: 0.00 reconn/s: 0.00
[ 294s ] thds: 32 tps: 303.97 qps: 6086.48 (r/w/o: 4260.64/1217.90/607.95) lat (ms,95%): 282.25 err/s: 0.00 reconn/s: 0.00
[ 295s ] thds: 32 tps: 241.02 qps: 4832.46 (r/w/o: 3387.32/963.09/482.05) lat (ms,95%): 344.08 err/s: 0.00 reconn/s: 0.00
[ 296s ] thds: 32 tps: 193.01 qps: 3883.14 (r/w/o: 2732.10/765.03/386.01) lat (ms,95%): 363.18 err/s: 0.00 reconn/s: 0.00
[ 297s ] thds: 32 tps: 181.00 qps: 3562.02 (r/w/o: 2474.02/726.00/362.00) lat (ms,95%): 530.08 err/s: 0.00 reconn/s: 0.00
[ 298s ] thds: 32 tps: 115.00 qps: 2285.99 (r/w/o: 1610.99/445.00/230.00) lat (ms,95%): 580.02 err/s: 0.00 reconn/s: 0.00
[ 299s ] thds: 32 tps: 66.00 qps: 1339.95 (r/w/o: 933.96/273.99/131.99) lat (ms,95%): 831.46 err/s: 0.00 reconn/s: 0.00
[ 300s ] thds: 32 tps: 45.00 qps: 866.03 (r/w/o: 599.02/177.01/90.00) lat (ms,95%): 1304.21 err/s: 0.00 reconn/s: 0.00
[ 301s ] thds: 32 tps: 32.00 qps: 682.00 (r/w/o: 490.00/128.00/64.00) lat (ms,95%): 1352.03 err/s: 0.00 reconn/s: 0.00
[ 302s ] thds: 32 tps: 38.00 qps: 773.99 (r/w/o: 536.99/161.00/76.00) lat (ms,95%): 1453.01 err/s: 0.00 reconn/s: 0.00
[ 303s ] thds: 32 tps: 47.00 qps: 916.01 (r/w/o: 638.00/184.00/94.00) lat (ms,95%): 1708.63 err/s: 0.00 reconn/s: 0.00
[ 304s ] thds: 32 tps: 51.00 qps: 1007.01 (r/w/o: 709.01/196.00/102.00) lat (ms,95%): 1352.03 err/s: 0.00 reconn/s: 0.00
[ 305s ] thds: 32 tps: 42.00 qps: 838.00 (r/w/o: 586.00/168.00/84.00) lat (ms,95%): 1427.08 err/s: 0.00 reconn/s: 0.00
[ 306s ] thds: 32 tps: 26.00 qps: 541.00 (r/w/o: 375.00/114.00/52.00) lat (ms,95%): 1280.93 err/s: 0.00 reconn/s: 0.00
[ 307s ] thds: 32 tps: 138.87 qps: 2829.33 (r/w/o: 1995.12/556.47/277.74) lat (ms,95%): 1327.91 err/s: 0.00 reconn/s: 0.00
[ 308s ] thds: 32 tps: 442.38 qps: 8851.53 (r/w/o: 6177.26/1789.52/884.75) lat (ms,95%): 130.13 err/s: 0.00 reconn/s: 0.00
[ 309s ] thds: 32 tps: 438.72 qps: 8795.37 (r/w/o: 6169.05/1748.88/877.44) lat (ms,95%): 118.92 err/s: 0.00 reconn/s: 0.00
[ 310s ] thds: 32 tps: 450.28 qps: 9027.65 (r/w/o: 6310.95/1816.14/900.56) lat (ms,95%): 121.08 err/s: 0.00 reconn/s: 0.00
[ 311s ] thds: 32 tps: 419.05 qps: 8361.90 (r/w/o: 5858.63/1665.18/838.09) lat (ms,95%): 121.08 err/s: 0.00 reconn/s: 0.00
[ 312s ] thds: 32 tps: 448.96 qps: 8925.26 (r/w/o: 6224.49/1804.85/895.93) lat (ms,95%): 121.08 err/s: 0.00 reconn/s: 0.00
[ 313s ] thds: 32 tps: 452.94 qps: 8971.76 (r/w/o: 6288.13/1775.75/907.87) lat (ms,95%): 114.72 err/s: 0.00 reconn/s: 0.00
[ 314s ] thds: 32 tps: 439.06 qps: 8826.19 (r/w/o: 6184.83/1763.24/878.12) lat (ms,95%): 108.68 err/s: 0.00 reconn/s: 0.00
[ 315s ] thds: 32 tps: 435.87 qps: 8751.41 (r/w/o: 6126.19/1753.48/871.74) lat (ms,95%): 116.80 err/s: 0.00 reconn/s: 0.00
[ 316s ] thds: 32 tps: 449.10 qps: 8942.03 (r/w/o: 6254.42/1790.41/897.20) lat (ms,95%): 108.68 err/s: 0.00 reconn/s: 0.00
[ 317s ] thds: 32 tps: 454.96 qps: 9059.13 (r/w/o: 6343.39/1806.83/908.91) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 318s ] thds: 32 tps: 452.10 qps: 9212.10 (r/w/o: 6462.47/1843.42/906.21) lat (ms,95%): 106.75 err/s: 0.00 reconn/s: 0.00
[ 319s ] thds: 32 tps: 456.95 qps: 9078.91 (r/w/o: 6338.24/1826.78/913.89) lat (ms,95%): 110.66 err/s: 0.00 reconn/s: 0.00
[ 320s ] thds: 32 tps: 451.03 qps: 8983.58 (r/w/o: 6292.41/1791.12/900.06) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 321s ] thds: 32 tps: 461.85 qps: 9152.09 (r/w/o: 6380.97/1846.41/924.71) lat (ms,95%): 110.66 err/s: 0.00 reconn/s: 0.00
[ 322s ] thds: 32 tps: 456.09 qps: 9225.82 (r/w/o: 6484.28/1828.36/913.18) lat (ms,95%): 114.72 err/s: 0.00 reconn/s: 0.00
[ 323s ] thds: 32 tps: 437.90 qps: 8862.93 (r/w/o: 6203.55/1783.58/875.80) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 324s ] thds: 32 tps: 463.20 qps: 9225.93 (r/w/o: 6459.75/1839.78/926.39) lat (ms,95%): 104.84 err/s: 0.00 reconn/s: 0.00
[ 325s ] thds: 32 tps: 443.97 qps: 8873.44 (r/w/o: 6221.61/1763.89/887.94) lat (ms,95%): 114.72 err/s: 0.00 reconn/s: 0.00
[ 326s ] thds: 32 tps: 476.02 qps: 9391.41 (r/w/o: 6557.29/1883.08/951.04) lat (ms,95%): 106.75 err/s: 0.00 reconn/s: 0.00
[ 327s ] thds: 32 tps: 452.95 qps: 9054.09 (r/w/o: 6321.37/1831.82/900.91) lat (ms,95%): 121.08 err/s: 0.00 reconn/s: 0.00
[ 328s ] thds: 32 tps: 444.05 qps: 9010.98 (r/w/o: 6340.69/1776.19/894.10) lat (ms,95%): 114.72 err/s: 0.00 reconn/s: 0.00
[ 329s ] thds: 32 tps: 454.98 qps: 9086.55 (r/w/o: 6349.69/1826.91/909.95) lat (ms,95%): 114.72 err/s: 0.00 reconn/s: 0.00
[ 330s ] thds: 32 tps: 453.80 qps: 9161.87 (r/w/o: 6412.11/1842.17/907.59) lat (ms,95%): 110.66 err/s: 0.00 reconn/s: 0.00
[ 331s ] thds: 32 tps: 334.61 qps: 6412.56 (r/w/o: 4470.81/1272.52/669.22) lat (ms,95%): 150.29 err/s: 0.00 reconn/s: 0.00
[ 332s ] thds: 32 tps: 259.44 qps: 5338.96 (r/w/o: 3766.32/1053.77/518.87) lat (ms,95%): 520.62 err/s: 0.00 reconn/s: 0.00
[ 333s ] thds: 32 tps: 126.00 qps: 2512.03 (r/w/o: 1762.02/498.01/252.00) lat (ms,95%): 669.89 err/s: 0.00 reconn/s: 0.00
[ 334s ] thds: 32 tps: 196.99 qps: 3913.90 (r/w/o: 2730.93/788.98/393.99) lat (ms,95%): 419.45 err/s: 0.00 reconn/s: 0.00
[ 335s ] thds: 32 tps: 164.00 qps: 3271.05 (r/w/o: 2291.04/652.01/328.01) lat (ms,95%): 442.73 err/s: 0.00 reconn/s: 0.00
[ 336s ] thds: 32 tps: 127.98 qps: 2592.60 (r/w/o: 1824.72/511.92/255.96) lat (ms,95%): 601.29 err/s: 0.00 reconn/s: 0.00
[ 337s ] thds: 32 tps: 103.02 qps: 2018.31 (r/w/o: 1401.21/411.06/206.03) lat (ms,95%): 746.32 err/s: 0.00 reconn/s: 0.00
[ 338s ] thds: 32 tps: 75.99 qps: 1546.87 (r/w/o: 1089.91/305.97/150.99) lat (ms,95%): 623.33 err/s: 0.00 reconn/s: 0.00
[ 339s ] thds: 32 tps: 43.00 qps: 875.08 (r/w/o: 615.06/173.02/87.01) lat (ms,95%): 1089.30 err/s: 0.00 reconn/s: 0.00
[ 340s ] thds: 32 tps: 48.00 qps: 934.98 (r/w/o: 645.98/193.00/96.00) lat (ms,95%): 1589.90 err/s: 0.00 reconn/s: 0.00
[ 341s ] thds: 32 tps: 39.00 qps: 817.00 (r/w/o: 577.00/162.00/78.00) lat (ms,95%): 1533.66 err/s: 0.00 reconn/s: 0.00
[ 342s ] thds: 32 tps: 73.00 qps: 1369.00 (r/w/o: 944.00/279.00/146.00) lat (ms,95%): 1069.86 err/s: 0.00 reconn/s: 0.00
[ 343s ] thds: 32 tps: 36.94 qps: 768.70 (r/w/o: 552.07/142.76/73.88) lat (ms,95%): 1453.01 err/s: 0.00 reconn/s: 0.00
[ 344s ] thds: 32 tps: 32.05 qps: 669.14 (r/w/o: 475.81/129.22/64.11) lat (ms,95%): 1401.61 err/s: 0.00 reconn/s: 0.00
[ 345s ] thds: 32 tps: 31.00 qps: 601.00 (r/w/o: 412.00/127.00/62.00) lat (ms,95%): 1938.16 err/s: 0.00 reconn/s: 0.00
[ 346s ] thds: 32 tps: 236.00 qps: 4752.93 (r/w/o: 3315.95/967.99/468.99) lat (ms,95%): 1129.24 err/s: 0.00 reconn/s: 0.00
[ 347s ] thds: 32 tps: 431.83 qps: 8663.57 (r/w/o: 6066.59/1730.31/866.66) lat (ms,95%): 116.80 err/s: 0.00 reconn/s: 0.00
[ 348s ] thds: 32 tps: 432.17 qps: 8628.34 (r/w/o: 6049.34/1714.66/864.33) lat (ms,95%): 127.81 err/s: 0.00 reconn/s: 0.00
[ 349s ] thds: 32 tps: 442.97 qps: 8830.44 (r/w/o: 6168.61/1778.89/882.94) lat (ms,95%): 118.92 err/s: 0.00 reconn/s: 0.00
[ 350s ] thds: 32 tps: 443.00 qps: 8839.04 (r/w/o: 6190.03/1760.01/889.00) lat (ms,95%): 114.72 err/s: 0.00 reconn/s: 0.00
[ 351s ] thds: 32 tps: 453.91 qps: 9096.21 (r/w/o: 6358.75/1829.64/907.82) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 352s ] thds: 32 tps: 454.11 qps: 9129.29 (r/w/o: 6397.60/1823.46/908.23) lat (ms,95%): 108.68 err/s: 0.00 reconn/s: 0.00
[ 353s ] thds: 32 tps: 457.97 qps: 9164.38 (r/w/o: 6427.56/1820.88/915.94) lat (ms,95%): 110.66 err/s: 0.00 reconn/s: 0.00
[ 354s ] thds: 32 tps: 450.00 qps: 9100.08 (r/w/o: 6361.06/1839.02/900.01) lat (ms,95%): 114.72 err/s: 0.00 reconn/s: 0.00
[ 355s ] thds: 32 tps: 467.97 qps: 9200.38 (r/w/o: 6431.57/1832.88/935.94) lat (ms,95%): 106.75 err/s: 0.00 reconn/s: 0.00
[ 356s ] thds: 32 tps: 439.98 qps: 8848.53 (r/w/o: 6200.67/1767.91/879.95) lat (ms,95%): 114.72 err/s: 0.00 reconn/s: 0.00
[ 357s ] thds: 32 tps: 457.98 qps: 9201.60 (r/w/o: 6445.72/1839.92/915.96) lat (ms,95%): 108.68 err/s: 0.00 reconn/s: 0.00
[ 358s ] thds: 32 tps: 452.99 qps: 9041.75 (r/w/o: 6333.82/1801.95/905.97) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 359s ] thds: 32 tps: 464.72 qps: 9255.51 (r/w/o: 6475.16/1851.90/928.45) lat (ms,95%): 110.66 err/s: 0.00 reconn/s: 0.00
[ 360s ] thds: 32 tps: 450.38 qps: 8978.52 (r/w/o: 6276.26/1800.51/901.76) lat (ms,95%): 114.72 err/s: 0.00 reconn/s: 0.00
[ 361s ] thds: 32 tps: 460.65 qps: 9230.91 (r/w/o: 6450.05/1859.57/921.29) lat (ms,95%): 108.68 err/s: 0.00 reconn/s: 0.00
[ 362s ] thds: 32 tps: 453.28 qps: 9106.54 (r/w/o: 6371.88/1828.11/906.55) lat (ms,95%): 104.84 err/s: 0.00 reconn/s: 0.00
[ 363s ] thds: 32 tps: 456.06 qps: 9088.12 (r/w/o: 6369.79/1807.22/911.11) lat (ms,95%): 106.75 err/s: 0.00 reconn/s: 0.00
[ 364s ] thds: 32 tps: 454.99 qps: 9054.72 (r/w/o: 6332.81/1811.94/909.97) lat (ms,95%): 110.66 err/s: 0.00 reconn/s: 0.00
[ 365s ] thds: 32 tps: 458.95 qps: 9188.09 (r/w/o: 6447.36/1821.82/918.91) lat (ms,95%): 110.66 err/s: 0.00 reconn/s: 0.00
[ 366s ] thds: 32 tps: 446.09 qps: 8956.82 (r/w/o: 6253.27/1812.37/891.18) lat (ms,95%): 114.72 err/s: 0.00 reconn/s: 0.00
[ 367s ] thds: 32 tps: 456.96 qps: 9193.15 (r/w/o: 6453.40/1824.83/914.92) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 368s ] thds: 32 tps: 456.98 qps: 9053.52 (r/w/o: 6340.66/1799.90/912.95) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 369s ] thds: 32 tps: 445.00 qps: 8994.96 (r/w/o: 6300.97/1803.99/890.00) lat (ms,95%): 106.75 err/s: 0.00 reconn/s: 0.00
[ 370s ] thds: 32 tps: 440.06 qps: 8705.15 (r/w/o: 6084.80/1739.23/881.12) lat (ms,95%): 125.52 err/s: 0.00 reconn/s: 0.00
[ 371s ] thds: 32 tps: 263.00 qps: 5412.06 (r/w/o: 3787.04/1099.01/526.01) lat (ms,95%): 253.35 err/s: 0.00 reconn/s: 0.00
[ 372s ] thds: 32 tps: 179.99 qps: 3449.78 (r/w/o: 2423.85/665.96/359.98) lat (ms,95%): 467.30 err/s: 0.00 reconn/s: 0.00
[ 373s ] thds: 32 tps: 117.01 qps: 2376.10 (r/w/o: 1670.07/472.02/234.01) lat (ms,95%): 733.00 err/s: 0.00 reconn/s: 0.00
[ 374s ] thds: 32 tps: 227.00 qps: 4513.04 (r/w/o: 3156.03/903.01/454.00) lat (ms,95%): 383.33 err/s: 0.00 reconn/s: 0.00
[ 375s ] thds: 32 tps: 137.00 qps: 2786.01 (r/w/o: 1953.01/559.00/274.00) lat (ms,95%): 467.30 err/s: 0.00 reconn/s: 0.00
[ 376s ] thds: 32 tps: 96.00 qps: 1896.02 (r/w/o: 1331.01/373.00/192.00) lat (ms,95%): 669.89 err/s: 0.00 reconn/s: 0.00
[ 377s ] thds: 32 tps: 48.00 qps: 1009.98 (r/w/o: 710.99/203.00/96.00) lat (ms,95%): 1170.65 err/s: 0.00 reconn/s: 0.00
[ 378s ] thds: 32 tps: 55.00 qps: 1091.01 (r/w/o: 765.01/216.00/110.00) lat (ms,95%): 1453.01 err/s: 0.00 reconn/s: 0.00
[ 379s ] thds: 32 tps: 41.00 qps: 797.00 (r/w/o: 541.00/174.00/82.00) lat (ms,95%): 1708.63 err/s: 0.00 reconn/s: 0.00
[ 380s ] thds: 32 tps: 57.00 qps: 1102.01 (r/w/o: 777.01/211.00/114.00) lat (ms,95%): 1589.90 err/s: 0.00 reconn/s: 0.00
[ 381s ] thds: 32 tps: 44.00 qps: 848.00 (r/w/o: 583.00/177.00/88.00) lat (ms,95%): 1032.01 err/s: 0.00 reconn/s: 0.00
[ 382s ] thds: 32 tps: 43.00 qps: 973.00 (r/w/o: 679.00/208.00/86.00) lat (ms,95%): 1678.14 err/s: 0.00 reconn/s: 0.00
[ 383s ] thds: 32 tps: 42.00 qps: 771.00 (r/w/o: 550.00/137.00/84.00) lat (ms,95%): 1506.29 err/s: 0.00 reconn/s: 0.00
[ 384s ] thds: 32 tps: 30.00 qps: 544.00 (r/w/o: 375.00/109.00/60.00) lat (ms,95%): 1803.47 err/s: 0.00 reconn/s: 0.00
[ 385s ] thds: 32 tps: 58.00 qps: 1277.97 (r/w/o: 892.98/268.99/116.00) lat (ms,95%): 1708.63 err/s: 0.00 reconn/s: 0.00
[ 386s ] thds: 32 tps: 461.94 qps: 9151.86 (r/w/o: 6398.20/1830.77/922.89) lat (ms,95%): 121.08 err/s: 0.00 reconn/s: 0.00
[ 387s ] thds: 32 tps: 435.02 qps: 8701.33 (r/w/o: 6097.23/1733.07/871.03) lat (ms,95%): 125.52 err/s: 0.00 reconn/s: 0.00
[ 388s ] thds: 32 tps: 435.99 qps: 8751.87 (r/w/o: 6138.91/1742.97/869.99) lat (ms,95%): 127.81 err/s: 0.00 reconn/s: 0.00
[ 389s ] thds: 32 tps: 438.00 qps: 8757.91 (r/w/o: 6110.94/1768.98/877.99) lat (ms,95%): 116.80 err/s: 0.00 reconn/s: 0.00
[ 390s ] thds: 32 tps: 449.60 qps: 9049.02 (r/w/o: 6360.39/1789.42/899.21) lat (ms,95%): 110.66 err/s: 0.00 reconn/s: 0.00
[ 391s ] thds: 32 tps: 456.27 qps: 9070.36 (r/w/o: 6316.73/1841.09/912.54) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 392s ] thds: 32 tps: 438.18 qps: 8747.62 (r/w/o: 6142.54/1728.71/876.36) lat (ms,95%): 116.80 err/s: 0.00 reconn/s: 0.00
[ 393s ] thds: 32 tps: 453.94 qps: 9100.85 (r/w/o: 6360.20/1832.77/907.89) lat (ms,95%): 110.66 err/s: 0.00 reconn/s: 0.00
[ 394s ] thds: 32 tps: 440.02 qps: 8856.43 (r/w/o: 6211.30/1766.09/879.04) lat (ms,95%): 110.66 err/s: 0.00 reconn/s: 0.00
[ 395s ] thds: 32 tps: 465.96 qps: 9185.12 (r/w/o: 6411.39/1840.82/932.91) lat (ms,95%): 108.68 err/s: 0.00 reconn/s: 0.00
[ 396s ] thds: 32 tps: 441.05 qps: 8958.03 (r/w/o: 6274.72/1802.21/881.10) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 397s ] thds: 32 tps: 458.99 qps: 9066.88 (r/w/o: 6343.91/1804.98/917.99) lat (ms,95%): 108.68 err/s: 0.00 reconn/s: 0.00
[ 398s ] thds: 32 tps: 450.95 qps: 9041.94 (r/w/o: 6327.26/1813.79/900.89) lat (ms,95%): 108.68 err/s: 0.00 reconn/s: 0.00
[ 399s ] thds: 32 tps: 455.03 qps: 9153.70 (r/w/o: 6414.49/1827.14/912.07) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 400s ] thds: 32 tps: 454.92 qps: 9110.38 (r/w/o: 6380.87/1819.68/909.84) lat (ms,95%): 118.92 err/s: 0.00 reconn/s: 0.00
[ 401s ] thds: 32 tps: 452.13 qps: 9108.63 (r/w/o: 6369.84/1834.53/904.26) lat (ms,95%): 108.68 err/s: 0.00 reconn/s: 0.00
[ 402s ] thds: 32 tps: 455.96 qps: 9087.26 (r/w/o: 6363.48/1811.85/911.93) lat (ms,95%): 114.72 err/s: 0.00 reconn/s: 0.00
[ 403s ] thds: 32 tps: 455.04 qps: 9039.72 (r/w/o: 6330.51/1799.14/910.07) lat (ms,95%): 118.92 err/s: 0.00 reconn/s: 0.00
[ 404s ] thds: 32 tps: 454.78 qps: 9159.62 (r/w/o: 6414.93/1835.12/909.57) lat (ms,95%): 110.66 err/s: 0.00 reconn/s: 0.00
[ 405s ] thds: 32 tps: 456.17 qps: 9062.37 (r/w/o: 6325.35/1824.68/912.34) lat (ms,95%): 114.72 err/s: 0.00 reconn/s: 0.00
[ 406s ] thds: 32 tps: 458.64 qps: 9188.86 (r/w/o: 6445.99/1826.58/916.29) lat (ms,95%): 108.68 err/s: 0.00 reconn/s: 0.00
[ 407s ] thds: 32 tps: 443.35 qps: 8849.99 (r/w/o: 6189.89/1774.40/885.70) lat (ms,95%): 116.80 err/s: 0.00 reconn/s: 0.00
[ 408s ] thds: 32 tps: 464.05 qps: 9291.91 (r/w/o: 6496.63/1865.18/930.09) lat (ms,95%): 104.84 err/s: 0.00 reconn/s: 0.00
[ 409s ] thds: 32 tps: 452.97 qps: 8982.35 (r/w/o: 6300.54/1777.87/903.93) lat (ms,95%): 110.66 err/s: 0.00 reconn/s: 0.00
[ 410s ] thds: 32 tps: 457.99 qps: 9295.86 (r/w/o: 6499.90/1877.97/917.99) lat (ms,95%): 104.84 err/s: 0.00 reconn/s: 0.00
[ 411s ] thds: 32 tps: 446.03 qps: 8890.63 (r/w/o: 6242.44/1757.12/891.06) lat (ms,95%): 114.72 err/s: 0.00 reconn/s: 0.00
[ 412s ] thds: 32 tps: 469.97 qps: 9347.39 (r/w/o: 6526.58/1880.88/939.94) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 413s ] thds: 32 tps: 405.03 qps: 8162.53 (r/w/o: 5739.37/1612.10/811.05) lat (ms,95%): 164.45 err/s: 0.00 reconn/s: 0.00
[ 414s ] thds: 32 tps: 276.86 qps: 5471.28 (r/w/o: 3822.10/1095.46/553.72) lat (ms,95%): 257.95 err/s: 0.00 reconn/s: 0.00
[ 415s ] thds: 32 tps: 276.05 qps: 5509.90 (r/w/o: 3859.63/1098.18/552.09) lat (ms,95%): 325.98 err/s: 0.00 reconn/s: 0.00
[ 416s ] thds: 32 tps: 228.08 qps: 4550.66 (r/w/o: 3179.16/915.33/456.17) lat (ms,95%): 390.30 err/s: 0.00 reconn/s: 0.00
[ 417s ] thds: 32 tps: 233.00 qps: 4630.91 (r/w/o: 3231.94/932.98/465.99) lat (ms,95%): 383.33 err/s: 0.00 reconn/s: 0.00
[ 418s ] thds: 32 tps: 114.00 qps: 2342.97 (r/w/o: 1640.98/473.99/228.00) lat (ms,95%): 733.00 err/s: 0.00 reconn/s: 0.00
[ 419s ] thds: 32 tps: 130.00 qps: 2538.04 (r/w/o: 1777.03/501.01/260.00) lat (ms,95%): 669.89 err/s: 0.00 reconn/s: 0.00
[ 420s ] thds: 32 tps: 99.00 qps: 2038.02 (r/w/o: 1444.02/396.00/198.00) lat (ms,95%): 646.19 err/s: 0.00 reconn/s: 0.00
[ 421s ] thds: 32 tps: 58.00 qps: 1127.96 (r/w/o: 786.97/224.99/116.00) lat (ms,95%): 943.16 err/s: 0.00 reconn/s: 0.00
[ 422s ] thds: 32 tps: 63.00 qps: 1226.03 (r/w/o: 838.02/262.01/126.00) lat (ms,95%): 1050.76 err/s: 0.00 reconn/s: 0.00
[ 423s ] thds: 32 tps: 39.00 qps: 836.00 (r/w/o: 593.00/165.00/78.00) lat (ms,95%): 1618.78 err/s: 0.00 reconn/s: 0.00
[ 424s ] thds: 32 tps: 34.00 qps: 669.01 (r/w/o: 479.00/122.00/68.00) lat (ms,95%): 1739.68 err/s: 0.00 reconn/s: 0.00
[ 425s ] thds: 32 tps: 45.00 qps: 851.00 (r/w/o: 586.00/175.00/90.00) lat (ms,95%): 1618.78 err/s: 0.00 reconn/s: 0.00
[ 426s ] thds: 32 tps: 41.00 qps: 876.98 (r/w/o: 628.99/166.00/82.00) lat (ms,95%): 1069.86 err/s: 0.00 reconn/s: 0.00
[ 427s ] thds: 32 tps: 24.00 qps: 456.01 (r/w/o: 300.01/108.00/48.00) lat (ms,95%): 2045.74 err/s: 0.00 reconn/s: 0.00
[ 428s ] thds: 32 tps: 362.97 qps: 7400.37 (r/w/o: 5174.56/1499.87/725.94) lat (ms,95%): 580.02 err/s: 0.00 reconn/s: 0.00
[ 429s ] thds: 32 tps: 450.03 qps: 8820.64 (r/w/o: 6181.45/1739.13/900.07) lat (ms,95%): 116.80 err/s: 0.00 reconn/s: 0.00
[ 430s ] thds: 32 tps: 431.83 qps: 8742.54 (r/w/o: 6125.58/1753.31/863.66) lat (ms,95%): 114.72 err/s: 0.00 reconn/s: 0.00
[ 431s ] thds: 32 tps: 446.12 qps: 8816.39 (r/w/o: 6137.66/1786.48/892.24) lat (ms,95%): 121.08 err/s: 0.00 reconn/s: 0.00
[ 432s ] thds: 32 tps: 434.03 qps: 8709.59 (r/w/o: 6126.42/1715.12/868.06) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 433s ] thds: 32 tps: 440.02 qps: 8899.46 (r/w/o: 6239.32/1780.09/880.05) lat (ms,95%): 114.72 err/s: 0.00 reconn/s: 0.00
[ 434s ] thds: 32 tps: 436.00 qps: 8691.93 (r/w/o: 6075.95/1743.99/871.99) lat (ms,95%): 114.72 err/s: 0.00 reconn/s: 0.00
[ 435s ] thds: 32 tps: 457.00 qps: 9167.00 (r/w/o: 6420.00/1833.00/914.00) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 436s ] thds: 32 tps: 452.77 qps: 8992.41 (r/w/o: 6292.78/1794.08/905.54) lat (ms,95%): 106.75 err/s: 0.00 reconn/s: 0.00
[ 437s ] thds: 32 tps: 445.17 qps: 8992.53 (r/w/o: 6301.47/1800.71/890.35) lat (ms,95%): 110.66 err/s: 0.00 reconn/s: 0.00
[ 438s ] thds: 32 tps: 454.96 qps: 9083.18 (r/w/o: 6356.43/1816.84/909.92) lat (ms,95%): 110.66 err/s: 0.00 reconn/s: 0.00
[ 439s ] thds: 32 tps: 458.06 qps: 9149.28 (r/w/o: 6383.89/1849.26/916.13) lat (ms,95%): 110.66 err/s: 0.00 reconn/s: 0.00
[ 440s ] thds: 32 tps: 455.94 qps: 9083.84 (r/w/o: 6375.19/1797.77/910.88) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 441s ] thds: 32 tps: 449.09 qps: 8962.71 (r/w/o: 6269.20/1794.34/899.17) lat (ms,95%): 116.80 err/s: 0.00 reconn/s: 0.00
[ 442s ] thds: 32 tps: 464.97 qps: 9267.31 (r/w/o: 6479.52/1858.86/928.93) lat (ms,95%): 104.84 err/s: 0.00 reconn/s: 0.00
[ 443s ] thds: 32 tps: 440.03 qps: 8913.54 (r/w/o: 6234.38/1798.11/881.05) lat (ms,95%): 116.80 err/s: 0.00 reconn/s: 0.00
[ 444s ] thds: 32 tps: 462.97 qps: 9169.44 (r/w/o: 6431.61/1811.89/925.94) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 445s ] thds: 32 tps: 446.94 qps: 8934.80 (r/w/o: 6248.16/1793.76/892.88) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 446s ] thds: 32 tps: 457.04 qps: 9175.82 (r/w/o: 6429.57/1832.16/914.08) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 447s ] thds: 32 tps: 446.03 qps: 8907.57 (r/w/o: 6240.40/1774.11/893.06) lat (ms,95%): 118.92 err/s: 0.00 reconn/s: 0.00
[ 448s ] thds: 32 tps: 461.83 qps: 9257.64 (r/w/o: 6460.65/1874.32/922.67) lat (ms,95%): 116.80 err/s: 0.00 reconn/s: 0.00
[ 449s ] thds: 32 tps: 459.10 qps: 9089.89 (r/w/o: 6363.33/1807.38/919.19) lat (ms,95%): 116.80 err/s: 0.00 reconn/s: 0.00
[ 450s ] thds: 32 tps: 447.07 qps: 9039.40 (r/w/o: 6334.98/1810.28/894.14) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 451s ] thds: 32 tps: 457.88 qps: 9109.71 (r/w/o: 6398.39/1795.55/915.77) lat (ms,95%): 108.68 err/s: 0.00 reconn/s: 0.00
[ 452s ] thds: 32 tps: 446.96 qps: 8990.21 (r/w/o: 6277.45/1818.84/893.92) lat (ms,95%): 108.68 err/s: 0.00 reconn/s: 0.00
[ 453s ] thds: 32 tps: 236.10 qps: 4648.92 (r/w/o: 3262.35/914.38/472.20) lat (ms,95%): 337.94 err/s: 0.00 reconn/s: 0.00
[ 454s ] thds: 32 tps: 156.00 qps: 3128.99 (r/w/o: 2188.00/629.00/312.00) lat (ms,95%): 520.62 err/s: 0.00 reconn/s: 0.00
[ 455s ] thds: 32 tps: 153.00 qps: 3019.01 (r/w/o: 2107.01/606.00/306.00) lat (ms,95%): 657.93 err/s: 0.00 reconn/s: 0.00
[ 456s ] thds: 32 tps: 186.00 qps: 3719.95 (r/w/o: 2605.96/741.99/371.99) lat (ms,95%): 427.07 err/s: 0.00 reconn/s: 0.00
[ 457s ] thds: 32 tps: 166.00 qps: 3350.10 (r/w/o: 2351.07/667.02/332.01) lat (ms,95%): 419.45 err/s: 0.00 reconn/s: 0.00
[ 458s ] thds: 32 tps: 72.00 qps: 1501.97 (r/w/o: 1056.98/300.99/144.00) lat (ms,95%): 682.06 err/s: 0.00 reconn/s: 0.00
[ 459s ] thds: 32 tps: 69.00 qps: 1345.01 (r/w/o: 939.01/268.00/138.00) lat (ms,95%): 1708.63 err/s: 0.00 reconn/s: 0.00
[ 460s ] thds: 32 tps: 40.00 qps: 767.01 (r/w/o: 534.00/153.00/80.00) lat (ms,95%): 1304.21 err/s: 0.00 reconn/s: 0.00
[ 461s ] thds: 32 tps: 54.00 qps: 1089.98 (r/w/o: 759.99/222.00/108.00) lat (ms,95%): 1129.24 err/s: 0.00 reconn/s: 0.00
[ 462s ] thds: 32 tps: 53.00 qps: 1063.93 (r/w/o: 751.95/205.99/105.99) lat (ms,95%): 1258.08 err/s: 0.00 reconn/s: 0.00
[ 463s ] thds: 32 tps: 45.00 qps: 905.06 (r/w/o: 628.04/187.01/90.01) lat (ms,95%): 1258.08 err/s: 0.00 reconn/s: 0.00
[ 464s ] thds: 32 tps: 61.00 qps: 1181.99 (r/w/o: 825.99/234.00/122.00) lat (ms,95%): 1327.91 err/s: 0.00 reconn/s: 0.00
[ 465s ] thds: 32 tps: 24.00 qps: 558.00 (r/w/o: 410.00/100.00/48.00) lat (ms,95%): 1304.21 err/s: 0.00 reconn/s: 0.00
[ 466s ] thds: 32 tps: 54.00 qps: 1007.99 (r/w/o: 683.99/216.00/108.00) lat (ms,95%): 1533.66 err/s: 0.00 reconn/s: 0.00
[ 467s ] thds: 32 tps: 224.87 qps: 4592.31 (r/w/o: 3207.12/937.45/447.74) lat (ms,95%): 831.46 err/s: 0.00 reconn/s: 0.00
[ 468s ] thds: 32 tps: 455.26 qps: 9000.09 (r/w/o: 6298.56/1790.01/911.52) lat (ms,95%): 114.72 err/s: 0.00 reconn/s: 0.00
[ 469s ] thds: 32 tps: 448.98 qps: 9013.53 (r/w/o: 6309.67/1804.91/898.95) lat (ms,95%): 116.80 err/s: 0.00 reconn/s: 0.00
[ 470s ] thds: 32 tps: 435.03 qps: 8814.52 (r/w/o: 6186.37/1758.10/870.05) lat (ms,95%): 116.80 err/s: 0.00 reconn/s: 0.00
[ 471s ] thds: 32 tps: 452.01 qps: 8943.19 (r/w/o: 6246.14/1793.04/904.02) lat (ms,95%): 114.72 err/s: 0.00 reconn/s: 0.00
[ 472s ] thds: 32 tps: 447.97 qps: 8948.42 (r/w/o: 6266.59/1785.88/895.94) lat (ms,95%): 114.72 err/s: 0.00 reconn/s: 0.00
[ 473s ] thds: 32 tps: 451.99 qps: 9010.85 (r/w/o: 6302.90/1804.97/902.99) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 474s ] thds: 32 tps: 460.04 qps: 9194.76 (r/w/o: 6442.53/1831.15/921.08) lat (ms,95%): 108.68 err/s: 0.00 reconn/s: 0.00
[ 475s ] thds: 32 tps: 439.99 qps: 8900.70 (r/w/o: 6235.79/1784.94/879.97) lat (ms,95%): 110.66 err/s: 0.00 reconn/s: 0.00
[ 476s ] thds: 32 tps: 446.98 qps: 9030.69 (r/w/o: 6319.78/1816.94/893.97) lat (ms,95%): 108.68 err/s: 0.00 reconn/s: 0.00
[ 477s ] thds: 32 tps: 461.03 qps: 9164.53 (r/w/o: 6417.37/1825.11/922.05) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 478s ] thds: 32 tps: 455.01 qps: 9139.10 (r/w/o: 6406.07/1824.02/909.01) lat (ms,95%): 108.68 err/s: 0.00 reconn/s: 0.00
[ 479s ] thds: 32 tps: 466.98 qps: 9197.70 (r/w/o: 6421.79/1840.94/934.97) lat (ms,95%): 110.66 err/s: 0.00 reconn/s: 0.00
[ 480s ] thds: 32 tps: 439.98 qps: 8904.56 (r/w/o: 6249.69/1774.91/879.96) lat (ms,95%): 108.68 err/s: 0.00 reconn/s: 0.00
[ 481s ] thds: 32 tps: 457.97 qps: 9153.45 (r/w/o: 6401.62/1835.89/915.95) lat (ms,95%): 108.68 err/s: 0.00 reconn/s: 0.00
[ 482s ] thds: 32 tps: 446.02 qps: 8945.45 (r/w/o: 6251.31/1803.09/891.04) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 483s ] thds: 32 tps: 465.04 qps: 9233.72 (r/w/o: 6472.50/1832.14/929.07) lat (ms,95%): 110.66 err/s: 0.00 reconn/s: 0.00
[ 484s ] thds: 32 tps: 452.01 qps: 9015.10 (r/w/o: 6311.07/1798.02/906.01) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 485s ] thds: 32 tps: 451.00 qps: 9006.96 (r/w/o: 6295.97/1810.99/900.00) lat (ms,95%): 110.66 err/s: 0.00 reconn/s: 0.00
[ 486s ] thds: 32 tps: 459.01 qps: 9217.15 (r/w/o: 6455.10/1842.03/920.01) lat (ms,95%): 110.66 err/s: 0.00 reconn/s: 0.00
[ 487s ] thds: 32 tps: 448.90 qps: 8955.99 (r/w/o: 6277.59/1780.60/897.80) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 488s ] thds: 32 tps: 468.05 qps: 9351.95 (r/w/o: 6542.66/1875.19/934.09) lat (ms,95%): 106.75 err/s: 0.00 reconn/s: 0.00
[ 489s ] thds: 32 tps: 436.75 qps: 8818.91 (r/w/o: 6156.45/1786.97/875.49) lat (ms,95%): 110.66 err/s: 0.00 reconn/s: 0.00
[ 490s ] thds: 32 tps: 473.24 qps: 9442.70 (r/w/o: 6635.30/1860.93/946.47) lat (ms,95%): 110.66 err/s: 0.00 reconn/s: 0.00
[ 491s ] thds: 32 tps: 459.08 qps: 9083.57 (r/w/o: 6339.10/1826.32/918.16) lat (ms,95%): 116.80 err/s: 0.00 reconn/s: 0.00
[ 492s ] thds: 32 tps: 424.00 qps: 8456.08 (r/w/o: 5927.06/1681.02/848.01) lat (ms,95%): 130.13 err/s: 0.00 reconn/s: 0.00
[ 493s ] thds: 32 tps: 249.00 qps: 5069.05 (r/w/o: 3561.04/1010.01/498.01) lat (ms,95%): 344.08 err/s: 0.00 reconn/s: 0.00
[ 494s ] thds: 32 tps: 177.98 qps: 3512.54 (r/w/o: 2449.68/706.91/355.95) lat (ms,95%): 442.73 err/s: 0.00 reconn/s: 0.00
[ 495s ] thds: 32 tps: 153.00 qps: 3080.97 (r/w/o: 2156.98/617.99/306.00) lat (ms,95%): 502.20 err/s: 0.00 reconn/s: 0.00
[ 496s ] thds: 32 tps: 160.00 qps: 3194.96 (r/w/o: 2237.97/636.99/320.00) lat (ms,95%): 549.52 err/s: 0.00 reconn/s: 0.00
[ 497s ] thds: 32 tps: 136.02 qps: 2676.40 (r/w/o: 1866.28/538.08/272.04) lat (ms,95%): 590.56 err/s: 0.00 reconn/s: 0.00
[ 498s ] thds: 32 tps: 92.00 qps: 1850.01 (r/w/o: 1297.01/369.00/184.00) lat (ms,95%): 707.07 err/s: 0.00 reconn/s: 0.00
[ 499s ] thds: 32 tps: 80.00 qps: 1643.96 (r/w/o: 1168.97/314.99/160.00) lat (ms,95%): 1129.24 err/s: 0.00 reconn/s: 0.00
[ 500s ] thds: 32 tps: 79.00 qps: 1536.06 (r/w/o: 1063.04/315.01/158.01) lat (ms,95%): 1069.86 err/s: 0.00 reconn/s: 0.00
[ 501s ] thds: 32 tps: 45.00 qps: 894.95 (r/w/o: 624.97/179.99/90.00) lat (ms,95%): 977.74 err/s: 0.00 reconn/s: 0.00
[ 502s ] thds: 32 tps: 48.00 qps: 1026.04 (r/w/o: 730.03/200.01/96.00) lat (ms,95%): 1327.91 err/s: 0.00 reconn/s: 0.00
[ 503s ] thds: 32 tps: 79.00 qps: 1518.00 (r/w/o: 1047.00/313.00/158.00) lat (ms,95%): 1013.60 err/s: 0.00 reconn/s: 0.00
[ 504s ] thds: 32 tps: 45.00 qps: 872.99 (r/w/o: 610.99/172.00/90.00) lat (ms,95%): 1149.76 err/s: 0.00 reconn/s: 0.00
[ 505s ] thds: 32 tps: 32.00 qps: 644.97 (r/w/o: 439.98/140.99/64.00) lat (ms,95%): 1170.65 err/s: 0.00 reconn/s: 0.00
[ 506s ] thds: 32 tps: 25.00 qps: 482.03 (r/w/o: 345.02/87.01/50.00) lat (ms,95%): 1938.16 err/s: 0.00 reconn/s: 0.00
[ 507s ] thds: 32 tps: 31.00 qps: 680.00 (r/w/o: 491.00/127.00/62.00) lat (ms,95%): 1938.16 err/s: 0.00 reconn/s: 0.00
[ 508s ] thds: 32 tps: 428.94 qps: 8616.79 (r/w/o: 6025.15/1733.76/857.88) lat (ms,95%): 434.83 err/s: 0.00 reconn/s: 0.00
[ 509s ] thds: 32 tps: 438.98 qps: 8745.52 (r/w/o: 6120.66/1748.90/875.95) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 510s ] thds: 32 tps: 436.05 qps: 8840.06 (r/w/o: 6182.74/1783.21/874.10) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 511s ] thds: 32 tps: 445.01 qps: 8798.18 (r/w/o: 6157.12/1751.03/890.02) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 512s ] thds: 32 tps: 446.88 qps: 8890.62 (r/w/o: 6231.33/1765.53/893.76) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 513s ] thds: 32 tps: 450.13 qps: 9109.67 (r/w/o: 6364.86/1844.54/900.26) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 514s ] thds: 32 tps: 447.95 qps: 8979.92 (r/w/o: 6307.24/1776.79/895.89) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 515s ] thds: 32 tps: 439.97 qps: 8804.50 (r/w/o: 6148.65/1776.90/878.95) lat (ms,95%): 114.72 err/s: 0.00 reconn/s: 0.00
[ 516s ] thds: 32 tps: 462.09 qps: 9176.86 (r/w/o: 6426.30/1825.37/925.19) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 517s ] thds: 32 tps: 443.87 qps: 8880.34 (r/w/o: 6228.13/1765.47/886.73) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 518s ] thds: 32 tps: 452.05 qps: 9043.97 (r/w/o: 6322.68/1816.19/905.10) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 519s ] thds: 32 tps: 462.04 qps: 9197.77 (r/w/o: 6433.54/1840.15/924.08) lat (ms,95%): 110.66 err/s: 0.00 reconn/s: 0.00
[ 520s ] thds: 32 tps: 440.03 qps: 8840.59 (r/w/o: 6170.41/1790.12/880.06) lat (ms,95%): 116.80 err/s: 0.00 reconn/s: 0.00
[ 521s ] thds: 32 tps: 459.94 qps: 9246.73 (r/w/o: 6491.11/1835.75/919.87) lat (ms,95%): 110.66 err/s: 0.00 reconn/s: 0.00
[ 522s ] thds: 32 tps: 445.04 qps: 8887.87 (r/w/o: 6218.61/1779.17/890.09) lat (ms,95%): 106.75 err/s: 0.00 reconn/s: 0.00
[ 523s ] thds: 32 tps: 454.01 qps: 9121.17 (r/w/o: 6392.12/1821.03/908.02) lat (ms,95%): 110.66 err/s: 0.00 reconn/s: 0.00
[ 524s ] thds: 32 tps: 462.96 qps: 9160.20 (r/w/o: 6407.44/1826.84/925.92) lat (ms,95%): 106.75 err/s: 0.00 reconn/s: 0.00
[ 525s ] thds: 32 tps: 443.03 qps: 8944.63 (r/w/o: 6259.44/1799.13/886.06) lat (ms,95%): 108.68 err/s: 0.00 reconn/s: 0.00
[ 526s ] thds: 32 tps: 456.89 qps: 9118.80 (r/w/o: 6392.45/1812.56/913.78) lat (ms,95%): 110.66 err/s: 0.00 reconn/s: 0.00
[ 527s ] thds: 32 tps: 454.03 qps: 9089.51 (r/w/o: 6353.36/1828.10/908.05) lat (ms,95%): 110.66 err/s: 0.00 reconn/s: 0.00
[ 528s ] thds: 32 tps: 448.12 qps: 9008.38 (r/w/o: 6296.67/1815.48/896.24) lat (ms,95%): 108.68 err/s: 0.00 reconn/s: 0.00
[ 529s ] thds: 32 tps: 459.00 qps: 9093.93 (r/w/o: 6375.95/1799.99/917.99) lat (ms,95%): 110.66 err/s: 0.00 reconn/s: 0.00
[ 530s ] thds: 32 tps: 463.94 qps: 9155.72 (r/w/o: 6392.11/1837.74/925.87) lat (ms,95%): 108.68 err/s: 0.00 reconn/s: 0.00
[ 531s ] thds: 32 tps: 446.99 qps: 9114.86 (r/w/o: 6406.90/1811.97/895.99) lat (ms,95%): 114.72 err/s: 0.00 reconn/s: 0.00
[ 532s ] thds: 32 tps: 431.04 qps: 8696.90 (r/w/o: 6071.63/1763.18/862.09) lat (ms,95%): 118.92 err/s: 0.00 reconn/s: 0.00
[ 533s ] thds: 32 tps: 472.03 qps: 9296.53 (r/w/o: 6527.37/1825.10/944.05) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 534s ] thds: 32 tps: 394.00 qps: 7795.04 (r/w/o: 5434.03/1573.01/788.00) lat (ms,95%): 150.29 err/s: 0.00 reconn/s: 0.00
[ 535s ] thds: 32 tps: 228.99 qps: 4652.90 (r/w/o: 3267.93/926.98/457.99) lat (ms,95%): 383.33 err/s: 0.00 reconn/s: 0.00
[ 536s ] thds: 32 tps: 212.01 qps: 4219.17 (r/w/o: 2954.12/841.03/424.02) lat (ms,95%): 363.18 err/s: 0.00 reconn/s: 0.00
[ 537s ] thds: 32 tps: 167.00 qps: 3375.98 (r/w/o: 2381.99/660.00/334.00) lat (ms,95%): 467.30 err/s: 0.00 reconn/s: 0.00
[ 538s ] thds: 32 tps: 112.00 qps: 2198.98 (r/w/o: 1511.98/463.00/224.00) lat (ms,95%): 646.19 err/s: 0.00 reconn/s: 0.00
[ 539s ] thds: 32 tps: 80.00 qps: 1566.00 (r/w/o: 1092.00/314.00/160.00) lat (ms,95%): 861.95 err/s: 0.00 reconn/s: 0.00
[ 540s ] thds: 32 tps: 106.00 qps: 2184.93 (r/w/o: 1549.95/422.99/211.99) lat (ms,95%): 733.00 err/s: 0.00 reconn/s: 0.00
[ 541s ] thds: 32 tps: 65.00 qps: 1274.04 (r/w/o: 891.03/253.01/130.00) lat (ms,95%): 802.05 err/s: 0.00 reconn/s: 0.00
[ 542s ] thds: 32 tps: 82.00 qps: 1662.91 (r/w/o: 1169.94/328.98/163.99) lat (ms,95%): 1032.01 err/s: 0.00 reconn/s: 0.00
[ 543s ] thds: 32 tps: 53.00 qps: 1031.06 (r/w/o: 716.04/209.01/106.01) lat (ms,95%): 960.30 err/s: 0.00 reconn/s: 0.00
[ 544s ] thds: 32 tps: 57.00 qps: 1106.98 (r/w/o: 766.99/226.00/114.00) lat (ms,95%): 1191.92 err/s: 0.00 reconn/s: 0.00
[ 545s ] thds: 32 tps: 29.00 qps: 655.96 (r/w/o: 474.97/122.99/58.00) lat (ms,95%): 1708.63 err/s: 0.00 reconn/s: 0.00
[ 546s ] thds: 32 tps: 49.00 qps: 978.07 (r/w/o: 681.05/199.01/98.01) lat (ms,95%): 1401.61 err/s: 0.00 reconn/s: 0.00
[ 547s ] thds: 32 tps: 31.00 qps: 576.00 (r/w/o: 402.00/112.00/62.00) lat (ms,95%): 1739.68 err/s: 0.00 reconn/s: 0.00
[ 548s ] thds: 32 tps: 37.00 qps: 732.98 (r/w/o: 500.99/158.00/74.00) lat (ms,95%): 1648.20 err/s: 0.00 reconn/s: 0.00
[ 549s ] thds: 32 tps: 442.01 qps: 8873.15 (r/w/o: 6208.10/1781.03/884.01) lat (ms,95%): 363.18 err/s: 0.00 reconn/s: 0.00
[ 550s ] thds: 32 tps: 444.98 qps: 8857.51 (r/w/o: 6200.66/1766.90/889.95) lat (ms,95%): 116.80 err/s: 0.00 reconn/s: 0.00
[ 551s ] thds: 32 tps: 439.97 qps: 8860.49 (r/w/o: 6195.64/1785.90/878.95) lat (ms,95%): 110.66 err/s: 0.00 reconn/s: 0.00
[ 552s ] thds: 32 tps: 441.01 qps: 8841.22 (r/w/o: 6194.16/1764.04/883.02) lat (ms,95%): 114.72 err/s: 0.00 reconn/s: 0.00
[ 553s ] thds: 32 tps: 448.95 qps: 8966.93 (r/w/o: 6290.25/1778.79/897.89) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 554s ] thds: 32 tps: 445.54 qps: 8908.72 (r/w/o: 6224.54/1793.11/891.07) lat (ms,95%): 114.72 err/s: 0.00 reconn/s: 0.00
[ 555s ] thds: 32 tps: 445.56 qps: 8963.45 (r/w/o: 6286.05/1786.27/891.13) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 556s ] thds: 32 tps: 457.99 qps: 9131.73 (r/w/o: 6379.81/1836.94/914.97) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 557s ] thds: 32 tps: 448.01 qps: 8994.21 (r/w/o: 6299.15/1798.04/897.02) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 558s ] thds: 32 tps: 459.98 qps: 9176.64 (r/w/o: 6426.75/1829.93/919.96) lat (ms,95%): 108.68 err/s: 0.00 reconn/s: 0.00
[ 559s ] thds: 32 tps: 470.02 qps: 9253.36 (r/w/o: 6464.25/1849.07/940.04) lat (ms,95%): 110.66 err/s: 0.00 reconn/s: 0.00
[ 560s ] thds: 32 tps: 450.72 qps: 9126.42 (r/w/o: 6400.09/1824.88/901.45) lat (ms,95%): 108.68 err/s: 0.00 reconn/s: 0.00
[ 561s ] thds: 32 tps: 458.25 qps: 9218.02 (r/w/o: 6447.51/1854.01/916.50) lat (ms,95%): 106.75 err/s: 0.00 reconn/s: 0.00
[ 562s ] thds: 32 tps: 462.68 qps: 9199.65 (r/w/o: 6448.55/1825.74/925.36) lat (ms,95%): 108.68 err/s: 0.00 reconn/s: 0.00
[ 563s ] thds: 32 tps: 449.28 qps: 9016.67 (r/w/o: 6299.96/1819.14/897.56) lat (ms,95%): 108.68 err/s: 0.00 reconn/s: 0.00
[ 564s ] thds: 32 tps: 460.95 qps: 9207.07 (r/w/o: 6454.35/1829.82/922.91) lat (ms,95%): 110.66 err/s: 0.00 reconn/s: 0.00
[ 565s ] thds: 32 tps: 461.07 qps: 9259.33 (r/w/o: 6479.93/1857.27/922.13) lat (ms,95%): 106.75 err/s: 0.00 reconn/s: 0.00
[ 566s ] thds: 32 tps: 450.94 qps: 9028.75 (r/w/o: 6311.13/1815.75/901.88) lat (ms,95%): 110.66 err/s: 0.00 reconn/s: 0.00
[ 567s ] thds: 32 tps: 475.05 qps: 9414.06 (r/w/o: 6599.74/1864.21/950.11) lat (ms,95%): 108.68 err/s: 0.00 reconn/s: 0.00
[ 568s ] thds: 32 tps: 448.03 qps: 8993.62 (r/w/o: 6291.43/1806.12/896.06) lat (ms,95%): 110.66 err/s: 0.00 reconn/s: 0.00
[ 569s ] thds: 32 tps: 463.97 qps: 9260.44 (r/w/o: 6473.61/1858.89/927.94) lat (ms,95%): 116.80 err/s: 0.00 reconn/s: 0.00
[ 570s ] thds: 32 tps: 463.80 qps: 9242.01 (r/w/o: 6458.21/1856.20/927.60) lat (ms,95%): 110.66 err/s: 0.00 reconn/s: 0.00
[ 571s ] thds: 32 tps: 448.20 qps: 9147.04 (r/w/o: 6415.83/1834.81/896.40) lat (ms,95%): 108.68 err/s: 0.00 reconn/s: 0.00
[ 572s ] thds: 32 tps: 460.01 qps: 9024.27 (r/w/o: 6325.19/1779.05/920.03) lat (ms,95%): 110.66 err/s: 0.00 reconn/s: 0.00
[ 573s ] thds: 32 tps: 449.99 qps: 9067.88 (r/w/o: 6340.91/1826.98/899.99) lat (ms,95%): 110.66 err/s: 0.00 reconn/s: 0.00
[ 574s ] thds: 32 tps: 347.02 qps: 6845.43 (r/w/o: 4810.30/1341.08/694.04) lat (ms,95%): 116.80 err/s: 0.00 reconn/s: 0.00
[ 575s ] thds: 32 tps: 233.00 qps: 4645.04 (r/w/o: 3244.03/935.01/466.00) lat (ms,95%): 397.39 err/s: 0.00 reconn/s: 0.00
[ 576s ] thds: 32 tps: 196.00 qps: 3955.93 (r/w/o: 2772.95/791.99/390.99) lat (ms,95%): 419.45 err/s: 0.00 reconn/s: 0.00
[ 577s ] thds: 32 tps: 186.00 qps: 3637.05 (r/w/o: 2525.04/739.01/373.01) lat (ms,95%): 411.96 err/s: 0.00 reconn/s: 0.00
[ 578s ] thds: 32 tps: 157.00 qps: 3260.01 (r/w/o: 2303.01/643.00/314.00) lat (ms,95%): 511.33 err/s: 0.00 reconn/s: 0.00
[ 579s ] thds: 32 tps: 125.00 qps: 2578.93 (r/w/o: 1801.95/526.99/249.99) lat (ms,95%): 549.52 err/s: 0.00 reconn/s: 0.00
[ 580s ] thds: 32 tps: 94.00 qps: 1743.02 (r/w/o: 1217.02/338.00/188.00) lat (ms,95%): 831.46 err/s: 0.00 reconn/s: 0.00
[ 581s ] thds: 32 tps: 68.00 qps: 1370.90 (r/w/o: 965.93/268.98/135.99) lat (ms,95%): 1170.65 err/s: 0.00 reconn/s: 0.00
[ 582s ] thds: 32 tps: 86.01 qps: 1783.15 (r/w/o: 1236.11/375.03/172.01) lat (ms,95%): 759.88 err/s: 0.00 reconn/s: 0.00
[ 583s ] thds: 32 tps: 70.99 qps: 1347.77 (r/w/o: 959.83/245.96/141.98) lat (ms,95%): 995.51 err/s: 0.00 reconn/s: 0.00
[ 584s ] thds: 32 tps: 35.01 qps: 687.12 (r/w/o: 473.08/144.03/70.01) lat (ms,95%): 1327.91 err/s: 0.00 reconn/s: 0.00
[ 585s ] thds: 32 tps: 39.00 qps: 893.01 (r/w/o: 628.00/187.00/78.00) lat (ms,95%): 1376.60 err/s: 0.00 reconn/s: 0.00
[ 586s ] thds: 32 tps: 34.00 qps: 624.00 (r/w/o: 442.00/114.00/68.00) lat (ms,95%): 2082.91 err/s: 0.00 reconn/s: 0.00
[ 587s ] thds: 32 tps: 56.00 qps: 1084.00 (r/w/o: 752.00/220.00/112.00) lat (ms,95%): 1533.66 err/s: 0.00 reconn/s: 0.00
[ 588s ] thds: 32 tps: 28.00 qps: 522.00 (r/w/o: 350.00/116.00/56.00) lat (ms,95%): 1149.76 err/s: 0.00 reconn/s: 0.00
[ 589s ] thds: 32 tps: 23.00 qps: 506.00 (r/w/o: 380.00/80.00/46.00) lat (ms,95%): 1739.68 err/s: 0.00 reconn/s: 0.00
[ 590s ] thds: 32 tps: 292.94 qps: 5919.69 (r/w/o: 4115.09/1218.73/585.87) lat (ms,95%): 1050.76 err/s: 0.00 reconn/s: 0.00
[ 591s ] thds: 32 tps: 439.02 qps: 8742.39 (r/w/o: 6138.27/1726.08/878.04) lat (ms,95%): 118.92 err/s: 0.00 reconn/s: 0.00
[ 592s ] thds: 32 tps: 445.03 qps: 8846.51 (r/w/o: 6178.35/1778.10/890.05) lat (ms,95%): 114.72 err/s: 0.00 reconn/s: 0.00
[ 593s ] thds: 32 tps: 435.71 qps: 8847.08 (r/w/o: 6197.85/1777.81/871.42) lat (ms,95%): 118.92 err/s: 0.00 reconn/s: 0.00
[ 594s ] thds: 32 tps: 443.34 qps: 8681.58 (r/w/o: 6062.59/1733.31/885.67) lat (ms,95%): 118.92 err/s: 0.00 reconn/s: 0.00
[ 595s ] thds: 32 tps: 444.00 qps: 8976.99 (r/w/o: 6292.99/1795.00/889.00) lat (ms,95%): 106.75 err/s: 0.00 reconn/s: 0.00
[ 596s ] thds: 32 tps: 460.00 qps: 9136.96 (r/w/o: 6399.97/1816.99/920.00) lat (ms,95%): 116.80 err/s: 0.00 reconn/s: 0.00
[ 597s ] thds: 32 tps: 436.02 qps: 8766.38 (r/w/o: 6128.26/1767.08/871.04) lat (ms,95%): 110.66 err/s: 0.00 reconn/s: 0.00
[ 598s ] thds: 32 tps: 460.94 qps: 9206.79 (r/w/o: 6451.15/1832.76/922.88) lat (ms,95%): 108.68 err/s: 0.00 reconn/s: 0.00
[ 599s ] thds: 32 tps: 437.99 qps: 8836.73 (r/w/o: 6200.81/1759.95/875.97) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 600s ] thds: 32 tps: 450.99 qps: 9061.70 (r/w/o: 6318.79/1845.94/896.97) lat (ms,95%): 106.75 err/s: 0.00 reconn/s: 0.00
SQL statistics:
    queries performed:
        read:                            2592128
        write:                           740608
        other:                           370304
        total:                           3703040
    transactions:                        185152 (308.53 per sec.)
    queries:                             3703040 (6170.56 per sec.)
    ignored errors:                      0      (0.00 per sec.)
    reconnects:                          0      (0.00 per sec.)

Throughput:
    events/s (eps):                      308.5280
    time elapsed:                        600.1141s
    total number of events:              185152

Latency (ms):
         min:                                    8.88
         avg:                                  103.70
         max:                                 3847.36
         95th percentile:                      253.35
         sum:                             19200637.19

Threads fairness:
    events (avg/stddev):           5786.0000/53.95
    execution time (avg/stddev):   600.0199/0.03

清理测试数据

[mysql@localhost lua]$ ./sysbench oltp_read_write.lua --mysql-host=127.0.0.1 --mysql-port=3306 --mysql-db=test --mysql-user=root --mysql-password=abcd1234 --table_size=250000 --tables=25 --threads=32 --events=0 --report-interval=1 --time=600 --percentile=95 --report-interval=1 cleanup
sysbench 1.1.0 (using bundled LuaJIT 2.1.0-beta3)

Dropping table 'sbtest1'...
Dropping table 'sbtest2'...
Dropping table 'sbtest3'...
Dropping table 'sbtest4'...
Dropping table 'sbtest5'...
Dropping table 'sbtest6'...
Dropping table 'sbtest7'...
Dropping table 'sbtest8'...
Dropping table 'sbtest9'...
Dropping table 'sbtest10'...
Dropping table 'sbtest11'...
Dropping table 'sbtest12'...
Dropping table 'sbtest13'...
Dropping table 'sbtest14'...
Dropping table 'sbtest15'...
Dropping table 'sbtest16'...
Dropping table 'sbtest17'...
Dropping table 'sbtest18'...
Dropping table 'sbtest19'...
Dropping table 'sbtest20'...
Dropping table 'sbtest21'...
Dropping table 'sbtest22'...
Dropping table 'sbtest23'...
Dropping table 'sbtest24'...
Dropping table 'sbtest25'...
]]>
http://www.jydba.net/index.php/archives/3432/feed 0
sysbench 测试MySQL磁盘IOPS http://www.jydba.net/index.php/archives/3430 http://www.jydba.net/index.php/archives/3430#respond Tue, 08 Nov 2022 09:31:53 +0000 http://www.jydba.net/?p=3430 sysbench 测试MySQL磁盘IOPS
1. 安装

https://github.com/akopytov/sysbench.git # 通过git clone得到源码

2. 上传到MySQL服务器并解压

[root@localhost soft]# unzip sysbench-master.zip
[root@localhost soft]# mv sysbench-master sysbench

[root@localhost sysbench]# ./autogen.sh
autoreconf: Entering directory `.'
autoreconf: configure.ac: not using Gettext
autoreconf: running: aclocal -I m4
autoreconf: configure.ac: tracing
autoreconf: running: libtoolize --copy
libtoolize: putting auxiliary files in AC_CONFIG_AUX_DIR, `config'.
libtoolize: copying file `config/ltmain.sh'
libtoolize: putting macros in AC_CONFIG_MACRO_DIR, `m4'.
libtoolize: copying file `m4/libtool.m4'
libtoolize: copying file `m4/ltoptions.m4'
libtoolize: copying file `m4/ltsugar.m4'
libtoolize: copying file `m4/ltversion.m4'
libtoolize: copying file `m4/lt~obsolete.m4'
autoreconf: running: /usr/bin/autoconf
autoreconf: running: /usr/bin/autoheader
autoreconf: running: automake --add-missing --copy --no-force
configure.ac:59: installing 'config/ar-lib'
configure.ac:45: installing 'config/compile'
configure.ac:27: installing 'config/config.guess'
configure.ac:27: installing 'config/config.sub'
configure.ac:32: installing 'config/install-sh'
configure.ac:32: installing 'config/missing'
src/Makefile.am: installing 'config/depcomp'
parallel-tests: installing 'config/test-driver'
autoreconf: Leaving directory `.'

2.1 关联mysql的头文件和库

[root@localhost sysbench]# ./configure  --with-mysql-includes=/mysqlsoft/mysql/include/  --with-mysql-libs=/mysqlsoft/mysql/lib/
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking for style of include used by make... GNU
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking dependency style of gcc... gcc3
checking how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking minix/config.h usability... no
checking minix/config.h presence... no
checking for minix/config.h... no
checking whether it is safe to define __EXTENSIONS__... yes
checking for gcc... (cached) gcc
checking whether we are using the GNU C compiler... (cached) yes
checking whether gcc accepts -g... (cached) yes
checking for gcc option to accept ISO C89... (cached) none needed
checking dependency style of gcc... (cached) gcc3
checking for gcc option to accept ISO C99... -std=gnu99
checking how to run the C preprocessor... gcc -E
checking whether gcc -std=gnu99 and cc understand -c and -o together... yes
checking for a sed that does not truncate output... /usr/bin/sed
checking for C compiler vendor... gnu
checking for gcc architecture flag...
checking for x86 cpuid 0 output... d:756e6547:6c65746e:49656e69
checking for x86 cpuid 1 output... 306e7:2040800:9e982203:1fabfbff
checking whether C compiler accepts -march=ivybridge... no
checking whether C compiler accepts -march=core-avx-i... yes
checking for gcc architecture flag... -march=core-avx-i
checking for ar... ar
checking the archiver (ar) interface... ar
checking how to print strings... printf
checking for a sed that does not truncate output... (cached) /usr/bin/sed
checking for fgrep... /usr/bin/grep -F
checking for ld used by gcc -std=gnu99... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 1572864
checking whether the shell understands some XSI constructs... yes
checking whether the shell understands "+="... yes
checking how to convert x86_64-unknown-linux-gnu file names to x86_64-unknown-linux-gnu format... func_convert_file_noop
checking how to convert x86_64-unknown-linux-gnu file names to toolchain format... func_convert_file_noop
checking for /usr/bin/ld option to reload object files... -r
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for dlltool... no
checking how to associate runtime and link libraries... printf %s\n
checking for archiver @FILE support... @
checking for strip... strip
checking for ranlib... ranlib
checking command to parse /usr/bin/nm -B output from gcc -std=gnu99 object... ok
checking for sysroot... no
checking for mt... mt
checking if mt is a manifest tool... no
checking for dlfcn.h... yes
checking for objdir... .libs
checking if gcc -std=gnu99 supports -fno-rtti -fno-exceptions... no
checking for gcc -std=gnu99 option to produce PIC... -fPIC -DPIC
checking if gcc -std=gnu99 PIC flag -fPIC -DPIC works... yes
checking if gcc -std=gnu99 static flag -static works... no
checking if gcc -std=gnu99 supports -c -o file.o... yes
checking if gcc -std=gnu99 supports -c -o file.o... (cached) yes
checking whether the gcc -std=gnu99 linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
checking for pkg-config... yes
checking for C compiler vendor... (cached) gnu
checking whether to compile with MySQL support... yes
checking whether to compile with PostgreSQL support... no
checking for pkg-config... /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking whether to build with system or bundled LuaJIT... bundled
checking whether to build with system or bundled Concurrency Kit... bundled
checking whether SHM_HUGETLB is declared... yes
checking whether O_SYNC is declared... yes
checking for the pthreads library -lpthreads... no
checking whether pthreads work without any flags... no
checking whether pthreads work with -Kthread... no
checking whether pthreads work with -kthread... no
checking for the pthreads library -llthread... no
checking whether pthreads work with -pthread... yes
checking for joinable pthread attribute... PTHREAD_CREATE_JOINABLE
checking if more special flags are required for pthreads... no
checking for sqrt in -lm... yes
checking MySQL includes... (cached) /mysqlsoft/mysql/include/
checking MySQL libraries... (cached) /mysqlsoft/mysql/lib/
checking for library containing mysql_real_connect... -lmysqlclient
checking if mysql.h defines MYSQL_OPT_SSL_MODE... yes
checking libaio.h usability... no
checking libaio.h presence... no
checking for libaio.h... no
checking for ANSI C header files... (cached) yes
checking errno.h usability... yes
checking errno.h presence... yes
checking for errno.h... yes
checking fcntl.h usability... yes
checking fcntl.h presence... yes
checking for fcntl.h... yes
checking math.h usability... yes
checking math.h presence... yes
checking for math.h... yes
checking pthread.h usability... yes
checking pthread.h presence... yes
checking for pthread.h... yes
checking sched.h usability... yes
checking sched.h presence... yes
checking for sched.h... yes
checking signal.h usability... yes
checking signal.h presence... yes
checking for signal.h... yes
checking for stdlib.h... (cached) yes
checking for string.h... (cached) yes
checking sys/aio.h usability... no
checking sys/aio.h presence... no
checking for sys/aio.h... no
checking sys/ipc.h usability... yes
checking sys/ipc.h presence... yes
checking for sys/ipc.h... yes
checking sys/time.h usability... yes
checking sys/time.h presence... yes
checking for sys/time.h... yes
checking sys/mman.h usability... yes
checking sys/mman.h presence... yes
checking for sys/mman.h... yes
checking sys/shm.h usability... yes
checking sys/shm.h presence... yes
checking for sys/shm.h... yes
checking thread.h usability... no
checking thread.h presence... no
checking for thread.h... no
checking for unistd.h... (cached) yes
checking limits.h usability... yes
checking limits.h presence... yes
checking for limits.h... yes
checking libgen.h usability... yes
checking libgen.h presence... yes
checking for libgen.h... yes
checking for off_t... yes
checking whether time.h and sys/time.h may both be included... yes
checking for thread local storage (TLS) class... __thread
checking for __attribute__((format))... yes
checking for __attribute__((unused))... yes
checking for special C compiler options needed for large files... no
checking for _FILE_OFFSET_BITS value needed for large files... no
checking size of size_t... 8
checking size of bool... 1
checking for stdlib.h... (cached) yes
checking for unistd.h... (cached) yes
checking for sys/param.h... yes
checking for getpagesize... yes
checking for working mmap... yes
checking whether strerror_r is declared... yes
checking for strerror_r... yes
checking whether strerror_r returns char *... yes
checking for library containing clock_gettime... none required
checking for alarm... yes
checking for clock_gettime... yes
checking for directio... no
checking for fdatasync... yes
checking for gettimeofday... yes
checking for isatty... yes
checking for memalign... yes
checking for memset... yes
checking for posix_memalign... yes
checking for pthread_cancel... yes
checking for pthread_yield... yes
checking for setvbuf... yes
checking for sqrt... yes
checking for strdup... yes
checking for thr_setconcurrency... no
checking for valloc... yes
checking for pthread_once... yes
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating third_party/luajit/Makefile
config.status: creating third_party/concurrency_kit/Makefile
config.status: creating src/Makefile
config.status: creating src/drivers/Makefile
config.status: creating src/drivers/mysql/Makefile
config.status: creating src/drivers/pgsql/Makefile
config.status: creating src/tests/Makefile
config.status: creating src/tests/cpu/Makefile
config.status: creating src/tests/fileio/Makefile
config.status: creating src/tests/memory/Makefile
config.status: creating src/tests/threads/Makefile
config.status: creating src/tests/mutex/Makefile
config.status: creating src/lua/Makefile
config.status: creating src/lua/internal/Makefile
config.status: creating tests/Makefile
config.status: creating tests/include/config.sh
config.status: creating snap/snapcraft.yaml
config.status: creating config/config.h
config.status: executing depfiles commands
config.status: executing libtool commands
===============================================================================
sysbench version   : 1.1.0
CC                 : gcc -std=gnu99
CFLAGS             : -O3 -funroll-loops -ggdb3  -march=core-avx-i -Wall -Wextra -Wpointer-arith -Wbad-function-cast -Wstrict-prototypes -Wnested-externs -Wno-format-zero-length -Wundef -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wcast-align -Wvla   -pthread
CPPFLAGS           : -D_GNU_SOURCE   -I$(top_srcdir)/src -I$(abs_top_builddir)/third_party/luajit/inc -I$(abs_top_builddir)/third_party/concurrency_kit/include
LDFLAGS            : -L/usr/local/lib
LIBS               : -lm

prefix             : /usr/local
bindir             : ${prefix}/bin
libexecdir         : ${prefix}/libexec
mandir             : ${prefix}/share/man
datadir            : ${prefix}/share

MySQL support      : yes
PostgreSQL support : no

LuaJIT             : bundled
LUAJIT_CFLAGS      : -I$(abs_top_builddir)/third_party/luajit/inc
LUAJIT_LIBS        : $(abs_top_builddir)/third_party/luajit/lib/libluajit-5.1.a -ldl
LUAJIT_LDFLAGS     : -rdynamic

Concurrency Kit    : bundled
CK_CFLAGS          : -I$(abs_top_builddir)/third_party/concurrency_kit/include
CK_LIBS            : $(abs_top_builddir)/third_party/concurrency_kit/lib/libck.a
configure flags    :
===============================================================================

2.2 编译源码
[root@localhost sysbench]# make -j 4

2.3 安装(默认安装到 /usr/local/bin , 如果有自定义目录,configure增加参数 –prefix=自定义目录)
[root@localhost sysbench]# make install

添加LD_LIBRARY_PATH

[root@localhost ~]# echo "export LD_LIBRARY_PATH=/mysqlsoft/mysql/lib/:$LD_LIBRARY_PATH" >> ~/.bashrc

[root@localhost ~]# source ~/.bashrc
[root@localhost ~]# sysbench –version
sysbench 1.1.0

3. 测试
生成测试文件

[root@localhost ~]# sysbench  fileio   help
sysbench 1.1.0 (using bundled LuaJIT 2.1.0-beta3)

fileio options:
  --file-num=N                  number of files to create [128]
  --file-block-size=N           block size to use in all IO operations [16384]
  --file-total-size=SIZE        total size of files to create [2G]
  --file-test-mode=STRING       test mode {seqwr, seqrewr, seqrd, rndrd, rndwr, rndrw}
  --file-io-mode=STRING         file operations mode {sync,async,mmap} [sync]
  --file-extra-flags=[LIST,...] list of additional flags to use to open files {sync,dsync,direct} []
  --file-fsync-freq=N           do fsync() after this number of requests (0 - don't use fsync()) [100]
  --file-fsync-all[=on|off]     do fsync() after each write operation [off]
  --file-fsync-end[=on|off]     do fsync() at the end of test [on]
  --file-fsync-mode=STRING      which method to use for synchronization {fsync, fdatasync} [fsync]
  --file-merged-requests=N      merge at most this number of IO requests if possible (0 - don't merge) [0]
  --file-rw-ratio=N             reads/writes ratio for combined test [1.5]

其他说明

  # --file-num=N                  创建文件数
  # --file-block-size=N           block size大小
  # --file-total-size=SIZE        文件数的大小总和
  # --file-test-mode=STRING       测试模式 {seqwr, seqrewr, seqrd, rndrd, rndwr, rndrw} (顺序写,顺序读写,顺序读,随机读,随机写,随机读写)
  # --file-io-mode=STRING         文件操作方式 {sync,async,mmap}
  # --file-extra-flags=STRING     打开文件的额外标志 {sync,dsync,direct} []
  # --file-fsync-freq=N           多少请求后执行fsync。默认是0,不执行
  # --file-fsync-all=[on|off]     是否每次操作后都执行fsync
  # --file-fsync-end=[on|off]     测完成后执行fsync,默认是on
  # --file-fsync-mode=STRING      同步的方法 {fsync, fdatasync}默认是 [fsync]
  # --file-merged-requests=N      最多多少IO请求被合并,默认为0,不合并
  # --file-rw-ratio=N             读写比例默认是 [1.5],即 3:2
[root@localhost ~]# sysbench  fileio --file-num=4 --file-block-size=8K --file-total-size=1G --file-test-mode=rndrd --file-extra-flags=direct prepare
sysbench 1.1.0 (using bundled LuaJIT 2.1.0-beta3)

4 files, 262144Kb each, 1024Mb total
Creating files for the test...
Extra file open flags: directio
Creating file test_file.0
Creating file test_file.1
Creating file test_file.2
Creating file test_file.3
1073741824 bytes written in 29.00 seconds (35.30 MiB/sec).

开始测试(–time=30简单测试,测试30秒 –report-interval=3 # 每3秒产生报告)

[root@localhost ~]# sysbench  fileio  --file-num=4  --file-block-size=8K  --file-total-size=1G  --file-test-mode=rndrd  --file-extra-flags=direct  --threads=4 --time=30 --report-interval=3  run
sysbench 1.1.0 (using bundled LuaJIT 2.1.0-beta3)

Running the test with following options:
Number of threads: 4
Report intermediate results every 3 second(s)
Initializing random number generator from current time


Extra file open flags: directio
4 files, 256MiB each
1GiB total file size
Block size 8KiB
Number of IO requests: 0
Read/Write ratio for combined random IO test: 1.50
Periodic FSYNC enabled, calling fsync() each 100 requests.
Calling fsync() at the end of test, Enabled.
Using synchronous I/O mode
Doing random read test
Initializing worker threads...

Threads started!

[ 3s ] reads: 4.48 MiB/s writes: 0.00 MiB/s fsyncs: 0.00/s latency (ms,95%): 15.268
[ 6s ] reads: 4.39 MiB/s writes: 0.00 MiB/s fsyncs: 0.00/s latency (ms,95%): 15.828
[ 9s ] reads: 4.61 MiB/s writes: 0.00 MiB/s fsyncs: 0.00/s latency (ms,95%): 14.995
[ 12s ] reads: 4.73 MiB/s writes: 0.00 MiB/s fsyncs: 0.00/s latency (ms,95%): 13.953
[ 15s ] reads: 4.77 MiB/s writes: 0.00 MiB/s fsyncs: 0.00/s latency (ms,95%): 13.953
[ 18s ] reads: 4.81 MiB/s writes: 0.00 MiB/s fsyncs: 0.00/s latency (ms,95%): 14.207
[ 21s ] reads: 4.82 MiB/s writes: 0.00 MiB/s fsyncs: 0.00/s latency (ms,95%): 14.728
[ 24s ] reads: 4.84 MiB/s writes: 0.00 MiB/s fsyncs: 0.00/s latency (ms,95%): 14.995
[ 27s ] reads: 5.09 MiB/s writes: 0.00 MiB/s fsyncs: 0.00/s latency (ms,95%): 13.953
[ 30s ] reads: 5.16 MiB/s writes: 0.00 MiB/s fsyncs: 0.00/s latency (ms,95%): 14.207

Throughput:
         read:  IOPS=610.59 4.77 MiB/s (5.00 MB/s) #4.77*1024/8;
         write: IOPS=0.00 0.00 MiB/s (0.00 MB/s)
         fsync: IOPS=0.00

Latency (ms):
         min:                                  0.18
         avg:                                  6.54
         max:                                 45.86
         95th percentile:                     14.46
         sum:                             119902.59

]]>
http://www.jydba.net/index.php/archives/3430/feed 0
MySQL 5.7配置SSL连接 http://www.jydba.net/index.php/archives/3422 http://www.jydba.net/index.php/archives/3422#respond Fri, 16 Sep 2022 00:29:53 +0000 http://www.jydba.net/?p=3422 MySQL 5.7配置SSL连接

如果想服务能够部署自动支持安全连接,使用mysql_ssl_rsa_setup工具来创建缺省SSL与RSA文件

[root@cs2 bin]# ./mysql_ssl_rsa_setup --datadir=/mysqldata/mysql
Generating a 2048 bit RSA private key
......................................................................+++
..............................................................+++
writing new private key to 'ca-key.pem'
-----
Generating a 2048 bit RSA private key
.............+++
..............+++
writing new private key to 'server-key.pem'
-----
Generating a 2048 bit RSA private key
.....................................+++
................................................+++
writing new private key to 'client-key.pem'
-----





启动mysql

[root@cs2 ~]# service mysqld start
Starting MySQL.. SUCCESS!

测试远程登录

-bash-4.2$ mysql -h 10.11.13.19 -P 3306 -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.22 MySQL Community Server (GPL)

Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> SELECT DISTINCT CONCAT('User: [', user, '''@''', host, '];') AS USER_HOST FROM user;
+------------------------------------+
| USER_HOST                          |
+------------------------------------+
| User: [root'@'%];                  |
| User: [mysql.session'@'localhost]; |
| User: [mysql.sys'@'localhost];     |
+------------------------------------+
3 rows in set (0.05 sec)

通过ssl登录mysql服务器

[mysql@localhost ~]$ mysql -h 10.11.13.19 -P 3306 -u root -pabcd123 --ssl-cert=client-cert.pem --ssl-key=client-key.pem
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 7
Server version: 5.7.26-log Source distribution

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> \s
--------------
mysql  Ver 14.14 Distrib 5.7.26, for Linux (x86_64) using  EditLine wrapper

Connection id:          7
Current database:
Current user:           root@10.11.13.19
SSL:                    Not in use
Current pager:          stdout
Using outfile:          ''
Using delimiter:        ;
Server version:         5.7.26-log Source distribution
Protocol version:       10
Connection:             10.11.13.19 via TCP/IP
Server characterset:    utf8mb4
Db     characterset:    utf8mb4
Client characterset:    gb2312
Conn.  characterset:    gb2312
TCP port:               3306
Uptime:                 14 min 11 sec

Threads: 2  Questions: 13  Slow queries: 0  Opens: 108  Flush tables: 1  Open tables: 101  Queries per second avg: 0.015
--------------

mysql> show variables like 'have_ssl';
+---------------+----------+
| Variable_name | Value    |
+---------------+----------+
| have_ssl      | DISABLED |
+---------------+----------+
1 row in set (0.01 sec)

mysql> show variables like 'require_secure_transport';
+--------------------------+-------+
| Variable_name            | Value |
+--------------------------+-------+
| require_secure_transport | OFF   |
+--------------------------+-------+
1 row in set (0.00 sec)

mysql> show variables like '%ssl%';
+---------------+-----------------+
| Variable_name | Value           |
+---------------+-----------------+
| have_openssl  | DISABLED        |
| have_ssl      | DISABLED        |
| ssl_ca        | ca.pem          |
| ssl_capath    |                 |
| ssl_cert      | server-cert.pem |
| ssl_cipher    |                 |
| ssl_crl       |                 |
| ssl_crlpath   |                 |
| ssl_key       | server-key.pem  |
+---------------+-----------------+

从上面的查询结果可以看到SSL: Not in use,have_ssl和have_openssl为DISABLED,这说明实际上是没有启用ssl。

这是因为通过执行mysql_ssl_rsa_setup命令产生的pem文件的权限为root用户而不是mysql用户造成的,将这些pem文件的权限修改为mysql用户与组 权限不要太大,只用户权限为rw,组与其它用户需要r权限

[root@localhost mysql]# ls -lrt
30172
-rw-r-----. 1 mysql mysql 104857600 321 16:25 ib_logfile1
-rw-r-----. 1 mysql mysql 104857600 321 16:25 ib_logfile2
drwxr-x---. 2 mysql mysql        48 321 16:25 undo
-rw-r-----. 1 mysql mysql        56 321 16:25 auto.cnf
drwxr-x---. 2 mysql mysql      8192 321 16:25 performance_schema
drwxr-x---. 2 mysql mysql      4096 321 16:25 mysql
drwxr-x---. 2 mysql mysql      8192 321 16:25 sys
-rw-r-----. 1 mysql mysql       177 321 16:25 binlog.000001
-rw-r--r--. 1 mysql mysql      1679 321 16:26 ca-key.pem
-rw-r--r--. 1 mysql mysql      1107 321 16:26 ca.pem
-rw-r--r--. 1 root  root       1679 321 16:26 server-key.pem
-rw-r--r--. 1 root  root       1107 321 16:26 server-cert.pem
-rw-r--r--. 1 root  root      1675 321 16:26 client-key.pem
-rw-r--r--. 1 root  root      1107 321 16:26 client-cert.pem
-rw-r--r--. 1 root  root      1675 321 16:26 private_key.pem
-rw-r--r--. 1 root  root       451 321 16:26 public_key.pem
-rw-r-----. 1 mysql mysql    114688 524 17:00 ts2.ibd
-rw-r-----. 1 mysql mysql     98304 524 17:01 ts1.ibd
drwxr-x---. 2 mysql mysql        32 524 17:11 test
-rw-r-----. 1 mysql mysql      9352 621 10:46 binlog.000002
-rw-r-----. 1 mysql mysql       177 621 10:46 binlog.000003
-rw-r-----. 1 mysql mysql       154 9 9 19:55 binlog.000004
-rw-r-----. 1 mysql mysql       177 9 9 20:23 binlog.000005
-rw-r-----. 1 mysql mysql       177 9 9 20:38 binlog.000006
-rw-r-----. 1 mysql mysql       177 9 9 20:44 binlog.000007
-rw-r-----. 1 mysql mysql       122 9 9 20:44 ib_buffer_pool
-rw-r-----. 1 mysql mysql       248 9 9 20:44 binlog.index
-rw-r-----. 1 mysql mysql       154 9 9 20:44 binlog.000008
-rw-r-----. 1 mysql mysql         6 9 9 20:44 mysqld.pid
-rw-r-----. 1 mysql mysql  12582912 9 9 20:44 ibtmp1
-rw-r-----. 1 mysql mysql  10485760 9 9 20:44 ibdata1
-rw-r-----. 1 mysql mysql 104857600 9 9 20:44 ib_logfile0
-rw-r-----. 1 mysql mysql    107011 9 9 20:54 mysql.err

[root@localhost mysql]# chown -R mysql:mysql *.pem
[root@localhost mysql]# ls -lrt
30172
-rw-r-----. 1 mysql mysql 104857600 321 16:25 ib_logfile1
-rw-r-----. 1 mysql mysql 104857600 321 16:25 ib_logfile2
drwxr-x---. 2 mysql mysql        48 321 16:25 undo
-rw-r-----. 1 mysql mysql        56 321 16:25 auto.cnf
drwxr-x---. 2 mysql mysql      8192 321 16:25 performance_schema
drwxr-x---. 2 mysql mysql      4096 321 16:25 mysql
drwxr-x---. 2 mysql mysql      8192 321 16:25 sys
-rw-r-----. 1 mysql mysql       177 321 16:25 binlog.000001
-rw-r--r--. 1 mysql mysql      1679 321 16:26 ca-key.pem
-rw-r--r--. 1 mysql mysql      1107 321 16:26 ca.pem
-rw-r--r--. 1 mysql mysql      1679 321 16:26 server-key.pem
-rw-r--r--. 1 mysql mysql      1107 321 16:26 server-cert.pem
-rw-r--r--. 1 mysql mysql      1675 321 16:26 client-key.pem
-rw-r--r--. 1 mysql mysql      1107 321 16:26 client-cert.pem
-rw-r--r--. 1 mysql mysql      1675 321 16:26 private_key.pem
-rw-r--r--. 1 mysql mysql       451 321 16:26 public_key.pem
-rw-r-----. 1 mysql mysql    114688 524 17:00 ts2.ibd
-rw-r-----. 1 mysql mysql     98304 524 17:01 ts1.ibd
drwxr-x---. 2 mysql mysql        32 524 17:11 test
-rw-r-----. 1 mysql mysql      9352 621 10:46 binlog.000002
-rw-r-----. 1 mysql mysql       177 621 10:46 binlog.000003
-rw-r-----. 1 mysql mysql       154 9 9 19:55 binlog.000004
-rw-r-----. 1 mysql mysql       177 9 9 20:23 binlog.000005
-rw-r-----. 1 mysql mysql       177 9 9 20:38 binlog.000006
-rw-r-----. 1 mysql mysql       177 9 9 20:44 binlog.000007
-rw-r-----. 1 mysql mysql       122 9 9 20:44 ib_buffer_pool
-rw-r-----. 1 mysql mysql       248 9 9 20:44 binlog.index
-rw-r-----. 1 mysql mysql       154 9 9 20:44 binlog.000008
-rw-r-----. 1 mysql mysql         6 9 9 20:44 mysqld.pid
-rw-r-----. 1 mysql mysql  12582912 9 9 20:44 ibtmp1
-rw-r-----. 1 mysql mysql  10485760 9 9 20:44 ibdata1
-rw-r-----. 1 mysql mysql 104857600 9 9 20:44 ib_logfile0
-rw-r-----. 1 mysql mysql    107011 9 9 20:54 mysql.err

pem文件权限太多可能会出现如下错误

[mysql@localhost mysql]$ mysql -h 10.11.13.19 -P 3306 -u root -pabcd123 --ssl-cert=/mysqldata/mysql/client-cert.pem --ssl-key=/mysqldata/mysql/client-key.pem
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 2026 (HY000): SSL connection error: SSL_CTX_set_default_verify_paths failed


[root@localhost mysql]# service mysqld restart
Shutting down MySQL.. SUCCESS!
Starting MySQL.. SUCCESS!

[mysql@localhost mysql]$ mysql -h 10.11.13.19 -P 3306 -u root -pabcd123 --ssl-cert=/mysqldata/mysql/client-cert.pem --ssl-key=/mysqldata/mysql/client-key.pem
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.26-log Source distribution

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> \s
--------------
mysql  Ver 14.14 Distrib 5.7.26, for Linux (x86_64) using  EditLine wrapper

Connection id:          4
Current database:
Current user:           root@10.11.13.19
SSL:                    Cipher in use is DHE-RSA-AES256-SHA
Current pager:          stdout
Using outfile:          ''
Using delimiter:        ;
Server version:         5.7.26-log Source distribution
Protocol version:       10
Connection:             10.11.13.19 via TCP/IP
Server characterset:    utf8mb4
Db     characterset:    utf8mb4
Client characterset:    gb2312
Conn.  characterset:    gb2312
TCP port:               3306
Uptime:                 59 sec

Threads: 2  Questions: 11  Slow queries: 0  Opens: 108  Flush tables: 1  Open tables: 101  Queries per second avg: 0.186
--------------

创建用户限制用户必须用ssl登录

mysql> create user 'jy'@'%' identified by "123";
Query OK, 0 rows affected (0.02 sec)

mysql> grant all on *.* to 'jy'@'%' require ssl;
Query OK, 0 rows affected, 1 warning (0.02 sec)

虽然要求用ssl但是还是可以使用密码登录,是因为mysql.user表中的ssl_type=ANY

[mysql@localhost ~]$  mysql -h 10.11.13.19 -P 3306 -u jy -p123
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 7
Server version: 5.7.26-log Source distribution

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> \s
--------------
mysql  Ver 14.14 Distrib 5.7.26, for Linux (x86_64) using  EditLine wrapper

Connection id:          7
Current database:
Current user:           jy@10.11.13.19
SSL:                    Cipher in use is DHE-RSA-AES256-SHA
Current pager:          stdout
Using outfile:          ''
Using delimiter:        ;
Server version:         5.7.26-log Source distribution
Protocol version:       10
Connection:             10.11.13.19 via TCP/IP
Server characterset:    utf8mb4
Db     characterset:    utf8mb4
Client characterset:    gb2312
Conn.  characterset:    gb2312
TCP port:               3306
Uptime:                 50 min 18 sec

Threads: 2  Questions: 69  Slow queries: 0  Opens: 139  Flush tables: 1  Open tables: 132  Queries per second avg: 0.022
--------------

mysql> select * from user where user='jy'\G
ERROR 1046 (3D000): No database selected
mysql> select * from mysql.user where user='root'\G
*************************** 1. row ***************************
                  Host: %
                  User: jy
           Select_priv: Y
           Insert_priv: Y
           Update_priv: Y
           Delete_priv: Y
           Create_priv: Y
             Drop_priv: Y
           Reload_priv: Y
         Shutdown_priv: Y
          Process_priv: Y
             File_priv: Y
            Grant_priv: Y
       References_priv: Y
            Index_priv: Y
            Alter_priv: Y
          Show_db_priv: Y
            Super_priv: Y
 Create_tmp_table_priv: Y
      Lock_tables_priv: Y
          Execute_priv: Y
       Repl_slave_priv: Y
      Repl_client_priv: Y
      Create_view_priv: Y
        Show_view_priv: Y
   Create_routine_priv: Y
    Alter_routine_priv: Y
      Create_user_priv: Y
            Event_priv: Y
          Trigger_priv: Y
Create_tablespace_priv: Y
              ssl_type: ANY
            ssl_cipher:
           x509_issuer:
          x509_subject:
         max_questions: 0
           max_updates: 0
       max_connections: 0
  max_user_connections: 0
                plugin: mysql_native_password
 authentication_string: *1AA476D99C1600C9D984E248FBF2FDE3A0BB256E
      password_expired: N
 password_last_changed: 2022-03-21 16:27:48
     password_lifetime: NULL
        account_locked: N
1 row in set (0.00 sec)

修改用户jy的ssl类型为x509

mysql> alter user 'jy'@'%' require x509
    -> ;
Query OK, 0 rows affected (0.01 sec)

在不指定ssl密钥时就不能登录了

[mysql@localhost ~]$ mysql -h 10.11.13.19 -P 3306 -u jy -p123
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 1045 (28000): Access denied for user 'jy'@'10.11.13.19' (using password: YES)
[mysql@localhost ~]$  mysql -h 10.11.13.19 -P 3306 -u jy -p123 --ssl
mysql: [Warning] Using a password on the command line interface can be insecure.
WARNING: --ssl is deprecated and will be removed in a future version. Use --ssl-mode instead.
ERROR 1045 (28000): Access denied for user 'jy'@'10.11.13.19' (using password: YES)

指定ssl密钥进行登录

[mysql@localhost ~]$  mysql -h 10.11.13.19 -P 3306 -u jy -p123 --ssl-cert=/mysqldata/mysql/client-cert.pem --ssl-key=/mysqldata/mysql/client-key.pem
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 5.7.26-log Source distribution

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> exit

如果指定ssl密钥进行登录时不指定密钥完整路径时会出现如下错误

[mysql@localhost ~]$  mysql -h 10.11.13.19 -P 3306 -u jy -p123 --ssl-cert=client-cert.pem --ssl-key=client-key.pem
mysql: [Warning] Using a password on the command line interface can be insecure.
mysql: [ERROR] SSL error: Unable to get certificate from 'client-cert.pem'
ERROR 2026 (HY000): SSL connection error: Unable to get certificate
]]>
http://www.jydba.net/index.php/archives/3422/feed 0
MySQL 拷贝一个InnoDB分区表到另一个实例 http://www.jydba.net/index.php/archives/3416 http://www.jydba.net/index.php/archives/3416#respond Mon, 11 Apr 2022 01:03:40 +0000 http://www.jydba.net/?p=3416 拷贝一个InnoDB分区表到另一个实例
这个过程演示了如何将一个InnoDB分区表从一个正在运行的MySQL服务器实例复制到另一个正在运行的实例。同样的过程,只要稍微做些调整,就可以在同一个实例上对InnoDB分区表执行完全恢复。

1.在源实例上,如果不存在分区表,则创建分区表。在下面的例子中,创建了一个包含三个分区(p0, p1, p2)的表

mysql> use test;
Database changed
mysql> create table t1(i int) engine=innodb partition by key(i) partitions 3;
Query OK, 0 rows affected (0.38 sec)

mysql> insert into t1 values(1),(2),(3),(4),(5),(6),(7),(8),(9);
Query OK, 9 rows affected (0.03 sec)
Records: 9  Duplicates: 0  Warnings: 0
mysql> select * from t1;
+------+
| i    |
+------+
|    4 |
|    5 |
|    1 |
|    6 |
|    7 |
|    2 |
|    3 |
|    8 |
|    9 |
+------+
9 rows in set (0.00 sec)

在/mysqldata/mysql/test目录中,对于三个分区都有一个单独的表空间(.ibd)文件:

[root@localhost ~]# cd /mysqldata/mysql/test
[root@localhost test]# ls -lrt
总用量 304
-rw-r-----. 1 mysql mysql    67 3月  15 16:53 db.opt
-rw-r-----. 1 mysql mysql  8554 3月  16 15:43 t1.frm
-rw-r-----. 1 mysql mysql 98304 3月  16 15:43 t1#P#p1.ibd
-rw-r-----. 1 mysql mysql 98304 3月  16 15:43 t1#P#p2.ibd
-rw-r-----. 1 mysql mysql 98304 3月  16 15:43 t1#P#p0.ibd

2.在目标实例上,创建相同的分区表:

mysql> use test;
Database changed
mysql> create table t1(i int) engine=innodb partition by key(i) partitions 3;
Query OK, 0 rows affected (0.20 sec)

在/mysqldata/mysql/test目录中,对于三个分区都有一个单独的表空间(.ibd)文件:

[root@localhost ~]# cd /mysqldata/mysql/test
[root@localhost test]# ls -lrt
总用量 304
-rw-r-----. 1 mysql mysql    67 3月  15 16:55 db.opt
-rw-r-----. 1 mysql mysql  8554 3月  16 15:45 t1.frm
-rw-r-----. 1 mysql mysql 98304 3月  16 15:45 t1#P#p0.ibd
-rw-r-----. 1 mysql mysql 98304 3月  16 15:45 t1#P#p1.ibd
-rw-r-----. 1 mysql mysql 98304 3月  16 15:45 t1#P#p2.ibd

3.在目标实例上,丢弃分区表的表空间。(在将表空间导入目标实例之前,必须丢弃附加到接收表的表空间。)

mysql> alter table t1 discard tablespace;
Query OK, 0 rows affected (0.09 sec)

组成分区表表空间的三个.ibd文件从/mysqldata/mysql/tes目录中被丢弃,留下以下文件

[root@localhost ~]# cd /mysqldata/mysql/test
[root@localhost test]# ls -lrt
总用量 16
-rw-r-----. 1 mysql mysql   67 3月  15 16:55 db.opt
-rw-r-----. 1 mysql mysql 8554 3月  16 15:45 t1.frm

4.在源实例上,运行FLUSH TABLES… FOR EXPORT用于暂停分区表并创建.cfg元数据文件

mysql> flush tables t1 for export;
Query OK, 0 rows affected (0.01 sec)

在源实例的/mysqldata/mysql/test目录中创建元数据(.cfg)文件,每个表空间(.ibd)文件对应一个元数据文件

[root@localhost ~]# cd /mysqldata/mysql/test
[root@localhost test]# ls -lrt
总用量 316
-rw-r-----. 1 mysql mysql    67 3月  15 16:53 db.opt
-rw-r-----. 1 mysql mysql  8554 3月  16 15:43 t1.frm
-rw-r-----. 1 mysql mysql 98304 3月  16 15:43 t1#P#p1.ibd
-rw-r-----. 1 mysql mysql 98304 3月  16 15:43 t1#P#p2.ibd
-rw-r-----. 1 mysql mysql 98304 3月  16 15:43 t1#P#p0.ibd
-rw-r-----. 1 mysql mysql   375 3月  16 16:00 t1#P#p1.cfg
-rw-r-----. 1 mysql mysql   375 3月  16 16:00 t1#P#p0.cfg
-rw-r-----. 1 mysql mysql   375 3月  16 16:00 t1#P#p2.cfg

FLUSH TABLES……FOR EXPORT语句确保对指定表的更改已刷新到磁盘,以便在实例运行时可以进行二进制表拷贝。当运行FLUSH TABLES … FOR EXPORT时,InnoDB会在数据库目录中为表的表空间文件生成一个.cfg元数据文件。.cfg文件中包含导入表空间文件时验证模式的元数据。FLUSH TABLES … FOR EXPORT只能在表上运行,而不能在单独的表分区上运行。

5.将.ibd和.cfg文件从源实例数据库目录复制到目标实例数据库目录。例如

[root@localhost test]# scp t1*.{ibd,cfg} mysql@192.168.1.243:/mysqldata/mysql/test/
mysql@192.168.1.243's password:
t1#P#p0.ibd                                                                                                                                                                                              100%   96KB  96.0KB/s   00:00
t1#P#p1.ibd                                                                                                                                                                                              100%   96KB  96.0KB/s   00:00
t1#P#p2.ibd                                                                                                                                                                                              100%   96KB  96.0KB/s   00:00
t1#P#p0.cfg                                                                                                                                                                                              100%  375     0.4KB/s   00:00
t1#P#p1.cfg                                                                                                                                                                                              100%  375     0.4KB/s   00:00
t1#P#p2.cfg                                                                                                                                                                                              100%  375     0.4KB/s   00:00
[root@localhost test]#

[root@localhost test]# ls -lrt
总用量 316
-rw-r-----. 1 mysql mysql    67 3月  15 16:55 db.opt
-rw-r-----. 1 mysql mysql  8554 3月  16 15:45 t1.frm
-rw-r-----. 1 mysql mysql 98304 3月  16 16:06 t1#P#p0.ibd
-rw-r-----. 1 mysql mysql 98304 3月  16 16:06 t1#P#p1.ibd
-rw-r-----. 1 mysql mysql 98304 3月  16 16:06 t1#P#p2.ibd
-rw-r-----. 1 mysql mysql   375 3月  16 16:06 t1#P#p0.cfg
-rw-r-----. 1 mysql mysql   375 3月  16 16:06 t1#P#p1.cfg
-rw-r-----. 1 mysql mysql   375 3月  16 16:06 t1#P#p2.cfg

6.在源实例上,使用unlock tables语句来释放由flush tables … for export所获取的锁:

mysql> unlock tables;
Query OK, 0 rows affected (0.00 sec)

在源实例上释放锁时,会向mysql日志文件写入删除.cfg文件的信息:

2022-03-16T08:08:27.653352Z 10 [Note] InnoDB: Deleting the meta-data file './test/t1#P#p0.cfg'
2022-03-16T08:08:27.653656Z 10 [Note] InnoDB: Deleting the meta-data file './test/t1#P#p1.cfg'
2022-03-16T08:08:27.654214Z 10 [Note] InnoDB: Deleting the meta-data file './test/t1#P#p2.cfg'
2022-03-16T08:08:27.654256Z 10 [Note] InnoDB: Resuming purge

7.在目标实例上,导入表空间:

mysql> select * from t1;
ERROR 1814 (HY000): Tablespace has been discarded for table 't1'
mysql> alter table t1 discard tablespace;
Query OK, 0 rows affected (0.09 sec)

mysql> alter table t1 import tablespace;
Query OK, 0 rows affected (0.46 sec)

mysql> select * from t1;
+------+
| i    |
+------+
|    4 |
|    5 |
|    1 |
|    6 |
|    7 |
|    2 |
|    3 |
|    8 |
|    9 |
+------+
9 rows in set (0.01 sec)
]]>
http://www.jydba.net/index.php/archives/3416/feed 0
MySQL 传输表空间 http://www.jydba.net/index.php/archives/3414 http://www.jydba.net/index.php/archives/3414#respond Sat, 09 Apr 2022 01:38:20 +0000 http://www.jydba.net/?p=3414 将file-per-table表空间复制到另一个实例
如何将一个file-per-table表空间从一个MySQL实例复制到另一个实例中,也就是众所周知的可传输表空间特性。

有很多原因可以解释为什么你可以将一个InnoDB文件表空间复制到不同的实例中:
.在不增加生产服务器额外负载的情况下运行报表。

.在新的从服务器上为表设置相同的数据

.在出现问题或错误后恢复表或分区的备份版本。

.作为一种比mysqldump命令导入更快的移动数据的方法。数据立即可用,而不需要重新插入和重建索引

.将每个file-per-table表空间移动到具有更适合系统需求的存储介质的服务器。例如,您可能希望在SSD设备上有繁忙的表,或者在高容量HDD设备上有大型表。

限制和使用说明
.只有当innodb_file_per_table设置为ON(默认设置)时,才可以拷贝表空间。驻留在共享系统表空间中的表不能被静默。

.当一个表被静默时,只允许在受影响的表上执行只读事务

.在导入表空间时,页面大小必须与导入实例的页面大小相匹配。

.当foreign_key_checks设置为1时,对于父-子(主-外键)关系的表空间不支持DISCARD TABLESPACE。在丢弃父-子表的表空间之前,设置foreign_key_checks=0。分区InnoDB表不支持外键。

.ALTER TABLE……IMPORT TABLESPACE不会对导入的数据强制外键约束。如果表之间存在外键约束,那么所有表都应该在同一(逻辑)时间点导出。分区InnoDB表不支持外键。

.ALTER TABLE……IMPORT TABLESPACE 和 ALTER TABLE…IMPORT PARTITION…TABLESPACE不需要.cfg元数据文件来导入一个表空间。但是,如果导入时没有.cfg文件,则不会执行元数据检查,并且会发出类似于下面的警告:

Message: InnoDB: IO Read error: (2, No such file or directory) Error opening '.\
test\t.cfg', will attempt to import without schema verification
1 row in set (0.00 sec)

在期待没用模式不匹配的情况下,不使用.cfg文件进行导入可能会更方便。此外,在无法从.ibd文件收集元数据的崩溃恢复场景中,不需要.cfg文件就可以导入。

.由于.cfg元数据文件的限制,当为分区表导入表空间文件时,不会对分区类型或分区定义差异报告模式不匹配。列差异被报告。

.当在子分区表上运行ALTER TABLE … DISCARD PARTITION … TABLESPACE和ALTER TABLE … IMPORT PARTITION … TABLESPACE,分区和子分区表名都是允许的。当指定分区名时,该分区的子分区将包含在操作中。

.如果两个实例都有GA(通用可用性)状态,并且它们的版本在同一系列可以从另一个MySQL服务器实例导入表空间文件。否则,该文件必须是在导入它的同一个服务器实例上所创建

.在复制场景中,innodb_file_per_table必须在主节点和从节点上都设置为ON。

.在Windows环境下,InnoDB内部存储数据库、表空间和表名时使用小写字母。为了避免在区分大小写的操作系统(如Linux、UNIX)上的导入问题,请在创建数据库、表空间和表时使用小写名称。一种方便的方法是在创建数据库、表空间或表之前,在my.cnf或my.ini文件的[mysqld]部分中添加下面这一行:

[mysqld]
lower_case_table_names=1

.alter table … discard tablespace和alter table … import tabelspace不支持属于InnoDB通用表空间中的表。

.InnoDB表的默认行格式可以通过innodb_default_row_format配置选项进行配置。如果导入的表没有明确定义行格式(ROW_FORMAT),或者使用了ROW_FORMAT=DEFAULT,那么如果源实例上的innodb_default_row_format设置与目标实例上的innodb_default_row_format设置不一致,可能会导致模式不匹配错误

.在使用InnoDB表空间加密特性导出加密的表空间时,InnoDB除了生成一个.cfg元数据文件外,还会生成一个.cfp文件。在目标实例上执行ALTER TABLE…IMPORT TABLESPACE之前,必须将.cfp文件与.cfg文件和表空间文件一起复制到目标实例中。cfp文件包含一个传输密钥和一个加密的表空间密钥。在导入时,InnoDB使用传输密钥来解密表空间密钥。

传输表空间示例
例如1:复制一个InnoDB表到另一个实例
这个过程演示了如何将一个普通的InnoDB表从一个正在运行的MySQL服务器实例复制到另一个正在运行的实例。可以使用相同的过程在相同的实例上执行全表恢复,只是做了一些小小的调整。
1. 在源实例上,如果不存在表,则创建一个表:

mysql> use test;
Database changed
mysql> create table t(c1 int) engine=innodb;
Query OK, 0 rows affected (0.12 sec)

mysql> insert into t values(1);
Query OK, 1 row affected (0.16 sec)

2.在目标实例上,如果不存在表,则创建表:

mysql> use test;
Database changed
mysql> create table t(c1 int) engine=innodb;
Query OK, 0 rows affected (0.09 sec)

3.在目标实例上,丢弃现有的表空间。(在导入表空间之前,InnoDB必须丢弃连接到接收表空间的表空间。)

[mysql@localhost test]$ ls -lrt
总用量 112
-rw-r-----. 1 mysql mysql    67 3月  15 16:55 db.opt
-rw-r-----. 1 mysql mysql  8556 3月  15 16:57 t.frm
-rw-r-----. 1 mysql mysql 98304 3月  15 16:57 t.ibd

mysql> alter table t discard tablespace;
Query OK, 0 rows affected (0.17 sec)



[mysql@localhost test]$ ls -lrt
总用量 16
-rw-r-----. 1 mysql mysql   67 3月  15 16:55 db.opt
-rw-r-----. 1 mysql mysql 8556 3月  15 16:57 t.frm

4.在源实例上,运行FLUSH TABLES…FOR EXPORT将暂停表并创建.cfg元数据文件

mysql> flush tables t for export;
Query OK, 0 rows affected (0.00 sec)


[mysql@localhost test]$ ls -lrt
总用量 116
-rw-r-----. 1 mysql mysql    67 3月  15 16:53 db.opt
-rw-r-----. 1 mysql mysql  8556 3月  15 16:54 t.frm
-rw-r-----. 1 mysql mysql 98304 3月  15 16:54 t.ibd
-rw-r-----. 1 mysql mysql   371 3月  15 17:00 t.cfg

在InnoDB数据目录下创建元数据(.cfg)
注意:FLUSH TABLES …… FOR EXPORT在MySQL 5.6.6版本中可用。该语句确保对指定表的更改已刷新到磁盘,以便在实例运行时可以生成二进制表副本。当FLUSH TABLES … FOR EXPORT时,InnoDB会在表所在的数据库目录中生成一个.cfg文件。cfg文件中包含导入表空间文件时用于模式验证的元数据。

5.将.ibd文件和.cfg元数据文件从源实例复制到目标实例

[mysql@localhost test]$ scp t.{ibd,cfg} mysql@192.168.1.243:/mysqldata/mysql/test/
mysql@192.168.1.243's password:
t.ibd                                                                                                                                                                                                    100%   96KB  96.0KB/s   00:00
t.cfg                                                                                                                                                                                                    100%  371     0.4KB/s   00:00
[mysql@localhost test]$

在释放共享锁之前必须复制.ibd与.cfg文件。

6.在源实例上,使用unlock tables语句来释放由flush tables … for export所获取的锁:

mysql> unlock tables;
Query OK, 0 rows affected (0.00 sec)

7.在目标实例上,导入表空间:
mysql> alter table t import tablespace;
Query OK, 0 rows affected (0.15 sec)

mysql> desc t;
+-------+---------+------+-----+---------+-------+
| Field | Type    | Null | Key | Default | Extra |
+-------+---------+------+-----+---------+-------+
| c1    | int(11) | YES  |     | NULL    |       |
+-------+---------+------+-----+---------+-------+
1 row in set (0.00 sec)

mysql> select * from t;
+------+
| c1   |
+------+
|    1 |
+------+
1 row in set (0.00 sec)

可以看到表t从一个实例迁移到另一个实例上。

]]>
http://www.jydba.net/index.php/archives/3414/feed 0
MySQL InnoDB File-Per-Table表空间 http://www.jydba.net/index.php/archives/3377 http://www.jydba.net/index.php/archives/3377#respond Fri, 11 Mar 2022 00:57:19 +0000 http://www.jydba.net/?p=3377 InnoDB File-Per-Table表空间
过去,所有InnoDB表和索引都存储在系统表空间中。这种整体的方法针对的是完全专用于数据库处理的机器,通过精心规划的数据增长,分配给MySQL的任何磁盘存储永远不会被用于其他用途。InnoDB的file-per-table表空间特性提供了一个更灵活的替代方案,每个InnoDB表及其索引都存储在一个单独的.ibd数据文件中。每个这样的.ibd数据文件代表一个单独的表空间。这个特性是由innodb_file_per_table配置选项控制的,在MySQL 5.6.6及更高版本中默认启用。

file-per-table表空间的优点
.当truncate或drop存储在file-per-table表空间中的表时,可以回收磁盘空间。truncate或drop存储在共享系统表空间中的表会在系统表空间数据文件(ibdata文件)内部创建空闲空间,这些空间只能用于新的InnoDB数据。

.在存储在file-per-table表空间文件中的表上运行TRUNCATE TABLE操作会更快。

.您可以将特定的表存储在单独的存储设备上,以实现I/O优化、空间管理或备份目的。在以前的版本中,您必须将整个数据库目录移动到其他驱动器,并在MySQL数据目录中创建符号链接。在MySQL 5.6.6及更高版本中,你可以使用
create table… data directory=absolute_path_to_directory。

.你可以运行OPTIMIZE TABLE来压缩或重新创建一个file-per-table表空间。当你运行一个OPTIMIZE TABLE时,InnoDB会创建一个新的.ibd文件,该文件带有一个临时名称,只使用存储实际数据所需的空间。当优化完成后,InnoDB会删除旧的.ibd文件,并用新文件替换它。如果以前的.ibd文件显著增长,但实际数据只占其大小的一部分,那么运行OPTIMIZE TABLE可以回收未使用的空间。

.你可以移动单个InnoDB表,而不是整个数据库

.你可以将InnoDB表从一个MySQL实例复制到另一个实例(称为可迁移表空间特性)。

.在file-per-table表空间中创建的表使用Barracuda文件格式。Barracuda文件格式支持压缩和动态行格式等特性

.可以使用动态行格式为具有大型BLOB或TEXT列的表启用更高效的存储。

.file-per-table表空间可以在发生损坏、服务器无法重启或备份和二进制日志不可用时提高成功恢复的机会并节省时间。

.在复制或备份表时,file-per-table表空间可以方便地报告每个表的状态。

.可以在文件系统级别监控表大小,而不需要访问MySQL。

.当innodb_flush_method设置为O_DIRECT时,普通的Linux文件系统不允许并发写入单个文件。因此,使用file-per-table表空间和innodb_flush_method可能会提高性能。

.系统表空间存储数据字典和undo日志,受InnoDB表空间大小限制。使用file-per_table表空间,每个表都有自己的表空间,这为增长提供了空间。

file-per-table表空间的潜在缺点
.使用file-per-table表空间,每个表可能有未使用的空间,这些空间只能由同一表的行使用。如果管理不当,可能会造成空间的浪费。

.fsync操作必须在每个打开的表上运行,而不是单个文件上。因为每个文件都有一个单独的fsync操作,所以对多个表的写操作不能合并成一个单独的I/O操作。这可能需要InnoDB执行更多的fsync操作。

.mysqld必须为每个表保留一个打开的文件句柄,如果在file-per-table表空间中有很多表,这可能会影响性能。

.使用了更多的文件描述符

.innodb_file_per_table在MySQL 5.6.6及更高版本中是默认启用的。如果向后兼容MySQL 5.5或5.1是一个问题,你可以考虑禁用它。禁用innodb_file_per_table功能可以防止在ALTER TABLE重新创建InnoDB表(ALGORITHM=COPY)时,阻止alter table将InnoDB表从系统表空间移动到单独的.ibd文件中。

例如,当重构InnoDB表的聚集索引时,表会使用innodb_file_per_table的当前设置重新创建。此行为在添加或删除InnoDB二级索引时不适用。当不重建表而创建二级索引时,无论当前的innodb_file_per_table设置是什么,索引都被存储在与表数据相同的文件中。此行为也不适用于使用CREATE TABLE…TABLESPACE或ALTER TABLE …TABLESPACE语法添加到系统表空间中的表。这些表不受innodb_file_per_table设置的影响。

.如果许多表都在增长,可能会出现更多的碎片,这可能会影响DROP TABLE和表扫描性能。但是,在管理碎片时,将文件放在它们自己的表空间中可以提高性能。

.在删除file-per-table表空间时会扫描缓冲池,对于大小为几十gb的缓冲池来说,这可能需要几秒钟的时间。扫描是用一个宽的内部锁执行的,这可能会延迟其他操作。系统表空间中的表不受影响。

.innodb_autoextend_increment变量定义了自动扩展的共享表空间文件满时的扩展大小(以MB为单位),但不适用于file-per-table表空间文件,不管是否设置了innodb_autoextend_increment,这些文件都是自动扩展的。最初的扩展是少量的,之后扩展以4MB的增量出现。

启用与禁用file-per-table表空间
innodb_file_per_table选项默认是启用的。

为了在启动时设置innodb_file_per_table选项,可以在启动服务时使用–innodb_file_per_table命令行选项或者在my.cnf文件中[mysqld]部分增加以下一行内容:

[mysqld]
innodb_file_per_table=1

你也可以在服务器运行时动态设置innodb_file_per_table:

mysql> SET GLOBAL innodb_file_per_table=1;
Query OK, 0 rows affected (0.00 sec)

启用innodb_file_per_table时,可以将InnoDB表存储在tbl_name.ibd文件。不像MyISAM存储引擎,它有单独的tbl_name.MYD和tbl_name.MYI文件用于索引和数据,InnoDB将数据和索引一起存储在一个.ibd文件中。仍然像往常一样创建tbl_name.frm文件。

如果在启动选项中禁用innodb_file_per_table并重启服务器或者使用set global命令来禁用它,除非你显式的使用create table … tablespace选项将表存放在file-per-table表空间或通用表空间否则innodb将在系统表空间创建新表。

你总是可以读取和写入任何InnoDB表,不管file-per-table设置情况。

如果要将表从系统表空间移动到自己的表空间,需要修改innodb_file_per_table的设置,然后重新创建表:

mysql> SET GLOBAL innodb_file_per_table=1;
mysql> ALTER TABLE table_name ENGINE=InnoDB;

使用CREATE TABLE…TABLESPACE或ALTER TABLE…TABLESPACE语法添加表到系统表空间不受innodb_file_per_table设置的影响。要将这些表从系统表空间移动到file-per-table表空间,必须使用ALTER TABLE…TABLESPACE语法。

InnoDB总是需要系统表空间,因为它把它的内部数据字典和undo日志放在那里。.ibd文件不够InnoDB操作。

当一个表从系统表空间移到它自己的.ibd文件时,组成系统表空间的数据文件保持相同的大小。InnoDB表以前占用的空间可以被新的InnoDB数据重用,但是不会被操作系统回收使用。当将较大的InnoDB表移出系统表空间(磁盘空间有限)时,你可能更喜欢启用innodb_file_per_table并使用mysqldump命令重新创建整个实例。如上所述,使用CREATE TABLE…TABLESPACE或者ALTER TABLE…表空间语法不受innodb_file_per_table设置的影响。这些桌子必须单独移动。

在数据目录外创建逐file-per-table表空间
要在MySQL数据目录之外的特定位置创建一个新的InnoDB file-per-table表空间,使用有data directory = absolute_path_to_directory子句的CREATE TABLE语句的来实现。

提前计划位置,因为您不能在ALTER TABLE语句中使用DATA DIRECTORY子句。您指定的目录可以位于具有特定性能或容量特征的另一个存储设备上,例如快速SSD或大容量HDD。

在目标目录中,MySQL创建一个与数据库名称对应的子目录,在该子目录中为新表创建一个.ibd文件。在MySQL DATADIR目录下的数据库目录中,MySQL创建了一个table_name.Isl文件包含表路径名。.isl文件被MySQL视为一个符号链接。(InnoDB表不支持使用实际的符号链接。)

下面的例子演示了如何在MySQL数据目录外创建一个file-per-table表空间。它显示了在指定目录中创建的.ibd,以及在MySQL数据目录下的数据库目录中创建的.isl。

mysql> use mysql
Database changed
mysql> show variables like 'innodb_file_per_table';
+-----------------------+-------+
| Variable_name         | Value |
+-----------------------+-------+
| innodb_file_per_table | ON    |
+-----------------------+-------+
1 row in set (0.01 sec)


mysql> create table t_cs(c1 int primary key) data directory='/data';
Query OK, 0 rows affected (0.22 sec)


[root@localhost mysql]# pwd
/data/mysql
[root@localhost mysql]# ls -lrt
总用量 96
-rw-r-----. 1 mysql mysql 98304 3月   8 16:09 t_cs.ibd

[root@localhost mysql]# ls -lrt t_cs*
-rw-r-----. 1 mysql mysql 8556 3月   8 16:09 t_cs.frm
-rw-r-----. 1 mysql mysql   20 3月   8 16:09 t_cs.isl

你也可以使用CREATE TABLE…TABLESPACE与DATA DIRECTORY子句结合,在MySQL数据目录之外创建一个file-per-table表空间。为此,你必须指定innodb_file_per_table作为表空间名。

mysql> create table t_cs_3(c1 int primary key) tablespace=innodb_file_per_table data directory='/data';
Query OK, 0 rows affected (0.28 sec)

[root@localhost mysql]# ls -lrt t_cs_2*
-rw-r-----. 1 mysql mysql 98304 3月   8 16:14 t_cs_2.ibd

[root@localhost mysql]# ls -lrt t_cs_2*
-rw-r-----. 1 mysql mysql 8556 3月   8 16:14 t_cs_2.frm
-rw-r-----. 1 mysql mysql   22 3月   8 16:14 t_cs_2.isl

使用这个方法时,你不需要启用innodb_file_per_table。

使用说明:
.MySQL最初保存的.ibd文件是打开的,防止您卸载设备,但如果服务器繁忙,可能最终会关闭表。小心不要在MySQL运行时意外地卸载外部设备,或者在设备断开连接时启动MySQL。当关联的.ibd文件丢失时,试图访问表会导致严重错误,需要重新启动服务器。

如果.ibd文件仍然不在预期的路径上,服务器重启可能会失败。在本例中,手动删除数据库目录中的table_name.isl文件重新启动后,执行DROPTABLE命令删除.frm文件,并从数据字典中删除该表的信息。

.在将表存放在NFS挂载的卷上之前,请查看在使用NFS和MySQL中列出的潜在问题。

.如果您使用LVM快照、文件复制或其他基于文件的机制来备份.ibd文件,请始终使用FLUSH TABLES…FOR EXPORT语句,以确保在备份发生之前将缓存在内存中的所有更改刷新到磁盘。

.DATA DIRECTORY子句是一种支持替代符号链接的方法,符号链接一直存在问题,从来没有被支持用于单独的InnoDB表。

]]>
http://www.jydba.net/index.php/archives/3377/feed 0
MySQL 修改InnoDB重做日志文件的数量或大小 http://www.jydba.net/index.php/archives/3375 http://www.jydba.net/index.php/archives/3375#respond Fri, 11 Mar 2022 00:53:26 +0000 http://www.jydba.net/?p=3375 修改InnoDB重做日志文件的数量或大小
修改你的InnoDB重做日志文件的数量或大小,请执行以下步骤:
1.停止MySQL服务器,并确保它没有错误地关闭

mysql> show variables like 'innodb_log_file%';
+---------------------------+----------+
| Variable_name             | Value    |
+---------------------------+----------+
| innodb_log_file_size      | 50331648 |
| innodb_log_files_in_group | 2        |
+---------------------------+----------+
2 rows in set (0.00 sec)


[root@localhost ~]# service mysqld stop
Shutting down MySQL.... SUCCESS!

2.编辑my.cnf以更改日志文件配置。如果需要修改日志文件大小,请配置innodb_log_file_size。要增加日志文件的数量,可以配置

innodb_log_files_in_group。

[mysql@localhost mysql]$ vi my.cnf
....
innodb_log_file_size=100m
innodb_log_files_in_group=3

3.重新启动MySQL服务器
如果InnoDB检测到innodb_log_file_size大小与重做日志文件大小不同,它会写一个日志检查点,关闭并删除旧的日志文件,创建新的大小的志文件,并打开新的日志文件。

[root@localhost ~]# service mysqld start
Starting MySQL.................................. SUCCESS!


日志文件显示如下:

[mysql@localhost mysql]$ tail -f mysql.err
2022-03-02T02:44:15.775252Z 0 [Warning] Insecure configuration for --secure-file-priv: Current value does not restrict location of generated files. Consider setting it to a valid, non-empty path.
2022-03-02T02:44:15.775476Z 0 [Note] /mysqlsoft/mysql/bin/mysqld (mysqld 5.7.26-log) starting as process 613 ...
2022-03-02T02:44:15.787224Z 0 [Note] InnoDB: PUNCH HOLE support available
2022-03-02T02:44:15.787311Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2022-03-02T02:44:15.787376Z 0 [Note] InnoDB: Uses event mutexes
2022-03-02T02:44:15.787395Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2022-03-02T02:44:15.787411Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2022-03-02T02:44:15.788175Z 0 [Note] InnoDB: Number of pools: 1
2022-03-02T02:44:15.788515Z 0 [Note] InnoDB: Using CPU crc32 instructions
2022-03-02T02:44:15.793577Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2022-03-02T02:44:15.812360Z 0 [Note] InnoDB: Completed initialization of buffer pool
2022-03-02T02:44:15.817437Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
2022-03-02T02:44:15.862640Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
2022-03-02T02:44:16.043532Z 0 [Warning] InnoDB: Resizing redo log from 2*3072 to 3*6400 pages, LSN=2494312
2022-03-02T02:44:16.169341Z 0 [Warning] InnoDB: Starting to delete and rewrite log files.
2022-03-02T02:44:16.200462Z 0 [Note] InnoDB: Setting log file ./ib_logfile101 size to 100 MB
2022-03-02T02:44:16.200745Z 0 [Note] InnoDB: Progress in MB:
 100
2022-03-02T02:44:26.280622Z 0 [Note] InnoDB: Setting log file ./ib_logfile1 size to 100 MB
2022-03-02T02:44:26.281005Z 0 [Note] InnoDB: Progress in MB:
 100
2022-03-02T02:44:37.028157Z 0 [Note] InnoDB: Setting log file ./ib_logfile2 size to 100 MB
2022-03-02T02:44:37.029053Z 0 [Note] InnoDB: Progress in MB:
 100
2022-03-02T02:44:47.532468Z 0 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
2022-03-02T02:44:47.532675Z 0 [Warning] InnoDB: New log files created, LSN=2494312
2022-03-02T02:44:47.533502Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2022-03-02T02:44:47.533760Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2022-03-02T02:44:48.119249Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2022-03-02T02:44:48.121693Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
2022-03-02T02:44:48.121740Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
2022-03-02T02:44:48.122598Z 0 [Note] InnoDB: Waiting for purge to start
2022-03-02T02:44:48.172771Z 0 [Note] InnoDB: page_cleaner: 1000ms intended loop took 32356ms. The settings might not be optimal. (flushed=0 and evicted=0, during the time.)
2022-03-02T02:44:48.186082Z 0 [Note] InnoDB: 5.7.26 started; log sequence number 2494303
2022-03-02T02:44:48.186431Z 0 [Note] InnoDB: Loading buffer pool(s) from /mysqldata/mysql/ib_buffer_pool
2022-03-02T02:44:48.186776Z 0 [Note] Plugin 'FEDERATED' is disabled.
2022-03-02T02:44:48.366419Z 0 [Note] Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them.
2022-03-02T02:44:48.367248Z 0 [Warning] CA certificate ca.pem is self signed.
2022-03-02T02:44:48.369110Z 0 [Note] Server hostname (bind-address): '*'; port: 3306
2022-03-02T02:44:48.371083Z 0 [Note] IPv6 is available.
2022-03-02T02:44:48.371145Z 0 [Note]   - '::' resolves to '::';
2022-03-02T02:44:48.371213Z 0 [Note] Server socket created on IP: '::'.
2022-03-02T02:44:48.430720Z 0 [Note] InnoDB: Buffer pool(s) load completed at 220302 10:44:48
2022-03-02T02:44:48.434777Z 0 [Note] Failed to start slave threads for channel ''
2022-03-02T02:44:48.452218Z 0 [Note] Event Scheduler: Loaded 0 events
2022-03-02T02:44:48.452566Z 0 [Note] /mysqlsoft/mysql/bin/mysqld: ready for connections.
Version: '5.7.26-log'  socket: '/mysqlsoft/mysql/mysql.sock'  port: 3306  Source distribution

其中以下部分显示了服务器重置日志文件的大小与数量

2022-03-02T02:44:16.043532Z 0 [Warning] InnoDB: Resizing redo log from 2*3072 to 3*6400 pages, LSN=2494312
2022-03-02T02:44:16.169341Z 0 [Warning] InnoDB: Starting to delete and rewrite log files.
2022-03-02T02:44:16.200462Z 0 [Note] InnoDB: Setting log file ./ib_logfile101 size to 100 MB
2022-03-02T02:44:16.200745Z 0 [Note] InnoDB: Progress in MB:
 100
2022-03-02T02:44:26.280622Z 0 [Note] InnoDB: Setting log file ./ib_logfile1 size to 100 MB
2022-03-02T02:44:26.281005Z 0 [Note] InnoDB: Progress in MB:
 100
2022-03-02T02:44:37.028157Z 0 [Note] InnoDB: Setting log file ./ib_logfile2 size to 100 MB
2022-03-02T02:44:37.029053Z 0 [Note] InnoDB: Progress in MB:
 100
2022-03-02T02:44:47.532468Z 0 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
2022-03-02T02:44:47.532675Z 0 [Warning] InnoDB: New log files created, LSN=2494312


[mysql@localhost ~]$ mysql -uroot -pxxzx7817600 mysql
mysql: [Warning] Using a password on the command line interface can be insecure.
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.26-log Source distribution

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show variables like 'innodb_log_file%';
+---------------------------+-----------+
| Variable_name             | Value     |
+---------------------------+-----------+
| innodb_log_file_size      | 104857600 |
| innodb_log_files_in_group | 3         |
+---------------------------+-----------+
2 rows in set (0.01 sec)
]]>
http://www.jydba.net/index.php/archives/3375/feed 0
MySQL 减少InnoDB系统表空间的大小 http://www.jydba.net/index.php/archives/3373 http://www.jydba.net/index.php/archives/3373#respond Fri, 11 Mar 2022 00:51:45 +0000 http://www.jydba.net/?p=3373 减少InnoDB系统表空间的大小
不能从系统表空间中删除数据文件。若要减少系统表空间大小,请使用此过程:
1.使用mysqldump将所有的包括MySQL数据库中的InnoDB表dump出来,在5.6当前版本中,包括5张InnoDB表:

[mysql@localhost ~]$ mysql -uroot -pxxzx7817600 mysql
mysql: [Warning] Using a password on the command line interface can be insecure.
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.26-log Source distribution

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show variables like 'innodb_data%';
+-----------------------+------------------------------------+
| Variable_name         | Value                              |
+-----------------------+------------------------------------+
| innodb_data_file_path | ibdata1:76M;ibdata2:50M:autoextend |
| innodb_data_home_dir  |                                    |
+-----------------------+------------------------------------+
2 rows in set (0.01 sec)

mysql> SELECT TABLE_NAME from INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='mysql' and ENGINE='InnoDB';
+---------------------------+
| TABLE_NAME                |
+---------------------------+
| engine_cost               |
| gtid_executed             |
| help_category             |
| help_keyword              |
| help_relation             |
| help_topic                |
| innodb_index_stats        |
| innodb_table_stats        |
| plugin                    |
| server_cost               |
| servers                   |
| slave_master_info         |
| slave_relay_log_info      |
| slave_worker_info         |
| time_zone                 |
| time_zone_leap_second     |
| time_zone_name            |
| time_zone_transition      |
| time_zone_transition_type |
+---------------------------+
19 rows in set (0.00 sec)



[mysql@localhost ~]$ mysqldump  -uroot -pxxzx7817600 --all-databases > all_db_dump_20220223.sql
mysqldump: [Warning] Using a password on the command line interface can be insecure.

2.停止MySQL服务器

[mysql@localhost ~]$ mysqladmin -uroot -pxxzx7817600 shutdown
mysqladmin: [Warning] Using a password on the command line interface can be insecure.

3.删除所有已经存在的表空间文件(*.ibd),包括ibdata和ib_log文件。不要忘记删除MySQL数据库中的*.ibd文件。

[mysql@localhost mysql]$ find ./mysql -name "*.ibd"
./mysql/plugin.ibd
./mysql/servers.ibd
./mysql/help_topic.ibd
./mysql/help_category.ibd
./mysql/help_relation.ibd
./mysql/help_keyword.ibd
./mysql/time_zone_name.ibd
./mysql/time_zone.ibd
./mysql/time_zone_transition.ibd
./mysql/time_zone_transition_type.ibd
./mysql/time_zone_leap_second.ibd
./mysql/innodb_table_stats.ibd
./mysql/innodb_index_stats.ibd
./mysql/slave_relay_log_info.ibd
./mysql/slave_master_info.ibd
./mysql/slave_worker_info.ibd
./mysql/gtid_executed.ibd
./mysql/server_cost.ibd
./mysql/engine_cost.ibd
[mysql@localhost mysql]$ find ./mysql -name "*.ibd"    | xargs -n 1 rm -f

[mysql@localhost mysql]$ rm -rf ibdata*
[mysql@localhost mysql]$ rm -rf ib_log*
[mysql@localhost mysql]$ ls -lrt ibdata*
ls: 无法访问ibdata*: 没有那个文件或目录
[mysql@localhost mysql]$ ls -lrt ib_log*
ls: 无法访问ib_log*: 没有那个文件或目录

4.删除InnoDB表的.frm文件

[mysql@localhost mysql]$ rm -rf mysql/plugin..frm
[mysql@localhost mysql]$ rm -rf mysql/servers..frm
[mysql@localhost mysql]$ rm -rf mysql/help_topic..frm
[mysql@localhost mysql]$ rm -rf mysql/help_category..frm
[mysql@localhost mysql]$ rm -rf mysql/help_relation.frm
[mysql@localhost mysql]$ rm -rf mysql/help_keyword.frm
[mysql@localhost mysql]$ rm -rf mysql/time_zone_name.frm
[mysql@localhost mysql]$ rm -rf mysql/time_zone.frm
[mysql@localhost mysql]$ rm -rf mysql/time_zone_transition.frm
[mysql@localhost mysql]$ rm -rf mysql/time_zone_transition_type.frm
[mysql@localhost mysql]$ rm -rf mysql/time_zone_leap_second.frm
[mysql@localhost mysql]$ rm -rf mysql/innodb_table_stats.frm
[mysql@localhost mysql]$ rm -rf mysql/innodb_index_stats.frm
[mysql@localhost mysql]$ rm -rf mysql/slave_relay_log_info.frm
[mysql@localhost mysql]$ rm -rf mysql/slave_master_info.frm
[mysql@localhost mysql]$ rm -rf mysql/slave_worker_info.frm
[mysql@localhost mysql]$ rm -rf mysql/gtid_executed.frm
[mysql@localhost mysql]$ rm -rf mysql/server_cost.frm
[mysql@localhost mysql]$ rm -rf mysql/engine_cost.frm

5.配置一个新表空间

[mysql@localhost mysql]$ vi my.cnf
.......
innodb_data_file_path = ibdata1:10M:autoextend

6.重启MySQL服务器

[root@localhost ~]# service mysqld start
Starting MySQL......... SUCCESS!

7.导入dump文件

[mysql@localhost ~]$ mysql -uroot -pxxzx7817600 < all_db_dump_20220223.sql
mysql: [Warning] Using a password on the command line interface can be insecure.

[mysql@localhost ~]$ mysql -uroot -pxxzx7817600 mysql
mysql: [Warning] Using a password on the command line interface can be insecure.
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.26-log Source distribution

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show variables like 'innodb_data%';
+-----------------------+------------------------+
| Variable_name         | Value                  |
+-----------------------+------------------------+
| innodb_data_file_path | ibdata1:10M:autoextend |
| innodb_data_home_dir  |                        |
+-----------------------+------------------------+
2 rows in set (0.01 sec)

InnoDB系统表空间的文件变回原来的ibdata1了

mysql> SELECT TABLE_NAME from INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='mysql' and ENGINE='InnoDB';
+---------------------------+
| TABLE_NAME                |
+---------------------------+
| engine_cost               |
| gtid_executed             |
| help_category             |
| help_keyword              |
| help_relation             |
| help_topic                |
| innodb_index_stats        |
| innodb_table_stats        |
| plugin                    |
| server_cost               |
| servers                   |
| slave_master_info         |
| slave_relay_log_info      |
| slave_worker_info         |
| time_zone                 |
| time_zone_leap_second     |
| time_zone_name            |
| time_zone_transition      |
| time_zone_transition_type |
+---------------------------+
19 rows in set (0.01 sec)

注意:如果您的数据库只使用InnoDB引擎,那么可能更简单的方法是转储所有数据库,停止服务器,删除所有数据库和InnoDB日志文件,重新启动服务器,并导入转储文件。

]]>
http://www.jydba.net/index.php/archives/3373/feed 0
MySQL 增加InnoDB系统表空间大小 http://www.jydba.net/index.php/archives/3371 http://www.jydba.net/index.php/archives/3371#respond Fri, 11 Mar 2022 00:50:04 +0000 http://www.jydba.net/?p=3371 增加InnoDB系统表空间大小
增加InnoDB系统表空间大小的最简单的方法是从一开始就配置为自动扩展。在表空间定义中为最后一个数据文件指定autoextend属性。当InnoDB用完空间时,会自动增加64MB的文件大小。可以通过设置innodb_autoextend_increment系统变量的值来更改增量大小,该变量以兆字节为单位度量。

mysql> show variables like 'innodb_autoextend_increment';
+-----------------------------+-------+
| Variable_name               | Value |
+-----------------------------+-------+
| innodb_autoextend_increment | 64    |
+-----------------------------+-------+
1 row in set (0.01 sec)

通过添加另一个数据文件,可以按定义的数量扩展系统表空间:
1.关闭MySQL服务器

2.如果上一个数据文件是用autoextend关键字定义的,那么根据它实际增长的大小,将其定义更改为使用固定大小。检查数据文件的大小,将其四舍四入到最接近的1024*1024字节(= 1MB)的倍数,并在innodb_data_file_path中显式指定这个四舍五入的大小。

3.在innodb_data_file_path的末尾添加一个新的数据文件,可以选择使该文件自动扩展。只有innodb_data_file_path中的最后一个数据文件可以被指定为自动扩展。

4.重新启动MySQL服务器。

例如,这个表空间只有一个自动扩展的数据文件ibdata1

mysql> show variables like 'innodb_data%';
+-----------------------+------------------------+
| Variable_name         | Value                  |
+-----------------------+------------------------+
| innodb_data_file_path | ibdata1:12M:autoextend |
| innodb_data_home_dir  |                        |
+-----------------------+------------------------+
2 rows in set (0.00 sec)

假设这个数据文件随着时间的推移增长到76MB。下面是修改原始数据文件以使用固定大小并添加新的自动扩展数据文件后的配置行

innodb_data_home_dir =
innodb_data_file_path =  ibdata1:76M;ibdata2:50M:autoextend

当您向系统表空间配置添加一个新的数据文件时,请确保文件名没有引用现有的文件。当您重启服务器时,InnoDB会创建并初始化该文件

a.关闭MySQL服务器

[root@localhost ~]# service mysqld stop
Shutting down MySQL.. SUCCESS!

b.检查数据文件的大小

[mysql@localhost mysql]$ du -sh ibdata1
76M     ibdata1

c.在innodb_data_file_path的末尾添加一个新的数据文件,可以选择使该文件自动扩展。

innodb_data_file_path =  ibdata1:76M;ibdata2:50M:autoextend

d.重启MySQL服务器

[root@localhost ~]# service mysqld start
Starting MySQL..... SUCCESS!

[mysql@localhost ~]$ mysql -uroot -pxxzx7817600 mysql
mysql: [Warning] Using a password on the command line interface can be insecure.
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.26-log Source distribution

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show variables like 'innodb_data%';
+-----------------------+------------------------------------+
| Variable_name         | Value                              |
+-----------------------+------------------------------------+
| innodb_data_file_path | ibdata1:76M;ibdata2:50M:autoextend |
| innodb_data_home_dir  |                                    |
+-----------------------+------------------------------------+
2 rows in set (0.01 sec)

[root@localhost mysql]# ls -lrt ibdata*
-rw-r-----. 1 mysql mysql 52428800 2月  23 11:13 ibdata2
-rwxr-xr-x. 1 mysql mysql 79691776 2月  23 11:13 ibdata1
]]>
http://www.jydba.net/index.php/archives/3371/feed 0
MySQL 配置索引页的合并阈值 http://www.jydba.net/index.php/archives/3368 http://www.jydba.net/index.php/archives/3368#respond Fri, 11 Mar 2022 00:47:58 +0000 http://www.jydba.net/?p=3368 配置索引页的合并阈值
您可以为索引页配置MERGE_THRESHOLD值。如果一个索引页的“page-full”百分比低于MERGE_THRESHOLD值,当一个行被删除或当一个行被UPDATE 操作缩短时,InnoDB会尝试合并这个索引页和相邻的索引页。默认的MERGE_THRESHOLD值是50,这是以前的硬编码值。MERGE_THRESHOLD最小值为1,最大值为50。

当索引页的页满百分比低于50%(默认的MERGE_THRESHOLD设置)时,InnoDB会尝试将索引页与相邻页合并。如果两个页面都接近50%的满,那么在页面合并后不久就会发生页面分割。如果频繁发生这种合并-分割行为,则会对性能产生不利影响。为了避免频繁的合并分割,你可以降低MERGE_THRESHOLD值,这样InnoDB尝试页面合并的百分比就会降低。以较低的页满百分比合并页面会在索引页中留下更多的空间,并有助于减少合并-分割行为。

可以为一个表或单个索引定义索引页的MERGE_THRESHOLD。为单个索引定义的MERGE_THRESHOLD值优先于为表定义的MERGE_THRESHOLD值。如果未定义,MERGE_THRESHOLD值默认为50。

设置表的MERGE_THRESHOLD
可以使用CREATE TABLE语句的table_option COMMENT子句为一个表设置MERGE_THRESHOLD值。例如:

CREATE TABLE t1 (
id INT,
KEY id_index (id)
) COMMENT='MERGE_THRESHOLD=45';

还可以使用ALTER TABLE的table_option COMMENT子句为现有表设置MERGE_THRESHOLD值

CREATE TABLE t1 (
id INT,
KEY id_index (id)
);

ALTER TABLE t1 COMMENT='MERGE_THRESHOLD=40';

为单个索引设置MERGE_THRESHOLD
要为单个索引设置MERGE_THRESHOLD值,可以使用带有CREATE TABLE、ALTER TABLE或CREATE INDEX的index_option COMMENT子句,如下面的示例所示:
.使用CREATE TABLE为单个索引设置MERGE_THRESHOLD:

mysql> CREATE TABLE t1 (
    -> id INT,
    -> KEY id_index (id) COMMENT 'MERGE_THRESHOLD=40'
    -> );
Query OK, 0 rows affected (0.11 sec)

.使用ALTER TABLE为单个索引设置MERGE_THRESHOLD:

mysql> CREATE TABLE t1 (
    -> id INT,
    -> KEY id_index (id)
    -> );
ALTER TABLE t1 DROP KEY id_index;
ALTER TABLE t1 ADD KEY id_index (id) COMMENT 'MERGE_THRESHOLD=40';Query OK, 0 rows affected (0.17 sec)

mysql> ALTER TABLE t1 DROP KEY id_index;
Query OK, 0 rows affected (0.05 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql> ALTER TABLE t1 ADD KEY id_index (id) COMMENT 'MERGE_THRESHOLD=40';
Query OK, 0 rows affected (0.09 sec)
Records: 0  Duplicates: 0  Warnings: 0

使用CREATE INDEX为单个索引设置MERGE_THRESHOLD:

mysql> CREATE TABLE t1 (id INT);
Query OK, 0 rows affected (0.14 sec)

mysql> CREATE INDEX id_index ON t1 (id) COMMENT 'MERGE_THRESHOLD=40';
Query OK, 0 rows affected (0.11 sec)
Records: 0  Duplicates: 0  Warnings: 0

不能在索引级别修改GEN_CLUST_INDEX的MERGE_THRESHOLD值,GEN_CLUST_INDEX是InnoDB在创建InnoDB表时,在没有主键或唯一键索引的情况下创建的聚集索引。只能通过设置表的MERGE_THRESHOLD来修改GEN_CLUST_INDEX的MERGE_THRESHOLD值

查询索引的MERGE_THRESHOLD值
当前索引的MERGE_THRESHOLD值可以通过查询INNODB_SYS_INDEXES表获得。例如:

mysql> SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_INDEXES WHERE NAME='id_index' \G
*************************** 1. row ***************************
       INDEX_ID: 265
           NAME: id_index
       TABLE_ID: 267
           TYPE: 0
       N_FIELDS: 1
        PAGE_NO: 4
          SPACE: 269
MERGE_THRESHOLD: 40
1 row in set (0.00 sec)

如果使用table_option COMMENT子句显式定义,可以使用SHOW CREATE TABLE查看表的MERGE_THRESHOLD值

mysql> SHOW CREATE TABLE t1 \G
*************************** 1. row ***************************
       Table: t1
Create Table: CREATE TABLE `t1` (
  `id` int(11) DEFAULT NULL,
  KEY `id_index` (`id`) COMMENT 'MERGE_THRESHOLD=40'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4
1 row in set (0.00 sec)

在索引级别定义的MERGE_THRESHOLD值优先于为表定义的MERGE_THRESHOLD值。如果未定义,MERGE_THRESHOLD默认为50% (MERGE_THRESHOLD=50,这是以前的硬编码值。

同样,如果使用index_option COMMENT子句显式地定义,也可以使用SHOW INDEX查看索引的MERGE_THRESHOLD值:

mysql> show index from t1 \G
*************************** 1. row ***************************
        Table: t1
   Non_unique: 1
     Key_name: id_index
 Seq_in_index: 1
  Column_name: id
    Collation: A
  Cardinality: 0
     Sub_part: NULL
       Packed: NULL
         Null: YES
   Index_type: BTREE
      Comment:
Index_comment: MERGE_THRESHOLD=40
1 row in set (0.00 sec)

测量MERGE_THRESHOLD设置的效果:

INNODB_METRICS表提供了两个计数器,可以用来衡量MERGE_THRESHOLD设置对索引页合并的影响。

mysql> SELECT NAME, COMMENT FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE NAME like '%index_page_merge%';
+-----------------------------+----------------------------------------+
| NAME                        | COMMENT                                |
+-----------------------------+----------------------------------------+
| index_page_merge_attempts   | Number of index page merge attempts    |
| index_page_merge_successful | Number of successful index page merges |
+-----------------------------+----------------------------------------+
2 rows in set (0.00 sec)

当降低MERGE_THRESHOLD值时,目标是:
.页面合并尝试和成功合并的次数更少
.尝试合并和成功合并页面的次数相同

太小的MERGE_THRESHOLD设置由于大量的空页面空间导致大量的数据文件。

]]>
http://www.jydba.net/index.php/archives/3368/feed 0
MySQL 配置InnoDB配置非持久优化器统计信息参数 http://www.jydba.net/index.php/archives/3366 http://www.jydba.net/index.php/archives/3366#respond Fri, 11 Mar 2022 00:44:30 +0000 http://www.jydba.net/?p=3366 配置非持久优化器统计信息参数
本节介绍如何配置非持久优化器统计信息。当innodb_stats_persistent=OFF或使用STATS_PERSISTENT=0创建或修改单个表时,优化器统计信息不会被持久化到磁盘。相反,统计信息存储在内存中,并且在服务器关闭时丢失。统计数据还由某些操作在某些条件下定期更新。

从MySQL 5.6.6开始,默认情况下,优化器统计数据被持久化到磁盘上,由innodb_stats_persistent配置选项启用。

优化器数据更新
在以下情况出现时非持久化的优化器统计信息会被更新:
.执行analyze table

.运行show table status,show index,或者在innodb_stats_on_metadata选项被启用时查询information_schema.tables或information_schema.statistics表。

MySQL 5.6.6中,当持久化优化器统计信息被启用时,innodb_stats_on_metadata默认设置为OFF。启用innodb_stats_on_metadata可能会降低具有大量表或索引的模式的访问速度,并降低涉及InnoDB表的查询的执行计划的稳定性。innodb_stats_on_metadata使用SET语句全局配置。set global innodb_stats_on_metadata=ON

innodb_stats_on_metadata只适用于优化器统计信息配置为非持久化(当innodb_stats_persistent被禁用时)。

.启动mysql客户端时启用–auto-rehash选项,这是默认设置。auto-rehash选项会打开所有InnoDB表,打开表的操作会导致统计数据重新计算。为了提高mysql客户端的启动和更新统计信息时间,你可以使用–disable-auto-rehash选项关闭auto-rehash。自动auto-rehash特性允许交互用户自动完成数据库、表和列名的命名。

.表第一次打开。

.InnoDB检测到有1 / 16的表在上次统计数据更新后被修改。

配置采样页面数
MySQL查询优化器使用关于键分布的估计统计信息,根据索引的相对选择性为执行计划选择索引。当InnoDB更新优化器统计数据时,它会从表上的每个索引中随机取样,以估计索引的基数。(这种技术被称为随机潜水。)

为了控制统计信息评估的质量(从而为查询优化器提供更好的信息),可以使用参数innodb_stats_transient_sample_pages更改抽样页面的数量。默认的抽样页面数是8,这可能不足以产生准确的评估,导致查询优化器的索引选择很差。这种技术对于大型表和连接中使用的表尤其重要。对这样的表进行不必要的全表扫描可能会造成严重的性能问题。

当innodb_stats_transient_sample_pages =0时,innodb_stats_persistent的值会影响所有InnoDB表和索引的索引采样。当您更改索引样本大小时,请注意以下潜在的重大影响。
.小值像1或2可以导致不精确的基数评估

.增加innodb_stats_transient_sample_pages的值可能需要更多的磁盘读取。大于8(比如100)的值会导致打开表或执行SHOW table STATUS所需的时间显著放缓。

.优化器可能会根据索引选择性的不同估计选择非常不同的查询计划

无论innodb_stats_transient_sample_pages的值是什么,设置该选项并保持该值。选择一个值,它可以为数据库中的所有表提供合理准确的估计,而不需要过多的I/O。因为除了在执行ANALYZE TABLE时,统计数据会在其他时间自动重新计算,所以增加索引样本大小,运行ANALYZE TABLE,然后再次减少样本大小是没有意义的。

较小的表通常比较大的表需要更少的索引样本。如果你的数据库有很多大的表,考虑使用一个更大的innodb_stats_transient_sample_pages值。

评估InnoDB表analyze table的复杂度
InnoDB表的ANALYZE TABLE复杂度依赖于:
.采样的页面数,由innodb_stats_persistent_sample_pages定义

.表中索引列的数目

.分区数。如果表没有分区,则认为分区数为1。

使用这些参数,估计ANALYZE TABLE复杂度的近似公式是
innodb_stats_persistent_sample_pages的值*表中索引的列数*分区数

通常,结果值越大,ANALYZE TABLE的执行时间就越长

innodb_stats_persistent_sample_pages定义了在全局级别上采样的页面数量。要设置单个表的采样页数,请使用有STATS_SAMPLE_PAGES选项的CREATE TABLE或ALTER TABLE的语句。

如果innodb_stats_persistent=OFF,则由innodb_stats_transient_sample_pages定义采样的页面数

要了解估算ANALYZE TABLE复杂度的更深入的方法,请考虑以下示例:
在大O符号中,ANALYZE TABLE的复杂度被描述为:

O(n_sample
* (n_cols_in_uniq_i
+ n_cols_in_non_uniq_i
+ n_cols_in_pk * (1 + n_non_uniq_i))
* n_part)

.n_sample是采样的页面数(由innodb_stats_persistent_sample_pages定义)

.n_cols_in_uniq_i是所有唯一索引中所有列的总数(不计算主键列)

.n_cols_in_non_uniq_i是所有非唯一索引中所有列的总数

.n_cols_in_pk是主键中的列数(如果没有定义主键,InnoDB会在内部创建一个单列主键)

.n_non_uniq_i是表中非唯一索引的个数

.n_part是分区的数量。如果没有定义分区,则将表视为单个分区。

现在,考虑下面的表(表t),它有一个主键(2列)、一个唯一索引(2列)和两个非唯一索引(各有两列):

mysql> CREATE TABLE t (
    -> a INT,
    -> b INT,
    -> c INT,
    -> d INT,
    -> e INT,
    -> f INT,
    -> g INT,
    -> h INT,
    -> PRIMARY KEY (a, b),
    -> UNIQUE KEY i1uniq (c, d),
    -> KEY i2nonuniq (e, f),
    -> KEY i3nonuniq (g, h)
    -> );
Query OK, 0 rows affected (0.13 sec)

对于上述算法所需的列和索引数据,查询mysql.innodb_index_stats来查看表t的持久索引统计信息。n_diff_pfx%显示了每个索引列的统计信息。
例如,列a和列b用于计算主键索引。对于非唯一索引,除了用户定义的列外,还要统计主键列(a,b)。

mysql> select index_name, stat_name, stat_description
    -> from mysql.innodb_index_stats
    -> where
    -> database_name='mysql' and
    -> table_name='t' and
    -> stat_name like 'n_diff_pfx%';
+------------+--------------+------------------+
| index_name | stat_name    | stat_description |
+------------+--------------+------------------+
| PRIMARY    | n_diff_pfx01 | a                |
| PRIMARY    | n_diff_pfx02 | a,b              |
| i1uniq     | n_diff_pfx01 | c                |
| i1uniq     | n_diff_pfx02 | c,d              |
| i2nonuniq  | n_diff_pfx01 | e                |
| i2nonuniq  | n_diff_pfx02 | e,f              |
| i2nonuniq  | n_diff_pfx03 | e,f,a            |
| i2nonuniq  | n_diff_pfx04 | e,f,a,b          |
| i3nonuniq  | n_diff_pfx01 | g                |
| i3nonuniq  | n_diff_pfx02 | g,h              |
| i3nonuniq  | n_diff_pfx03 | g,h,a            |
| i3nonuniq  | n_diff_pfx04 | g,h,a,b          |
+------------+--------------+------------------+
12 rows in set (0.01 sec)

根据上面显示的索引统计数据和表定义,可以确定以下值:
.n_cols_in_uniq_i,不计算主键列的所有唯一索引中所有列的总数为2 (c和d)

.n_cols_in_non_uniq_i,所有非唯一索引中所有列的总数,为4 (e、f、g和h)

.n_cols_in_pk,主键中的列数是2(a和b)

.n_non_uniq_i,表中非唯一索引的数量为2 (i2nonuniq和i3nonuniq))

.n_part, 分区数,为1

现在可以计算innodb_stats_persistent_sample_pages *(2 + 4 + 2 *(1 + 2)) * 1来确定扫描的叶页数。如果将innodb_stats_persistent_sample_pages设置为默认值20,并将默认的页面大小设置为16 KiB (innodb_page_size=16384),那么你可以估计为表t读取20 * 12 * 16384字节,或者大约4 MiB。

所有4MiB可能不是从磁盘读取的,因为一些叶页可能已经缓存在缓冲池中。

]]>
http://www.jydba.net/index.php/archives/3366/feed 0