但行好事 莫问前程 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
oracle使用rman对启用归档的rac 11g数据库执行备份与恢复操作(异机恢复) http://www.jydba.net/index.php/archives/3553 http://www.jydba.net/index.php/archives/3553#respond Tue, 19 Mar 2024 00:41:33 +0000 http://www.jydba.net/?p=3553 因为要被审计的数据库有10T大小,用逻辑导出导入方式复制一份数据用于审计满足不了时间要求,而且生产环境没有空间用于执行逻辑备份或物理备份,所以执行rman物理备份时只能通过nfs将备份文件直接存储在目标主机上。但我这里的测试还是在生产环境中执行rman备份,这个只是测试可行性。下面是将生产库通过rman备份在异机上执行恢复的具体步骤:
1.对源库执行全库备份脚本

vi backup.sh
backtime=`date +"20%y%m%d%H%M%S"`
rman target /  log=/rmanbak/dadb_backupall_$backtime.log < 

2.执行备份脚本对源库执行备份

[oracle@dbs1 rmanbak]$ ./jy.sh

RMAN> 2> 3> 4> 5> 6> 7> 8> 9> 10> 11> 12> 13> 14>
using target database control file instead of recovery catalog
allocated channel: c1
channel c1: SID=3694 instance=dadb1 device type=DISK

allocated channel: c2
channel c2: SID=1849 instance=dadb1 device type=DISK

Starting backup at 06-MAR-24
channel c1: starting compressed full datafile backup set
channel c1: specifying datafile(s) in backup set
input datafile file number=00002 name=+DA/dadbp/datafile/sysaux.260.1109022421
input datafile file number=00007 name=+DA/dadbp/datafile/system001.dbf
input datafile file number=00010 name=+DA/dadbp/datafile/test.288.1109026503
input datafile file number=00004 name=+DA/dadbp/datafile/users.267.1109022873
input datafile file number=00006 name=+DA/dadbp/datafile/hygeia.261.1109022717
channel c1: starting piece 1 at 06-MAR-24
channel c2: starting compressed full datafile backup set
channel c2: specifying datafile(s) in backup set
input datafile file number=00008 name=+DA/dadbp/datafile/sysaux.259.1109022127
input datafile file number=00001 name=+DA/dadbp/datafile/system.263.1109022847
input datafile file number=00005 name=+DA/dadbp/datafile/undotbs2.264.1109022863
input datafile file number=00003 name=+DA/dadbp/datafile/undotbs1.265.1109022869
input datafile file number=00009 name=+DA/dadbp/datafile/cs01.bdf
channel c2: starting piece 1 at 06-MAR-24
channel c2: finished piece 1 at 06-MAR-24
piece handle=/rmanbak/dadb_DADB_20240306_vv2l0hog_1_1 tag=DA_FULL_BAK comment=NONE
channel c2: backup set complete, elapsed time: 00:14:35
channel c2: starting compressed full datafile backup set
channel c2: specifying datafile(s) in backup set
including current control file in backup set
channel c2: starting piece 1 at 06-MAR-24
channel c2: finished piece 1 at 06-MAR-24
piece handle=/rmanbak/dadb_DADB_20240306_002l0ijr_1_1 tag=DA_FULL_BAK comment=NONE
channel c2: backup set complete, elapsed time: 00:00:03
channel c2: starting compressed full datafile backup set
channel c2: specifying datafile(s) in backup set
including current SPFILE in backup set
channel c2: starting piece 1 at 06-MAR-24
channel c2: finished piece 1 at 06-MAR-24
piece handle=/rmanbak/dadb_DADB_20240306_012l0ijv_1_1 tag=DA_FULL_BAK comment=NONE
channel c2: backup set complete, elapsed time: 00:00:01
channel c1: finished piece 1 at 06-MAR-24
piece handle=/rmanbak/dadb_DADB_20240306_vu2l0hog_1_1 tag=DA_FULL_BAK comment=NONE
channel c1: backup set complete, elapsed time: 00:18:24
Finished backup at 06-MAR-24

sql statement: alter system archive log current

Starting backup at 06-MAR-24
current log archived
channel c1: starting archived log backup set
channel c1: specifying archived log(s) in backup set
input archived log thread=1 sequence=36171 RECID=12088 STAMP=1162596765
input archived log thread=2 sequence=27786 RECID=12094 STAMP=1162628068
input archived log thread=1 sequence=36172 RECID=12090 STAMP=1162625683
input archived log thread=1 sequence=36173 RECID=12092 STAMP=1162628067
input archived log thread=1 sequence=36174 RECID=12096 STAMP=1162645216
input archived log thread=2 sequence=27787 RECID=12098 STAMP=1162663210
input archived log thread=1 sequence=36175 RECID=12101 STAMP=1162679311
input archived log thread=2 sequence=27788 RECID=12102 STAMP=1162679311
input archived log thread=1 sequence=36176 RECID=12104 STAMP=1162679313
input archived log thread=2 sequence=27789 RECID=12106 STAMP=1162679314
input archived log thread=1 sequence=36177 RECID=12108 STAMP=1162683167
input archived log thread=2 sequence=27790 RECID=12114 STAMP=1162714548
input archived log thread=1 sequence=36178 RECID=12110 STAMP=1162713627
input archived log thread=1 sequence=36179 RECID=12112 STAMP=1162714545
input archived log thread=1 sequence=36180 RECID=12116 STAMP=1162750588
input archived log thread=2 sequence=27791 RECID=12120 STAMP=1162765758
channel c1: starting piece 1 at 06-MAR-24
channel c2: starting archived log backup set
channel c2: specifying archived log(s) in backup set
input archived log thread=1 sequence=36181 RECID=12118 STAMP=1162765756
input archived log thread=1 sequence=36182 RECID=12124 STAMP=1162765763
input archived log thread=2 sequence=27792 RECID=12122 STAMP=1162765761
input archived log thread=2 sequence=27793 RECID=12130 STAMP=1162800019
input archived log thread=1 sequence=36183 RECID=12126 STAMP=1162769575
input archived log thread=1 sequence=36184 RECID=12128 STAMP=1162800017
input archived log thread=1 sequence=36185 RECID=12132 STAMP=1162801020
input archived log thread=2 sequence=27794 RECID=12136 STAMP=1162850453
input archived log thread=1 sequence=36186 RECID=12134 STAMP=1162846806
input archived log thread=1 sequence=36187 RECID=12138 STAMP=1162852076
input archived log thread=2 sequence=27795 RECID=12140 STAMP=1162852078
input archived log thread=1 sequence=36188 RECID=12144 STAMP=1162852082
input archived log thread=2 sequence=27796 RECID=12142 STAMP=1162852080
input archived log thread=2 sequence=27797 RECID=12150 STAMP=1162887460
input archived log thread=1 sequence=36189 RECID=12146 STAMP=1162855991
input archived log thread=1 sequence=36190 RECID=12148 STAMP=1162887457
input archived log thread=1 sequence=36191 RECID=12154 STAMP=1162890083
input archived log thread=2 sequence=27798 RECID=12152 STAMP=1162890082
channel c2: starting piece 1 at 06-MAR-24
channel c1: finished piece 1 at 06-MAR-24
piece handle=/rmanbak/dadb_arc_1162890092_21506 tag=DA_ARC_BAK comment=NONE
channel c1: backup set complete, elapsed time: 00:00:15
channel c1: starting archived log backup set
channel c1: specifying archived log(s) in backup set
input archived log thread=2 sequence=27799 RECID=12158 STAMP=1162890088
input archived log thread=1 sequence=36192 RECID=12156 STAMP=1162890086
channel c1: starting piece 1 at 06-MAR-24
channel c2: finished piece 1 at 06-MAR-24
piece handle=/rmanbak/dadb_arc_1162890092_21507 tag=DA_ARC_BAK comment=NONE
channel c2: backup set complete, elapsed time: 00:00:15
channel c1: finished piece 1 at 06-MAR-24
piece handle=/rmanbak/dadb_arc_1162890107_21508 tag=DA_ARC_BAK comment=NONE
channel c1: backup set complete, elapsed time: 00:00:01
Finished backup at 06-MAR-24

Starting backup at 06-MAR-24
channel c1: starting full datafile backup set
channel c1: specifying datafile(s) in backup set
including current control file in backup set
channel c1: starting piece 1 at 06-MAR-24
channel c1: finished piece 1 at 06-MAR-24
piece handle=/rmanbak/dadb_cntrl_21509_1_21509 tag=DA_CONTROL_BAK comment=NONE
channel c1: backup set complete, elapsed time: 00:00:01
Finished backup at 06-MAR-24

validation succeeded for archived log
archived log file name=+ARCH/dadbp/archivelog/2024_03_02/thread_1_seq_36171.938.1162596765 RECID=12088 STAMP=1162596765
validation succeeded for archived log
archived log file name=+ARCH/dadbp/archivelog/2024_03_03/thread_1_seq_36172.317.1162625683 RECID=12090 STAMP=1162625683
validation succeeded for archived log
archived log file name=+ARCH/dadbp/archivelog/2024_03_03/thread_1_seq_36173.2388.1162628067 RECID=12092 STAMP=1162628067
validation succeeded for archived log
archived log file name=+ARCH/dadbp/archivelog/2024_03_03/thread_1_seq_36174.1976.1162645215 RECID=12096 STAMP=1162645216
validation succeeded for archived log
archived log file name=+ARCH/dadbp/archivelog/2024_03_03/thread_1_seq_36175.370.1162679311 RECID=12101 STAMP=1162679311
validation succeeded for archived log
archived log file name=+ARCH/dadbp/archivelog/2024_03_03/thread_1_seq_36176.962.1162679313 RECID=12104 STAMP=1162679313
validation succeeded for archived log
archived log file name=+ARCH/dadbp/archivelog/2024_03_03/thread_1_seq_36177.2719.1162683167 RECID=12108 STAMP=1162683167
validation succeeded for archived log
archived log file name=+ARCH/dadbp/archivelog/2024_03_04/thread_1_seq_36178.2575.1162713627 RECID=12110 STAMP=1162713627
validation succeeded for archived log
archived log file name=+ARCH/dadbp/archivelog/2024_03_04/thread_1_seq_36179.2282.1162714545 RECID=12112 STAMP=1162714545
validation succeeded for archived log
archived log file name=+ARCH/dadbp/archivelog/2024_03_04/thread_1_seq_36180.1884.1162750589 RECID=12116 STAMP=1162750588
validation succeeded for archived log
archived log file name=+ARCH/dadbp/archivelog/2024_03_04/thread_1_seq_36181.973.1162765757 RECID=12118 STAMP=1162765756
validation succeeded for archived log
archived log file name=+ARCH/dadbp/archivelog/2024_03_04/thread_1_seq_36182.2148.1162765763 RECID=12124 STAMP=1162765763
validation succeeded for archived log
archived log file name=+ARCH/dadbp/archivelog/2024_03_04/thread_1_seq_36183.1132.1162769575 RECID=12126 STAMP=1162769575
validation succeeded for archived log
archived log file name=+ARCH/dadbp/archivelog/2024_03_05/thread_1_seq_36184.2397.1162800017 RECID=12128 STAMP=1162800017
validation succeeded for archived log
archived log file name=+ARCH/dadbp/archivelog/2024_03_05/thread_1_seq_36185.1359.1162801021 RECID=12132 STAMP=1162801020
validation succeeded for archived log
archived log file name=+ARCH/dadbp/archivelog/2024_03_05/thread_1_seq_36186.2488.1162846805 RECID=12134 STAMP=1162846806
validation succeeded for archived log
archived log file name=+ARCH/dadbp/archivelog/2024_03_05/thread_1_seq_36187.2068.1162852077 RECID=12138 STAMP=1162852076
validation succeeded for archived log
archived log file name=+ARCH/dadbp/archivelog/2024_03_05/thread_1_seq_36188.2513.1162852083 RECID=12144 STAMP=1162852082
validation succeeded for archived log
archived log file name=+ARCH/dadbp/archivelog/2024_03_05/thread_1_seq_36189.2592.1162855991 RECID=12146 STAMP=1162855991
validation succeeded for archived log
archived log file name=+ARCH/dadbp/archivelog/2024_03_06/thread_1_seq_36190.287.1162887457 RECID=12148 STAMP=1162887457
validation succeeded for archived log
archived log file name=+ARCH/dadbp/archivelog/2024_03_06/thread_1_seq_36191.2276.1162890083 RECID=12154 STAMP=1162890083
validation succeeded for archived log
archived log file name=+ARCH/dadbp/archivelog/2024_03_06/thread_1_seq_36192.1168.1162890087 RECID=12156 STAMP=1162890086
validation succeeded for archived log
archived log file name=+ARCH/dadbp/archivelog/2024_03_03/thread_2_seq_27786.2448.1162628069 RECID=12094 STAMP=1162628068
validation succeeded for archived log
archived log file name=+ARCH/dadbp/archivelog/2024_03_03/thread_2_seq_27787.1182.1162663211 RECID=12098 STAMP=1162663210
validation succeeded for archived log
archived log file name=+ARCH/dadbp/archivelog/2024_03_03/thread_2_seq_27788.567.1162679311 RECID=12102 STAMP=1162679311
validation succeeded for archived log
archived log file name=+ARCH/dadbp/archivelog/2024_03_03/thread_2_seq_27789.2305.1162679315 RECID=12106 STAMP=1162679314
validation succeeded for archived log
archived log file name=+ARCH/dadbp/archivelog/2024_03_04/thread_2_seq_27790.2769.1162714549 RECID=12114 STAMP=1162714548
validation succeeded for archived log
archived log file name=+ARCH/dadbp/archivelog/2024_03_04/thread_2_seq_27791.2742.1162765757 RECID=12120 STAMP=1162765758
validation succeeded for archived log
archived log file name=+ARCH/dadbp/archivelog/2024_03_04/thread_2_seq_27792.1811.1162765761 RECID=12122 STAMP=1162765761
validation succeeded for archived log
archived log file name=+ARCH/dadbp/archivelog/2024_03_05/thread_2_seq_27793.1189.1162800019 RECID=12130 STAMP=1162800019
validation succeeded for archived log
archived log file name=+ARCH/dadbp/archivelog/2024_03_05/thread_2_seq_27794.1140.1162850449 RECID=12136 STAMP=1162850453
validation succeeded for archived log
archived log file name=+ARCH/dadbp/archivelog/2024_03_05/thread_2_seq_27795.2058.1162852077 RECID=12140 STAMP=1162852078
validation succeeded for archived log
archived log file name=+ARCH/dadbp/archivelog/2024_03_05/thread_2_seq_27796.2345.1162852081 RECID=12142 STAMP=1162852080
validation succeeded for archived log
archived log file name=+ARCH/dadbp/archivelog/2024_03_06/thread_2_seq_27797.1391.1162887461 RECID=12150 STAMP=1162887460
validation succeeded for archived log
archived log file name=+ARCH/dadbp/archivelog/2024_03_06/thread_2_seq_27798.2100.1162890083 RECID=12152 STAMP=1162890082
validation succeeded for archived log
archived log file name=+ARCH/dadbp/archivelog/2024_03_06/thread_2_seq_27799.2212.1162890089 RECID=12158 STAMP=1162890088
Crosschecked 36 objects


crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/rmanbak/dangan/db_DADB_20240303_v62kq4gm_1_1 RECID=21314 STAMP=1162678806
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/rmanbak/dangan/db_DADB_20240303_v72kq4uk_1_1 RECID=21315 STAMP=1162679259
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/rmanbak/dangan/db_DADB_20240303_v52kq4gm_1_1 RECID=21317 STAMP=1162678806
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/rmanbak/dangan/arc_1162679319_21482 RECID=21318 STAMP=1162679319
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/rmanbak/dangan/arc_1162679319_21481 RECID=21319 STAMP=1162679319
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/rmanbak/dangan/arc_1162679326_21483 RECID=21320 STAMP=1162679326
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/rmanbak/dangan/cntrl_21484_1_21484 RECID=21321 STAMP=1162679331
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/rmanbak/dangan/db_DADB_20240304_ve2ksoso_1_1 RECID=21322 STAMP=1162765208
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/rmanbak/dangan/db_DADB_20240304_vf2kspbt_1_1 RECID=21323 STAMP=1162765719
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/rmanbak/dangan/db_DADB_20240304_vg2kspco_1_1 RECID=21324 STAMP=1162765720
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/rmanbak/dangan/db_DADB_20240304_vd2ksoso_1_1 RECID=21325 STAMP=1162765208
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/rmanbak/dangan/arc_1162765766_21490 RECID=21326 STAMP=1162765767
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/rmanbak/dangan/arc_1162765766_21489 RECID=21327 STAMP=1162765766
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/rmanbak/dangan/cntrl_21491_1_21491 RECID=21328 STAMP=1162765777
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/rmanbak/dangan/db_DADB_20240305_vl2kvd8m_1_1 RECID=21329 STAMP=1162851606
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/rmanbak/dangan/db_DADB_20240305_vm2kvdll_1_1 RECID=21330 STAMP=1162852028
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/rmanbak/dangan/db_DADB_20240305_vn2kvdlt_1_1 RECID=21331 STAMP=1162852029
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/rmanbak/dangan/db_DADB_20240305_vk2kvd8m_1_1 RECID=21332 STAMP=1162851606
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/rmanbak/dangan/arc_1162852086_21496 RECID=21333 STAMP=1162852086
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/rmanbak/dangan/arc_1162852086_21497 RECID=21334 STAMP=1162852086
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/rmanbak/dangan/arc_1162852093_21498 RECID=21335 STAMP=1162852093
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/rmanbak/dangan/cntrl_21499_1_21499 RECID=21336 STAMP=1162852098
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/rmanbak/dadb_DADB_20240306_vv2l0hog_1_1 RECID=21337 STAMP=1162888976
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/rmanbak/dadb_DADB_20240306_002l0ijr_1_1 RECID=21338 STAMP=1162889852
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/rmanbak/dadb_DADB_20240306_012l0ijv_1_1 RECID=21339 STAMP=1162889855
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/rmanbak/dadb_DADB_20240306_vu2l0hog_1_1 RECID=21340 STAMP=1162888976
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/rmanbak/dadb_arc_1162890092_21506 RECID=21341 STAMP=1162890092
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/rmanbak/dadb_arc_1162890092_21507 RECID=21342 STAMP=1162890092
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/rmanbak/dadb_arc_1162890107_21508 RECID=21343 STAMP=1162890107
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/rmanbak/dadb_cntrl_21509_1_21509 RECID=21344 STAMP=1162890110
Crosschecked 30 objects


specification does not match any backup in the repository

RMAN retention policy will be applied to the command
RMAN retention policy is set to recovery window of 7 days
no obsolete backups found

released channel: c1

released channel: c2

RMAN>

Recovery Manager complete.

3.将备份文件拷贝到目标主机上

[root@dbs1 rmanbak]# scp dadb*  10.18.10.101:/databak/dadb/
root@10.18.10.101's password:
dadb_arc_1162890092_21506                                                                                                                                                                                100%  970MB  88.2MB/s   00:11
dadb_arc_1162890092_21507                                                                                                                                                                                100%  854MB  85.4MB/s   00:10
dadb_arc_1162890107_21508                                                                                                                                                                                100%   20KB  20.0KB/s   00:00
dadb_backupall_20240306084252.log                                                                                                                                                                        100%   17KB  16.7KB/s   00:00
dadb_cntrl_21509_1_21509                                                                                                                                                                                 100%   85MB  85.4MB/s   00:00
dadb_DADB_20240306_002l0ijr_1_1                                                                                                                                                                          100% 5344KB   5.2MB/s   00:01
dadb_DADB_20240306_012l0ijv_1_1                                                                                                                                                                          100%   96KB  96.0KB/s   00:00
dadb_DADB_20240306_vu2l0hog_1_1                                                                                                                                                                          100% 5794MB  90.5MB/s   01:04
dadb_DADB_20240306_vv2l0hog_1_1                                                                                                                                                                          100% 4626MB  94.4MB/s   00:49
[root@dbs1 rmanbak]#

4.将源库的密码文件复制到目标主机上

[root@dbs1 rmanbak]# scp  /u01/app/oracle/product/11.2.0.4/db/dbs/orapwdadb1  10.18.10.101:/u01/app/oracle/product/11.2.0.4/db/dbs/
root@10.18.10.101's password:
orapwdadb1                                                                                                                                                                                               100% 1536     1.5KB/s   00:00
[root@dbs1 rmanbak]#

5.恢复初始化参数文件(这里需要找到包含初始化参数文件的备份集,在源端数据库可以通过list backup可以找到包含参数文件的备份集)

[oracle@sjjh dbs]$ rman target/

Recovery Manager: Release 11.2.0.4.0 - Production on Wed Mar 6 09:39:47 2024

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

connected to target database (not started)

RMAN> startup nomount

startup failed: ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file '/u01/app/oracle/product/11.2.0.4/db/dbs/initdadb.ora'

starting Oracle instance without parameter file for retrieval of spfile
Oracle instance started

Total System Global Area    1068937216 bytes

Fixed Size                     2260088 bytes
Variable Size                327156616 bytes
Database Buffers             734003200 bytes
Redo Buffers                   5517312 bytes

RMAN> restore spfile to pfile '/u01/app/oracle/product/11.2.0.4/db/dbs/initdadb.ora' from '/databak/dadb/dadb_DADB_20240306_012l0ijv_1_1';

Starting restore at 06-MAR-24
using channel ORA_DISK_1

channel ORA_DISK_1: restoring spfile from AUTOBACKUP /databak/dadb/dadb_DADB_20240306_012l0ijv_1_1
channel ORA_DISK_1: SPFILE restore from AUTOBACKUP complete
Finished restore at 06-MAR-24

6.修改控制文件

[oracle@sjjh dbs]$ cat  initdadb.ora
dadb1.__db_cache_size=5133828096
dadb2.__db_cache_size=6442450944
dadb1.__java_pool_size=234881024
dadb2.__java_pool_size=234881024
dadb1.__large_pool_size=268435456
dadb2.__large_pool_size=268435456
dadb1.__oracle_base='/u01/app/oracle'#ORACLE_BASE set from environment
dadb1.__pga_aggregate_target=5368709120
dadb2.__pga_aggregate_target=5368709120
dadb1.__sga_target=10737418240
dadb2.__sga_target=10737418240
dadb1.__shared_io_pool_size=536870912
dadb2.__shared_io_pool_size=0
dadb1.__shared_pool_size=4429185024
dadb2.__shared_pool_size=3724541952
dadb1.__streams_pool_size=67108864
dadb2.__streams_pool_size=0
*.audit_file_dest='/u01/app/oracle/admin/dadb/adump'
*.audit_trail='db'
*.compatible='11.2.0.4.0'
*.control_files='/oradata/dadb/controlfile/control01.ctl','/oradata/dadb/controlfile/control02.ctl'
*.db_block_size=8192
*.db_create_file_dest='/oradata/dadb'
*.db_domain=''
*.db_file_name_convert='+da/dadbs/','/oradata/dadb/'
*.db_name='dadb'
*.db_unique_name='dadbp'
*.diagnostic_dest='/u01/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=dadbXDB)'
dadb2.instance_number=2
dadb1.instance_number=1
*.log_archive_dest_1='location=/oradata/arch  valid_for=(all_logfiles,all_roles) db_unique_name=dadb'
*.log_archive_dest_2=''
*.log_archive_dest_state_1='ENABLE'
*.log_archive_dest_state_2='enable'
*.log_archive_format='%t_%s_%r.arch'
*.log_file_name_convert='+da/dadbs/','/oradata/dadb/'
*.open_cursors=300
*.pga_aggregate_target=5368709120
*.processes=3000
*.remote_login_passwordfile='exclusive'
*.service_names='dadb'
*.sessions=3305
*.sga_max_size=10737418240
*.sga_target=10737418240
dadb2.thread=2
dadb1.thread=1
dadb1.undo_tablespace='UNDOTBS1'
dadb2.undo_tablespace='UNDOTBS2'

[oracle@sjjh dbs]$ mkdir -p /u01/app/oracle/admin/dadb/adump

7.使用恢复的初始化参数文件nomount数据库

RMAN> shutdown immediate

Oracle instance shut down


RMAN> startup nomount pfile='/u01/app/oracle/product/11.2.0.4/db/dbs/initdadb.ora'

Oracle instance started

Total System Global Area   10689474560 bytes

Fixed Size                     2262656 bytes
Variable Size               2785020288 bytes
Database Buffers            7885291520 bytes
Redo Buffers                  16900096 bytes

8.恢复控制文件

RMAN> restore controlfile from '/databak/dadb/dadb_DADB_20240306_002l0ijr_1_1';

Starting restore at 06-MAR-24
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=1982 device type=DISK

channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:03
output file name=/oradata/dadb/controlfile/control01.ctl
output file name=/oradata/dadb/controlfile/control02.ctl
Finished restore at 06-MAR-24

9.启动数据库到mount状态

RMAN> alter database mount;

database mounted
released channel: ORA_DISK_1

10.将备份集的信息加入到catalog,使目前的控制文件记录有目前的备份信息,以便用户恢复.从远端数据库拷贝过来的备份集存放于目录/databak/dadb/

RMAN> catalog start with '/databak/dadb/';

searching for all files that match the pattern /databak/dadb/

List of Files Unknown to the Database
=====================================
File Name: /databak/dadb/dadb_cntrl_21509_1_21509
File Name: /databak/dadb/dadb_DADB_20240306_vu2l0hog_1_1
File Name: /databak/dadb/dadb_DADB_20240306_002l0ijr_1_1
File Name: /databak/dadb/dadb_arc_1162890092_21506
File Name: /databak/dadb/dadb_DADB_20240306_012l0ijv_1_1
File Name: /databak/dadb/dadb_arc_1162890092_21507
File Name: /databak/dadb/dadb_arc_1162890107_21508
File Name: /databak/dadb/dadb_DADB_20240306_vv2l0hog_1_1

Do you really want to catalog the above files (enter YES or NO)? YES
cataloging files...
cataloging done

List of Cataloged Files
=======================
File Name: /databak/dadb/dadb_cntrl_21509_1_21509
File Name: /databak/dadb/dadb_DADB_20240306_vu2l0hog_1_1
File Name: /databak/dadb/dadb_DADB_20240306_002l0ijr_1_1
File Name: /databak/dadb/dadb_arc_1162890092_21506
File Name: /databak/dadb/dadb_DADB_20240306_012l0ijv_1_1
File Name: /databak/dadb/dadb_arc_1162890092_21507
File Name: /databak/dadb/dadb_arc_1162890107_21508
File Name: /databak/dadb/dadb_DADB_20240306_vv2l0hog_1_1

11.还原数据文件

RMAN> run{
2> allocate channel c1 device type disk;
3> allocate channel c2 device type disk;
4> set newname for datafile '+DA/dadbp/datafile/cs01.bdf' to '/oradata/dadb/cs01.dbf';
5> set newname for datafile '+DA/dadbp/datafile/hygeia.261.1109022717' to '/oradata/dadb/hygeia.dbf';
6> set newname for datafile '+DA/dadbp/datafile/sysaux.260.1109022421' to '/oradata/dadb/sysaux01.dbf';
7> set newname for datafile '+DA/dadbp/datafile/sysaux.259.1109022127' to '/oradata/dadb/sysaux.dbf';
8> set newname for datafile '+DA/dadbp/datafile/system.263.1109022847' to '/oradata/dadb/system.dbf';
9> set newname for datafile '+DA/dadbp/datafile/system001.dbf' to '/oradata/dadb/system001.dbf';
10> set newname for datafile '+DA/dadbp/datafile/test.288.1109026503' to '/oradata/dadb/test.dbf';
11> set newname for datafile '+DA/dadbp/datafile/undotbs1.265.1109022869' to '/oradata/dadb/undotbs1.dbf';
12> set newname for datafile '+DA/dadbp/datafile/undotbs2.264.1109022863' to '/oradata/dadb/undotbs2.dbf';
13> set newname for datafile '+DA/dadbp/datafile/users.267.1109022873' to '/oradata/dadb/users.dbf';
14> restore database;
15> switch datafile all;
16> release channel c1;
17> release channel c2;
18> }

released channel: ORA_DISK_1
allocated channel: c1
channel c1: SID=1982 device type=DISK

allocated channel: c2
channel c2: SID=2266 device type=DISK

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

Starting restore at 06-MAR-24

channel c1: starting datafile backup set restore
channel c1: specifying datafile(s) to restore from backup set
channel c1: restoring datafile 00002 to /oradata/dadb/sysaux01.dbf
channel c1: restoring datafile 00004 to /oradata/dadb/users.dbf
channel c1: restoring datafile 00006 to /oradata/dadb/hygeia.dbf
channel c1: restoring datafile 00007 to /oradata/dadb/system001.dbf
channel c1: restoring datafile 00010 to /oradata/dadb/test.dbf
channel c1: reading from backup piece /databak/dadb/dadb_DADB_20240306_vu2l0hog_1_1
channel c2: starting datafile backup set restore
channel c2: specifying datafile(s) to restore from backup set
channel c2: restoring datafile 00001 to /oradata/dadb/system.dbf
channel c2: restoring datafile 00003 to /oradata/dadb/undotbs1.dbf
channel c2: restoring datafile 00005 to /oradata/dadb/undotbs2.dbf
channel c2: restoring datafile 00008 to /oradata/dadb/sysaux.dbf
channel c2: restoring datafile 00009 to /oradata/dadb/cs01.dbf
channel c2: reading from backup piece /databak/dadb/dadb_DADB_20240306_vv2l0hog_1_1
channel c2: piece handle=/databak/dadb/dadb_DADB_20240306_vv2l0hog_1_1 tag=DA_FULL_BAK
channel c2: restored backup piece 1
channel c2: restore complete, elapsed time: 00:20:26
channel c1: piece handle=/databak/dadb/dadb_DADB_20240306_vu2l0hog_1_1 tag=DA_FULL_BAK
channel c1: restored backup piece 1
channel c1: restore complete, elapsed time: 00:25:36
Finished restore at 06-MAR-24


released channel: c1

released channel: c2

12.还原归档日志文件

RMAN> run{
2> allocate channel c1 device type disk;
3> allocate channel c2 device type disk;
4> set archivelog destination to '/oradata/arch/';
5> restore archivelog from logseq 36171 until logseq 36192 thread 1;
6> restore archivelog from logseq 27786 until logseq 27799 thread 2;
7> release channel c1;
8> release channel c2;
9> }

allocated channel: c1
channel c1: SID=1700 device type=DISK

allocated channel: c2
channel c2: SID=1982 device type=DISK

executing command: SET ARCHIVELOG DESTINATION

Starting restore at 06-MAR-24

channel c1: starting archived log restore to user-specified destination
archived log destination=/oradata/arch/
channel c1: restoring archived log
archived log thread=1 sequence=36171
channel c1: restoring archived log
archived log thread=1 sequence=36172
channel c1: restoring archived log
archived log thread=1 sequence=36173
channel c1: restoring archived log
archived log thread=1 sequence=36174
channel c1: restoring archived log
archived log thread=1 sequence=36175
channel c1: restoring archived log
archived log thread=1 sequence=36176
channel c1: restoring archived log
archived log thread=1 sequence=36177
channel c1: restoring archived log
archived log thread=1 sequence=36178
channel c1: restoring archived log
archived log thread=1 sequence=36179
channel c1: restoring archived log
archived log thread=1 sequence=36180
channel c1: reading from backup piece /databak/dadb/dadb_arc_1162890092_21506
channel c2: starting archived log restore to user-specified destination
archived log destination=/oradata/arch/
channel c2: restoring archived log
archived log thread=1 sequence=36181
channel c2: restoring archived log
archived log thread=1 sequence=36182
channel c2: restoring archived log
archived log thread=1 sequence=36183
channel c2: restoring archived log
archived log thread=1 sequence=36184
channel c2: restoring archived log
archived log thread=1 sequence=36185
channel c2: restoring archived log
archived log thread=1 sequence=36186
channel c2: restoring archived log
archived log thread=1 sequence=36187
channel c2: restoring archived log
archived log thread=1 sequence=36188
channel c2: restoring archived log
archived log thread=1 sequence=36189
channel c2: restoring archived log
archived log thread=1 sequence=36190
channel c2: restoring archived log
archived log thread=1 sequence=36191
channel c2: reading from backup piece /databak/dadb/dadb_arc_1162890092_21507
channel c2: piece handle=/databak/dadb/dadb_arc_1162890092_21507 tag=DA_ARC_BAK
channel c2: restored backup piece 1
channel c2: restore complete, elapsed time: 00:00:15
channel c2: starting archived log restore to user-specified destination
archived log destination=/oradata/arch/
channel c2: restoring archived log
archived log thread=1 sequence=36192
channel c2: reading from backup piece /databak/dadb/dadb_arc_1162890107_21508
channel c1: piece handle=/databak/dadb/dadb_arc_1162890092_21506 tag=DA_ARC_BAK
channel c1: restored backup piece 1
channel c1: restore complete, elapsed time: 00:00:16
channel c2: piece handle=/databak/dadb/dadb_arc_1162890107_21508 tag=DA_ARC_BAK
channel c2: restored backup piece 1
channel c2: restore complete, elapsed time: 00:00:01
Finished restore at 06-MAR-24

Starting restore at 06-MAR-24

channel c1: starting archived log restore to user-specified destination
archived log destination=/oradata/arch/
channel c1: restoring archived log
archived log thread=2 sequence=27786
channel c1: restoring archived log
archived log thread=2 sequence=27787
channel c1: restoring archived log
archived log thread=2 sequence=27788
channel c1: restoring archived log
archived log thread=2 sequence=27789
channel c1: restoring archived log
archived log thread=2 sequence=27790
channel c1: restoring archived log
archived log thread=2 sequence=27791
channel c1: reading from backup piece /databak/dadb/dadb_arc_1162890092_21506
channel c2: starting archived log restore to user-specified destination
archived log destination=/oradata/arch/
channel c2: restoring archived log
archived log thread=2 sequence=27792
channel c2: restoring archived log
archived log thread=2 sequence=27793
channel c2: restoring archived log
archived log thread=2 sequence=27794
channel c2: restoring archived log
archived log thread=2 sequence=27795
channel c2: restoring archived log
archived log thread=2 sequence=27796
channel c2: restoring archived log
archived log thread=2 sequence=27797
channel c2: restoring archived log
archived log thread=2 sequence=27798
channel c2: reading from backup piece /databak/dadb/dadb_arc_1162890092_21507
channel c2: piece handle=/databak/dadb/dadb_arc_1162890092_21507 tag=DA_ARC_BAK
channel c2: restored backup piece 1
channel c2: restore complete, elapsed time: 00:00:07
channel c2: starting archived log restore to user-specified destination
archived log destination=/oradata/arch/
channel c2: restoring archived log
archived log thread=2 sequence=27799
channel c2: reading from backup piece /databak/dadb/dadb_arc_1162890107_21508
channel c1: piece handle=/databak/dadb/dadb_arc_1162890092_21506 tag=DA_ARC_BAK
channel c1: restored backup piece 1
channel c1: restore complete, elapsed time: 00:00:09
channel c2: piece handle=/databak/dadb/dadb_arc_1162890107_21508 tag=DA_ARC_BAK
channel c2: restored backup piece 1
channel c2: restore complete, elapsed time: 00:00:01
Finished restore at 06-MAR-24

released channel: c1

released channel: c2

13.执行恢复操作

RMAN> recover database;

Starting recover at 06-MAR-24
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=1700 device type=DISK

starting media recovery

archived log for thread 1 with sequence 36191 is already on disk as file /oradata/arch/1_36191_939387772.arch
archived log for thread 1 with sequence 36192 is already on disk as file /oradata/arch/1_36192_939387772.arch
archived log for thread 2 with sequence 27798 is already on disk as file /oradata/arch/2_27798_939387772.arch
archived log for thread 2 with sequence 27799 is already on disk as file /oradata/arch/2_27799_939387772.arch
archived log file name=/oradata/arch/1_36191_939387772.arch thread=1 sequence=36191
archived log file name=/oradata/arch/2_27798_939387772.arch thread=2 sequence=27798
archived log file name=/oradata/arch/2_27799_939387772.arch thread=2 sequence=27799
archived log file name=/oradata/arch/1_36192_939387772.arch thread=1 sequence=36192
unable to find archived log
archived log thread=1 sequence=36193
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 03/06/2024 12:21:52
RMAN-06054: media recovery requesting unknown archived log for thread 1 with sequence 36193 and starting SCN of 18518339722150

上面提示需要日志序号为36193的归档日志文件,因为我的备份只备到日志序号为36192的归档日志。

RMAN> list backup;


List of Backup Sets
===================


BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
21345   Full    85.42M     DISK        00:00:00     06-MAR-24
        BP Key: 21346   Status: AVAILABLE  Compressed: NO  Tag: DA_CONTROL_BAK
        Piece Name: /databak/dadb/dadb_cntrl_21509_1_21509
  Control File Included: Ckp SCN: 18518339722264   Ckp time: 06-MAR-24

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
21346   Full    5.66G      DISK        00:00:00     06-MAR-24
        BP Key: 21347   Status: AVAILABLE  Compressed: YES  Tag: DA_FULL_BAK
        Piece Name: /databak/dadb/dadb_DADB_20240306_vu2l0hog_1_1
  List of Datafiles in backup set 21346
  File LV Type Ckp SCN    Ckp Time  Name
  ---- -- ---- ---------- --------- ----
  2       Full 18518339718516 06-MAR-24 /oradata/dadb/sysaux01.dbf
  4       Full 18518339718516 06-MAR-24 /oradata/dadb/users.dbf
  6       Full 18518339718516 06-MAR-24 /oradata/dadb/hygeia.dbf
  7       Full 18518339718516 06-MAR-24 /oradata/dadb/system001.dbf
  10      Full 18518339718516 06-MAR-24 /oradata/dadb/test.dbf

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
21347   Full    5.20M      DISK        00:00:00     06-MAR-24
        BP Key: 21348   Status: AVAILABLE  Compressed: YES  Tag: DA_FULL_BAK
        Piece Name: /databak/dadb/dadb_DADB_20240306_002l0ijr_1_1
  Control File Included: Ckp SCN: 18518339720451   Ckp time: 06-MAR-24

BS Key  Size       Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
21348   970.06M    DISK        00:00:00     06-MAR-24
        BP Key: 21349   Status: AVAILABLE  Compressed: NO  Tag: DA_ARC_BAK
        Piece Name: /databak/dadb/dadb_arc_1162890092_21506

  List of Archived Logs in backup set 21348
  Thrd Seq     Low SCN    Low Time  Next SCN   Next Time
  ---- ------- ---------- --------- ---------- ---------
  1    36171   18518338674292 02-MAR-24 18518338689793 02-MAR-24
  1    36172   18518338689793 02-MAR-24 18518338799839 03-MAR-24
  1    36173   18518338799839 03-MAR-24 18518338813263 03-MAR-24
  1    36174   18518338813263 03-MAR-24 18518338884449 03-MAR-24
  1    36175   18518338884449 03-MAR-24 18518338974024 03-MAR-24
  1    36176   18518338974024 03-MAR-24 18518338974039 03-MAR-24
  1    36177   18518338974039 03-MAR-24 18518338993139 03-MAR-24
  1    36178   18518338993139 03-MAR-24 18518339079673 04-MAR-24
  1    36179   18518339079673 04-MAR-24 18518339088612 04-MAR-24
  1    36180   18518339088612 04-MAR-24 18518339193641 04-MAR-24
  2    27786   18518338674296 02-MAR-24 18518338813706 03-MAR-24
  2    27787   18518338813706 03-MAR-24 18518338929221 03-MAR-24
  2    27788   18518338929221 03-MAR-24 18518338974028 03-MAR-24
  2    27789   18518338974028 03-MAR-24 18518338974042 03-MAR-24
  2    27790   18518338974042 03-MAR-24 18518339090540 04-MAR-24
  2    27791   18518339090540 04-MAR-24 18518339290871 04-MAR-24

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
21349   Full    80.00K     DISK        00:00:00     06-MAR-24
        BP Key: 21350   Status: AVAILABLE  Compressed: YES  Tag: DA_FULL_BAK
        Piece Name: /databak/dadb/dadb_DADB_20240306_012l0ijv_1_1
  SPFILE Included: Modification time: 05-MAR-24
  SPFILE db_unique_name: DADBP

BS Key  Size       Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
21350   854.23M    DISK        00:00:00     06-MAR-24
        BP Key: 21351   Status: AVAILABLE  Compressed: NO  Tag: DA_ARC_BAK
        Piece Name: /databak/dadb/dadb_arc_1162890092_21507

  List of Archived Logs in backup set 21350
  Thrd Seq     Low SCN    Low Time  Next SCN   Next Time
  ---- ------- ---------- --------- ---------- ---------
  1    36181   18518339193641 04-MAR-24 18518339290866 04-MAR-24
  1    36182   18518339290866 04-MAR-24 18518339290887 04-MAR-24
  1    36183   18518339290887 04-MAR-24 18518339307311 04-MAR-24
  1    36184   18518339307311 04-MAR-24 18518339398770 05-MAR-24
  1    36185   18518339398770 05-MAR-24 18518339409567 05-MAR-24
  1    36186   18518339409567 05-MAR-24 18518339534019 05-MAR-24
  1    36187   18518339534019 05-MAR-24 18518339592978 05-MAR-24
  1    36188   18518339592978 05-MAR-24 18518339593000 05-MAR-24
  1    36189   18518339593000 05-MAR-24 18518339609217 05-MAR-24
  1    36190   18518339609217 05-MAR-24 18518339708119 06-MAR-24
  1    36191   18518339708119 06-MAR-24 18518339722138 06-MAR-24
  2    27792   18518339290871 04-MAR-24 18518339290882 04-MAR-24
  2    27793   18518339290882 04-MAR-24 18518339398968 05-MAR-24
  2    27794   18518339398968 05-MAR-24 18518339548475 05-MAR-24
  2    27795   18518339548475 05-MAR-24 18518339592982 05-MAR-24
  2    27796   18518339592982 05-MAR-24 18518339592995 05-MAR-24
  2    27797   18518339592995 05-MAR-24 18518339709370 06-MAR-24
  2    27798   18518339709370 06-MAR-24 18518339722134 06-MAR-24

BS Key  Size       Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
21351   19.50K     DISK        00:00:00     06-MAR-24
        BP Key: 21352   Status: AVAILABLE  Compressed: NO  Tag: DA_ARC_BAK
        Piece Name: /databak/dadb/dadb_arc_1162890107_21508

  List of Archived Logs in backup set 21351
  Thrd Seq     Low SCN    Low Time  Next SCN   Next Time
  ---- ------- ---------- --------- ---------- ---------
  1    36192   18518339722138 06-MAR-24 18518339722150 06-MAR-24
  2    27799   18518339722134 06-MAR-24 18518339722196 06-MAR-24

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
21352   Full    4.52G      DISK        00:00:00     06-MAR-24
        BP Key: 21353   Status: AVAILABLE  Compressed: YES  Tag: DA_FULL_BAK
        Piece Name: /databak/dadb/dadb_DADB_20240306_vv2l0hog_1_1
  List of Datafiles in backup set 21352
  File LV Type Ckp SCN    Ckp Time  Name
  ---- -- ---- ---------- --------- ----
  1       Full 18518339718518 06-MAR-24 /oradata/dadb/system.dbf
  3       Full 18518339718518 06-MAR-24 /oradata/dadb/undotbs1.dbf
  5       Full 18518339718518 06-MAR-24 /oradata/dadb/undotbs2.dbf
  8       Full 18518339718518 06-MAR-24 /oradata/dadb/sysaux.dbf
  9       Full 18518339718518 06-MAR-24 /oradata/dadb/cs01.dbf

执行按时间点或scn号的恢复操作。因为日志序号为36193的归档日志文件的scn号是从18518339722150开始,所以我们可以执行恢复到scn号=18518339722150为止。

RMAN> recover database until scn 18518339722150;

Starting recover at 06-MAR-24
using channel ORA_DISK_1

starting media recovery
media recovery complete, elapsed time: 00:00:01

Finished recover at 06-MAR-24

14.打开数据库。

RMAN> alter database open resetlogs;

database opened

[oracle@sjjh oradata]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Wed Mar 6 12:25:01 2024

Copyright (c) 1982, 2013, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options


SQL> select instance_name,status from v$instance;

INSTANCE_NAME    STATUS
---------------- ------------
dadb             OPEN
]]> http://www.jydba.net/index.php/archives/3553/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
Oracle 18c 使用影子表空间来管理丢失写保护 http://www.jydba.net/index.php/archives/3517 http://www.jydba.net/index.php/archives/3517#respond Fri, 24 Nov 2023 00:28:36 +0000 http://www.jydba.net/?p=3517 使用影子表空间来管理丢失写保护

当I/O子系统确认块写入已完成,但在持久存储中没有发生写入时,就会发生数据块丢失写入。影子丢失写保护可以防止丢失写。
.关于影子丢失写保护
当I/O子系统确认块写入的完成,即使没有发生写入,或者当块的前一个镜像覆盖了当前的镜像时,就会发生数据块丢失写. 影子丢失写保护可以防止表空间或单个数据文件的丢失写。

.为影子丢失写保护创建影子表空间
为了给影子丢失写保护创建一个影子表空间,在执行create big file tablespace语句时使用lost write protection子句。

.对数据库启用影子丢失写保护
为了对一个多租户容器数据库(CDB)或一个非CDB启用影子丢人写保护,可以执行带有enable lost write protection子句的alter database语句。为了对一个PDB启用影子丢失写失保护,可以执行带有enable lost write protection子句的alter pluggable database语句。

.对表空间和数据文件启用影子丢失写保护
可以对表空间和数据文件启用影子丢失写保护

.对数据库禁用影子丢失写保护
为了对CDB或非CDB数据库禁用影子丢失写保护,执行带有disable lost write protection子句的alter database语句。为了对一个pdb禁用丢失写保护,执行带有disable lost write protection子句的alter pluggable database语句。

.删除或暂停影子丢失写保护
可以对表空间或数据文件删除或暂停影子丢失写保护

.删除影子表空间
可以执行drop tablespace语句来删除影子表空间。如果使用带有including contents子句的drop tablespace语句,那么影子表空间连同它的内容会一起被删除。如果使用不带including contents子句的drop tablespace语句,那么在删除影子表空间之前,影子表空间的内容在存在其它影子表空间且有足够的可用空间时会被移动到其它的影子表空间中。

关于影子丢失写保护
当I/O子系统确认块写入的完成,即使没有发生写入,或者当块的前一个镜像覆盖了当前的镜像时,就会发生数据块丢失写操作。影子丢失写保护可以防止表空间或数据文件发生丢失写。

影子丢失写保护对于丢失写提供了一种快速检测和立即响应的方法。使用影子丢失写保护可以最小化数据丢失和请求修复数据库所需要的时间。

为了使用影子丢失写保护,你必须对数据库启用并创建一个或多个影子表空间。一个影子表空间是一种特殊目的的大文件表空间它只包含跟踪数据文件的系统改变号(SCNs)。可以通过使用带有lost write protection子句的create tablespace语句来创建一个影子表空间。

当一个被跟踪的数据块从磁盘被读取时,影子丢失写保护通过比较在影子表空间中数据块的SCN与将被读取的数据块最近写入的SCN来检测是否发生了丢失写。如果影子条目的SCN大于被读数据块的SCN,那么发生了丢失写。当检测到丢失写时会返回一个错误。

未检测到的丢失写可能会造成数据损坏因为不正确的数据可能被用于其它的DML事务。影子丢失写保护在使用之前检测到丢失写,以防止数据损坏。可以对特定的表空间和数据文件启用影子丢失写保护。因此,可以对你最重要的数据启用它。你不必使用它来跟踪你的所有数据。

此外,影子表空间也是灵活的。您可以将一个影子表空间替换为另一个影子表空间,以更改其配置或位置。

当影子丢失写保护被启用后,可以对正常的DML操作和SQL*Loader常规路径加载和直接路径加载启用。也可以对RMAN备份启用。RMAN备份检查正在读取的块是否丢失写,如果找到这样的块,会引发错误。

在对表空间或数据文件启用影子丢失写保护之后,如果你想停止收集新的丢失写保护信息并检测丢失写可以暂停它。当影子丢失写保护被暂停之后,跟踪数据会被保存在影子表空间中,并且可以重新启用影子丢失写保护。如果对数据文件或表空间删除影子丢失写保护,那么它的跟踪数据会被删除并且不能重新使用。

可以通过执行带有lost write protection子句的alter tablespace语句来对表空间启用影子丢失写保护,执行带有lost write protection子句的alter database data_file_name语句来对数据文件启用影子丢失写保护。当对表空间启用影子丢失写保护后,表空间的所有当前和以后的数据文件都会启用影子丢失写保护。

Oracle数据库会自动对一个特定的影子表空间指派一个跟踪数据文件。你不能指定那个影子表空间使用某个特定的数据文件。影子表空间中的空间量应该至少为启用影子丢失写保护的数据文件所使用的空间的2%。

注意:
如果增加跟踪数据文件的大小,那么影子丢失写保护将试图重置影子表空间中的跟踪数据。如果没有足够的空间来跟踪所有数据,那么影子丢失写保护会向日志文件插入一条告警信息并使用它所能使用的影子空间来跟踪数据。

数据库闪回会造成任何影子丢失写保护数据被删除。在闪回之后,影子丢失写保护在重新填充时跟踪数据,并在块更新时对影子跟踪数据进行更新。

影子丢失写保护与使用DB_LOST_WRITE_PROTECT初始化参数和备用数据库配置的丢失写保护无关。

为影子丢失写保护创建影子表空间
可以使用带有lost write protection子句的create bigfile tablespace语句来为影子丢失写保护创建一个影子表空间。

一个影子表空间可以被任何启用影子丢失写保护的表空间或数据文件所使用。影子表空间的空间量至少是那些启用影子丢失写保护的数据文件大小的2%.

为了创建影子表空间,数据库的兼容级别必须至少为18.0.0或更高版本。

例如创建一个名为shadow_lwp1的影子表空间供影子丢失写保护使用

SQL> CREATE BIGFILE TABLESPACE shadow_lwp1 DATAFILE 'shadow_lwp1.df' SIZE 10M LOST WRITE PROTECTION;

Tablespace created.

对数据库启用影子丢失写保护
为了对一个CDB或非CDB启用影子丢失写保护,执行带有enable lost write protection子句的alter database语句。为了对pdb启用影子丢失写保护执行带有enable lost write protection子句的alter pluggable database语句。

在对单个表空间和数据文件启用影子丢失写保护之前,你必须至少创建一个影子表空间,并且必须对包含它的数据库启用影子丢失写保护。在执行这些配置后,可以通过执行alter tablespace语句来对表空间启用影子丢失写保护,并且可以通过执行alter database语句来为数据文件启用影子丢失写保护。

注意:
对数据库启用影子丢失写保护,那么数据库的兼容级别至少为18.0.0或更高版本,并且至少存在一个影子表空间。

对CDB root启用或禁用影子丢失写保护不影响PDBs的影子丢失写保护。因此即使对CDB root禁用了影子丢失写保护也还是能对PDB启用影子丢失写保护。

当对数据库启用影子丢失写保护时,会自动指派一个影子表空间供其使用。

对数据库启用影子丢失写保护操作如下:
1.通过SQL*Plus,使用有要求的权限的用户进行登录:
.对于非CDB或CDB root使用有alter database系统权限的用户进行登录。

.对于应用程序root,PDB或应用程序PDB,使用有alter pluggable database系统权限的用户进行登录。

2.执行以下操作:
.对于非CDB或CDB root,执行带有enable lost write protection子句的alter database语句。

.对于应用程序root,PDB或应用程序PDB,执行带有enable lost write protection子句的alter pluggable database语句。

对非CDB或CDB root启用影子丢失写保护

SQL> alter database enable lost write protection;

Database altered.

对PDB启用影子丢失写保护

SQL> create bigfile tablespace shadow_pdb datafile 'shadow_pdb.dbf' size 10M lost write protection;

Tablespace created.

SQL> alter pluggable database enable lost write protection;

Pluggable database altered.

对表空间和数据文件启用影子丢失写保护
为了对表空间启用影子丢失写保护,执行带有enable lost write protection子句的alter tablespace语句。为了对数据文件启用影子丢失写保护执行带有enable lost write protection子句的alter database data_file_name语句。当对一个表空间启用了影子丢失写保护,那么就是对表空间的所有数据文件启用了影子丢失写保护,并且对于向表空间增加的任何数据文件也会启用影子丢失写保护。

注意:
.为了对一个表空间或数据文件启用影子丢失写保护那么数据库中必须至少存在一个影子表空间。
.当对一个表空间或数据文件启用影子丢失写保护,那么这个影子表空间会自动被分配给它。

为了对一个表空间或数据文件启用影子丢失写保护必须满足以下条件:
1.在SQL*Plus中,使用有以下权限的用户来连接数据库:
.如果计划对一个表空间启用影子丢失写保护,那么连接用户必须有alter tablespace权限。

.如果计划对非CDB或CDB root中的数据文件启用影子丢失写保护,那么连接用户必须有alter database权限。

.如果计划对一个应用程序root,PDB或应用程序PDB中的数据文件启用影子丢失写保护,那么连接用户必须有alter pluggable database权限。

2.执行以下操作来启用影子丢失写保护:
.为了对一个表空间启用影子丢失写保护,执行带有enable lost write protection子句的alter tablespace语句。

.为了对非CDB或CDB root中的数据文件启用影子丢失写保护,执行带有enable lost write protection子句的alter database data_file_name语句。

.为了对一个应用程序root,PDB或应用程序PDB中的数据文件启用影子丢失写保护,执行带有enable lost write protection子句的alter pluggable database datafile data_file_name语句。

创建一个test表空间并启用影子丢失写保护:

SQL> create tablespace test datafile 'test01.dbf' size 10M;

Tablespace created.


SQL> alter tablespace test enable lost write protection;

Tablespace altered.

对非CDB或CDB root中的数据文件启用影子丢失写保护

SQL> create tablespace test1 datafile 'test1_01.dbf' size 10M;

Tablespace created.

SQL> alter tablespace test1 add datafile 'test1_02.dbf' size 10M;

Tablespace altered.

SQL> alter database datafile 'test1_01.dbf' enable lost write protection;

Database altered.

对一个应用程序root,PDB或应用程序PDB中的数据文件启用影子丢失写保护

SQL> alter session set container=hypdb;

Session altered.

SQL> create tablespace cs datafile 'cs01.dbf' size 10M;

Tablespace created.

SQL> alter pluggable database datafile 'cs01.dbf' enable lost write protection;

Pluggable database altered.

对数据库禁用影子丢失写保护
为了对CDB或非CDB禁用影子丢失写保护,执行带有disable lost write protection子句的alter database语句。为了对PDB禁用影子丢失写保护,执行带有disable lost write protection子句的alter pluggable database语句。

当你对一个数据库禁用影子丢失写保护后,不是这个数据库中的表空间或数据文件可以被影子丢失写保护。

注意:
.禁用影子丢失写保护不会删除现有影子表空间中的数据,但表空间中的数据不再被更新或被检查。如果想删除影子表空间中的数据,那么可以使用带有including contents子句的drop tablespace语句。

.对CDB root启用或禁用影子丢失写保护不会影响PDBs的影子丢失写保护。

为了对一个数据库禁用影子丢失写保护必须满足以下条件:
1.在SQL*Plus中,使用有以下权限的用户来连接数据库:
.在非CDB或CDB root中,那么连接用户必须有alter tablespace权限。

.在应用程序root,PDB或应用程序PDB中,那么连接用户必须有alter pluggable database权限。

2.执行以下操作来启用影子丢失写保护:
.对非CDB或CDB root,执行带有disable lost write protection子句的alter database语句。

.对应用程序root,PDB或应用程序PDB,执行带有disable lost write protection子句的alter pluggable database语句。

对非CDB或CDB root禁用影子丢失写保护

SQL> alter session set container=cdb$root;

Session altered.


SQL> alter database disable lost write protection;

Database altered.

对PDB禁用影子丢失写保护

SQL> alter session set container=hypdb;

Session altered.

SQL> alter pluggable database disable lost write protection;

Pluggable database altered.

删除或暂停影子丢失写保护
可以对表空间或数据文件删了或暂停影子丢失写保护。

当表空间或数据文件不再需要影子丢失写保护,可以选对以下操作:
.可以删除影子丢失写保护。这个操作会从影子表空间中删除表空间或数据文件的跟踪信息。这个选项也会停止对表空间或数据文件收集新的写丢失信息并且对他们的新丢失写停止检查。

.也可以暂停影子丢失写保护。停止对表空间或数据文件收集新的写丢失信息并且对他们的新丢失写停止检查。然而旧的丢失写信息仍然保留在影子表空间中。如果对表空间或数据文件重新启用影子丢失写保护,那么它们可以使用旧的丢失写信息。

当对表空间删除或暂停影子丢失写保护后,会删除影子丢失写保护或对表空间中的所有数据文件暂停影子丢失写保护。

为了对一个表空间或数据文件删除或暂停影子丢失写保护必须满足以下条件:
1.在SQL*Plus中,使用有以下权限的用户来连接数据库:
.如果计划对一个表空间删了或禁用影子丢失写保护,那么连接用户必须有alter tablespace权限。

.如果计划对非CDB或CDB root中的数据文件删除或禁用影子丢失写保护,那么连接用户必须有alter database权限。

.如果计划对一个应用程序root,PDB或应用程序PDB中的数据文件删除或禁用影子丢失写保护,那么连接用户必须有alter pluggable database权限。

2.执行以下操作来启用影子丢失写保护:
.为了对一个表空间删除或禁用影子丢失写保护,执行带有enable lost write protection或suspend lost write protection子句的alter tablespace语句。

.为了对非CDB或CDB root中的数据文件删除或禁用影子丢失写保护,执行带有enable lost write protection或suspend lost write protection 子句的alter database data_file_name语句。

.为了对一个应用程序root,PDB或应用程序PDB中的数据文件删除或禁用影子丢失写保护,执行带有enable lost write protection或suspend lost write protection子句的alter pluggable database datafile data_file_name语句。

删了表空间test的影子丢失写保护

SQL> alter session set container=cdb$root;

Session altered.

SQL> alter tablespace test remove lost write protection;

Tablespace altered.

暂停对数据文件test1_01.dbf的影子丢失写保护

SQL> alter database datafile 'test1_01.dbf' suspend lost write protection;

Database altered.

对PDB中的数据文件cs01.dbf暂停影子丢失写保护

SQL> alter session set container=hypdb;

Session altered.

SQL> alter pluggable database datafile 'cs01.dbf' suspend lost write protection;

Pluggable database altered.

删除影子表空间
可以执行drop tablespace语句来删除影子表空间。如果执行带有including contents子句的drop tablespace语句,那么在删除影子表空间的同时也会删除它的内容和数据文件。如果执行没带inclding contents子句的drop tablespace语句,那么在删除影子表空间之前,如果存在其它的影子表空间且有足够空间,它的内容会被移到另一个影子表空间中。

SQL> drop tablespace shadow_pdb including contents;

Tablespace dropped.
]]>
http://www.jydba.net/index.php/archives/3517/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/3504 http://www.jydba.net/index.php/archives/3504#respond Fri, 01 Sep 2023 03:21:17 +0000 http://www.jydba.net/?p=3504 InnoDB文件格式管理
随着InnoDB的发展,数据文件格式有时需要与以前版本的InnoDB不兼容,以支持新特性。为了在升级和降级的情况下管理兼容性,以及运行不同版本MySQL的系统,InnoDB使用命名文件格式。InnoDB目前支持两种命名文件格式,Antelope和Barracuda。

.Antelope是原始的InnoDB文件格式,以前没有一个名字。它支持紧凑和冗余的InnoDB表行格式。

.Barracuda是最新的文件格式。它支持所有InnoDB行格式,包括较新的compressed和dynamic行格式。与compressed和dynamic行格式相关的特性包括压缩表、页外列的高效存储以及高达3072字节的索引键前缀(innodb_large_prefix)。

这将讨论为新的InnoDB表启用InnoDB文件格式,验证MySQL版本之间不同文件格式的兼容性,以及识别正在使用的文件格式。

InnoDB文件格式设置不适用于存储在一般表空间中的表。通用表空间提供对所有行格式和相关特性的支持。

以下文件格式配置参数有新的默认值:
.innodb_file_format默认值修改为Barracuda。之前的默认值是Antelope。

.innodb_large_prefix默认值修改为ON。之前的默认值是OFF。

以下文件格式配置参数已弃用,并可能在将来的版本中删除:
.innodb_file_format

.innodb_file_format_check

.innodb_file_format_max

.innodb_large_prefix

文件格式配置参数用于创建与MySQL 5.1中早期版本的InnoDB兼容的表。现在MySQL 5.1已经结束了它的产品生命周期,不再需要这些参数。

启用文件格式
innodb_file_format配置选项为file-per-table表空间启用一个InnoDB文件格式。

Barracuda是默认的innodb_file_format设置。在早期版本中,默认的文件格式是Antelope。

innodb_file_format配置选项已弃用,可能在将来的版本中被删除。

当你启动mysqld时,你可以在命令行中设置innodb_file_format的值,或者在选项文件中(Unix上是my.cnf, Windows上是my.ini)。你也可以使用SET GLOBAL语句动态地修改它。

SET GLOBAL innodb_file_format=Barracuda;

使用说明
.InnoDB文件格式设置不适用于存储在一般表空间中的表。通用表空间提供对所有行格式和相关特性的支持。

.当使用CREATE table或ALTER table的TABLESPACE [=] innodb_system 表选项在system表空间中存储动态表时,innodb_file_format设置不适用。

.在创建使用动态行格式的表时,innodb_file_format设置会被忽略。

验证文件格式兼容性
InnoDB包含了一些检查来防止可能发生的崩溃和数据损坏,如果你对运行在旧版本的MySQL服务器上的InnoDB数据文件使用新文件格式可能会发生。这些检查发生在服务器启动时,以及用户第一次访问表时。本节描述这些检查,如何控制它们,以及可能出现的错误和警告条件。

向后兼容性
你只需要在使用最新版本的InnoDB (InnoDB的MySQL 5.5或更高版本)和旧版本(MySQL 5.1或更早版本,内置InnoDB而不是InnoDB插件)时考虑向后的文件格式兼容性。为了尽量减少兼容性问题,你可以在所有MySQL 5.1和更早版本的数据库服务器上使用InnoDB插件进行标准化。

一般来说,新版本的InnoDB创建的表或索引在旧版本的InnoDB中无法安全地读取或写入,而不会有崩溃、挂起、错误结果或损坏的风险。InnoDB提供了一种机制来防范这些情况,并有助于保持数据库文件和InnoDB版本之间的兼容性。这种机制可以让你利用InnoDB版本的一些新特性(如性能改进和bug修复),同时通过防止意外使用创建向下不兼容的磁盘文件的新特性,仍然保留使用旧版本InnoDB数据库的选择。

如果某个版本的InnoDB支持一种特定的文件格式(不管这种格式是否是默认的),你就可以查询和更新任何需要这种格式或更早的格式的表。根据所启用的特定文件格式,只有使用新特性创建新表的操作受到限制。相反,如果表空间包含一个使用不支持的文件格式的表或索引,则根本无法访问它,即使是读访问。

将InnoDB表空间“降级”为早期的Antelope文件格式的唯一方法是将数据复制到使用早期格式的新表中。

确定一个已经存在的InnoDB表空间的文件格式最简单的方法是检查它所包含的表的属性,使用SHOW table STATUS命令或者查询表INFORMATION_SCHEMA.TABLES。如果表的Row_format被报告为’Compressed’或’Dynamic’,则包含该表的表空间支持Barracuda格式。

内部细节
每个InnoDB file-per-table表空间(由一个*.ibd文件)文件标记了文件格式标识符。system表空间(由ibdata文件表示)被标记为在一组InnoDB数据库文件中使用的“最高”文件格式,并且当文件被打开时检查这个标记。

创建一个压缩表,或者一个带有ROW_FORMAT=DYNAMIC的表,更新对应file-per-table .ibd文件的文件头和InnoDB数据字典中的表类型,其中包含Barracuda文件格式的标识符。从那以后,这个表就不能在不支持Barracuda文件格式的InnoDB版本中使用了。为了防止异常行为,InnoDB会在打开表时进行兼容性检查。(在很多情况下,ALTER TABLE语句会重新创建一个表,从而改变它的属性。)

一般的表空间,也用*.ibd文件表示,支持Antelope和Barracuda文件格式。

ib文件集的定义
为了避免混淆,为了讨论的目的,我们将术语“ib文件集”定义为InnoDB作为一个单元管理的操作系统文件集。ib文件集合包括以下文件:

.系统表空间(一个或多个ibdata文件),包含内部系统信息(包括内部目录和undo信息),可能包括用户数据和索引。

.零个或多个单表表空间(也称为“file per table”文件,命名为*.ibd文件)。

.InnoDB日志文件;通常有两个,ib_logfile0和ib_logfile1。用于崩溃恢复和备份。

“ib文件集”不包含包含InnoDB表元数据的对应的.frm文件。.frm文件由MySQL创建和管理,有时会与InnoDB中的内部元数据不同步。

多个表(甚至来自多个数据库)可以存储在一个“ib文件集”中。(在MySQL中,“数据库”是表的逻辑集合,其他系统称之为“模式”或“目录”。)

InnoDB启动时的兼容性检查
当InnoDB打开ib文件集时,为了防止可能的崩溃或数据损坏,它会检查是否完全支持ib文件集中正在使用的文件格式。如果系统在崩溃后重新启动,或者“快速关机”(即innodb_fast_shutdown大于零),磁盘上的数据结构(如redo或undo条目,或doublewrite页面)可能对当前软件来说是“太新的”格式。在恢复过程中,如果访问了这些数据结构,可能会对数据文件造成严重的破坏。文件格式的启动检查在任何恢复过程开始之前进行,从而防止新表的一致性问题或MySQL服务器的启动问题。

从版本InnoDB 1.0.1开始,system表空间记录了ib文件集中任何表空间中任何表使用的“最高”文件格式的标识符或标记。这个文件格式标签的检查由配置参数innodb_file_format_check控制,默认是开启的。

如果system表空间中的文件格式标签比当前执行的软件支持的最高版本更新或更高,并且innodb_file_format_check开启,则在服务器启动时会发出以下错误:

InnoDB: Error: the system tablespace is in a
file format that this version doesn't support

mysql> show variables like 'innodb_file_format_check';
+--------------------------+-------+
| Variable_name            | Value |
+--------------------------+-------+
| innodb_file_format_check | ON    |
+--------------------------+-------+
1 row in set (0.01 sec)

mysql> show variables like 'innodb_file_format';
+--------------------+-----------+
| Variable_name      | Value     |
+--------------------+-----------+
| innodb_file_format | Barracuda |
+--------------------+-----------+
1 row in set (0.02 sec)

也可以设置“innodb_file_format”为文件格式名称。如果当前软件不支持指定的文件格式,这样做可以防止InnoDB启动。它还将“高水位标记”设置为指定的值。如果你手动“降级”ib文件集中的所有表,那么设置innodb_file_format_check的能力(在未来的版本中)是很有用的。如果你随后使用旧版本的InnoDB来访问ib文件集,那么你可以依赖启动时的文件格式检查。

在某些有限的情况下,您可能希望启动服务器并使用ib文件集,该文件集是您正在使用的软件不支持的新文件格式。如果你把配置参数innodb_file_format_check设置为OFF, InnoDB会打开数据库,但会在错误日志中显示如下警告信息:

InnoDB: Warning: the system tablespace is in a
file format that this version doesn't support

这是一个危险的设置,因为它允许恢复过程运行,如果之前的关闭是崩溃或“快速关闭”,可能会破坏数据库。

只有当你确定上一次关闭innodb_fast_shutdown=0时,才应该将innodb_file_format_check设置为OFF,这样基本上没有恢复过程发生。

参数innodb_file_format_check只影响打开数据库时发生的操作,不会影响后续操作。相反,参数innodb_file_format(启用特定的格式)只确定是否可以以启用的格式创建新表,对数据库是否可以打开没有影响。

文件格式标记是一个“高水位标记”,如果创建了一个“更高”格式的表,或者访问一个现有的表进行读或写(假设支持它的格式),那么在服务器启动后,它就会增加。如果你以高于运行软件支持的格式访问一个已经存在的表,系统表空间标签不会更新,但是表级别的兼容性检查会应用(并且会发出错误),如14.10.2.2节“打开表时兼容性检查”所述。每当高水位线更新时,innodb_file_format_check的值也会更新,因此执行SELECT @@innodb_file_format_check;显示当前打开的ib文件集中的表使用的、当前执行软件支持的最新文件格式的名称。

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

打开表时检查兼容性
当第一次访问表时,InnoDB(包括一些InnoDB 1.0之前的版本)会检查存储表的表空间的文件格式是否完全支持。这种检查可以防止使用“太新”数据结构的表出现崩溃或损坏。

使用某个版本支持的任何文件格式的所有表都可以读或写(假设用户有足够的权限)。设置系统配置参数innodb_file_format可以防止创建使用特定文件格式的新表,即使给定的版本支持这种文件格式。这样的设置可以用来保持向后兼容性,但它不会阻止访问任何使用支持的格式的表。

如果在创建表时使用了新的文件格式,那么5.0.21之前的MySQL版本不能可靠地使用新版本创建的数据库文件。为了防止各种错误或损坏,InnoDB在打开文件时(例如,第一次访问一张表时)会检查文件格式的兼容性。如果当前运行的InnoDB版本不支持InnoDB数据字典中表类型标识的文件格式,MySQL报告如下错误:

ERROR 1146 (42S02): Table 'test.t1' doesn't exist

InnoDB也会在错误日志中写入一条消息:

InnoDB: table test/t1: unknown table type 33

MySQL 4.1之前的InnoDB版本在数据库文件中不包含表格式标识符,MySQL 5.0.21之前的版本不包含表格式兼容性检查。因此,如果在5.0.21之前的InnoDB版本中使用了较新的文件格式的表,则无法确保操作是正确的。

InnoDB 1.0及更高版本的文件格式管理能力(表空间标记和运行时检查)允许InnoDB尽快验证运行版本的软件能够正确处理数据库中存在的表。

如果你允许InnoDB打开一个包含它不支持的文件格式的数据库(通过设置参数innodb_file_format_check为OFF),本节描述的表级检查仍然适用。

在使用InnoDB插件的MySQL 5.1之前的版本中强烈建议用户不要使用包含Barracuda文件格式表的数据库文件。可以使用Antelope格式重建这样的表。

识别正在使用的文件格式
如果您使用innodb_file_format配置选项启用不同的文件格式,则更改仅适用于新创建的表。此外,当您创建一个新表时,包含该表的表空间被标记为支持表特性所需的“最早”或“最简单”文件格式。例如,如果您启用了Barracuda文件格式,并创建了一个不使用Dynamic或Compressed行格式的新表,那么包含该表的新表空间将被标记为使用Antelope文件格式。

很容易识别给定表使用的文件格式。如果SHOW TABLE STATUS报告的行格式是Compact或Redundant,则表使用Antelope文件格式。如果SHOW TABLE STATUS报告的行格式是Compressed或Dynamic,则表使用Barracuda文件格式。


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 INFORMATION_SCHEMA表识别给定表或表空间使用的文件格式。例如:

mysql> SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES WHERE NAME='undo/big_table'\G
*************************** 1. row ***************************
     TABLE_ID: 488
         NAME: undo/big_table
         FLAG: 33
       N_COLS: 25
        SPACE: 487
  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_TABLESPACES WHERE NAME='undo/big_table'\G
*************************** 1. row ***************************
         SPACE: 487
          NAME: undo/big_table
          FLAG: 33
   FILE_FORMAT: Barracuda
    ROW_FORMAT: Dynamic
     PAGE_SIZE: 16384
 ZIP_PAGE_SIZE: 0
    SPACE_TYPE: Single
 FS_BLOCK_SIZE: 4096
     FILE_SIZE: 708837376
ALLOCATED_SIZE: 708841472
1 row in set (0.00 sec)

修改文件格式
每个InnoDB表空间文件(名称匹配*.ibd)都被标记为用于创建其表和索引的文件格式。修改文件格式的方法是重新创建表及其索引。重建表及其索引的最简单方法是在每个想要修改的表上使用以下命令:

ALTER TABLE t ROW_FORMAT=format_name;

如果您正在修改文件格式以降级到较旧的MySQL版本,则可能存在表存储格式的不兼容性,需要额外的步骤。

]]>
http://www.jydba.net/index.php/archives/3504/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
Oracle 19c IMP-00058 ORA-03113 http://www.jydba.net/index.php/archives/3482 http://www.jydba.net/index.php/archives/3482#respond Fri, 05 May 2023 00:26:06 +0000 http://www.jydba.net/?p=3482 用imp命令向Oracle 19c数据库导入数据时出现IMP-00058 ORA-03113错误

经过排查最后发现是因为执行imp命令的客户端机器内存不足引起的,在关闭无关的程序后再次执行可以正常导入。

]]>
http://www.jydba.net/index.php/archives/3482/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
Oracle Linux 7.1 通过systemctl将Weblogic设置为开机自启动 http://www.jydba.net/index.php/archives/3471 http://www.jydba.net/index.php/archives/3471#respond Fri, 31 Mar 2023 09:13:03 +0000 http://www.jydba.net/?p=3471 1 说明
设置开机自启动,需要用到systemctl工具。systemctl是一个systemd工具,主要负责控制systemd系统和服务管理器。systemd是一个系统管理守护进程、工具和库的集合,用于取代System V初始进程。Systemd的功能是用于集中管理和配置类UNIX系统。

2 准备
操作系统:Oracle Linux 7.1
systemctl –version : systemd 208
weblogic version:12.2.1.3.0
3 编写系统服务文件
3.1 adminserver 系统服务文件

[root@localhost system]# vi weblogic.service
[Unit]
Description=WebLogic Adminserver Service[Service]
[Service]
Type=simple
WorkingDirectory=/weblogic/Oracle/Middleware/user_projects/domains/base_domain
ExecStart=/weblogic/Oracle/Middleware/user_projects/domains/base_domain/bin/startWebLogic.sh
ExecStop=/weblogic/Oracle/Middleware/user_projects/domains/base_domain/bin/stopWebLogic.sh
User=weblogic
Group=weblogic
[Install]
WantedBy=multi-user.target

3.2 配置weblogic将日志输出到指定文件${DOMAIN_HOME}/admin.log,也就是在以下命令后面加上>”${DOMAIN_HOME}/admin.log” 2>&1

[weblogic@localhost bin]$ vi startWebLogic.sh
if [ "${WLS_REDIRECT_LOG}" = "" ] ; then
        echo "Starting WLS with line:"
        echo "${JAVA_HOME}/bin/java ${JAVA_VM} ${MEM_ARGS} ${LAUNCH_ARGS} -Dweblogic.Name=${SERVER_NAME} -Djava.security.policy=${WLS_POLICY_FILE} ${JAVA_OPTIONS} ${PROXY_SETTINGS} ${SERVER_CLASS}"
        ${JAVA_HOME}/bin/java ${JAVA_VM} ${MEM_ARGS} ${LAUNCH_ARGS} -Dweblogic.Name=${SERVER_NAME} -Djava.security.policy=${WLS_POLICY_FILE} ${JAVA_OPTIONS} ${PROXY_SETTINGS} ${SERVER_CLASS} >"${DOMAIN_HOME}/admin.log"  2>&1
else
        echo "Redirecting output from WLS window to ${WLS_REDIRECT_LOG}"
        ${JAVA_HOME}/bin/java ${JAVA_VM} ${MEM_ARGS} ${LAUNCH_ARGS} -Dweblogic.Name=${SERVER_NAME} -Djava.security.policy=${WLS_POLICY_FILE} ${JAVA_OPTIONS} ${PROXY_SETTINGS} ${SERVER_CLASS}  >"${DOMAIN_HOME}/admin.log"  2>&1

3.3 查看系统服务文件是否被识别

[root@localhost system]# systemctl list-unit-files|grep weblogic
weblogic.service                            disabled

3.4 禁用防火墙和SELinux
[root@localhost system]# setenforce 0
[root@localhost system]# sed -i "/^SELINUX=/s#enforcing#disabled#" /etc/selinux/config
[root@localhost system]# cat /etc/selinux/config

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of three two values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected.
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted
[root@localhost system]# systemctl is-enabled firewalld
enabled
[root@localhost system]# systemctl status firewalld
firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled)
   Active: active (running) since Fri 2023-03-31 14:11:15 CST; 1h 16min ago
 Main PID: 602 (firewalld)
   CGroup: /system.slice/firewalld.service
           └─602 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid

Mar 31 14:11:15 localhost.localdomain systemd[1]: Started firewalld - dynamic firewall daemon.
[root@localhost system]# systemctl stop firewalld
[root@localhost system]# systemctl disable firewalld
rm '/etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service'
rm '/etc/systemd/system/basic.target.wants/firewalld.service'
[root@localhost system]# systemctl is-enabled firewalld
disabled
[root@localhost system]# firewall-cmd --zone=public --list-ports
FirewallD is not running

4 测试系统服务
4.1 启动系统服务

[root@localhost system]# systemctl start weblogic.service

[root@localhost base_domain]# tail -f admin.log
<Mar 31, 2023 3:56:09 PM CST> <Info> <Security> <BEA-090905> <Disabling the CryptoJ JCE Provider self-integrity check for better startup performance. To enable this check, specify -Dweblogic.security.allowCryptoJDefaultJCEVerification=true.>
<Mar 31, 2023 3:56:09 PM CST> <Info> <Security> <BEA-090906> <Changing the default Random Number Generator in RSA CryptoJ from ECDRBG128 to HMACDRBG. To disable this change, specify -Dweblogic.security.allowCryptoJDefaultPRNG=true.>
<Mar 31, 2023 3:56:10 PM CST> <Info> <WebLogicServer> <BEA-000377> <Starting WebLogic Server with Java HotSpot(TM) 64-Bit Server VM Version 25.131-b11 from Oracle Corporation.>
<Mar 31, 2023 3:56:10 PM CST> <Info> <RCM> <BEA-2165021> <“ResourceManagement” is not enabled in this JVM. Enable “ResourceManagement” to use the WebLogic Server “Resource Consumption Management” feature. To enable “ResourceManagement”, you must specify the following JVM options in the WebLogic Server instance in which the JVM runs: -XX:+UnlockCommercialFeatures -XX:+ResourceManagement.>
<Mar 31, 2023 3:56:10 PM CST> <Info> <Management> <BEA-141107> <Version: WebLogic Server 12.2.1.3.0 Thu Aug 17 13:39:49 PDT 2017 1882952>
<Mar 31, 2023 3:59:53 PM CST> <Notice> <WebLogicServer> <BEA-000365> <Server state changed to STARTING.>
<Mar 31, 2023 3:59:53 PM CST> <Info> <WorkManager> <BEA-002900> <Initializing self-tuning thread pool.>
<Mar 31, 2023 3:59:53 PM CST> <Info> <WorkManager> <BEA-002942> <CMM memory level becomes 0. Setting standby thread pool size to 256.>
<Mar 31, 2023 4:01:39,810 PM CST> <Notice> <Log Management> <BEA-170019> <The server log file weblogic.logging.FileStreamHandler instance=460171696
Current log file=/weblogic/Oracle/Middleware/user_projects/domains/base_domain/servers/AdminServer/logs/AdminServer.log
Rotation dir=/weblogic/Oracle/Middleware/user_projects/domains/base_domain/servers/AdminServer/logs
is opened. All server side log events will be written to this file.>
<Mar 31, 2023 4:01:40,077 PM CST> <Notice> <Security> <BEA-090946> <Security pre-initializing using security realm: myrealm>
<Mar 31, 2023 4:01:40,771 PM CST> <Notice> <Security> <BEA-090947> <Security post-initializing using security realm: myrealm>
<Mar 31, 2023 4:01:41,826 PM CST> <Notice> <Security> <BEA-090082> <Security initialized using administrative security realm: myrealm>
<Mar 31, 2023 4:01:42,631 PM CST> <Notice> <JMX> <BEA-149512> <JMX Connector Server started at service:jmx:iiop://10.138.130.64:7001/jndi/weblogic.management.mbeanservers.runtime.>

4.2 停止系统服务

[root@localhost system]# systemctl stop weblogic.service

5 将服务设置成开机自启动

[root@localhost system]# systemctl enable weblogic.service
ln -s '/etc/systemd/system/weblogic.service' '/etc/systemd/system/multi-user.target.wants/weblogic.service'
[root@localhost system]# systemctl list-unit-files|grep weblogic
weblogic.service                            enabled

反向命令:

[root@localhost system]# systemctl disable weblogic.service
rm '/etc/systemd/system/multi-user.target.wants/weblogic.service'
[root@localhost system]# systemctl list-unit-files|grep weblogic
weblogic.service                            disabled

6 重启服务器并检查weblogic是否自启动

[root@localhost system]#reboot

[root@localhost ~]# ps -ef | grep java
weblogic   721     1  0 16:13 ?        00:00:01 /usr/java/jdk1.8.0_131/bin/java -Dderby.system.home=/weblogic/Oracle/Middleware/user_projects/domains/base_domain/common/db -classpath /weblogic/Oracle/Middleware/wlserver/common/derby/lib/derby.jar:/weblogic/Oracle/Middleware/wlserver/common/derby/lib/derbynet.jar:/weblogic/Oracle/Middleware/wlserver/common/derby/lib/derbytools.jar:/weblogic/Oracle/Middleware/wlserver/common/derby/lib/derbyclient.jar org.apache.derby.drda.NetworkServerControl start
weblogic   722   645  6 16:13 ?        00:01:07 /usr/java/jdk1.8.0_131/bin/java -server -Xms256m -Xmx512m -XX:CompileThreshold=8000 -cp /weblogic/Oracle/Middleware/wlserver/server/lib/weblogic-launcher.jar -Dlaunch.use.env.classpath=true -Dweblogic.Name=AdminServer -Djava.security.policy=/weblogic/Oracle/Middleware/wlserver/server/lib/weblogic.policy -Djava.system.class.loader=com.oracle.classloader.weblogic.LaunchClassLoader -javaagent:/weblogic/Oracle/Middleware/wlserver/server/lib/debugpatch-agent.jar -da -Dwls.home=/weblogic/Oracle/Middleware/wlserver/server -Dweblogic.home=/weblogic/Oracle/Middleware/wlserver/server weblogic.Server
root      3094  3019  0 16:31 pts/0    00:00:00 grep --color=auto java
]]>
http://www.jydba.net/index.php/archives/3471/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
Oracle Linux 7.1 静默安装Weblogic 12.2.1.3 http://www.jydba.net/index.php/archives/3461 http://www.jydba.net/index.php/archives/3461#respond Fri, 10 Mar 2023 03:22:24 +0000 http://www.jydba.net/?p=3461 安装前准备
下载软件
Java SE 8 (jdk-linux-x64.tar.gz)
WebLogic Server 12cR2 (12.2.1) (fmw_12.2.1.3.0_wls.jar)

1.创建weblogic用户
[root@localhost java]# id weblogic
id: weblogic: no such user
[root@localhost java]# groupadd weblogic
[root@localhost java]# useradd -g weblogic weblogic
[root@localhost java]# passwd weblogic
Changing password for user weblogic.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.

2.安装java
[root@localhost soft]# mkdir -p /usr/java
[root@localhost soft]# tar -zxvf jdk-linux-x64.tar.gz -C /usr/java

3.配置JAVA_HOME
[root@localhost ~]# cd /usr/java
[root@localhost java]# ll
total 4
drwxr-xr-x. 8 10 143 4096 Mar 15 2017 jdk1.8.0_131
[root@localhost java]# cp /etc/profile /etc/profile20230309
[root@localhost java]# vi /etc/profile
# /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.

pathmunge () {
case “:${PATH}:” in
*:”$1″:*)
;;
*)
if [ “$2” = “after” ] ; then
PATH=$PATH:$1
else
PATH=$1:$PATH
fi
esac
}

if [ -x /usr/bin/id ]; then
if [ -z “$EUID” ]; then
# ksh workaround
EUID=`id -u`
UID=`id -ru`
fi
USER=”`id -un`”
LOGNAME=$USER
MAIL=”/var/spool/mail/$USER”
fi

# Path manipulation
if [ “$EUID” = “0” ]; then
pathmunge /usr/sbin
pathmunge /usr/local/sbin
else
pathmunge /usr/local/sbin after
pathmunge /usr/sbin after
fi

HOSTNAME=`/usr/bin/hostname 2>/dev/null`
HISTSIZE=1000
if [ “$HISTCONTROL” = “ignorespace” ] ; then
export HISTCONTROL=ignoreboth
else
export HISTCONTROL=ignoredups
fi

export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE HISTCONTROL

# By default, we want umask to get set. This sets it for login shell
# Current threshold for system reserved uid/gids is 200
# You could check uidgid reservation validity in
# /usr/share/doc/setup-*/uidgid file
if [ $UID -gt 199 ] && [ “`id -gn`” = “`id -un`” ]; then
umask 002
else
umask 022
fi

for i in /etc/profile.d/*.sh ; do
if [ -r “$i” ]; then
if [ “${-#*i}” != “$-” ]; then
. “$i”
else
. “$i” >/dev/null
fi
fi
done

#java
JAVA_HOME=/usr/java/jdk1.8.0_131
PATH=$JAVA_HOME/bin:$PATH
CLASSPATH=$JAVA_HOME/jre/lib/ext:$JAVA_HOME/lib/tools.jar
export PATH JAVA_HOME CLASSPATH
“/etc/profile” 82L, 1906C written
[root@localhost java]# source /etc/profile

4.查看java -version
[root@localhost java]# 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)

5.创建目录,并设定权限
[weblogic@localhost weblogic]$ mkdir -p /weblogic/Oracle/Middleware
[weblogic@localhost weblogic]$ chmod -R 775 /weblogic/Oracle/Middleware

[root@localhost soft]# vi /etc/profile
#weblogic
export MW_HOME=/weblogic/Oracle/Middleware
export WLS_HOME=$MW_HOME/wlserver
export WL_HOME=$WLS_HOME

[root@localhost ~]# source /etc/profile
[root@localhost ~]# echo

[root@localhost ~]# echo $MW_HOME
/weblogic/Oracle/Middleware
[root@localhost ~]# su – weblogic
Last login: Fri Mar 10 07:56:30 CST 2023 on pts/1
[weblogic@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)
[weblogic@localhost ~]$ echo $MW_HOME
/weblogic/Oracle/Middleware

安装weblogic软件
6.创建响应文件
编辑文件/weblogic/wls.rsp
[weblogic@localhost weblogic]$ vi wls.rsp
[ENGINE]
Response File Version=1.0.0.0.0
[GENERIC]
ORACLE_HOME=/weblogic/Oracle/Middleware
INSTALL_TYPE=WebLogic Server
MYORACLESUPPORT_USERNAME=
MYORACLESUPPORT_PASSWORD=<SECURE VALUE>
DECLINE_SECURITY_UPDATES=true
SECURITY_UPDATES_VIA_MYORACLESUPPORT=false
PROXY_HOST=
PROXY_PORT=
PROXY_USER=
PROXY_PWD=<SECURE VALUE>
COLLECTOR_SUPPORTHUB_URL=

7.指定Oracle的库存位置
编辑文件/weblogic/oraInst.loc
[weblogic@localhost weblogic]$ vi oraInst.loc

inventory_loc=/weblogic/oraInventory

inst_group=weblogic

[weblogic@localhost weblogic]$ mkdir -p /weblogic/oraInventory
[weblogic@localhost weblogic]$ ll
total 819548
-r-xr-xr-x. 1 weblogic weblogic 839208313 Aug 22 2017 fmw_12.2.1.3.0_wls.jar
drwxrwxr-x. 3 weblogic weblogic 23 Mar 10 08:00 Oracle
-rw-rw-r–. 1 weblogic weblogic 59 Mar 9 15:34 oraInst.loc
drwxrwxr-x. 2 weblogic weblogic 6 Mar 10 08:11 oraInventory
-rw-rw-r–. 1 weblogic weblogic 342 Mar 10 08:09 wls.rsp

8.安装weblogic
[weblogic@localhost weblogic]$ java -Xmx1024m -jar /weblogic/fmw_12.2.1.3.0_wls.jar -silent -responseFile /weblogic/wls.rsp -invPtrLoc /weblogic/oraInst.loc
Launcher log file is /tmp/OraInstall2023-03-10_08-16-04AM/launcher2023-03-10_08-16-04AM.log.
Extracting the installer . . . . . . . Done
Checking if CPU speed is above 300 MHz. Actual 2000.000 MHz Passed
Checking swap space: must be greater than 512 MB. Actual 8063 MB Passed
Checking if this platform requires a 64-bit JVM. Actual 64 Passed (64-bit not required)
Checking temp space: must be greater than 300 MB. Actual 81295 MB Passed
Preparing to launch the Oracle Universal Installer from /tmp/OraInstall2023-03-10_08-16-04AM
Log: /tmp/OraInstall2023-03-10_08-16-04AM/install2023-03-10_08-16-04AM.log
Copyright (c) 1996, 2017, Oracle and/or its affiliates. All rights reserved.
Reading response file..
Skipping Software Updates
Starting check : CertifiedVersions
Expected result: One of oracle-6, oracle-7, redhat-7, redhat-6, SuSE-11, SuSE-12
Actual Result: oracle-7.1
Check complete. The overall result of this check is: Passed
CertifiedVersions Check: Success.

Starting check : CheckJDKVersion
Expected result: 1.8.0_131
Actual Result: 1.8.0_131
Check complete. The overall result of this check is: Passed
CheckJDKVersion Check: Success.

Validations are enabled for this session.
Verifying data
Copying Files
Percent Complete : 10
Percent Complete : 20
Percent Complete : 30
Percent Complete : 40
Percent Complete : 50
Percent Complete : 60
Percent Complete : 70
Percent Complete : 80
Percent Complete : 90
Percent Complete : 100

The installation of Oracle Fusion Middleware 12c WebLogic Server and Coherence 12.2.1.3.0 completed successfully.
Logs successfully copied to /weblogic/oraInventory/logs.

9.创建domain域名

[weblogic@localhost bin]$ ./wlst.sh
WARNING: This is a deprecated script. Please invoke the wlst.sh script under oracle_common/common/bin.

Initializing WebLogic Scripting Tool (WLST) …

Welcome to WebLogic Server Administration Scripting Shell

Type help() for help on available commands

wls:/offline> readTemplate(‘/weblogic/Oracle/Middleware/wlserver/common/templates/wls/wls.jar’)
WARNING: The readTemplate is deprecated. Use selectTemplate followed by loadTemplates in place of readTemplate.
wls:/offline/base_domain>cd(‘Servers/AdminServer’)
wls:/offline/base_domain/Server/AdminServer>set(‘ListenAddress’,”)
wls:/offline/base_domain/Server/AdminServer>set(‘ListenPort’, 7001)
wls:/offline/base_domain/Server/AdminServer>cd(‘/’)
wls:/offline/base_domain>cd(‘Security/base_domain/User/weblogic’)
wls:/offline/base_domain/Security/base_domain/User/weblogic>cmo.setPassword(‘Xxzx$7817600’)
wls:/offline/base_domain/Security/base_domain/User/weblogic>setOption(‘OverwriteDomain’, ‘true’)
wls:/offline/base_domain/Security/base_domain/User/weblogic>writeDomain(‘/weblogic/Oracle/Middleware/user_projects/domains/base_domain’)
wls:/offline/base_domain/Security/base_domain/User/weblogic>closeTemplate()
wls:/offline>exit()

Exiting WebLogic Scripting Tool.

10.启动weblogic
修改weblogic端口号和IP
[weblogic@localhost config]$ vi config.xml
….
<server>
<name>AdminServer</name>
<listen-port>7001</listen-port>
<iiop-enabled>false</iiop-enabled>
<listen-address>10.13.13.4</listen-address>
</server>
…..

设置免密启动/weblogic/Oracle/Middleware/user_projects/domains/base_domain/servers/AdminServer/security目录下,编辑文件boot.properties
[weblogic@localhost security]$ cat boot.properties
# Generated by Configuration Wizard on Fri Mar 10 09:20:49 CST 2023
username={AES}m1DMhibRLp4hckxgycOV3fFtVs309buJFfJPxHa162Q=
password={AES}1UeQbtMNEYL40/c37MYUTfpPIoON7ql50cD/tparxp0=
[weblogic@localhost security]$ vi boot.properties
# Generated by Configuration Wizard on Fri Mar 10 09:20:49 CST 2023
username=weblogic
password=Xxzx$7817600

[[weblogic@localhost bin]$ ./startWebLogic.sh
.
.
JAVA Memory arguments: -Xms256m -Xmx512m -XX:CompileThreshold=8000
.
CLASSPATH=/usr/java/jdk1.8.0_131/lib/tools.jar:/weblogic/Oracle/Middleware/wlserver/server/lib/weblogic.jar:/weblogic/Oracle/Middleware/wlserver/../oracle_common/modules/thirdparty/ant-contrib-1.0b3.jar:/weblogic/Oracle/Middleware/wlserver/modules/features/oracle.wls.common.nodemanager.jar::/weblogic/Oracle/Middleware/wlserver/common/derby/lib/derbynet.jar:/weblogic/Oracle/Middleware/wlserver/common/derby/lib/derbyclient.jar:/weblogic/Oracle/Middleware/wlserver/common/derby/lib/derby.jar:/usr/java/jdk1.8.0_131/jre/lib/ext:/usr/java/jdk1.8.0_131/lib/tools.jar
.
PATH=/weblogic/Oracle/Middleware/user_projects/domains/base_domain/bin:/weblogic/Oracle/Middleware/wlserver/server/bin:/weblogic/Oracle/Middleware/wlserver/../oracle_common/modules/thirdparty/org.apache.ant/1.9.8.0.0/apache-ant-1.9.8/bin:/usr/java/jdk1.8.0_131/jre/bin:/usr/java/jdk1.8.0_131/bin:/usr/java/jdk1.8.0_131/bin:/usr/lib64/qt-3.3/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/weblogic/.local/bin:/home/weblogic/bin
.
***************************************************
* To start WebLogic Server, use a username and *
* password assigned to an admin-level user. For *
* server administration, use the WebLogic Server *
* console at http://hostname:port/console *
***************************************************
Starting WLS with line:
/usr/java/jdk1.8.0_131/bin/java -server -Xms256m -Xmx512m -XX:CompileThreshold=8000 -cp /weblogic/Oracle/Middleware/wlserver/server/lib/weblogic-launcher.jar -Dlaunch.use.env.classpath=true -Dweblogic.Name=AdminServer -Djava.security.policy=/weblogic/Oracle/Middleware/wlserver/server/lib/weblogic.policy -Djava.system.class.loader=com.oracle.classloader.weblogic.LaunchClassLoader -javaagent:/weblogic/Oracle/Middleware/wlserver/server/lib/debugpatch-agent.jar -da -Dwls.home=/weblogic/Oracle/Middleware/wlserver/server -Dweblogic.home=/weblogic/Oracle/Middleware/wlserver/server weblogic.Server
<Mar 10, 2023 10:10:21 AM CST> <Info> <Security> <BEA-090905> <Disabling the CryptoJ JCE Provider self-integrity check for better startup performance. To enable this check, specify -Dweblogic.security.allowCryptoJDefaultJCEVerification=true.>
<Mar 10, 2023 10:10:21 AM CST> <Info> <Security> <BEA-090906> <Changing the default Random Number Generator in RSA CryptoJ from ECDRBG128 to HMACDRBG. To disable this change, specify -Dweblogic.security.allowCryptoJDefaultPRNG=true.>
<Mar 10, 2023 10:10:22 AM CST> <Info> <WebLogicServer> <BEA-000377> <Starting WebLogic Server with Java HotSpot(TM) 64-Bit Server VM Version 25.131-b11 from Oracle Corporation.>
<Mar 10, 2023 10:10:22 AM CST> <Info> <RCM> <BEA-2165021> <“ResourceManagement” is not enabled in this JVM. Enable “ResourceManagement” to use the WebLogic Server “Resource Consumption Management” feature. To enable “ResourceManagement”, you must specify the following JVM options in the WebLogic Server instance in which the JVM runs: -XX:+UnlockCommercialFeatures -XX:+ResourceManagement.>
<Mar 10, 2023 10:10:23 AM CST> <Info> <Management> <BEA-141107> <Version: WebLogic Server 12.2.1.3.0 Thu Aug 17 13:39:49 PDT 2017 1882952>
<Mar 10, 2023 10:12:23 AM CST> <Notice> <WebLogicServer> <BEA-000365> <Server state changed to STARTING.>
<Mar 10, 2023 10:12:23 AM CST> <Info> <WorkManager> <BEA-002900> <Initializing self-tuning thread pool.>
<Mar 10, 2023 10:12:23 AM CST> <Info> <WorkManager> <BEA-002942> <CMM memory level becomes 0. Setting standby thread pool size to 256.>
<Mar 10, 2023 10:13:37,658 AM CST> <Notice> <Log Management> <BEA-170019> <The server log file weblogic.logging.FileStreamHandler instance=414943286
Current log file=/weblogic/Oracle/Middleware/user_projects/domains/base_domain/servers/AdminServer/logs/AdminServer.log
Rotation dir=/weblogic/Oracle/Middleware/user_projects/domains/base_domain/servers/AdminServer/logs
is opened. All server side log events will be written to this file.>
<Mar 10, 2023 10:13:37,911 AM CST> <Notice> <Security> <BEA-090946> <Security pre-initializing using security realm: myrealm>
<Mar 10, 2023 10:13:38,607 AM CST> <Notice> <Security> <BEA-090947> <Security post-initializing using security realm: myrealm>
<Mar 10, 2023 10:13:39,600 AM CST> <Notice> <Security> <BEA-090082> <Security initialized using administrative security realm: myrealm>
<Mar 10, 2023 10:13:39,664 AM CST> <Notice> <Security> <BEA-090083> <Storing boot identity in the file: /weblogic/Oracle/Middleware/user_projects/domains/base_domain/servers/AdminServer/security/boot.properties.>
<Mar 10, 2023 10:19:50,908 AM CST> <Notice> <JMX> <BEA-149512> <JMX Connector Server started at service:jmx:iiop://10.13.13.4:7001/jndi/weblogic.management.mbeanservers.runtime.>
<Mar 10, 2023 10:19:50,949 AM CST> <Notice> <JMX> <BEA-149512> <JMX Connector Server started at service:jmx:iiop://10.13.13.4:7001/jndi/weblogic.management.mbeanservers.domainruntime.>
<Mar 10, 2023 10:19:50,966 AM CST> <Notice> <JMX> <BEA-149512> <JMX Connector Server started at service:jmx:iiop://10.13.13.4:7001/jndi/weblogic.management.mbeanservers.edit.>
<Mar 10, 2023 10:21:52,707 AM CST> <Notice> <WebLogicServer> <BEA-000365> <Server state changed to STANDBY.>
<Mar 10, 2023 10:21:52,708 AM CST> <Notice> <WebLogicServer> <BEA-000365> <Server state changed to STARTING.>
<Mar 10, 2023 10:21:52,785 AM CST> <Notice> <Log Management> <BEA-170036> <The Logging monitoring service timer has started to check for logged message counts every 30 seconds.>
<Mar 10, 2023 10:21:53,221 AM CST> <Notice> <Log Management> <BEA-170027> <The server has successfully established a connection with the Domain level Diagnostic Service.>
<Mar 10, 2023 10:21:53,401 AM CST> <Notice> <WebLogicServer> <BEA-000365> <Server state changed to ADMIN.>
<Mar 10, 2023 10:21:53,509 AM CST> <Notice> <WebLogicServer> <BEA-000365> <Server state changed to RESUMING.>
<Mar 10, 2023 10:21:53,608 AM CST> <Notice> <WebLogicServer> <BEA-000331> <Started the WebLogic Server Administration Server “AdminServer” for domain “base_domain” running in development mode.>
<Mar 10, 2023 10:21:53,615 AM CST> <Notice> <WebLogicServer> <BEA-000360> <The server started in RUNNING mode.>
<Mar 10, 2023 10:21:53,615 AM CST> <Notice> <Server> <BEA-002613> <Channel “Default” is now listening on 10.13.13.4:7001 for protocols iiop, t3, ldap, snmp, http.>
<Mar 10, 2023 10:21:53,616 AM CST> <Notice> <Server> <BEA-002613> <Channel “Default” is now listening on 10.13.13.4:7001 for protocols iiop, t3, ldap, snmp, http.>
<Mar 10, 2023 10:21:53,628 AM CST> <Notice> <WebLogicServer> <BEA-000365> <Server state changed to RUNNING.>

]]>
http://www.jydba.net/index.php/archives/3461/feed 0
benchmark 压测Oracle 11g http://www.jydba.net/index.php/archives/3458 http://www.jydba.net/index.php/archives/3458#respond Wed, 22 Feb 2023 00:58:11 +0000 http://www.jydba.net/?p=3458 benchmarksql 5.0 支持对MySQL的TPC-C测试
根据官方文档介绍的测试环境,本文中涉及的TPC-C测试将使用 BenchmarkSQL5.0 软件实现。BenchmarkSQL是一款基于JDBC实现的类似于OLTP的TPC-C标准测试工具,目前支持的数据库如:PostgreSQL、Oracle等。

一.下载&编译安装

1.先要确定服务器是否安装了 JDK1.8

[root@sjjh /]# 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@sjjh lib]# mv jvm jvmold
[root@sjjh lib]# java -version
-bash: /usr/bin/java: ???

2.安装JDK1.8

[root@sjjh /]# tar -zxvf jdk-linux-x64.tar.gz

[root@sjjh /]# mkdir /usr/java
[root@sjjh /]# mv jdk1.8.0_131 /usr/java/
[root@sjjh /]# 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@sjjh /]# source /etc/profile
[root@sjjh /]# 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@shard1 /]# unzip benchmarksql-5.0.zip
[root@shard1 /]# cd benchmarksql-5.0/

加载oracle 驱动

[oracle@sjjh lib]$ ls -lrt
total 26084
-rw-r--r--. 1 oracle oinstall 2091135 Jul 11  2013 ojdbc5.jar
-rw-r--r--. 1 oracle oinstall 2739616 Jul 11  2013 ojdbc6.jar
-rw-r--r--. 1 oracle oinstall 2609739 Jul 11  2013 ojdbc5dms.jar
-rw-r--r--. 1 oracle oinstall 3350717 Jul 11  2013 ojdbc6dms.jar
-rw-r--r--. 1 oracle oinstall 3424145 Jul 11  2013 ojdbc5_g.jar
-rw-r--r--. 1 oracle oinstall 3445412 Jul 11  2013 ojdbc5dms_g.jar
-rw-r--r--. 1 oracle oinstall 4494540 Jul 11  2013 ojdbc6_g.jar
-rw-r--r--. 1 oracle oinstall 4517780 Jul 11  2013 ojdbc6dms_g.jar
-rw-r--r--. 1 oracle oinstall   20365 Jul 11  2013 simplefan.jar
[oracle@sjjh lib]$ pwd
/u01/app/oracle/product/11.2.0.4/db/jdbc/lib

[oracle@sjjh lib]$ cp ojdbc6.jar /benchmarksql-5.0/lib/oracle/

[oracle@sjjh lib]$ cd /benchmarksql-5.0/lib/oracle/
[oracle@sjjh oracle]$ pwd
/benchmarksql-5.0/lib/oracle
[oracle@sjjh oracle]$ ls -lrt
total 2680
-rwxrwxr-x. 1 oracle oinstall     174 May 26  2016 README.txt
-rw-r--r--. 1 oracle oinstall 2739616 Nov 14 10:21 ojdbc6.jar


修改props.ora

[oracle@sjjh run]$ vi props.ora
db=oracle
driver=oracle.jdbc.driver.OracleDriver
conn=jdbc:oracle:thin:@localhost:1521:sjjh
user=tpcs
password=tpcs

warehouses=40
loadWorkers=10

terminals=10
//To run specified transactions per terminal- runMins must equal zero
runTxnsPerTerminal=
//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
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

使用ant进行编译

[oracle@sjjh 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


初始化数据

[oracle@sjjh run]$  ./runDatabaseBuild.sh props.ora
# ------------------------------------------------------------
# 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;
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=oracle.jdbc.driver.OracleDriver
conn=jdbc:oracle:thin:@10.138.130.101:1521:sjjh
user=tpcs
password=***********
warehouses=40
loadWorkers=10
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 009: Loading Warehouse      9
Worker 000: Loading ITEM done
Worker 000: Loading Warehouse     10
Worker 004: Loading Warehouse      4 done
Worker 004: Loading Warehouse     11
Worker 007: Loading Warehouse      7 done
Worker 007: Loading Warehouse     12
Worker 005: Loading Warehouse      5 done
Worker 005: Loading Warehouse     13
Worker 008: Loading Warehouse      8 done
Worker 008: Loading Warehouse     14
Worker 006: Loading Warehouse      6 done
Worker 001: Loading Warehouse      1 done
Worker 006: Loading Warehouse     15
Worker 001: Loading Warehouse     16
Worker 009: Loading Warehouse      9 done
Worker 009: Loading Warehouse     17
Worker 002: Loading Warehouse      2 done
Worker 002: Loading Warehouse     18
Worker 003: Loading Warehouse      3 done
Worker 003: Loading Warehouse     19
Worker 000: Loading Warehouse     10 done
Worker 000: Loading Warehouse     20
Worker 004: Loading Warehouse     11 done
Worker 004: Loading Warehouse     21
Worker 008: Loading Warehouse     14 done
Worker 008: Loading Warehouse     22
Worker 005: Loading Warehouse     13 done
Worker 005: Loading Warehouse     23
Worker 007: Loading Warehouse     12 done
Worker 006: Loading Warehouse     15 done
Worker 007: Loading Warehouse     24
Worker 006: Loading Warehouse     25
Worker 003: Loading Warehouse     19 done
Worker 003: Loading Warehouse     26
Worker 002: Loading Warehouse     18 done
Worker 002: Loading Warehouse     27
Worker 000: Loading Warehouse     20 done
Worker 000: Loading Warehouse     28
Worker 001: Loading Warehouse     16 done
Worker 001: Loading Warehouse     29
Worker 009: Loading Warehouse     17 done
Worker 009: Loading Warehouse     30
Worker 004: Loading Warehouse     21 done
Worker 004: Loading Warehouse     31
Worker 008: Loading Warehouse     22 done
Worker 008: Loading Warehouse     32
Worker 006: Loading Warehouse     25 done
Worker 006: Loading Warehouse     33
Worker 007: Loading Warehouse     24 done
Worker 007: Loading Warehouse     34
Worker 003: Loading Warehouse     26 done
Worker 001: Loading Warehouse     29 done
Worker 003: Loading Warehouse     35
Worker 001: Loading Warehouse     36
Worker 005: Loading Warehouse     23 done
Worker 005: Loading Warehouse     37
Worker 002: Loading Warehouse     27 done
Worker 002: Loading Warehouse     38
Worker 000: Loading Warehouse     28 done
Worker 000: Loading Warehouse     39
Worker 009: Loading Warehouse     30 done
Worker 009: Loading Warehouse     40
Worker 007: Loading Warehouse     34 done
Worker 004: Loading Warehouse     31 done
Worker 008: Loading Warehouse     32 done
Worker 006: Loading Warehouse     33 done
Worker 003: Loading Warehouse     35 done
Worker 001: Loading Warehouse     36 done
Worker 005: Loading Warehouse     37 done
Worker 000: Loading Warehouse     39 done
Worker 009: Loading Warehouse     40 done
Worker 002: Loading Warehouse     38 done
# ------------------------------------------------------------
# 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.oracle/extraHistID.sql
# ------------------------------------------------------------
-- ----
-- Extra Schema objects/definitions for history.hist_id in Oracle
-- ----
-- ----
--      This is an extra column not present in the TPC-C
--      specs. It is useful for replication systems like
--      Bucardo and Slony-I, which like to have a primary
--      key on a table. It is an auto-increment or serial
--      column type. The definition below is compatible
--      with Oracle 11g, using the sequence in a trigger.
-- ----
-- Adjust the sequence above the current max(hist_id)
alter sequence bmsql_hist_id_seq increment by 30000;
declare
n integer;
i integer;
dummy integer;
begin
select max(hist_id) into n from bmsql_history;
i := 0;
while i < = n loop
select bmsql_hist_id_seq.nextval into dummy from dual;
i := i + 30000;
end loop;
end;
;
alter sequence bmsql_hist_id_seq increment by 1;
-- Create a trigger that forces hist_id to be hist_id_seq.nextval
create trigger bmsql_history_before_insert
before insert on bmsql_history
for each row
begin
if :new.hist_id is null then
select bmsql_hist_id_seq.nextval into :new.hist_id from dual;
end if;
end;
;
-- Add a primary key history(hist_id)
alter table bmsql_history add primary key (hist_id);
# ------------------------------------------------------------
# Loading SQL file ./sql.common/buildFinish.sql
# ------------------------------------------------------------
-- ----
-- Extra commands to run after the tables are created, loaded,
-- indexes built and extra's created.
-- ----‘

执行压测

[oracle@sjjh run]$ ./runBenchmark.sh props.ora
10:51:30,810 [main] INFO   jTPCC : Term-00,
10:51:30,815 [main] INFO   jTPCC : Term-00, +-------------------------------------------------------------+
10:51:30,816 [main] INFO   jTPCC : Term-00,      BenchmarkSQL v5.0
10:51:30,816 [main] INFO   jTPCC : Term-00, +-------------------------------------------------------------+
10:51:30,816 [main] INFO   jTPCC : Term-00,  (c) 2003, Raul Barbosa
10:51:30,817 [main] INFO   jTPCC : Term-00,  (c) 2004-2016, Denis Lussier
10:51:30,821 [main] INFO   jTPCC : Term-00,  (c) 2016, Jan Wieck
10:51:30,821 [main] INFO   jTPCC : Term-00, +-------------------------------------------------------------+
10:51:30,822 [main] INFO   jTPCC : Term-00,
10:51:30,822 [main] INFO   jTPCC : Term-00, db=oracle
10:51:30,822 [main] INFO   jTPCC : Term-00, driver=oracle.jdbc.driver.OracleDriver
10:51:30,823 [main] INFO   jTPCC : Term-00, conn=jdbc:oracle:thin:@10.138.130.101:1521:sjjh
10:51:30,823 [main] INFO   jTPCC : Term-00, user=tpcs
10:51:30,823 [main] INFO   jTPCC : Term-00,
10:51:30,823 [main] INFO   jTPCC : Term-00, warehouses=40
10:51:30,824 [main] INFO   jTPCC : Term-00, terminals=10
10:51:30,827 [main] INFO   jTPCC : Term-00, runMins=10
10:51:30,827 [main] INFO   jTPCC : Term-00, limitTxnsPerMin=0
10:51:30,827 [main] INFO   jTPCC : Term-00, terminalWarehouseFixed=true
10:51:30,828 [main] INFO   jTPCC : Term-00,
10:51:30,828 [main] INFO   jTPCC : Term-00, newOrderWeight=45
10:51:30,828 [main] INFO   jTPCC : Term-00, paymentWeight=43
10:51:30,828 [main] INFO   jTPCC : Term-00, orderStatusWeight=4
10:51:30,829 [main] INFO   jTPCC : Term-00, deliveryWeight=4
10:51:30,829 [main] INFO   jTPCC : Term-00, stockLevelWeight=4
10:51:30,829 [main] INFO   jTPCC : Term-00,
10:51:30,829 [main] INFO   jTPCC : Term-00, resultDirectory=my_result_%tY-%tm-%td_%tH%tM%tS
10:51:30,830 [main] INFO   jTPCC : Term-00, osCollectorScript=./misc/os_collector_linux.py
10:51:30,830 [main] INFO   jTPCC : Term-00,
10:51:31,026 [main] INFO   jTPCC : Term-00, copied props.ora to my_result_2022-11-14_105131/run.properties
10:51:31,027 [main] INFO   jTPCC : Term-00, created my_result_2022-11-14_105131/data/runInfo.csv for runID 1
10:51:31,027 [main] INFO   jTPCC : Term-00, writing per transaction results to my_result_2022-11-14_105131/data/result.csv
10:51:31,028 [main] INFO   jTPCC : Term-00, osCollectorScript=./misc/os_collector_linux.py
10:51:31,029 [main] INFO   jTPCC : Term-00, osCollectorInterval=1
10:51:31,029 [main] INFO   jTPCC : Term-00, osCollectorSSHAddr=null
10:51:31,029 [main] INFO   jTPCC : Term-00, osCollectorDevices=null
10:51:31,161 [main] INFO   jTPCC : Term-00,
10:51:31,676 [main] INFO   jTPCC : Term-00, C value for C_LAST during load: 243
10:51:31,677 [main] INFO   jTPCC : Term-00, C value for C_LAST this run:    125
10:51:31,677 [main] INFO   jTPCC : Term-00,
Term-00, Running Average tpmTOTAL: 10382.94    Current tpmTOTAL: 684828    Memory Usage: 107MB / 649MB
11:01:32,117 [Thread-2] INFO   jTPCC : Term-00,
11:01:32,118 [Thread-2] INFO   jTPCC : Term-00,
11:01:32,118 [Thread-2] INFO   jTPCC : Term-00, Measured tpmC (NewOrders) = 4686.82
11:01:32,118 [Thread-2] INFO   jTPCC : Term-00, Measured tpmTOTAL = 10382.59
11:01:32,118 [Thread-2] INFO   jTPCC : Term-00, Session Start     = 2022-11-14 10:51:32
11:01:32,118 [Thread-2] INFO   jTPCC : Term-00, Session End       = 2022-11-14 11:01:32
11:01:32,119 [Thread-2] INFO   jTPCC : Term-00, Transaction Count = 103831'

清理数据

[oracle@sjjh run]$ ./runDatabaseDestroy.sh props.ora
# ------------------------------------------------------------
# Loading SQL file ./sql.common/tableDrops.sql
# ------------------------------------------------------------
drop table bmsql_config;
drop table bmsql_new_order;
drop table bmsql_order_line;
drop table bmsql_oorder;
drop table bmsql_history;
drop table bmsql_customer;
drop table bmsql_stock;
drop table bmsql_item;
drop table bmsql_district;
drop table bmsql_warehouse;
drop sequence bmsql_hist_id_seq;
]]>
http://www.jydba.net/index.php/archives/3458/feed 0
benchmark 压测Oracle 12c http://www.jydba.net/index.php/archives/3455 http://www.jydba.net/index.php/archives/3455#respond Mon, 20 Feb 2023 00:39:37 +0000 http://www.jydba.net/?p=3455 benchmarksql 5.0 支持对MySQL的TPC-C测试
根据官方文档介绍的测试环境,本文中涉及的TPC-C测试将使用 BenchmarkSQL5.0 软件实现。BenchmarkSQL是一款基于JDBC实现的类似于OLTP的TPC-C标准测试工具,目前支持的数据库如:PostgreSQL、Oracle等。

一.下载&编译安装

1.先要确定服务器是否安装了 JDK1.8

[root@shard1 /]# 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@shard1 lib]# mv jvm jvmold
[root@shard1 lib]# java -version
-bash: /usr/bin/java: ???

2.安装JDK1.8

[root@shard1 /]# tar -zxvf jdk-linux-x64.tar.gz

[root@shard1 /]# mkdir /usr/java
[root@shard1 /]# mv jdk1.8.0_131 /usr/java/
[root@shard1 /]# 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@shard1 /]# source /etc/profile
[root@shard1 /]# 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@shard1 /]# unzip benchmarksql-5.0.zip
[root@shard1 /]# cd benchmarksql-5.0/


加载oracle 驱动(这里要使用11g版本的驱动ojdbc6.jar不能使用oracle 12c的ojdbc8.jar)

[oracle@shard1 lib]$ pwd
/u01/app/oracle/product/12.2.0/db/jdbc/lib
[oracle@shard1 lib]$ ls -lrt
2604
-rw-r--r--. 1 oracle oinstall   29051 123 2016 simplefan.jar
-rw-r--r--. 1 oracle oinstall 4036257 123 2016 ojdbc8.jar
-rw-r--r--. 1 oracle oinstall 5623186 123 2016 ojdbc8dms.jar
-rw-r--r--. 1 oracle oinstall 6708730 123 2016 ojdbc8_g.jar
-rw-r--r--. 1 oracle oinstall 6738172 123 2016 ojdbc8dms_g.jar
[oracle@shard1 lib]$ cp ojdbc8.jar /benchmarksql-5.0/lib/oracle/

使用oracle 12c的ojdbc8.jar在执行测试时就会报以下错误信息

[oracle@shard1 run]$ ./runBenchmark.sh props.ora
10:04:25,158 [main] INFO   jTPCC : Term-00,
10:04:25,192 [main] INFO   jTPCC : Term-00, +-------------------------------------------------------------+
10:04:25,192 [main] INFO   jTPCC : Term-00,      BenchmarkSQL v5.0
10:04:25,192 [main] INFO   jTPCC : Term-00, +-------------------------------------------------------------+
10:04:25,192 [main] INFO   jTPCC : Term-00,  (c) 2003, Raul Barbosa
10:04:25,192 [main] INFO   jTPCC : Term-00,  (c) 2004-2016, Denis Lussier
10:04:25,196 [main] INFO   jTPCC : Term-00,  (c) 2016, Jan Wieck
10:04:25,196 [main] INFO   jTPCC : Term-00, +-------------------------------------------------------------+
10:04:25,197 [main] INFO   jTPCC : Term-00,
10:04:25,197 [main] INFO   jTPCC : Term-00, db=oracle
10:04:25,197 [main] INFO   jTPCC : Term-00, driver=oracle.jdbc.driver.OracleDriver
10:04:25,197 [main] INFO   jTPCC : Term-00, conn=jdbc:oracle:thin:@localhost:1521:shardcat
10:04:25,197 [main] INFO   jTPCC : Term-00, user=tpcs
10:04:25,198 [main] INFO   jTPCC : Term-00,
10:04:25,198 [main] INFO   jTPCC : Term-00, warehouses=40
10:04:25,198 [main] INFO   jTPCC : Term-00, terminals=10
Exception in thread "main" java.lang.NumberFormatException: For input string: ""
        at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
        at java.lang.Integer.parseInt(Integer.java:592)
        at java.lang.Integer.parseInt(Integer.java:615)
        at jTPCC.(jTPCC.java:95)
        at jTPCC.main(jTPCC.java:53)


[oracle@shard1 lib]$ ls -lrt
total 26084
-rw-r--r--. 1 oracle oinstall 2091135 Jul 11  2013 ojdbc5.jar
-rw-r--r--. 1 oracle oinstall 2739616 Jul 11  2013 ojdbc6.jar
-rw-r--r--. 1 oracle oinstall 2609739 Jul 11  2013 ojdbc5dms.jar
-rw-r--r--. 1 oracle oinstall 3350717 Jul 11  2013 ojdbc6dms.jar
-rw-r--r--. 1 oracle oinstall 3424145 Jul 11  2013 ojdbc5_g.jar
-rw-r--r--. 1 oracle oinstall 3445412 Jul 11  2013 ojdbc5dms_g.jar
-rw-r--r--. 1 oracle oinstall 4494540 Jul 11  2013 ojdbc6_g.jar
-rw-r--r--. 1 oracle oinstall 4517780 Jul 11  2013 ojdbc6dms_g.jar
-rw-r--r--. 1 oracle oinstall   20365 Jul 11  2013 simplefan.jar
[oracle@shard1 lib]$ pwd
/u01/app/oracle/product/11.2.0.4/db/jdbc/lib

[oracle@shard1 lib]$ cp ojdbc6.jar /benchmarksql-5.0/lib/oracle/

[oracle@shard1 lib]$ cd /benchmarksql-5.0/lib/oracle/
[oracle@shard1 oracle]$ pwd
/benchmarksql-5.0/lib/oracle
[oracle@shard1 oracle]$ ls -lrt
total 2680
-rwxrwxr-x. 1 oracle oinstall     174 May 26  2016 README.txt
-rw-r--r--. 1 oracle oinstall 2739616 Nov 14 10:21 ojdbc6.jar

修改props.ora

[oracle@shard1 run]$ vi props.ora
db=oracle
driver=oracle.jdbc.driver.OracleDriver
conn=jdbc:oracle:thin:@localhost:1521:shardcat
user=tpcs
password=tpcs

warehouses=40
loadWorkers=10

terminals=10
//To run specified transactions per terminal- runMins must equal zero
runTxnsPerTerminal=
//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
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

使用ant进行编译

[oracle@shard1 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


初始化数据

[oracle@shard1 run]$ ./runDatabaseBuild.sh props.ora
# ------------------------------------------------------------
# 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;
ORA-00955: name is already used by an existing object

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=oracle.jdbc.driver.OracleDriver
conn=jdbc:oracle:thin:@localhost:1521:shardcat
user=tpcc
password=***********
warehouses=40
loadWorkers=10
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 009: Loading Warehouse      9
Worker 000: Loading ITEM done
Worker 000: Loading Warehouse     10
Worker 003: Loading Warehouse      3 done
Worker 003: Loading Warehouse     11
Worker 004: Loading Warehouse      4 done
Worker 004: Loading Warehouse     12
Worker 006: Loading Warehouse      6 done
Worker 006: Loading Warehouse     13
Worker 002: Loading Warehouse      2 done
Worker 002: Loading Warehouse     14
Worker 005: Loading Warehouse      5 done
Worker 005: Loading Warehouse     15
Worker 007: Loading Warehouse      7 done
Worker 007: Loading Warehouse     16
Worker 001: Loading Warehouse      1 done
Worker 001: Loading Warehouse     17
Worker 009: Loading Warehouse      9 done
Worker 009: Loading Warehouse     18
Worker 008: Loading Warehouse      8 done
Worker 008: Loading Warehouse     19
Worker 000: Loading Warehouse     10 done
Worker 000: Loading Warehouse     20
Worker 006: Loading Warehouse     13 done
Worker 006: Loading Warehouse     21
Worker 002: Loading Warehouse     14 done
Worker 002: Loading Warehouse     22
Worker 003: Loading Warehouse     11 done
Worker 003: Loading Warehouse     23
Worker 005: Loading Warehouse     15 done
Worker 005: Loading Warehouse     24
Worker 004: Loading Warehouse     12 done
Worker 004: Loading Warehouse     25
Worker 007: Loading Warehouse     16 done
Worker 007: Loading Warehouse     26
Worker 008: Loading Warehouse     19 done
Worker 008: Loading Warehouse     27
Worker 000: Loading Warehouse     20 done
Worker 000: Loading Warehouse     28
Worker 009: Loading Warehouse     18 done
Worker 009: Loading Warehouse     29
Worker 001: Loading Warehouse     17 done
Worker 001: Loading Warehouse     30
Worker 000: Loading Warehouse     28 done
Worker 000: Loading Warehouse     31
Worker 006: Loading Warehouse     21 done
Worker 006: Loading Warehouse     32
Worker 009: Loading Warehouse     29 done
Worker 009: Loading Warehouse     33
Worker 008: Loading Warehouse     27 done
Worker 008: Loading Warehouse     34
Worker 003: Loading Warehouse     23 done
Worker 003: Loading Warehouse     35
Worker 007: Loading Warehouse     26 done
Worker 007: Loading Warehouse     36
Worker 005: Loading Warehouse     24 done
Worker 005: Loading Warehouse     37
Worker 001: Loading Warehouse     30 done
Worker 001: Loading Warehouse     38
Worker 002: Loading Warehouse     22 done
Worker 002: Loading Warehouse     39
Worker 004: Loading Warehouse     25 done
Worker 004: Loading Warehouse     40
Worker 000: Loading Warehouse     31 done
Worker 009: Loading Warehouse     33 done
Worker 005: Loading Warehouse     37 done
Worker 004: Loading Warehouse     40 done
Worker 008: Loading Warehouse     34 done
Worker 007: Loading Warehouse     36 done
Worker 003: Loading Warehouse     35 done
Worker 006: Loading Warehouse     32 done
Worker 001: Loading Warehouse     38 done
Worker 002: Loading Warehouse     39 done
# ------------------------------------------------------------
# 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.oracle/extraHistID.sql
# ------------------------------------------------------------
-- ----
-- Extra Schema objects/definitions for history.hist_id in Oracle
-- ----
-- ----
--      This is an extra column not present in the TPC-C
--      specs. It is useful for replication systems like
--      Bucardo and Slony-I, which like to have a primary
--      key on a table. It is an auto-increment or serial
--      column type. The definition below is compatible
--      with Oracle 11g, using the sequence in a trigger.
-- ----
-- Adjust the sequence above the current max(hist_id)
alter sequence bmsql_hist_id_seq increment by 30000;
declare
n integer;
i integer;
dummy integer;
begin
select max(hist_id) into n from bmsql_history;
i := 0;
while i < = n loop
select bmsql_hist_id_seq.nextval into dummy from dual;
i := i + 30000;
end loop;
end;
;
alter sequence bmsql_hist_id_seq increment by 1;
-- Create a trigger that forces hist_id to be hist_id_seq.nextval
create trigger bmsql_history_before_insert
before insert on bmsql_history
for each row
begin
if :new.hist_id is null then
select bmsql_hist_id_seq.nextval into :new.hist_id from dual;
end if;
end;
;
-- Add a primary key history(hist_id)
alter table bmsql_history add primary key (hist_id);
# ------------------------------------------------------------
# Loading SQL file ./sql.common/buildFinish.sql
# ------------------------------------------------------------
-- ----
-- Extra commands to run after the tables are created, loaded,
-- indexes built and extra's created.
-- ----

执行压测

[oracle@shard1 run]$ ./runBenchmark.sh props.ora
10:55:01,136 [main] INFO   jTPCC : Term-00,
10:55:01,142 [main] INFO   jTPCC : Term-00, +-------------------------------------------------------------+
10:55:01,142 [main] INFO   jTPCC : Term-00,      BenchmarkSQL v5.0
10:55:01,142 [main] INFO   jTPCC : Term-00, +-------------------------------------------------------------+
10:55:01,143 [main] INFO   jTPCC : Term-00,  (c) 2003, Raul Barbosa
10:55:01,143 [main] INFO   jTPCC : Term-00,  (c) 2004-2016, Denis Lussier
10:55:01,147 [main] INFO   jTPCC : Term-00,  (c) 2016, Jan Wieck
10:55:01,147 [main] INFO   jTPCC : Term-00, +-------------------------------------------------------------+
10:55:01,147 [main] INFO   jTPCC : Term-00,
10:55:01,147 [main] INFO   jTPCC : Term-00, db=oracle
10:55:01,148 [main] INFO   jTPCC : Term-00, driver=oracle.jdbc.driver.OracleDriver
10:55:01,148 [main] INFO   jTPCC : Term-00, conn=jdbc:oracle:thin:@localhost:1521:shardcat
10:55:01,148 [main] INFO   jTPCC : Term-00, user=tpcc
10:55:01,148 [main] INFO   jTPCC : Term-00,
10:55:01,148 [main] INFO   jTPCC : Term-00, warehouses=40
10:55:01,149 [main] INFO   jTPCC : Term-00, terminals=10
10:55:01,151 [main] INFO   jTPCC : Term-00, runMins=10
10:55:01,152 [main] INFO   jTPCC : Term-00, limitTxnsPerMin=0
10:55:01,152 [main] INFO   jTPCC : Term-00, terminalWarehouseFixed=true
10:55:01,152 [main] INFO   jTPCC : Term-00,
10:55:01,152 [main] INFO   jTPCC : Term-00, newOrderWeight=45
10:55:01,152 [main] INFO   jTPCC : Term-00, paymentWeight=43
10:55:01,152 [main] INFO   jTPCC : Term-00, orderStatusWeight=4
10:55:01,153 [main] INFO   jTPCC : Term-00, deliveryWeight=4
10:55:01,153 [main] INFO   jTPCC : Term-00, stockLevelWeight=4
10:55:01,153 [main] INFO   jTPCC : Term-00,
10:55:01,153 [main] INFO   jTPCC : Term-00, resultDirectory=my_result_%tY-%tm-%td_%tH%tM%tS
10:55:01,154 [main] INFO   jTPCC : Term-00, osCollectorScript=./misc/os_collector_linux.py
10:55:01,154 [main] INFO   jTPCC : Term-00,
10:55:01,455 [main] INFO   jTPCC : Term-00, copied props.ora to my_result_2022-11-14_105501/run.properties
10:55:01,456 [main] INFO   jTPCC : Term-00, created my_result_2022-11-14_105501/data/runInfo.csv for runID 5
10:55:01,456 [main] INFO   jTPCC : Term-00, writing per transaction results to my_result_2022-11-14_105501/data/result.csv
10:55:01,457 [main] INFO   jTPCC : Term-00, osCollectorScript=./misc/os_collector_linux.py
10:55:01,457 [main] INFO   jTPCC : Term-00, osCollectorInterval=1
10:55:01,458 [main] INFO   jTPCC : Term-00, osCollectorSSHAddr=null
10:55:01,458 [main] INFO   jTPCC : Term-00, osCollectorDevices=null
10:55:01,543 [main] INFO   jTPCC : Term-00,
10:55:02,053 [main] INFO   jTPCC : Term-00, C value for C_LAST during load: 74
10:55:02,054 [main] INFO   jTPCC : Term-00, C value for C_LAST this run:    175
10:55:02,054 [main] INFO   jTPCC : Term-00,
Term-00, Running Average tpmTOTAL: 33105.98    Current tpmTOTAL: 2183436    Memory Usage: 39MB / 196MB
11:05:02,526 [Thread-6] INFO   jTPCC : Term-00,
11:05:02,526 [Thread-6] INFO   jTPCC : Term-00,
11:05:02,527 [Thread-6] INFO   jTPCC : Term-00, Measured tpmC (NewOrders) = 14913.98
11:05:02,527 [Thread-6] INFO   jTPCC : Term-00, Measured tpmTOTAL = 33102.08
11:05:02,527 [Thread-6] INFO   jTPCC : Term-00, Session Start     = 2022-11-14 10:55:02
11:05:02,528 [Thread-6] INFO   jTPCC : Term-00, Session End       = 2022-11-14 11:05:02
11:05:02,528 [Thread-6] INFO   jTPCC : Term-00, Transaction Count = 331069

清理数据

[oracle@shard1 run]$ ./runDatabaseDestroy.sh props.ora
# ------------------------------------------------------------
# Loading SQL file ./sql.common/tableDrops.sql
# ------------------------------------------------------------
drop table bmsql_config;
drop table bmsql_new_order;
drop table bmsql_order_line;
drop table bmsql_oorder;
drop table bmsql_history;
drop table bmsql_customer;
drop table bmsql_stock;
drop table bmsql_item;
drop table bmsql_district;
drop table bmsql_warehouse;
drop sequence bmsql_hist_id_seq;
]]>
http://www.jydba.net/index.php/archives/3455/feed 0
sysbench压测Oracle 11g http://www.jydba.net/index.php/archives/3453 http://www.jydba.net/index.php/archives/3453#respond Thu, 16 Feb 2023 03:34:14 +0000 http://www.jydba.net/?p=3453 sysbench是一款测试工具主要包括以下几种方式的测试:
1、cpu性能
2、磁盘io性能
3、调度程式性能
4、内存分配及传输速度
5、POSIX线程性能
6、数据库性能(OLTP基准测试)现在sysbench主要支持 MySQL,pgsql,oracle 这3种数据库,默认支持MySQL,想要支持pgsql和oracle需要在编译时指定参数

环境介绍

名称	             版本
sysbench软件版本	sysbench 0.5
操作系统	        oracle linux 7.1
Oracle	          11.2.0.4

安装
1.安装依赖包

[root@shard1 /]# yum -y install make m4  autoconf automake libtool pkgconfig libaio-devel

2.解压sysbench软件

[root@sjjh /]# unzip sysbench-0.5.zip
Archive:  sysbench-0.5.zip
b23a7db377916e424cb555108dc5f784f615993b
   creating: sysbench-0.5/
  inflating: sysbench-0.5/.gitignore
  inflating: sysbench-0.5/.travis.yml
  inflating: sysbench-0.5/COPYING
  inflating: sysbench-0.5/ChangeLog
  inflating: sysbench-0.5/Makefile.am
  inflating: sysbench-0.5/README-WIN.txt
  inflating: sysbench-0.5/README.md
 extracting: sysbench-0.5/TODO
  inflating: sysbench-0.5/autogen.sh
   creating: sysbench-0.5/config/
  inflating: sysbench-0.5/config/config.rpath
  inflating: sysbench-0.5/configure.ac
   creating: sysbench-0.5/doc/
  inflating: sysbench-0.5/doc/Makefile.am
  inflating: sysbench-0.5/doc/manual.xml
   creating: sysbench-0.5/doc/xsl/
  inflating: sysbench-0.5/doc/xsl/Makefile.am
  inflating: sysbench-0.5/doc/xsl/catalog.xml.in
  inflating: sysbench-0.5/doc/xsl/xhtml-chunk.xsl
  inflating: sysbench-0.5/doc/xsl/xhtml-common.xsl
  inflating: sysbench-0.5/doc/xsl/xhtml.xsl
  inflating: sysbench-0.5/install-sh
   creating: sysbench-0.5/m4/
  inflating: sysbench-0.5/m4/ac_check_aio.m4
  inflating: sysbench-0.5/m4/ac_check_mysqlr.m4
  inflating: sysbench-0.5/m4/ac_check_pgsql.m4
  inflating: sysbench-0.5/m4/ac_lua_devel.m4
  inflating: sysbench-0.5/m4/acx_pthread.m4
  inflating: sysbench-0.5/m4/ax_check_docbook.m4
  inflating: sysbench-0.5/m4/extensions.m4
  inflating: sysbench-0.5/m4/lib-ld.m4
  inflating: sysbench-0.5/m4/lib-link.m4
  inflating: sysbench-0.5/m4/lib-prefix.m4
  inflating: sysbench-0.5/missing
  inflating: sysbench-0.5/mkinstalldirs
   creating: sysbench-0.5/sysbench/
  inflating: sysbench-0.5/sysbench/CMakeLists.txt
  inflating: sysbench-0.5/sysbench/Makefile.am
  inflating: sysbench-0.5/sysbench/db_driver.c
  inflating: sysbench-0.5/sysbench/db_driver.h
   creating: sysbench-0.5/sysbench/drivers/
  inflating: sysbench-0.5/sysbench/drivers/Makefile.am
   creating: sysbench-0.5/sysbench/drivers/attachsql/
  inflating: sysbench-0.5/sysbench/drivers/attachsql/Makefile.am
  inflating: sysbench-0.5/sysbench/drivers/attachsql/drv_attachsql.c
   creating: sysbench-0.5/sysbench/drivers/drizzle/
  inflating: sysbench-0.5/sysbench/drivers/drizzle/Makefile.am
  inflating: sysbench-0.5/sysbench/drivers/drizzle/drv_drizzle.c
   creating: sysbench-0.5/sysbench/drivers/mysql/
  inflating: sysbench-0.5/sysbench/drivers/mysql/CMakeLists.txt
  inflating: sysbench-0.5/sysbench/drivers/mysql/Makefile.am
  inflating: sysbench-0.5/sysbench/drivers/mysql/drv_mysql.c
   creating: sysbench-0.5/sysbench/drivers/oracle/
  inflating: sysbench-0.5/sysbench/drivers/oracle/Makefile.am
  inflating: sysbench-0.5/sysbench/drivers/oracle/drv_oracle.c
   creating: sysbench-0.5/sysbench/drivers/pgsql/
  inflating: sysbench-0.5/sysbench/drivers/pgsql/Makefile.am
  inflating: sysbench-0.5/sysbench/drivers/pgsql/drv_pgsql.c
  inflating: sysbench-0.5/sysbench/sb_barrier.c
  inflating: sysbench-0.5/sysbench/sb_barrier.h
  inflating: sysbench-0.5/sysbench/sb_list.h
  inflating: sysbench-0.5/sysbench/sb_logger.c
  inflating: sysbench-0.5/sysbench/sb_logger.h
  inflating: sysbench-0.5/sysbench/sb_options.c
  inflating: sysbench-0.5/sysbench/sb_options.h
  inflating: sysbench-0.5/sysbench/sb_percentile.c
  inflating: sysbench-0.5/sysbench/sb_percentile.h
  inflating: sysbench-0.5/sysbench/sb_timer.c
  inflating: sysbench-0.5/sysbench/sb_timer.h
  inflating: sysbench-0.5/sysbench/sb_win.c
  inflating: sysbench-0.5/sysbench/sb_win.h
   creating: sysbench-0.5/sysbench/scripting/
  inflating: sysbench-0.5/sysbench/scripting/CMakeLists.txt
  inflating: sysbench-0.5/sysbench/scripting/Makefile.am
   creating: sysbench-0.5/sysbench/scripting/lua/
  inflating: sysbench-0.5/sysbench/scripting/lua/COPYRIGHT
  inflating: sysbench-0.5/sysbench/scripting/lua/Makefile.am
  inflating: sysbench-0.5/sysbench/scripting/lua/README
   creating: sysbench-0.5/sysbench/scripting/lua/src/
  inflating: sysbench-0.5/sysbench/scripting/lua/src/CMakeLists.txt
  inflating: sysbench-0.5/sysbench/scripting/lua/src/Makefile.am
  inflating: sysbench-0.5/sysbench/scripting/lua/src/lapi.c
  inflating: sysbench-0.5/sysbench/scripting/lua/src/lapi.h
  inflating: sysbench-0.5/sysbench/scripting/lua/src/lauxlib.c
  inflating: sysbench-0.5/sysbench/scripting/lua/src/lauxlib.h
  inflating: sysbench-0.5/sysbench/scripting/lua/src/lbaselib.c
  inflating: sysbench-0.5/sysbench/scripting/lua/src/lcode.c
  inflating: sysbench-0.5/sysbench/scripting/lua/src/lcode.h
  inflating: sysbench-0.5/sysbench/scripting/lua/src/ldblib.c
  inflating: sysbench-0.5/sysbench/scripting/lua/src/ldebug.c
  inflating: sysbench-0.5/sysbench/scripting/lua/src/ldebug.h
  inflating: sysbench-0.5/sysbench/scripting/lua/src/ldo.c
  inflating: sysbench-0.5/sysbench/scripting/lua/src/ldo.h
  inflating: sysbench-0.5/sysbench/scripting/lua/src/ldump.c
  inflating: sysbench-0.5/sysbench/scripting/lua/src/lfunc.c
  inflating: sysbench-0.5/sysbench/scripting/lua/src/lfunc.h
  inflating: sysbench-0.5/sysbench/scripting/lua/src/lgc.c
  inflating: sysbench-0.5/sysbench/scripting/lua/src/lgc.h
  inflating: sysbench-0.5/sysbench/scripting/lua/src/linit.c
  inflating: sysbench-0.5/sysbench/scripting/lua/src/liolib.c
  inflating: sysbench-0.5/sysbench/scripting/lua/src/llex.c
  inflating: sysbench-0.5/sysbench/scripting/lua/src/llex.h
  inflating: sysbench-0.5/sysbench/scripting/lua/src/llimits.h
  inflating: sysbench-0.5/sysbench/scripting/lua/src/lmathlib.c
  inflating: sysbench-0.5/sysbench/scripting/lua/src/lmem.c
  inflating: sysbench-0.5/sysbench/scripting/lua/src/lmem.h
  inflating: sysbench-0.5/sysbench/scripting/lua/src/loadlib.c
  inflating: sysbench-0.5/sysbench/scripting/lua/src/lobject.c
  inflating: sysbench-0.5/sysbench/scripting/lua/src/lobject.h
  inflating: sysbench-0.5/sysbench/scripting/lua/src/lopcodes.c
  inflating: sysbench-0.5/sysbench/scripting/lua/src/lopcodes.h
  inflating: sysbench-0.5/sysbench/scripting/lua/src/loslib.c
  inflating: sysbench-0.5/sysbench/scripting/lua/src/lparser.c
  inflating: sysbench-0.5/sysbench/scripting/lua/src/lparser.h
  inflating: sysbench-0.5/sysbench/scripting/lua/src/lstate.c
  inflating: sysbench-0.5/sysbench/scripting/lua/src/lstate.h
  inflating: sysbench-0.5/sysbench/scripting/lua/src/lstring.c
  inflating: sysbench-0.5/sysbench/scripting/lua/src/lstring.h
  inflating: sysbench-0.5/sysbench/scripting/lua/src/lstrlib.c
  inflating: sysbench-0.5/sysbench/scripting/lua/src/ltable.c
  inflating: sysbench-0.5/sysbench/scripting/lua/src/ltable.h
  inflating: sysbench-0.5/sysbench/scripting/lua/src/ltablib.c
  inflating: sysbench-0.5/sysbench/scripting/lua/src/ltm.c
  inflating: sysbench-0.5/sysbench/scripting/lua/src/ltm.h
  inflating: sysbench-0.5/sysbench/scripting/lua/src/lua.h
  inflating: sysbench-0.5/sysbench/scripting/lua/src/luaconf.h
  inflating: sysbench-0.5/sysbench/scripting/lua/src/lualib.h
  inflating: sysbench-0.5/sysbench/scripting/lua/src/lundump.c
  inflating: sysbench-0.5/sysbench/scripting/lua/src/lundump.h
  inflating: sysbench-0.5/sysbench/scripting/lua/src/lvm.c
  inflating: sysbench-0.5/sysbench/scripting/lua/src/lvm.h
  inflating: sysbench-0.5/sysbench/scripting/lua/src/lzio.c
  inflating: sysbench-0.5/sysbench/scripting/lua/src/lzio.h
  inflating: sysbench-0.5/sysbench/scripting/lua/src/print.c
  inflating: sysbench-0.5/sysbench/scripting/sb_script.c
  inflating: sysbench-0.5/sysbench/scripting/sb_script.h
  inflating: sysbench-0.5/sysbench/scripting/script_lua.c
  inflating: sysbench-0.5/sysbench/scripting/script_lua.h
  inflating: sysbench-0.5/sysbench/sysbench.c
  inflating: sysbench-0.5/sysbench/sysbench.h
   creating: sysbench-0.5/sysbench/tests/
  inflating: sysbench-0.5/sysbench/tests/CMakeLists.txt
  inflating: sysbench-0.5/sysbench/tests/Makefile.am
   creating: sysbench-0.5/sysbench/tests/cpu/
  inflating: sysbench-0.5/sysbench/tests/cpu/CMakeLists.txt
  inflating: sysbench-0.5/sysbench/tests/cpu/Makefile.am
  inflating: sysbench-0.5/sysbench/tests/cpu/sb_cpu.c
   creating: sysbench-0.5/sysbench/tests/db/
  inflating: sysbench-0.5/sysbench/tests/db/Makefile.am
  inflating: sysbench-0.5/sysbench/tests/db/bulk_insert.lua
  inflating: sysbench-0.5/sysbench/tests/db/common.lua
  inflating: sysbench-0.5/sysbench/tests/db/delete.lua
  inflating: sysbench-0.5/sysbench/tests/db/insert.lua
  inflating: sysbench-0.5/sysbench/tests/db/oltp.lua
  inflating: sysbench-0.5/sysbench/tests/db/oltp_simple.lua
  inflating: sysbench-0.5/sysbench/tests/db/parallel_prepare.lua
  inflating: sysbench-0.5/sysbench/tests/db/select.lua
  inflating: sysbench-0.5/sysbench/tests/db/select_random_points.lua
  inflating: sysbench-0.5/sysbench/tests/db/select_random_ranges.lua
  inflating: sysbench-0.5/sysbench/tests/db/update_index.lua
  inflating: sysbench-0.5/sysbench/tests/db/update_non_index.lua
   creating: sysbench-0.5/sysbench/tests/fileio/
  inflating: sysbench-0.5/sysbench/tests/fileio/CMakeLists.txt
  inflating: sysbench-0.5/sysbench/tests/fileio/Makefile.am
  inflating: sysbench-0.5/sysbench/tests/fileio/crc32.c
  inflating: sysbench-0.5/sysbench/tests/fileio/crc32.h
  inflating: sysbench-0.5/sysbench/tests/fileio/crc32tbl.h
  inflating: sysbench-0.5/sysbench/tests/fileio/sb_fileio.c
   creating: sysbench-0.5/sysbench/tests/memory/
  inflating: sysbench-0.5/sysbench/tests/memory/CMakeLists.txt
  inflating: sysbench-0.5/sysbench/tests/memory/Makefile.am
  inflating: sysbench-0.5/sysbench/tests/memory/sb_memory.c
   creating: sysbench-0.5/sysbench/tests/mutex/
  inflating: sysbench-0.5/sysbench/tests/mutex/CMakeLists.txt
  inflating: sysbench-0.5/sysbench/tests/mutex/Makefile.am
  inflating: sysbench-0.5/sysbench/tests/mutex/sb_mutex.c
  inflating: sysbench-0.5/sysbench/tests/sb_cpu.h
  inflating: sysbench-0.5/sysbench/tests/sb_fileio.h
  inflating: sysbench-0.5/sysbench/tests/sb_memory.h
  inflating: sysbench-0.5/sysbench/tests/sb_mutex.h
  inflating: sysbench-0.5/sysbench/tests/sb_threads.h
   creating: sysbench-0.5/sysbench/tests/threads/
  inflating: sysbench-0.5/sysbench/tests/threads/CMakeLists.txt
  inflating: sysbench-0.5/sysbench/tests/threads/Makefile.am
  inflating: sysbench-0.5/sysbench/tests/threads/sb_threads.c
   creating: sysbench-0.5/tests/
  inflating: sysbench-0.5/tests/Makefile.am
  inflating: sysbench-0.5/tests/README.md
   creating: sysbench-0.5/tests/include/
  inflating: sysbench-0.5/tests/include/config.sh.in
  inflating: sysbench-0.5/tests/include/drv_common.sh
  inflating: sysbench-0.5/tests/include/script_oltp_common.sh
   creating: sysbench-0.5/tests/t/
 extracting: sysbench-0.5/tests/t/1st.t
  inflating: sysbench-0.5/tests/t/api_basic.t
  inflating: sysbench-0.5/tests/t/api_rand.t
  inflating: sysbench-0.5/tests/t/api_sql.t
  inflating: sysbench-0.5/tests/t/cleanup.t
  inflating: sysbench-0.5/tests/t/commands.t
  inflating: sysbench-0.5/tests/t/drivers.t
  inflating: sysbench-0.5/tests/t/drv_mysql.t
  inflating: sysbench-0.5/tests/t/drv_pgsql.t
  inflating: sysbench-0.5/tests/t/help.t
  inflating: sysbench-0.5/tests/t/help_drv_mysql.t
  inflating: sysbench-0.5/tests/t/help_drv_pgsql.t
  inflating: sysbench-0.5/tests/t/prepare.t
  inflating: sysbench-0.5/tests/t/run.t
  inflating: sysbench-0.5/tests/t/script_oltp_mysql.t
  inflating: sysbench-0.5/tests/t/script_oltp_pgsql.t
  inflating: sysbench-0.5/tests/t/test_cpu.t
  inflating: sysbench-0.5/tests/t/test_fileio.t
  inflating: sysbench-0.5/tests/t/test_memory.t
  inflating: sysbench-0.5/tests/t/test_mutex.t
  inflating: sysbench-0.5/tests/t/test_threads.t
  inflating: sysbench-0.5/tests/t/tests.t
  inflating: sysbench-0.5/tests/t/version.t
  inflating: sysbench-0.5/tests/test_run.sh

3.配置环境变量,使用实际的ORACLE_HOME目录

export CC=cc
export CXX=c++
export CFLAGS="-m64 -I /u01/app/oracle/product/11.2.0.4/db/rdbms/public"
export CXXFLAGS="$CFLAGS"
export ORACLE_HOME=/u01/app/oracle/product/11.2.0.4/db
export LD_LIBRARY_PATH=/u01/app/oracle/product/11.2.0.4/db/lib

[root@sjjh /]# export CC=cc
[root@sjjh /]# export CXX=c++
[root@sjjh /]# export CFLAGS="-m64 -I /u01/app/oracle/product/11.2.0.4/db/rdbms/public"
[root@sjjh /]# export CXXFLAGS="$CFLAGS"
[root@sjjh /]# export ORACLE_HOME=/u01/app/oracle/product/11.2.0.4/db
[root@sjjh /]# export LD_LIBRARY_PATH=/u01/app/oracle/product/11.2.0.4/db/lib

4.运行autogen.sh,生成configure目录

[root@sjjh sysbench-0.5]# ./autogen.sh
./autogen.sh: running `aclocal -I m4'
./autogen.sh: running `libtoolize --copy --force'
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'
./autogen.sh: running `autoheader'
./autogen.sh: running `automake -c --foreign --add-missing'
configure.ac:25: installing `config/compile'
configure.ac:11: installing `config/config.guess'
configure.ac:11: installing `config/config.sub'
configure.ac:16: installing `config/install-sh'
configure.ac:16: installing `config/missing'
sysbench/Makefile.am: installing `config/depcomp'
./autogen.sh: running `autoconf'
Libtoolized with: libtoolize (GNU libtool) 2.2.6b
Automade with: automake (GNU automake) 1.11.1
Configured with: autoconf (GNU Autoconf) 2.63

5.编译参数配置,加上–with-oracle

[root@sjjh sysbench-0.5]# ./configure --with-oracle --libdir=/u01/app/oracle/product/11.2.0.4/db/lib --without-mysql
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... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking for style of include used by make... GNU
checking for gcc... cc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether cc accepts -g... yes
checking for cc option to accept ISO C89... none needed
checking dependency style of cc... gcc3
checking how to run the C preprocessor... cc -E
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /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) cc
checking whether we are using the GNU C compiler... (cached) yes
checking whether cc accepts -g... (cached) yes
checking for cc option to accept ISO C89... (cached) none needed
checking dependency style of cc... (cached) gcc3
checking how to run the C preprocessor... cc -E
checking whether cc understands -c and -o together... yes
checking for a sed that does not truncate output... /bin/sed
checking for fgrep... /bin/grep -F
checking for ld used by cc... /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 for /usr/bin/ld option to reload object files... -r
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for ar... ar
checking for strip... strip
checking for ranlib... ranlib
checking command to parse /usr/bin/nm -B output from cc object... ok
checking for dlfcn.h... yes
checking for objdir... .libs
checking if cc supports -fno-rtti -fno-exceptions... no
checking for cc option to produce PIC... -fPIC -DPIC
checking if cc PIC flag -fPIC -DPIC works... yes
checking if cc static flag -static works... no
checking if cc supports -c -o file.o... yes
checking if cc supports -c -o file.o... (cached) yes
checking whether the cc 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 whether __SUNPRO_C is declared... no
checking "C Compiler version"... "cc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-16)"
checking whether to compile with MySQL support... (cached) no
checking whether to compile with Drizzle support... (cached) yes
checking whether to compile with libattachsql support... (cached) yes
checking whether to compile with Oracle support... (cached) yes
checking whether to compile with PostgreSQL support... (cached) no
checking whether to compile with Lua support... (cached) yes
checking whether SHM_HUGETLB is declared... yes
checking whether O_SYNC is declared... yes
checking for xsltproc... xsltproc
checking whether xsltproc works... 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 for ld used by GCC... /usr/bin/ld -m elf_x86_64
checking if the linker (/usr/bin/ld -m elf_x86_64) is GNU ld... yes
checking for shared library run path origin... done
checking for libdrizzle... no
checking for libattachsql... no
checking libaio.h usability... yes
checking libaio.h presence... yes
checking for libaio.h... yes
checking for io_queue_init in -laio... yes
checking if io_getevents() has an old interface... no
checking for malloc in -lumem... no
checking for malloc in -lmtmalloc... 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 for inline... inline
checking for off_t... yes
checking for size_t... yes
checking whether time.h and sys/time.h may both be included... 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 for stdlib.h... (cached) yes
checking for GNU libc compatible malloc... yes
checking for stdlib.h... (cached) yes
checking for unistd.h... (cached) 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 whether clock_gettime is declared... yes
checking for library containing clock_gettime... -lrt
checking for alarm... yes
checking for directio... no
checking for fdatasync... yes
checking for gettimeofday... yes
checking for lrand48... yes
checking for drand48... yes
checking for memalign... yes
checking for memset... yes
checking for mkstemp... yes
checking for popen... yes
checking for posix_memalign... yes
checking for pthread_yield... yes
checking for _setjmp... 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
configure: creating ./config.status
config.status: creating Makefile
config.status: creating doc/xsl/Makefile
config.status: creating doc/xsl/catalog.xml
config.status: creating doc/Makefile
config.status: creating sysbench/Makefile
config.status: creating sysbench/drivers/Makefile
config.status: creating sysbench/drivers/mysql/Makefile
config.status: creating sysbench/drivers/drizzle/Makefile
config.status: creating sysbench/drivers/oracle/Makefile
config.status: creating sysbench/drivers/pgsql/Makefile
config.status: creating sysbench/drivers/attachsql/Makefile
config.status: creating sysbench/tests/Makefile
config.status: creating sysbench/tests/cpu/Makefile
config.status: creating sysbench/tests/fileio/Makefile
config.status: creating sysbench/tests/memory/Makefile
config.status: creating sysbench/tests/threads/Makefile
config.status: creating sysbench/tests/mutex/Makefile
config.status: creating sysbench/tests/db/Makefile
config.status: creating sysbench/scripting/Makefile
config.status: creating sysbench/scripting/lua/Makefile
config.status: creating sysbench/scripting/lua/src/Makefile
config.status: creating tests/Makefile
config.status: creating tests/include/config.sh
config.status: creating config/config.h
config.status: executing depfiles commands
config.status: executing libtool commands

6.编译及安装,注意这里要带上oracle的一个so

[oracle@sjjh db]$ pwd
/u01/app/oracle/product/11.2.0.4/db
[oracle@sjjh db]$ cd /u01/app/oracle/product/11.2.0.4/db/lib
[oracle@sjjh lib]$ ls -lrt libclntsh.so
lrwxrwxrwx. 1 oracle oinstall 57 Sep 18 10:06 libclntsh.so -> /u01/app/oracle/product/11.2.0.4/db/lib/libclntsh.so.11.1

[root@sjjh sysbench-0.5]# make ORA_LIBS=/u01/app/oracle/product/11.2.0.4/db/lib/libclntsh.so -j 4
Making all in doc
make[1]: Entering directory `/sysbench-0.5/doc'
Making all in xsl
make[2]: Entering directory `/sysbench-0.5/doc/xsl'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `/sysbench-0.5/doc/xsl'
make[2]: Entering directory `/sysbench-0.5/doc'
XML_CATALOG_FILES=./xsl/catalog.xml xsltproc --nonet -o manual.html ./xsl/xhtml.xsl ../doc/manual.xml
make[2]: Leaving directory `/sysbench-0.5/doc'
make[1]: Leaving directory `/sysbench-0.5/doc'
Making all in sysbench
make[1]: Entering directory `/sysbench-0.5/sysbench'
Making all in drivers
make[2]: Entering directory `/sysbench-0.5/sysbench/drivers'
Making all in oracle
make[3]: Entering directory `/sysbench-0.5/sysbench/drivers/oracle'
cc -DHAVE_CONFIG_H -I. -I../../../config  -Iyes/rdbms/demo -Iyes/rdbms/public -I../../../sysbench -D_XOPEN_SOURCE=500 -D_GNU_SOURCE  -W -Wall -Wextra -Wpointer-arith -Wbad-function-cast   -Wstrict-prototypes -Wnested-externs -Winline   -funroll-loops  -Wundef -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wcast-align        -pthread -O2 -ggdb3 -m64 -I /u01/app/oracle/product/11.2.0.4/db/rdbms/public -MT libsboracle_a-drv_oracle.o -MD -MP -MF .deps/libsboracle_a-drv_oracle.Tpo -c -o libsboracle_a-drv_oracle.o `test -f 'drv_oracle.c' || echo './'`drv_oracle.c
In file included from /u01/app/oracle/product/11.2.0.4/db/rdbms/public/oci.h:3045,
                 from drv_oracle.c:30:
/u01/app/oracle/product/11.2.0.4/db/rdbms/public/ociap.h:10795: warning: function declaration isn’t a prototype
/u01/app/oracle/product/11.2.0.4/db/rdbms/public/ociap.h:10801: warning: function declaration isn’t a prototype
drv_oracle.c: In function ‘ora_drv_init’:
drv_oracle.c:243: warning: pointer targets in assignment differ in signedness
drv_oracle.c: In function ‘ora_drv_connect’:
drv_oracle.c:310: warning: pointer targets in passing argument 1 of ‘strlen’ differ in signedness
/usr/include/string.h:399: note: expected ‘const char *’ but argument is of type ‘unsigned char *’
drv_oracle.c: In function ‘ora_drv_prepare’:
drv_oracle.c:472: warning: pointer targets in passing argument 3 of ‘OCIStmtPrepare’ differ in signedness
/u01/app/oracle/product/11.2.0.4/db/rdbms/public/ociap.h:7163: note: expected ‘const OraText *’ but argument is of type ‘char *’
drv_oracle.c: In function ‘ora_drv_store_results’:
drv_oracle.c:852: warning: pointer targets in assignment differ in signedness
drv_oracle.c:855: warning: pointer targets in passing argument 1 of ‘__builtin_strncpy’ differ in signedness
drv_oracle.c:855: note: expected ‘char *’ but argument is of type ‘text *’
drv_oracle.c:855: warning: pointer targets in passing argument 2 of ‘__builtin_strncpy’ differ in signedness
drv_oracle.c:855: note: expected ‘const char *’ but argument is of type ‘text *’
drv_oracle.c: At top level:
drv_oracle.c:1077: warning: no previous prototype for ‘get_db_bind_type’
mv -f .deps/libsboracle_a-drv_oracle.Tpo .deps/libsboracle_a-drv_oracle.Po
rm -f libsboracle.a
ar cru libsboracle.a libsboracle_a-drv_oracle.o
ranlib libsboracle.a
make[3]: Leaving directory `/sysbench-0.5/sysbench/drivers/oracle'
make[3]: Entering directory `/sysbench-0.5/sysbench/drivers'
make[3]: Nothing to be done for `all-am'.
make[3]: Leaving directory `/sysbench-0.5/sysbench/drivers'
make[2]: Leaving directory `/sysbench-0.5/sysbench/drivers'
Making all in tests
make[2]: Entering directory `/sysbench-0.5/sysbench/tests'
Making all in cpu
make[3]: Entering directory `/sysbench-0.5/sysbench/tests/cpu'
cc -DHAVE_CONFIG_H -I. -I../../../config  -I../../../sysbench -D_XOPEN_SOURCE=500 -D_GNU_SOURCE  -W -Wall -Wextra -Wpointer-arith -Wbad-function-cast   -Wstrict-prototypes -Wnested-externs -Winline   -funroll-loops  -Wundef -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wcast-align        -pthread -O2 -ggdb3 -m64 -I /u01/app/oracle/product/11.2.0.4/db/rdbms/public -MT libsbcpu_a-sb_cpu.o -MD -MP -MF .deps/libsbcpu_a-sb_cpu.Tpo -c -o libsbcpu_a-sb_cpu.o `test -f 'sb_cpu.c' || echo './'`sb_cpu.c
mv -f .deps/libsbcpu_a-sb_cpu.Tpo .deps/libsbcpu_a-sb_cpu.Po
rm -f libsbcpu.a
ar cru libsbcpu.a libsbcpu_a-sb_cpu.o
ranlib libsbcpu.a
make[3]: Leaving directory `/sysbench-0.5/sysbench/tests/cpu'
Making all in fileio
make[3]: Entering directory `/sysbench-0.5/sysbench/tests/fileio'
cc -DHAVE_CONFIG_H -I. -I../../../config  -I../../../sysbench -D_XOPEN_SOURCE=500 -D_GNU_SOURCE  -W -Wall -Wextra -Wpointer-arith -Wbad-function-cast   -Wstrict-prototypes -Wnested-externs -Winline   -funroll-loops  -Wundef -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wcast-align        -pthread -O2 -ggdb3 -m64 -I /u01/app/oracle/product/11.2.0.4/db/rdbms/public -MT libsbfileio_a-sb_fileio.o -MD -MP -MF .deps/libsbfileio_a-sb_fileio.Tpo -c -o libsbfileio_a-sb_fileio.o `test -f 'sb_fileio.c' || echo './'`sb_fileio.c
cc -DHAVE_CONFIG_H -I. -I../../../config  -I../../../sysbench -D_XOPEN_SOURCE=500 -D_GNU_SOURCE  -W -Wall -Wextra -Wpointer-arith -Wbad-function-cast   -Wstrict-prototypes -Wnested-externs -Winline   -funroll-loops  -Wundef -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wcast-align        -pthread -O2 -ggdb3 -m64 -I /u01/app/oracle/product/11.2.0.4/db/rdbms/public -MT libsbfileio_a-crc32.o -MD -MP -MF .deps/libsbfileio_a-crc32.Tpo -c -o libsbfileio_a-crc32.o `test -f 'crc32.c' || echo './'`crc32.c
mv -f .deps/libsbfileio_a-crc32.Tpo .deps/libsbfileio_a-crc32.Po
mv -f .deps/libsbfileio_a-sb_fileio.Tpo .deps/libsbfileio_a-sb_fileio.Po
rm -f libsbfileio.a
ar cru libsbfileio.a libsbfileio_a-sb_fileio.o libsbfileio_a-crc32.o
ranlib libsbfileio.a
make[3]: Leaving directory `/sysbench-0.5/sysbench/tests/fileio'
Making all in memory
make[3]: Entering directory `/sysbench-0.5/sysbench/tests/memory'
cc -DHAVE_CONFIG_H -I. -I../../../config  -I../../../sysbench -D_XOPEN_SOURCE=500 -D_GNU_SOURCE  -W -Wall -Wextra -Wpointer-arith -Wbad-function-cast   -Wstrict-prototypes -Wnested-externs -Winline   -funroll-loops  -Wundef -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wcast-align        -pthread -O2 -ggdb3 -m64 -I /u01/app/oracle/product/11.2.0.4/db/rdbms/public -MT libsbmemory_a-sb_memory.o -MD -MP -MF .deps/libsbmemory_a-sb_memory.Tpo -c -o libsbmemory_a-sb_memory.o `test -f 'sb_memory.c' || echo './'`sb_memory.c
mv -f .deps/libsbmemory_a-sb_memory.Tpo .deps/libsbmemory_a-sb_memory.Po
rm -f libsbmemory.a
ar cru libsbmemory.a libsbmemory_a-sb_memory.o
ranlib libsbmemory.a
make[3]: Leaving directory `/sysbench-0.5/sysbench/tests/memory'
Making all in threads
make[3]: Entering directory `/sysbench-0.5/sysbench/tests/threads'
cc -DHAVE_CONFIG_H -I. -I../../../config  -I../../../sysbench -D_XOPEN_SOURCE=500 -D_GNU_SOURCE  -W -Wall -Wextra -Wpointer-arith -Wbad-function-cast   -Wstrict-prototypes -Wnested-externs -Winline   -funroll-loops  -Wundef -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wcast-align        -pthread -O2 -ggdb3 -m64 -I /u01/app/oracle/product/11.2.0.4/db/rdbms/public -MT libsbthreads_a-sb_threads.o -MD -MP -MF .deps/libsbthreads_a-sb_threads.Tpo -c -o libsbthreads_a-sb_threads.o `test -f 'sb_threads.c' || echo './'`sb_threads.c
mv -f .deps/libsbthreads_a-sb_threads.Tpo .deps/libsbthreads_a-sb_threads.Po
rm -f libsbthreads.a
ar cru libsbthreads.a libsbthreads_a-sb_threads.o
ranlib libsbthreads.a
make[3]: Leaving directory `/sysbench-0.5/sysbench/tests/threads'
Making all in mutex
make[3]: Entering directory `/sysbench-0.5/sysbench/tests/mutex'
cc -DHAVE_CONFIG_H -I. -I../../../config  -I../../../sysbench -D_XOPEN_SOURCE=500 -D_GNU_SOURCE  -W -Wall -Wextra -Wpointer-arith -Wbad-function-cast   -Wstrict-prototypes -Wnested-externs -Winline   -funroll-loops  -Wundef -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wcast-align        -pthread -O2 -ggdb3 -m64 -I /u01/app/oracle/product/11.2.0.4/db/rdbms/public -MT libsbmutex_a-sb_mutex.o -MD -MP -MF .deps/libsbmutex_a-sb_mutex.Tpo -c -o libsbmutex_a-sb_mutex.o `test -f 'sb_mutex.c' || echo './'`sb_mutex.c
mv -f .deps/libsbmutex_a-sb_mutex.Tpo .deps/libsbmutex_a-sb_mutex.Po
rm -f libsbmutex.a
ar cru libsbmutex.a libsbmutex_a-sb_mutex.o
ranlib libsbmutex.a
make[3]: Leaving directory `/sysbench-0.5/sysbench/tests/mutex'
Making all in db
make[3]: Entering directory `/sysbench-0.5/sysbench/tests/db'
make[3]: Nothing to be done for `all'.
make[3]: Leaving directory `/sysbench-0.5/sysbench/tests/db'
make[3]: Entering directory `/sysbench-0.5/sysbench/tests'
make[3]: Nothing to be done for `all-am'.
make[3]: Leaving directory `/sysbench-0.5/sysbench/tests'
make[2]: Leaving directory `/sysbench-0.5/sysbench/tests'
Making all in scripting
make[2]: Entering directory `/sysbench-0.5/sysbench/scripting'
Making all in lua
make[3]: Entering directory `/sysbench-0.5/sysbench/scripting/lua'
Making all in src
make[4]: Entering directory `/sysbench-0.5/sysbench/scripting/lua/src'
cc -DHAVE_CONFIG_H -I. -I../../../../config  -I../../../../sysbench -D_XOPEN_SOURCE=500 -D_GNU_SOURCE  -W -Wall -Wextra -Wpointer-arith -Wbad-function-cast   -Wstrict-prototypes -Wnested-externs -Winline   -funroll-loops  -Wundef -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wcast-align        -pthread -Wno-bad-function-cast -O2 -ggdb3 -m64 -I /u01/app/oracle/product/11.2.0.4/db/rdbms/public -MT lapi.o -MD -MP -MF .deps/lapi.Tpo -c -o lapi.o lapi.c
cc -DHAVE_CONFIG_H -I. -I../../../../config  -I../../../../sysbench -D_XOPEN_SOURCE=500 -D_GNU_SOURCE  -W -Wall -Wextra -Wpointer-arith -Wbad-function-cast   -Wstrict-prototypes -Wnested-externs -Winline   -funroll-loops  -Wundef -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wcast-align        -pthread -Wno-bad-function-cast -O2 -ggdb3 -m64 -I /u01/app/oracle/product/11.2.0.4/db/rdbms/public -MT lcode.o -MD -MP -MF .deps/lcode.Tpo -c -o lcode.o lcode.c
cc -DHAVE_CONFIG_H -I. -I../../../../config  -I../../../../sysbench -D_XOPEN_SOURCE=500 -D_GNU_SOURCE  -W -Wall -Wextra -Wpointer-arith -Wbad-function-cast   -Wstrict-prototypes -Wnested-externs -Winline   -funroll-loops  -Wundef -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wcast-align        -pthread -Wno-bad-function-cast -O2 -ggdb3 -m64 -I /u01/app/oracle/product/11.2.0.4/db/rdbms/public -MT ldebug.o -MD -MP -MF .deps/ldebug.Tpo -c -o ldebug.o ldebug.c
cc -DHAVE_CONFIG_H -I. -I../../../../config  -I../../../../sysbench -D_XOPEN_SOURCE=500 -D_GNU_SOURCE  -W -Wall -Wextra -Wpointer-arith -Wbad-function-cast   -Wstrict-prototypes -Wnested-externs -Winline   -funroll-loops  -Wundef -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wcast-align        -pthread -Wno-bad-function-cast -O2 -ggdb3 -m64 -I /u01/app/oracle/product/11.2.0.4/db/rdbms/public -MT ldo.o -MD -MP -MF .deps/ldo.Tpo -c -o ldo.o ldo.c
mv -f .deps/ldebug.Tpo .deps/ldebug.Po
cc -DHAVE_CONFIG_H -I. -I../../../../config  -I../../../../sysbench -D_XOPEN_SOURCE=500 -D_GNU_SOURCE  -W -Wall -Wextra -Wpointer-arith -Wbad-function-cast   -Wstrict-prototypes -Wnested-externs -Winline   -funroll-loops  -Wundef -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wcast-align        -pthread -Wno-bad-function-cast -O2 -ggdb3 -m64 -I /u01/app/oracle/product/11.2.0.4/db/rdbms/public -MT ldump.o -MD -MP -MF .deps/ldump.Tpo -c -o ldump.o ldump.c
mv -f .deps/ldo.Tpo .deps/ldo.Po
cc -DHAVE_CONFIG_H -I. -I../../../../config  -I../../../../sysbench -D_XOPEN_SOURCE=500 -D_GNU_SOURCE  -W -Wall -Wextra -Wpointer-arith -Wbad-function-cast   -Wstrict-prototypes -Wnested-externs -Winline   -funroll-loops  -Wundef -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wcast-align        -pthread -Wno-bad-function-cast -O2 -ggdb3 -m64 -I /u01/app/oracle/product/11.2.0.4/db/rdbms/public -MT lfunc.o -MD -MP -MF .deps/lfunc.Tpo -c -o lfunc.o lfunc.c
mv -f .deps/lcode.Tpo .deps/lcode.Po
cc -DHAVE_CONFIG_H -I. -I../../../../config  -I../../../../sysbench -D_XOPEN_SOURCE=500 -D_GNU_SOURCE  -W -Wall -Wextra -Wpointer-arith -Wbad-function-cast   -Wstrict-prototypes -Wnested-externs -Winline   -funroll-loops  -Wundef -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wcast-align        -pthread -Wno-bad-function-cast -O2 -ggdb3 -m64 -I /u01/app/oracle/product/11.2.0.4/db/rdbms/public -MT lgc.o -MD -MP -MF .deps/lgc.Tpo -c -o lgc.o lgc.c
mv -f .deps/ldump.Tpo .deps/ldump.Po
cc -DHAVE_CONFIG_H -I. -I../../../../config  -I../../../../sysbench -D_XOPEN_SOURCE=500 -D_GNU_SOURCE  -W -Wall -Wextra -Wpointer-arith -Wbad-function-cast   -Wstrict-prototypes -Wnested-externs -Winline   -funroll-loops  -Wundef -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wcast-align        -pthread -Wno-bad-function-cast -O2 -ggdb3 -m64 -I /u01/app/oracle/product/11.2.0.4/db/rdbms/public -MT llex.o -MD -MP -MF .deps/llex.Tpo -c -o llex.o llex.c
mv -f .deps/lapi.Tpo .deps/lapi.Po
mv -f .deps/lfunc.Tpo .deps/lfunc.Po
cc -DHAVE_CONFIG_H -I. -I../../../../config  -I../../../../sysbench -D_XOPEN_SOURCE=500 -D_GNU_SOURCE  -W -Wall -Wextra -Wpointer-arith -Wbad-function-cast   -Wstrict-prototypes -Wnested-externs -Winline   -funroll-loops  -Wundef -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wcast-align        -pthread -Wno-bad-function-cast -O2 -ggdb3 -m64 -I /u01/app/oracle/product/11.2.0.4/db/rdbms/public -MT lmem.o -MD -MP -MF .deps/lmem.Tpo -c -o lmem.o lmem.c
cc -DHAVE_CONFIG_H -I. -I../../../../config  -I../../../../sysbench -D_XOPEN_SOURCE=500 -D_GNU_SOURCE  -W -Wall -Wextra -Wpointer-arith -Wbad-function-cast   -Wstrict-prototypes -Wnested-externs -Winline   -funroll-loops  -Wundef -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wcast-align        -pthread -Wno-bad-function-cast -O2 -ggdb3 -m64 -I /u01/app/oracle/product/11.2.0.4/db/rdbms/public -MT lobject.o -MD -MP -MF .deps/lobject.Tpo -c -o lobject.o lobject.c
mv -f .deps/lmem.Tpo .deps/lmem.Po
cc -DHAVE_CONFIG_H -I. -I../../../../config  -I../../../../sysbench -D_XOPEN_SOURCE=500 -D_GNU_SOURCE  -W -Wall -Wextra -Wpointer-arith -Wbad-function-cast   -Wstrict-prototypes -Wnested-externs -Winline   -funroll-loops  -Wundef -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wcast-align        -pthread -Wno-bad-function-cast -O2 -ggdb3 -m64 -I /u01/app/oracle/product/11.2.0.4/db/rdbms/public -MT lopcodes.o -MD -MP -MF .deps/lopcodes.Tpo -c -o lopcodes.o lopcodes.c
mv -f .deps/lopcodes.Tpo .deps/lopcodes.Po
cc -DHAVE_CONFIG_H -I. -I../../../../config  -I../../../../sysbench -D_XOPEN_SOURCE=500 -D_GNU_SOURCE  -W -Wall -Wextra -Wpointer-arith -Wbad-function-cast   -Wstrict-prototypes -Wnested-externs -Winline   -funroll-loops  -Wundef -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wcast-align        -pthread -Wno-bad-function-cast -O2 -ggdb3 -m64 -I /u01/app/oracle/product/11.2.0.4/db/rdbms/public -MT lparser.o -MD -MP -MF .deps/lparser.Tpo -c -o lparser.o lparser.c
mv -f .deps/lobject.Tpo .deps/lobject.Po
cc -DHAVE_CONFIG_H -I. -I../../../../config  -I../../../../sysbench -D_XOPEN_SOURCE=500 -D_GNU_SOURCE  -W -Wall -Wextra -Wpointer-arith -Wbad-function-cast   -Wstrict-prototypes -Wnested-externs -Winline   -funroll-loops  -Wundef -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wcast-align        -pthread -Wno-bad-function-cast -O2 -ggdb3 -m64 -I /u01/app/oracle/product/11.2.0.4/db/rdbms/public -MT lstate.o -MD -MP -MF .deps/lstate.Tpo -c -o lstate.o lstate.c
mv -f .deps/llex.Tpo .deps/llex.Po
cc -DHAVE_CONFIG_H -I. -I../../../../config  -I../../../../sysbench -D_XOPEN_SOURCE=500 -D_GNU_SOURCE  -W -Wall -Wextra -Wpointer-arith -Wbad-function-cast   -Wstrict-prototypes -Wnested-externs -Winline   -funroll-loops  -Wundef -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wcast-align        -pthread -Wno-bad-function-cast -O2 -ggdb3 -m64 -I /u01/app/oracle/product/11.2.0.4/db/rdbms/public -MT lstring.o -MD -MP -MF .deps/lstring.Tpo -c -o lstring.o lstring.c
mv -f .deps/lstate.Tpo .deps/lstate.Po
cc -DHAVE_CONFIG_H -I. -I../../../../config  -I../../../../sysbench -D_XOPEN_SOURCE=500 -D_GNU_SOURCE  -W -Wall -Wextra -Wpointer-arith -Wbad-function-cast   -Wstrict-prototypes -Wnested-externs -Winline   -funroll-loops  -Wundef -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wcast-align        -pthread -Wno-bad-function-cast -O2 -ggdb3 -m64 -I /u01/app/oracle/product/11.2.0.4/db/rdbms/public -MT ltable.o -MD -MP -MF .deps/ltable.Tpo -c -o ltable.o ltable.c
mv -f .deps/lgc.Tpo .deps/lgc.Po
cc -DHAVE_CONFIG_H -I. -I../../../../config  -I../../../../sysbench -D_XOPEN_SOURCE=500 -D_GNU_SOURCE  -W -Wall -Wextra -Wpointer-arith -Wbad-function-cast   -Wstrict-prototypes -Wnested-externs -Winline   -funroll-loops  -Wundef -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wcast-align        -pthread -Wno-bad-function-cast -O2 -ggdb3 -m64 -I /u01/app/oracle/product/11.2.0.4/db/rdbms/public -MT ltm.o -MD -MP -MF .deps/ltm.Tpo -c -o ltm.o ltm.c
mv -f .deps/lstring.Tpo .deps/lstring.Po
cc -DHAVE_CONFIG_H -I. -I../../../../config  -I../../../../sysbench -D_XOPEN_SOURCE=500 -D_GNU_SOURCE  -W -Wall -Wextra -Wpointer-arith -Wbad-function-cast   -Wstrict-prototypes -Wnested-externs -Winline   -funroll-loops  -Wundef -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wcast-align        -pthread -Wno-bad-function-cast -O2 -ggdb3 -m64 -I /u01/app/oracle/product/11.2.0.4/db/rdbms/public -MT lundump.o -MD -MP -MF .deps/lundump.Tpo -c -o lundump.o lundump.c
mv -f .deps/ltm.Tpo .deps/ltm.Po
cc -DHAVE_CONFIG_H -I. -I../../../../config  -I../../../../sysbench -D_XOPEN_SOURCE=500 -D_GNU_SOURCE  -W -Wall -Wextra -Wpointer-arith -Wbad-function-cast   -Wstrict-prototypes -Wnested-externs -Winline   -funroll-loops  -Wundef -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wcast-align        -pthread -Wno-bad-function-cast -O2 -ggdb3 -m64 -I /u01/app/oracle/product/11.2.0.4/db/rdbms/public -MT lvm.o -MD -MP -MF .deps/lvm.Tpo -c -o lvm.o lvm.c
mv -f .deps/lundump.Tpo .deps/lundump.Po
cc -DHAVE_CONFIG_H -I. -I../../../../config  -I../../../../sysbench -D_XOPEN_SOURCE=500 -D_GNU_SOURCE  -W -Wall -Wextra -Wpointer-arith -Wbad-function-cast   -Wstrict-prototypes -Wnested-externs -Winline   -funroll-loops  -Wundef -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wcast-align        -pthread -Wno-bad-function-cast -O2 -ggdb3 -m64 -I /u01/app/oracle/product/11.2.0.4/db/rdbms/public -MT lzio.o -MD -MP -MF .deps/lzio.Tpo -c -o lzio.o lzio.c
mv -f .deps/lparser.Tpo .deps/lparser.Po
cc -DHAVE_CONFIG_H -I. -I../../../../config  -I../../../../sysbench -D_XOPEN_SOURCE=500 -D_GNU_SOURCE  -W -Wall -Wextra -Wpointer-arith -Wbad-function-cast   -Wstrict-prototypes -Wnested-externs -Winline   -funroll-loops  -Wundef -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wcast-align        -pthread -Wno-bad-function-cast -O2 -ggdb3 -m64 -I /u01/app/oracle/product/11.2.0.4/db/rdbms/public -MT lauxlib.o -MD -MP -MF .deps/lauxlib.Tpo -c -o lauxlib.o lauxlib.c
mv -f .deps/ltable.Tpo .deps/ltable.Po
cc -DHAVE_CONFIG_H -I. -I../../../../config  -I../../../../sysbench -D_XOPEN_SOURCE=500 -D_GNU_SOURCE  -W -Wall -Wextra -Wpointer-arith -Wbad-function-cast   -Wstrict-prototypes -Wnested-externs -Winline   -funroll-loops  -Wundef -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wcast-align        -pthread -Wno-bad-function-cast -O2 -ggdb3 -m64 -I /u01/app/oracle/product/11.2.0.4/db/rdbms/public -MT lbaselib.o -MD -MP -MF .deps/lbaselib.Tpo -c -o lbaselib.o lbaselib.c
mv -f .deps/lzio.Tpo .deps/lzio.Po
cc -DHAVE_CONFIG_H -I. -I../../../../config  -I../../../../sysbench -D_XOPEN_SOURCE=500 -D_GNU_SOURCE  -W -Wall -Wextra -Wpointer-arith -Wbad-function-cast   -Wstrict-prototypes -Wnested-externs -Winline   -funroll-loops  -Wundef -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wcast-align        -pthread -Wno-bad-function-cast -O2 -ggdb3 -m64 -I /u01/app/oracle/product/11.2.0.4/db/rdbms/public -MT ldblib.o -MD -MP -MF .deps/ldblib.Tpo -c -o ldblib.o ldblib.c
mv -f .deps/ldblib.Tpo .deps/ldblib.Po
cc -DHAVE_CONFIG_H -I. -I../../../../config  -I../../../../sysbench -D_XOPEN_SOURCE=500 -D_GNU_SOURCE  -W -Wall -Wextra -Wpointer-arith -Wbad-function-cast   -Wstrict-prototypes -Wnested-externs -Winline   -funroll-loops  -Wundef -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wcast-align        -pthread -Wno-bad-function-cast -O2 -ggdb3 -m64 -I /u01/app/oracle/product/11.2.0.4/db/rdbms/public -MT liolib.o -MD -MP -MF .deps/liolib.Tpo -c -o liolib.o liolib.c
mv -f .deps/lauxlib.Tpo .deps/lauxlib.Po
cc -DHAVE_CONFIG_H -I. -I../../../../config  -I../../../../sysbench -D_XOPEN_SOURCE=500 -D_GNU_SOURCE  -W -Wall -Wextra -Wpointer-arith -Wbad-function-cast   -Wstrict-prototypes -Wnested-externs -Winline   -funroll-loops  -Wundef -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wcast-align        -pthread -Wno-bad-function-cast -O2 -ggdb3 -m64 -I /u01/app/oracle/product/11.2.0.4/db/rdbms/public -MT lmathlib.o -MD -MP -MF .deps/lmathlib.Tpo -c -o lmathlib.o lmathlib.c
mv -f .deps/lbaselib.Tpo .deps/lbaselib.Po
cc -DHAVE_CONFIG_H -I. -I../../../../config  -I../../../../sysbench -D_XOPEN_SOURCE=500 -D_GNU_SOURCE  -W -Wall -Wextra -Wpointer-arith -Wbad-function-cast   -Wstrict-prototypes -Wnested-externs -Winline   -funroll-loops  -Wundef -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wcast-align        -pthread -Wno-bad-function-cast -O2 -ggdb3 -m64 -I /u01/app/oracle/product/11.2.0.4/db/rdbms/public -MT loslib.o -MD -MP -MF .deps/loslib.Tpo -c -o loslib.o loslib.c
mv -f .deps/lvm.Tpo .deps/lvm.Po
cc -DHAVE_CONFIG_H -I. -I../../../../config  -I../../../../sysbench -D_XOPEN_SOURCE=500 -D_GNU_SOURCE  -W -Wall -Wextra -Wpointer-arith -Wbad-function-cast   -Wstrict-prototypes -Wnested-externs -Winline   -funroll-loops  -Wundef -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wcast-align        -pthread -Wno-bad-function-cast -O2 -ggdb3 -m64 -I /u01/app/oracle/product/11.2.0.4/db/rdbms/public -MT ltablib.o -MD -MP -MF .deps/ltablib.Tpo -c -o ltablib.o ltablib.c
mv -f .deps/loslib.Tpo .deps/loslib.Po
cc -DHAVE_CONFIG_H -I. -I../../../../config  -I../../../../sysbench -D_XOPEN_SOURCE=500 -D_GNU_SOURCE  -W -Wall -Wextra -Wpointer-arith -Wbad-function-cast   -Wstrict-prototypes -Wnested-externs -Winline   -funroll-loops  -Wundef -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wcast-align        -pthread -Wno-bad-function-cast -O2 -ggdb3 -m64 -I /u01/app/oracle/product/11.2.0.4/db/rdbms/public -MT lstrlib.o -MD -MP -MF .deps/lstrlib.Tpo -c -o lstrlib.o lstrlib.c
mv -f .deps/lmathlib.Tpo .deps/lmathlib.Po
cc -DHAVE_CONFIG_H -I. -I../../../../config  -I../../../../sysbench -D_XOPEN_SOURCE=500 -D_GNU_SOURCE  -W -Wall -Wextra -Wpointer-arith -Wbad-function-cast   -Wstrict-prototypes -Wnested-externs -Winline   -funroll-loops  -Wundef -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wcast-align        -pthread -Wno-bad-function-cast -O2 -ggdb3 -m64 -I /u01/app/oracle/product/11.2.0.4/db/rdbms/public -MT loadlib.o -MD -MP -MF .deps/loadlib.Tpo -c -o loadlib.o loadlib.c
mv -f .deps/ltablib.Tpo .deps/ltablib.Po
cc -DHAVE_CONFIG_H -I. -I../../../../config  -I../../../../sysbench -D_XOPEN_SOURCE=500 -D_GNU_SOURCE  -W -Wall -Wextra -Wpointer-arith -Wbad-function-cast   -Wstrict-prototypes -Wnested-externs -Winline   -funroll-loops  -Wundef -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wcast-align        -pthread -Wno-bad-function-cast -O2 -ggdb3 -m64 -I /u01/app/oracle/product/11.2.0.4/db/rdbms/public -MT linit.o -MD -MP -MF .deps/linit.Tpo -c -o linit.o linit.c
mv -f .deps/liolib.Tpo .deps/liolib.Po
mv -f .deps/linit.Tpo .deps/linit.Po
mv -f .deps/loadlib.Tpo .deps/loadlib.Po
mv -f .deps/lstrlib.Tpo .deps/lstrlib.Po
rm -f liblua.a
ar cru liblua.a lapi.o lcode.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o lmem.o lobject.o lopcodes.o lparser.o lstate.o lstring.o ltable.o ltm.o lundump.o lvm.o lzio.o lauxlib.o lbaselib.o ldblib.o liolib.o lmathlib.o loslib.o ltablib.o lstrlib.o loadlib.o linit.o
ranlib liblua.a
make[4]: Leaving directory `/sysbench-0.5/sysbench/scripting/lua/src'
make[4]: Entering directory `/sysbench-0.5/sysbench/scripting/lua'
make[4]: Nothing to be done for `all-am'.
make[4]: Leaving directory `/sysbench-0.5/sysbench/scripting/lua'
make[3]: Leaving directory `/sysbench-0.5/sysbench/scripting/lua'
Making all in .
make[3]: Entering directory `/sysbench-0.5/sysbench/scripting'
cc -DHAVE_CONFIG_H -I. -I../../config  -I../../sysbench -I./lua/src -DDATA_PATH=\"/usr/local/share/sysbench\" -D_XOPEN_SOURCE=500 -D_GNU_SOURCE  -W -Wall -Wextra -Wpointer-arith -Wbad-function-cast   -Wstrict-prototypes -Wnested-externs -Winline   -funroll-loops  -Wundef -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wcast-align        -pthread -O2 -ggdb3 -m64 -I /u01/app/oracle/product/11.2.0.4/db/rdbms/public -MT libsbscript_a-sb_script.o -MD -MP -MF .deps/libsbscript_a-sb_script.Tpo -c -o libsbscript_a-sb_script.o `test -f 'sb_script.c' || echo './'`sb_script.c
cc -DHAVE_CONFIG_H -I. -I../../config  -I../../sysbench -I./lua/src -DDATA_PATH=\"/usr/local/share/sysbench\" -D_XOPEN_SOURCE=500 -D_GNU_SOURCE  -W -Wall -Wextra -Wpointer-arith -Wbad-function-cast   -Wstrict-prototypes -Wnested-externs -Winline   -funroll-loops  -Wundef -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wcast-align        -pthread -O2 -ggdb3 -m64 -I /u01/app/oracle/product/11.2.0.4/db/rdbms/public -MT libsbscript_a-script_lua.o -MD -MP -MF .deps/libsbscript_a-script_lua.Tpo -c -o libsbscript_a-script_lua.o `test -f 'script_lua.c' || echo './'`script_lua.c
mv -f .deps/libsbscript_a-sb_script.Tpo .deps/libsbscript_a-sb_script.Po
mv -f .deps/libsbscript_a-script_lua.Tpo .deps/libsbscript_a-script_lua.Po
rm -f libsbscript.a
ar cru libsbscript.a libsbscript_a-sb_script.o libsbscript_a-script_lua.o
ranlib libsbscript.a
make[3]: Leaving directory `/sysbench-0.5/sysbench/scripting'
make[2]: Leaving directory `/sysbench-0.5/sysbench/scripting'
Making all in .
make[2]: Entering directory `/sysbench-0.5/sysbench'
cc -DHAVE_CONFIG_H -I. -I../config  -I../sysbench -D_XOPEN_SOURCE=500 -D_GNU_SOURCE  -W -Wall -Wextra -Wpointer-arith -Wbad-function-cast   -Wstrict-prototypes -Wnested-externs -Winline   -funroll-loops  -Wundef -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wcast-align        -pthread -O2 -ggdb3 -m64 -I /u01/app/oracle/product/11.2.0.4/db/rdbms/public -MT sysbench.o -MD -MP -MF .deps/sysbench.Tpo -c -o sysbench.o sysbench.c
cc -DHAVE_CONFIG_H -I. -I../config  -I../sysbench -D_XOPEN_SOURCE=500 -D_GNU_SOURCE  -W -Wall -Wextra -Wpointer-arith -Wbad-function-cast   -Wstrict-prototypes -Wnested-externs -Winline   -funroll-loops  -Wundef -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wcast-align        -pthread -O2 -ggdb3 -m64 -I /u01/app/oracle/product/11.2.0.4/db/rdbms/public -MT sb_timer.o -MD -MP -MF .deps/sb_timer.Tpo -c -o sb_timer.o sb_timer.c
cc -DHAVE_CONFIG_H -I. -I../config  -I../sysbench -D_XOPEN_SOURCE=500 -D_GNU_SOURCE  -W -Wall -Wextra -Wpointer-arith -Wbad-function-cast   -Wstrict-prototypes -Wnested-externs -Winline   -funroll-loops  -Wundef -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wcast-align        -pthread -O2 -ggdb3 -m64 -I /u01/app/oracle/product/11.2.0.4/db/rdbms/public -MT sb_options.o -MD -MP -MF .deps/sb_options.Tpo -c -o sb_options.o sb_options.c
cc -DHAVE_CONFIG_H -I. -I../config  -I../sysbench -D_XOPEN_SOURCE=500 -D_GNU_SOURCE  -W -Wall -Wextra -Wpointer-arith -Wbad-function-cast   -Wstrict-prototypes -Wnested-externs -Winline   -funroll-loops  -Wundef -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wcast-align        -pthread -O2 -ggdb3 -m64 -I /u01/app/oracle/product/11.2.0.4/db/rdbms/public -MT sb_logger.o -MD -MP -MF .deps/sb_logger.Tpo -c -o sb_logger.o sb_logger.c
mv -f .deps/sb_timer.Tpo .deps/sb_timer.Po
cc -DHAVE_CONFIG_H -I. -I../config  -I../sysbench -D_XOPEN_SOURCE=500 -D_GNU_SOURCE  -W -Wall -Wextra -Wpointer-arith -Wbad-function-cast   -Wstrict-prototypes -Wnested-externs -Winline   -funroll-loops  -Wundef -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wcast-align        -pthread -O2 -ggdb3 -m64 -I /u01/app/oracle/product/11.2.0.4/db/rdbms/public -MT db_driver.o -MD -MP -MF .deps/db_driver.Tpo -c -o db_driver.o db_driver.c
mv -f .deps/sb_logger.Tpo .deps/sb_logger.Po
cc -DHAVE_CONFIG_H -I. -I../config  -I../sysbench -D_XOPEN_SOURCE=500 -D_GNU_SOURCE  -W -Wall -Wextra -Wpointer-arith -Wbad-function-cast   -Wstrict-prototypes -Wnested-externs -Winline   -funroll-loops  -Wundef -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wcast-align        -pthread -O2 -ggdb3 -m64 -I /u01/app/oracle/product/11.2.0.4/db/rdbms/public -MT sb_percentile.o -MD -MP -MF .deps/sb_percentile.Tpo -c -o sb_percentile.o sb_percentile.c
mv -f .deps/sb_options.Tpo .deps/sb_options.Po
cc -DHAVE_CONFIG_H -I. -I../config  -I../sysbench -D_XOPEN_SOURCE=500 -D_GNU_SOURCE  -W -Wall -Wextra -Wpointer-arith -Wbad-function-cast   -Wstrict-prototypes -Wnested-externs -Winline   -funroll-loops  -Wundef -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wcast-align        -pthread -O2 -ggdb3 -m64 -I /u01/app/oracle/product/11.2.0.4/db/rdbms/public -MT sb_barrier.o -MD -MP -MF .deps/sb_barrier.Tpo -c -o sb_barrier.o sb_barrier.c
mv -f .deps/sb_barrier.Tpo .deps/sb_barrier.Po
mv -f .deps/sb_percentile.Tpo .deps/sb_percentile.Po
mv -f .deps/sysbench.Tpo .deps/sysbench.Po
mv -f .deps/db_driver.Tpo .deps/db_driver.Po
/bin/sh ../libtool --tag=CC   --mode=link cc -W -Wall -Wextra -Wpointer-arith -Wbad-function-cast   -Wstrict-prototypes -Wnested-externs -Winline   -funroll-loops  -Wundef -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wcast-align        -pthread -O2 -ggdb3 -m64 -I /u01/app/oracle/product/11.2.0.4/db/rdbms/public       -L/u01/app/oracle/product/11.2.0.4/db/lib -o sysbench sysbench.o sb_timer.o sb_options.o sb_logger.o db_driver.o sb_percentile.o sb_barrier.o tests/fileio/libsbfileio.a tests/threads/libsbthreads.a tests/memory/libsbmemory.a tests/cpu/libsbcpu.a tests/mutex/libsbmutex.a scripting/libsbscript.a     drivers/oracle/libsboracle.a /u01/app/oracle/product/11.2.0.4/db/lib/libclntsh.so scripting/lua/src/liblua.a -lm -ldl -lrt -laio -lm
libtool: link: cc -W -Wall -Wextra -Wpointer-arith -Wbad-function-cast -Wstrict-prototypes -Wnested-externs -Winline -funroll-loops -Wundef -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wcast-align -pthread -O2 -ggdb3 -m64 -I /u01/app/oracle/product/11.2.0.4/db/rdbms/public -o sysbench sysbench.o sb_timer.o sb_options.o sb_logger.o db_driver.o sb_percentile.o sb_barrier.o /u01/app/oracle/product/11.2.0.4/db/lib/libclntsh.so  -L/u01/app/oracle/product/11.2.0.4/db/lib tests/fileio/libsbfileio.a tests/threads/libsbthreads.a tests/memory/libsbmemory.a tests/cpu/libsbcpu.a tests/mutex/libsbmutex.a scripting/libsbscript.a drivers/oracle/libsboracle.a scripting/lua/src/liblua.a -ldl -lrt -laio -lm -pthread
make[2]: Leaving directory `/sysbench-0.5/sysbench'
make[1]: Leaving directory `/sysbench-0.5/sysbench'
Making all in tests
make[1]: Entering directory `/sysbench-0.5/tests'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/sysbench-0.5/tests'
make[1]: Entering directory `/sysbench-0.5'
make[1]: Nothing to be done for `all-am'.
make[1]: Leaving directory `/sysbench-0.5'


[root@sjjh sysbench-0.5]# make install
Making install in doc
make[1]: Entering directory `/sysbench-0.5/doc'
Making install in xsl
make[2]: Entering directory `/sysbench-0.5/doc/xsl'
make[3]: Entering directory `/sysbench-0.5/doc/xsl'
make[3]: Nothing to be done for `install-exec-am'.
make[3]: Nothing to be done for `install-data-am'.
make[3]: Leaving directory `/sysbench-0.5/doc/xsl'
make[2]: Leaving directory `/sysbench-0.5/doc/xsl'
make[2]: Entering directory `/sysbench-0.5/doc'
make[3]: Entering directory `/sysbench-0.5/doc'
make[3]: Nothing to be done for `install-exec-am'.
test -z "/usr/local/share/doc/sysbench" || /bin/mkdir -p "/usr/local/share/doc/sysbench"
 /usr/bin/install -c -m 644 manual.html '/usr/local/share/doc/sysbench'
make[3]: Leaving directory `/sysbench-0.5/doc'
make[2]: Leaving directory `/sysbench-0.5/doc'
make[1]: Leaving directory `/sysbench-0.5/doc'
Making install in sysbench
make[1]: Entering directory `/sysbench-0.5/sysbench'
Making install in drivers
make[2]: Entering directory `/sysbench-0.5/sysbench/drivers'
Making install in oracle
make[3]: Entering directory `/sysbench-0.5/sysbench/drivers/oracle'
make[4]: Entering directory `/sysbench-0.5/sysbench/drivers/oracle'
make[4]: Nothing to be done for `install-exec-am'.
make[4]: Nothing to be done for `install-data-am'.
make[4]: Leaving directory `/sysbench-0.5/sysbench/drivers/oracle'
make[3]: Leaving directory `/sysbench-0.5/sysbench/drivers/oracle'
make[3]: Entering directory `/sysbench-0.5/sysbench/drivers'
make[4]: Entering directory `/sysbench-0.5/sysbench/drivers'
make[4]: Nothing to be done for `install-exec-am'.
make[4]: Nothing to be done for `install-data-am'.
make[4]: Leaving directory `/sysbench-0.5/sysbench/drivers'
make[3]: Leaving directory `/sysbench-0.5/sysbench/drivers'
make[2]: Leaving directory `/sysbench-0.5/sysbench/drivers'
Making install in tests
make[2]: Entering directory `/sysbench-0.5/sysbench/tests'
Making install in cpu
make[3]: Entering directory `/sysbench-0.5/sysbench/tests/cpu'
make[4]: Entering directory `/sysbench-0.5/sysbench/tests/cpu'
make[4]: Nothing to be done for `install-exec-am'.
make[4]: Nothing to be done for `install-data-am'.
make[4]: Leaving directory `/sysbench-0.5/sysbench/tests/cpu'
make[3]: Leaving directory `/sysbench-0.5/sysbench/tests/cpu'
Making install in fileio
make[3]: Entering directory `/sysbench-0.5/sysbench/tests/fileio'
make[4]: Entering directory `/sysbench-0.5/sysbench/tests/fileio'
make[4]: Nothing to be done for `install-exec-am'.
make[4]: Nothing to be done for `install-data-am'.
make[4]: Leaving directory `/sysbench-0.5/sysbench/tests/fileio'
make[3]: Leaving directory `/sysbench-0.5/sysbench/tests/fileio'
Making install in memory
make[3]: Entering directory `/sysbench-0.5/sysbench/tests/memory'
make[4]: Entering directory `/sysbench-0.5/sysbench/tests/memory'
make[4]: Nothing to be done for `install-exec-am'.
make[4]: Nothing to be done for `install-data-am'.
make[4]: Leaving directory `/sysbench-0.5/sysbench/tests/memory'
make[3]: Leaving directory `/sysbench-0.5/sysbench/tests/memory'
Making install in threads
make[3]: Entering directory `/sysbench-0.5/sysbench/tests/threads'
make[4]: Entering directory `/sysbench-0.5/sysbench/tests/threads'
make[4]: Nothing to be done for `install-exec-am'.
make[4]: Nothing to be done for `install-data-am'.
make[4]: Leaving directory `/sysbench-0.5/sysbench/tests/threads'
make[3]: Leaving directory `/sysbench-0.5/sysbench/tests/threads'
Making install in mutex
make[3]: Entering directory `/sysbench-0.5/sysbench/tests/mutex'
make[4]: Entering directory `/sysbench-0.5/sysbench/tests/mutex'
make[4]: Nothing to be done for `install-exec-am'.
make[4]: Nothing to be done for `install-data-am'.
make[4]: Leaving directory `/sysbench-0.5/sysbench/tests/mutex'
make[3]: Leaving directory `/sysbench-0.5/sysbench/tests/mutex'
Making install in db
make[3]: Entering directory `/sysbench-0.5/sysbench/tests/db'
make[4]: Entering directory `/sysbench-0.5/sysbench/tests/db'
make[4]: Nothing to be done for `install-exec-am'.
test -z "/usr/local/share/sysbench" || /bin/mkdir -p "/usr/local/share/sysbench"
 /usr/bin/install -c -m 644 common.lua delete.lua insert.lua bulk_insert.lua oltp.lua oltp_simple.lua parallel_prepare.lua select_random_points.lua select_random_ranges.lua select.lua update_index.lua update_non_index.lua '/usr/local/share/sysbench'
make[4]: Leaving directory `/sysbench-0.5/sysbench/tests/db'
make[3]: Leaving directory `/sysbench-0.5/sysbench/tests/db'
make[3]: Entering directory `/sysbench-0.5/sysbench/tests'
make[4]: Entering directory `/sysbench-0.5/sysbench/tests'
make[4]: Nothing to be done for `install-exec-am'.
make[4]: Nothing to be done for `install-data-am'.
make[4]: Leaving directory `/sysbench-0.5/sysbench/tests'
make[3]: Leaving directory `/sysbench-0.5/sysbench/tests'
make[2]: Leaving directory `/sysbench-0.5/sysbench/tests'
Making install in scripting
make[2]: Entering directory `/sysbench-0.5/sysbench/scripting'
Making install in lua
make[3]: Entering directory `/sysbench-0.5/sysbench/scripting/lua'
Making install in src
make[4]: Entering directory `/sysbench-0.5/sysbench/scripting/lua/src'
make[5]: Entering directory `/sysbench-0.5/sysbench/scripting/lua/src'
make[5]: Nothing to be done for `install-exec-am'.
make[5]: Nothing to be done for `install-data-am'.
make[5]: Leaving directory `/sysbench-0.5/sysbench/scripting/lua/src'
make[4]: Leaving directory `/sysbench-0.5/sysbench/scripting/lua/src'
make[4]: Entering directory `/sysbench-0.5/sysbench/scripting/lua'
make[5]: Entering directory `/sysbench-0.5/sysbench/scripting/lua'
make[5]: Nothing to be done for `install-exec-am'.
make[5]: Nothing to be done for `install-data-am'.
make[5]: Leaving directory `/sysbench-0.5/sysbench/scripting/lua'
make[4]: Leaving directory `/sysbench-0.5/sysbench/scripting/lua'
make[3]: Leaving directory `/sysbench-0.5/sysbench/scripting/lua'
Making install in .
make[3]: Entering directory `/sysbench-0.5/sysbench/scripting'
make[4]: Entering directory `/sysbench-0.5/sysbench/scripting'
make[4]: Nothing to be done for `install-exec-am'.
make[4]: Nothing to be done for `install-data-am'.
make[4]: Leaving directory `/sysbench-0.5/sysbench/scripting'
make[3]: Leaving directory `/sysbench-0.5/sysbench/scripting'
make[2]: Leaving directory `/sysbench-0.5/sysbench/scripting'
Making install in .
make[2]: Entering directory `/sysbench-0.5/sysbench'
make[3]: Entering directory `/sysbench-0.5/sysbench'
test -z "/usr/local/bin" || /bin/mkdir -p "/usr/local/bin"
  /bin/sh ../libtool   --mode=install /usr/bin/install -c sysbench '/usr/local/bin'
libtool: install: /usr/bin/install -c sysbench /usr/local/bin/sysbench
make[3]: Nothing to be done for `install-data-am'.
make[3]: Leaving directory `/sysbench-0.5/sysbench'
make[2]: Leaving directory `/sysbench-0.5/sysbench'
make[1]: Leaving directory `/sysbench-0.5/sysbench'
Making install in tests
make[1]: Entering directory `/sysbench-0.5/tests'
make[2]: Entering directory `/sysbench-0.5/tests'
make[2]: Nothing to be done for `install-exec-am'.
make    INSTALL_TO_DIR="/usr/local/share/sysbench/tests" install_test_files
make[3]: Entering directory `/sysbench-0.5/tests'
make[3]: Leaving directory `/sysbench-0.5/tests'
test -z "/usr/local/share/sysbench/tests" || /bin/mkdir -p "/usr/local/share/sysbench/tests"
 /usr/bin/install -c test_run.sh '/usr/local/share/sysbench/tests'
make[2]: Leaving directory `/sysbench-0.5/tests'
make[1]: Leaving directory `/sysbench-0.5/tests'
make[1]: Entering directory `/sysbench-0.5'
make[2]: Entering directory `/sysbench-0.5'
make[2]: Nothing to be done for `install-exec-am'.
make[2]: Nothing to be done for `install-data-am'.
make[2]: Leaving directory `/sysbench-0.5'
make[1]: Leaving directory `/sysbench-0.5'


[root@shard1 sysbench-0.5]# which sysbench
/usr/local/bin/sysbench

7.设置sysbench到path环境变量

[root@sjjh sysbench-0.5]# echo "export PATH=$PATH:/usr/local/sysbench/bin">>/etc/profile
[root@sjjh sysbench-0.5]# source /etc/profile

8.验证安装是否成功

[root@sjjh ~]# su - oracle
[oracle@sjjh ~]$ sysbench
Missing required command argument.
Usage:
  sysbench --test= [options]... 

Commands: prepare run cleanup help version

General options:
  --num-threads=N             number of threads to use [1]
  --max-requests=N            limit for total number of requests [10000]
  --max-time=N                limit for total execution time in seconds [0]
  --forced-shutdown=STRING    amount of time to wait after --max-time before forcing shutdown [off]
  --thread-stack-size=SIZE    size of stack per thread [64K]
  --tx-rate=N                 target transaction rate (tps) [0]
  --report-interval=N         periodically report intermediate statistics with a specified interval in seconds. 0 disables intermediate reports [0]
  --report-checkpoints=[LIST,...]dump full statistics and reset all counters at specified points in time. The argument is a list of comma-separated values representing the amount of time in seconds elapsed from start of test when report checkpoint(s) must be performed. Report checkpoints are off by default. []
  --test=STRING               test to run
  --debug=[on|off]            print more debugging info [off]
  --validate=[on|off]         perform validation checks where possible [off]
  --help=[on|off]             print help and exit
  --version=[on|off]          print version and exit [off]
  --rand-init=[on|off]        initialize random number generator [off]
  --rand-type=STRING          random numbers distribution {uniform,gaussian,special,pareto} [special]
  --rand-spec-iter=N          number of iterations used for numbers generation [12]
  --rand-spec-pct=N           percentage of values to be treated as 'special' (for special distribution) [1]
  --rand-spec-res=N           percentage of 'special' values to use (for special distribution) [75]
  --rand-seed=N               seed for random number generator, ignored when 0 [0]
  --rand-pareto-h=N           parameter h for pareto distibution [0.2]
  --config-file=FILENAME      File containing command line options

Log options:
  --verbosity=N      verbosity level {5 - debug, 0 - only critical messages} [3]

  --percentile=N      percentile rank of query response times to count [95]

General database options:

  --db-driver=STRING  specifies database driver to use ('help' to get list of available drivers)
  --db-ps-mode=STRING prepared statements usage mode {auto, disable} [auto]
  --db-debug=[on|off] print database-specific debug information [off]


Compiled-in database drivers:
  oracle - Oracle driver

oracle options:
  --oracle-user=STRING     Oracle user [sbtest]
  --oracle-password=STRING Oracle password []
  --oracle-db=STRING       Oracle database name [sbtest]

Compiled-in tests:
  fileio - File I/O test
  cpu - CPU performance test
  memory - Memory functions speed test
  threads - Threads subsystem performance test
  mutex - Mutex performance test

See 'sysbench --test= help' for a list of options for each test.

9.将.lua文件存储在sysbench-0.5/tests/db

[root@sjjh /]# unzip sysbench_lua-master.zip
Archive:  sysbench_lua-master.zip
f2ceb6cdf7315dbb8dd5f43d9c6757320a80a270
   creating: sysbench_lua-master/
  inflating: sysbench_lua-master/README.md
   creating: sysbench_lua-master/lua/
  inflating: sysbench_lua-master/lua/common.lua
  inflating: sysbench_lua-master/lua/delete.lua
  inflating: sysbench_lua-master/lua/insert.lua
  inflating: sysbench_lua-master/lua/oltp.lua
  inflating: sysbench_lua-master/lua/oltp_simple.lua
  inflating: sysbench_lua-master/lua/parallel_prepare.lua
  inflating: sysbench_lua-master/lua/select.lua
  inflating: sysbench_lua-master/lua/select_ora.lua
  inflating: sysbench_lua-master/lua/select_random_points.lua
  inflating: sysbench_lua-master/lua/select_random_ranges.lua
  inflating: sysbench_lua-master/lua/update_index.lua
  inflating: sysbench_lua-master/lua/update_index_ora.lua
  inflating: sysbench_lua-master/lua/update_index_pg_with_prepare.lua
  inflating: sysbench_lua-master/lua/update_index_with_commit.lua
  inflating: sysbench_lua-master/lua/update_non_index.lua
  inflating: sysbench_lua-master/lua/update_non_index_pg_with_prepare.lua
  inflating: sysbench_lua-master/lua/update_non_index_with_commit.lua

[root@sjjh db]# cd /sysbench_lua-master
[root@sjjh sysbench_lua-master]# ls
lua  README.md
[root@sjjh sysbench_lua-master]# cd lua
[root@sjjh lua]# ls -lrt
total 72
-rw-r--r--. 1 root root  595 Dec 18  2015 update_non_index_with_commit.lua
-rw-r--r--. 1 root root  640 Dec 18  2015 update_non_index_pg_with_prepare.lua
-rw-r--r--. 1 root root  552 Dec 18  2015 update_non_index.lua
-rw-r--r--. 1 root root  386 Dec 18  2015 update_index_with_commit.lua
-rw-r--r--. 1 root root  496 Dec 18  2015 update_index_pg_with_prepare.lua
-rw-r--r--. 1 root root  551 Dec 18  2015 update_index_ora.lua
-rw-r--r--. 1 root root  343 Dec 18  2015 update_index.lua
-rw-r--r--. 1 root root 4066 Dec 18  2015 select_random_ranges.lua
-rw-r--r--. 1 root root 3964 Dec 18  2015 select_random_points.lua
-rw-r--r--. 1 root root  526 Dec 18  2015 select_ora.lua
-rw-r--r--. 1 root root  343 Dec 18  2015 select.lua
-rw-r--r--. 1 root root  425 Dec 18  2015 parallel_prepare.lua
-rw-r--r--. 1 root root  342 Dec 18  2015 oltp_simple.lua
-rw-r--r--. 1 root root 3139 Dec 18  2015 oltp.lua
-rw-r--r--. 1 root root  830 Dec 18  2015 insert.lua
-rw-r--r--. 1 root root  340 Dec 18  2015 delete.lua
-rw-r--r--. 1 root root 4576 Dec 18  2015 common.lua

[root@sjjh lua]# cp *.lua  /sysbench-0.5/tests/db/
[root@sjjh lua]# cd /sysbench-0.5/tests/db/
[root@sjjh db]# ls -lrt
total 72
-rw-r--r--. 1 root root  830 Nov 10 12:18 insert.lua
-rw-r--r--. 1 root root  340 Nov 10 12:18 delete.lua
-rw-r--r--. 1 root root 4576 Nov 10 12:18 common.lua
-rw-r--r--. 1 root root  526 Nov 10 12:18 select_ora.lua
-rw-r--r--. 1 root root  343 Nov 10 12:18 select.lua
-rw-r--r--. 1 root root  425 Nov 10 12:18 parallel_prepare.lua
-rw-r--r--. 1 root root  342 Nov 10 12:18 oltp_simple.lua
-rw-r--r--. 1 root root 3139 Nov 10 12:18 oltp.lua
-rw-r--r--. 1 root root  640 Nov 10 12:18 update_non_index_pg_with_prepare.lua
-rw-r--r--. 1 root root  552 Nov 10 12:18 update_non_index.lua
-rw-r--r--. 1 root root  386 Nov 10 12:18 update_index_with_commit.lua
-rw-r--r--. 1 root root  496 Nov 10 12:18 update_index_pg_with_prepare.lua
-rw-r--r--. 1 root root  551 Nov 10 12:18 update_index_ora.lua
-rw-r--r--. 1 root root  343 Nov 10 12:18 update_index.lua
-rw-r--r--. 1 root root 4066 Nov 10 12:18 select_random_ranges.lua
-rw-r--r--. 1 root root 3964 Nov 10 12:18 select_random_points.lua
-rw-r--r--. 1 root root  595 Nov 10 12:18 update_non_index_with_commit.lua

测试
1.创建测试用户

SQL> create user sysbench identified by sysbench default tablespace users;

User created.

SQL> grant connect,resource,dba to sysbench;

Grant succeeded.

2.准备数据,lua文件需要指定绝对路径 需要进去oracle用户,并且数据库TNS配置在tnsnames.ora中

[oracle@sjjh admin]$ cat tnsnames.ora
sjjh =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 10.138.130.101)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = sjjh)(UR=A)
    )
  )


[oracle@sjjh admin]$ sysbench --test=/sysbench-0.5/tests/db/oltp.lua --db-driver=oracle --oltp-table-name=sysbench --oltp-table-size=250000 --oltp-tables-count=25 --oracle-db=sjjh --oracle-user=sysbench --oracle-password=sysbench --max-time=600 --max-requests=10000000 --num-threads=32 --report-interval=1 prepare
sysbench 0.5:  multi-threaded system evaluation benchmark

Creating table 'sbtest1'...
Inserting 250000 records into 'sbtest1'
Creating table 'sbtest2'...
Inserting 250000 records into 'sbtest2'
Creating table 'sbtest3'...
Inserting 250000 records into 'sbtest3'
Creating table 'sbtest4'...
Inserting 250000 records into 'sbtest4'
Creating table 'sbtest5'...
Inserting 250000 records into 'sbtest5'
Creating table 'sbtest6'...
Inserting 250000 records into 'sbtest6'
Creating table 'sbtest7'...
Inserting 250000 records into 'sbtest7'
Creating table 'sbtest8'...
Inserting 250000 records into 'sbtest8'
Creating table 'sbtest9'...
Inserting 250000 records into 'sbtest9'
Creating table 'sbtest10'...
Inserting 250000 records into 'sbtest10'
Creating table 'sbtest11'...
Inserting 250000 records into 'sbtest11'
Creating table 'sbtest12'...
Inserting 250000 records into 'sbtest12'
Creating table 'sbtest13'...
Inserting 250000 records into 'sbtest13'
Creating table 'sbtest14'...
Inserting 250000 records into 'sbtest14'
Creating table 'sbtest15'...
Inserting 250000 records into 'sbtest15'
Creating table 'sbtest16'...
Inserting 250000 records into 'sbtest16'
Creating table 'sbtest17'...
Inserting 250000 records into 'sbtest17'
Creating table 'sbtest18'...
Inserting 250000 records into 'sbtest18'
Creating table 'sbtest19'...
Inserting 250000 records into 'sbtest19'
Creating table 'sbtest20'...
Inserting 250000 records into 'sbtest20'
Creating table 'sbtest21'...
Inserting 250000 records into 'sbtest21'
Creating table 'sbtest22'...
Inserting 250000 records into 'sbtest22'
Creating table 'sbtest23'...
Inserting 250000 records into 'sbtest23'
Creating table 'sbtest24'...
Inserting 250000 records into 'sbtest24'
Creating table 'sbtest25'...
Inserting 250000 records into 'sbtest25'
[oracle@sjjh admin]$ sysbench --test=/sysbench-0.5/tests/db/oltp.lua --db-driver=oracle --oltp-table-name=sysbench --oltp-table-size=250000 --oltp-tables-count=25 --oracle-db=sjjh --oracle-user=sysbench --oracle-password=sysbench --max-time=600 --max-requests=10000000 --num-threads=32 --report-interval=1 run
sysbench 0.5:  multi-threaded system evaluation benchmark

Running the test with following options:
Number of threads: 32
Report intermediate results every 1 second(s)
Random number generator seed is 0 and will be ignored


Initializing worker threads...

Threads started!

[   1s] threads: 32, tps: 193.63, reads: 2939.43, writes: 792.50, response time: 381.18ms (95%), errors: 0.00, reconnects:  0.00
[   2s] threads: 32, tps: 254.03, reads: 3611.49, writes: 1015.14, response time: 181.98ms (95%), errors: 0.00, reconnects:  0.00
[   3s] threads: 32, tps: 267.99, reads: 3887.91, writes: 1105.97, response time: 156.17ms (95%), errors: 0.00, reconnects:  0.00
[   4s] threads: 32, tps: 295.00, reads: 3854.02, writes: 1129.00, response time: 150.21ms (95%), errors: 0.00, reconnects:  0.00
[   5s] threads: 32, tps: 270.00, reads: 3867.02, writes: 1105.00, response time: 153.39ms (95%), errors: 0.00, reconnects:  0.00
[   6s] threads: 32, tps: 271.00, reads: 3825.97, writes: 1099.99, response time: 153.76ms (95%), errors: 0.00, reconnects:  0.00
[   7s] threads: 32, tps: 267.01, reads: 3880.10, writes: 1091.03, response time: 174.88ms (95%), errors: 0.00, reconnects:  0.00
[   8s] threads: 32, tps: 289.99, reads: 4054.90, writes: 1143.97, response time: 141.61ms (95%), errors: 0.00, reconnects:  0.00
[   9s] threads: 32, tps: 279.00, reads: 3897.03, writes: 1127.01, response time: 190.62ms (95%), errors: 0.00, reconnects:  0.00
[  10s] threads: 32, tps: 268.00, reads: 3746.98, writes: 1074.99, response time: 201.17ms (95%), errors: 0.00, reconnects:  0.00
[  11s] threads: 32, tps: 297.99, reads: 3987.83, writes: 1136.95, response time: 147.84ms (95%), errors: 0.00, reconnects:  0.00
[  12s] threads: 32, tps: 297.01, reads: 4255.20, writes: 1208.06, response time: 142.07ms (95%), errors: 0.00, reconnects:  0.00
[  13s] threads: 32, tps: 304.96, reads: 4248.48, writes: 1225.85, response time: 145.12ms (95%), errors: 0.00, reconnects:  0.00
[  14s] threads: 32, tps: 296.04, reads: 4177.59, writes: 1185.17, response time: 144.60ms (95%), errors: 0.00, reconnects:  0.00
[  15s] threads: 32, tps: 302.99, reads: 4357.84, writes: 1256.95, response time: 148.51ms (95%), errors: 0.00, reconnects:  0.00
[  16s] threads: 32, tps: 298.01, reads: 4097.07, writes: 1166.02, response time: 194.31ms (95%), errors: 0.00, reconnects:  0.00
[  17s] threads: 32, tps: 311.00, reads: 4312.98, writes: 1202.99, response time: 132.82ms (95%), errors: 0.00, reconnects:  0.00
[  18s] threads: 32, tps: 274.00, reads: 3973.01, writes: 1202.00, response time: 151.43ms (95%), errors: 0.00, reconnects:  0.00
[  19s] threads: 32, tps: 300.00, reads: 4070.02, writes: 1101.01, response time: 179.71ms (95%), errors: 0.00, reconnects:  0.00
[  20s] threads: 32, tps: 306.00, reads: 4347.07, writes: 1270.02, response time: 144.78ms (95%), errors: 0.00, reconnects:  0.00
[  21s] threads: 32, tps: 285.00, reads: 3910.99, writes: 1075.00, response time: 177.94ms (95%), errors: 0.00, reconnects:  0.00
[  22s] threads: 32, tps: 302.99, reads: 4350.84, writes: 1249.96, response time: 151.79ms (95%), errors: 0.00, reconnects:  0.00
[  23s] threads: 32, tps: 313.01, reads: 4256.07, writes: 1261.02, response time: 141.78ms (95%), errors: 0.00, reconnects:  0.00
[  24s] threads: 32, tps: 300.01, reads: 4042.08, writes: 1155.02, response time: 160.58ms (95%), errors: 0.00, reconnects:  0.00
[  25s] threads: 32, tps: 318.00, reads: 4708.94, writes: 1304.98, response time: 123.46ms (95%), errors: 0.00, reconnects:  0.00
[  26s] threads: 32, tps: 318.99, reads: 4360.92, writes: 1260.98, response time: 142.24ms (95%), errors: 0.00, reconnects:  0.00
[  27s] threads: 32, tps: 316.01, reads: 4531.16, writes: 1281.05, response time: 128.56ms (95%), errors: 0.00, reconnects:  0.00
[  28s] threads: 32, tps: 307.00, reads: 4296.94, writes: 1279.98, response time: 163.10ms (95%), errors: 0.00, reconnects:  0.00
[  29s] threads: 32, tps: 293.00, reads: 4101.96, writes: 1156.99, response time: 196.06ms (95%), errors: 0.00, reconnects:  0.00
[  30s] threads: 32, tps: 309.00, reads: 4371.06, writes: 1274.02, response time: 132.46ms (95%), errors: 0.00, reconnects:  0.00
[  31s] threads: 32, tps: 289.00, reads: 3932.93, writes: 1111.98, response time: 206.17ms (95%), errors: 0.00, reconnects:  0.00
[  32s] threads: 32, tps: 334.00, reads: 4695.96, writes: 1307.99, response time: 130.22ms (95%), errors: 0.00, reconnects:  0.00
[  33s] threads: 32, tps: 280.01, reads: 3995.12, writes: 1176.03, response time: 206.73ms (95%), errors: 0.00, reconnects:  0.00
[  34s] threads: 32, tps: 334.00, reads: 4484.98, writes: 1291.99, response time: 142.07ms (95%), errors: 0.00, reconnects:  0.00
[  35s] threads: 32, tps: 319.00, reads: 4671.97, writes: 1322.99, response time: 122.95ms (95%), errors: 0.00, reconnects:  0.00
[  36s] threads: 32, tps: 308.00, reads: 4333.04, writes: 1261.01, response time: 126.72ms (95%), errors: 0.00, reconnects:  0.00
[  37s] threads: 32, tps: 332.97, reads: 4528.63, writes: 1255.90, response time: 156.03ms (95%), errors: 0.00, reconnects:  0.00
[  38s] threads: 32, tps: 336.02, reads: 4702.32, writes: 1304.09, response time: 128.59ms (95%), errors: 0.00, reconnects:  0.00
[  39s] threads: 32, tps: 323.00, reads: 4603.01, writes: 1349.00, response time: 129.99ms (95%), errors: 0.00, reconnects:  0.00
[  40s] threads: 32, tps: 341.91, reads: 4618.82, writes: 1338.66, response time: 130.96ms (95%), errors: 0.00, reconnects:  0.00
[  41s] threads: 32, tps: 305.07, reads: 4395.94, writes: 1218.26, response time: 171.76ms (95%), errors: 0.00, reconnects:  0.00
[  42s] threads: 32, tps: 321.01, reads: 4574.20, writes: 1343.06, response time: 123.02ms (95%), errors: 0.00, reconnects:  0.00
[  43s] threads: 32, tps: 319.01, reads: 4298.11, writes: 1215.03, response time: 141.82ms (95%), errors: 0.00, reconnects:  0.00
[  44s] threads: 32, tps: 314.99, reads: 4544.90, writes: 1282.97, response time: 144.39ms (95%), errors: 0.00, reconnects:  0.00
[  45s] threads: 32, tps: 287.00, reads: 4068.02, writes: 1217.01, response time: 191.77ms (95%), errors: 0.00, reconnects:  0.00
[  46s] threads: 32, tps: 340.98, reads: 4629.77, writes: 1246.94, response time: 135.96ms (95%), errors: 0.00, reconnects:  0.00
[  47s] threads: 32, tps: 325.01, reads: 4626.17, writes: 1306.05, response time: 123.76ms (95%), errors: 0.00, reconnects:  0.00
[  48s] threads: 32, tps: 341.00, reads: 4773.01, writes: 1428.00, response time: 123.24ms (95%), errors: 0.00, reconnects:  0.00
[  49s] threads: 32, tps: 343.00, reads: 4723.06, writes: 1314.02, response time: 120.61ms (95%), errors: 0.00, reconnects:  0.00
[  50s] threads: 32, tps: 328.00, reads: 4604.96, writes: 1352.99, response time: 137.88ms (95%), errors: 0.00, reconnects:  0.00
[  51s] threads: 32, tps: 330.99, reads: 4719.90, writes: 1344.97, response time: 135.92ms (95%), errors: 0.00, reconnects:  0.00
[  52s] threads: 32, tps: 360.00, reads: 4867.04, writes: 1399.01, response time: 123.61ms (95%), errors: 0.00, reconnects:  0.00
[  53s] threads: 32, tps: 298.01, reads: 4214.08, writes: 1208.02, response time: 168.76ms (95%), errors: 0.00, reconnects:  0.00
[  54s] threads: 32, tps: 343.89, reads: 4698.55, writes: 1331.59, response time: 130.07ms (95%), errors: 0.00, reconnects:  0.00
[  55s] threads: 32, tps: 275.08, reads: 4147.25, writes: 1211.37, response time: 185.11ms (95%), errors: 0.00, reconnects:  0.00
[  56s] threads: 32, tps: 309.01, reads: 4289.08, writes: 1182.02, response time: 153.57ms (95%), errors: 0.00, reconnects:  0.00
[  57s] threads: 32, tps: 322.99, reads: 4494.91, writes: 1264.98, response time: 179.28ms (95%), errors: 0.00, reconnects:  0.00
[  58s] threads: 32, tps: 300.00, reads: 4186.94, writes: 1222.98, response time: 154.91ms (95%), errors: 0.00, reconnects:  0.00
[  59s] threads: 32, tps: 335.00, reads: 4638.05, writes: 1286.01, response time: 151.15ms (95%), errors: 0.00, reconnects:  0.00
[  60s] threads: 32, tps: 310.01, reads: 4353.11, writes: 1263.03, response time: 184.89ms (95%), errors: 0.00, reconnects:  0.00
[  61s] threads: 32, tps: 318.99, reads: 4528.81, writes: 1278.95, response time: 168.71ms (95%), errors: 0.00, reconnects:  0.00
[  62s] threads: 32, tps: 337.00, reads: 4681.06, writes: 1338.02, response time: 147.62ms (95%), errors: 0.00, reconnects:  0.00
[  63s] threads: 32, tps: 345.00, reads: 4830.05, writes: 1361.02, response time: 130.69ms (95%), errors: 0.00, reconnects:  0.00
[  64s] threads: 32, tps: 332.00, reads: 4660.98, writes: 1386.99, response time: 123.87ms (95%), errors: 0.00, reconnects:  0.00
[  65s] threads: 32, tps: 317.00, reads: 4494.98, writes: 1300.99, response time: 173.26ms (95%), errors: 0.00, reconnects:  0.00
[  66s] threads: 32, tps: 341.00, reads: 4772.93, writes: 1339.98, response time: 128.52ms (95%), errors: 0.00, reconnects:  0.00
[  67s] threads: 32, tps: 300.01, reads: 4011.18, writes: 1163.05, response time: 140.13ms (95%), errors: 0.00, reconnects:  0.00
[  68s] threads: 32, tps: 309.00, reads: 4331.98, writes: 1222.99, response time: 238.46ms (95%), errors: 0.00, reconnects:  0.00
[  69s] threads: 32, tps: 322.99, reads: 4679.90, writes: 1329.97, response time: 169.26ms (95%), errors: 0.00, reconnects:  0.00
[  70s] threads: 32, tps: 353.93, reads: 4895.04, writes: 1354.73, response time: 118.89ms (95%), errors: 0.00, reconnects:  0.00
[  71s] threads: 32, tps: 339.07, reads: 4717.98, writes: 1373.28, response time: 131.87ms (95%), errors: 0.00, reconnects:  0.00
[  72s] threads: 32, tps: 322.00, reads: 4472.01, writes: 1309.00, response time: 149.71ms (95%), errors: 0.00, reconnects:  0.00
[  73s] threads: 32, tps: 308.00, reads: 4313.95, writes: 1234.99, response time: 146.92ms (95%), errors: 0.00, reconnects:  0.00
[  74s] threads: 32, tps: 335.00, reads: 4647.02, writes: 1307.01, response time: 133.78ms (95%), errors: 0.00, reconnects:  0.00
[  75s] threads: 32, tps: 356.00, reads: 4998.99, writes: 1427.00, response time: 121.78ms (95%), errors: 0.00, reconnects:  0.00
[  76s] threads: 32, tps: 347.00, reads: 4898.01, writes: 1390.00, response time: 124.47ms (95%), errors: 0.00, reconnects:  0.00
[  77s] threads: 32, tps: 353.00, reads: 4987.02, writes: 1425.01, response time: 121.78ms (95%), errors: 0.00, reconnects:  0.00
[  78s] threads: 32, tps: 320.00, reads: 4449.97, writes: 1303.99, response time: 208.91ms (95%), errors: 0.00, reconnects:  0.00
[  79s] threads: 32, tps: 348.00, reads: 4819.00, writes: 1363.00, response time: 122.21ms (95%), errors: 0.00, reconnects:  0.00
[  80s] threads: 32, tps: 297.00, reads: 4221.07, writes: 1220.02, response time: 166.90ms (95%), errors: 0.00, reconnects:  0.00
[  81s] threads: 32, tps: 328.99, reads: 4644.85, writes: 1303.96, response time: 137.80ms (95%), errors: 0.00, reconnects:  0.00
[  82s] threads: 32, tps: 327.97, reads: 4574.64, writes: 1316.90, response time: 148.86ms (95%), errors: 0.00, reconnects:  0.00
[  83s] threads: 32, tps: 344.04, reads: 4840.55, writes: 1351.15, response time: 130.69ms (95%), errors: 0.00, reconnects:  0.00
[  84s] threads: 32, tps: 351.98, reads: 4789.74, writes: 1399.92, response time: 124.80ms (95%), errors: 0.00, reconnects:  0.00
[  85s] threads: 32, tps: 296.01, reads: 4302.14, writes: 1249.04, response time: 166.55ms (95%), errors: 0.00, reconnects:  0.00
[  86s] threads: 32, tps: 332.99, reads: 4558.89, writes: 1279.97, response time: 146.13ms (95%), errors: 0.00, reconnects:  0.00
[  87s] threads: 32, tps: 323.01, reads: 4473.21, writes: 1291.06, response time: 154.86ms (95%), errors: 0.00, reconnects:  0.00
[  88s] threads: 32, tps: 345.00, reads: 4957.94, writes: 1396.98, response time: 129.79ms (95%), errors: 0.00, reconnects:  0.00
[  89s] threads: 32, tps: 327.00, reads: 4489.93, writes: 1285.98, response time: 136.00ms (95%), errors: 0.00, reconnects:  0.00
[  90s] threads: 32, tps: 362.01, reads: 5145.08, writes: 1453.02, response time: 115.08ms (95%), errors: 0.00, reconnects:  0.00
[  91s] threads: 32, tps: 350.00, reads: 4819.95, writes: 1391.99, response time: 142.80ms (95%), errors: 0.00, reconnects:  0.00
[  92s] threads: 32, tps: 310.00, reads: 4515.03, writes: 1325.01, response time: 157.81ms (95%), errors: 0.00, reconnects:  0.00
[  93s] threads: 32, tps: 312.00, reads: 4374.02, writes: 1267.01, response time: 133.26ms (95%), errors: 0.00, reconnects:  0.00
[  94s] threads: 32, tps: 340.00, reads: 4684.99, writes: 1254.00, response time: 222.26ms (95%), errors: 0.00, reconnects:  0.00
[  95s] threads: 32, tps: 349.00, reads: 4889.06, writes: 1410.02, response time: 121.85ms (95%), errors: 0.00, reconnects:  0.00
[  96s] threads: 32, tps: 343.99, reads: 4776.86, writes: 1383.96, response time: 135.47ms (95%), errors: 0.00, reconnects:  0.00
[  97s] threads: 32, tps: 341.01, reads: 4677.12, writes: 1340.04, response time: 136.28ms (95%), errors: 0.00, reconnects:  0.00
[  98s] threads: 32, tps: 313.00, reads: 4432.93, writes: 1280.98, response time: 172.80ms (95%), errors: 0.00, reconnects:  0.00
[  99s] threads: 32, tps: 358.00, reads: 4953.01, writes: 1383.00, response time: 121.81ms (95%), errors: 0.00, reconnects:  0.00
[ 100s] threads: 32, tps: 337.99, reads: 4868.87, writes: 1410.96, response time: 118.18ms (95%), errors: 0.00, reconnects:  0.00
[ 101s] threads: 32, tps: 339.01, reads: 4697.16, writes: 1301.04, response time: 132.66ms (95%), errors: 0.00, reconnects:  0.00
[ 102s] threads: 32, tps: 337.00, reads: 4741.97, writes: 1385.99, response time: 136.73ms (95%), errors: 0.00, reconnects:  0.00
[ 103s] threads: 32, tps: 316.00, reads: 4489.00, writes: 1296.00, response time: 178.95ms (95%), errors: 0.00, reconnects:  0.00
[ 104s] threads: 32, tps: 368.00, reads: 5075.99, writes: 1405.00, response time: 115.46ms (95%), errors: 0.00, reconnects:  0.00
[ 105s] threads: 32, tps: 356.00, reads: 4953.01, writes: 1445.00, response time: 121.81ms (95%), errors: 0.00, reconnects:  0.00
[ 106s] threads: 32, tps: 318.99, reads: 4472.89, writes: 1276.97, response time: 169.36ms (95%), errors: 0.00, reconnects:  0.00
[ 107s] threads: 32, tps: 351.84, reads: 4843.87, writes: 1412.38, response time: 140.00ms (95%), errors: 0.00, reconnects:  0.00
[ 108s] threads: 32, tps: 351.16, reads: 4884.20, writes: 1406.63, response time: 129.83ms (95%), errors: 0.00, reconnects:  0.00
[ 109s] threads: 32, tps: 355.00, reads: 5105.00, writes: 1428.00, response time: 119.86ms (95%), errors: 0.00, reconnects:  0.00
[ 110s] threads: 32, tps: 359.01, reads: 4830.14, writes: 1392.04, response time: 121.09ms (95%), errors: 0.00, reconnects:  0.00
[ 111s] threads: 32, tps: 353.00, reads: 5070.01, writes: 1424.00, response time: 118.72ms (95%), errors: 0.00, reconnects:  0.00
[ 112s] threads: 32, tps: 349.99, reads: 4980.91, writes: 1447.97, response time: 127.10ms (95%), errors: 0.00, reconnects:  0.00
[ 113s] threads: 32, tps: 318.01, reads: 4486.08, writes: 1242.02, response time: 175.66ms (95%), errors: 0.00, reconnects:  0.00
[ 114s] threads: 32, tps: 344.99, reads: 4861.91, writes: 1445.97, response time: 127.10ms (95%), errors: 0.00, reconnects:  0.00
[ 115s] threads: 32, tps: 320.00, reads: 4415.97, writes: 1188.99, response time: 160.05ms (95%), errors: 0.00, reconnects:  0.00
[ 116s] threads: 32, tps: 314.00, reads: 4468.96, writes: 1344.99, response time: 132.82ms (95%), errors: 0.00, reconnects:  0.00
[ 117s] threads: 32, tps: 369.01, reads: 5009.17, writes: 1426.05, response time: 143.18ms (95%), errors: 0.00, reconnects:  0.00
[ 118s] threads: 32, tps: 343.99, reads: 5002.89, writes: 1459.97, response time: 115.73ms (95%), errors: 0.00, reconnects:  0.00
[ 119s] threads: 32, tps: 343.00, reads: 4781.00, writes: 1327.00, response time: 173.21ms (95%), errors: 0.00, reconnects:  0.00
[ 120s] threads: 32, tps: 370.01, reads: 5124.11, writes: 1466.03, response time: 114.87ms (95%), errors: 0.00, reconnects:  0.00
[ 121s] threads: 32, tps: 319.99, reads: 4556.89, writes: 1333.97, response time: 141.48ms (95%), errors: 0.00, reconnects:  0.00
[ 122s] threads: 32, tps: 377.00, reads: 5042.00, writes: 1399.00, response time: 131.95ms (95%), errors: 0.00, reconnects:  0.00
[ 123s] threads: 32, tps: 304.01, reads: 4402.10, writes: 1228.03, response time: 203.54ms (95%), errors: 0.00, reconnects:  0.00
[ 124s] threads: 32, tps: 348.00, reads: 4917.02, writes: 1417.01, response time: 142.12ms (95%), errors: 0.00, reconnects:  0.00
[ 125s] threads: 32, tps: 374.00, reads: 5098.99, writes: 1463.00, response time: 116.78ms (95%), errors: 0.00, reconnects:  0.00
[ 126s] threads: 32, tps: 354.00, reads: 4958.01, writes: 1401.00, response time: 126.49ms (95%), errors: 0.00, reconnects:  0.00
[ 127s] threads: 32, tps: 361.99, reads: 5137.87, writes: 1496.96, response time: 120.36ms (95%), errors: 0.00, reconnects:  0.00
[ 128s] threads: 32, tps: 314.01, reads: 4457.09, writes: 1272.03, response time: 173.00ms (95%), errors: 0.00, reconnects:  0.00
[ 129s] threads: 32, tps: 326.00, reads: 4567.00, writes: 1303.00, response time: 165.95ms (95%), errors: 0.00, reconnects:  0.00
[ 130s] threads: 32, tps: 338.99, reads: 4750.89, writes: 1372.97, response time: 128.29ms (95%), errors: 0.00, reconnects:  0.00
[ 131s] threads: 32, tps: 365.96, reads: 5082.44, writes: 1440.84, response time: 138.59ms (95%), errors: 0.00, reconnects:  0.00
[ 132s] threads: 32, tps: 368.05, reads: 5083.68, writes: 1413.19, response time: 111.78ms (95%), errors: 0.00, reconnects:  0.00
[ 133s] threads: 32, tps: 368.95, reads: 5047.36, writes: 1473.81, response time: 119.97ms (95%), errors: 0.00, reconnects:  0.00
[ 134s] threads: 32, tps: 327.03, reads: 4749.51, writes: 1358.14, response time: 128.98ms (95%), errors: 0.00, reconnects:  0.00
[ 135s] threads: 32, tps: 348.01, reads: 4954.08, writes: 1429.02, response time: 130.69ms (95%), errors: 0.00, reconnects:  0.00
[ 136s] threads: 32, tps: 345.99, reads: 4696.93, writes: 1300.98, response time: 135.96ms (95%), errors: 0.00, reconnects:  0.00
[ 137s] threads: 32, tps: 346.00, reads: 4934.04, writes: 1438.01, response time: 133.86ms (95%), errors: 0.00, reconnects:  0.00
[ 138s] threads: 32, tps: 374.00, reads: 5179.06, writes: 1496.02, response time: 117.20ms (95%), errors: 0.00, reconnects:  0.00
[ 139s] threads: 32, tps: 350.99, reads: 4988.88, writes: 1385.97, response time: 118.72ms (95%), errors: 0.00, reconnects:  0.00
[ 140s] threads: 32, tps: 388.01, reads: 5286.12, writes: 1530.04, response time: 113.50ms (95%), errors: 0.00, reconnects:  0.00
[ 141s] threads: 32, tps: 347.99, reads: 5062.88, writes: 1492.97, response time: 119.11ms (95%), errors: 0.00, reconnects:  0.00
[ 142s] threads: 32, tps: 340.01, reads: 4637.12, writes: 1241.03, response time: 140.21ms (95%), errors: 0.00, reconnects:  0.00
[ 143s] threads: 32, tps: 320.99, reads: 4474.89, writes: 1288.97, response time: 154.73ms (95%), errors: 0.00, reconnects:  0.00
[ 144s] threads: 32, tps: 367.01, reads: 5105.10, writes: 1463.03, response time: 112.12ms (95%), errors: 0.00, reconnects:  0.00
[ 145s] threads: 32, tps: 360.99, reads: 4917.91, writes: 1443.97, response time: 120.40ms (95%), errors: 0.00, reconnects:  0.00
[ 146s] threads: 32, tps: 243.00, reads: 3641.00, writes: 1075.00, response time: 193.67ms (95%), errors: 0.00, reconnects:  0.00
[ 147s] threads: 32, tps: 317.00, reads: 4520.02, writes: 1293.01, response time: 126.72ms (95%), errors: 0.00, reconnects:  0.00
[ 148s] threads: 32, tps: 292.00, reads: 3823.97, writes: 1050.99, response time: 191.19ms (95%), errors: 0.00, reconnects:  0.00
[ 149s] threads: 32, tps: 221.01, reads: 3349.09, writes: 973.03, response time: 226.36ms (95%), errors: 0.00, reconnects:  0.00
[ 150s] threads: 32, tps: 360.99, reads: 4948.92, writes: 1355.98, response time: 116.53ms (95%), errors: 0.00, reconnects:  0.00
[ 151s] threads: 32, tps: 354.79, reads: 4965.10, writes: 1426.17, response time: 120.69ms (95%), errors: 0.00, reconnects:  0.00
[ 152s] threads: 32, tps: 292.17, reads: 4084.35, writes: 1164.67, response time: 194.25ms (95%), errors: 0.00, reconnects:  0.00
[ 153s] threads: 32, tps: 368.01, reads: 5193.12, writes: 1466.03, response time: 109.01ms (95%), errors: 0.00, reconnects:  0.00
[ 154s] threads: 32, tps: 360.00, reads: 5010.93, writes: 1445.98, response time: 118.47ms (95%), errors: 0.00, reconnects:  0.00
[ 155s] threads: 32, tps: 327.00, reads: 4531.95, writes: 1299.98, response time: 175.77ms (95%), errors: 0.00, reconnects:  0.00
[ 156s] threads: 32, tps: 348.99, reads: 4992.89, writes: 1422.97, response time: 125.74ms (95%), errors: 0.00, reconnects:  0.00
[ 157s] threads: 32, tps: 347.02, reads: 4815.23, writes: 1399.07, response time: 135.06ms (95%), errors: 0.00, reconnects:  0.00
[ 158s] threads: 32, tps: 389.00, reads: 5460.00, writes: 1531.00, response time: 107.32ms (95%), errors: 0.00, reconnects:  0.00
[ 159s] threads: 32, tps: 314.00, reads: 4373.00, writes: 1316.00, response time: 146.26ms (95%), errors: 0.00, reconnects:  0.00
[ 160s] threads: 32, tps: 380.99, reads: 5295.90, writes: 1465.97, response time: 112.83ms (95%), errors: 0.00, reconnects:  0.00
[ 161s] threads: 32, tps: 344.01, reads: 4851.08, writes: 1361.02, response time: 128.09ms (95%), errors: 0.00, reconnects:  0.00
[ 162s] threads: 32, tps: 347.00, reads: 4899.94, writes: 1484.98, response time: 129.41ms (95%), errors: 0.00, reconnects:  0.00
[ 163s] threads: 32, tps: 361.00, reads: 5078.00, writes: 1436.00, response time: 126.95ms (95%), errors: 0.00, reconnects:  0.00
[ 164s] threads: 32, tps: 302.00, reads: 4192.04, writes: 1170.01, response time: 179.81ms (95%), errors: 0.00, reconnects:  0.00
[ 165s] threads: 32, tps: 324.00, reads: 4407.02, writes: 1259.01, response time: 185.72ms (95%), errors: 0.00, reconnects:  0.00
[ 166s] threads: 32, tps: 334.00, reads: 4688.01, writes: 1315.00, response time: 147.62ms (95%), errors: 0.00, reconnects:  0.00
[ 167s] threads: 32, tps: 364.00, reads: 5177.99, writes: 1504.00, response time: 118.43ms (95%), errors: 0.00, reconnects:  0.00
[ 168s] threads: 32, tps: 331.00, reads: 4674.01, writes: 1298.00, response time: 140.05ms (95%), errors: 0.00, reconnects:  0.00
[ 169s] threads: 32, tps: 354.96, reads: 4924.44, writes: 1454.83, response time: 136.24ms (95%), errors: 0.00, reconnects:  0.00
[ 170s] threads: 32, tps: 358.03, reads: 5118.49, writes: 1483.14, response time: 118.15ms (95%), errors: 0.00, reconnects:  0.00
[ 171s] threads: 32, tps: 352.00, reads: 4882.95, writes: 1352.99, response time: 132.50ms (95%), errors: 0.00, reconnects:  0.00
[ 172s] threads: 32, tps: 377.01, reads: 5209.15, writes: 1507.04, response time: 107.71ms (95%), errors: 0.00, reconnects:  0.00
[ 173s] threads: 32, tps: 372.98, reads: 5084.79, writes: 1459.94, response time: 117.58ms (95%), errors: 0.00, reconnects:  0.00
[ 174s] threads: 32, tps: 315.01, reads: 4669.11, writes: 1368.03, response time: 136.16ms (95%), errors: 0.00, reconnects:  0.00
[ 175s] threads: 32, tps: 355.00, reads: 4941.03, writes: 1405.01, response time: 147.67ms (95%), errors: 0.00, reconnects:  0.00
[ 176s] threads: 32, tps: 361.00, reads: 5064.04, writes: 1398.01, response time: 118.93ms (95%), errors: 0.00, reconnects:  0.00
[ 177s] threads: 32, tps: 370.00, reads: 5096.01, writes: 1417.00, response time: 120.15ms (95%), errors: 0.00, reconnects:  0.00
[ 178s] threads: 32, tps: 379.00, reads: 5254.02, writes: 1551.01, response time: 111.68ms (95%), errors: 0.00, reconnects:  0.00
[ 179s] threads: 32, tps: 333.99, reads: 4752.86, writes: 1383.96, response time: 150.39ms (95%), errors: 0.00, reconnects:  0.00
[ 180s] threads: 32, tps: 378.00, reads: 5328.00, writes: 1505.00, response time: 107.55ms (95%), errors: 0.00, reconnects:  0.00
[ 181s] threads: 32, tps: 395.01, reads: 5419.13, writes: 1515.04, response time: 106.97ms (95%), errors: 0.00, reconnects:  0.00
[ 182s] threads: 32, tps: 359.95, reads: 5037.36, writes: 1476.81, response time: 126.49ms (95%), errors: 0.00, reconnects:  0.00
[ 183s] threads: 32, tps: 335.03, reads: 4836.50, writes: 1386.14, response time: 127.22ms (95%), errors: 0.00, reconnects:  0.00
[ 184s] threads: 32, tps: 362.01, reads: 4945.12, writes: 1400.03, response time: 129.99ms (95%), errors: 0.00, reconnects:  0.00
[ 185s] threads: 32, tps: 325.99, reads: 4654.88, writes: 1294.97, response time: 133.62ms (95%), errors: 0.00, reconnects:  0.00
[ 186s] threads: 32, tps: 352.00, reads: 4969.03, writes: 1495.01, response time: 120.40ms (95%), errors: 0.00, reconnects:  0.00
[ 187s] threads: 32, tps: 330.00, reads: 4480.00, writes: 1221.00, response time: 180.03ms (95%), errors: 0.00, reconnects:  0.00
[ 188s] threads: 32, tps: 333.99, reads: 4487.83, writes: 1322.95, response time: 170.13ms (95%), errors: 0.00, reconnects:  0.00
[ 189s] threads: 32, tps: 357.02, reads: 5295.31, writes: 1488.09, response time: 119.11ms (95%), errors: 0.00, reconnects:  0.00
[ 190s] threads: 32, tps: 365.98, reads: 5046.71, writes: 1458.92, response time: 141.06ms (95%), errors: 0.00, reconnects:  0.00
[ 191s] threads: 32, tps: 340.01, reads: 4868.21, writes: 1417.06, response time: 113.67ms (95%), errors: 0.00, reconnects:  0.00
[ 192s] threads: 32, tps: 393.00, reads: 5283.04, writes: 1496.01, response time: 175.30ms (95%), errors: 0.00, reconnects:  0.00
[ 193s] threads: 32, tps: 353.00, reads: 5133.03, writes: 1436.01, response time: 125.03ms (95%), errors: 0.00, reconnects:  0.00
[ 194s] threads: 32, tps: 378.90, reads: 5276.55, writes: 1512.58, response time: 122.65ms (95%), errors: 0.00, reconnects:  0.00
[ 195s] threads: 32, tps: 376.10, reads: 5191.42, writes: 1458.40, response time: 115.56ms (95%), errors: 0.00, reconnects:  0.00
[ 196s] threads: 32, tps: 357.99, reads: 5046.86, writes: 1432.96, response time: 112.32ms (95%), errors: 0.00, reconnects:  0.00
[ 197s] threads: 32, tps: 344.01, reads: 4882.15, writes: 1407.04, response time: 127.86ms (95%), errors: 0.00, reconnects:  0.00
[ 198s] threads: 32, tps: 351.99, reads: 4934.84, writes: 1445.95, response time: 130.26ms (95%), errors: 0.00, reconnects:  0.00
[ 199s] threads: 32, tps: 342.01, reads: 4670.11, writes: 1294.03, response time: 163.24ms (95%), errors: 0.00, reconnects:  0.00
[ 200s] threads: 32, tps: 328.00, reads: 4497.00, writes: 1293.00, response time: 183.07ms (95%), errors: 0.00, reconnects:  0.00
[ 201s] threads: 32, tps: 330.99, reads: 4760.92, writes: 1396.98, response time: 166.80ms (95%), errors: 0.00, reconnects:  0.00
[ 202s] threads: 32, tps: 340.00, reads: 4760.00, writes: 1355.00, response time: 134.90ms (95%), errors: 0.00, reconnects:  0.00
[ 203s] threads: 32, tps: 352.00, reads: 4974.02, writes: 1390.01, response time: 134.34ms (95%), errors: 0.00, reconnects:  0.00
[ 204s] threads: 32, tps: 325.00, reads: 4576.07, writes: 1286.02, response time: 163.93ms (95%), errors: 0.00, reconnects:  0.00
[ 205s] threads: 32, tps: 355.00, reads: 4897.01, writes: 1388.00, response time: 119.93ms (95%), errors: 0.00, reconnects:  0.00
[ 206s] threads: 32, tps: 327.00, reads: 4633.00, writes: 1333.00, response time: 137.10ms (95%), errors: 0.00, reconnects:  0.00
[ 207s] threads: 32, tps: 387.00, reads: 5284.02, writes: 1533.01, response time: 113.78ms (95%), errors: 0.00, reconnects:  0.00
[ 208s] threads: 32, tps: 380.00, reads: 5446.96, writes: 1531.99, response time: 111.12ms (95%), errors: 0.00, reconnects:  0.00
[ 209s] threads: 32, tps: 379.99, reads: 5080.91, writes: 1494.97, response time: 115.01ms (95%), errors: 0.00, reconnects:  0.00
[ 210s] threads: 32, tps: 330.00, reads: 4919.03, writes: 1430.01, response time: 140.47ms (95%), errors: 0.00, reconnects:  0.00
[ 211s] threads: 32, tps: 366.00, reads: 4933.98, writes: 1412.99, response time: 119.14ms (95%), errors: 0.00, reconnects:  0.00
[ 212s] threads: 32, tps: 366.01, reads: 5259.11, writes: 1483.03, response time: 137.84ms (95%), errors: 0.00, reconnects:  0.00
[ 213s] threads: 32, tps: 397.99, reads: 5443.87, writes: 1521.96, response time: 107.84ms (95%), errors: 0.00, reconnects:  0.00
[ 214s] threads: 32, tps: 320.00, reads: 4568.04, writes: 1328.01, response time: 199.50ms (95%), errors: 0.00, reconnects:  0.00
[ 215s] threads: 32, tps: 380.00, reads: 5314.05, writes: 1488.01, response time: 115.77ms (95%), errors: 0.00, reconnects:  0.00
[ 216s] threads: 32, tps: 349.00, reads: 4963.03, writes: 1430.01, response time: 126.00ms (95%), errors: 0.00, reconnects:  0.00
[ 217s] threads: 32, tps: 321.99, reads: 4422.89, writes: 1248.97, response time: 185.94ms (95%), errors: 0.00, reconnects:  0.00
[ 218s] threads: 32, tps: 359.00, reads: 5013.03, writes: 1445.01, response time: 162.95ms (95%), errors: 0.00, reconnects:  0.00
[ 219s] threads: 32, tps: 366.00, reads: 5039.96, writes: 1438.99, response time: 115.28ms (95%), errors: 0.00, reconnects:  0.00
[ 220s] threads: 32, tps: 378.01, reads: 5367.14, writes: 1572.04, response time: 107.20ms (95%), errors: 0.00, reconnects:  0.00
[ 221s] threads: 32, tps: 380.99, reads: 5382.83, writes: 1468.95, response time: 109.50ms (95%), errors: 0.00, reconnects:  0.00
[ 222s] threads: 32, tps: 394.01, reads: 5502.16, writes: 1599.05, response time: 106.52ms (95%), errors: 0.00, reconnects:  0.00
[ 223s] threads: 32, tps: 364.99, reads: 5081.88, writes: 1447.97, response time: 127.98ms (95%), errors: 0.00, reconnects:  0.00
[ 224s] threads: 32, tps: 367.01, reads: 5104.12, writes: 1463.04, response time: 123.95ms (95%), errors: 0.00, reconnects:  0.00
[ 225s] threads: 32, tps: 336.00, reads: 4804.99, writes: 1366.00, response time: 154.73ms (95%), errors: 0.00, reconnects:  0.00
[ 226s] threads: 32, tps: 342.99, reads: 4787.86, writes: 1354.96, response time: 176.24ms (95%), errors: 0.00, reconnects:  0.00
[ 227s] threads: 32, tps: 356.00, reads: 5052.06, writes: 1518.02, response time: 113.67ms (95%), errors: 0.00, reconnects:  0.00
[ 228s] threads: 32, tps: 352.00, reads: 4781.99, writes: 1291.00, response time: 151.56ms (95%), errors: 0.00, reconnects:  0.00
[ 229s] threads: 32, tps: 381.00, reads: 5282.99, writes: 1540.00, response time: 109.99ms (95%), errors: 0.00, reconnects:  0.00
[ 230s] threads: 32, tps: 353.98, reads: 4951.72, writes: 1407.92, response time: 127.56ms (95%), errors: 0.00, reconnects:  0.00
[ 231s] threads: 32, tps: 351.02, reads: 5018.32, writes: 1431.09, response time: 136.16ms (95%), errors: 0.00, reconnects:  0.00
[ 232s] threads: 32, tps: 394.01, reads: 5438.09, writes: 1552.03, response time: 105.67ms (95%), errors: 0.00, reconnects:  0.00
[ 233s] threads: 32, tps: 375.94, reads: 5376.12, writes: 1575.74, response time: 112.79ms (95%), errors: 0.00, reconnects:  0.00
[ 234s] threads: 32, tps: 345.05, reads: 4748.70, writes: 1367.20, response time: 157.25ms (95%), errors: 0.00, reconnects:  0.00
[ 235s] threads: 32, tps: 366.00, reads: 4969.96, writes: 1420.99, response time: 146.13ms (95%), errors: 0.00, reconnects:  0.00
[ 236s] threads: 32, tps: 351.00, reads: 5127.01, writes: 1433.00, response time: 120.98ms (95%), errors: 0.00, reconnects:  0.00
[ 237s] threads: 32, tps: 392.01, reads: 5540.13, writes: 1578.04, response time: 105.32ms (95%), errors: 0.00, reconnects:  0.00
[ 238s] threads: 32, tps: 360.00, reads: 4950.01, writes: 1441.00, response time: 126.34ms (95%), errors: 0.00, reconnects:  0.00
[ 239s] threads: 32, tps: 352.99, reads: 4882.83, writes: 1349.95, response time: 140.51ms (95%), errors: 0.00, reconnects:  0.00
[ 240s] threads: 32, tps: 376.01, reads: 5290.08, writes: 1524.02, response time: 118.79ms (95%), errors: 0.00, reconnects:  0.00
[ 241s] threads: 32, tps: 338.00, reads: 4859.00, writes: 1413.00, response time: 145.69ms (95%), errors: 0.00, reconnects:  0.00
[ 242s] threads: 32, tps: 369.00, reads: 5111.00, writes: 1448.00, response time: 120.04ms (95%), errors: 0.00, reconnects:  0.00
[ 243s] threads: 32, tps: 355.00, reads: 5034.06, writes: 1462.02, response time: 133.38ms (95%), errors: 0.00, reconnects:  0.00
[ 244s] threads: 32, tps: 374.99, reads: 5166.93, writes: 1415.98, response time: 122.10ms (95%), errors: 0.00, reconnects:  0.00
[ 245s] threads: 32, tps: 338.01, reads: 4736.08, writes: 1368.02, response time: 132.30ms (95%), errors: 0.00, reconnects:  0.00
[ 246s] threads: 32, tps: 377.99, reads: 5261.93, writes: 1526.98, response time: 120.76ms (95%), errors: 0.00, reconnects:  0.00
[ 247s] threads: 32, tps: 336.01, reads: 4781.07, writes: 1364.02, response time: 174.56ms (95%), errors: 0.00, reconnects:  0.00
[ 248s] threads: 32, tps: 377.00, reads: 5224.01, writes: 1477.00, response time: 118.57ms (95%), errors: 0.00, reconnects:  0.00
[ 249s] threads: 32, tps: 355.00, reads: 5079.96, writes: 1510.99, response time: 115.11ms (95%), errors: 0.00, reconnects:  0.00
[ 250s] threads: 32, tps: 377.96, reads: 5149.49, writes: 1417.86, response time: 140.38ms (95%), errors: 0.00, reconnects:  0.00
[ 251s] threads: 32, tps: 338.03, reads: 4851.43, writes: 1387.12, response time: 188.52ms (95%), errors: 0.00, reconnects:  0.00
[ 252s] threads: 32, tps: 366.01, reads: 4935.11, writes: 1395.03, response time: 169.62ms (95%), errors: 0.00, reconnects:  0.00
[ 253s] threads: 32, tps: 316.99, reads: 4639.88, writes: 1379.96, response time: 158.86ms (95%), errors: 0.00, reconnects:  0.00
[ 254s] threads: 32, tps: 386.00, reads: 5337.01, writes: 1465.00, response time: 117.48ms (95%), errors: 0.00, reconnects:  0.00
[ 255s] threads: 32, tps: 343.00, reads: 4792.01, writes: 1370.00, response time: 183.79ms (95%), errors: 0.00, reconnects:  0.00
[ 256s] threads: 32, tps: 408.94, reads: 5645.21, writes: 1616.77, response time: 105.10ms (95%), errors: 0.00, reconnects:  0.00
[ 257s] threads: 32, tps: 359.06, reads: 5139.80, writes: 1487.23, response time: 121.70ms (95%), errors: 0.00, reconnects:  0.00
[ 258s] threads: 32, tps: 387.97, reads: 5441.53, writes: 1527.87, response time: 108.94ms (95%), errors: 0.00, reconnects:  0.00
[ 259s] threads: 32, tps: 388.03, reads: 5408.37, writes: 1597.11, response time: 107.49ms (95%), errors: 0.00, reconnects:  0.00
[ 260s] threads: 32, tps: 363.00, reads: 5100.98, writes: 1415.99, response time: 125.93ms (95%), errors: 0.00, reconnects:  0.00
[ 261s] threads: 32, tps: 405.01, reads: 5593.13, writes: 1587.04, response time: 107.29ms (95%), errors: 0.00, reconnects:  0.00
[ 262s] threads: 32, tps: 388.88, reads: 5202.41, writes: 1540.53, response time: 147.71ms (95%), errors: 0.00, reconnects:  0.00
[ 263s] threads: 32, tps: 379.11, reads: 5549.63, writes: 1588.47, response time: 109.20ms (95%), errors: 0.00, reconnects:  0.00
[ 264s] threads: 32, tps: 345.00, reads: 4955.98, writes: 1436.00, response time: 128.21ms (95%), errors: 0.00, reconnects:  0.00
[ 265s] threads: 32, tps: 387.01, reads: 5352.08, writes: 1440.02, response time: 120.69ms (95%), errors: 0.00, reconnects:  0.00
[ 266s] threads: 32, tps: 401.98, reads: 5456.79, writes: 1587.94, response time: 111.58ms (95%), errors: 0.00, reconnects:  0.00
[ 267s] threads: 32, tps: 363.00, reads: 5267.05, writes: 1543.02, response time: 116.74ms (95%), errors: 0.00, reconnects:  0.00
[ 268s] threads: 32, tps: 358.01, reads: 4943.15, writes: 1361.04, response time: 174.82ms (95%), errors: 0.00, reconnects:  0.00
[ 269s] threads: 32, tps: 375.99, reads: 5368.85, writes: 1580.95, response time: 109.43ms (95%), errors: 0.00, reconnects:  0.00
[ 270s] threads: 32, tps: 407.00, reads: 5591.01, writes: 1536.00, response time: 113.16ms (95%), errors: 0.00, reconnects:  0.00
[ 271s] threads: 32, tps: 388.00, reads: 5447.05, writes: 1579.01, response time: 105.19ms (95%), errors: 0.00, reconnects:  0.00
[ 272s] threads: 32, tps: 344.99, reads: 4747.80, writes: 1390.94, response time: 147.80ms (95%), errors: 0.00, reconnects:  0.00
[ 273s] threads: 32, tps: 343.01, reads: 4918.14, writes: 1377.04, response time: 149.09ms (95%), errors: 0.00, reconnects:  0.00
[ 274s] threads: 32, tps: 337.00, reads: 4764.07, writes: 1397.02, response time: 127.67ms (95%), errors: 0.00, reconnects:  0.00
[ 275s] threads: 32, tps: 390.99, reads: 5451.89, writes: 1510.97, response time: 118.33ms (95%), errors: 0.00, reconnects:  0.00
[ 276s] threads: 32, tps: 336.00, reads: 4754.00, writes: 1428.00, response time: 167.95ms (95%), errors: 0.00, reconnects:  0.00
[ 277s] threads: 32, tps: 320.01, reads: 4231.13, writes: 1152.04, response time: 156.50ms (95%), errors: 0.00, reconnects:  0.00
[ 278s] threads: 32, tps: 349.99, reads: 5044.91, writes: 1443.97, response time: 117.34ms (95%), errors: 0.00, reconnects:  0.00
[ 279s] threads: 32, tps: 392.00, reads: 5502.04, writes: 1562.01, response time: 109.34ms (95%), errors: 0.00, reconnects:  0.00
[ 280s] threads: 32, tps: 396.00, reads: 5592.97, writes: 1574.99, response time: 112.89ms (95%), errors: 0.00, reconnects:  0.00
[ 281s] threads: 32, tps: 393.00, reads: 5416.94, writes: 1603.98, response time: 114.87ms (95%), errors: 0.00, reconnects:  0.00
[ 282s] threads: 32, tps: 373.01, reads: 5323.09, writes: 1533.03, response time: 115.25ms (95%), errors: 0.00, reconnects:  0.00
[ 283s] threads: 32, tps: 365.00, reads: 4963.98, writes: 1403.00, response time: 121.01ms (95%), errors: 0.00, reconnects:  0.00
[ 284s] threads: 32, tps: 294.95, reads: 4124.28, writes: 1178.79, response time: 163.58ms (95%), errors: 0.00, reconnects:  0.00
[ 285s] threads: 32, tps: 370.06, reads: 5205.90, writes: 1499.26, response time: 114.77ms (95%), errors: 0.00, reconnects:  0.00
[ 286s] threads: 32, tps: 389.01, reads: 5550.11, writes: 1546.03, response time: 108.03ms (95%), errors: 0.00, reconnects:  0.00
[ 287s] threads: 32, tps: 336.00, reads: 4502.95, writes: 1298.99, response time: 217.13ms (95%), errors: 0.00, reconnects:  0.00
[ 288s] threads: 32, tps: 337.00, reads: 4908.93, writes: 1355.98, response time: 144.00ms (95%), errors: 0.00, reconnects:  0.00
[ 289s] threads: 32, tps: 384.96, reads: 5382.48, writes: 1557.85, response time: 115.87ms (95%), errors: 0.00, reconnects:  0.00
[ 290s] threads: 32, tps: 344.04, reads: 4781.50, writes: 1360.14, response time: 175.24ms (95%), errors: 0.00, reconnects:  0.00
[ 291s] threads: 32, tps: 385.00, reads: 5367.99, writes: 1584.00, response time: 109.76ms (95%), errors: 0.00, reconnects:  0.00
[ 292s] threads: 32, tps: 375.00, reads: 5371.01, writes: 1564.00, response time: 104.07ms (95%), errors: 0.00, reconnects:  0.00
[ 293s] threads: 32, tps: 405.99, reads: 5578.89, writes: 1512.97, response time: 122.29ms (95%), errors: 0.00, reconnects:  0.00
[ 294s] threads: 32, tps: 377.79, reads: 5239.15, writes: 1512.18, response time: 114.73ms (95%), errors: 0.00, reconnects:  0.00
[ 295s] threads: 32, tps: 377.22, reads: 5375.13, writes: 1586.92, response time: 113.37ms (95%), errors: 0.00, reconnects:  0.00
[ 296s] threads: 32, tps: 320.00, reads: 4337.98, writes: 1201.99, response time: 167.85ms (95%), errors: 0.00, reconnects:  0.00
[ 297s] threads: 32, tps: 359.97, reads: 4927.64, writes: 1430.90, response time: 126.00ms (95%), errors: 0.00, reconnects:  0.00
[ 298s] threads: 32, tps: 374.03, reads: 5461.39, writes: 1568.11, response time: 110.98ms (95%), errors: 0.00, reconnects:  0.00
[ 299s] threads: 32, tps: 371.96, reads: 5235.40, writes: 1428.84, response time: 115.25ms (95%), errors: 0.00, reconnects:  0.00
[ 300s] threads: 32, tps: 389.04, reads: 5288.52, writes: 1556.15, response time: 110.52ms (95%), errors: 0.00, reconnects:  0.00
[ 301s] threads: 32, tps: 315.99, reads: 4350.84, writes: 1253.95, response time: 165.51ms (95%), errors: 0.00, reconnects:  0.00
[ 302s] threads: 32, tps: 331.01, reads: 4778.19, writes: 1318.05, response time: 161.20ms (95%), errors: 0.00, reconnects:  0.00
[ 303s] threads: 32, tps: 380.00, reads: 5329.02, writes: 1565.01, response time: 111.08ms (95%), errors: 0.00, reconnects:  0.00
[ 304s] threads: 32, tps: 376.00, reads: 5347.96, writes: 1492.99, response time: 122.58ms (95%), errors: 0.00, reconnects:  0.00
[ 305s] threads: 32, tps: 400.99, reads: 5589.88, writes: 1597.96, response time: 112.02ms (95%), errors: 0.00, reconnects:  0.00
[ 306s] threads: 32, tps: 377.02, reads: 5279.22, writes: 1496.06, response time: 115.49ms (95%), errors: 0.00, reconnects:  0.00
[ 307s] threads: 32, tps: 362.97, reads: 5040.65, writes: 1475.90, response time: 122.62ms (95%), errors: 0.00, reconnects:  0.00
[ 308s] threads: 32, tps: 380.02, reads: 5385.29, writes: 1523.08, response time: 112.69ms (95%), errors: 0.00, reconnects:  0.00
[ 309s] threads: 32, tps: 383.99, reads: 5311.92, writes: 1503.98, response time: 124.35ms (95%), errors: 0.00, reconnects:  0.00
[ 310s] threads: 32, tps: 381.00, reads: 5280.01, writes: 1532.00, response time: 109.43ms (95%), errors: 0.00, reconnects:  0.00
[ 311s] threads: 32, tps: 331.97, reads: 4788.55, writes: 1365.87, response time: 181.60ms (95%), errors: 0.00, reconnects:  0.00
[ 312s] threads: 32, tps: 367.04, reads: 5164.52, writes: 1507.15, response time: 118.61ms (95%), errors: 0.00, reconnects:  0.00
[ 313s] threads: 32, tps: 362.00, reads: 4896.05, writes: 1354.01, response time: 179.54ms (95%), errors: 0.00, reconnects:  0.00
[ 314s] threads: 32, tps: 338.00, reads: 4817.06, writes: 1383.02, response time: 147.31ms (95%), errors: 0.00, reconnects:  0.00
[ 315s] threads: 32, tps: 381.99, reads: 5402.88, writes: 1582.96, response time: 109.27ms (95%), errors: 0.00, reconnects:  0.00
[ 316s] threads: 32, tps: 401.00, reads: 5372.02, writes: 1518.00, response time: 109.86ms (95%), errors: 0.00, reconnects:  0.00
[ 317s] threads: 32, tps: 249.00, reads: 3766.02, writes: 1118.01, response time: 186.11ms (95%), errors: 0.00, reconnects:  0.00
[ 318s] threads: 32, tps: 298.99, reads: 4024.91, writes: 1131.97, response time: 153.11ms (95%), errors: 0.00, reconnects:  0.00
[ 319s] threads: 32, tps: 269.01, reads: 3866.09, writes: 1030.02, response time: 165.80ms (95%), errors: 0.00, reconnects:  0.00
[ 320s] threads: 32, tps: 248.00, reads: 3289.98, writes: 977.99, response time: 177.67ms (95%), errors: 0.00, reconnects:  0.00
[ 321s] threads: 32, tps: 220.00, reads: 3314.98, writes: 969.00, response time: 285.97ms (95%), errors: 0.00, reconnects:  0.00
[ 322s] threads: 32, tps: 246.01, reads: 3318.09, writes: 970.03, response time: 159.19ms (95%), errors: 0.00, reconnects:  0.00
[ 323s] threads: 32, tps: 255.00, reads: 3700.93, writes: 1064.98, response time: 174.93ms (95%), errors: 0.00, reconnects:  0.00
[ 324s] threads: 32, tps: 272.00, reads: 3558.00, writes: 992.00, response time: 200.09ms (95%), errors: 0.00, reconnects:  0.00
[ 325s] threads: 32, tps: 219.00, reads: 3297.02, writes: 935.01, response time: 218.11ms (95%), errors: 0.00, reconnects:  0.00
[ 326s] threads: 32, tps: 268.00, reads: 3771.97, writes: 1100.99, response time: 162.66ms (95%), errors: 0.00, reconnects:  0.00
[ 327s] threads: 32, tps: 179.00, reads: 2508.02, writes: 728.00, response time: 217.91ms (95%), errors: 0.00, reconnects:  0.00
[ 328s] threads: 32, tps: 280.00, reads: 3692.02, writes: 1004.01, response time: 196.65ms (95%), errors: 0.00, reconnects:  0.00
[ 329s] threads: 32, tps: 265.00, reads: 3897.93, writes: 1143.98, response time: 181.22ms (95%), errors: 0.00, reconnects:  0.00
[ 330s] threads: 32, tps: 275.00, reads: 3890.06, writes: 1132.02, response time: 151.93ms (95%), errors: 0.00, reconnects:  0.00
[ 331s] threads: 32, tps: 243.00, reads: 3401.97, writes: 970.99, response time: 179.92ms (95%), errors: 0.00, reconnects:  0.00
[ 332s] threads: 32, tps: 289.01, reads: 3886.08, writes: 1081.02, response time: 178.31ms (95%), errors: 0.00, reconnects:  0.00
[ 333s] threads: 32, tps: 211.00, reads: 3005.97, writes: 795.99, response time: 209.85ms (95%), errors: 0.00, reconnects:  0.00
[ 334s] threads: 32, tps: 211.00, reads: 3061.94, writes: 966.98, response time: 176.19ms (95%), errors: 0.00, reconnects:  0.00
[ 335s] threads: 32, tps: 206.00, reads: 2884.02, writes: 825.01, response time: 244.17ms (95%), errors: 0.00, reconnects:  0.00
[ 336s] threads: 32, tps: 246.00, reads: 3365.99, writes: 936.00, response time: 181.00ms (95%), errors: 0.00, reconnects:  0.00
[ 337s] threads: 32, tps: 225.00, reads: 3228.02, writes: 948.01, response time: 178.15ms (95%), errors: 0.00, reconnects:  0.00
[ 338s] threads: 32, tps: 218.99, reads: 2897.87, writes: 827.96, response time: 378.11ms (95%), errors: 0.00, reconnects:  0.00
[ 339s] threads: 32, tps: 222.01, reads: 3274.11, writes: 932.03, response time: 198.54ms (95%), errors: 0.00, reconnects:  0.00
[ 340s] threads: 32, tps: 237.01, reads: 3306.10, writes: 899.03, response time: 204.21ms (95%), errors: 0.00, reconnects:  0.00
[ 341s] threads: 32, tps: 274.00, reads: 3849.97, writes: 1139.99, response time: 169.16ms (95%), errors: 0.00, reconnects:  0.00
[ 342s] threads: 32, tps: 232.98, reads: 3032.74, writes: 844.93, response time: 199.56ms (95%), errors: 0.00, reconnects:  0.00
[ 343s] threads: 32, tps: 216.02, reads: 3253.26, writes: 959.08, response time: 182.91ms (95%), errors: 0.00, reconnects:  0.00
[ 344s] threads: 32, tps: 242.99, reads: 3401.90, writes: 972.97, response time: 201.17ms (95%), errors: 0.00, reconnects:  0.00
[ 345s] threads: 32, tps: 292.01, reads: 3945.17, writes: 1044.04, response time: 192.86ms (95%), errors: 0.00, reconnects:  0.00
[ 346s] threads: 32, tps: 225.00, reads: 3292.97, writes: 1023.99, response time: 185.67ms (95%), errors: 0.00, reconnects:  0.00
[ 347s] threads: 32, tps: 261.00, reads: 3520.97, writes: 959.99, response time: 190.85ms (95%), errors: 0.00, reconnects:  0.00
[ 348s] threads: 32, tps: 208.00, reads: 3045.01, writes: 914.00, response time: 214.29ms (95%), errors: 0.00, reconnects:  0.00
[ 349s] threads: 32, tps: 208.00, reads: 2902.95, writes: 787.99, response time: 221.40ms (95%), errors: 0.00, reconnects:  0.00
[ 350s] threads: 32, tps: 246.01, reads: 3240.11, writes: 902.03, response time: 203.05ms (95%), errors: 0.00, reconnects:  0.00
[ 351s] threads: 32, tps: 203.00, reads: 2903.94, writes: 811.98, response time: 243.22ms (95%), errors: 0.00, reconnects:  0.00
[ 352s] threads: 32, tps: 249.00, reads: 3637.01, writes: 1124.00, response time: 182.63ms (95%), errors: 0.00, reconnects:  0.00
[ 353s] threads: 32, tps: 258.99, reads: 3625.86, writes: 1034.96, response time: 171.05ms (95%), errors: 0.00, reconnects:  0.00
[ 354s] threads: 32, tps: 259.01, reads: 3626.08, writes: 1036.02, response time: 181.65ms (95%), errors: 0.00, reconnects:  0.00
[ 355s] threads: 32, tps: 258.00, reads: 3611.06, writes: 1019.02, response time: 211.04ms (