MySQL – 但行好事 莫问前程 http://www.jydba.net Fri, 26 Apr 2024 01:44:00 +0000 zh-CN hourly 1 https://wordpress.org/?v=4.9.10 MySQL Innodb 数据文件头损坏的恢复 http://www.jydba.net/index.php/archives/3556 http://www.jydba.net/index.php/archives/3556#respond Fri, 26 Apr 2024 01:44:00 +0000 http://www.jydba.net/?p=3556 一.数据头损坏
1:观察日志
数据库启动失败,同时查看日志文件中出现头文件校验时出现报错

[root@localhost soft]# service mysqld start

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

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

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

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

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

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

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

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

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

5:修改fsb header 中的space id

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

再检查确认是否修改正确

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

6:启动恢复

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

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

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

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

4:编译

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

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

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

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

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

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

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

2:确认硬盘分区

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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


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

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

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

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

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

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

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

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

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

到此数据已经恢复了。

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

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

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

4:编译

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

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

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

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

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

Database changed

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

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

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


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

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

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

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

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

3:确认硬盘分区

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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




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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

mysql> use dbrecover
Database changed

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

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.01 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

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

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.01 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.01 sec)

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

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

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

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.01 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

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

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.01 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

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

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.01 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

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

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.01 sec)

Query OK, 0 rows affected (0.00 sec)

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

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.01 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

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

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

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

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

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

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.01 sec)

Query OK, 0 rows affected (0.01 sec)

Query OK, 0 rows affected (0.00 sec)

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

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

mysql> use dbrecover
Database changed

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

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

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

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

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


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

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

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

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

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

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

至此数据恢复了。

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

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

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

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

在Windows上,stderr被定向到默认日志文件,除非另有配置。如果您希望将输出定向到控制台窗口而不是错误日志,请使用–console选项从控制台窗口的命令提示符启动服务器。

在Unix和类Unix系统上,stderr通常被定向到终端,除非另有配置。

当启用时,InnoDB监控大约每15秒打印一次数据。这些数据在性能调优中很有用。作为副作用,SHOW ENGINE INNODB STATUS的输出每15秒写入MySQL数据目录中的状态文件。文件名为innodb_status.pid,其中pid是服务器进程ID。InnoDB在服务器正常关闭时删除文件。如果发生了异常关机,则可能存在这些状态文件的实例,必须手动删除。在删除文件之前,检查它们是否包含有关异常关机原因的有用信息。一个innodb_status.pid只有启用了innodb-status-file配置选项,才会创建。默认关闭。

InnoDB监控器应该只在你真正想要查看监控器信息时才启用,因为输出的生成会导致一些性能下降。此外,如果监视器输出指向错误日志,如果您稍后忘记禁用监视器,则日志可能会变得相当大。

注意:
为了辅助故障诊断,在某些条件下,InnoDB临时启用了标准的InnoDB监视器输出。

InnoDB监视器输出以一个包含时间戳和监视器名称的报头开始。例如:

=====================================
2024-01-15 16:50:33 0x7f3e8c201700 INNODB MONITOR OUTPUT
=====================================

标准InnoDB监控器的首部(InnoDB监控器输出)也用于锁监控器,因为后者产生了相同的输出,但添加了额外的锁信息。

innodb_status_output和innodb_status_output_locks系统变量用于启用标准的InnoDB监视器和InnoDB锁监视器。

启用或禁用InnoDB监视器需要PROCESS特权。

启用标准InnoDB监视器
通过将innodb_status_output系统变量设置为ON来启用标准InnoDB监视器。

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

mysql> show variables like '%innodb_status_output%';
+----------------------------+-------+
| Variable_name              | Value |
+----------------------------+-------+
| innodb_status_output       | ON    |
| innodb_status_output_locks | OFF   |
+----------------------------+-------+
2 rows in set (0.01 sec)

关闭标准的InnoDB Monitor,将innodb_status_output设置为OFF。

当您关闭服务器时,innodb_status_output变量被设置为默认的OFF值。

按需获取标准的InnoDB监控器输出
作为启用标准InnoDB监控器周期性输出的替代方案,您可以使用SHOW ENGINE INNODB STATUS SQL语句按需获取标准InnoDB监控器输出,该语句将输出获取到您的客户端程序。如果你使用的是mysql交互式客户端,将通常的分号语句结束符替换为\G,输出的可读性会更好:

mysql> SHOW ENGINE INNODB STATUS\G
*************************** 1. row ***************************
  Type: InnoDB
  Name:
Status:
=====================================
2024-01-15 16:50:33 0x7f3e8c201700 INNODB MONITOR OUTPUT
=====================================
Per second averages calculated from the last 8 seconds
-----------------
BACKGROUND THREAD
-----------------
srv_master_thread loops: 27 srv_active, 0 srv_shutdown, 427925 srv_idle
srv_master_thread log flush and writes: 427940
----------
SEMAPHORES
----------
OS WAIT ARRAY INFO: reservation count 15736
OS WAIT ARRAY INFO: signal count 1770
RW-shared spins 0, rounds 18523, OS waits 12422
RW-excl spins 0, rounds 32549, OS waits 1086
RW-sx spins 1768, rounds 50702, OS waits 1607
Spin rounds per wait: 18523.00 RW-shared, 32549.00 RW-excl, 28.68 RW-sx
------------
TRANSACTIONS
------------
Trx id counter 5697073
Purge done for trx's n:o < 5697071 undo n:o < 0 state: running but idle
History list length 70
LIST OF TRANSACTIONS FOR EACH SESSION:
---TRANSACTION 421390708152144, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
--------
FILE I/O
--------
I/O thread 0 state: waiting for i/o request (insert buffer thread)
I/O thread 1 state: waiting for i/o request (log thread)
I/O thread 2 state: waiting for i/o request (read thread)
I/O thread 3 state: waiting for i/o request (read thread)
I/O thread 4 state: waiting for i/o request (read thread)
I/O thread 5 state: waiting for i/o request (read thread)
I/O thread 6 state: waiting for i/o request (write thread)
I/O thread 7 state: waiting for i/o request (write thread)
I/O thread 8 state: waiting for i/o request (write thread)
I/O thread 9 state: waiting for i/o request (write thread)
Pending normal aio reads: [0, 0, 0, 0] , aio writes: [0, 0, 0, 0] ,
 ibuf aio reads:, log i/o's:, sync i/o's:
Pending flushes (fsync) log: 0; buffer pool: 0
141 OS file reads, 4062 OS file writes, 3289 OS fsyncs
0.00 reads/s, 0 avg bytes/read, 0.00 writes/s, 0.00 fsyncs/s
-------------------------------------
INSERT BUFFER AND ADAPTIVE HASH INDEX
-------------------------------------
Ibuf: size 1, free list len 1714, seg size 1716, 0 merges
merged operations:
 insert 0, delete mark 0, delete 0
discarded operations:
 insert 0, delete mark 0, delete 0
Hash table size 2365241, node heap has 0 buffer(s)
Hash table size 2365241, node heap has 0 buffer(s)
Hash table size 2365241, node heap has 0 buffer(s)
Hash table size 2365241, node heap has 0 buffer(s)
Hash table size 2365241, node heap has 0 buffer(s)
Hash table size 2365241, node heap has 0 buffer(s)
Hash table size 2365241, node heap has 0 buffer(s)
Hash table size 2365241, node heap has 0 buffer(s)
0.00 hash searches/s, 0.00 non-hash searches/s
---
LOG
---
Log sequence number 89430260246
Log flushed up to   89430260246
Pages flushed up to 89430260246
Last checkpoint at  89430260237
0 pending log flushes, 0 pending chkp writes
2662 log i/o's done, 0.00 log i/o's/second
----------------------
BUFFER POOL AND MEMORY
----------------------
Total large memory allocated 8795455488
Dictionary memory allocated 234968
Buffer pool size   524224
Free buffers       523545
Database pages     685
Old database pages 0
Modified db pages  0
Pending reads      0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 0, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 96, created 589, written 893
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
No buffer pool page gets since the last printout
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 685, unzip_LRU len: 0
I/O sum[0]:cur[0], unzip sum[0]:cur[0]
----------------------
INDIVIDUAL BUFFER POOL INFO
----------------------
---BUFFER POOL 0
Buffer pool size   65528
Free buffers       65456
Database pages     78
Old database pages 0
Modified db pages  0
Pending reads      0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 0, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 31, created 47, written 131
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
No buffer pool page gets since the last printout
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 78, unzip_LRU len: 0
I/O sum[0]:cur[0], unzip sum[0]:cur[0]
---BUFFER POOL 1
Buffer pool size   65528
Free buffers       65391
Database pages     137
Old database pages 0
Modified db pages  0
Pending reads      0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 0, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 11, created 126, written 367
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
No buffer pool page gets since the last printout
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 137, unzip_LRU len: 0
I/O sum[0]:cur[0], unzip sum[0]:cur[0]
---BUFFER POOL 2
Buffer pool size   65528
Free buffers       65413
Database pages     115
Old database pages 0
Modified db pages  0
Pending reads      0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 0, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 8, created 107, written 166
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
No buffer pool page gets since the last printout
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 115, unzip_LRU len: 0
I/O sum[0]:cur[0], unzip sum[0]:cur[0]
---BUFFER POOL 3
Buffer pool size   65528
Free buffers       65406
Database pages     122
Old database pages 0
Modified db pages  0
Pending reads      0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 0, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 13, created 109, written 182
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
No buffer pool page gets since the last printout
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 122, unzip_LRU len: 0
I/O sum[0]:cur[0], unzip sum[0]:cur[0]
---BUFFER POOL 4
Buffer pool size   65528
Free buffers       65463
Database pages     65
Old database pages 0
Modified db pages  0
Pending reads      0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 0, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 8, created 57, written 16
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
No buffer pool page gets since the last printout
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 65, unzip_LRU len: 0
I/O sum[0]:cur[0], unzip sum[0]:cur[0]
---BUFFER POOL 5
Buffer pool size   65528
Free buffers       65469
Database pages     59
Old database pages 0
Modified db pages  0
Pending reads      0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 0, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 9, created 50, written 11
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
No buffer pool page gets since the last printout
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 59, unzip_LRU len: 0
I/O sum[0]:cur[0], unzip sum[0]:cur[0]
---BUFFER POOL 6
Buffer pool size   65528
Free buffers       65470
Database pages     58
Old database pages 0
Modified db pages  0
Pending reads      0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 0, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 9, created 49, written 10
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
No buffer pool page gets since the last printout
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 58, unzip_LRU len: 0
I/O sum[0]:cur[0], unzip sum[0]:cur[0]
---BUFFER POOL 7
Buffer pool size   65528
Free buffers       65477
Database pages     51
Old database pages 0
Modified db pages  0
Pending reads      0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 0, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 7, created 44, written 10
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
No buffer pool page gets since the last printout
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 51, unzip_LRU len: 0
I/O sum[0]:cur[0], unzip sum[0]:cur[0]
--------------
ROW OPERATIONS
--------------
0 queries inside InnoDB, 0 queries in queue
0 read views open inside InnoDB
Process ID=10759, Main thread ID=139906706892544, state: sleeping
Number of rows inserted 5990, updated 0, deleted 0, read 1794460
0.00 inserts/s, 0.00 updates/s, 0.00 deletes/s, 0.00 reads/s
----------------------------
END OF INNODB MONITOR OUTPUT
============================

1 row in set (0.00 sec)

如果启用了InnoDB锁监视器, SHOW ENGINE INNODB STATUS输出还包括InnoDB锁监视器数据。

启用InnoDB锁监视器
InnoDB锁监控器数据与InnoDB标准监控器输出一起打印。InnoDB标准监控器和InnoDB锁监控器都必须启用,才能定期打印InnoDB锁监控器数据。

开启InnoDB锁监控,设置innodb_status_output_locks系统变量为ON。InnoDB标准监控器和InnoDB锁监控器都必须启用,以便定期打印InnoDB锁监控器数据:

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

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

mysql> show variables like '%innodb_status_output%';
+----------------------------+-------+
| Variable_name              | Value |
+----------------------------+-------+
| innodb_status_output       | ON    |
| innodb_status_output_locks | ON    |
+----------------------------+-------+
2 rows in set (0.00 sec)

要禁用InnoDB锁监控,将innodb_status_output_locks设置为OFF。将innodb_status_output设置为OFF也禁用InnoDB标准监视器。

当你关闭服务器时,innodb_status_output和innodb_status_output_locks变量被设置为默认的OFF值。

注意:
为SHOW ENGINE INNODB STATUS输出启用InnoDB锁监视器,只需要启用innodb_status_output_locks。

InnoDB标准监视器和锁监视器输出
锁监视器与标准监视器相同,只是它包含了额外的锁信息。

为周期性输出启用任一监视器都会打开相同的输出流,但如果启用了Lock monitor,则该流将包含额外的信息。例如,如果您启用了标准监控和锁定监视器,它打开单个输出流。在禁用锁监视器之前,流包含额外的锁信息。

当使用SHOW ENGINE INNODB STATUS语句生成时,标准Monitor输出限制为1MB。此限制不适用于写入tserver标准错误输出(stderr)的输出。

标准监视器输出示例:

mysql> SHOW ENGINE INNODB STATUS\G
*************************** 1. row ***************************
  Type: InnoDB
  Name:
Status:
=====================================
2024-01-15 17:08:03 0x7f3e8c201700 INNODB MONITOR OUTPUT
=====================================
Per second averages calculated from the last 18 seconds
-----------------
BACKGROUND THREAD
-----------------
srv_master_thread loops: 27 srv_active, 0 srv_shutdown, 428975 srv_idle
srv_master_thread log flush and writes: 428990
----------
SEMAPHORES
----------
OS WAIT ARRAY INFO: reservation count 15736
OS WAIT ARRAY INFO: signal count 1770
RW-shared spins 0, rounds 18523, OS waits 12422
RW-excl spins 0, rounds 32549, OS waits 1086
RW-sx spins 1768, rounds 50702, OS waits 1607
Spin rounds per wait: 18523.00 RW-shared, 32549.00 RW-excl, 28.68 RW-sx
------------
TRANSACTIONS
------------
Trx id counter 5697073
Purge done for trx's n:o < 5697071 undo n:o < 0 state: running but idle
History list length 70
LIST OF TRANSACTIONS FOR EACH SESSION:
---TRANSACTION 421390708152144, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
--------
FILE I/O
--------
I/O thread 0 state: waiting for i/o request (insert buffer thread)
I/O thread 1 state: waiting for i/o request (log thread)
I/O thread 2 state: waiting for i/o request (read thread)
I/O thread 3 state: waiting for i/o request (read thread)
I/O thread 4 state: waiting for i/o request (read thread)
I/O thread 5 state: waiting for i/o request (read thread)
I/O thread 6 state: waiting for i/o request (write thread)
I/O thread 7 state: waiting for i/o request (write thread)
I/O thread 8 state: waiting for i/o request (write thread)
I/O thread 9 state: waiting for i/o request (write thread)
Pending normal aio reads: [0, 0, 0, 0] , aio writes: [0, 0, 0, 0] ,
 ibuf aio reads:, log i/o's:, sync i/o's:
Pending flushes (fsync) log: 0; buffer pool: 0
141 OS file reads, 4062 OS file writes, 3289 OS fsyncs
0.00 reads/s, 0 avg bytes/read, 0.00 writes/s, 0.00 fsyncs/s
-------------------------------------
INSERT BUFFER AND ADAPTIVE HASH INDEX
-------------------------------------
Ibuf: size 1, free list len 1714, seg size 1716, 0 merges
merged operations:
 insert 0, delete mark 0, delete 0
discarded operations:
 insert 0, delete mark 0, delete 0
Hash table size 2365241, node heap has 0 buffer(s)
Hash table size 2365241, node heap has 0 buffer(s)
Hash table size 2365241, node heap has 0 buffer(s)
Hash table size 2365241, node heap has 0 buffer(s)
Hash table size 2365241, node heap has 0 buffer(s)
Hash table size 2365241, node heap has 0 buffer(s)
Hash table size 2365241, node heap has 0 buffer(s)
Hash table size 2365241, node heap has 0 buffer(s)
0.00 hash searches/s, 0.00 non-hash searches/s
---
LOG
---
Log sequence number 89430260246
Log flushed up to   89430260246
Pages flushed up to 89430260246
Last checkpoint at  89430260237
0 pending log flushes, 0 pending chkp writes
2662 log i/o's done, 0.00 log i/o's/second
----------------------
BUFFER POOL AND MEMORY
----------------------
Total large memory allocated 8795455488
Dictionary memory allocated 234968
Buffer pool size   524224
Free buffers       523545
Database pages     685
Old database pages 0
Modified db pages  0
Pending reads      0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 0, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 96, created 589, written 893
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
No buffer pool page gets since the last printout
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 685, unzip_LRU len: 0
I/O sum[0]:cur[0], unzip sum[0]:cur[0]
----------------------
INDIVIDUAL BUFFER POOL INFO
----------------------
---BUFFER POOL 0
Buffer pool size   65528
Free buffers       65456
Database pages     78
Old database pages 0
Modified db pages  0
Pending reads      0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 0, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 31, created 47, written 131
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
No buffer pool page gets since the last printout
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 78, unzip_LRU len: 0
I/O sum[0]:cur[0], unzip sum[0]:cur[0]
---BUFFER POOL 1
Buffer pool size   65528
Free buffers       65391
Database pages     137
Old database pages 0
Modified db pages  0
Pending reads      0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 0, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 11, created 126, written 367
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
No buffer pool page gets since the last printout
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 137, unzip_LRU len: 0
I/O sum[0]:cur[0], unzip sum[0]:cur[0]
---BUFFER POOL 2
Buffer pool size   65528
Free buffers       65413
Database pages     115
Old database pages 0
Modified db pages  0
Pending reads      0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 0, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 8, created 107, written 166
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
No buffer pool page gets since the last printout
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 115, unzip_LRU len: 0
I/O sum[0]:cur[0], unzip sum[0]:cur[0]
---BUFFER POOL 3
Buffer pool size   65528
Free buffers       65406
Database pages     122
Old database pages 0
Modified db pages  0
Pending reads      0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 0, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 13, created 109, written 182
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
No buffer pool page gets since the last printout
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 122, unzip_LRU len: 0
I/O sum[0]:cur[0], unzip sum[0]:cur[0]
---BUFFER POOL 4
Buffer pool size   65528
Free buffers       65463
Database pages     65
Old database pages 0
Modified db pages  0
Pending reads      0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 0, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 8, created 57, written 16
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
No buffer pool page gets since the last printout
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 65, unzip_LRU len: 0
I/O sum[0]:cur[0], unzip sum[0]:cur[0]
---BUFFER POOL 5
Buffer pool size   65528
Free buffers       65469
Database pages     59
Old database pages 0
Modified db pages  0
Pending reads      0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 0, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 9, created 50, written 11
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
No buffer pool page gets since the last printout
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 59, unzip_LRU len: 0
I/O sum[0]:cur[0], unzip sum[0]:cur[0]
---BUFFER POOL 6
Buffer pool size   65528
Free buffers       65470
Database pages     58
Old database pages 0
Modified db pages  0
Pending reads      0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 0, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 9, created 49, written 10
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
No buffer pool page gets since the last printout
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 58, unzip_LRU len: 0
I/O sum[0]:cur[0], unzip sum[0]:cur[0]
---BUFFER POOL 7
Buffer pool size   65528
Free buffers       65477
Database pages     51
Old database pages 0
Modified db pages  0
Pending reads      0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 0, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 7, created 44, written 10
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
No buffer pool page gets since the last printout
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 51, unzip_LRU len: 0
I/O sum[0]:cur[0], unzip sum[0]:cur[0]
--------------
ROW OPERATIONS
--------------
0 queries inside InnoDB, 0 queries in queue
0 read views open inside InnoDB
Process ID=10759, Main thread ID=139906706892544, state: sleeping
Number of rows inserted 5990, updated 0, deleted 0, read 1794460
0.00 inserts/s, 0.00 updates/s, 0.00 deletes/s, 0.00 reads/s
----------------------------
END OF INNODB MONITOR OUTPUT
============================

1 row in set (0.00 sec)

标准监视器输出部分
.Status(状态)
本节显示时间戳、监视器名称和每秒平均值所基于的秒数。秒数是当前时间和最后一次打印InnoDB Monitor输出之间经过的时间。

.BACKGROUND THREAD(后台线程)
srv_master_thread行显示了主后台线程完成的工作。

.SEMAPHORES(信号量)
这部分是报告等待信号量的线程,以及线程需要旋转或等待互斥量或rw-lock信号量的统计数据。大量线程等待信号量可能是磁盘I/O的结果,或者是InnoDB内部的争用问题。竞争可能是由于大量的并行查询或操作系统线程调度问题造成的。在这种情况下,将innodb_thread_concurrency系统变量设置为小于默认值可能会有所帮助。Spin rounds per wait line显示了每个操作系统等待互斥量的旋转轮数。

互斥参数由SHOW ENGINE INNODB MUTEX报告。

mysql> SHOW ENGINE INNODB MUTEX\G
*************************** 1. row ***************************
  Type: InnoDB
  Name: rwlock: dict0dict.cc:2737
Status: waits=35
*************************** 2. row ***************************
  Type: InnoDB
  Name: rwlock: dict0dict.cc:1183
Status: waits=77
*************************** 3. row ***************************
  Type: InnoDB
  Name: rwlock: log0log.cc:838
Status: waits=32
*************************** 4. row ***************************
  Type: InnoDB
  Name: sum rwlock: buf0buf.cc:1460
Status: waits=13399
4 rows in set (0.04 sec)

.LATEST FOREIGN KEY ERROR(最新的外键错误)
本节提供有关最近的外键约束错误的信息。如果没有发生此类错误,则不存在该错误。内容包括失败的语句以及有关失败的约束以及被引用表和引用表的信息。

.LATEST DETECTED DEADLOCK(最近检测到的死锁)
本节提供有关最近死锁的信息。如果没有发生死锁,则不存在。内容显示了涉及到哪些事务,每个试图执行的语句,它们拥有和需要的锁,以及InnoDB决定回滚哪个事务以打破死锁。

.TRANSACTIONS(事务)
如果本节报告锁等待,则您的应用程序可能存在锁争用。输出还可以帮助跟踪事务死锁的原因。

.FILE I/O(文件IO)
本节提供了InnoDB用于执行各种类型I/O的线程的信息。前几个是专用于一般InnoDB处理的。内容还显示挂起的I/O操作信息和I/O性能统计信息。

这些线程的数量由innodb_read_io_threads和innodb_write_io_threads参数控制。

.INSERT BUFFER AND ADAPTIVE HASH INDEX
本节展示了InnoDB插入缓冲区(也称为更改缓冲区)和自适应哈希索引的状态。

.LOG
介绍InnoDB日志的相关信息。内容包括当前日志序列号,日志被刷新到磁盘的距离,以及InnoDB最后一次执行检查点的位置。该部分还显示有关挂起写和写性能统计信息的信息。

.BUFFER POOL AND MEMORY
本节提供了读取和写入页面的统计信息。您可以从这些数字中计算出查询当前正在执行多少数据文件I/O操作

.ROW OPERATIONS
本节显示主线程正在执行的操作,包括每种类型的行操作的数量和性能比率。

]]>
http://www.jydba.net/index.php/archives/3543/feed 0
MySQL InnoDB集成MySQL性能模式 http://www.jydba.net/index.php/archives/3540 http://www.jydba.net/index.php/archives/3540#respond Sat, 20 Jan 2024 07:52:21 +0000 http://www.jydba.net/?p=3540 InnoDB集成MySQL性能模式

你可以使用MySQL Performance Schema特性来分析某些内部InnoDB操作。这种类型的调优主要针对那些评估优化策略以克服性能瓶颈的专家用户。dba还可以使用此功能进行容量规划,以查看他们的典型工作负载在特定的CPU、RAM和磁盘存储组合上是否遇到任何性能瓶颈;如果是,则判断是否可以通过增加系统某些部分的容量来提高性能。

使用这个特性来检查InnoDB的性能:
.您必须熟悉如何使用Performance Schema特性。例如,您应该知道如何启用仪器和消费者,以及如何查询performance_schema表以检索数据。

.您应该熟悉用于InnoDB的性能模式工具。要查看与innodb相关的仪器,可以查询setup_instruments表中包含’innodb’的仪器名称。

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

Database changed
mysql> SELECT * FROM setup_instruments WHERE NAME LIKE '%innodb%';
+-------------------------------------------------------+---------+-------+
| NAME                                                  | ENABLED | TIMED |
+-------------------------------------------------------+---------+-------+
| wait/synch/mutex/innodb/commit_cond_mutex             | NO      | NO    |
| wait/synch/mutex/innodb/innobase_share_mutex          | NO      | NO    |
| wait/synch/mutex/innodb/autoinc_mutex                 | NO      | NO    |
..........
| memory/innodb/adaptive hash index                     | NO      | NO    |
| memory/innodb/buf_buf_pool                            | NO      | NO    |
| memory/innodb/dict_stats_bg_recalc_pool_t             | NO      | NO    |
| memory/innodb/dict_stats_index_map_t                  | NO      | NO    |
| memory/innodb/dict_stats_n_diff_on_level              | NO      | NO    |
| memory/innodb/other                                   | NO      | NO    |
| memory/innodb/row_log_buf                             | NO      | NO    |
| memory/innodb/row_merge_sort                          | NO      | NO    |
| memory/innodb/std                                     | NO      | NO    |
| memory/innodb/trx_sys_t::rw_trx_ids                   | NO      | NO    |
| memory/innodb/partitioning                            | NO      | NO    |
| memory/innodb/api0api                                 | NO      | NO    |
| memory/innodb/btr0btr                                 | NO      | NO    |
| memory/innodb/btr0bulk                                | NO      | NO    |
| memory/innodb/btr0cur                                 | NO      | NO    |
| memory/innodb/btr0pcur                                | NO      | NO    |
| memory/innodb/btr0sea                                 | NO      | NO    |
| memory/innodb/buf0buf                                 | NO      | NO    |
| memory/innodb/buf0dblwr                               | NO      | NO    |
| memory/innodb/buf0dump                                | NO      | NO    |
| memory/innodb/buf0flu                                 | NO      | NO    |
| memory/innodb/buf0lru                                 | NO      | NO    |
| memory/innodb/dict0dict                               | NO      | NO    |
| memory/innodb/dict0mem                                | NO      | NO    |
| memory/innodb/dict0stats                              | NO      | NO    |
| memory/innodb/dict0stats_bg                           | NO      | NO    |
| memory/innodb/eval0eval                               | NO      | NO    |
| memory/innodb/fil0fil                                 | NO      | NO    |
| memory/innodb/fsp0file                                | NO      | NO    |
| memory/innodb/fsp0space                               | NO      | NO    |
| memory/innodb/fsp0sysspace                            | NO      | NO    |
| memory/innodb/fts0ast                                 | NO      | NO    |
| memory/innodb/fts0config                              | NO      | NO    |
| memory/innodb/fts0fts                                 | NO      | NO    |
| memory/innodb/fts0opt                                 | NO      | NO    |
| memory/innodb/fts0pars                                | NO      | NO    |
| memory/innodb/fts0que                                 | NO      | NO    |
| memory/innodb/fts0sql                                 | NO      | NO    |
| memory/innodb/gis0sea                                 | NO      | NO    |
| memory/innodb/ha0ha                                   | NO      | NO    |
| memory/innodb/ha_innodb                               | NO      | NO    |
| memory/innodb/handler0alter                           | NO      | NO    |
| memory/innodb/hash0hash                               | NO      | NO    |
| memory/innodb/i_s                                     | NO      | NO    |
| memory/innodb/ibuf0ibuf                               | NO      | NO    |
| memory/innodb/lexyy                                   | NO      | NO    |
| memory/innodb/lock0lock                               | NO      | NO    |
| memory/innodb/log0log                                 | NO      | NO    |
| memory/innodb/log0recv                                | NO      | NO    |
| memory/innodb/mem0mem                                 | NO      | NO    |
| memory/innodb/os0event                                | NO      | NO    |
| memory/innodb/os0file                                 | NO      | NO    |
| memory/innodb/page0cur                                | NO      | NO    |
| memory/innodb/page0zip                                | NO      | NO    |
| memory/innodb/pars0lex                                | NO      | NO    |
| memory/innodb/read0read                               | NO      | NO    |
| memory/innodb/rem0rec                                 | NO      | NO    |
| memory/innodb/row0ftsort                              | NO      | NO    |
| memory/innodb/row0import                              | NO      | NO    |
| memory/innodb/row0log                                 | NO      | NO    |
| memory/innodb/row0merge                               | NO      | NO    |
| memory/innodb/row0mysql                               | NO      | NO    |
| memory/innodb/row0sel                                 | NO      | NO    |
| memory/innodb/row0trunc                               | NO      | NO    |
| memory/innodb/srv0conc                                | NO      | NO    |
| memory/innodb/srv0srv                                 | NO      | NO    |
| memory/innodb/srv0start                               | NO      | NO    |
| memory/innodb/sync0arr                                | NO      | NO    |
| memory/innodb/sync0debug                              | NO      | NO    |
| memory/innodb/sync0rw                                 | NO      | NO    |
| memory/innodb/sync0types                              | NO      | NO    |
| memory/innodb/trx0i_s                                 | NO      | NO    |
| memory/innodb/trx0purge                               | NO      | NO    |
| memory/innodb/trx0roll                                | NO      | NO    |
| memory/innodb/trx0rseg                                | NO      | NO    |
| memory/innodb/trx0sys                                 | NO      | NO    |
| memory/innodb/trx0trx                                 | NO      | NO    |
| memory/innodb/trx0undo                                | NO      | NO    |
| memory/innodb/usr0sess                                | NO      | NO    |
| memory/innodb/ut0list                                 | NO      | NO    |
| memory/innodb/ut0mem                                  | NO      | NO    |
| memory/innodb/ut0mutex                                | NO      | NO    |
| memory/innodb/ut0pool                                 | NO      | NO    |
| memory/innodb/ut0rbt                                  | NO      | NO    |
| memory/innodb/ut0wqueue                               | NO      | NO    |
+-------------------------------------------------------+---------+-------+
167 rows in set (0.00 sec)

关于已仪表化的InnoDB对象的附加信息,您可以查询Performance Schema实例表,它提供了关于已仪表化对象的附加信息。与InnoDB相关的实例表
包括:
.mutex_instances表
.rwlock_instances表
.cond_instances表
.file_instances表

注意:
与InnoDB缓冲池相关的互斥量和读写锁不在本章的讨论范围内;SHOW ENGINE INNODB MUTEX命令的输出结果也是如此。

例如,在执行文件I/O仪表化时,要查看Performance Schema所看到的已仪表化的InnoDB文件对象的信息,您可以发出以下查询:

mysql> SELECT * FROM file_instances WHERE EVENT_NAME LIKE '%innodb%'\G
*************************** 1. row ***************************
 FILE_NAME: /mysqldata/mysql/ibdata1
EVENT_NAME: wait/io/file/innodb/innodb_data_file
OPEN_COUNT: 3
*************************** 2. row ***************************
 FILE_NAME: /mysqldata/mysql/ib_logfile0
EVENT_NAME: wait/io/file/innodb/innodb_log_file
OPEN_COUNT: 2
*************************** 3. row ***************************
 FILE_NAME: /mysqldata/mysql/ib_logfile1
EVENT_NAME: wait/io/file/innodb/innodb_log_file
OPEN_COUNT: 2
......

你应该要熟悉存储InnoDB事件数据的performance_schema表。与innodb相关事件相关的表包括:
.等待事件表,存储等待事件。

.汇总表,提供随时间推移终止的事件的聚合信息。汇总表包括文件I/O汇总表,它聚合了关于I/O操作的信息。

.阶段事件表,存储InnoDB ALTER TABLE和缓冲池load操作事件数据。

使用性能模式监控InnoDB表的ALTER TABLE进度

你可以使用Performance Schema监控InnoDB表的ALTER TABLE进度。

有7个阶段事件表示ALTER TABLE的不同阶段。每个阶段事件报告整个ALTER TABLE操作在其不同阶段进行时的WORK_COMPLETED和WORK_ESTIMATED运行总数。WORK_ESTIMATEDe使用一个公式计算,该公式考虑了ALTER TABLE执行的所有工作,并且可能在ALTER TABLE处理期间进行修改。WORK_COMPLETED和WORK_ESTIMATED值是ALTER TABLE执行的所有工作的抽象表示。

按照发生的顺序,ALTER TABLE阶段的事件包括:
.stage/innodb/alter table (read PK and internal sort):当ALTER TABLE处于read -primary-key阶段时,这个阶段是活动的。它一开始将设置WORK_COMPLETED=0和WORK_ESTIMATED设置为主键中估计的页面数。当这个阶段完成时,WORK_ESTIMATED被更新为主键中的实际页面数。

.stage/innodb/alter table (merge sort):对于通过ALTER TABLE操作添加的每个索引,重复此阶段。

.stage/innodb/alter table (insert):对于通过ALTER TABLE操作添加的每个索引,重复此阶段。

.stage/innodb/alter table (log apply index):这个阶段包括应用运行ALTER TABLE时生成的DML日志。

.stage/innodb/alter table (flush):在此阶段开始之前,根据刷新列表的长度,使用更准确的估计值更新WORK_ESTIMATED。

.stage/innodb/alter table (log apply table):此阶段包括应用在ALTER TABLE运行时生成的并发DML日志。这个阶段的持续时间取决于表变化的程度。如果在表上没有运行并发的DML,则此阶段会瞬间完成。

.stage/innodb/alter table (end):包括在刷新阶段之后出现的任何剩余工作,例如当运行ALTER TABLE时重新应用在表上执行的DML。

注意:
InnoDB ALTER TABLE阶段事件目前不会对添加的空间索引进行计数。

使用Performance Schema(性能模式)监控ALTER TABLE操作

下面的例子演示了如何启用stage/innodb/alter table% stage事件仪器和相关的消费者表来监控alter table的进度。
1.启用stage/innodb/alter%仪器:

mysql> UPDATE setup_instruments SET ENABLED = 'YES' WHERE NAME LIKE 'stage/innodb/alter%';
Query OK, 7 rows affected (0.00 sec)
Rows matched: 7  Changed: 7  Warnings: 0

2.启用阶段事件消费者表,其中包括events_stages_current、events_stages_history和events_stages_history_long。

mysql> UPDATE setup_consumers SET ENABLED = 'YES' WHERE NAME LIKE '%stages%';
Query OK, 3 rows affected (0.00 sec)
Rows matched: 3  Changed: 3  Warnings: 0

3.执行ALTER TABLE操作。在本例中,将middle_name列添加到employees示例数据库的employees表中。

mysql> ALTER TABLE employees.employees ADD COLUMN middle_name varchar(14) AFTER first_name;
Query OK, 0 rows affected (1.80 sec)
Records: 0  Duplicates: 0  Warnings: 0

4.通过查询Performance Schema的events_stages_current表来检查ALTER TABLE操作的进度。所显示的阶段事件取决于当前正在进行的ALTER TABLE阶段。WORK_COMPLETED列显示完成的工作,WORK_ESTIMATED列提供了对剩余工作的估计。

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

Database changed
mysql> SELECT EVENT_NAME, WORK_COMPLETED, WORK_ESTIMATED FROM events_stages_current;
Empty set (0.00 sec)

mysql> SELECT EVENT_NAME, WORK_COMPLETED, WORK_ESTIMATED FROM events_stages_current;
+----------------------------------+----------------+----------------+
| EVENT_NAME                       | WORK_COMPLETED | WORK_ESTIMATED |
+----------------------------------+----------------+----------------+
| stage/innodb/alter table (flush) |            938 |           1793 |
+----------------------------------+----------------+----------------+
1 row in set (0.00 sec)

如果ALTER TABLE操作已经完成,events_stages_current表返回一个空集合。在这种情况下,您可以检查events_stages_history表来查看已完成操作的事件数据。例如:

mysql> SELECT EVENT_NAME, WORK_COMPLETED, WORK_ESTIMATED FROM events_stages_history;
+------------------------------------------------------+----------------+----------------+
| EVENT_NAME                                           | WORK_COMPLETED | WORK_ESTIMATED |
+------------------------------------------------------+----------------+----------------+
| stage/innodb/alter table (read PK and internal sort) |            886 |           1793 |
| stage/innodb/alter table (flush)                     |           1793 |           1793 |
| stage/innodb/alter table (log apply table)           |           2177 |           2177 |
| stage/innodb/alter table (end)                       |           2177 |           2177 |
| stage/innodb/alter table (log apply table)           |           2561 |           2561 |
+------------------------------------------------------+----------------+----------------+
5 rows in set (0.00 sec)

如上所示,在ALTER TABLE处理期间修改了WORK_ESTIMATED的值。初始阶段完成后的预计工作量为1793。当ALTER TABLE处理完成时,WORK_ESTIMATED被设置为实际值,即2561。

使用Performance Schema(性能模式)监控InnoDB互斥锁等待
互斥锁是代码中使用的一种同步机制,用于强制在给定时间内只有一个线程可以访问公共资源。当服务器上执行的两个或多个线程需要访问相同的资源时,线程之间会相互竞争。第一个获得互斥锁的线程会导致其他线程等待,直到锁被释放。

对于仪表化的InnoDB互斥锁,可以使用Performance Schema来监控互斥锁的等待。
例如,在Performance Schema表中收集的等待事件数据可以帮助识别等待时间最长或总等待时间最长的互斥锁。

下面的例子演示了如何启用InnoDB互斥锁等待工具,如何启用关联的消费者,以及如何查询等待事件数据。
1.要查看可用的InnoDB互斥锁等待工具,请查询Performance Schema setup_instruments表,如下所示。所有InnoDB互斥锁等待工具默认是禁用的。

mysql> SELECT * FROM performance_schema.setup_instruments WHERE NAME LIKE '%wait/synch/mutex/innodb%';
+-------------------------------------------------------+---------+-------+
| NAME                                                  | ENABLED | TIMED |
+-------------------------------------------------------+---------+-------+
| wait/synch/mutex/innodb/commit_cond_mutex             | NO      | NO    |
| wait/synch/mutex/innodb/innobase_share_mutex          | NO      | NO    |
| wait/synch/mutex/innodb/autoinc_mutex                 | NO      | NO    |
| wait/synch/mutex/innodb/buf_pool_mutex                | NO      | NO    |
| wait/synch/mutex/innodb/buf_pool_zip_mutex            | NO      | NO    |
| wait/synch/mutex/innodb/cache_last_read_mutex         | NO      | NO    |
| wait/synch/mutex/innodb/dict_foreign_err_mutex        | NO      | NO    |
| wait/synch/mutex/innodb/dict_sys_mutex                | NO      | NO    |
| wait/synch/mutex/innodb/recalc_pool_mutex             | NO      | NO    |
| wait/synch/mutex/innodb/file_format_max_mutex         | NO      | NO    |
| wait/synch/mutex/innodb/fil_system_mutex              | NO      | NO    |
| wait/synch/mutex/innodb/flush_list_mutex              | NO      | NO    |
| wait/synch/mutex/innodb/fts_bg_threads_mutex          | NO      | NO    |
| wait/synch/mutex/innodb/fts_delete_mutex              | NO      | NO    |
| wait/synch/mutex/innodb/fts_optimize_mutex            | NO      | NO    |
| wait/synch/mutex/innodb/fts_doc_id_mutex              | NO      | NO    |
| wait/synch/mutex/innodb/fts_pll_tokenize_mutex        | NO      | NO    |
| wait/synch/mutex/innodb/log_flush_order_mutex         | NO      | NO    |
| wait/synch/mutex/innodb/hash_table_mutex              | NO      | NO    |
| wait/synch/mutex/innodb/ibuf_bitmap_mutex             | NO      | NO    |
| wait/synch/mutex/innodb/ibuf_mutex                    | NO      | NO    |
| wait/synch/mutex/innodb/ibuf_pessimistic_insert_mutex | NO      | NO    |
| wait/synch/mutex/innodb/log_sys_mutex                 | NO      | NO    |
| wait/synch/mutex/innodb/log_sys_write_mutex           | NO      | NO    |
| wait/synch/mutex/innodb/log_cmdq_mutex                | NO      | NO    |
| wait/synch/mutex/innodb/mutex_list_mutex              | NO      | NO    |
| wait/synch/mutex/innodb/page_cleaner_mutex            | NO      | NO    |
| wait/synch/mutex/innodb/page_zip_stat_per_index_mutex | NO      | NO    |
| wait/synch/mutex/innodb/purge_sys_pq_mutex            | NO      | NO    |
| wait/synch/mutex/innodb/recv_sys_mutex                | NO      | NO    |
| wait/synch/mutex/innodb/recv_writer_mutex             | NO      | NO    |
| wait/synch/mutex/innodb/redo_rseg_mutex               | NO      | NO    |
| wait/synch/mutex/innodb/noredo_rseg_mutex             | NO      | NO    |
| wait/synch/mutex/innodb/rw_lock_list_mutex            | NO      | NO    |
| wait/synch/mutex/innodb/rw_lock_mutex                 | NO      | NO    |
| wait/synch/mutex/innodb/srv_dict_tmpfile_mutex        | NO      | NO    |
| wait/synch/mutex/innodb/srv_innodb_monitor_mutex      | NO      | NO    |
| wait/synch/mutex/innodb/srv_misc_tmpfile_mutex        | NO      | NO    |
| wait/synch/mutex/innodb/srv_monitor_file_mutex        | NO      | NO    |
| wait/synch/mutex/innodb/buf_dblwr_mutex               | NO      | NO    |
| wait/synch/mutex/innodb/trx_undo_mutex                | NO      | NO    |
| wait/synch/mutex/innodb/trx_pool_mutex                | NO      | NO    |
| wait/synch/mutex/innodb/trx_pool_manager_mutex        | NO      | NO    |
| wait/synch/mutex/innodb/srv_sys_mutex                 | NO      | NO    |
| wait/synch/mutex/innodb/lock_mutex                    | NO      | NO    |
| wait/synch/mutex/innodb/lock_wait_mutex               | NO      | NO    |
| wait/synch/mutex/innodb/trx_mutex                     | NO      | NO    |
| wait/synch/mutex/innodb/srv_threads_mutex             | NO      | NO    |
| wait/synch/mutex/innodb/rtr_active_mutex              | NO      | NO    |
| wait/synch/mutex/innodb/rtr_match_mutex               | NO      | NO    |
| wait/synch/mutex/innodb/rtr_path_mutex                | NO      | NO    |
| wait/synch/mutex/innodb/rtr_ssn_mutex                 | NO      | NO    |
| wait/synch/mutex/innodb/trx_sys_mutex                 | NO      | NO    |
| wait/synch/mutex/innodb/thread_mutex                  | NO      | NO    |
| wait/synch/mutex/innodb/sync_array_mutex              | NO      | NO    |
| wait/synch/mutex/innodb/zip_pad_mutex                 | NO      | NO    |
| wait/synch/mutex/innodb/row_drop_list_mutex           | NO      | NO    |
| wait/synch/mutex/innodb/master_key_id_mutex           | NO      | NO    |
+-------------------------------------------------------+---------+-------+
58 rows in set (0.00 sec)

2.一些InnoDB互斥锁实例是在服务器启动时创建的,并且只有在服务器启动时启用了相关的工具时才会被检测。为了确保所有InnoDB互斥锁实例都被仪表化和启用,请将以下性能模式仪表规则添加到您的MySQL配置文件:

performance-schema-instrument='wait/synch/mutex/innodb%=ON'

如果您不需要某等待事件的所有InnoDB互斥锁数据,您可以通过在MySQL配置文件中添加额外的性能模式仪表规则来禁用特定的仪表。例如,要禁用与全文搜索相关的InnoDB互斥锁等待事件工具,请添加以下规则:

performance-schema-instrument='wait/synch/mutex/innodb/fts%=OFF'

注意:
前缀较长的规则(如wait/sync /mutex/innodb/fts%)优先于前缀较短的规则(如wait/sync /mutex/innodb/ %)。

将performance-schema-instrument规则添加到配置文件后,重新启动服务器。除了那些与全文搜索相关的其它所有的InnoDB互斥锁都是启用的。要验证这一点,请查询setup_instruments表。对于您启用的仪器,ENABLED和TIMED列应该设置为YES。

[root@localhost mysql]# service mysqld restart
Shutting down MySQL.... SUCCESS!
Starting MySQL... SUCCESS!

mysql> SELECT * FROM performance_schema.setup_instruments WHERE NAME LIKE '%wait/synch/mutex/innodb%';
+-------------------------------------------------------+---------+-------+
| NAME                                                  | ENABLED | TIMED |
+-------------------------------------------------------+---------+-------+
| wait/synch/mutex/innodb/commit_cond_mutex             | YES     | YES   |
| wait/synch/mutex/innodb/innobase_share_mutex          | YES     | YES   |
| wait/synch/mutex/innodb/autoinc_mutex                 | YES     | YES   |
| wait/synch/mutex/innodb/buf_pool_mutex                | YES     | YES   |
| wait/synch/mutex/innodb/buf_pool_zip_mutex            | YES     | YES   |
| wait/synch/mutex/innodb/cache_last_read_mutex         | YES     | YES   |
| wait/synch/mutex/innodb/dict_foreign_err_mutex        | YES     | YES   |
| wait/synch/mutex/innodb/dict_sys_mutex                | YES     | YES   |
| wait/synch/mutex/innodb/recalc_pool_mutex             | YES     | YES   |
| wait/synch/mutex/innodb/file_format_max_mutex         | YES     | YES   |
| wait/synch/mutex/innodb/fil_system_mutex              | YES     | YES   |
| wait/synch/mutex/innodb/flush_list_mutex              | YES     | YES   |
| wait/synch/mutex/innodb/fts_bg_threads_mutex          | NO      | NO    |
| wait/synch/mutex/innodb/fts_delete_mutex              | NO      | NO    |
| wait/synch/mutex/innodb/fts_optimize_mutex            | NO      | NO    |
| wait/synch/mutex/innodb/fts_doc_id_mutex              | NO      | NO    |
| wait/synch/mutex/innodb/fts_pll_tokenize_mutex        | NO      | NO    |
| wait/synch/mutex/innodb/log_flush_order_mutex         | YES     | YES   |
| wait/synch/mutex/innodb/hash_table_mutex              | YES     | YES   |
| wait/synch/mutex/innodb/ibuf_bitmap_mutex             | YES     | YES   |
| wait/synch/mutex/innodb/ibuf_mutex                    | YES     | YES   |
| wait/synch/mutex/innodb/ibuf_pessimistic_insert_mutex | YES     | YES   |
| wait/synch/mutex/innodb/log_sys_mutex                 | YES     | YES   |
| wait/synch/mutex/innodb/log_sys_write_mutex           | YES     | YES   |
| wait/synch/mutex/innodb/log_cmdq_mutex                | YES     | YES   |
| wait/synch/mutex/innodb/mutex_list_mutex              | YES     | YES   |
| wait/synch/mutex/innodb/page_cleaner_mutex            | YES     | YES   |
| wait/synch/mutex/innodb/page_zip_stat_per_index_mutex | YES     | YES   |
| wait/synch/mutex/innodb/purge_sys_pq_mutex            | YES     | YES   |
| wait/synch/mutex/innodb/recv_sys_mutex                | YES     | YES   |
| wait/synch/mutex/innodb/recv_writer_mutex             | YES     | YES   |
| wait/synch/mutex/innodb/redo_rseg_mutex               | YES     | YES   |
| wait/synch/mutex/innodb/noredo_rseg_mutex             | YES     | YES   |
| wait/synch/mutex/innodb/rw_lock_list_mutex            | YES     | YES   |
| wait/synch/mutex/innodb/rw_lock_mutex                 | YES     | YES   |
| wait/synch/mutex/innodb/srv_dict_tmpfile_mutex        | YES     | YES   |
| wait/synch/mutex/innodb/srv_innodb_monitor_mutex      | YES     | YES   |
| wait/synch/mutex/innodb/srv_misc_tmpfile_mutex        | YES     | YES   |
| wait/synch/mutex/innodb/srv_monitor_file_mutex        | YES     | YES   |
| wait/synch/mutex/innodb/buf_dblwr_mutex               | YES     | YES   |
| wait/synch/mutex/innodb/trx_undo_mutex                | YES     | YES   |
| wait/synch/mutex/innodb/trx_pool_mutex                | YES     | YES   |
| wait/synch/mutex/innodb/trx_pool_manager_mutex        | YES     | YES   |
| wait/synch/mutex/innodb/srv_sys_mutex                 | YES     | YES   |
| wait/synch/mutex/innodb/lock_mutex                    | YES     | YES   |
| wait/synch/mutex/innodb/lock_wait_mutex               | YES     | YES   |
| wait/synch/mutex/innodb/trx_mutex                     | YES     | YES   |
| wait/synch/mutex/innodb/srv_threads_mutex             | YES     | YES   |
| wait/synch/mutex/innodb/rtr_active_mutex              | YES     | YES   |
| wait/synch/mutex/innodb/rtr_match_mutex               | YES     | YES   |
| wait/synch/mutex/innodb/rtr_path_mutex                | YES     | YES   |
| wait/synch/mutex/innodb/rtr_ssn_mutex                 | YES     | YES   |
| wait/synch/mutex/innodb/trx_sys_mutex                 | YES     | YES   |
| wait/synch/mutex/innodb/thread_mutex                  | YES     | YES   |
| wait/synch/mutex/innodb/sync_array_mutex              | YES     | YES   |
| wait/synch/mutex/innodb/zip_pad_mutex                 | YES     | YES   |
| wait/synch/mutex/innodb/row_drop_list_mutex           | YES     | YES   |
| wait/synch/mutex/innodb/master_key_id_mutex           | YES     | YES   |
+-------------------------------------------------------+---------+-------+
58 rows in set (0.00 sec)

3.通过更新setup_consumers表来启用等待事件消费者。默认情况下,等待事件消费者是禁用的

mysql> UPDATE performance_schema.setup_consumers SET enabled = 'YES' WHERE name like 'events_waits%';
Query OK, 0 rows affected (0.00 sec)
Rows matched: 3  Changed: 3  Warnings: 0

可以通过查询setup_consumers表来验证是否启用了等待事件消费者。应该启用events_waits_current、events_waits_history和events_waits_history_long消费者。

mysql> SELECT * FROM performance_schema.setup_consumers;
+----------------------------------+---------+
| NAME                             | ENABLED |
+----------------------------------+---------+
| events_stages_current            | NO      |
| events_stages_history            | NO      |
| events_stages_history_long       | NO      |
| events_statements_current        | YES     |
| events_statements_history        | YES     |
| events_statements_history_long   | NO      |
| events_transactions_current      | NO      |
| events_transactions_history      | NO      |
| events_transactions_history_long | NO      |
| events_waits_current             | YES     |
| events_waits_history             | YES     |
| events_waits_history_long        | YES     |
| global_instrumentation           | YES     |
| thread_instrumentation           | YES     |
| statements_digest                | YES     |
+----------------------------------+---------+
15 rows in set (0.00 sec)

4.启用仪器和使用者后,运行要监视的工作负载。在这个例子中,mysqlslap负载模拟客户端用于模拟工作负载。

[mysql@localhost mysql]$ mysqlslap  -uroot -p123456 mysql  --auto-generate-sql --concurrency=100 --iterations=10 --number-of-queries=1000 --number-char-cols=6 --number-int-cols=6;
mysqlslap: [Warning] Using a password on the command line interface can be insecure.
Benchmark
        Average number of seconds to run all queries: 11.287 seconds
        Minimum number of seconds to run all queries: 11.172 seconds
        Maximum number of seconds to run all queries: 12.000 seconds
        Number of clients running queries: 100
        Average number of queries per client: 10




5.查询wait事件数据。在这个例子中,从events_waits_summary_global_by_event_name表中查询等待事件数据,该表聚合了events_waits_current、events_waits_history和events_waits_history_long表中的数据。数据按事件名称(EVENT_NAME)汇总,这是产生事件的工具的名称。汇总数据包括:
.COUNT_STAR 汇总等待事件的数量。

.SUM_TIMER_WAIT 汇总的定时等待事件的总等待时间。

.MIN_TIMER_WAIT 汇总的定时等待事件的最小等待时间。

.AVG_TIMER_WAIT 汇总的定时等待事件的平均等待时间。

.MAX_TIMER_WAIT 汇总的定时等待事件的最大等待时间。

下面的查询返回工具名称(EVENT_NAME)、等待事件数(COUNT_STAR)和该工具事件的总等待时间(SUM_TIMER_WAIT)。因为等待的时间默认以皮秒(万亿分之一秒)为单位,所以等待时间除以1000000000以毫秒为单位。数据按汇总的等待事件数量降序排列(COUNT_STAR)。可以调整ORDER BY子句,按总等待时间对数据进行排序。

mysql> SELECT EVENT_NAME, COUNT_STAR, SUM_TIMER_WAIT/1000000000 SUM_TIMER_WAIT_MS
    -> FROM performance_schema.events_waits_summary_global_by_event_name
    -> WHERE SUM_TIMER_WAIT > 0 AND EVENT_NAME LIKE 'wait/synch/mutex/innodb/%'
    -> ORDER BY COUNT_STAR DESC;
+--------------------------------------------------+------------+-------------------+
| EVENT_NAME                                       | COUNT_STAR | SUM_TIMER_WAIT_MS |
+--------------------------------------------------+------------+-------------------+
| wait/synch/mutex/innodb/buf_pool_mutex           |   10169469 |         1019.8992 |
| wait/synch/mutex/innodb/flush_list_mutex         |    6774758 |         1142.6652 |
| wait/synch/mutex/innodb/buf_dblwr_mutex          |    3387219 |          254.6546 |
| wait/synch/mutex/innodb/log_sys_mutex            |    1306588 |          236.5495 |
| wait/synch/mutex/innodb/sync_array_mutex         |     892914 |          214.6077 |
| wait/synch/mutex/innodb/rw_lock_list_mutex       |     524623 |           17.1254 |
| wait/synch/mutex/innodb/fil_system_mutex         |     449955 |          103.0167 |
| wait/synch/mutex/innodb/dict_sys_mutex           |     432432 |           44.9851 |
| wait/synch/mutex/innodb/log_sys_write_mutex      |     426698 |           32.9908 |
| wait/synch/mutex/innodb/log_flush_order_mutex    |     424318 |           76.9258 |
| wait/synch/mutex/innodb/lock_wait_mutex          |     423173 |          154.4097 |
| wait/synch/mutex/innodb/row_drop_list_mutex      |     423165 |          115.7234 |
| wait/synch/mutex/innodb/trx_mutex                |     148083 |           14.0274 |
| wait/synch/mutex/innodb/recalc_pool_mutex        |      42731 |           16.2913 |
| wait/synch/mutex/innodb/redo_rseg_mutex          |      36442 |           72.2952 |
| wait/synch/mutex/innodb/trx_sys_mutex            |      32181 |          595.8351 |
| wait/synch/mutex/innodb/lock_mutex               |      20761 |           49.5238 |
| wait/synch/mutex/innodb/srv_innodb_monitor_mutex |       6939 |            2.3340 |
| wait/synch/mutex/innodb/trx_undo_mutex           |       6550 |            0.8013 |
| wait/synch/mutex/innodb/trx_pool_mutex           |       2272 |        15580.2291 |
| wait/synch/mutex/innodb/innobase_share_mutex     |       2015 |            0.2733 |
| wait/synch/mutex/innodb/trx_pool_manager_mutex   |       1138 |            0.2584 |
| wait/synch/mutex/innodb/file_format_max_mutex    |       1021 |            0.0499 |
| wait/synch/mutex/innodb/page_cleaner_mutex       |        567 |            0.0531 |
| wait/synch/mutex/innodb/purge_sys_pq_mutex       |         70 |            0.0063 |
| wait/synch/mutex/innodb/srv_sys_mutex            |         52 |            0.0071 |
| wait/synch/mutex/innodb/ibuf_mutex               |         29 |            0.0022 |
| wait/synch/mutex/innodb/thread_mutex             |         27 |            0.0045 |
| wait/synch/mutex/innodb/recv_sys_mutex           |         22 |            0.0023 |
| wait/synch/mutex/innodb/buf_pool_zip_mutex       |         22 |            0.0020 |
| wait/synch/mutex/innodb/recv_writer_mutex        |          1 |            0.0002 |
| wait/synch/mutex/innodb/autoinc_mutex            |          1 |            0.0001 |
+--------------------------------------------------+------------+-------------------+
32 rows in set (0.02 sec)

注意:
上述结果集包括启动过程中产生的等待事件数据。要排除这些数据,您可以在启动后和运行工作负载之前立即截断events_waits_summary_global_by_event_name表。但truncate操作本身产生的等待事件数据量可以忽略不计。

mysql> TRUNCATE performance_schema.events_waits_summary_global_by_event_name;
Query OK, 0 rows affected (0.00 sec)

mysql> SELECT EVENT_NAME, COUNT_STAR, SUM_TIMER_WAIT/1000000000 SUM_TIMER_WAIT_MS
    -> FROM performance_schema.events_waits_summary_global_by_event_name
    -> WHERE SUM_TIMER_WAIT > 0 AND EVENT_NAME LIKE 'wait/synch/mutex/innodb/%'
    -> ORDER BY COUNT_STAR DESC;
+-----------------------------------------------+------------+-------------------+
| EVENT_NAME                                    | COUNT_STAR | SUM_TIMER_WAIT_MS |
+-----------------------------------------------+------------+-------------------+
| wait/synch/mutex/innodb/buf_pool_mutex        |        264 |            0.0381 |
| wait/synch/mutex/innodb/flush_list_mutex      |        176 |            0.0316 |
| wait/synch/mutex/innodb/buf_dblwr_mutex       |         88 |            0.0079 |
| wait/synch/mutex/innodb/log_sys_mutex         |         33 |            0.0079 |
| wait/synch/mutex/innodb/sync_array_mutex      |         22 |            0.0042 |
| wait/synch/mutex/innodb/dict_sys_mutex        |         11 |            0.0009 |
| wait/synch/mutex/innodb/fil_system_mutex      |         11 |            0.0022 |
| wait/synch/mutex/innodb/log_flush_order_mutex |         11 |            0.0020 |
| wait/synch/mutex/innodb/log_sys_write_mutex   |         11 |            0.0010 |
| wait/synch/mutex/innodb/lock_wait_mutex       |         11 |            0.0073 |
| wait/synch/mutex/innodb/row_drop_list_mutex   |         11 |            0.0067 |
| wait/synch/mutex/innodb/recalc_pool_mutex     |          1 |            0.0008 |
+-----------------------------------------------+------------+-------------------+
12 rows in set (0.02 sec)

]]>
http://www.jydba.net/index.php/archives/3540/feed 0
MySQL 获取InnoDB表空间元数据 http://www.jydba.net/index.php/archives/3538 http://www.jydba.net/index.php/archives/3538#respond Mon, 15 Jan 2024 07:43:12 +0000 http://www.jydba.net/?p=3538 从INFORMATION_SCHEMA.FILES中获取InnoDB表空间元数据
INFORMATION_SCHEMA。FILES表提供了所有InnoDB表空间类型的元数据,包括file-per-table表空间、通用表空间、system表空间、临时表空间和undo表空间(如果存在)。

注意:
INNODB_SYS_TABLESPACES和INNODB_SYS_DATAFILES表也提供了关于InnoDB表空间的元数据,但数据仅限于file-per-table和通用表空间。

该查询从INFORMATION_SCHEMA.FILES表的字段中检索有关InnoDB系统表空间的元数据。与InnoDB无关的字段总是返回NULL,并且被排除在查询之外。

mysql> SELECT FILE_ID, FILE_NAME, FILE_TYPE, TABLESPACE_NAME, FREE_EXTENTS,
    -> TOTAL_EXTENTS, EXTENT_SIZE, INITIAL_SIZE, MAXIMUM_SIZE, AUTOEXTEND_SIZE, DATA_FREE, STATUS ENGINE
    -> FROM INFORMATION_SCHEMA.FILES WHERE TABLESPACE_NAME LIKE 'innodb_system' \G
*************************** 1. row ***************************
        FILE_ID: 0
      FILE_NAME: ./ibdata1
      FILE_TYPE: TABLESPACE
TABLESPACE_NAME: innodb_system
   FREE_EXTENTS: 2
  TOTAL_EXTENTS: 74
    EXTENT_SIZE: 1048576
   INITIAL_SIZE: 77594624
   MAXIMUM_SIZE: NULL
AUTOEXTEND_SIZE: 67108864
      DATA_FREE: 37748736
         ENGINE: NORMAL
1 row in set (0.01 sec)

对于InnoDB file-per-table和通用表空间,下面这个查询检索FILE_ID(等价于space ID)和FILE_NAME(包含路径信息)。file-per-table和通用表空间的文件扩展名是.ibd。

mysql> SELECT FILE_ID, FILE_NAME FROM INFORMATION_SCHEMA.FILES WHERE FILE_NAME LIKE '%.ibd%' ORDER BY FILE_ID;
+---------+----------------------------------------------------------+
| FILE_ID | FILE_NAME                                                |
+---------+----------------------------------------------------------+
|       5 | ./mysql/plugin.ibd                                       |
|       6 | ./mysql/servers.ibd                                      |
|       7 | ./mysql/help_topic.ibd                                   |
|       8 | ./mysql/help_category.ibd                                |
|       9 | ./mysql/help_relation.ibd                                |
|      10 | ./mysql/help_keyword.ibd                                 |
|      11 | ./mysql/time_zone_name.ibd                               |
|      12 | ./mysql/time_zone.ibd                                    |
|      13 | ./mysql/time_zone_transition.ibd                         |
|      14 | ./mysql/time_zone_transition_type.ibd                    |
|      15 | ./mysql/time_zone_leap_second.ibd                        |
|      16 | ./mysql/innodb_table_stats.ibd                           |
|      17 | ./mysql/innodb_index_stats.ibd                           |
|      18 | ./mysql/slave_relay_log_info.ibd                         |
|      19 | ./mysql/slave_master_info.ibd                            |
|      20 | ./mysql/slave_worker_info.ibd                            |
|      21 | ./mysql/gtid_executed.ibd                                |
|      22 | ./mysql/server_cost.ibd                                  |
|      23 | ./mysql/engine_cost.ibd                                  |
|      24 | ./sys/sys_config.ibd                                     |
|      37 | ./ts1.ibd                                                |
|      38 | ./ts2.ibd                                                |
|      51 | ./test/user.ibd                                          |
|      57 | ./mysql/test_index_1.ibd                                 |
|      58 | ./test/test_index_1.ibd                                  |
|      59 | ./employees/employees.ibd                                |
|      60 | ./employees/departments.ibd                              |
|      61 | ./employees/dept_manager.ibd                             |
|      62 | ./employees/dept_emp.ibd                                 |
|      63 | ./employees/titles.ibd                                   |
|      64 | ./employees/salaries.ibd                                 |
|     262 | ./test/bmsql_config.ibd                                  |
|     272 | ./test/bmsql_warehouse.ibd                               |
|     279 | ./test/bmsql_item.ibd                                    |
|     280 | ./test/bmsql_district.ibd                                |
|     281 | ./test/bmsql_customer.ibd                                |
|     283 | ./test/bmsql_history.ibd                                 |
|     284 | ./test/bmsql_new_order.ibd                               |
|     285 | ./test/bmsql_oorder.ibd                                  |
|     287 | ./test/bmsql_order_line.ibd                              |
|     289 | ./test/bmsql_stock.ibd                                   |
|     293 | ./ts01.ibd                                               |
|     294 | ./ts02.ibd                                               |
|     414 | ./employees/t.ibd                                        |
|     415 | ./employees/c.ibd                                        |
|     420 | ./test/ts03.ibd                                          |
|     423 | ./test/abc.ibd                                           |
|     425 | ./test/t3.ibd                                            |
|     426 | ./test/t4.ibd                                            |
|     427 | ./test/t7.ibd                                            |
|     428 | ./test/t8.ibd                                            |
|     472 | ./undo/opening_lines.ibd                                 |
|     473 | ./undo/FTS_00000000000001d9_BEING_DELETED.ibd            |
|     474 | ./undo/FTS_00000000000001d9_BEING_DELETED_CACHE.ibd      |
|     475 | ./undo/FTS_00000000000001d9_CONFIG.ibd                   |
|     476 | ./undo/FTS_00000000000001d9_DELETED.ibd                  |
|     477 | ./undo/FTS_00000000000001d9_DELETED_CACHE.ibd            |
|     478 | ./undo/FTS_00000000000001d9_00000000000002da_INDEX_1.ibd |
|     479 | ./undo/FTS_00000000000001d9_00000000000002da_INDEX_2.ibd |
|     480 | ./undo/FTS_00000000000001d9_00000000000002da_INDEX_3.ibd |
|     481 | ./undo/FTS_00000000000001d9_00000000000002da_INDEX_4.ibd |
|     482 | ./undo/FTS_00000000000001d9_00000000000002da_INDEX_5.ibd |
|     483 | ./undo/FTS_00000000000001d9_00000000000002da_INDEX_6.ibd |
|     484 | ./undo/t1.ibd                                            |
|     485 | ./ts3.ibd                                                |
|     487 | ./undo/big_table.ibd                                     |
|     489 | ./undo/key_block_size_4.ibd                              |
|     490 | ./ts4.ibd                                                |
|     491 | ./ts5.ibd                                                |
|     492 | ./ts6.ibd                                                |
|     494 | ./undo/t7.ibd                                            |
|     497 | ./undo/t8.ibd                                            |
|     498 | ./undo/employees.ibd                                     |
|     499 | ./undo/t9.ibd                                            |
|     500 | ./undo/t10.ibd                                           |
|     501 | ./undo/t11.ibd                                           |
|     503 | ./undo/t12.ibd                                           |
|     506 | ./undo/t13.ibd                                           |
|     507 | ./undo/t14.ibd                                           |
|     509 | ./test/parent.ibd                                        |
|     510 | ./test/child.ibd                                         |
|     523 | ./test/articles.ibd                                      |
|     524 | ./test/FTS_000000000000020c_BEING_DELETED.ibd            |
|     525 | ./test/FTS_000000000000020c_BEING_DELETED_CACHE.ibd      |
|     526 | ./test/FTS_000000000000020c_CONFIG.ibd                   |
|     527 | ./test/FTS_000000000000020c_DELETED.ibd                  |
|     528 | ./test/FTS_000000000000020c_DELETED_CACHE.ibd            |
|     529 | ./test/FTS_000000000000020c_0000000000000310_INDEX_1.ibd |
|     530 | ./test/FTS_000000000000020c_0000000000000310_INDEX_2.ibd |
|     531 | ./test/FTS_000000000000020c_0000000000000310_INDEX_3.ibd |
|     532 | ./test/FTS_000000000000020c_0000000000000310_INDEX_4.ibd |
|     533 | ./test/FTS_000000000000020c_0000000000000310_INDEX_5.ibd |
|     534 | ./test/FTS_000000000000020c_0000000000000310_INDEX_6.ibd |
|     535 | ./test/t1.ibd                                            |
+---------+----------------------------------------------------------+
94 rows in set (0.00 sec)

下面这个查询获取了InnoDB临时表空间的FILE_ID和FILE_NAME。临时表空间文件名以ibtmp为前缀。

mysql> SELECT FILE_ID, FILE_NAME FROM INFORMATION_SCHEMA.FILES WHERE FILE_NAME LIKE '%ibtmp%';
+---------+-----------+
| FILE_ID | FILE_NAME |
+---------+-----------+
|     537 | ./ibtmp1  |
+---------+-----------+
1 row in set (0.01 sec)

类似地,InnoDB的undo表空间文件名以undo为前缀。如果配置了单独的undo表空间,下面的查询返回了InnoDB undo表空间的FILE_ID和FILE_NAME。

mysql> SELECT FILE_ID, FILE_NAME FROM INFORMATION_SCHEMA.FILES WHERE FILE_NAME LIKE '%undo%';
+---------+----------------------------------------------------------+
| FILE_ID | FILE_NAME                                                |
+---------+----------------------------------------------------------+
|       1 | /mysqldata/mysql/undo/undo001                            |
|       2 | /mysqldata/mysql/undo/undo002                            |
|       3 | /mysqldata/mysql/undo/undo003                            |
+---------+----------------------------------------------------------+
3 rows in set (0.00 sec)
]]>
http://www.jydba.net/index.php/archives/3538/feed 0
MySQL InnoDB INFORMATION_SCHEMA临时表信息表 http://www.jydba.net/index.php/archives/3536 http://www.jydba.net/index.php/archives/3536#respond Sat, 13 Jan 2024 07:40:45 +0000 http://www.jydba.net/?p=3536 InnoDB INFORMATION_SCHEMA临时表信息表

INNODB_TEMP_TABLE_INFO表为用户提供了一个活动的InnoDB临时表的快照。这张表包含了除InnoDB内部使用的优化过的临时表之外的所有用户和系统创建的临时表的元数据,这些临时表在给定的InnoDB实例中是活动的。

mysql> SHOW TABLES FROM INFORMATION_SCHEMA LIKE 'INNODB_TEMP%';
+---------------------------------------------+
| Tables_in_information_schema (INNODB_TEMP%) |
+---------------------------------------------+
| INNODB_TEMP_TABLE_INFO                      |
+---------------------------------------------+
1 row in set (0.00 sec)

下面这个例子将展示了INNODB_TEMP_TABLE_INFO表的特征。
1.创建一个单列的简单InnoDB临时表:

mysql> CREATE TEMPORARY TABLE t1 (c1 INT PRIMARY KEY) ENGINE=INNODB;
Query OK, 0 rows affected (0.01 sec)

2.查询INNODB_TEMP_TABLE_INFO表查看临时表的元数据。

mysql> SELECT * FROM INFORMATION_SCHEMA.INNODB_TEMP_TABLE_INFO\G
*************************** 1. row ***************************
            TABLE_ID: 537
                NAME: #sql1d89_101_0
              N_COLS: 4
               SPACE: 444
PER_TABLE_TABLESPACE: FALSE
       IS_COMPRESSED: FALSE
1 row in set (0.00 sec)

TABLE_ID是临时表的唯一标识符。NAME列显示了系统生成的临时表的名称,前缀是“#sql”。列数(N_COLS)是4而不是1,因为InnoDB总是创建3个隐藏表列(DB_ROW_ID、DB_TRX_ID和DB_ROLL_PTR)。PER_TABLE_TABLESPACE和IS_COMPRESSED仅对压缩的临时表报告为TRUE。

3.创建一个压缩的临时表。在此之前,确保innodb_file_format设置为Barracuda,这是创建压缩行格式的表所必需的。

mysql> SET GLOBAL innodb_file_format="Barracuda";
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> CREATE TEMPORARY TABLE t2 (c1 INT) ROW_FORMAT=COMPRESSED ENGINE=INNODB;
Query OK, 0 rows affected (0.00 sec)

4.再次查询INNODB_TEMP_TABLE_INFO表。

mysql> SELECT * FROM INFORMATION_SCHEMA.INNODB_TEMP_TABLE_INFO\G
*************************** 1. row ***************************
            TABLE_ID: 538
                NAME: #sql1d89_101_1
              N_COLS: 4
               SPACE: 536
PER_TABLE_TABLESPACE: TRUE
       IS_COMPRESSED: TRUE
*************************** 2. row ***************************
            TABLE_ID: 537
                NAME: #sql1d89_101_0
              N_COLS: 4
               SPACE: 444
PER_TABLE_TABLESPACE: FALSE
       IS_COMPRESSED: FALSE
2 rows in set (0.00 sec)

对于压缩临时表,PER_TABLE_TABLESPACE和IS_COMPRESSED报告为TRUE。压缩临时表的空间ID是不同的,因为压缩临时表是在单独的per-table表空间中创建的。非压缩临时表共享一个表空间(默认情况下是ibtmp1),并且报告相同的空间ID。

5.重启MySQL并查询INNODB_TEMP_TABLE_INFO表。

[root@localhost mysql]# service mysqld restart
Shutting down MySQL.... SUCCESS!
Starting MySQL... SUCCESS!

mysql> SELECT * FROM INFORMATION_SCHEMA.INNODB_TEMP_TABLE_INFO\G
Empty set (0.00 sec)

返回一个空集合,因为INNODB_TEMP_TABLE_INFO表和其中的数据在服务器关闭时没有持久化到磁盘。

6.创建一个新的临时表。

mysql> CREATE TEMPORARY TABLE t1 (c1 INT PRIMARY KEY) ENGINE=INNODB;
Query OK, 0 rows affected (0.00 sec)

7.查询INNODB_TEMP_TABLE_INFO表查看临时表的元数据。

mysql> CREATE TEMPORARY TABLE t1 (c1 INT PRIMARY KEY) ENGINE=INNODB;
Query OK, 0 rows affected (0.00 sec)

mysql> SELECT * FROM INFORMATION_SCHEMA.INNODB_TEMP_TABLE_INFO\G
*************************** 1. row ***************************
            TABLE_ID: 539
                NAME: #sql216d_2_0
              N_COLS: 4
               SPACE: 537
PER_TABLE_TABLESPACE: FALSE
       IS_COMPRESSED: FALSE
1 row in set (0.00 sec)

空间ID是新的,因为它是在服务器重启时动态生成的。

]]>
http://www.jydba.net/index.php/archives/3536/feed 0
MySQL InnoDB INFORMATION_SCHEMA度量表 http://www.jydba.net/index.php/archives/3530 http://www.jydba.net/index.php/archives/3530#respond Wed, 10 Jan 2024 07:37:04 +0000 http://www.jydba.net/?p=3530 InnoDB INFORMATION_SCHEMA度量表
MySQL 5.6.2中引入了INNODB_METRICS表,它将所有InnoDB性能和资源相关的计数器合并到一个INFORMATION_SCHEMA表中。

mysql> SELECT * FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE NAME="dml_inserts" \G
*************************** 1. row ***************************
           NAME: dml_inserts
      SUBSYSTEM: dml
          COUNT: 17263004
      MAX_COUNT: 17263004
      MIN_COUNT: NULL
      AVG_COUNT: 0.8178722213173183
    COUNT_RESET: 17263004
MAX_COUNT_RESET: 17263004
MIN_COUNT_RESET: NULL
AVG_COUNT_RESET: NULL
   TIME_ENABLED: 2023-05-10 09:02:54
  TIME_DISABLED: NULL
   TIME_ELAPSED: 21107214
     TIME_RESET: NULL
         STATUS: enabled
           TYPE: status_counter
        COMMENT: Number of rows inserted

启用、禁用和重置计数器
可以使用以下配置选项启用、禁用和重置计数器:
.innodb_monitor_enable:启用一个或多个计数器。

SET GLOBAL innodb_monitor_enable = [counter-name|module_name|pattern|all];

.innodb_monitor_disable:禁用一个或多个计数器。

SET GLOBAL innodb_monitor_disable = [counter-name|module_name|pattern|all];

.innodb_monitor_reset:将一个或多个计数器的计数值重置为零。

SET GLOBAL innodb_monitor_reset = [counter-name|module_name|pattern|all];

.innodb_monitor_reset_all:重置一个或多个计数器的所有值。在使用innodb_monitor_reset_all之前,必须禁用计数器。

SET GLOBAL innodb_monitor_reset_all = [counter-name|module_name|pattern|all];

你也可以在启动时使用MySQL服务器配置文件启用计数器和计数器模块。例如,要启用log模块、metadata_table_handles_opened和metadata_table_handles_closed计数器,在my.cnf配置文件的[mysqld]部分输入以下代码。

[mysqld]
innodb_monitor_enable = module_recovery,metadata_table_handles_opened,metadata_table_handles_closed

当在你的配置文件中启用多个计数器或模块时,你必须指定innodb_monitor_enable配置选项,后面跟着用逗号分隔的计数器和模块名称,如上例所示。只有innodb_monitor_enable选项可以在你的配置文件中使用。禁用和重置配置选项仅支持在命令行上。

注意:
因为每个计数器都会在服务器上增加一定程度的运行时开销,所以通常在试验和基准测试期间在测试和开发服务器上启用更多的计数器,并且仅在生产服务器上启用计数器以诊断已知问题或监视可能成为特定服务器和工作负载瓶颈的方面。

计数器
INNODB_METRICS表中的计数器可能会发生变化,所以要获取最新的计数器列表,可以在运行中的MySQL服务器上查询。

默认启用的计数器与“SHOW ENGINE INNODB STATUS”使用的计数器对应。SHOW ENGINE INNODB STATUS使用的计数器在系统级别上总是“on”的,但是你可以根据需要禁用INNODB_METRICS表的这些计数器。另外,计数器状态不是持久的。除非另外指定,否则计数器在服务器重启时将恢复到默认的启用或禁用状态。

如果你运行的程序会受到INNODB_METRICS表中新增或更改的影响,建议你查看发布说明,并在升级之前查询INNODB_METRICS表中的新版本。

mysql> SELECT name, subsystem, status FROM INFORMATION_SCHEMA.INNODB_METRICS ORDER BY NAME;
+------------------------------------------+---------------------+----------+
| name                                     | subsystem           | status   |
+------------------------------------------+---------------------+----------+
| adaptive_hash_pages_added                | adaptive_hash_index | disabled |
| adaptive_hash_pages_removed              | adaptive_hash_index | disabled |
| adaptive_hash_rows_added                 | adaptive_hash_index | disabled |
| adaptive_hash_rows_deleted_no_hash_entry | adaptive_hash_index | disabled |
| adaptive_hash_rows_removed               | adaptive_hash_index | disabled |
| adaptive_hash_rows_updated               | adaptive_hash_index | disabled |
| adaptive_hash_searches                   | adaptive_hash_index | enabled  |
| adaptive_hash_searches_btree             | adaptive_hash_index | enabled  |
| buffer_data_reads                        | buffer              | enabled  |
| buffer_data_written                      | buffer              | enabled  |
| buffer_flush_adaptive                    | buffer              | disabled |
| buffer_flush_adaptive_avg_pass           | buffer              | disabled |
| buffer_flush_adaptive_avg_time_est       | buffer              | disabled |
| buffer_flush_adaptive_avg_time_slot      | buffer              | disabled |
| buffer_flush_adaptive_avg_time_thread    | buffer              | disabled |
| buffer_flush_adaptive_pages              | buffer              | disabled |
| buffer_flush_adaptive_total_pages        | buffer              | disabled |
| buffer_flush_avg_page_rate               | buffer              | disabled |
| buffer_flush_avg_pass                    | buffer              | disabled |
| buffer_flush_avg_time                    | buffer              | disabled |
| buffer_flush_background                  | buffer              | disabled |
| buffer_flush_background_pages            | buffer              | disabled |
| buffer_flush_background_total_pages      | buffer              | disabled |
| buffer_flush_batches                     | buffer              | disabled |
| buffer_flush_batch_num_scan              | buffer              | disabled |
| buffer_flush_batch_pages                 | buffer              | disabled |
| buffer_flush_batch_scanned               | buffer              | disabled |
| buffer_flush_batch_scanned_per_call      | buffer              | disabled |
| buffer_flush_batch_total_pages           | buffer              | disabled |
| buffer_flush_lsn_avg_rate                | buffer              | disabled |
| buffer_flush_nei***or                    | buffer              | disabled |
| buffer_flush_nei***or_pages              | buffer              | disabled |
| buffer_flush_nei***or_total_pages        | buffer              | disabled |
| buffer_flush_n_to_flush_by_age           | buffer              | disabled |
| buffer_flush_n_to_flush_requested        | buffer              | disabled |
| buffer_flush_pct_for_dirty               | buffer              | disabled |
| buffer_flush_pct_for_lsn                 | buffer              | disabled |
| buffer_flush_sync                        | buffer              | disabled |
| buffer_flush_sync_pages                  | buffer              | disabled |
| buffer_flush_sync_total_pages            | buffer              | disabled |
| buffer_flush_sync_waits                  | buffer              | disabled |
| buffer_LRU_batches_evict                 | buffer              | disabled |
| buffer_LRU_batches_flush                 | buffer              | disabled |
| buffer_LRU_batch_evict_pages             | buffer              | disabled |
| buffer_LRU_batch_evict_total_pages       | buffer              | disabled |
| buffer_LRU_batch_flush_avg_pass          | buffer              | disabled |
| buffer_LRU_batch_flush_avg_time_est      | buffer              | disabled |
| buffer_LRU_batch_flush_avg_time_slot     | buffer              | disabled |
| buffer_LRU_batch_flush_avg_time_thread   | buffer              | disabled |
| buffer_LRU_batch_flush_pages             | buffer              | disabled |
| buffer_LRU_batch_flush_total_pages       | buffer              | disabled |
| buffer_LRU_batch_num_scan                | buffer              | disabled |
| buffer_LRU_batch_scanned                 | buffer              | disabled |
| buffer_LRU_batch_scanned_per_call        | buffer              | disabled |
| buffer_LRU_get_free_loops                | buffer              | disabled |
| buffer_LRU_get_free_search               | Buffer              | disabled |
| buffer_LRU_get_free_waits                | buffer              | disabled |
| buffer_LRU_search_num_scan               | buffer              | disabled |
| buffer_LRU_search_scanned                | buffer              | disabled |
| buffer_LRU_search_scanned_per_call       | buffer              | disabled |
| buffer_LRU_single_flush_failure_count    | Buffer              | disabled |
| buffer_LRU_single_flush_num_scan         | buffer              | disabled |
| buffer_LRU_single_flush_scanned          | buffer              | disabled |
| buffer_LRU_single_flush_scanned_per_call | buffer              | disabled |
| buffer_LRU_unzip_search_num_scan         | buffer              | disabled |
| buffer_LRU_unzip_search_scanned          | buffer              | disabled |
| buffer_LRU_unzip_search_scanned_per_call | buffer              | disabled |
| buffer_pages_created                     | buffer              | enabled  |
| buffer_pages_read                        | buffer              | enabled  |
| buffer_pages_written                     | buffer              | enabled  |
| buffer_page_read_blob                    | buffer_page_io      | disabled |
| buffer_page_read_fsp_hdr                 | buffer_page_io      | disabled |
| buffer_page_read_ibuf_bitmap             | buffer_page_io      | disabled |
| buffer_page_read_ibuf_free_list          | buffer_page_io      | disabled |
| buffer_page_read_index_ibuf_leaf         | buffer_page_io      | disabled |
| buffer_page_read_index_ibuf_non_leaf     | buffer_page_io      | disabled |
| buffer_page_read_index_inode             | buffer_page_io      | disabled |
| buffer_page_read_index_leaf              | buffer_page_io      | disabled |
| buffer_page_read_index_non_leaf          | buffer_page_io      | disabled |
| buffer_page_read_other                   | buffer_page_io      | disabled |
| buffer_page_read_system_page             | buffer_page_io      | disabled |
| buffer_page_read_trx_system              | buffer_page_io      | disabled |
| buffer_page_read_undo_log                | buffer_page_io      | disabled |
| buffer_page_read_xdes                    | buffer_page_io      | disabled |
| buffer_page_read_zblob                   | buffer_page_io      | disabled |
| buffer_page_read_zblob2                  | buffer_page_io      | disabled |
| buffer_page_written_blob                 | buffer_page_io      | disabled |
| buffer_page_written_fsp_hdr              | buffer_page_io      | disabled |
| buffer_page_written_ibuf_bitmap          | buffer_page_io      | disabled |
| buffer_page_written_ibuf_free_list       | buffer_page_io      | disabled |
| buffer_page_written_index_ibuf_leaf      | buffer_page_io      | disabled |
| buffer_page_written_index_ibuf_non_leaf  | buffer_page_io      | disabled |
| buffer_page_written_index_inode          | buffer_page_io      | disabled |
| buffer_page_written_index_leaf           | buffer_page_io      | disabled |
| buffer_page_written_index_non_leaf       | buffer_page_io      | disabled |
| buffer_page_written_other                | buffer_page_io      | disabled |
| buffer_page_written_system_page          | buffer_page_io      | disabled |
| buffer_page_written_trx_system           | buffer_page_io      | disabled |
| buffer_page_written_undo_log             | buffer_page_io      | disabled |
| buffer_page_written_xdes                 | buffer_page_io      | disabled |
| buffer_page_written_zblob                | buffer_page_io      | disabled |
| buffer_page_written_zblob2               | buffer_page_io      | disabled |
| buffer_pool_bytes_data                   | buffer              | enabled  |
| buffer_pool_bytes_dirty                  | buffer              | enabled  |
| buffer_pool_pages_data                   | buffer              | enabled  |
| buffer_pool_pages_dirty                  | buffer              | enabled  |
| buffer_pool_pages_free                   | buffer              | enabled  |
| buffer_pool_pages_misc                   | buffer              | enabled  |
| buffer_pool_pages_total                  | buffer              | enabled  |
| buffer_pool_reads                        | buffer              | enabled  |
| buffer_pool_read_ahead                   | buffer              | enabled  |
| buffer_pool_read_ahead_evicted           | buffer              | enabled  |
| buffer_pool_read_requests                | buffer              | enabled  |
| buffer_pool_size                         | server              | enabled  |
| buffer_pool_wait_free                    | buffer              | enabled  |
| buffer_pool_write_requests               | buffer              | enabled  |
| compression_pad_decrements               | compression         | disabled |
| compression_pad_increments               | compression         | disabled |
| compress_pages_compressed                | compression         | disabled |
| compress_pages_decompressed              | compression         | disabled |
| ddl_background_drop_indexes              | ddl                 | disabled |
| ddl_background_drop_tables               | ddl                 | disabled |
| ddl_log_file_alter_table                 | ddl                 | disabled |
| ddl_online_create_index                  | ddl                 | disabled |
| ddl_pending_alter_table                  | ddl                 | disabled |
| ddl_sort_file_alter_table                | ddl                 | disabled |
| dml_deletes                              | dml                 | enabled  |
| dml_inserts                              | dml                 | enabled  |
| dml_reads                                | dml                 | disabled |
| dml_updates                              | dml                 | enabled  |
| file_num_open_files                      | file_system         | enabled  |
| ibuf_merges                              | change_buffer       | enabled  |
| ibuf_merges_delete                       | change_buffer       | enabled  |
| ibuf_merges_delete_mark                  | change_buffer       | enabled  |
| ibuf_merges_discard_delete               | change_buffer       | enabled  |
| ibuf_merges_discard_delete_mark          | change_buffer       | enabled  |
| ibuf_merges_discard_insert               | change_buffer       | enabled  |
| ibuf_merges_insert                       | change_buffer       | enabled  |
| ibuf_size                                | change_buffer       | enabled  |
| icp_attempts                             | icp                 | disabled |
| icp_match                                | icp                 | disabled |
| icp_no_match                             | icp                 | disabled |
| icp_out_of_range                         | icp                 | disabled |
| index_page_discards                      | index               | disabled |
| index_page_merge_attempts                | index               | disabled |
| index_page_merge_successful              | index               | disabled |
| index_page_reorg_attempts                | index               | disabled |
| index_page_reorg_successful              | index               | disabled |
| index_page_splits                        | index               | disabled |
| innodb_activity_count                    | server              | enabled  |
| innodb_background_drop_table_usec        | server              | disabled |
| innodb_checkpoint_usec                   | server              | disabled |
| innodb_dblwr_pages_written               | server              | enabled  |
| innodb_dblwr_writes                      | server              | enabled  |
| innodb_dict_lru_count                    | server              | disabled |
| innodb_dict_lru_usec                     | server              | disabled |
| innodb_ibuf_merge_usec                   | server              | disabled |
| innodb_log_flush_usec                    | server              | disabled |
| innodb_master_active_loops               | server              | disabled |
| innodb_master_idle_loops                 | server              | disabled |
| innodb_master_purge_usec                 | server              | disabled |
| innodb_master_thread_sleeps              | server              | disabled |
| innodb_mem_validate_usec                 | server              | disabled |
| innodb_page_size                         | server              | enabled  |
| innodb_rwlock_sx_os_waits                | server              | enabled  |
| innodb_rwlock_sx_spin_rounds             | server              | enabled  |
| innodb_rwlock_sx_spin_waits              | server              | enabled  |
| innodb_rwlock_s_os_waits                 | server              | enabled  |
| innodb_rwlock_s_spin_rounds              | server              | enabled  |
| innodb_rwlock_s_spin_waits               | server              | enabled  |
| innodb_rwlock_x_os_waits                 | server              | enabled  |
| innodb_rwlock_x_spin_rounds              | server              | enabled  |
| innodb_rwlock_x_spin_waits               | server              | enabled  |
| lock_deadlocks                           | lock                | enabled  |
| lock_rec_locks                           | lock                | disabled |
| lock_rec_lock_created                    | lock                | disabled |
| lock_rec_lock_removed                    | lock                | disabled |
| lock_rec_lock_requests                   | lock                | disabled |
| lock_rec_lock_waits                      | lock                | disabled |
| lock_row_lock_current_waits              | lock                | enabled  |
| lock_row_lock_time                       | lock                | enabled  |
| lock_row_lock_time_avg                   | lock                | enabled  |
| lock_row_lock_time_max                   | lock                | enabled  |
| lock_row_lock_waits                      | lock                | enabled  |
| lock_table_locks                         | lock                | disabled |
| lock_table_lock_created                  | lock                | disabled |
| lock_table_lock_removed                  | lock                | disabled |
| lock_table_lock_waits                    | lock                | disabled |
| lock_timeouts                            | lock                | enabled  |
| log_checkpoints                          | recovery            | disabled |
| log_lsn_buf_pool_oldest                  | recovery            | disabled |
| log_lsn_checkpoint_age                   | recovery            | disabled |
| log_lsn_current                          | recovery            | disabled |
| log_lsn_last_checkpoint                  | recovery            | disabled |
| log_lsn_last_flush                       | recovery            | disabled |
| log_max_modified_age_async               | recovery            | disabled |
| log_max_modified_age_sync                | recovery            | disabled |
| log_num_log_io                           | recovery            | disabled |
| log_padded                               | recovery            | enabled  |
| log_pending_checkpoint_writes            | recovery            | disabled |
| log_pending_log_flushes                  | recovery            | disabled |
| log_waits                                | recovery            | enabled  |
| log_writes                               | recovery            | enabled  |
| log_write_requests                       | recovery            | enabled  |
| metadata_table_handles_closed            | metadata            | disabled |
| metadata_table_handles_opened            | metadata            | disabled |
| metadata_table_reference_count           | metadata            | disabled |
| os_data_fsyncs                           | os                  | enabled  |
| os_data_reads                            | os                  | enabled  |
| os_data_writes                           | os                  | enabled  |
| os_log_bytes_written                     | os                  | enabled  |
| os_log_fsyncs                            | os                  | enabled  |
| os_log_pending_fsyncs                    | os                  | enabled  |
| os_log_pending_writes                    | os                  | enabled  |
| os_pending_reads                         | os                  | disabled |
| os_pending_writes                        | os                  | disabled |
| purge_del_mark_records                   | purge               | disabled |
| purge_dml_delay_usec                     | purge               | disabled |
| purge_invoked                            | purge               | disabled |
| purge_resume_count                       | purge               | disabled |
| purge_stop_count                         | purge               | disabled |
| purge_undo_log_pages                     | purge               | disabled |
| purge_upd_exist_or_extern_records        | purge               | disabled |
| trx_active_transactions                  | transaction         | disabled |
| trx_commits_insert_update                | transaction         | disabled |
| trx_nl_ro_commits                        | transaction         | disabled |
| trx_rollbacks                            | transaction         | disabled |
| trx_rollbacks_savepoint                  | transaction         | disabled |
| trx_rollback_active                      | transaction         | disabled |
| trx_ro_commits                           | transaction         | disabled |
| trx_rseg_current_size                    | transaction         | disabled |
| trx_rseg_history_len                     | transaction         | enabled  |
| trx_rw_commits                           | transaction         | disabled |
| trx_undo_slots_cached                    | transaction         | disabled |
| trx_undo_slots_used                      | transaction         | disabled |
+------------------------------------------+---------------------+----------+
235 rows in set (0.03 sec)

计数器模块
模块名与INNODB_METRICS表中的SUBSYSTEM列对应,但不完全相同。相对于单独启用、禁用或重置计数器,您可以使用模块名称来快速启用、禁用或重置特定子系统的所有计数器。例如,使用module_dml启用与dml子系统关联的所有计数器。

mysql> SELECT name, subsystem, status FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem ='dml';
+-------------+-----------+----------+
| name        | subsystem | status   |
+-------------+-----------+----------+
| dml_reads   | dml       | disabled |
| dml_inserts | dml       | enabled  |
| dml_deletes | dml       | enabled  |
| dml_updates | dml       | enabled  |
+-------------+-----------+----------+
4 rows in set (0.00 sec)

mysql> SET GLOBAL innodb_monitor_enable = module_dml;
Query OK, 0 rows affected (0.00 sec)

mysql> SELECT name, subsystem, status FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem ='dml';
+-------------+-----------+---------+
| name        | subsystem | status  |
+-------------+-----------+---------+
| dml_reads   | dml       | enabled |
| dml_inserts | dml       | enabled |
| dml_deletes | dml       | enabled |
| dml_updates | dml       | enabled |
+-------------+-----------+---------+
4 rows in set (0.00 sec)

下面是innodb_monitor_enable和相关的配置选项可以使用的module_name值以及相应的子系统名称。

.module_adaptive_hash (subsystem = adaptive_hash_index)
.module_buffer (subsystem = buffer)
.module_buffer_page (subsystem = buffer_page_io)
.module_compress (subsystem = compression)
.module_ddl (subsystem = ddl)
.module_dml (subsystem = dml)
.module_file (subsystem = file_system)
.module_ibuf_system (subsystem = change_buffer)
.module_icp (subsystem = icp)
.module_index (subsystem = index)
.module_innodb (subsystem = innodb)
.module_lock (subsystem = lock)
.module_log (subsystem = recovery)
.module_metadata (subsystem = metadata)
.module_os (subsystem = os)
.module_purge (subsystem = purge)
.module_trx (subsystem = transaction)

使用INNODB_METRICS表计数器
下面这个例子演示了启用、禁用、重置计数器,以及查询INNODB_METRICS表中的计数器数据。

1.创建一个简单的InnoDB表;

mysql> use test
Database changed
mysql> CREATE TABLE t1 (c1 INT) ENGINE=INNODB;
Query OK, 0 rows affected (0.01 sec)

2.启用dml_inserts计数器。
先禁用dml_inserts计数器并将所有计数清零

mysql> SET GLOBAL innodb_monitor_disable=dml_inserts;
Query OK, 0 rows affected (0.00 sec)

mysql> SELECT * FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE NAME="dml_inserts" \G
*************************** 1. row ***************************
           NAME: dml_inserts
      SUBSYSTEM: dml
          COUNT: 17263007
      MAX_COUNT: 17263007
      MIN_COUNT: NULL
      AVG_COUNT: 0.817808627174022
    COUNT_RESET: 0
MAX_COUNT_RESET: 0
MIN_COUNT_RESET: NULL
AVG_COUNT_RESET: 0
   TIME_ENABLED: 2023-05-10 09:02:54
  TIME_DISABLED: 2024-01-09 16:37:13
   TIME_ELAPSED: 21108859
     TIME_RESET: NULL
         STATUS: disabled
           TYPE: status_counter
        COMMENT: Number of rows inserted
1 row in set (0.00 sec)

mysql> SET GLOBAL innodb_monitor_reset_all=dml_inserts;
Query OK, 0 rows affected (0.05 sec)

mysql> SELECT * FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE NAME="dml_inserts" \G
*************************** 1. row ***************************
           NAME: dml_inserts
      SUBSYSTEM: dml
          COUNT: 0
      MAX_COUNT: NULL
      MIN_COUNT: NULL
      AVG_COUNT: NULL
    COUNT_RESET: 0
MAX_COUNT_RESET: NULL
MIN_COUNT_RESET: NULL
AVG_COUNT_RESET: NULL
   TIME_ENABLED: NULL
  TIME_DISABLED: NULL
   TIME_ELAPSED: NULL
     TIME_RESET: NULL
         STATUS: disabled
           TYPE: status_counter
        COMMENT: Number of rows inserted
1 row in set (0.00 sec)

再启用dml_inserts计数器

mysql> SET GLOBAL innodb_monitor_enable = dml_inserts;
Query OK, 0 rows affected (0.00 sec)

在INNODB_METRICS表的COMMENT列中找到的关于dml_inserts计数器的描述:

mysql> SELECT NAME, COMMENT FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE NAME="dml_inserts";
+-------------+-------------------------+
| NAME        | COMMENT                 |
+-------------+-------------------------+
| dml_inserts | Number of rows inserted |
+-------------+-------------------------+
1 row in set (0.00 sec)

3.查询INNODB_METRICS表中的dml_inserts计数器数据。因为没有执行DML操作,所以计数器值为零或NULL。TIME_ENABLED和TIME_ELAPSED值表示计数器上次启用的时间,以及从该时间起已经过去了多少秒。

mysql> SELECT * FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE NAME="dml_inserts" \G
*************************** 1. row ***************************
           NAME: dml_inserts
      SUBSYSTEM: dml
          COUNT: 0
      MAX_COUNT: 0
      MIN_COUNT: NULL
      AVG_COUNT: 0
    COUNT_RESET: 0
MAX_COUNT_RESET: 0
MIN_COUNT_RESET: NULL
AVG_COUNT_RESET: NULL
   TIME_ENABLED: 2024-01-09 16:40:33
  TIME_DISABLED: NULL
   TIME_ELAPSED: 150
     TIME_RESET: NULL
         STATUS: enabled
           TYPE: status_counter
        COMMENT: Number of rows inserted
1 row in set (0.00 sec)

4.向表中插入三行数据。

mysql> INSERT INTO t1 values(1);
Query OK, 1 row affected (0.01 sec)

mysql> INSERT INTO t1 values(2);
Query OK, 1 row affected (0.01 sec)

mysql> INSERT INTO t1 values(3);
Query OK, 1 row affected (0.00 sec)

5.再次查询INNODB_METRICS表获取dml_inserts计数器数据。现在有一些计数器的值已经递增,包括COUNT、MAX_COUNT、AVG_COUNT和COUNT_RESET。

mysql> SELECT * FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE NAME="dml_inserts"\G
*************************** 1. row ***************************
           NAME: dml_inserts
      SUBSYSTEM: dml
          COUNT: 3
      MAX_COUNT: 3
      MIN_COUNT: NULL
      AVG_COUNT: 0.00980392156862745
    COUNT_RESET: 3
MAX_COUNT_RESET: 3
MIN_COUNT_RESET: NULL
AVG_COUNT_RESET: NULL
   TIME_ENABLED: 2024-01-09 16:40:33
  TIME_DISABLED: NULL
   TIME_ELAPSED: 306
     TIME_RESET: NULL
         STATUS: enabled
           TYPE: status_counter
        COMMENT: Number of rows inserted
1 row in set (0.00 sec)

6.重置dml_inserts计数器,然后再次在INNODB_METRICS表中查询dml_inserts计数器数据。之前报告的%_RESET值,如COUNT_RESET和MAX_RESET,将重置为零。COUNT、MAX_COUNT和AVG_COUNT等值从计数器启用时开始收集数据,这些值不受重置的影响。

mysql> SET GLOBAL innodb_monitor_disable=dml_inserts;
Query OK, 0 rows affected (0.00 sec)

mysql> SELECT * FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE NAME="dml_inserts"\G
*************************** 1. row ***************************
           NAME: dml_inserts
      SUBSYSTEM: dml
          COUNT: 20
      MAX_COUNT: 20
      MIN_COUNT: NULL
      AVG_COUNT: 0.03424657534246575
    COUNT_RESET: 0
MAX_COUNT_RESET: 0
MIN_COUNT_RESET: NULL
AVG_COUNT_RESET: 0
   TIME_ENABLED: 2024-01-09 16:40:33
  TIME_DISABLED: 2024-01-09 16:50:17
   TIME_ELAPSED: 584
     TIME_RESET: NULL
         STATUS: disabled
           TYPE: status_counter
        COMMENT: Number of rows inserted
1 row in set (0.00 sec)

7.要重置所有计数器值,必须首先禁用计数器。禁用计数器将状态值设置为禁用。

mysql> SET GLOBAL innodb_monitor_disable=dml_inserts;
Query OK, 0 rows affected (0.00 sec)

mysql> SELECT * FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE NAME="dml_inserts"\G
*************************** 1. row ***************************
           NAME: dml_inserts
      SUBSYSTEM: dml
          COUNT: 20
      MAX_COUNT: 20
      MIN_COUNT: NULL
      AVG_COUNT: 0.03076923076923077
    COUNT_RESET: 0
MAX_COUNT_RESET: 0
MIN_COUNT_RESET: NULL
AVG_COUNT_RESET: 0
   TIME_ENABLED: 2024-01-09 16:40:33
  TIME_DISABLED: 2024-01-09 16:51:23
   TIME_ELAPSED: 650
     TIME_RESET: NULL
         STATUS: disabled
           TYPE: status_counter
        COMMENT: Number of rows inserted
1 row in set (0.01 sec)

注意:
计数器和模块名称支持通配符匹配。例如,可以指定dml_i%,而不是指定完整的dml_inserts计数器名称。还可以使用通配符匹配一次启用、禁用或重置多个计数器或模块。例如,指定dml_%来启用、禁用或重置所有以dml_%开头的计数器。

8.当计数器被禁用后,你可以使用innodb_monitor_reset_all选项重置所有计数器的值。所有值都设置为0或NULL。

mysql> SET GLOBAL innodb_monitor_reset_all=dml_inserts;
Query OK, 0 rows affected (0.05 sec)

mysql> SELECT * FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE NAME="dml_inserts"\G
*************************** 1. row ***************************
           NAME: dml_inserts
      SUBSYSTEM: dml
          COUNT: 0
      MAX_COUNT: NULL
      MIN_COUNT: NULL
      AVG_COUNT: NULL
    COUNT_RESET: 0
MAX_COUNT_RESET: NULL
MIN_COUNT_RESET: NULL
AVG_COUNT_RESET: NULL
   TIME_ENABLED: NULL
  TIME_DISABLED: NULL
   TIME_ELAPSED: NULL
     TIME_RESET: NULL
         STATUS: disabled
           TYPE: status_counter
        COMMENT: Number of rows inserted
1 row in set (0.00 sec)
]]>
http://www.jydba.net/index.php/archives/3530/feed 0
MySQL InnoDB INFORMATION_SCHEMA缓冲池表 http://www.jydba.net/index.php/archives/3527 http://www.jydba.net/index.php/archives/3527#respond Tue, 09 Jan 2024 07:12:07 +0000 http://www.jydba.net/?p=3527 InnoDB INFORMATION_SCHEMA缓冲池表
InnoDB INFORMATION_SCHEMA缓冲池表提供了缓冲池状态信息和InnoDB缓冲池中页的元数据。这些表是在MySQL 5.6.2中引入的,后来移植到MySQL 5.5 (MySQL 5.5.28)和MySQL 5.1 (MySQL 5.1.66)。

InnoDB INFORMATION_SCHEMA缓冲池表包括下面这些表:

mysql> show tables from information_schema like 'INNODB_BUFFER%';
+-----------------------------------------------+
| Tables_in_information_schema (INNODB_BUFFER%) |
+-----------------------------------------------+
| INNODB_BUFFER_PAGE_LRU                        |
| INNODB_BUFFER_PAGE                            |
| INNODB_BUFFER_POOL_STATS                      |
+-----------------------------------------------+
3 rows in set (0.00 sec)

.INNODB_BUFFER_PAGE:保存InnoDB缓冲池中每一页的信息。

.INNODB_BUFFER_PAGE_LRU:保存了关于InnoDB缓冲池中页的信息,特别是它们在LRU列表中的排序方式,该列表决定了当缓冲池满时从缓冲池中清除哪些页。INNODB_BUFFER_PAGE_LRU表和INNODB_BUFFER_PAGE表有相同的列,不同的是INNODB_BUFFER_PAGE_LRU表有一个LRU_POSITION列而不是BLOCK_ID列。

.INNODB_BUFFER_POOL_STATS:缓冲池状态信息。大部分相同的信息由SHOW ENGINE INNODB STATUS输出提供,或者可以通过使用INNODB缓冲池服务器状态变量获得。

警示:
查询INNODB_BUFFER_PAGE表或INNODB_BUFFER_PAGE_LRU表会引入显著的性能开销。不要在生产系统上查询这些表,除非您意识到您的查询可能产生的性能影响,并确定它是可接受的。为了避免影响性能,在测试实例上重现您想要调查的问题,并在测试实例上运行您的查询。

查询INNODB_BUFFER_PAGE表中的系统数据
该查询通过排除TABLE_NAME值为NULL或包含表名中有斜杠/或句点.的表名表示用户自定义表,提供了包含系统数据的页面的大致数量。

mysql> select count(*) from information_schema.innodb_buffer_page
    -> where table_name is null or (instr(table_name, '/') = 0 and instr(table_name, '.') = 0);
+----------+
| count(*) |
+----------+
|   451428 |
+----------+
1 row in set (1.80 sec)

该查询返回包含系统数据的大约页数、缓冲池页数和包含系统数据的大约百分比的页数。

mysql> select
    -> (select count(*) from information_schema.innodb_buffer_page
    -> where table_name is null or (instr(table_name, '/') = 0 and instr(table_name, '.') = 0)
    -> ) as system_pages,
    -> (
    -> select count(*)
    -> from information_schema.innodb_buffer_page
    -> ) as total_pages,
    -> (
    -> select round((system_pages/total_pages) * 100)
    -> ) as system_page_percentage;
+--------------+-------------+------------------------+
| system_pages | total_pages | system_page_percentage |
+--------------+-------------+------------------------+
|       451428 |      524224 |                     86 |
+--------------+-------------+------------------------+
1 row in set (3.35 sec)

通过查询PAGE_TYPE的值,可以确定缓冲池中系统数据的类型。例如,下面的查询返回包含系统数据的页的10个不同的PAGE_TYPE值:

mysql> select distinct page_type from information_schema.innodb_buffer_page
    -> where table_name is null or (instr(table_name, '/') = 0 and instr(table_name, '.') = 0);
+-------------------+
| page_type         |
+-------------------+
| SYSTEM            |
| INODE             |
| IBUF_INDEX        |
| INDEX             |
| IBUF_BITMAP       |
| TRX_SYSTEM        |
| FILE_SPACE_HEADER |
| UNKNOWN           |
| UNDO_LOG          |
| EXTENT_DESCRIPTOR |
+-------------------+
10 rows in set (2.02 sec)

查询INNODB_BUFFER_PAGE表中的用户数据
这个查询通过统计TABLE_NAME值不为NULL且不像’%INNODB_SYS_TABLES%’的页面,提供了包含用户数据的页面的近似计数。

mysql> select count(*) from information_schema.innodb_buffer_page
    -> where table_name is not null and table_name not like '%innodb_sys_tables%';
+----------+
| count(*) |
+----------+
|    91067 |
+----------+
1 row in set (1.67 sec)

该查询返回包含用户数据的页面的大致数量、缓冲池页面的总数以及包含用户数据的页面的大致百分比。

mysql> select
    -> (select count(*) from information_schema.innodb_buffer_page
    -> where table_name is not null and (instr(table_name, '/') > 0 or instr(table_name, '.') > 0)
    -> ) as user_pages,
    -> (
    -> select count(*)
    -> from information_schema.innodb_buffer_page
    -> ) as total_pages,
    -> (
    -> select round((user_pages/total_pages) * 100)
    -> ) as user_page_percentage;
+------------+-------------+----------------------+
| user_pages | total_pages | user_page_percentage |
+------------+-------------+----------------------+
|      72796 |      524224 |                   14 |
+------------+-------------+----------------------+
1 row in set (3.31 sec)

这个查询将使用缓冲池中的页的用户定义的表标识出来:

mysql> select distinct table_name from information_schema.innodb_buffer_page
    -> where table_name is not null and (instr(table_name, '/') > 0 or instr(table_name, '.') > 0)
    -> and table_name not like '`mysql`.`innodb_%';
+--------------------------------------------------------+
| table_name                                             |
+--------------------------------------------------------+
| `undo`.`opening_lines`                                 |
| `undo`.`FTS_00000000000001d9_00000000000002da_INDEX_3` |
| `mysql`.`help_category`                                |
| `mysql`.`help_topic`                                   |
| `undo`.`big_table`                                     |
| `undo`.`key_block_size_4`                              |
| `sys`.`sys_config`                                     |
| `test`.`FTS_000000000000020c_DELETED_CACHE`            |
| `undo`.`FTS_00000000000001d9_BEING_DELETED`            |
| `undo`.`FTS_00000000000001d9_00000000000002da_INDEX_4` |
| `mysql`.`help_relation`                                |
| `undo`.`t8`                                            |
| `test`.`FTS_000000000000020c_0000000000000310_INDEX_1` |
| `mysql`.`slave_relay_log_info`                         |
| `undo`.`FTS_00000000000001d9_BEING_DELETED_CACHE`      |
| `undo`.`FTS_00000000000001d9_00000000000002da_INDEX_5` |
| `mysql`.`help_keyword`                                 |
| `undo`.`employees`                                     |
| `undo`.`t13`                                           |
| `test`.`FTS_000000000000020c_0000000000000310_INDEX_2` |
| `mysql`.`time_zone_name`                               |
| `mysql`.`slave_master_info`                            |
| `test`.`t7`                                            |
| `test`.`user`                                          |
| `undo`.`FTS_00000000000001d9_CONFIG`                   |
| `undo`.`FTS_00000000000001d9_00000000000002da_INDEX_6` |
| `undo`.`t9`                                            |
| `undo`.`t14`                                           |
| `test`.`articles`                                      |
| `test`.`FTS_000000000000020c_0000000000000310_INDEX_3` |
| `mysql`.`time_zone`                                    |
| `mysql`.`slave_worker_info`                            |
| `test`.`t8`                                            |
| `undo`.`FTS_00000000000001d9_DELETED`                  |
| `undo`.`t1`                                            |
| `undo`.`t10`                                           |
| `test`.`t1`                                            |
| `test`.`FTS_000000000000020c_BEING_DELETED`            |
| `test`.`FTS_000000000000020c_0000000000000310_INDEX_4` |
| `mysql`.`plugin`                                       |
| `mysql`.`gtid_executed`                                |
| `mysql`.`time_zone_transition`                         |
| `undo`.`FTS_00000000000001d9_DELETED_CACHE`            |
| `undo`.`t2`                                            |
| `undo`.`t11`                                           |
| `test`.`parent`                                        |
| `test`.`FTS_000000000000020c_BEING_DELETED_CACHE`      |
| `test`.`FTS_000000000000020c_0000000000000310_INDEX_5` |
| `mysql`.`server_cost`                                  |
| `mysql`.`time_zone_transition_type`                    |
| `mysql`.`servers`                                      |
| `undo`.`FTS_00000000000001d9_00000000000002da_INDEX_1` |
| `undo`.`t7`                                            |
| `test`.`child`                                         |
| `test`.`FTS_000000000000020c_CONFIG`                   |
| `test`.`FTS_000000000000020c_0000000000000310_INDEX_6` |
| `mysql`.`engine_cost`                                  |
| `mysql`.`time_zone_leap_second`                        |
| `undo`.`FTS_00000000000001d9_00000000000002da_INDEX_2` |
| `undo`.`t12`                                           |
| `test`.`abc`                                           |
| `test`.`FTS_000000000000020c_DELETED`                  |
+--------------------------------------------------------+
62 rows in set (1.81 sec)

查询INNODB_BUFFER_PAGE表中的索引数据
有关索引页的信息,请使用索引的名称查询INDEX_NAME列。例如,下面的查询返回在employees.salaries表上定义的emp_no索引的页数和总数据大小:

mysql> select index_name, count(*) as pages,
    -> round(sum(if(compressed_size = 0, @@global.innodb_page_size, compressed_size))/1024/1024)
    -> as 'total data (mb)'
    -> from information_schema.innodb_buffer_page
    -> where index_name='emp_no' and table_name = '`employees`.`salaries`';
+------------+-------+-----------------+
| index_name | pages | total data (mb) |
+------------+-------+-----------------+
| emp_no     |    44 |               1 |
+------------+-------+-----------------+
1 row in set (1.75 sec)

该查询返回在employees.salaries表上定义的所有索引的页数和总数据大小:

mysql> select index_name, count(*) as pages,
    -> round(sum(if(compressed_size = 0, @@global.innodb_page_size, compressed_size))/1024/1024)
    -> as 'total data (mb)'
    -> from information_schema.innodb_buffer_page
    -> where table_name = '`employees`.`salaries`'
    -> group by index_name;
+------------+-------+-----------------+
| index_name | pages | total data (mb) |
+------------+-------+-----------------+
| emp_no     |    44 |               1 |
| idx_salary |    65 |               1 |
| PRIMARY    |  6086 |              95 |
+------------+-------+-----------------+
3 rows in set (1.73 sec)

查询INNODB_BUFFER_PAGE_LRU表中的LRU_POSITION数据
INNODB_BUFFER_PAGE_LRU表保存了InnoDB缓冲池中页的信息,特别是当缓冲池满时,它们是如何排序的,这决定了哪些页需要从缓冲池中移除。该表的定义与INNODB_BUFFER_PAGE表相同,不同之处在于该表有一个LRU_POSITION列而不是BLOCK_ID列。

该查询计算LRU链表中特定位置上employees.employees表所使用的页数:

mysql> select count(lru_position) from information_schema.innodb_buffer_page_lru
    -> where table_name='`employees`.`employees`' and lru_position < 6570;
+---------------------+
| count(lru_position) |
+---------------------+
|                  13 |
+---------------------+
1 row in set (0.58 sec)

查询INNODB_BUFFER_POOL_STATS表
INNODB_BUFFER_POOL_STATS表提供了类似于SHOW ENGINE INNODB STATUS和INNODB缓冲池状态变量的信息。

mysql> select * from information_schema.innodb_buffer_pool_stats \G
*************************** 1. row ***************************
                         POOL_ID: 0
                       POOL_SIZE: 65528
                    FREE_BUFFERS: 46471
                  DATABASE_PAGES: 17936
              OLD_DATABASE_PAGES: 6640
         MODIFIED_DATABASE_PAGES: 0
              PENDING_DECOMPRESS: 4480
                   PENDING_READS: 0
               PENDING_FLUSH_LRU: 0
              PENDING_FLUSH_LIST: 0
                PAGES_MADE_YOUNG: 16823
            PAGES_NOT_MADE_YOUNG: 19769
           PAGES_MADE_YOUNG_RATE: 0
       PAGES_MADE_NOT_YOUNG_RATE: 0
               NUMBER_PAGES_READ: 857
            NUMBER_PAGES_CREATED: 17087
            NUMBER_PAGES_WRITTEN: 24505
                 PAGES_READ_RATE: 0
               PAGES_CREATE_RATE: 0
              PAGES_WRITTEN_RATE: 0
                NUMBER_PAGES_GET: 3448729
                        HIT_RATE: 0
    YOUNG_MAKE_PER_THOUSAND_GETS: 0
NOT_YOUNG_MAKE_PER_THOUSAND_GETS: 0
         NUMBER_PAGES_READ_AHEAD: 768
       NUMBER_READ_AHEAD_EVICTED: 0
                 READ_AHEAD_RATE: 0
         READ_AHEAD_EVICTED_RATE: 0
                    LRU_IO_TOTAL: 0
                  LRU_IO_CURRENT: 0
                UNCOMPRESS_TOTAL: 0
              UNCOMPRESS_CURRENT: 0
*************************** 2. row ***************************
                         POOL_ID: 1
                       POOL_SIZE: 65528
                    FREE_BUFFERS: 47000
                  DATABASE_PAGES: 17515
              OLD_DATABASE_PAGES: 6485
         MODIFIED_DATABASE_PAGES: 0
              PENDING_DECOMPRESS: 4051
                   PENDING_READS: 0
               PENDING_FLUSH_LRU: 0
              PENDING_FLUSH_LIST: 0
                PAGES_MADE_YOUNG: 0
            PAGES_NOT_MADE_YOUNG: 0
           PAGES_MADE_YOUNG_RATE: 0
       PAGES_MADE_NOT_YOUNG_RATE: 0
               NUMBER_PAGES_READ: 864
            NUMBER_PAGES_CREATED: 16651
            NUMBER_PAGES_WRITTEN: 23771
                 PAGES_READ_RATE: 0
               PAGES_CREATE_RATE: 0
              PAGES_WRITTEN_RATE: 0
                NUMBER_PAGES_GET: 5410983
                        HIT_RATE: 0
    YOUNG_MAKE_PER_THOUSAND_GETS: 0
NOT_YOUNG_MAKE_PER_THOUSAND_GETS: 0
         NUMBER_PAGES_READ_AHEAD: 832
       NUMBER_READ_AHEAD_EVICTED: 0
                 READ_AHEAD_RATE: 0
         READ_AHEAD_EVICTED_RATE: 0
                    LRU_IO_TOTAL: 0
                  LRU_IO_CURRENT: 0
                UNCOMPRESS_TOTAL: 0
              UNCOMPRESS_CURRENT: 0
*************************** 3. row ***************************
                         POOL_ID: 2
                       POOL_SIZE: 65528
                    FREE_BUFFERS: 46659
                  DATABASE_PAGES: 17733
              OLD_DATABASE_PAGES: 6565
         MODIFIED_DATABASE_PAGES: 0
              PENDING_DECOMPRESS: 4544
                   PENDING_READS: 0
               PENDING_FLUSH_LRU: 0
              PENDING_FLUSH_LIST: 0
                PAGES_MADE_YOUNG: 0
            PAGES_NOT_MADE_YOUNG: 0
           PAGES_MADE_YOUNG_RATE: 0
       PAGES_MADE_NOT_YOUNG_RATE: 0
               NUMBER_PAGES_READ: 755
            NUMBER_PAGES_CREATED: 16978
            NUMBER_PAGES_WRITTEN: 23908
                 PAGES_READ_RATE: 0
               PAGES_CREATE_RATE: 0
              PAGES_WRITTEN_RATE: 0
                NUMBER_PAGES_GET: 3462987
                        HIT_RATE: 0
    YOUNG_MAKE_PER_THOUSAND_GETS: 0
NOT_YOUNG_MAKE_PER_THOUSAND_GETS: 0
         NUMBER_PAGES_READ_AHEAD: 640
       NUMBER_READ_AHEAD_EVICTED: 0
                 READ_AHEAD_RATE: 0
         READ_AHEAD_EVICTED_RATE: 0
                    LRU_IO_TOTAL: 0
                  LRU_IO_CURRENT: 0
                UNCOMPRESS_TOTAL: 0
              UNCOMPRESS_CURRENT: 0
*************************** 4. row ***************************
                         POOL_ID: 3
                       POOL_SIZE: 65528
                    FREE_BUFFERS: 46644
                  DATABASE_PAGES: 17751
              OLD_DATABASE_PAGES: 6572
         MODIFIED_DATABASE_PAGES: 0
              PENDING_DECOMPRESS: 4528
                   PENDING_READS: 0
               PENDING_FLUSH_LRU: 0
              PENDING_FLUSH_LIST: 0
                PAGES_MADE_YOUNG: 2251
            PAGES_NOT_MADE_YOUNG: 17746
           PAGES_MADE_YOUNG_RATE: 0
       PAGES_MADE_NOT_YOUNG_RATE: 0
               NUMBER_PAGES_READ: 802
            NUMBER_PAGES_CREATED: 16961
            NUMBER_PAGES_WRITTEN: 23848
                 PAGES_READ_RATE: 0
               PAGES_CREATE_RATE: 0
              PAGES_WRITTEN_RATE: 0
                NUMBER_PAGES_GET: 4188354
                        HIT_RATE: 0
    YOUNG_MAKE_PER_THOUSAND_GETS: 0
NOT_YOUNG_MAKE_PER_THOUSAND_GETS: 0
         NUMBER_PAGES_READ_AHEAD: 768
       NUMBER_READ_AHEAD_EVICTED: 0
                 READ_AHEAD_RATE: 0
         READ_AHEAD_EVICTED_RATE: 0
                    LRU_IO_TOTAL: 0
                  LRU_IO_CURRENT: 0
                UNCOMPRESS_TOTAL: 0
              UNCOMPRESS_CURRENT: 0
*************************** 5. row ***************************
                         POOL_ID: 4
                       POOL_SIZE: 65528
                    FREE_BUFFERS: 46660
                  DATABASE_PAGES: 17729
              OLD_DATABASE_PAGES: 6564
         MODIFIED_DATABASE_PAGES: 0
              PENDING_DECOMPRESS: 4550
                   PENDING_READS: 0
               PENDING_FLUSH_LRU: 0
              PENDING_FLUSH_LIST: 0
                PAGES_MADE_YOUNG: 0
            PAGES_NOT_MADE_YOUNG: 0
           PAGES_MADE_YOUNG_RATE: 0
       PAGES_MADE_NOT_YOUNG_RATE: 0
               NUMBER_PAGES_READ: 792
            NUMBER_PAGES_CREATED: 16937
            NUMBER_PAGES_WRITTEN: 24222
                 PAGES_READ_RATE: 0
               PAGES_CREATE_RATE: 0
              PAGES_WRITTEN_RATE: 0
                NUMBER_PAGES_GET: 4314265
                        HIT_RATE: 0
    YOUNG_MAKE_PER_THOUSAND_GETS: 0
NOT_YOUNG_MAKE_PER_THOUSAND_GETS: 0
         NUMBER_PAGES_READ_AHEAD: 768
       NUMBER_READ_AHEAD_EVICTED: 0
                 READ_AHEAD_RATE: 0
         READ_AHEAD_EVICTED_RATE: 0
                    LRU_IO_TOTAL: 0
                  LRU_IO_CURRENT: 0
                UNCOMPRESS_TOTAL: 0
              UNCOMPRESS_CURRENT: 0
*************************** 6. row ***************************
                         POOL_ID: 5
                       POOL_SIZE: 65528
                    FREE_BUFFERS: 46748
                  DATABASE_PAGES: 17642
              OLD_DATABASE_PAGES: 6532
         MODIFIED_DATABASE_PAGES: 0
              PENDING_DECOMPRESS: 4548
                   PENDING_READS: 0
               PENDING_FLUSH_LRU: 0
              PENDING_FLUSH_LIST: 0
                PAGES_MADE_YOUNG: 0
            PAGES_NOT_MADE_YOUNG: 0
           PAGES_MADE_YOUNG_RATE: 0
       PAGES_MADE_NOT_YOUNG_RATE: 0
               NUMBER_PAGES_READ: 790
            NUMBER_PAGES_CREATED: 16852
            NUMBER_PAGES_WRITTEN: 23741
                 PAGES_READ_RATE: 0
               PAGES_CREATE_RATE: 0
              PAGES_WRITTEN_RATE: 0
                NUMBER_PAGES_GET: 3449085
                        HIT_RATE: 0
    YOUNG_MAKE_PER_THOUSAND_GETS: 0
NOT_YOUNG_MAKE_PER_THOUSAND_GETS: 0
         NUMBER_PAGES_READ_AHEAD: 768
       NUMBER_READ_AHEAD_EVICTED: 0
                 READ_AHEAD_RATE: 0
         READ_AHEAD_EVICTED_RATE: 0
                    LRU_IO_TOTAL: 0
                  LRU_IO_CURRENT: 0
                UNCOMPRESS_TOTAL: 0
              UNCOMPRESS_CURRENT: 0
*************************** 7. row ***************************
                         POOL_ID: 6
                       POOL_SIZE: 65528
                    FREE_BUFFERS: 46821
                  DATABASE_PAGES: 17571
              OLD_DATABASE_PAGES: 6506
         MODIFIED_DATABASE_PAGES: 0
              PENDING_DECOMPRESS: 4544
                   PENDING_READS: 0
               PENDING_FLUSH_LRU: 0
              PENDING_FLUSH_LIST: 0
                PAGES_MADE_YOUNG: 0
            PAGES_NOT_MADE_YOUNG: 0
           PAGES_MADE_YOUNG_RATE: 0
       PAGES_MADE_NOT_YOUNG_RATE: 0
               NUMBER_PAGES_READ: 727
            NUMBER_PAGES_CREATED: 16844
            NUMBER_PAGES_WRITTEN: 24005
                 PAGES_READ_RATE: 0
               PAGES_CREATE_RATE: 0
              PAGES_WRITTEN_RATE: 0
                NUMBER_PAGES_GET: 3852166
                        HIT_RATE: 0
    YOUNG_MAKE_PER_THOUSAND_GETS: 0
NOT_YOUNG_MAKE_PER_THOUSAND_GETS: 0
         NUMBER_PAGES_READ_AHEAD: 704
       NUMBER_READ_AHEAD_EVICTED: 0
                 READ_AHEAD_RATE: 0
         READ_AHEAD_EVICTED_RATE: 0
                    LRU_IO_TOTAL: 0
                  LRU_IO_CURRENT: 0
                UNCOMPRESS_TOTAL: 0
              UNCOMPRESS_CURRENT: 0
*************************** 8. row ***************************
                         POOL_ID: 7
                       POOL_SIZE: 65528
                    FREE_BUFFERS: 46651
                  DATABASE_PAGES: 17749
              OLD_DATABASE_PAGES: 6571
         MODIFIED_DATABASE_PAGES: 0
              PENDING_DECOMPRESS: 4512
                   PENDING_READS: 0
               PENDING_FLUSH_LRU: 0
              PENDING_FLUSH_LIST: 0
                PAGES_MADE_YOUNG: 0
            PAGES_NOT_MADE_YOUNG: 0
           PAGES_MADE_YOUNG_RATE: 0
       PAGES_MADE_NOT_YOUNG_RATE: 0
               NUMBER_PAGES_READ: 804
            NUMBER_PAGES_CREATED: 16945
            NUMBER_PAGES_WRITTEN: 23958
                 PAGES_READ_RATE: 0
               PAGES_CREATE_RATE: 0
              PAGES_WRITTEN_RATE: 0
                NUMBER_PAGES_GET: 3606901
                        HIT_RATE: 0
    YOUNG_MAKE_PER_THOUSAND_GETS: 0
NOT_YOUNG_MAKE_PER_THOUSAND_GETS: 0
         NUMBER_PAGES_READ_AHEAD: 768
       NUMBER_READ_AHEAD_EVICTED: 0
                 READ_AHEAD_RATE: 0
         READ_AHEAD_EVICTED_RATE: 0
                    LRU_IO_TOTAL: 0
                  LRU_IO_CURRENT: 0
                UNCOMPRESS_TOTAL: 0
              UNCOMPRESS_CURRENT: 0
8 rows in set (0.00 sec)

为了比较,SHOW ENGINE INNODB STATUS输出和INNODB缓冲池状态变量输出如下所示,基于相同的数据集。

mysql> show engine innodb status \G
......

----------------------
BUFFER POOL AND MEMORY
----------------------
Total large memory allocated 8795455488
Dictionary memory allocated 519969
Buffer pool size   524224
Free buffers       373654
Database pages     141626
Old database pages 52435
Modified db pages  0
Pending reads      0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 19074, not young 37515
0.00 youngs/s, 0.00 non-youngs/s
Pages read 6391, created 135255, written 191958
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
No buffer pool page gets since the last printout
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 141626, unzip_LRU len: 35757
I/O sum[0]:cur[0], unzip sum[0]:cur[0]
----------------------
INDIVIDUAL BUFFER POOL INFO
----------------------
---BUFFER POOL 0
Buffer pool size   65528
Free buffers       46471
Database pages     17936
Old database pages 6640
Modified db pages  0
Pending reads      0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 16823, not young 19769
0.00 youngs/s, 0.00 non-youngs/s
Pages read 857, created 17087, written 24505
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
No buffer pool page gets since the last printout
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 17936, unzip_LRU len: 4480
I/O sum[0]:cur[0], unzip sum[0]:cur[0]
---BUFFER POOL 1
Buffer pool size   65528
Free buffers       47000
Database pages     17515
Old database pages 6485
Modified db pages  0
Pending reads      0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 0, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 864, created 16651, written 23771
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
No buffer pool page gets since the last printout
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 17515, unzip_LRU len: 4051
I/O sum[0]:cur[0], unzip sum[0]:cur[0]
---BUFFER POOL 2
Buffer pool size   65528
Free buffers       46659
Database pages     17733
Old database pages 6565
Modified db pages  0
Pending reads      0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 0, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 755, created 16978, written 23908
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
No buffer pool page gets since the last printout
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 17733, unzip_LRU len: 4544
I/O sum[0]:cur[0], unzip sum[0]:cur[0]
---BUFFER POOL 3
Buffer pool size   65528
Free buffers       46644
Database pages     17751
Old database pages 6572
Modified db pages  0
Pending reads      0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 2251, not young 17746
0.00 youngs/s, 0.00 non-youngs/s
Pages read 802, created 16961, written 23848
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
No buffer pool page gets since the last printout
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 17751, unzip_LRU len: 4528
I/O sum[0]:cur[0], unzip sum[0]:cur[0]
---BUFFER POOL 4
Buffer pool size   65528
Free buffers       46660
Database pages     17729
Old database pages 6564
Modified db pages  0
Pending reads      0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 0, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 792, created 16937, written 24222
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
No buffer pool page gets since the last printout
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 17729, unzip_LRU len: 4550
I/O sum[0]:cur[0], unzip sum[0]:cur[0]
---BUFFER POOL 5
Buffer pool size   65528
Free buffers       46748
Database pages     17642
Old database pages 6532
Modified db pages  0
Pending reads      0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 0, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 790, created 16852, written 23741
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
No buffer pool page gets since the last printout
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 17642, unzip_LRU len: 4548
I/O sum[0]:cur[0], unzip sum[0]:cur[0]
---BUFFER POOL 6
Buffer pool size   65528
Free buffers       46821
Database pages     17571
Old database pages 6506
Modified db pages  0
Pending reads      0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 0, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 727, created 16844, written 24005
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
No buffer pool page gets since the last printout
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 17571, unzip_LRU len: 4544
I/O sum[0]:cur[0], unzip sum[0]:cur[0]
---BUFFER POOL 7
Buffer pool size   65528
Free buffers       46651
Database pages     17749
Old database pages 6571
Modified db pages  0
Pending reads      0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 0, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 804, created 16945, written 23958
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
No buffer pool page gets since the last printout
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 17749, unzip_LRU len: 4512
I/O sum[0]:cur[0], unzip sum[0]:cur[0]
......


mysql> show status like 'Innodb_buffer%';
+---------------------------------------+--------------------------------------------------+
| Variable_name                         | Value                                            |
+---------------------------------------+--------------------------------------------------+
| Innodb_buffer_pool_dump_status        | Dumping of buffer pool not started               |
| Innodb_buffer_pool_load_status        | Buffer pool(s) load completed at 230510  9:02:54 |
| Innodb_buffer_pool_resize_status      |                                                  |
| Innodb_buffer_pool_pages_data         | 141626                                           |
| Innodb_buffer_pool_bytes_data         | 2466910208                                       |
| Innodb_buffer_pool_pages_dirty        | 0                                                |
| Innodb_buffer_pool_bytes_dirty        | 0                                                |
| Innodb_buffer_pool_pages_flushed      | 154983                                           |
| Innodb_buffer_pool_pages_free         | 373654                                           |
| Innodb_buffer_pool_pages_misc         | 8944                                             |
| Innodb_buffer_pool_pages_total        | 524224                                           |
| Innodb_buffer_pool_read_ahead_rnd     | 0                                                |
| Innodb_buffer_pool_read_ahead         | 6016                                             |
| Innodb_buffer_pool_read_ahead_evicted | 0                                                |
| Innodb_buffer_pool_read_requests      | 31733470                                         |
| Innodb_buffer_pool_reads              | 376                                              |
| Innodb_buffer_pool_wait_free          | 0                                                |
| Innodb_buffer_pool_write_requests     | 15535407                                         |
+---------------------------------------+--------------------------------------------------+
18 rows in set (0.01 sec)
]]>
http://www.jydba.net/index.php/archives/3527/feed 0
MySQL InnoDB INFORMATION_SCHEMA全文索引表 http://www.jydba.net/index.php/archives/3524 http://www.jydba.net/index.php/archives/3524#respond Thu, 04 Jan 2024 07:08:20 +0000 http://www.jydba.net/?p=3524 InnoDB INFORMATION_SCHEMA全文索引表
随着MySQL 5.6.4对InnoDB表的全文索引支持的引入,以下表被添加到INFORMATION_SCHEMA数据库中:

mysql> show tables from information_schema like 'INNODB_FT%';
+-------------------------------------------+
| Tables_in_information_schema (INNODB_FT%) |
+-------------------------------------------+
| INNODB_FT_CONFIG                          |
| INNODB_FT_BEING_DELETED                   |
| INNODB_FT_DELETED                         |
| INNODB_FT_DEFAULT_STOPWORD                |
| INNODB_FT_INDEX_TABLE                     |
| INNODB_FT_INDEX_CACHE                     |
+-------------------------------------------+
6 rows in set (0.00 sec)

.INNODB_FT_CONFIG:显示关于InnoDB表的全文索引和相关处理的元数据。

.INNODB_FT_BEING_DELETED:提供INNODB_FT_DELETED表的快照,仅在使用optimizer table执行维护时使用。当OPTIMIZE TABLE运行时,INNODB_FT_BEING_DELETED表被清空,doc_id从INNODB_FT_DELETED表中移除。因为INNODB_FT_BEING_DELETED的内容的生命周期通常很短,所以该表在监控或调试方面的用途有限。

.INNODB_FT_DELETED:从InnoDB表的全文索引中删除的记录。为了避免在DML操作中对InnoDB全文索引进行昂贵的索引重组,新删除的单词的信息被单独存储,在执行文本搜索时从搜索结果中过滤,并且只有在运行OPTIMIZE TABLE时才从主搜索索引中删除。

.INNODB_FT_DEFAULT_STOPWORD:保存在创建全文索引时默认使用的停用词列表。

.INNODB_FT_INDEX_TABLE:包含用于处理全文索引的文本搜索的倒排索引的数据。

.INNODB_FT_INDEX_CACHE:包含新插入的行在全文索引中的标记信息。为了避免DML操作过程中昂贵的索引重组,新索引词的信息被单独存储,并仅在优化表运行时、服务器关闭时或缓存大小超过innodb_ft_cache_size或innodb_ft_total_cache_size定义的限制时才与主搜索索引结合。

注意:
除了INNODB_FT_DEFAULT_STOPWORD表,你必须将innodb_ft_aux_table配置变量设置为包含全文索引的表名(database_name/table_name)。否则,InnoDB的全文索引INFORMATION_SCHEMA表显示为空。

InnoDB全文索引INFORMATION_SCHEMA表
这个例子使用一个带全文索引的表来演示全文索引INFORMATION_SCHEMA表中包含的数据。
1.创建一个包含全文索引的表并插入一些数据:

mysql> create table articles (
    -> id int unsigned auto_increment not null primary key,
    -> title varchar(200),
    -> body text,
    -> fulltext (title,body)
    -> ) engine=innodb;
Query OK, 0 rows affected (0.05 sec)

mysql> insert into articles (title,body) values
    -> ('MySQL Tutorial','DBMS stands for DataBase ...'),
    -> ('How To Use MySQL Well','After you went through a ...'),
    -> ('Optimizing MySQL','In this tutorial we will show ...'),
    -> ('1001 MySQL Tricks','1. Never run mysqld as root. 2. ...'),
    -> ('MySQL vs. YourSQL','In the following database comparison ...'),
    -> ('MySQL Security','When configured properly, MySQL ...');
Query OK, 6 rows affected (0.01 sec)
Records: 6  Duplicates: 0  Warnings: 0

2.设置innodb_ft_aux_table变量为FULLTEXT索引表的名称。如果没有设置这个变量,除了INNODB_FT_DEFAULT_STOPWORD表之外,InnoDB的FULLTEXT INFORMATION_SCHEMA表将显示为空。

mysql> set global innodb_ft_aux_table = 'test/articles';
Query OK, 0 rows affected (0.00 sec)

mysql> show variables like '%aux_table%';
+---------------------+---------------+
| Variable_name       | Value         |
+---------------------+---------------+
| innodb_ft_aux_table | test/articles |
+---------------------+---------------+
1 row in set (0.01 sec)

3.查询INNODB_FT_INDEX_CACHE表,它显示了在全文索引中新插入的行信息。为了避免DML操作期间昂贵的索引重组,新插入行的数据将保留在全文索引缓存中,直到优化表运行(或直到服务器关闭或超过缓存限制)。

mysql> select * from information_schema.innodb_ft_index_cache limit 5;
+------------+--------------+-------------+-----------+--------+----------+
| WORD       | FIRST_DOC_ID | LAST_DOC_ID | DOC_COUNT | DOC_ID | POSITION |
+------------+--------------+-------------+-----------+--------+----------+
| 1001       |            5 |           5 |         1 |      5 |        0 |
| after      |            3 |           3 |         1 |      3 |       22 |
| comparison |            6 |           6 |         1 |      6 |       44 |
| configured |            7 |           7 |         1 |      7 |       20 |
| database   |            2 |           6 |         2 |      2 |       31 |
+------------+--------------+-------------+-----------+--------+----------+
5 rows in set (0.00 sec)

4.启用innodb_optimize_fulltext_only,在包含全文索引的表上运行OPTIMIZE TABLE。此操作将全文索引缓存的内容刷新到主全文索引。innodb_optimize_fulltext_only改变了optimize_table语句在InnoDB表上的操作方式,并且是在对带有全文索引的InnoDB表进行维护操作时临时启用的。

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

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


mysql> optimize table articles;
+---------------+----------+----------+----------+
| Table         | Op       | Msg_type | Msg_text |
+---------------+----------+----------+----------+
| test.articles | optimize | status   | OK       |
+---------------+----------+----------+----------+
1 row in set (0.01 sec)

5.查询INNODB_FT_INDEX_TABLE表,查看主要全文索引中的数据信息,包括刚刚从全文索引缓存中刷新的数据信息。

mysql> select * from information_schema.innodb_ft_index_table limit 5;
+------------+--------------+-------------+-----------+--------+----------+
| WORD       | FIRST_DOC_ID | LAST_DOC_ID | DOC_COUNT | DOC_ID | POSITION |
+------------+--------------+-------------+-----------+--------+----------+
| 1001       |            5 |           5 |         1 |      5 |        0 |
| after      |            3 |           3 |         1 |      3 |       22 |
| comparison |            6 |           6 |         1 |      6 |       44 |
| configured |            7 |           7 |         1 |      7 |       20 |
| database   |            2 |           6 |         2 |      2 |       31 |
+------------+--------------+-------------+-----------+--------+----------+
5 rows in set (0.00 sec)

INNODB_FT_INDEX_CACHE表现在是空的,因为优化表操作刷新了全文索引缓存。

mysql> select * from information_schema.innodb_ft_index_cache limit 5;
Empty set (0.00 sec)

6.从test/articles表中删除一些记录。

mysql> delete from test.articles where id < 4;
Query OK, 3 rows affected (0.01 sec)

7.查询INNODB_FT_DELETED表。该表记录从全文索引中删除的行。为了避免DML操作期间昂贵的索引重组,新删除记录的信息被单独存储,在进行文本搜索时从搜索结果中过滤,在运行OPTIMIZE TABLE时从主搜索索引中删除。

mysql> select * from information_schema.innodb_ft_deleted;
+--------+
| DOC_ID |
+--------+
|      2 |
|      3 |
|      4 |
+--------+
3 rows in set (0.01 sec)

8.运行OPTIMIZE TABLE删除删除的记录。

mysql> optimize table articles;
+---------------+----------+----------+----------+
| Table         | Op       | Msg_type | Msg_text |
+---------------+----------+----------+----------+
| test.articles | optimize | status   | OK       |
+---------------+----------+----------+----------+
1 row in set (0.03 sec)

INNODB_FT_DELETED表现在应该是空的。

mysql> select * from information_schema.innodb_ft_deleted;
Empty set (0.00 sec)

9.查询INNODB_FT_CONFIG表。该表包含关于全文索引和相关处理的元数据:
.optimize_checkpoint_limit是optimize table运行结束的秒数。

.synced_doc_id是下一个要发布的DOC_ID。

.stopword_table_name是用户定义的停止词表的数据库/表名。如果没有用户定义的停用词表,该字段显示为空。

.use_stopword表示是否使用stopword表,stopword表在创建FULLTEXT索引时定义。

mysql> select * from information_schema.innodb_ft_config;
+---------------------------+-------+
| KEY                       | VALUE |
+---------------------------+-------+
| optimize_checkpoint_limit | 180   |
| synced_doc_id             | 8     |
| stopword_table_name       |       |
| use_stopword              | 1     |
+---------------------------+-------+
4 rows in set (0.00 sec)
]]>
http://www.jydba.net/index.php/archives/3524/feed 0
MySQL InnoDB INFORMATION_SCHEMA系统表 http://www.jydba.net/index.php/archives/3521 http://www.jydba.net/index.php/archives/3521#respond Tue, 02 Jan 2024 07:04:23 +0000 http://www.jydba.net/?p=3521 InnoDB INFORMATION_SCHEMA系统表
你可以使用InnoDB INFORMATION_SCHEMA系统表来提取由InnoDB管理的schema对象的元数据。这些信息来自InnoDB内部的系统表(也称为InnoDB数据字典),它不能像普通的InnoDB表那样直接查询。传统上,你可以使用InnoDB监视器技术来获取这类信息,设置InnoDB监视器并解析SHOW ENGINE InnoDB STATUS语句的输出。InnoDB INFORMATION_SCHEMA表接口允许你使用SQL查询这些数据。

除了INNODB_SYS_TABLESTATS没有对应的内部系统表外,InnoDB INFORMATION_SCHEMA系统表中的数据都是直接从InnoDB内部系统表中读取的,而不是从内存中缓存的元数据中读取。

InnoDB INFORMATION_SCHEMA系统表包括下面列出的表。INNODB_SYS_DATAFILES和INNODB_SYS_TABLESPACES是在MySQL 5.6.6中添加的,引入了对CREATE TABLE语句中的DATA DIRECTORY=’ DIRECTORY ‘子句的支持,它允许InnoDB file-per-table表空间(在MySQL数据目录之外的位置创建ibd文件。

mysql> SHOW TABLES FROM INFORMATION_SCHEMA LIKE 'INNODB_SYS%';
+--------------------------------------------+
| Tables_in_information_schema (INNODB_SYS%) |
+--------------------------------------------+
| INNODB_SYS_DATAFILES                       |
| INNODB_SYS_VIRTUAL                         |
| INNODB_SYS_INDEXES                         |
| INNODB_SYS_TABLES                          |
| INNODB_SYS_FIELDS                          |
| INNODB_SYS_TABLESPACES                     |
| INNODB_SYS_FOREIGN_COLS                    |
| INNODB_SYS_COLUMNS                         |
| INNODB_SYS_FOREIGN                         |
| INNODB_SYS_TABLESTATS                      |
+--------------------------------------------+
10 rows in set (0.00 sec)

表名表明所提供的数据类型:
.INNODB_SYS_TABLES提供关于InnoDB表的元数据,等价于InnoDB数据字典中的SYS_TABLES表中的信息。

.INNODB_SYS_COLUMNS提供关于InnoDB表列的元数据,等价于InnoDB数据字典中的SYS_COLUMNS表中的信息。

.INNODB_SYS_INDEXES提供有关InnoDB索引的元数据,等价于InnoDB数据字典中的SYS_INDEXES表中的信息。

.INNODB_SYS_FIELDS提供了InnoDB索引中关键列(字段)的元数据,等价于InnoDB数据字典中的SYS_FIELDS表中的信息。

.INNODB_SYS_TABLESTATS提供了关于InnoDB表的底层状态信息的视图,这些状态信息来源于内存中的数据结构。没有对应的内部InnoDB系统表。

.INNODB_SYS_DATAFILES提供了InnoDB file-per-table件和一般表空间的数据文件路径信息,等价于InnoDB数据字典中的SYS_DATAFILES表中的信息。

.INNODB_SYS_TABLESPACES提供了关于InnoDB file-per-table和一般表空间的元数据,等价于InnoDB数据字典中的SYS_TABLESPACES表中的信息。

.INNODB_SYS_FOREIGN提供了定义在InnoDB表上的外键的元数据,等价于InnoDB数据字典中的SYS_FOREIGN表中的信息。

.INNODB_SYS_FOREIGN_COLS提供了定义在InnoDB表中的外键列的元数据,等价于InnoDB数据字典中的SYS_FOREIGN_COLS表中的信息。

InnoDB INFORMATION_SCHEMA系统表可以通过TABLE_ID、INDEX_ID和SPACE等字段连接在一起,让你可以轻松地检索到你想要研究或监控的对象的所有可用数据。

这个例子使用一个简单的表(t1)和一个索引(i1)来展示在InnoDB INFORMATION_SCHEMA系统表中发现的元数据的类型。
1.创建表t1:

mysql> use test;
Database changed
mysql> create table t1 (
    -> col1 int,
    -> col2 char(10),
    -> col3 varchar(10))
    -> engine = innodb;
Query OK, 0 rows affected (0.04 sec)

mysql> create index i1 on t1(col1);
Query OK, 0 rows affected (0.02 sec)
Records: 0  Duplicates: 0  Warnings: 0

2.创建表t1后,查询innodb_sys_tables来定位test/t1的元数据:

mysql> select * from information_schema.innodb_sys_tables where name='test/t1' \G
*************************** 1. row ***************************
     TABLE_ID: 509
         NAME: test/t1
         FLAG: 33
       N_COLS: 6
        SPACE: 508
  FILE_FORMAT: Barracuda
   ROW_FORMAT: Dynamic
ZIP_PAGE_SIZE: 0
   SPACE_TYPE: Single
1 row in set (0.01 sec)

表t1的TABLE_ID是509。FLAG字段提供了有关表格式和存储特性的位级别信息。有6列,其中3列是由InnoDB创建的隐藏列(DB_ROW_ID, DB_TRX_ID和DB_ROLL_PTR)。表空间的ID是508(值为0表示表驻留在system表空间中)。FILE_FORMAT是Barracuda格式,ROW_FORMAT是Dynamic格式。ZIP_PAGE_SIZE只适用于行格式压缩的表。

3.使用innodb_sys_tables中的table_id信息,查询innodb_sys_columns表中关于表的列的信息。

mysql> select * from information_schema.innodb_sys_columns where table_id = 509 \G
*************************** 1. row ***************************
TABLE_ID: 509
    NAME: col1
     POS: 0
   MTYPE: 6
  PRTYPE: 1027
     LEN: 4
*************************** 2. row ***************************
TABLE_ID: 509
    NAME: col2
     POS: 1
   MTYPE: 13
  PRTYPE: 2949374
     LEN: 40
*************************** 3. row ***************************
TABLE_ID: 509
    NAME: col3
     POS: 2
   MTYPE: 12
  PRTYPE: 2949135
     LEN: 40
3 rows in set (0.00 sec)

除了TABLE_ID和NAME列之外,INNODB_SYS_COLUMNS还提供了每列的序号位置(POS)(从0开始,顺序递增),列的MTYPE或“主类型”(6 = INT,13 = CHAR, 12 = VARCHAR), PRTYPE或“精确类型”(一个二进制值,用比特表示MySQL的数据类型,字符集代码和可空性),以及列的长度(LEN)。

4.再次使用innodb_sys_tables中的table_id信息,查询innodb_sys_indexes,获取与表t1相关的索引信息。

mysql> select * from information_schema.innodb_sys_indexes where table_id = 509 \G
*************************** 1. row ***************************
       INDEX_ID: 758
           NAME: GEN_CLUST_INDEX
       TABLE_ID: 509
           TYPE: 1
       N_FIELDS: 0
        PAGE_NO: 3
          SPACE: 508
MERGE_THRESHOLD: 50
*************************** 2. row ***************************
       INDEX_ID: 759
           NAME: i1
       TABLE_ID: 509
           TYPE: 0
       N_FIELDS: 1
        PAGE_NO: 4
          SPACE: 508
MERGE_THRESHOLD: 50
2 rows in set (0.01 sec)

INNODB_SYS_INDEXES返回两个索引的数据第一个索引是GEN_CLUST_INDEX,如果表没有用户定义的聚集索引,它是由InnoDB创建的聚集索引。第二个索引(i1)是用户定义的辅助索引。

INDEX_ID是索引的标识符,在一个实例中的所有数据库中都是唯一的。TABLE_ID标识了索引关联的表。索引TYPE值指示索引类型(1 =集群索引,0 =辅助索引)。n_fields值是组成索引的字段数目。PAGE_NO是索引B-tree的根页号,SPACE是索引所在的表空间ID。非零值表示索引不在系统表空间中。MERGE_THRESHOLD定义索引页中数据量的百分比阈值。当删除一行或者更新操作缩短一行时,如果索引页中的数据量低于这个值(默认值为50%),InnoDB会尝试将索引页与相邻的索引页合并。

5.使用innodb_sys_indexes中的index_id信息,查询innodb_sys_fields中索引i1的字段信息。

mysql> select * from information_schema.innodb_sys_fields where index_id = 759 \G
*************************** 1. row ***************************
INDEX_ID: 759
    NAME: col1
     POS: 0
1 row in set (0.01 sec)

INNODB_SYS_FIELDS提供了索引字段的名称及其在索引中的序号位置。如果索引(i1)定义在多个字段上,INNODB_SYS_FIELDS将为每个被索引的字段提供元数据。

6.使用innodb_sys_tables中的space信息,查询innodb_sys_tables]表获得关于表的表空间信息。

mysql> select * from information_schema.innodb_sys_tablespaces where space = 508 \G
*************************** 1. row ***************************
         SPACE: 508
          NAME: test/t1
          FLAG: 33
   FILE_FORMAT: Barracuda
    ROW_FORMAT: Dynamic
     PAGE_SIZE: 16384
 ZIP_PAGE_SIZE: 0
    SPACE_TYPE: Single
 FS_BLOCK_SIZE: 4096
     FILE_SIZE: 114688
ALLOCATED_SIZE: 114688
1 row in set (0.05 sec)

除了表空间的SPACE ID和关联表的NAME之外,INNODB_SYS_TABLESPACES还提供了表空间的FLAG数据,这是有关表空间格式和存储特性的位级别信息。还提供了表空间FILE_FORMAT、ROW_FORMAT、PAGE_SIZE和其他几个表空间元数据项。

7.再次使用INNODB_SYS_TABLES中的SPACE信息,查询INNODB_SYS_DATAFILES表空间数据文件的位置。

mysql> select * from information_schema.innodb_sys_datafiles where space = 508 \G
*************************** 1. row ***************************
SPACE: 508
 PATH: ./test/t1.ibd
1 row in set (0.00 sec)

该数据文件位于MySQL的data目录下的test目录中。如果使用CREATE TABLE语句的data directory子句在MySQL数据目录之外的位置创建一个file-per-table表空间,那么表空间路径将是一个完全限定的目录路径。

8.最后一步,在表t1 (TABLE_ID = 509)中插入一行,然后查看INNODB_SYS_TABLESTATS表中的数据。MySQL优化器使用该表中的数据来计算查询InnoDB表时使用的索引。该信息来源于内存中的数据结构。没有对应的内部InnoDB系统表。

mysql> insert into t1 values(5, 'abc', 'def');
Query OK, 1 row affected (0.00 sec)

mysql> select * from information_schema.innodb_sys_tablestats where table_id = 509 \G
*************************** 1. row ***************************
         TABLE_ID: 509
             NAME: test/t1
STATS_INITIALIZED: Initialized
         NUM_ROWS: 1
 CLUST_INDEX_SIZE: 1
 OTHER_INDEX_SIZE: 1
 MODIFIED_COUNTER: 1
          AUTOINC: 0
        REF_COUNT: 2
1 row in set (0.00 sec)

STATS_INITIALIZED字段表示是否收集了表的统计信息。NUM_ROWS是表中当前估计的行数。cluster_index_size和OTHER_INDEX_SIZE字段分别报告磁盘上为表存储集群索引和辅助索引的页数。MODIFIED_COUNTER值显示了由DML操作和来自外键的级联操作修改的行数。AUTOINC值是任何基于自动递增操作的下一个数字。在表t1中没有定义autoincrement列,因此值为0。REF_COUNT值是一个计数器。当计数器变为0时,表示表元数据可以从表缓存中移除。

外键信息_schema系统表
INNODB_SYS_FOREIGN和INNODB_SYS_FOREIGN_COLS表提供了有关外键关系的数据。这个例子使用具有外键关系的父表和子表来展示在INNODB_SYS_FOREIGN和INNODB_SYS_FOREIGN_COLS表中找到的数据。

1.创建包含父表和子表的测试数据库:

mysql> create table parent (id int not null,
    -> primary key (id)) engine=innodb;
Query OK, 0 rows affected (0.03 sec)

mysql> create table child (id int, parent_id int,
    -> index par_ind (parent_id),
    -> constraint fk1
    -> foreign key (parent_id) references parent(id)
    -> on delete cascade) engine=innodb;
Query OK, 0 rows affected (0.01 sec)

2.在创建父表和子表之后,查询INNODB_SYS_FOREIGN并找到test/child和test/parent外键关系的外键数据:

mysql> select * from information_schema.innodb_sys_foreign \G
*************************** 1. row ***************************
      ID: test/fk1
FOR_NAME: test/child
REF_NAME: test/parent
  N_COLS: 1
    TYPE: 1

元数据包括外键ID (fk1),它是根据在子表上定义的约束命名的。FOR_NAME是定义外键的子表的名称。REF_NAME是父表(被引用的表)的名称。N_COLS是外键索引中的列数。TYPE是一个数值,表示提供有关外键列的附加信息的位标志。在本例中,TYPE值为1,表示为外键指定了ON DELETE CASCADE选项。有关类型值的更多信息,请参阅INNODB_SYS_FOREIGN表定义。

3.使用外键ID,查询INNODB_SYS_FOREIGN_COLS来查看这个外键对应的列的数据。

mysql> select * from information_schema.innodb_sys_foreign_cols where id = 'test/fk1' \G
*************************** 1. row ***************************
          ID: test/fk1
FOR_COL_NAME: parent_id
REF_COL_NAME: id
         POS: 0
1 row in set (0.00 sec)

FOR_COL_NAME是子表中外键列的名称,REF_COL_NAME是父表中被引用的列的名称。POS值是键字段在外键索引中的顺序位置,从0开始。

连接InnoDB INFORMATION_SCHEMA系统表
这个例子展示了连接三个InnoDB INFORMATION_SCHEMA系统表(INNODB_SYS_TABLES、INNODB_SYS_TABLESPACES和INNODB_SYS_TABLESTATS)来收集employees sample数据库中表的文件格式、行格式、页面大小和索引大小信息。

mysql> select a.name, a.file_format, a.row_format,
    -> @page_size :=
    -> if(a.row_format='compressed',
    -> b.zip_page_size, b.page_size)
    -> as page_size,
    -> round((@page_size * c.clust_index_size)
    -> /(1024*1024)) as pk_mb,
    -> round((@page_size * c.other_index_size)
    -> /(1024*1024)) as secidx_mb
    -> from information_schema.innodb_sys_tables a
    -> inner join information_schema.innodb_sys_tablespaces b on a.name = b.name
    -> inner join information_schema.innodb_sys_tablestats c on b.name = c.name
    -> where a.name like 'employees/%'
    -> order by a.name desc;
+------------------------+-------------+------------+-----------+-------+-----------+
| name                   | file_format | row_format | page_size | pk_mb | secidx_mb |
+------------------------+-------------+------------+-----------+-------+-----------+
| employees/titles       | Barracuda   | Dynamic    |     16384 |     0 |         0 |
| employees/t            | Barracuda   | Dynamic    |     16384 |     0 |         0 |
| employees/salaries     | Barracuda   | Dynamic    |     16384 |     0 |         0 |
| employees/employees    | Barracuda   | Dynamic    |     16384 |     0 |         0 |
| employees/dept_manager | Barracuda   | Dynamic    |     16384 |     0 |         0 |
| employees/dept_emp     | Barracuda   | Dynamic    |     16384 |     0 |         0 |
| employees/departments  | Barracuda   | Dynamic    |     16384 |     0 |         0 |
| employees/c            | Barracuda   | Dynamic    |     16384 |     0 |         0 |
+------------------------+-------------+------------+-----------+-------+-----------+
8 rows in set (0.05 sec)

IF()控制流函数用于处理压缩表。如果表被压缩,则使用ZIP_PAGE_SIZE而不是PAGE_SIZE计算索引大小。cluster_index_size和OTHER_INDEX_SIZE以字节为单位,它们除以1024*1024,就得到了以兆字节(MBs)为单位的索引长度。使用ROUND()函数将MB值四舍五入为0个小数空格。

]]>
http://www.jydba.net/index.php/archives/3521/feed 0
MySQL使用InnoDB事务和锁信息识别阻塞事务 http://www.jydba.net/index.php/archives/3514 http://www.jydba.net/index.php/archives/3514#respond Sat, 21 Oct 2023 00:22:55 +0000 http://www.jydba.net/?p=3514 使用InnoDB事务和锁信息识别阻塞事务
有时识别哪些事务阻塞了另一个事务是有帮助的。包含InnoDB事务和数据锁信息的表使您能够确定哪个事务正在等待另一个事务,以及正在请求哪些资源。

假设有三个会话同时运行。每个会话对应于一个MySQL线程,并依次执行一个事务。考虑当这些会话发出以下语句,但还没有提交事务时,系统的状态:

.会话a

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

mysql> select a from abc for update;
select sleep(100);+---+
| a |
+---+
| 1 |
+---+
1 row in set (0.01 sec)

mysql> select sleep(100);
+------------+
| sleep(100) |
+------------+
|          0 |
+------------+
1 row in set (1 min 40.00 sec)

.会话b

mysql> select a from abc for update;

.会话c

mysql> select a from abc for update;

在这种情况下,使用以下查询来查看哪些事务正在等待,哪些事务正在阻塞它们:

mysql> SELECT
    -> r.trx_id waiting_trx_id,
    -> r.trx_mysql_thread_id waiting_thread,
    -> r.trx_query waiting_query,
    -> b.trx_id blocking_trx_id,
    -> b.trx_mysql_thread_id blocking_thread,
    -> b.trx_query blocking_query
    -> FROM information_schema.innodb_lock_waits w
    -> INNER JOIN information_schema.innodb_trx b
    -> ON b.trx_id = w.blocking_trx_id
    -> INNER JOIN information_schema.innodb_trx r
    -> ON r.trx_id = w.requesting_trx_id;
+----------------+----------------+------------------------------+-----------------+-----------------+------------------------------+
| waiting_trx_id | waiting_thread | waiting_query                | blocking_trx_id | blocking_thread | blocking_query               |
+----------------+----------------+------------------------------+-----------------+-----------------+------------------------------+
| 5686612        |            174 | select a from abc for update | 5686611         |             173 | select a from abc for update |
| 5686612        |            174 | select a from abc for update | 5686610         |             172 | select sleep(100)            |
| 5686611        |            173 | select a from abc for update | 5686610         |             172 | select sleep(100)            |
+----------------+----------------+------------------------------+-----------------+-----------------+------------------------------+
3 rows in set, 1 warning (0.01 sec)

或者,更简单地,使用sys schema的innodb_lock_waits视图:

mysql> SELECT
    -> waiting_trx_id,
    -> waiting_pid,
    -> waiting_query,
    -> blocking_trx_id,
    -> blocking_pid,
    -> blocking_query
    -> FROM sys.innodb_lock_waits;
+----------------+-------------+------------------------------+-----------------+--------------+------------------------------+
| waiting_trx_id | waiting_pid | waiting_query                | blocking_trx_id | blocking_pid | blocking_query               |
+----------------+-------------+------------------------------+-----------------+--------------+------------------------------+
| 5686611        |         173 | select a from abc for update | 5686610         |          172 | select sleep(100)            |
| 5686612        |         174 | select a from abc for update | 5686611         |          173 | select a from abc for update |
| 5686612        |         174 | select a from abc for update | 5686610         |          172 | select sleep(100)            |
+----------------+-------------+------------------------------+-----------------+--------------+------------------------------+
3 rows in set, 3 warnings (0.08 sec)

在上面的查询结果中,你可以通过“等待查询”或“阻塞查询”列来识别会话。如你所见:
.会话b(trx_id 568661,线程号173)和会话c(trx id 5686612,线程号174)都在等待会话a(trx id 5686610,线程号172

.会话c正等待会话b和会话a

你可以在表INNODB_TRX、INNODB_LOCKS和INNODB_LOCK_WAITS中看到底层的数据。

下表是INFORMATION_SCHEMA.INNODB_TRX的一些示例内容。

mysql> select trx_id,trx_state,trx_started,trx_requested_lock_id,trx_wait_started,trx_weight,trx_mysql_thread_id,trx_query from information_schema.innodb_trx;
+-----------------+-----------+---------------------+-----------------------+---------------------+------------+---------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------+
| trx_id          | trx_state | trx_started         | trx_requested_lock_id | trx_wait_started    | trx_weight | trx_mysql_thread_id | trx_query                                                                                                                                              |
+-----------------+-----------+---------------------+-----------------------+---------------------+------------+---------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------+
| 5686614         | RUNNING   | 2023-12-11 16:39:57 | NULL                  | NULL                |          2 |                 172 | select sleep(100)                                                                                                                                      |
| 5686612         | LOCK WAIT | 2023-12-11 16:07:07 | 5686612:423:3:2       | 2023-12-11 16:40:07 |          2 |                 174 | select a from abc for update                                                                                                                           |
| 5686611         | LOCK WAIT | 2023-12-11 16:07:04 | 5686611:423:3:2       | 2023-12-11 16:40:04 |          2 |                 173 | select a from abc for update                                                                                                                           |
| 421200136110592 | RUNNING   | 2023-12-11 16:07:52 | NULL                  | NULL                |          0 |                 176 | select trx_id,trx_state,trx_started,trx_requested_lock_id,trx_wait_started,trx_weight,trx_mysql_thread_id,trx_query from information_schema.innodb_trx |
+-----------------+-----------+---------------------+-----------------------+---------------------+------------+---------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------+
4 rows in set (0.00 sec)

mysql> select lock_id,lock_trx_id,lock_mode,lock_type,lock_table,lock_index,lock_data from information_schema.innodb_locks;
+-----------------+-------------+-----------+-----------+--------------+------------+-----------+
| lock_id         | lock_trx_id | lock_mode | lock_type | lock_table   | lock_index | lock_data |
+-----------------+-------------+-----------+-----------+--------------+------------+-----------+
| 5686612:423:3:2 | 5686612     | X         | RECORD    | `test`.`abc` | PRIMARY    | 1         |
| 5686611:423:3:2 | 5686611     | X         | RECORD    | `test`.`abc` | PRIMARY    | 1         |
| 5686614:423:3:2 | 5686614     | X         | RECORD    | `test`.`abc` | PRIMARY    | 1         |
+-----------------+-------------+-----------+-----------+--------------+------------+-----------+
3 rows in set, 1 warning (0.00 sec)

mysql> select requesting_trx_id,requested_lock_id,blocking_trx_id,blocking_lock_id from information_schema.innodb_lock_waits;
+-------------------+-------------------+-----------------+------------------+
| requesting_trx_id | requested_lock_id | blocking_trx_id | blocking_lock_id |
+-------------------+-------------------+-----------------+------------------+
| 5686612           | 5686612:423:3:2   | 5686611         | 5686611:423:3:2  |
| 5686612           | 5686612:423:3:2   | 5686614         | 5686614:423:3:2  |
| 5686611           | 5686611:423:3:2   | 5686614         | 5686614:423:3:2  |
+-------------------+-------------------+-----------------+------------------+
3 rows in set, 1 warning (0.00 sec)

InnoDB锁和锁等待信息

当一个事务更新表中的一行,或者用SELECT FOR UPDATE锁住它时,InnoDB会为该行建立一个锁的列表或队列。类似地,InnoDB在表上维护了一个表级锁的列表。如果第二个事务想要更新一行数据或者在不兼容的模式下锁定一个已经被前一个事务锁定的表,InnoDB会向相应的队列添加一个锁请求。为了让事务获得锁,必须删除先前进入锁队列的所有不兼容的锁请求(当持有或请求这些锁的事务提交或回滚这些锁时)。

一个事务可以对不同的行或表有任意数量的锁请求。在任何给定的时间,一个事务可以请求一个由另一个事务持有的锁,在这种情况下,它被另一个事务阻塞。请求事务必须等待持有阻塞锁的事务提交或回滚。如果事务没有等待锁,则它处于运行状态。如果事务正在等待锁,则它处于锁等待状态。(INFORMATION_SCHEMA INNODB_TRX表表示事务状态值。)

INNODB_LOCKS表为每个锁等待事务保存了一个或多个行,表示任何阻止其进行的锁请求。该表还包含一行,描述给定行或表的待决锁队列中的每个锁。INNODB_LOCK_WAITS表显示了一个事务持有的哪些锁是其他事务请求的阻塞锁。

InnoDB事务与锁信息的持久化与一致性
由事务和锁表(INNODB_TRX、INNODB_LOCKS和INNODB_LOCK_WAITS)暴露的数据代表了快速变化的数据。这与用户表不同,用户表中的数据只有在应用程序发起更新时才会发生变化。底层数据是内部系统管理的数据,可以非常快速地更改。

出于性能方面的原因,以及为了尽量减少事务和锁定表之间的误导性连接,每当发出对任何表的SELECT请求时,InnoDB都会将所需的事务和锁定信息收集到中间缓冲区中。仅当从上一次读取缓冲区以来已经超过0.1秒时,才会刷新该缓冲区。填充这三张表所需的数据以原子性和一致性的方式获取,并保存在这个全局内部缓冲区中,形成一个即时点的“快照”。如果在0.1秒内发生多次表访问(当MySQL处理这些表之间的联结时,几乎肯定会发生这种情况),则使用相同的快照来满足查询。

当您将这些表中的任何一张联结到一个查询中时,都会返回正确的结果,因为这三张表的数据来自同一个快照。因为对这些表的每次查询都不会刷新缓冲区,如果您在十分之一秒内对这些表发出单独的查询,那么每次查询的结果都是相同的。另一方面,如果两次对相同或不同表的单独查询间隔超过十分之一秒,可能会得到不同的结果,因为数据来自不同的快照。

因为在收集事务和锁定数据时,InnoDB必须暂时停止,对这些表过于频繁的查询可能会对其他用户的性能产生负面影响。

因为这些表包含敏感信息(至少INNODB_LOCKS.LOCK_DATA和INNODB_TRX.TRX_QUERY),出于安全考虑,只有具有进程权限的用户才能从中选择。

如前所述,填充事务和锁表(INNODB_TRX, INNODB_LOCKS和INNODB_LOCK_WAITS)的数据会被自动获取并保存到一个提供“时间点”快照的中间缓冲区中。当从同一个快照中查询时,所有三个表的数据是一致的。然而,底层数据变化如此之快,以至于其他类似的快速变化的数据可能并不同步。因此,在比较InnoDB事务和锁定表中的数据与PROCESSLIST表中的数据时,你应该小心。PROCESSLIST表中的数据与锁定和事务的数据并不来自同一个快照。即使你只执行了一个SELECT操作(例如,关联INNODB_TRX和PROCESSLIST),这些表的内容通常也不一致。INNODB_TRX可以引用PROCESSLIST中不存在的行,或者INNODB_TRX中显示的当前正在执行的事务的SQL查询。TRX_QUERY可能与PROCESSLIST.INFO中的不同。

]]>
http://www.jydba.net/index.php/archives/3514/feed 0
MySQL InnoDB与联机DDL http://www.jydba.net/index.php/archives/3510 http://www.jydba.net/index.php/archives/3510#respond Tue, 19 Sep 2023 00:32:54 +0000 http://www.jydba.net/?p=3510 InnoDB与联机DDL
InnoDB联机DDL特性允许就地表更改或并发DML,或两者兼而有之。这个特性的好处包括:
.改进了繁忙的生产环境中的响应性和可用性,在这些环境中,使表在几分钟或几小时内不可用是不现实的。

.使用LOCK子句在DDL操作期间调整性能和并发性之间的平衡的能力。
.LOCK=EXCLUSIVE完全阻塞对表的访问

.LOCK=SHARED允许查询,但不允许DML。

.LOCK=NONE允许对表进行完整的查询和DML访问。

.LOCK=DEFAULT或省略LOCK子句允许尽可能多的并发,具体取决于DDL操作的类型。

.避免了与复制表和重建二级索引相关的磁盘空间使用和I/O开销。

联机DDL概述
联机DDL特性增强了许多DDL操作,这些操作以前需要表复制或阻塞表上的DML操作,或者两者兼而有之。除了大多数ALTER TABLE分区子句之外,分区后的InnoDB表的在线DDL操作遵循与普通InnoDB表相同的规则。一些因素会影响在线DDL操作的性能、空间使用和语义。
.”In-Place?”列显示哪些操作允许使用ALGORITHM=INPLACE子句。

.”Rebuilds Table?”列显示重建表的操作。对于使用INPLACE算法的操作,将就地重建表。对于不支持INPLACE算法的操作,使用表复制方法重建表。

.”Permits Concurrent DML?”列显示哪些操作是完全在线执行的。您可以指定LOCK=NONE来断言在DDL操作期间允许并发DML。MySQL在可能的情况下自动允许并发DML。

在所有在线DDL操作期间都允许并发查询。可以指定LOCK=SHARED来断言在DDL操作期间允许并发查询。MySQL在可能的情况下自动允许并发查询。

.“Notes”列提供额外的信息,并解释与其他列的“Yes/No”值相关的异常和依赖关系。星号表示异常或依赖。

下面的小节提供了各种在线DDL操作的基本语法和用法说明。
添加或删除二级索引
.添加二级索引:

CREATE INDEX name ON table (col_list);

ALTER TABLE table ADD INDEX name (col_list);

.删除二级索引:

DROP INDEX name ON table;

ALTER TABLE table DROP INDEX name;

尽管在CREATE INDEX或DROP INDEX命令中不需要更改语法,但有一些因素会影响此操作的性能、空间使用和语义。

在InnoDB表上创建和删除二级索引会跳过表复制行为。

在创建或删除索引时,表仍然可用于读写操作。CREATE INDEX或DROP INDEX语句仅在所有访问表的事务完成后才完成,因此索引的初始状态反映了表的最新内容。以前,在创建或删除索引时修改表通常会导致死锁,从而取消表上的INSERT、UPDATE或DELETE语句。

在线DDL支持添加二级索引,这意味着通常可以加快创建和加载表及其关联索引的整体过程,方法是创建不带任何二级索引的表,然后在加载数据后添加二级索引。

修改列属性
.修改列的默认值:

ALTER TABLE tbl ALTER COLUMN col SET DEFAULT literal;
ALTER TABLE tbl ALTER COLUMN col DROP DEFAULT;

列的默认值存储在表的.frm文件中,而不是InnoDB数据字典中。

.更改列的自动增量值:
ALTER TABLE table AUTO_INCREMENT=next_value;

特别是在使用复制或分片的分布式系统中,有时需要将表的自动递增计数器重置为特定值。插入到表中的下一行使用指定的值作为其自动递增列。您也可以在数据仓库环境中使用此技术,您可以定期清空所有表并重新加载它们,并且可以从1重新启动自动递增序列。

.重命名列
ALTER TABLE tbl CHANGE old_col_name new_col_name datatype;

当您保持相同的数据类型和[NOT] NULL属性时,仅更改列名,此操作始终可以在线执行。

还可以重命名属于外键约束的列。外键定义会自动更新,以使用新的列名。重命名参与外键的列仅适用于ALTER TABLE的in-place模式。如果使用了ALGORITHM=COPY子句,或者其他条件导致命令在后台使用了ALGORITHM=COPY,那么ALTER TABLE语句就会失败。

.使用in-place ALTER TABLE语句扩展VARCHAR的大小:
ALTER TABLE t13 ALGORITHM=INPLACE, CHANGE COLUMN c1 c1 VARCHAR(50);

VARCHAR列所需的长度字节数必须保持不变。对于0到255的VARCHAR值,需要一个长度字节来编码该值。对于256字节或更多的VARCHAR值,需要两个长度字节。因此,in-place ALTER TABLE只支持将VARCHAR大小从0增加到255字节,或将VARCHAR大小从等于或大于256字节的值增加。In-place ALTER TABLE不支持将VARCHAR大小从小于256字节增加到等于或大于256字节。在这种情况下,所需长度字节的数量将从1变为2,只有表复制(ALGORITHM= copy)才支持这种情况。例如,试图使用in-place ALTER TABLE将VARCHAR列的大小从255更改为256将会返回错误:

mysql> ALTER TABLE t13 ALGORITHM=INPLACE, CHANGE COLUMN c1 c1 VARCHAR(256);
ERROR 1846 (0A000): ALGORITHM=INPLACE is not supported. Reason: Cannot change column type INPLACE. Try ALGORITHM=COPY.

mysql> ALTER TABLE t13 ALGORITHM=COPY, CHANGE COLUMN c1 c1 VARCHAR(256);
Query OK, 0 rows affected (0.02 sec)
Records: 0  Duplicates: 0  Warnings: 0

不支持使用in-place ALTER TABLE减少VARCHAR大小。减少VARCHAR的大小需要表的复制(ALGORITHM=COPY)。

mysql> ALTER TABLE t13 ALGORITHM=INPLACE, CHANGE COLUMN c1 c1 VARCHAR(20);
ERROR 1846 (0A000): ALGORITHM=INPLACE is not supported. Reason: Cannot change column type INPLACE. Try ALGORITHM=COPY.

mysql> ALTER TABLE t13 ALGORITHM=COPY, CHANGE COLUMN c1 c1 VARCHAR(20);
Query OK, 0 rows affected (0.02 sec)
Records: 0  Duplicates: 0  Warnings: 0

添加或删除外键
.添加或删除外键约束:

ALTER TABLE tbl1 ADD CONSTRAINT fk_name FOREIGN KEY index (col1) REFERENCES tbl2(col2) referential_actions;

ALTER TABLE tbl DROP FOREIGN KEY fk_name;

删除外键可以在启用或禁用foreign_key_checks选项的情况下在线执行。在线创建外键需要禁用foreign_key_checks。

如果你不知道某张表上的外键约束的名称,执行下面的语句,并在每个外键的约束子句中找到约束名称:

SHOW CREATE TABLE table\G

或者,查询INFORMATION_SCHEMA.TABLE_CONSTRAINTS表,使用CONSTRAINT_NAME和CONSTRAINT_TYPE列来标识外键的名称。

你也可以在一条语句中删除外键及其关联索引:

ALTER TABLE table DROP FOREIGN KEY constraint, DROP INDEX index;

如果外键已经存在于被修改的表中(也就是说,它是一个包含FOREIGN KEY …REFERENCE子句的子表),其他的限制适用于在线DDL操作,即使是那些不直接涉及外键列的操作:

.如果对父表的更改通过使用CASCADE或SET NULL参数的on UPDATE或on DELETE子句引起子表的相关更改,则子表上的ALTER TABLE可以等待另一个事务提交。

.同样,如果一张表是外键关系中的父表,即使它不包含任何外键子句,如果INSERT、UPDATE或DELETE语句导致子表中的ON UPDATE或ON DELETE操作,它也可以等待ALTER TABLE完成。

维护CREATE TABLE语句
当你的数据库模式随着新列、数据类型、约束、索引等的变化而变化时,请确保CREATE TABLE语句与最新的表定义保持一致。即使有了在线DDL的性能改进,在开始时创建稳定的数据库结构比创建模式的一部分然后发出ALTER TABLE语句更有效。

对有大量行记录表的二级索引这条准则除外。通常最有效的做法是:先指定除二级索引之外的所有详细信息,然后加载数据,再创建二级索引。如果您知道初始数据是干净的,并且在加载过程中不需要一致性检查,则可以对外键使用相同的技术(首先加载数据,然后设置外键)。

无论CREATE TABLE、CREATE INDEX、ALTER TABLE和类似的语句是如何将一个表组合在一起的,您都可以通过执行语句SHOW CREATE TABLE TABLE \G(为了整洁的格式化,需要大写\G)来捕获重建表所需的SQL。上述输出显示了numeric precision、NOT NULL和CHARACTER SET等子句,这些子句有时是在后台添加的,用户可能希望在新系统上克隆表或设置相同类型的外键列时省去这些子句。

联机DDL性能、并发性和空间需求
联机DDL提高了MySQL操作的几个方面,如性能、并发性、可用性和可伸缩性:
.由于表上的查询和DML操作可以在DDL进行时继续进行,因此访问表的应用程序响应更快。在整个MySQL服务器中减少锁和等待其他资源会带来更大的可伸缩性,即使对于不涉及修改表的操作也是如此。

.对于in-place操作,通过避免重新构建表所需的磁盘I/O和CPU周期,可以最小化数据库的总体负载,并在DDL操作期间保持良好的性能和高吞吐量。

.对于in-place操作,由于读入缓冲池的数据比复制所有数据要少,因此可以避免从内存中清除频繁访问的数据,这在以前可能会在DDL操作之后导致暂时的性能下降。

如果联机操作需要临时排序文件,InnoDB默认在临时文件目录下创建它们,而不是在包含原始表的目录下。如果这个目录不够大,无法容纳这样的文件,您可能需要将tmpdir系统变量设置为另一个目录。另外,您可以使用innodb_tmpdir配置选项为InnoDB在线ALTER TABLE操作定义一个单独的临时目录。

联机DDL的锁选项
当DDL操作改变InnoDB表时,表可能被锁住,也可能不被锁住,这取决于DDL操作的内部工作原理和ALTER table语句的LOCK子句。默认情况下,MySQL在DDL操作期间使用尽可能少的锁;您可以指定这个子句,使锁定比通常情况下更加严格(从而限制并发DML或DML和查询),或者确保某个操作允许某种预期程度的锁定。如果LOCK子句指定的锁级别不适用于特定类型的DDL操作,例如在创建或删除主键时指定LOCK=SHARED或LOCK=NONE,那么该子句就会像断言一样工作,导致语句失败并报错。下面列出了LOCK子句的不同可能性,从最宽松的到最严格的:

.对于LOCK=NONE的DDL操作,查询和并发DML都是允许的。如果不能使用所请求的锁类型执行DDL操作,则该子句会使ALTER TABLE失败,因此,如果保持表完全可用是至关重要的,则指定LOCK=NONE,如果不可能则可以取消DDL。例如,您可以在DDLs中对涉及客户注册或购买的表使用此子句,以避免错误地发出昂贵的ALTER TABLE语句,从而使这些表不可用。

.对于LOCK=SHARED的DDL操作,任何对表的写操作(即DML操作)都会被阻塞,但是可以读取表中的数据。如果请求的锁类型不能执行这种DDL操作,则该子句会使ALTER TABLE失败,因此,如果保持表对查询可用非常重要,则指定LOCK=SHARED,如果不可能,则可以取消DDL。例如,您可以在DDL中为数据仓库中的表使用这个子句,在DDL中可以延迟数据加载操作直到DDL完成,但是不能长时间延迟查询。

.对于使用LOCK=DEFAULT或省略LOCK子句的DDL操作,MySQL针对此类操作使用可用的最低级别的锁,允许并发查询、DML或两者同时使用。当您根据表的工作负载进行预先计划、预先测试的更改,并且知道不会导致任何可用性问题时,将使用此设置。

.对于LOCK=EXCLUSIVE的DDL操作,查询和DML操作都被阻塞。如果请求的锁类型不能执行这种DDL操作,这个子句会使ALTER TABLE失败,因此,如果主要关注的是在尽可能短的时间内完成DDL,则指定LOCK=EXCLUSIVE,并且可以使应用程序在尝试访问表时等待。如果服务器应该是空闲的,您也可以使用LOCK=EXCLUSIVE,以避免对表的意外访问。

在大多数情况下,表上的联机DDL操作等待正在访问表的当前执行的事务提交或回滚,因为在准备DDL语句时,它需要在短时间内独占访问表。同样,联机DDL操作在完成之前需要对表进行短时间的独占访问。因此,联机DDL语句也会等待DDL正在提交或回滚时启动的事务完成。因此,对于执行插入、更新、删除的长时间运行的事务或对表执行SELECT .. FOR UPDATE操作,联机DDL操作可能会超时等待对表的独占访问。

当表处于外键关系中,并且事务在外键关系中的另一个表上显式运行时,可能发生表上的在线DDL操作不等待当前执行的事务完成的情况。在这种情况下,事务在它正在更新的表上持有一个排他的元数据锁,但只持有另一张表上共享的InnoDB表锁(外键检查所需)。共享的InnoDB表锁允许在线DDL操作继续进行,当需要一个互斥的InnoDB表锁时会在提交阶段阻塞操作。当其他事务等待在线DDL操作提交时,此场景可能导致死锁。(参见Bug #48652和Bug #77390)

因为需要一些处理工作来记录并发DML操作所做的更改,然后在最后应用这些更改,所以在线DDL操作可能比阻止其他会话访问表的旧式机制花费更长的时间。原始性能的降低与使用表的应用程序更好的响应性是平衡的。在评估更改表结构的理想技术时,要根据诸如网页加载时间等因素,考虑最终用户对性能的感知。

当CREATE INDEX或ALTER TABLE语句执行完毕时,一个新创建的InnoDB二级索引只包含表中已提交的数据。它不包含任何未提交的值、值的旧版本或标记为删除但尚未从旧索引中删除的值。

In-PlaceDDL操作与Table-Copy DDL操作的性能
在线DDL操作的原始性能在很大程度上取决于该操作是in-place执行,还是需要复制和重建整个表。

in-place DDL带来的性能提升适用于二级索引上的操作,而不是主键索引。InnoDB表中的行存储在一个基于主键组织的聚集索引中,形成了一些数据库系统所称的“索引组织表”。因为表结构与主键紧密联系在一起,所以重新定义主键仍然需要复制数据。

当对主键的操作使用ALGORITHM=INPLACE时,即使数据仍然被复制,它也比使用ALGORITHM=COPY更有效,因为:
.ALGORITHM=INPLACE不需要undo日志记录或相关的重做日志记录。这些操作增加了使用ALGORITHM=COPY的DDL语句的开销。

.二级索引项是预先排序的,因此可以按顺序加载。

.没有使用更改缓冲区,因为没有随机访问插入到二级索引中。

为了判断在线DDL操作的相对性能,你可以使用当前版本和更早版本的MySQL在一个大的InnoDB表上运行这样的操作。还可以在最新的MySQL版本下运行所有性能测试,通过设置old_alter_table系统变量,模拟“before”结果的DDL行为。在会话中发出语句set old_alter_table=1,并测量DDL性能以记录“之前”的数字。然后设置old_alter_table=0以重新启用更新、更快的行为,并再次运行DDL操作以记录“之后”的数字。

要了解DDL操作是in-place进行更改还是执行表复制的基本概念,请查看命令完成后显示的“受影响的行”值。例如,在执行不同类型的DDL操作后,您可能会看到以下行:
.更改列的默认值(超快,完全不影响表数据):

Query OK, 0 rows affected (0.07 sec)

.添加索引(需要时间,但是0行受影响表明表没有被复制):

Query OK, 0 rows affected (21.42 sec)

.更改列的数据类型(需要花费大量时间,并且需要重建表中的所有行):

Query OK, 1671168 rows affected (1 min 35.54 sec)

更改列的数据类型需要重建表中的所有行,VARCHAR大小的更改除外,这可以使用在线ALTER table执行。

例如,在一个大表上运行DDL操作之前,你可能会检查操作的快慢,如下所示:
1.克隆表结构。

2.用少量数据填充克隆表。

3.在克隆表上运行DDL操作。

4.检查“受影响的行”值是否为零。非零值意味着操作需要重建整个表,这可能需要特殊的规划。例如,您可以在计划的停机期间执行DDL操作,或者每次在每个复制从服务器上执行一个。

为了更深入地了解MySQL处理过程中的归约,可以查看DDL操作前后与InnoDB相关的performance_schema和INFORMATION_SCHEMA表,查看物理读、写、内存分配等的数量。

联机DDL操作的空间要求
联机DDL操作对空间的要求如下:
.存放临时日志文件的空间
对于每个创建的索引或修改的表,都有一个这样的日志文件。此日志文件存储在DDL操作期间在表中插入、更新或删除的数据。临时日志文件在需要时通过innodb_sort_buffer_size的值进行扩展,直到达到innodb_online_alter_log_max_size指定的最大值。如果临时日志文件的大小超过上限,那么ALTER TABLE操作将失败,所有未提交的并发DML操作将回滚。因此,如果该选项的值较大,就允许在联机DDL操作期间发生更多的DML,
但也会延长DDL操作结束时表被锁定以应用日志中的数据的时间。

如果操作花费的时间太长,并发的DML修改表的时间太长,导致临时在线日志的大小超过innodb_online_alter_log_max_size配置选项的值,则在线DDL操作失败,并出现DB_ONLINE_LOG_TOO_BIG错误。

.临时排序文件的空间
重建表的在线DDL操作在创建索引时将临时排序文件写入MySQL临时目录(Unix上为$TMPDIR, Windows上为%TEMP%,或由–tmpdir配置变量指定的目录)。每个临时排序文件都足够大,可以容纳新二级索引定义的所有列,以及聚集索引的主键的列,一旦合并到最终表或索引中,这些列就会被删除。此类操作需要的临时空间相当于存储表中数据和索引数据所需要的空间大小。如果重建表的联机DDL操作使用了数据目录(datadir)所在的文件系统上的所有可用磁盘空间,则会导致错误。

从MySQL 5.7.11开始,你可以使用innodb_tmpdir配置选项为联机DDL操作定义一个单独的临时目录。innodb_tmpdir选项的引入是为了避免在联机ALTER TABLE操作重建表时创建大型临时排序文件时可能发生的临时目录溢出。

.中间表文件的空间
一些重建表的联机DDL操作在与原始表相同的目录中创建临时中间表文件,而不是在原地重建表。中间表文件可能需要与原始表大小相等的空间。

联机DDL SQL语法
通常,当对InnoDB表使用ALTER TABLE语句时,不需要做任何特殊的事情来启用联机DDL。一些变体需要使用配置或与ALTER TABLE子句的特定组合。

通过使用ALTER TABLE语句的LOCK和ALGORITHM子句,可以控制特定联机DDL操作的各个方面。这些子句位于语句的末尾,用逗号与表和列的规范分隔。LOCK子句用于微调对表的并发访问程度。ALGORITHM子句主要用于性能比较并作为在现有DDL代码遇到任何问题时对旧表复制行为的回退。例如:
.为了避免意外地使表不可读、不可写或不可读和不可写,可以在ALTER table语句中指定一个子句,例如LOCK=NONE(允许读写)或LOCK=SHARED(允许读)。如果请求的并发级别不可用,操作将立即停止。

.为了比较性能,除了设置old_alter_table配置选项外,还可以运行一个ALGORITHM=INPLACE语句和另一个算法ALGORITHM=COPY的语句。

.为了避免复制表的ALTER TABLE操作占用服务器资源,可以使用ALGORITHM=INPLACE子名。如果不能使用in-place机制,该语句将立即停止。

使用联机DDL简化DDL语句
在引入联机DDL之前,将许多DDL操作组合到单个ALTER TABLE语句中是一种常见的做法。因为每个ALTER TABLE语句都涉及复制和重建表,所以一次对同一个表进行多次更改会更加高效,因为这些更改可以通过对表的一次重建操作完成。缺点是涉及DDL操作的SQL代码很难在不同的脚本中维护和重用。如果每次的具体更改都不同,则可能需要为每个稍有不同的场景构建一个新的复杂的ALTER TABLE。

对于可以in-place完成的DDL操作,现在,您可以将它们分离为单独的ALTER TABLE语句,以便于编写脚本和维护,而不会牺牲效率。例如,你可以用这样一个复杂的语句:

ALTER TABLE t1 ADD INDEX i1(c1), ADD UNIQUE INDEX i2(c2),
CHANGE c4_old_name c4_new_name INTEGER UNSIGNED;

将其分解为可以独立测试和执行的更简单的部分,例如:

ALTER TABLE t1 ADD INDEX i1(c1);
ALTER TABLE t1 ADD UNIQUE INDEX i2(c2);
ALTER TABLE t1 CHANGE c4_old_name c4_new_name INTEGER UNSIGNED NOT NULL;

你可能仍然要使用由多个部分组成的ALTER TABLE语句:
.必须按特定顺序执行的操作,例如创建索引,然后使用该索引的外键约束。

.所有操作都使用相同的特定LOCK子句,希望作为一个组成功或失败。

.不能in-place执行的操作,即仍然复制和重建表的操作。

.指定ALGORITHM=COPY或old_alter_table=1的操作,如果需要在特定场景中实现精确的向后兼容性,可以强制表复制行为。

联机DDL实现详细信息
InnoDB表的每个ALTER TABLE操作都受以下几个方面的控制:
.是否对表的物理表示有任何更改,或者是否纯粹是对元数据的更改,而无需触及表本身。

.表中的数据量是保持不变、增加还是减少

.表数据的更改是否涉及聚集索引、二级索引或两者。

.被修改的表与其他表之间是否存在外键关系。机制差异取决于foreign_key_checks配置选项是启用还是禁用。

.表是否被分区。ALTER TABLE的分区子句被转换为涉及一个或多个表的低级操作,这些操作遵循联机DDL的常规规则。

.是否必须复制表数据,表是否可以“in-place”重组,或者两者的组合。

.需要多大程度的锁定,取决于底层数据库操作的性质,或者取决于在ALTER TABLE语句中指定的LOCK子句。

联机DDL错误条件
以下是联机DDL操作可能失败的主要原因:
.如果LOCK子句指定了低级别锁(SHARED或NONE)将与特定类型的DDL操作不兼容。

.如果在等待获得表上的排他锁时发生超时,在DDL操作的初始和最后阶段可能需要短暂的超时。

.MySQL在创建索引时将临时排序文件写入磁盘,如果tmpdir或innodb_tmpdir文件系统耗尽了磁盘空间。

.如果ALTER TABLE花费了很长时间,并且并发的DML对表的修改太多,那么临时在线日志的大小超过了innodb_online_alter_log_max_size配置选项的值。这种情况会导致DB_ONLINE_LOG_TOO_BIG错误。

.如果并发DML对原表定义允许的表进行更改,但新表定义不允许。只有在最后,当MySQL试图应用并发DML语句中的所有更改时,操作才会失败。例如,用户可以在创建唯一索引时向列中插入重复的值,或者在创建主键索引时向列中插入NULL值。并发DML所做的更改优先,并且有效地回滚了ALTER TABLE操作。

尽管配置选项innodb_file_per_table对InnoDB表的表示有显著的影响,但是不管这个选项是启用还是禁用,不管表物理位置是在它自己的.ibd文件中还是在系统表空间中,所有的在线DDL操作都是一样的。

InnoDB有两种类型的索引:代表表中所有数据的聚集索引,以及可选的加速查询的二级索引。因为聚集索引包含其b树节点中的数据值,所以添加或删除聚集索引需要复制数据,并创建表的新副本。而二级索引只包含索引键和主键的值。可以在不复制聚集索引中的数据的情况下创建或删除这种类型的索引。因为每个二级索引都包含主键值的副本(用于在需要时访问聚集索引),所以当更改主键的定义时,也会重新创建所有二级索引。

删除二级索引很简单。只有内部的InnoDB系统表和MySQL数据字典表被更新,以反映索引不再存在的事实。InnoDB将用于索引的存储空间返回到包含它的表空间,以便新的索引或额外的表行可以使用该空间。

为了给已存在的表添加二级索引,InnoDB会扫描表,并使用内存缓冲区和临时文件,根据二级索引键列的值对行进行排序。B树是按键值顺序构建的,这比按随机顺序将行插入索引更高效。因为b树节点在填充时是分裂的,以这种方式构建索引会导致索引的填充因子更高,从而使后续访问更高效。

联机DDL和崩溃恢复
虽然在执行ALTER TABLE语句时服务器崩溃不会丢失数据,但是集群索引和二级索引的崩溃恢复过程是不同的。

如果服务器在创建InnoDB二索引时崩溃,在恢复时,MySQL删除所有部分创建的索引。您必须重新运行ALTER TABLE或CREATE INDEX语句。

当在创建InnoDB集群索引时发生崩溃时,恢复会更加复杂,因为表中的数据必须复制到一个全新的集群索引中。请记住,所有InnoDB表都存储为集群索引。

MySQL通过将原始InnoDB表中的现有数据复制到具有所需索引结构的临时表中来创建新的集群索引。一旦数据被完全复制到这个临时表中,原始表将被重命名为一个不同的临时表名。包含新聚集索引的临时表将使用原始表的名称重命名,原始表将从数据库中删除。

如果在创建新的聚集索引时发生系统崩溃,则不会丢失数据,但是必须使用该过程中存在的临时表来完成恢复过程。由于在此操作期间很少重新创建聚集索引或重新定义大型表上的主键,也很少遇到系统崩溃的情况,因此本手册不提供有关从此场景中恢复的信息。

分区表的联机DDL
大多数ALTER TABLE分区子句不会像常规的非分区InnoDB表那样使用相同的内部联机DDL API。因此,对ALTER TABLE分区子句的联机支持各不相同。

下表显示了每个ALTER TABLE分区语句的联机状态。不管使用的是哪种联机DDL API, MySQL都会尽可能地减少数据复制和锁定。
.”In-Place”列显示哪些操作允许使用ALGORITHM=INPLACE子句。

.”Permits Concurrent DML?”列显示哪些操作是完全联机执行的。您可以指定LOCK=NONE来断言在DDL操作期间允许并发DML。MySQL在可能的情况下自动允许并发DML。

对于支持ALGORITHM={COPY|INPLACE}的操作,可以指定LOCK=SHARED来断言DDL操作期间允许并发查询。MySQL在可能的情况下自动允许并发查询。

.“Notes”列提供了其他信息,并解释了与其他列的“Yes/No”值相关的异常和依赖关系。星号表示异常或依赖项。

使用ALGORITHM=COPY或只允许”ALGORITHM=DEFAULT, LOCK=DEFAULT”的ALTER TABLE分区选项,将使用COPY算法对表进行重新分区。换句话说,使用新的分区方案创建了一个新的分区表。新创建的表包含ALTER table语句应用的任何更改,表数据被复制到新的表结构中。

对分区表执行非分区联机ALTER TABLE操作遵循适用于常规表的相同规则。但是,ALTER TABLE在每个表分区上执行在线操作,由于在多个分区上执行操作,这会导致对系统资源的需求增加。

联机DDL限制
联机DDL操作存在以下限制:
.在TEMPORARY表上创建索引时复制表,而不是使用快速索引创建。这已经被报告为MySQL Bug #39833。

.当用户试图删除外键所需的索引时,InnoDB会处理错误。

.如果表上有ON…CASCADE或ON…SET NULLT约束,ALTER TABLE子句LOCK=NONE是不允许的。

.根据联机DDL操作的内部工作原理和ALTER TABLE语句的LOCK子句,联机DDL操作在DDL操作的初始阶段和最终阶段可能需要在短时间内对表进行排他访问。因此,如果有一个执行插入、更新、删除或对表执行SELECT … FOR UPDATE的长时间运行的事务并且如果在ALTER TABLE进行中启动了类似的长时间运行的事务,则联机DDL操作可能需要等待才能完成。

.当运行一个联机DDL操作时,运行ALTER TABLE语句的线程应用一个来自其他连接线程在同一个表上并发运行的DML操作的“在线日志”。当应用DML操作时,可能会遇到重复键条目错误(错误1062(23000):重复条目),即使重复条目只是临时的,并且会被“在线日志”中的稍后条目恢复。这类似于InnoDB中的外键约束检查,其中约束必须在事务期间保持。

.将InnoDB表的OPTIMIZE TABLE映射到ALTER TABLE以重建表并更新索引统计信息和释放聚集索引中的未使用空间。创建辅助索引的效率不高,因为键是按照它们在主键中出现的顺序插入的。通过添加在线DDL支持,可以重建常规的和分区的InnoDB表。

.在MySQL 5.6之前创建的InnoDB表,对于包括时间列(日期,日期时间或时间戳)的表不支持ALTER TABLE…ALGORITHM=INPLACE且不能使用ALTER TABLE…ALGORITHM=COPY进行重建。在这种情况下,ALTER TABLE…ALGORITHM=INPLACE操作返回如下错误:

ERROR 1846 (0A000): ALGORITHM=INPLACE is not supported.
Reason: Cannot change column type INPLACE. Try ALGORITHM=COPY.

.这些限制通常适用于涉及表复制的大型表上的在线DDL操作:
.不存在暂停在线DDL操作或限制在线DDL操作的I/O或CPU使用的机制DDL操作。

.如果操作失败,回滚在线DDL操作的代价可能很高。

.长时间运行在线DDL操作可能导致复制滞后。在线DDL操作必须在主节点上运行完之后才能在从节点上运行。此外,在主服务器上并发处理的DML只有在从服务器上的DDL操作完成后才会在从服务器上处理(Bug #73196)。

]]>
http://www.jydba.net/index.php/archives/3510/feed 0
MySQL InnoDB行存储和行格式 http://www.jydba.net/index.php/archives/3508 http://www.jydba.net/index.php/archives/3508#respond Thu, 14 Sep 2023 03:42:41 +0000 http://www.jydba.net/?p=3508 InnoDB行存储和行格式
本节讨论InnoDB的特性,如表压缩、可变长度列值的页外存储和大索引键前缀(innodb_large_prefix)是如何由InnoDB表的行格式控制的。它还讨论了选择正确行格式的注意事项,以及MySQL版本之间行格式的兼容性。

InnoDB行存储概述
行和关联列的存储影响查询和DML操作的性能。由于单个磁盘页面中容纳了更多的行,查询和索引查找可以更快地工作,InnoDB缓冲池中所需的缓存内存更少,为数字和短字符串列写更新值所需的I/O也更少。

每个InnoDB表中的数据被划分为多个页。组成每个表的页面排列在称为b-树索引的树状数据结构中。表数据和二级索引都使用这种类型的结构。表示整个表的b树索引称为聚集索引,它是根据主键列组织的。索引数据结构的节点包含该行中所有列的值(对于聚集索引)或索引列和主键列的值(对于辅助索引)。

变长列是此规则的例外。像BLOB和VARCHAR这样的列太长而不能放在b树页上,它们存储在单独分配的磁盘页上,称为溢出页。我们称这样的列为页外列。这些列的值存储在溢出页的单链表中,每个这样的列都有自己的一个或多个溢出页列表。在某些情况下,长列值的全部或前缀存储在b树中,以避免浪费存储空间并消除读取单独页面的需要。

下面的章节描述了如何配置InnoDB表的行格式来控制如何存储可变长度列的值。行格式配置还决定了表压缩特性和大索引键前缀特性(innodb_large_prefix)的可用性。

指定表的行格式
默认的行格式由innodb_default_row_format定义,默认值为DYNAMIC。当没有显式定义ROW_FORMAT表选项或指定ROW_FORMAT= default时,使用默认行格式。

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

表的行格式可以在CREATE table或ALTER table语句中使用ROW_FORMAT表选项显式定义。例如:

mysql> CREATE TABLE t9 (c1 INT) ROW_FORMAT=DYNAMIC;
Query OK, 0 rows affected (0.03 sec)

显式定义的ROW_FORMAT设置覆盖隐式默认值。指定ROW_FORMAT=DEFAULT相当于使用隐式默认值。

innodb_default_row_format选项可以动态设置:

mysql> SET GLOBAL innodb_default_row_format=DYNAMIC;

有效的innodb_default_row_format选项包括DYNAMIC、COMPACT和REDUNDANT。COMPRESSED行格式不支持在系统表空间中使用,不能被定义为默认行格式。它只能在CREATE TABLE或ALTER TABLE语句中显式指定。尝试将innodb_default_row_format设置为COMPRESSED会返回一个错误:

mysql> SET GLOBAL innodb_default_row_format=COMPRESSED;
ERROR 1231 (42000): Variable 'innodb_default_row_format' can't be set to the value of 'COMPRESSED'

当没有明确指定ROW_FORMAT选项或使用ROW_FORMAT=DEFAULT时,新创建的表使用innodb_default_row_format定义的行格式。例如,下面的CREATE TABLE语句使用innodb_default_row_format定义的行格式。

mysql> CREATE TABLE t10 (c1 INT);
Query OK, 0 rows affected (0.02 sec)

mysql> CREATE TABLE t11 (c1 INT) ROW_FORMAT=DEFAULT;
Query OK, 0 rows affected (0.01 sec)


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

mysql> SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES WHERE NAME='undo/t10'\G
*************************** 1. row ***************************
     TABLE_ID: 498
         NAME: undo/t10
         FLAG: 33
       N_COLS: 4
        SPACE: 500
  FILE_FORMAT: Barracuda
   ROW_FORMAT: Dynamic
ZIP_PAGE_SIZE: 0
   SPACE_TYPE: Single
1 row in set (0.00 sec)

mysql> SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES WHERE NAME='undo/t11'\G
*************************** 1. row ***************************
     TABLE_ID: 499
         NAME: undo/t11
         FLAG: 33
       N_COLS: 4
        SPACE: 501
  FILE_FORMAT: Barracuda
   ROW_FORMAT: Dynamic
ZIP_PAGE_SIZE: 0
   SPACE_TYPE: Single
1 row in set (0.00 sec)

当没有显式指定ROW_FORMAT选项或使用ROW_FORMAT=DEFAULT时,任何重建表的操作都会将表的行格式静默地更改为innodb_default_row_format定义的格式。

表重建操作包括使用ALGORITHM=COPY的ALTER TABLE操作和使用ALGORITHM= INPLACE的ALTER TABLE操作。OPTIMIZE TABLE也是一个表重建操作。

下面的示例演示了一个表重建操作,该操作静默地更改在没有显式定义行格式的情况下创建的表的行格式。

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

mysql> CREATE TABLE t12 (c1 INT);
Query OK, 0 rows affected (0.01 sec)

mysql> SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES WHERE NAME LIKE 'undo/t12' \G
*************************** 1. row ***************************
     TABLE_ID: 500
         NAME: undo/t12
         FLAG: 33
       N_COLS: 4
        SPACE: 502
  FILE_FORMAT: Barracuda
   ROW_FORMAT: Dynamic
ZIP_PAGE_SIZE: 0
   SPACE_TYPE: Single
1 row in set (0.01 sec)

mysql> SET GLOBAL innodb_default_row_format=COMPACT;
Query OK, 0 rows affected (0.00 sec)

mysql> ALTER TABLE t12 ADD COLUMN (c2 INT);
Query OK, 0 rows affected (0.02 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql> SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES WHERE NAME LIKE 'undo/t12' \G
*************************** 1. row ***************************
     TABLE_ID: 501
         NAME: undo/t12
         FLAG: 1
       N_COLS: 5
        SPACE: 503
  FILE_FORMAT: Antelope
   ROW_FORMAT: Compact
ZIP_PAGE_SIZE: 0
   SPACE_TYPE: Single
1 row in set (0.00 sec)

在将现有表的行格式从REDUNDANT或COMPACT更改为DYNAMIC之前,请考虑以下潜在问题。
.如果启用了innodb_large_prefix配置选项,则REDUNDANT和COMPACT行格式支持的最大索引键前缀长度为767字节,而DYNAMIC和COMPRESSED行格式支持的索引键前缀长度为3072字节。在复制环境中,如果innodb_default_row_format在主服务器上被设置为DYNAMIC,在从服务器上被设置为COMPACT,那么下面的DDL语句(没有明确定义行格式)在主服务器上成功,在从服务器上失败:

CREATE TABLE t1 (c1 INT PRIMARY KEY, c2 VARCHAR(5000), KEY i1(c2(3070)));

.导入一个没有显式定义行格式的表,如果源服务器上的innodb_default_row_format设置与目标服务器上的设置不同,则会导致模式不匹配错误。

要查看表的行格式,可以发出SHOW TABLE STATUS语句或查询INFORMATION_SCHEMA.TABLES。

mysql> SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES WHERE NAME LIKE 'undo/t12' \G
*************************** 1. row ***************************
     TABLE_ID: 501
         NAME: undo/t12
         FLAG: 1
       N_COLS: 5
        SPACE: 503
  FILE_FORMAT: Antelope
   ROW_FORMAT: Compact
ZIP_PAGE_SIZE: 0
   SPACE_TYPE: Single
1 row in set (0.00 sec)

mysql> SHOW TABLE STATUS\G
*************************** 1. row ***************************
           Name: big_table
         Engine: InnoDB
        Version: 10
     Row_format: Dynamic
           Rows: 3370592
 Avg_row_length: 205
    Data_length: 694140928
Max_data_length: 0
   Index_length: 0
      Data_free: 3145728
 Auto_increment: 3326977
    Create_time: 2023-07-06 18:05:18
    Update_time: NULL
     Check_time: NULL
      Collation: utf8mb4_general_ci
       Checksum: NULL
 Create_options:
        Comment:

InnoDB表的行格式决定了它的物理行结构。

DYNAMIC和COMPRESSED行格式
当创建一个ROW_FORMAT=DYNAMIC或ROW_FORMAT=COMPRESSED的表时,InnoDB可以存储长可变长度的列值(对于VARCHAR, VARBINARY, BLOB和TEXT类型)完全溢出页,集群索引记录只包含一个指向溢出页的20字节指针。InnoDB也将长度大于或等于768字节的固定长度字段编码为可变长度字段。例如,如果字符集的最大字节长度大于3,那么CHAR(255)列可以超过768字节,就像utf8mb4一样。

是否有列存储在页外取决于页大小和行的总大小。当行太长时,InnoDB选择最长的列作为页外存储,直到聚集索引记录适合B-tree页。小于或等于40字节的TEXT和BLOB列始终内联存储。

如果适合的话,DYNAMIC行格式保持了在索引节点中存储整行的效率(就像COMPACT和REDUNDANT格式一样),但是DYNAMIC行格式避免了用长列的大量数据字节填充b树节点的问题。DYNAMIC格式基于这样的思想:如果长数据值的一部分存储在页外,那么将所有值存储在页外通常是最有效的。使用DYNAMIC格式,较短的列可能会保留在B-tree节点中,从而最大限度地减少任何给定行所需的溢出页数。

对于页外存储,COMPRESSED行格式使用了与DYNAMIC行格式类似的内部细节,同时对表和索引数据进行了额外的存储和性能考虑,并使用了更小的页面大小。对于COMPRESSED行格式,KEY_BLOCK_SIZE选项控制在聚集索引中存储多少列数据,以及在溢出页上放置多少列数据。

DYNAMIC和COMPRESSED行格式都支持最多3072字节的索引键前缀。该特性由innodb_large_prefix配置选项控制,默认情况下是启用的。

mysql> select @@innodb_large_prefix;
+-----------------------+
| @@innodb_large_prefix |
+-----------------------+
|                     1 |
+-----------------------+
1 row in set (0.00 sec)

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

使用COMPRESSED行格式的表可以在file-per-table表空间或一般表空间中创建。system表空间不支持COMPRESSED行格式。为了在file-per-table表空间中存储压缩表,innodb_file_per_table必须启用,innodb_file_format必须设置为Barracuda。innodb_file_per_table和innodb_file_format配置选项不适用于一般表空间。一般表空间支持所有的行格式,但需要注意的是,由于物理页大小不同,压缩表和未压缩表不能在同一通用表空间
中共存。

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

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

DYNAMIC表可以存储在file-per-table表空间、通用表空间和系统表空间中。要在系统表空间中存储DYNAMIC表,必须使用CREATE TABLE或ALTER TABLE语句并使用选项tablespace [=] innodb_system。innodb_file_per_table和innodb_file_format配置选项不适用于一般表空间,也不适用于使用TABLESPACE [=] innodb_system表选项在system表空间中存储DYNAMIC表。

可以通过禁用innodb_file_per_table并使用常规的CREATE TABLE或ALTER TABLE语句向系统表空间添加一个DYNAMIC表。innodb_file_format设置将被忽略。DYNAMIC表总是使用Barracuda文件格式。

DYNAMIC和COMPRESSED行格式是COMPACT行格式的变体,因此处理CHAR存储的方式与COMPACT行格式相同。

COMPACT and REDUNDANT行格式
早期版本的InnoDB使用一种未命名的文件格式(现在称为Antelope)来处理数据库文件。对于这种文件格式,表定义为ROW_FORMAT=COMPACT或ROW_FORMAT=REDUNDANT。使用这些行格式,InnoDB将可变长度列(VARCHAR, VARBINARY, BLOB和TEXT类型)的前768字节存储在b树节点的索引记录中,其余的存储在溢出页上。InnoDB还将长度大于或等于768字节的固定长度字段编码为可变长度字段,可以存储在页外。例如,如果字符集的最大字节长度大于3,那么CHAR(255)列可以超过768字节,就像utf8mb4一样。

对于Antelope文件格式,如果列的值为768字节或更少,则不需要溢出页,并且可能会节省一些I/O,因为该值位于b树节点中。这对于相对较短的blob很有效,但可能导致B树节点填充数据而不是键值,从而降低了它们的效率。具有许多BLOB列的表可能会导致B树节点的数据太满,而包含的行太少,从而使整个索引的效率低于行更短或列值存储在页外的情况。

]]>
http://www.jydba.net/index.php/archives/3508/feed 0
MySQL InnoDB页面压缩 http://www.jydba.net/index.php/archives/3501 http://www.jydba.net/index.php/archives/3501#respond Fri, 04 Aug 2023 08:51:22 +0000 http://www.jydba.net/?p=3501 InnoDB页面压缩
innoDB支持页面级别的表压缩,这些表位于file-per-table表空间中。这个特性被称为透明页面压缩。通过使用CREATE TABLE或ALTER TABLE指定compression属性,可以启用页面压缩。支持的压缩算法包括Zlib和LZ4。

支持平台
页面压缩需要稀疏文件和穿孔支持。在带有NTFS的Windows上,以及以下支持mysql的Linux平台子集上支持页面压缩,其中内核级别提供了hole punch支持:
. RHEL 7 and derived distributions that use kernel version 3.10.0-123 or higher
. OEL 5.10 (UEK2) kernel version 2.6.39 or higher
. OEL 6.5 (UEK3) kernel version 3.8.13 or higher
. OEL 7.0 kernel version 3.8.13 or higher
. SLE11 kernel version 3.0-x
. SLE12 kernel version 3.12-x
. OES11 kernel version 3.0-x
. Ubuntu 14.0.4 LTS kernel version 3.13 or higher
. Ubuntu 12.0.4 LTS kernel version 3.2 or higher
. Debian 7 kernel version 3.2 or higher

对于给定的Linux发行版,所有可用的文件系统可能都不支持打孔。

页面压缩工作原理
在写入一页时,使用指定的压缩算法对其进行压缩。压缩后的数据被写入磁盘,在磁盘上打孔机制从页的末尾释放空块。如果压缩失败,数据会原样写入。

Linux上的打孔尺寸
在Linux系统中,文件系统块长度是用于打孔的单位长度。因此,只有当页面数据可以压缩到小于或等于InnoDB页面大小减去文件系统块大小时,页面压缩才有效。例如,如果innodb_page_size=16K,文件系统块大小为4K,则页面数据必须压缩到小于或等于12K,才能穿孔。

Windows上的打孔尺寸
在Windows系统上,用于稀疏文件的底层基础设施是基于NTFS压缩。冲孔尺寸为NTFS压缩单元,是NTFS集群尺寸的16倍。集群大小及其压缩单位如下表所示:

Windows NTFS集群大小和压缩单元
集群大小 压缩单元
512 Bytes 8 KB
1 KB 16 KB
2 KB 32 KB
4 KB 64 KB

在Windows系统上,只有当页面数据可以压缩到小于或等于InnoDB页面大小减去压缩单位大小时,页面压缩才有效。

NTFS集群的默认大小是4K,其中压缩单位大小是64K。这意味着页面压缩对于开箱即用的Windows NTFS配置没有任何好处,因为innodb_page_size的最大值也是64K。

为了让页面压缩在Windows上工作,创建文件系统时必须使用小于4K的集群大小,并且innodb_page_size必须至少是压缩单元大小的两倍。例如,为了让页面压缩在Windows上工作,你可以构建一个512字节的集群文件系统(压缩单位是8KB),并将InnoDB初始化为16K或更高的值。

启用页面压缩
要启用页面压缩,请在CREATE TABLE语句中指定compression属性。例如:

mysql> CREATE TABLE t7 (c1 INT) COMPRESSION="zlib";
Query OK, 0 rows affected (0.03 sec)

您还可以在ALTER TABLE语句中启用页面压缩。但是,ALTER TABLE…COMPRESSION只更新表空间的COMPRESSION属性。在设置新的压缩算法之后,对表空间的写入将使用新的设置,但是要将新的压缩算法应用到现有页面,必须使用OPTIMIZE table重建表。
mysql>  CREATE TABLE t8 (c1 INT);
Query OK, 0 rows affected (0.01 sec)

mysql>  ALTER TABLE t8 COMPRESSION="zlib";
Query OK, 0 rows affected (0.01 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql> OPTIMIZE TABLE t8;
+---------+----------+----------+-------------------------------------------------------------------+
| Table   | Op       | Msg_type | Msg_text                                                          |
+---------+----------+----------+-------------------------------------------------------------------+
| undo.t8 | optimize | note     | Table does not support optimize, doing recreate + analyze instead |
| undo.t8 | optimize | status   | OK                                                                |
+---------+----------+----------+-------------------------------------------------------------------+
2 rows in set (0.02 sec)

对于Innodb存储引擎不能支持optimize table,Myisam存储引擎支持optimize table。

禁用页面压缩
要禁用页面压缩,请使用ALTER TABLE设置compression =None。在设置COMPRESSION=None后,写入表空间不再使用页面压缩。要解压缩现有页面,必须在设置COMPRESSION=None后使用OPTIMIZE TABLE重新构建表。

mysql> ALTER TABLE t8 COMPRESSION="None";
Query OK, 0 rows affected (0.00 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql> OPTIMIZE TABLE t8;
+---------+----------+----------+-------------------------------------------------------------------+
| Table   | Op       | Msg_type | Msg_text                                                          |
+---------+----------+----------+-------------------------------------------------------------------+
| undo.t8 | optimize | note     | Table does not support optimize, doing recreate + analyze instead |
| undo.t8 | optimize | status   | OK                                                                |
+---------+----------+----------+-------------------------------------------------------------------+
2 rows in set (0.02 sec)

mysql> show create table t8;
+-------+------------------------------------------------------------------------------------------------------------+
| Table | Create Table                                                                                               |
+-------+------------------------------------------------------------------------------------------------------------+
| t8    | CREATE TABLE `t8` (
  `c1` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMPRESSION='None' |
+-------+------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

页面压缩元数据
页面压缩元数据可以在INFORMATION_SCHEMA.INNODB_SYS_TABLESPACES表中找到。在下列列中:
.FS_BLOCK_SIZE:文件系统块大小,打孔时使用的单位大小。

.FILE_SIZE:文件的外观大小,表示未压缩时文件的最大大小。

.ALLOCATED_SIZE:文件的实际大小,即在磁盘上分配的空间量。

在类unix系统上,使用ls -l tablespace_name.ibd以字节为单位给出了明显的文件长度(相当于FILE_SIZE)。要查看磁盘上实际分配的空间大小(相当于ALLOCATED_SIZE),可以使用du –block-size=1 tablespace_name.ibd。–block-size=1选项以字节(而不是块)打印分配的空间,以便与ls -l的输出进行比较。

使用SHOW CREATE TABLE查看当前页面压缩设置(Zlib、Lz4或None)。一个表可能包含具有不同压缩设置的混合页面。

在下面的示例中,从INFORMATION_SCHEMA.INNODB_SYS_TABLESPACES表中检索employees表的页面压缩元数据。

# Create the employees table with Zlib page compression
mysql> CREATE TABLE employees (
    -> emp_no INT NOT NULL,
    -> birth_date DATE NOT NULL,
    -> first_name VARCHAR(14) NOT NULL,
    -> last_name VARCHAR(16) NOT NULL,
    -> gender ENUM ('M','F') NOT NULL,
    -> hire_date DATE NOT NULL,
    -> PRIMARY KEY (emp_no)
    -> ) COMPRESSION="zlib";
Query OK, 0 rows affected (0.01 sec)

# Insert data
mysql> insert into employees values(1,'1985-02-28','yong','jing','M','2023-08-04');
Query OK, 1 row affected (0.00 sec)

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


# Query page compression metadata in INFORMATION_SCHEMA.INNODB_SYS_TABLESPACES

mysql> SELECT SPACE, NAME, FS_BLOCK_SIZE, FILE_SIZE, ALLOCATED_SIZE FROM
    -> INFORMATION_SCHEMA.INNODB_SYS_TABLESPACES WHERE NAME='undo/employees'\G
*************************** 1. row ***************************
         SPACE: 498
          NAME: undo/employees
 FS_BLOCK_SIZE: 4096
     FILE_SIZE: 98304
ALLOCATED_SIZE: 61440
1 row in set (0.01 sec)

employees表的页面压缩元数据显示,表面文件大小为98304字节,而实际文件大小(使用页面压缩)为61440字节。文件系统块大小为4096字节,即穿孔时使用的块大小。

页面压缩限制和使用说明
.如果文件系统块大小(或Windows上的压缩单位大小)* 2>innodb_page_size禁用页面压缩。

.对于驻留在共享表空间中的表,包括system表空间、临时表空间和一般表空间,不支持页面压缩。

.undo日志表空间不支持页面压缩。

.重做日志页面不支持页面压缩。

.用于空间索引的R树页面不能被压缩。

.属于压缩表(ROW_FORMAT= compressed)的页面保持原样。

.在恢复过程中,更新后的页面将以未压缩的形式输出。

.在不支持所用压缩算法的服务器上加载页压缩表空间会导致I/O错误。

.在降级到不支持页面压缩的MySQL早期版本之前,请解压使用页面压缩特性的表。要解压一张表,运行ALTER table…compression=None和
optimize table。

.如果所使用的压缩算法在Linux和Windows服务器上可用,则可以在Linux和Windows服务器之间复制页压缩表空间。

.在将页面压缩的表空间文件从一台主机移动到另一台主机时保持页面压缩需要一个保留稀疏文件的实用程序。

.与其他平台相比,使用NVMFS的Fusion-io硬件可以实现更好的页面压缩,因为NVMFS旨在利用打孔功能。

.在InnoDB页面大小较大和文件系统块相对较小的情况下使用页面压缩特性可能会导致写入放大。例如,InnoDB页的最大大小为64KB,而文件系统块的大小为4KB,这可能会提高压缩性能,但也可能会增加对缓冲池的需求,从而导致I/O增加和潜在的写放大。

]]>
http://www.jydba.net/index.php/archives/3501/feed 0
MySQL InnoDB表压缩 http://www.jydba.net/index.php/archives/3499 http://www.jydba.net/index.php/archives/3499#respond Fri, 04 Aug 2023 08:46:21 +0000 http://www.jydba.net/?p=3499 InnoDB表压缩
InnoDB表压缩,它支持在file_per_table表空间或普通表空间中的InnoDB表。使用ROW_FORMAT=COMPRESSED属性与CREATE Table或ALTER Table一起启用表压缩。

表压缩概述
InnoDB表压缩,它支持在file_per_table表空间或普通表空间中的InnoDB表。使用ROW_FORMAT=COMPRESSED属性与CREATE Table或ALTER Table一起启用表压缩。

表压缩概述
由于处理器和缓存内存的速度比磁盘存储设备提高得更快,因此许多工作负载都是磁盘绑定的。数据压缩可以实现更小的数据库大小、更少的I/O和更高的吞吐量,而增加CPU利用率的代价很小。压缩对于读密集型应用程序尤其有价值,因为系统有足够的RAM将经常使用的数据保存在内存中。

使用ROW_FORMAT=COMPRESSED创建的InnoDB表可以在磁盘上使用比配置的innodb_page_size值更小的页面大小。更小的页面需要更少的I/O来读写磁盘,这对于SSD设备来说特别有价值。

压缩后的页面大小通过CREATE TABLE或ALTER TABLE KEY_BLOCK_SIZE参数指定。不同的页面大小要求将表放在file-per-table表空间或通用表空间中,而不是放在系统表空间中,因为系统表空间不能存储压缩表。

无论KEY_BLOCK_SIZE值如何,压缩级别都是相同的。当您为KEY_BLOCK_SIZE指定较小的值时,您将获得越来越小的页面所带来的I/O好处。但是,如果指定的值太小,则在数据值无法压缩到足以容纳每个页中的多行时,会有重新组织页的额外开销。表的KEY_BLOCK_SIZE可以有多小是有严格限制的,这取决于每个索引的键列的长度。如果指定的值太小,CREATE TABLE或ALTER TABLE语句将失败。

在缓冲池中,压缩数据保存在小页面中,页面大小基于KEY_BLOCK_SIZE值。为了提取或更新列值,MySQL还使用未压缩的数据在缓冲池中创建一个未压缩的页面。在缓冲池中,对未压缩页面的任何更新也会被重新写回等效的压缩页面。您可能需要调整缓冲池的大小,以容纳压缩和未压缩页面的附加数据,尽管在需要空间时将未压缩页面从缓冲池中取出,然后在下一次访问时再次解压缩。

创建压缩表
压缩表可以在file-per-table表空间中创建,也可以在一般表空间中创建。InnoDB系统表空间不支持表压缩。系统表空间(空间0,.ibdata文件)可以包含用户创建的表,但它也包含内部系统数据,这些数据从未被压缩过。因此,压缩只适用于存储在file-per-table或一般表空间中的表(和索引)。

在file-per-table表空间中创建压缩表
要在file-per-table表空间中创建压缩表,innodb_file_per_table必须启用(MySQL 5.6.6默认设置),innodb_file_format必须设置为Barracuda。您可以在MySQL配置文件(my.cnf或my.ini)中设置这些参数,也可以使用set语句动态设置这些参数

在配置了innodb_file_per_table和innodb_file_format选项后,在CREATE TABLE或ALTER TABLE语句中指定ROW_FORMAT=COMPRESSED或KEY_BLOCK_SIZE子句,或两者都指定,以在file-per-table表空间中创建压缩表。

例如,你可以使用以下语句:

mysql> SET GLOBAL innodb_file_per_table=1;
Query OK, 0 rows affected (0.00 sec)

mysql> SET GLOBAL innodb_file_format=Barracuda;
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> CREATE TABLE t1
    -> (c1 INT PRIMARY KEY)
    -> ROW_FORMAT=COMPRESSED
    -> KEY_BLOCK_SIZE=8;
Query OK, 0 rows affected (0.01 sec)

在通用表空间中创建压缩表
要在通用表空间中创建压缩表,必须为通用表空间定义FILE_BLOCK_SIZE,该值在创建表空间时指定。FILE_BLOCK_SIZE值必须是相对于innodb_page_size值的有效压缩页大小,并且由CREATE table或ALTER table KEY_BLOCK_SIZE子句定义的压缩表的页大小必须等于FILE_BLOCK_SIZE/1024。例如,innodb_page_size=16384, FILE_BLOCK_SIZE=8192,则表的KEY_BLOCK_SIZE必须为8。

下面的示例演示创建一个通用表空间和添加一个压缩表。本例innodb_page_size的默认值为16K。FILE_BLOCK_SIZE为8192要求压缩表的KEY_BLOCK_SIZE为8。

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

mysql> CREATE TABLESPACE ts3 ADD DATAFILE 'ts3.ibd' FILE_BLOCK_SIZE = 8192 Engine=InnoDB;
Query OK, 0 rows affected (0.01 sec)

mysql> CREATE TABLE t2 (c1 INT PRIMARY KEY) TABLESPACE ts3 ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=8;
Query OK, 0 rows affected (0.01 sec)

注意:
.如果指定ROW_FORMAT=COMPRESSED,则可以省略KEY_BLOCK_SIZE;KEY_BLOCK_SIZE默认为innodb_page_size值的一半。

.如果你指定了一个有效的KEY_BLOCK_SIZE值,你可以忽略ROW_FORMAT=COMPRESSED;自动启用压缩功能。

.要确定KEY_BLOCK_SIZE的最佳值,通常需要为该子句创建具有不同值的同一表的多个副本,然后测量生成的.ibd文件的大小,并查看每个文件在实际工作负载下的性能如何。对于一般的表空间,请记住,删除表并不会减少一般表空间.ibd文件的大小,也不会将磁盘空间返回给操作系统。

.KEY_BLOCK_SIZE值被视为提示;如果需要,InnoDB可以使用不同的大小。对于file-per-table表空间,KEY_BLOCK_SIZE只能小于或等于innodb_page_size值。如果指定的值大于innodb_page_size,则忽略指定的值,并发出警告,并将KEY_BLOCK_SIZE设置为innodb_page_size值的一半。如果innodb_strict_mode=ON,指定无效的KEY_BLOCK_SIZE值将返回错误。对于一般的表空间,有效的KEY_BLOCK_SIZE值取决于表空间的FILE_BLOCK_SIZE设置。

.32k和64k页面大小不支持压缩。

.InnoDB数据页的默认未压缩大小是16KB。根据选项值的组合,MySQL使用1KB、2KB、4KB、8KB或16KB的页大小来存放表空间数据文件(.ibd文件)。实际的压缩算法不受KEY_BLOCK_SIZE值的影响;该值决定每个压缩块的大小,进而影响每个压缩页中可以装入多少行。

.当在file-per-table表空间中创建压缩表时,将KEY_BLOCK_SIZE设置为InnoDB页面大小通常不会导致太多压缩。例如,设置KEY_BLOCK_SIZE=16通常不会导致太多的压缩,因为正常的InnoDB页面大小是16KB。此设置对于具有许多长BLOB、VARCHAR或TEXT列的表可能仍然有用,因为这些值通常可以很好地压缩,因此可能需要更少的溢出页。对于一般的表空间,KEY_BLOCK_SIZE值等于InnoDB页面大小是不允许的。

.表的所有索引(包括聚集索引)使用相同的页面大小进行压缩,这在CREATE table或ALTER table语句中指定。表属性如ROW_FORMAT和KEY_BLOCK_SIZE不是InnoDB表的CREATE INDEX语法的一部分,如果指定了,它们将被忽略(尽管,如果指定了,它们将出现在SHOW CREATE Table语句的输出中)。

压缩表的限制
.5.1之前的MySQL版本不能处理压缩表。

.压缩表不能存储在InnoDB系统表空间中。

.一般表空间可以包含多个表,但是压缩表和未压缩表不能在同一个表空间中共存。

.压缩适用于整个表及其所有关联索引,而不是单独的行,尽管子句名为ROW_FORMAT。

InnoDB表压缩调优
大多数情况下,InnoDB数据存储和压缩中描述的内部优化可以确保系统在压缩数据下运行良好。但是,由于压缩的效率取决于数据的性质,因此您可以做出影响压缩表性能的决定:
.要压缩哪些表。

.要使用的压缩页面大小。

.是否根据运行时性能特征(例如系统压缩和解压缩数据所花费的时间)调整缓冲池的大小。工作负载更像数据仓库(主要是查询)还是OLTP系统(查询和DML的混合)。

.如果系统在压缩表上执行DML操作,并且数据分布的方式在运行时导致代价高昂的压缩失败,那么您可能需要调整其他高级配置选项。

何时使用压缩
一般来说,压缩在包含合理数量的字符串列的表上效果最好,并且数据的读取次数远远多于写入次数。因为没有保证的方法来预测压缩是否有利于特定情况,所以总是使用在代表性配置上运行的特定工作负载和数据集进行测试。在决定压缩哪些表时,请考虑以下因素。

数据特性与压缩
在压缩数据文件时,决定压缩效率的一个关键因素是数据本身的性质。回想一下,压缩的工作原理是识别数据块中重复的字节串。完全随机的数据是最糟糕的情况。典型的数据通常有重复的值,因此压缩效果很好。无论是定义在CHAR、VARCHAR、TEXT还是BLOB列中的字符串,通常压缩效果都很好。另一方面,主要包含二进制数据(整数或浮点数)或之前压缩过的数据(例如JPEG或PNG图像)的表通常不能很好地压缩,或者显著压缩,或者根本压缩不了。

你可以选择是否为每个InnoDB表开启压缩。一张表及其所有索引使用相同的(压缩的)页面大小。可能是包含表中所有列数据的主键(聚集)索引比辅助索引压缩更有效。对于那些行很长的情况,使用压缩可能会导致长列值被存储在“页外”,那些溢出的页面可以很好地压缩。考虑到这些因素,对于许多应用程序,有些表的压缩比其他表的压缩更有效,并且您可能会发现只有在压缩了一部分表的情况下,您的工作负载才能达到最佳性能。

要确定是否要压缩一个特定的表,可以进行实验。通过使用对未压缩表的.ibd文件副本实现LZ77压缩的实用程序(如gzip或WinZip),您可以粗略估计数据压缩的效率。与基于文件的压缩工具相比,MySQL压缩表的压缩更少,因为MySQL根据页面大小(默认为16KB)分块压缩数据。除了用户数据之外,页面格式还包括一些未压缩的内部系统数据。基于文件的压缩工具可以检查更大的数据块,因此可能会在一个巨大的文件中发现更多重复的字符串比MySQL在单个页面中所能找到的多。

在特定表上测试压缩的另一种方法是将一些数据从未压缩的表复制到一个类似的、压缩的表(具有相同的索引)中,并查看生成的.ibd文件的大小。
例如:

mysql> use undo
Database changed
mysql> SET GLOBAL innodb_file_per_table=1;
Query OK, 0 rows affected (0.00 sec)

mysql> SET GLOBAL innodb_file_format=Barracuda;
Query OK, 0 rows affected, 1 warning (0.00 sec)

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

mysql> CREATE TABLE big_table AS SELECT * FROM information_schema.columns;
Query OK, 3249 rows affected, 1 warning (0.52 sec)
Records: 3249  Duplicates: 0  Warnings: 1

mysql> INSERT INTO big_table SELECT * FROM big_table;
Query OK, 3249 rows affected (0.05 sec)
Records: 3249  Duplicates: 0  Warnings: 0

mysql> INSERT INTO big_table SELECT * FROM big_table;
Query OK, 6498 rows affected (0.10 sec)
Records: 6498  Duplicates: 0  Warnings: 0

mysql> INSERT INTO big_table SELECT * FROM big_table;
Query OK, 12996 rows affected (0.20 sec)
Records: 12996  Duplicates: 0  Warnings: 0

mysql> INSERT INTO big_table SELECT * FROM big_table;
Query OK, 25992 rows affected (0.51 sec)
Records: 25992  Duplicates: 0  Warnings: 0

mysql> INSERT INTO big_table SELECT * FROM big_table;
Query OK, 51984 rows affected (0.78 sec)
Records: 51984  Duplicates: 0  Warnings: 0

mysql> INSERT INTO big_table SELECT * FROM big_table;
Query OK, 103968 rows affected (1.40 sec)
Records: 103968  Duplicates: 0  Warnings: 0

mysql> INSERT INTO big_table SELECT * FROM big_table;
Query OK, 207936 rows affected (2.84 sec)
Records: 207936  Duplicates: 0  Warnings: 0

mysql> INSERT INTO big_table SELECT * FROM big_table;
Query OK, 415872 rows affected (5.72 sec)
Records: 415872  Duplicates: 0  Warnings: 0

mysql> INSERT INTO big_table SELECT * FROM big_table;
Query OK, 831744 rows affected (11.46 sec)
Records: 831744  Duplicates: 0  Warnings: 0

mysql> INSERT INTO big_table SELECT * FROM big_table;
Query OK, 1663488 rows affected (22.86 sec)
Records: 1663488  Duplicates: 0  Warnings: 0

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

mysql> ALTER TABLE big_table ADD id int unsigned NOT NULL PRIMARY KEY auto_increment;
Query OK, 0 rows affected (48.18 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql> SHOW CREATE TABLE big_table\G
*************************** 1. row ***************************
       Table: big_table
Create Table: CREATE TABLE `big_table` (
  `TABLE_CATALOG` varchar(512) CHARACTER SET utf8 NOT NULL DEFAULT '',
  `TABLE_SCHEMA` varchar(64) CHARACTER SET utf8 NOT NULL DEFAULT '',
  `TABLE_NAME` varchar(64) CHARACTER SET utf8 NOT NULL DEFAULT '',
  `COLUMN_NAME` varchar(64) CHARACTER SET utf8 NOT NULL DEFAULT '',
  `ORDINAL_POSITION` bigint(21) unsigned NOT NULL DEFAULT '0',
  `COLUMN_DEFAULT` longtext CHARACTER SET utf8,
  `IS_NULLABLE` varchar(3) CHARACTER SET utf8 NOT NULL DEFAULT '',
  `DATA_TYPE` varchar(64) CHARACTER SET utf8 NOT NULL DEFAULT '',
  `CHARACTER_MAXIMUM_LENGTH` bigint(21) unsigned DEFAULT NULL,
  `CHARACTER_OCTET_LENGTH` bigint(21) unsigned DEFAULT NULL,
  `NUMERIC_PRECISION` bigint(21) unsigned DEFAULT NULL,
  `NUMERIC_SCALE` bigint(21) unsigned DEFAULT NULL,
  `DATETIME_PRECISION` bigint(21) unsigned DEFAULT NULL,
  `CHARACTER_SET_NAME` varchar(32) CHARACTER SET utf8 DEFAULT NULL,
  `COLLATION_NAME` varchar(32) CHARACTER SET utf8 DEFAULT NULL,
  `COLUMN_TYPE` longtext CHARACTER SET utf8 NOT NULL,
  `COLUMN_KEY` varchar(3) CHARACTER SET utf8 NOT NULL DEFAULT '',
  `EXTRA` varchar(30) CHARACTER SET utf8 NOT NULL DEFAULT '',
  `PRIVILEGES` varchar(80) CHARACTER SET utf8 NOT NULL DEFAULT '',
  `COLUMN_COMMENT` varchar(1024) CHARACTER SET utf8 NOT NULL DEFAULT '',
  `GENERATION_EXPRESSION` longtext CHARACTER SET utf8 NOT NULL,
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3326977 DEFAULT CHARSET=utf8mb4
1 row in set (0.00 sec)

mysql> select count(id) from big_table;
+-----------+
| count(id) |
+-----------+
|   3326976 |
+-----------+
1 row in set (1.09 sec)


mysql> \! ls -l /mysqldata/mysql/undo/big_table.ibd
-rw-r-----. 1 mysql mysql 708837376 Jul  6 18:06 /mysqldata/mysql/undo/big_table.ibd


mysql> CREATE TABLE key_block_size_4 LIKE big_table;
Query OK, 0 rows affected (0.02 sec)

mysql> ALTER TABLE key_block_size_4 key_block_size=4 row_format=compressed;
Query OK, 0 rows affected (0.02 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql> INSERT INTO key_block_size_4 SELECT * FROM big_table;
Query OK, 3326976 rows affected (2 min 52.11 sec)
Records: 3326976  Duplicates: 0  Warnings: 0

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

mysql> \! ls -l /mysqldata/mysql/undo/key_block_size_4.ibd
-rw-r-----. 1 mysql mysql 155189248 Jul  6 18:11 /mysqldata/mysql/undo/key_block_size_4.ibd

这个实验产生了以下数字,当然,根据您的表结构和数据,这些数字可能会有很大的不同:
-rw-r-----. 1 mysql mysql 708837376 Jul  6 18:06 /mysqldata/mysql/undo/big_table.ibd
-rw-r-----. 1 mysql mysql 155189248 Jul  6 18:11 /mysqldata/mysql/undo/key_block_size_4.ibd

要查看压缩对您的特定工作负载是否有效:
.对于简单的测试,使用一个没有其他压缩表的MySQL实例,并对INFORMATION_SCHEMA.INNODB_CMP表进行查询。

.对于涉及多个压缩表的工作负载的更复杂的测试,可以对INFORMATION_SCHEMA.INNODB_CMP_PER_INDEX表进行查询。因为收集INNODB_CMP_PER_INDEX表中的统计信息非常昂贵,所以你必须在查询这张表之前启用配置选项innodb_cmp_per_index_enabled,并且你可以将这样的测试限制在开发服务器或非关键的从服务器上。

.对正在测试的压缩表运行一些典型的SQL语句。

.通过查询INFORMATION_SCHEMA.INNODB_CMP或INFORMATION_SCHEMA.INNODB_CMP_PER_INDEX表,并比较COMPRESS_OPS和COMPRESS_OPS_OK,可以查看成功压缩操作与总体压缩操作的比率。

.如果成功完成的压缩操作的百分比很高,则该表可能是压缩的一个很好的候选者。

.如果压缩失败的比例很高,您可以调整innodb_compression_level、innodb_compression_failure_threshold_pct和innodb_compression_pad_pct_max选项,并尝试进一步的测试。

数据库压缩与应用程序压缩
决定压缩应用程序中的数据还是表中的数据;不要对同一数据同时使用两种压缩方式。当压缩应用程序中的数据并将结果存储在压缩表中时,几乎不可能节省额外的空间,而双重压缩只会浪费CPU周期。

在数据库中压缩
当启用时,MySQL表压缩是自动的,并且适用于所有列和索引值。这些列仍然可以使用LIKE之类的操作符进行测试,即使索引值被压缩了,排序操作仍然可以使用索引。因为索引通常占数据库总大小的很大一部分,所以压缩可以显著节省存储、I/O或处理器时间。压缩和解压缩操作发生在数据库服务器上,这可能是一个强大的系统,其大小可以处理预期的负载。

应用程序压缩
如果在应用程序中压缩文本等数据,在将其插入数据库之前,通过压缩某些列而不压缩其他列,可以为压缩效果不好的数据节省开销。这种方法使用CPU周期在客户机机器上而不是数据库服务器上进行压缩和解压缩,这可能适用于具有许多客户机的分布式应用程序,或者客户机机器有空闲CPU周期的情况。

混合方法
当然,也可以结合使用这两种方法。对于某些应用程序,可能适合使用一些压缩表和一些非压缩表。最好从外部压缩一些数据(并将其存储在未压缩的表中),并允许MySQL压缩应用程序中的其他表。与往常一样,预先设计和真实的测试对于做出正确的决定是有价值的。

工作负载特征和压缩
除了选择要压缩的表(和页面大小)之外,工作负载是性能的另一个关键决定因素。如果应用程序主要是读操作,而不是更新操作,那么在索引页耗尽MySQL为压缩数据维护的每页“修改日志”的空间后,需要重新组织和重新压缩的页面就会更少。如果更新主要是更改非索引的列,或者那些包含blob或大字符串的列,它们恰巧存储在“页外”,那么压缩的开销是可以接受的。如果对表的唯一更改是使用单调递增主键的插入,并且辅助索引很少,那么就不需要重新组织和重新压缩索引页。由于MySQL可以通过修改未压缩的数据“就地”删除压缩页上的行,因此表上的删除操作是相对高效的。

对于某些环境,加载数据所需的时间可能与运行时检索同样重要。特别是在数据仓库环境中,许多表可能是只读的或大多数情况下是只读的。在这些情况下,以增加加载时间为代价进行压缩可能是可接受的,也可能是不可接受的,除非由此减少磁盘读取或存储成本的节省非常显著。

基本上,当CPU时间可以用于压缩和解压缩数据时,压缩工作得最好。因此,如果您的工作负载是I/O绑定的,而不是cpu绑定的,您可能会发现压缩可以提高整体性能。当您使用不同的压缩配置测试应用程序性能时,请在与生产系统的计划配置类似的平台上进行测试。

配置特点及压缩
从磁盘读写数据库页面是系统性能最慢的方面。压缩试图通过使用CPU时间来压缩和解压缩数据来减少I/O,当I/O相对于处理器周期来说是一种稀缺资源时,这种方法最有效。

当运行在具有快速多核cpu的多用户环境中时,情况尤其如此。当压缩表的一页在内存中时,MySQL通常会使用额外的内存,通常是16KB,在缓冲池中用于页面的未压缩副本。自适应LRU算法试图平衡压缩页和未压缩页之间的内存使用,以考虑工作负载是以I/ o绑定方式还是cpu绑定方式运行。尽管如此,在使用压缩表时,为缓冲池提供更多内存的配置往往比内存高度受限的配置运行得更好。

选择压缩页面大小
压缩页大小的最佳设置取决于表及其索引包含的数据的类型和分布。压缩后的页面大小应该总是大于最大记录大小,否则操作可能会失败,正如b树页面压缩中提到的那样。

将压缩页的大小设置得太大会浪费一些空间,但并不需要经常压缩页。如果压缩页大小设置得太小,插入或更新可能需要耗时的重新压缩,并且b树节点可能需要更频繁地分割,导致数据文件更大和索引效率更低。

通常,您可以将压缩页面大小设置为8K或4K字节。考虑到InnoDB表的最大行大小大约是8K, KEY_BLOCK_SIZE=8通常是一个安全的选择。

在运行时监控InnoDB表压缩
应用程序的整体性能、CPU和I/O利用率以及磁盘文件的大小都可以很好地反映压缩对应用程序的有效性。基于“InnoDB表的压缩调优”中的性能调优建议,并展示如何发现在初始测试中可能不会出现的问题。

为了更深入地了解压缩表的性能考虑因素,你可以使用INFORMATION_SCHEMA方案中的表来监控运行时的压缩性能。这些表反映了内存的内部使用情况和总体的压缩率。

INNODB_CMP表报告了每个压缩页大小(KEY_BLOCK_SIZE)的压缩活动信息。这些表中的信息是系统范围的:它总结了数据库中所有压缩表的压缩统计信息。当没有其他压缩表被访问时,通过检查这些表,可以使用这些数据来帮助决定是否要压缩表。它在服务器上的开销相对较低,所以你可以定期在生产服务器上查询它,以检查压缩特性的整体效率。

INNODB_CMP_PER_INDEX表报告了关于单个表和索引的压缩活动的信息。这些信息更有针对性,对于评估压缩效率和诊断一次一个表或索引的性能问题更有用。(因为每个InnoDB表都表示为一个聚集索引,MySQL在这个上下文中没有对表和索引做很大的区分。)INNODB_CMP_PER_INDEX表确实涉及大量的开销,因此它更适合于开发服务器,在那里你可以单独比较不同工作负载、数据和压缩设置的影响。为了防止意外造成这种监控开销,用户必须在查询INNODB_CMP_PER_INDEX表之前启用innodb_cmp_per_index_enabled配置选项。

要考虑的主要统计数据是执行压缩和解压缩操作的数量和时间。由于MySQL在修改后会在b树节点满到无法包含压缩后的数据时拆分b树节点,因此需要将“成功”的压缩操作的数量与此类操作的总体数量进行比较。根据INNODB_CMP和INNODB_CMP_PER_INDEX表中的信息以及应用程序的整体性能和硬件资源利用率,您可以更改硬件配置,调整缓冲池的大小,选择不同的页面大小,或者选择不同的表集进行压缩。

如果压缩和解压缩所需的CPU时间非常多,那么在相同的数据、应用程序工作负载和压缩表集的情况下,改用更快的CPU或多核CPU可以帮助提高性能。增加缓冲池的大小也可能有助于提高性能,这样更多未压缩的页可以驻留在内存中,减少了对仅以压缩形式存在于内存中的页进行压缩的需求。

总体上大量的压缩操作(与应用程序中的插入、更新和删除操作的数量以及数据库的大小相比)可能表明某些压缩表的更新过于频繁,无法进行有效的压缩。如果是这样,请选择更大的页面大小,或者对要压缩的表更有选择性。

如果“成功”的压缩操作数量(COMPRESS_OPS_OK)占压缩操作总数(COMPRESS_OPS)的比例很高,那么系统可能性能良好。如果这个比率很低,那么MySQL会频繁地重组、重新压缩和分裂b树节点。在这种情况下,请避免压缩某些表,或者增大某些已压缩表的KEY_BLOCK_SIZE。如果你关闭了表的压缩,导致应用程序中的“压缩失败”数量超过了总数的1%或2%,那么你可以关闭表的压缩。(在数据加载等临时操作期间,这样的失败率是可以接受的)。

如何压缩InnoDB表
本节描述一些关于InnoDB表压缩的内部实现细节。这里提供的信息可能对性能调优有帮助,但对于压缩的基本使用来说没有必要知道。

压缩算法
有些操作系统在文件系统级别实现压缩。文件通常被划分为固定大小的块,然后被压缩为可变大小的块,这很容易导致碎片。每次数据块中的某些内容被修改时,整个数据块都会被重新压缩,然后再写入磁盘。这些特性使得这种压缩技术不适合在更新密集型数据库系统中使用。

MySQL在著名的zlib库的帮助下实现了压缩,该库实现了LZ77压缩算法。该压缩算法成熟、稳定,在CPU利用率和数据压缩方面都是有效的。该算法是“无损”的,因此原始未压缩的数据总是可以从压缩的形式中重构出来。LZ77压缩的工作原理是找出在要压缩的数据中重复出现的数据序列。数据中值的模式决定了它的压缩效果,但典型的用户数据通常会压缩50%或更多。

InnoDB只支持zlib库到1.2.3版本。

与应用程序执行的压缩或其他一些数据库管理系统的压缩特性不同,InnoDB压缩同时适用于用户数据和索引。在许多情况下,索引占数据库总大小的40-50%或更多,因此这种差异是显著的。当数据集的压缩工作正常时,InnoDB数据文件的大小(file-per-table表空间或一般的表空间.idb文件)是未压缩大小的25%到50%,甚至可能更小。根据工作负载的不同,这个较小的数据库可以反过来减少I/O,增加吞吐量,但在增加CPU利用率方面代价不大。您可以通过修改innodb_compression_level配置选项来调整压缩级别和CPU开销之间的平衡。

InnoDB数据存储和压缩
InnoDB表中的所有用户数据都存储在由b树索引(聚集索引)组成的页中。在其他一些数据库系统中,这种类型的索引被称为“索引组织表”。索引节点中的每一行包含(用户指定的或系统生成的)主键和表中所有其他列的值。

InnoDB表中的辅助索引也是b树,包含成对的值:索引键和指向聚集索引中的某一行的指针。指针实际上是表的主键的值,如果需要索引键和主键以外的列,则用于访问聚集索引。辅助索引记录必须始终能够放置在单个b树页上。

b树节点(集群索引和辅助索引)的压缩与用于存储长VARCHAR、BLOB或TEXT列的溢出页的压缩处理不同,以下各节将对此进行解释。

压缩b树页面
由于b树页经常更新,因此需要特殊处理。重要的是尽量减少b树节点拆分的次数,以及尽量减少解压缩和重新压缩它们的内容的需要。

MySQL使用的一种技术是在b树节点中以未压缩的形式维护一些系统信息,从而方便某些就地更新。例如,这允许在不进行任何压缩操作的情况下删除标记的行。

此外,当索引页发生变化时,MySQL试图避免不必要的解压缩和重压缩。在每个B-tree页面中,系统保存一个未压缩的“修改日志”来记录对页面所做的更改。小记录的更新和插入可以写入该修改日志,而不需要完全重建整个页面。

当修改日志的空间耗尽时,InnoDB解压缩页面,应用更改并重新压缩页面。如果重新压缩失败(这种情况称为压缩失败),则分割b树节点,并重复该过程,直到更新或插入成功。

为了避免在写密集的应用(比如OLTP应用)中频繁发生压缩失败,MySQL有时会在页面中预留一些空白空间(填充),这样修改日志就会很快填满,并且在有足够空间避免拆分页面时重新压缩页面。随着系统跟踪页面拆分的频率,每个页面中剩余的填充空间的大小也会变化。在一个繁忙的服务器上对压缩表进行频繁的写操作,你可以调整innodb_compression_failure_threshold_pct和innodb_compression_pad_pct_max配置选项来微调这种机制。

一般来说,MySQL要求InnoDB表中的每个B-tree页至少能容纳两条记录。对于压缩表,这个要求已经放宽了。b树节点的叶子页(无论是主键还是辅助索引)只需要容纳一条记录,但该记录必须以未压缩的形式容纳到每个页面的修改日志中。如果innodb_strict_mode是ON, MySQL会在CREATE TABLE或CREATE INDEX时检查最大行大小。如果行不合适,则会发出以下错误消息:error HY000: Too big row。

如果你在innodb_strict_mode关闭时创建表,并且后续的INSERT或UPDATE语句试图创建一个不适合压缩页面大小的索引项,操作将失败,ERROR 42000:Row size too large。(此错误消息没有指出哪个索引的记录太大,也没有提到该索引记录的长度或该特定索引页上的最大记录大小。)要解决这个问题,用ALTER table重建表并选择一个更大的压缩页大小(KEY_BLOCK_SIZE),缩短任何列前缀索引,或完全禁用压缩ROW_FORMAT=DYNAMIC或ROW_FORMAT=COMPACT。

Innodb_strict_mode不适用于普通表空间,普通表空间也支持压缩表。一般表空间的表空间管理规则是严格执行的,独立于innodb_strict_mode。

压缩BLOB、VARCHAR和TEXT列
在InnoDB表中,不属于主键的BLOB、VARCHAR和TEXT列可能会存储在单独分配的溢出页上。我们把这些列称为页外列。其值存储在溢出页的单链表上。

对于以ROW_FORMAT=DYNAMIC或ROW_FORMAT=COMPRESSED创建的表,BLOB、TEXT或VARCHAR列的值可以完全存储在页外,这取决于它们的长度和整行的长度。对于存储在页外的列,聚集索引记录只包含指向溢出页的20字节指针,每个列一个。是否有列存储在页外取决于页大小和行总大小。当一行太长,不能完全装入聚集索引页时,MySQL选择最长的列进行页外存储,直到该行装入聚集索引页为止。如上所述,如果压缩页中某一行不适合它自己,就会发生错误。

对于以ROW_FORMAT=DYNAMIC或ROW_FORMAT=COMPRESSED创建的表,小于或等于40字节的TEXT和BLOB列总是行内存储。

在旧版本的MySQL中创建的表使用羚羊文件格式,它只支持ROW_FORMAT= redundancy和ROW_FORMAT=COMPACT。在这些格式中,MySQL将BLOB、VARCHAR和TEXT列的前768字节与主键一起存储在聚集索引记录中。768字节的前缀后面是一个20字节的指针,指向包含该列剩余值的溢出页。

在表采用压缩格式时,写入溢出页的所有数据都“按原样”压缩;也就是说,MySQL对整个数据项应用zlib压缩算法。除了数据之外,压缩溢出页面还包含一个未压缩的头部和尾部,其中包含一个页面校验和和指向下一个溢出页面的链接。因此,如果数据是高度可压缩的,那么较长的BLOB、TEXT或VARCHAR列可以显著节省存储空间,文本数据通常就是这种情况。图像数据,如JPEG,通常已经被压缩,因此不能从存储在压缩表中获得太多好处;双重压缩可能会浪费CPU周期,但节省的空间很少或根本没有。

溢出页的大小与其他页相同。一个包含10列且存储在页外的行会占用10个溢出页,即使所有列的总长度只有8K字节。在未压缩的表中,10个未压缩的溢出页占用160K字节。在一个页面大小为8K的压缩表中,它们只占用80K字节。因此,对于with的表,使用压缩表格式通常更有效长列值。

对于file-per_table表空间,使用16K的压缩页大小可以减少BLOB、VARCHAR或TEXT列的存储和I/O成本,因为这些数据通常压缩得很好,因此可能需要更少的溢出页,即使b树节点本身占用与未压缩形式相同的页。一般的表空间不支持16K的压缩页大小(KEY_BLOCK_SIZE)。

压缩和InnoDB缓冲池
在一个压缩的InnoDB表中,每个压缩页(无论是1K、2K、4K还是8K)对应一个16K字节的未压缩页(如果设置了innodb_page_size,则更小)。为了访问页面中的数据,MySQL会从磁盘中读取压缩过的页面(如果它不在缓冲池中),然后将页面解压缩为原始形式。本节描述了InnoDB如何管理压缩表的页的缓冲池。

为了尽量减少I/O和减少解压缩页面的需要,缓冲池有时同时包含数据库页面的压缩形式和未压缩形式。为了给其他需要的数据库页面腾出空间,MySQL可以从缓冲池中移除未压缩的页面,而将压缩的页面留在内存中。或者,如果页有一段时间没有被访问,则可能将该页的压缩格式写入磁盘,以便为其他数据释放空间。因此,在任何给定的时间,缓冲池可能同时包含页的压缩形式和未压缩形式,或者只包含页的压缩形式,或者两者都不包含。

MySQL使用最近最少使用(least-recently-used, LRU)列表来跟踪哪些页应该保存在内存中,哪些页应该清除,这样热的(频繁访问的)数据就倾向于保存在内存中。当访问压缩表时,MySQL使用自适应LRU算法来实现内存中压缩页和未压缩页的适当平衡。该算法对系统是I/O密集型运行还是cpu密集型运行非常敏感。目标是避免在CPU繁忙时花费过多的处理时间来解压缩页,并避免在CPU有空闲周期可用于解压缩已压缩页(可能已经在内存中)时进行过多的I/O操作。当系统处于I/O绑定时,该算法倾向于移除一个页面的未压缩副本,而不是两个副本,以便为其他磁盘页面腾出更多空间成为内存驻留。当系统使用CPU 绑定时,MySQL倾向于同时移除压缩和未压缩的页面,这样就可以将更多的内存用于“热”页面,从而减少
只对压缩格式的数据进行解压的需求。

压缩和重做日志文件
在将压缩页面写入数据文件之前,MySQL将页面的一个副本写入重做日志(如果它从上次写入数据库以来已经被重新压缩过)。这样做是为了确保重做日志对于崩溃恢复是可用的,即使在zlib库升级的情况下,该更改也会引入与压缩数据的兼容性问题。因此,在使用压缩时,日志文件的大小可能会增加,或者需要更频繁的检查点。日志文件大小或检查点频率的增加量,取决于以需要重新组织和重新压缩的方式修改压缩页的次数。

压缩表需要Barracuda文件格式。要在一个以文件为表的表空间中创建一个压缩表,必须启用innodb_file_per_table,并且必须将innodb_file_format设置为Barracuda。在普通表空间中创建压缩表时,不依赖于innodb_file_format设置。

OLTP工作负载压缩
传统上,InnoDB压缩特性主要被推荐用于只读或以读为主的工作负载,例如在数据仓库配置中。SSD存储设备速度很快,但相对较小和昂贵,这使得压缩对于OLTP工作负载也很有吸引力:高流量、交互式的网站可以通过对频繁插入、更新和删除操作的应用程序使用压缩表来减少它们的存储需求和每秒I/O操作(IOPS)。

MySQL 5.6引入的配置选项允许你针对特定的MySQL实例调整压缩的工作方式,重点是写密集型操作的性能和可伸缩性:
.Innodb_compression_level允许你提高或降低压缩程度。值越高,存储设备上的数据就越多,但压缩时的CPU开销也越大。当存储空间不是很重要,或者你希望数据不是特别可压缩时,较小的值可以减少CPU开销。

.innodb_compression_failure_threshold_pct压缩表更新失败的截止点。当超过这个阈值时,MySQL开始在每个新的压缩页面中留下额外的空闲空间,动态调整空闲空间的数量,直到innodb_compression_pad_pct_max指定的页面大小的百分比

.innodb_compression_pad_pct_max允许您调整每个页面中保留的最大空间大小,以记录对压缩行的更改,而不需要再次压缩整个页面。该值越高,在不重新压缩页面的情况下可以记录的更改越多。MySQL为每个压缩表中的页面使用的空闲空间是可变的,只有当压缩操作在运行时“失败”时,需要执行昂贵的操作来分割压缩页面。

.Innodb_compression_pad_pct_max允许您调整每个页面中保留的最大空间大小,以记录对压缩行的更改,而不需要再次压缩整个页面。该值越高,在不重新压缩页面的情况下可以记录的更改越多。MySQL为每个压缩表中的页面使用的空闲空间是可变的,只有当压缩操作在运行时“失败”时,需要执行昂贵的操作来分割压缩页面。

.innodb_log_compressed_pages允许你禁止将重新压缩的页面的图像写入重做日志。当对压缩数据进行更改时,可能会发生重新压缩。默认启用此选项是为了防止在恢复过程中使用不同版本的zlib压缩算法时发生损坏。如果你确定zlib版本不会改变,禁用innodb_log_compressed_pages来减少修改压缩数据的工作负载的重做日志生成。

因为在处理压缩数据时,有时需要在内存中同时保存一个页面的压缩版本和未压缩版本,所以在使用oltp风格的工作负载时,要准备好增加innodb_buffer_pool_size配置选项的值。

SQL压缩语法警告和错误
在使用file-per-tabl表空间和通用表空间的表压缩特性时可能遇到的语法警告和错误。

针对每个表文件的表空间的SQL压缩语法警告和错误
当innodb_strict_mode被启用时(默认),在CREATE TABLE或ALTER TABLE语句中指定ROW_FORMAT=COMPRESSED或KEY_BLOCK_SIZE,如果innodb_file_per_table被禁用或者innodb_file_format被设置为Antelope而不是Barracuda会产生如下错误。

ERROR 1031 (HY000): Table storage engine for 't1' doesn't have this option

如果当前配置不允许使用压缩表,则不会创建该表。

当innodb_strict_mode被禁用时,在CREATE TABLE或ALTER TABLE语句中指定ROW_FORMAT=COMPRESSED或KEY_BLOCK_SIZE,如果innodb_file_per_table被禁用会产生如下警告。

mysql> SHOW WARNINGS;
+---------+------+---------------------------------------------------------------+
| Level | Code | Message |
+---------+------+---------------------------------------------------------------+
| Warning | 1478 | InnoDB: KEY_BLOCK_SIZE requires innodb_file_per_table. |
| Warning | 1478 | InnoDB: ignoring KEY_BLOCK_SIZE=4. |
| Warning | 1478 | InnoDB: ROW_FORMAT=COMPRESSED requires innodb_file_per_table. |
| Warning | 1478 | InnoDB: assuming ROW_FORMAT=DYNAMIC. |
+---------+------+---------------------------------------------------------------+

如果innodb_file_format设置为Antelope而不是Barracuda,则会发出类似的警告。

这些消息只是警告,而不是错误,而且创建表时没有压缩,就像没有指定选项一样。

“非严格”行为允许您将mysqldump文件导入到不支持压缩表的数据库中,即使源数据库包含压缩表。在这种情况下,MySQL会在ROW_FORMAT=COMPACT中创建表,而不是阻止操作。

要将转储文件导入到一个新的数据库中,并重新创建原始数据库中的表,请确保服务器对innodb_file_format和innodb_file_per_table配置参数有适当的设置。

只有在ROW_FORMAT指定为COMPRESSED或省略时,属性KEY_BLOCK_SIZE才允许使用。使用任何其他ROW_FORMAT指定KEY_BLOCK_SIZE都会产生一个警告,用户可以通过SHOW WARNINGS查看。但是,该表没有被压缩。忽略指定的KEY_BLOCK_SIZE)。

Level   Code Message
Warning 1478 InnoDB: ignoring KEY_BLOCK_SIZE=n unless ROW_FORMAT=COMPRESSED.

如果运行时启用了innodb_strict_mode, KEY_BLOCK_SIZE和任何ROW_FORMAT的组合都会产生一个错误,而不是一个警告,并且表不会被创建。

当innodb_strict_mode关闭时,MySQL创建或修改表,但忽略某些设置,如下所示。你可以在MySQL错误日志中看到警告消息。当innodb_strict_mode开启时,这些指定的选项组合将产生错误,表不会被创建或修改。要查看错误条件的完整描述,请执行SHOW ERRORS语句:示例:

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

mysql> CREATE TABLE x (id INT PRIMARY KEY, c INT)  ENGINE=INNODB KEY_BLOCK_SIZE=33333;
ERROR 1005 (HY000): Can't create table 'test.x' (errno: 1478)

mysql> SHOW ERRORS;
+-------+------+-------------------------------------------+
| Level | Code | Message |
+-------+------+-------------------------------------------+
| Error | 1478 | InnoDB: invalid KEY_BLOCK_SIZE=33333. |
| Error | 1005 | Can't create table 'test.x' (errno: 1478) |
+-------+------+-------------------------------------------+

当innodb_strict_mode开启时,MySQL会拒绝无效的ROW_FORMAT或KEY_BLOCK_SIZE参数并抛出错误。当innodb_strict_mode关闭时,MySQL会对忽略的无效参数发出警告而不是错误。innodb_strict_mode默认开启。

当innodb_strict_mode开启时,MySQL拒绝无效的ROW_FORMAT或KEY_BLOCK_SIZE参数。为了兼容MySQL的早期版本,默认不会启用严格模式。相反,MySQL会对被忽略的无效参数发出警告(而不是错误)。

使用SHOW TABLE STATUS是不可能看到选定的KEY_BLOCK_SIZE的。语句SHOW CREATE TABLE显示KEY_BLOCK_SIZE(即使在创建表时忽略了它)。MySQL无法显示表的实际压缩页大小。

通用表空间的SQL压缩语法警告和错误
.如果在创建表空间时没有为普通表空间定义FILE_BLOCK_SIZE,则该表空间不能包含压缩表。如果试图添加压缩表,则返回错误,如下面的例子所示:

mysql> CREATE TABLESPACE ts4 ADD DATAFILE 'ts4.ibd' Engine=InnoDB;
Query OK, 0 rows affected (0.00 sec)


mysql> CREATE TABLE t4 (c1 INT PRIMARY KEY) TABLESPACE ts4 ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=8;
ERROR 1478 (HY000): InnoDB: Tablespace `ts4` cannot contain a COMPRESSED table

.试图将无效KEY_BLOCK_SIZE设置的表添加到普通表空间会返回错误,如下面的例子所示:

mysql> CREATE TABLESPACE `ts5` ADD DATAFILE 'ts5.ibd' FILE_BLOCK_SIZE = 8192 Engine=InnoDB;
Query OK, 0 rows affected (0.01 sec)

mysql> CREATE TABLE t5 (c1 INT PRIMARY KEY) TABLESPACE ts5 ROW_FORMAT=COMPRESSED  KEY_BLOCK_SIZE=4;
ERROR 1478 (HY000): InnoDB: Tablespace `ts5` uses block size 8192 and cannot contain a table with physical page size 4096

对于普通表空间,表的KEY_BLOCK_SIZE必须等于表空间的FILE_BLOCK_SIZE除以1024。例如,表空间的FILE_BLOCK_SIZE为8192,则表的KEY_BLOCK_SIZE必须为8。

.尝试将一个未压缩行格式的表添加到配置为存储压缩表的一般表空间会返回一个错误,如下面的例子所示:

mysql> CREATE TABLESPACE `ts6` ADD DATAFILE 'ts6.ibd' FILE_BLOCK_SIZE = 8192 Engine=InnoDB;
Query OK, 0 rows affected (0.01 sec)

mysql> CREATE TABLE t6 (c1 INT PRIMARY KEY) TABLESPACE ts6 ROW_FORMAT=COMPACT;
ERROR 1478 (HY000): InnoDB: Tablespace `ts6` uses block size 8192 and cannot contain a table with physical page size 16384

innodb_strict_mode不适用于一般表空间。一般表空间的表空间管理规则是严格执行的,独立于innodb_strict_mode。

]]>
http://www.jydba.net/index.php/archives/3499/feed 0
MySQL InnoDB全文索引 http://www.jydba.net/index.php/archives/3496 http://www.jydba.net/index.php/archives/3496#respond Fri, 16 Jun 2023 07:52:43 +0000 http://www.jydba.net/?p=3496 InnoDB全文索引
FULLTEXT索引是在基于文本的列(CHAR、VARCHAR或TEXT列)上创建的,以帮助加快对这些列中包含的数据的查询和DML操作,从而省略定义为停止词的任何单词。FULLTEXT索引定义为CREATE TABLE语句的一部分,或者使用ALTER TABLE或CREATE index将其添加到现有表中。全文搜索使用MATCH()…对语法。

InnoDB全文索引设计
InnoDB FULLTEXT索引采用倒排索引设计。倒排索引存储一个单词列表,对于每个单词,存储该单词出现在其中的文档列表。为了支持邻近搜索,每个字的位置信息也以字节偏移量的形式存储。

InnoDB全文索引表
当创建一个InnoDB FULLTEXT索引时,会创建一组索引表,示例如下:

mysql> CREATE TABLE opening_lines (
    -> id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY,
    -> opening_line TEXT(500),
    -> author VARCHAR(200),
    -> title VARCHAR(200),
    -> FULLTEXT idx (opening_line)
    -> ) ENGINE=InnoDB;
Query OK, 0 rows affected (0.05 sec)

mysql> SELECT table_id, name, space from INFORMATION_SCHEMA.INNODB_SYS_TABLES WHERE name LIKE 'undo/%';
+----------+----------------------------------------------------+-------+
| table_id | name                                               | space |
+----------+----------------------------------------------------+-------+
|      453 | undo/FTS_00000000000001bf_00000000000002bb_INDEX_1 |   452 |
|      454 | undo/FTS_00000000000001bf_00000000000002bb_INDEX_2 |   453 |
|      455 | undo/FTS_00000000000001bf_00000000000002bb_INDEX_3 |   454 |
|      456 | undo/FTS_00000000000001bf_00000000000002bb_INDEX_4 |   455 |
|      457 | undo/FTS_00000000000001bf_00000000000002bb_INDEX_5 |   456 |
|      458 | undo/FTS_00000000000001bf_00000000000002bb_INDEX_6 |   457 |
|      448 | undo/FTS_00000000000001bf_BEING_DELETED            |   447 |
|      449 | undo/FTS_00000000000001bf_BEING_DELETED_CACHE      |   448 |
|      450 | undo/FTS_00000000000001bf_CONFIG                   |   449 |
|      451 | undo/FTS_00000000000001bf_DELETED                  |   450 |
|      452 | undo/FTS_00000000000001bf_DELETED_CACHE            |   451 |
|      447 | undo/opening_lines                                 |   446 |
+----------+----------------------------------------------------+-------+
12 rows in set (0.00 sec)

前六个表表示倒排索引,称为辅助索引表。在对传入文档进行标记时,将单个单词(也称为“标记”)与位置信息和相关文档ID (DOC_ID)一起插入到索引表中。根据单词第一个字符的字符集排序权重,将单词完全排序并在六个索引表中进行分区。

倒排索引被划分为六个辅助索引表,以支持并行索引创建。默认情况下,两个线程对单词和相关数据进行标记、排序和插入索引表。线程的数量可以使用innodb_ft_sort_pll_degree选项进行配置。考虑在大型表上创建FULLTEXT索引时增加线程数。

辅助索引表名的前缀是FTS_,后缀是INDEX_*。每个索引表通过索引表名称中的十六进制值与被索引表相关联,该值与被索引表的table_id相匹配。例如,test/opening_lines表的table_id为447,其十六进制值为0x1bf。如前面的示例所示,“1bf”十六进制值出现在与test/opening_lines表相关联的索引表的名称中。

表示FULLTEXT索引的index_id的十六进制值也出现在辅助索引表名中。例如,在辅助表名undo/FTS_00000000000001bf_00000000000002bb_INDEX_1中,十六进制值2bb的十进制值为699。opening_lines表(idx)上定义的索引可以通过查询INFORMATION_SCHEMA来识别。INNODB_SYS_INDEXES表的值(699)。

mysql> SELECT index_id, name, table_id, space from INFORMATION_SCHEMA.INNODB_SYS_INDEXES WHERE index_id=699;
+----------+------+----------+-------+
| index_id | name | table_id | space |
+----------+------+----------+-------+
|      699 | idx  |      447 |   446 |
+----------+------+----------+-------+
1 row in set (0.00 sec)

如果主表是在每个表文件的表空间中创建的,则索引表存储在它们自己的表空间中。

前面示例中显示的其他索引表被称为公共索引表,用于删除处理和存储FULLTEXT索引的内部状态。与为每个全文索引创建的倒排索引表不同,这组表对于在特定表上创建的所有全文索引都是通用的。

即使删除全文索引,也会保留常见的辅助表。当全文索引被删除时,为索引创建的FTS_DOC_ID列将被保留,因为删除FTS_DOC_ID列将需要重建表。管理FTS_DOC_ID列需要使用普通的辅助表。
.FTS_*_DELETED and FTS_*_DELETED_CACHE

包含已删除但其数据尚未从全文索引中删除的文档的文档id (DOC_ID)。FTS_*_DELETED_CACHE是FTS_*_DELETED表的内存版本。

.FTS_*_BEING_DELETED and FTS_*_BEING_DELETED_CACHE
包含要删除的文档的文档id (DOC_ID),这些文档的数据目前正在从全文索引中删除。FTS_*_BEING_DELETED_CACHE表是FTS_*_BEING_DELETED表的内存版本。

.FTS_*_CONFIG
存储关于FULLTEXT索引的内部状态的信息。最重要的是,它存储FTS_SYNCED_DOC_ID,它标识已解析并刷新到磁盘的文档。在崩溃恢复的情况下,FTS_SYNCED_DOC_ID值用于标识尚未刷新到磁盘的文档,以便可以重新解析文档并将其添加回FULLTEXT索引缓存。要查看该表中的数据,请查询INFORMATION_SCHEMA.INNODB_FT_CONFIG表。

InnoDB全文索引缓存
插入文档时,将对其进行标记,并将单个单词和相关数据插入到FULLTEXT索引中。这个过程,即使对于小文档,也可能导致对辅助索引表进行大量小的插入,从而使对这些表的并发访问成为争用点。为了避免这个问题,InnoDB使用FULLTEXT索引缓存来临时缓存索引表中最近插入的行。这个内存缓存结构保存插入,直到缓存满,然后将它们批量刷新到磁盘(到辅助索引表)。可以查询INFORMATION_SCHEMA.INNODB_FT_INDEX_CACHE表用于查看最近插入的行的标记化数据。

缓存和批处理刷新行为避免了对辅助索引表的频繁更新,这可能在繁忙的插入和更新期间导致并发访问问题。批处理技术还避免了对同一个单词的多次插入,并最大限度地减少了重复条目。不是逐个刷新每个单词,而是将相同单词的插入合并并作为单个条目刷新到磁盘,从而提高了插入效率,同时使辅助索引表尽可能小。

innodb_ft_cache_size变量用于配置全文索引缓存大小(以每个表为基础),它影响全文索引缓存刷新的频率。您还可以使用innodb_ft_total_cache_size选项为给定实例中的所有表定义全局全文索引缓存大小限制。

全文索引缓存存储与辅助索引表相同的信息。但是,全文索引缓存仅为最近插入的行缓存标记化的数据。查询时,已经刷新到磁盘(全文辅助表)的数据不会被带回到全文索引缓存中。直接查询辅助索引表中的数据,并且在返回之前,将辅助索引表中的结果与全文索引缓存中的结果合并。

InnoDB全文索引文档ID和FTS_DOC_ID列
InnoDB使用一个唯一的文档标识符,即文档ID (DOC_ID),将全文索引中的单词映射到该单词出现的文档记录。映射需要索引表上的FTS_DOC_ID列。如果没有定义FTS_DOC_ID列,InnoDB会在创建全文索引时自动添加一个隐藏的FTS_DOC_ID列。下面的示例演示了这种行为。

下面的表定义不包含FTS_DOC_ID列:

mysql> CREATE TABLE opening_lines (
    -> id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY,
    -> opening_line TEXT(500),
    -> author VARCHAR(200),
    -> title VARCHAR(200)
    -> ) ENGINE=InnoDB;
Query OK, 0 rows affected (0.01 sec)

当使用create FULLTEXT index语法在表上创建全文索引时,会返回一个警告,报告InnoDB正在重建表以添加FTS_DOC_ID列。

mysql> CREATE FULLTEXT INDEX idx ON opening_lines(opening_line);
Query OK, 0 rows affected, 1 warning (0.10 sec)
Records: 0  Duplicates: 0  Warnings: 1

mysql> SHOW WARNINGS;
+---------+------+--------------------------------------------------+
| Level   | Code | Message                                          |
+---------+------+--------------------------------------------------+
| Warning |  124 | InnoDB rebuilding table to add column FTS_DOC_ID |
+---------+------+--------------------------------------------------+
1 row in set (0.00 sec)

当使用ALTER TABLE向没有FTS_DOC_ID列的表添加全文索引时,也会返回相同的警告。如果你在create TABLE时间创建一个全文索引,并且没有指定FTS_DOC_ID列,InnoDB会添加一个隐藏的FTS_DOC_ID列,没有警告。

在CREATE TABLE时定义一个FTS_DOC_ID列比在一个已经加载了数据的表上创建一个全文索引要便宜。如果在加载数据之前在表上定义了FTS_DOC_ID列,则不必重新构建表及其索引来添加新列。如果你不关心CREATE FULLTEXT INDEX的性能,可以省略FTS_DOC_ID列,让InnoDB为你创建它。InnoDB创建一个隐藏的FTS_DOC_ID列,并在FTS_DOC_ID列上创建一个唯一的索引(FTS_DOC_ID_INDEX)。如果你想创建自己的FTS_DOC_ID列,该列必须定义为BIGINT UNSIGNED NOT NULL,并命名为FTS_DOC_ID(全大写),如下所示:

FTS_DOC_ID列不需要定义为AUTO_INCREMENT列,但是AUTO_INCREMENT可以使加载数据更容易。

mysql> CREATE TABLE opening_lines (
    -> FTS_DOC_ID BIGINT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY,
    -> opening_line TEXT(500),
    -> author VARCHAR(200),
    -> title VARCHAR(200)
    -> ) ENGINE=InnoDB;
Query OK, 0 rows affected (0.01 sec)

如果选择自己定义FTS_DOC_ID列,则负责管理该列,以避免空值或重复值。FTS_DOC_ID的值不能重复使用,这意味着FTS_DOC_ID的值必须不断增加。

可选地,您可以在FTS_DOC_ID列上创建所需的惟一FTS_DOC_ID_INDEX(全部大写)。

mysql> CREATE UNIQUE INDEX FTS_DOC_ID_INDEX on opening_lines(FTS_DOC_ID);
Query OK, 0 rows affected (0.01 sec)
Records: 0  Duplicates: 0  Warnings: 0

如果你没有创建FTS_DOC_ID_INDEX, InnoDB会自动创建它。

在MySQL 5.7.13之前,已使用的FTS_DOC_ID值与新的FTS_DOC_ID值之间允许的最大差值为10000。在MySQL 5.7.13及以后版本中,允许的间隙是65535。

为了避免重新构建表,在删除全文索引时保留FTS_DOC_ID列。

InnoDB全文索引删除处理
删除具有全文索引列的记录可能会导致辅助索引表中出现大量小的删除,从而使对这些表的并发访问成为争用点。为了避免这个问题,被删除文档的文档ID (DOC_ID)记录在一个特殊的FTS_*_DELETED表中,当一条记录从索引表中删除时,被索引的记录保留在全文索引中。在返回查询结果之前,使用FTS_*_DELETED表中的信息过滤已删除的Document id。这种设计的好处是,删除是快速和廉价的。缺点是在删除记录后索引的大小不会立即减小。要删除已删除记录的全文索引项,可以在已索引的表上运行OPTIMIZE TABLE命令(innodb_optimize_fulltext_only= on)重建全文索引。

InnoDB全文索引事务处理
InnoDB FULLTEXT索引由于其缓存和批处理行为而具有特殊的事务处理特性。具体来说,FULLTEXT索引上的更新和插入是在事务提交时处理的,这意味着FULLTEXT搜索只能看到提交的数据。下面的示例演示了这种行为。FULLTEXT搜索只在提交插入的行之后返回结果。

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

mysql> INSERT INTO opening_lines(opening_line,author,title) VALUES
    -> ('Call me Ishmael.','Herman Melville','Moby-Dick'),
    -> ('A screaming comes across the sky.','Thomas Pynchon','Gravity\'s Rainbow'),
    -> ('I am an invisible man.','Ralph Ellison','Invisible Man'),
    -> ('Where now? Who now? When now?','Samuel Beckett','The Unnamable'),
    -> ('It was love at first sight.','Joseph Heller','Catch-22'),
    -> ('All this happened, more or less.','Kurt Vonnegut','Slaughterhouse-Five'),
    -> ('Mrs. Dalloway said she would buy the flowers herself.','Virginia Woolf','Mrs. Dalloway'),
    -> ('It was a pleasure to burn.','Ray Bradbury','Fahrenheit 451');
Query OK, 8 rows affected (0.00 sec)
Records: 8  Duplicates: 0  Warnings: 0

mysql> SELECT COUNT(*) FROM opening_lines WHERE MATCH(opening_line) AGAINST('Ishmael');
+----------+
| COUNT(*) |
+----------+
|        0 |
+----------+
1 row in set (0.01 sec)

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

mysql> SELECT COUNT(*) FROM opening_lines WHERE MATCH(opening_line) AGAINST('Ishmael');
+----------+
| COUNT(*) |
+----------+
|        1 |
+----------+
1 row in set (0.00 sec)

]]>
http://www.jydba.net/index.php/archives/3496/feed 0
MySQL InnoDB的AUTO_INCREMENT处理 http://www.jydba.net/index.php/archives/3493 http://www.jydba.net/index.php/archives/3493#respond Wed, 10 May 2023 01:58:51 +0000 http://www.jydba.net/?p=3493 InnoDB的AUTO_INCREMENT处理
InnoDB提供了一种可配置的锁机制,可以显著提高将行添加到具有AUTO_INCREMENT列的表中的SQL语句的可伸缩性和性能。要在InnoDB表中使用AUTO_INCREMENT机制,必须将一个AUTO_INCREMENT列定义为索引的一部分,这样就可以在表上执行相当于索引SELECT MAX(ai_col)的查找以获得最大列值。通常,这是通过使某一列成为某些表索引的第一列来实现的。

本节描述AUTO_INCREMENT锁模式的行为,不同AUTO_INCREMENT锁模式设置的使用影响,以及InnoDB如何初始化AUTO_INCREMENT计数器。
.InnoDB AUTO_INCREMENT锁模式
.InnoDB AUTO_INCREMENT锁模式使用影响
.InnoDB AUTO_INCREMENT计数器初始化

InnoDB AUTO_INCREMENT锁模式
用于生成自动增量值的AUTO_INCREMENT锁模式的行为,以及每种锁模式如何影响复制。自动增量锁模式在启动时使用innodb_autoinc_lock_mode配置参数配置。

以下术语用于描述innodb_autoinc_lock_mode设置:
.“INSERT-like”语句

所有在表中生成新行的语句,包括INSERT, INSERT… SELECT,REPLACE,REPLACE… SELECT和LOAD DATA。包括“简单插入”、“批量插入”和“混合模式”插入。

.“简单插入”
可以提前确定要插入的行数的语句(在初始处理语句时)。这包括没有嵌套子查询的单行和多行INSERT和REPLACE语句,但不包括INSERT … ON DUPLICATE KEY UPDATE。

.“混合模式插入”
这些是“简单插入”语句,它们为一些(但不是全部)新行指定自动增量值。下面是一个例子,其中c1是表t1的AUTO_INCREMENT列:

INSERT INTO t1 (c1,c2) VALUES (1,'a'), (NULL,'b'), (5,'c'), (NULL,'d');

另一种“混合模式插入”是INSERT…ON DUPLICATE KEY UPDATE,在最坏的情况下,它实际上是INSERT,然后是UPDATE,其中AUTO_INCREMENT列的分配值可能在更新阶段使用,也可能不使用。

innodb_autoinc_lock_mode配置参数有三种可能的设置。“传统”、“连续”、“交错”锁模式的取值分别为0、1、2。
.innodb_autoinc_lock_mode = 0(“传统”锁模式)

传统的锁模式提供了与MySQL 5.1中引入innodb_autoinc_lock_mode配置参数之前相同的行为。传统的锁模式选项是为了向后兼容、性能测试和解决“混合模式插入”的问题而提供的,因为可能存在语义上的差异。

在这种锁模式下,所有“INSERT-like”语句都获得一个特殊的表级AUTO-INC锁,用于向具有AUTO_INCREMENT列的表中插入数据。该锁通常保持到语句的末尾(而不是事务的末尾),以确保对给定的INSERT语句序列按可预测和可重复的顺序分配自动递增值,并确保任何给定语句分配的自动递增值是连续的。

在基于语句的复制的情况下,这意味着当从服务器上复制SQL语句时,自动递增列的值与主服务器上相同。多个INSERT语句的执行结果是确定的,从服务器复制的数据与主服务器相同。如果多个INSERT语句生成的自动递增值是交错的,则两个并发INSERT语句的结果将是不确定的,并且不能使用基于语句的复制可靠地将其传播到从服务器。

为了更清楚地说明这一点,考虑一个使用这个表的例子:

CREATE TABLE t1 (
  c1 INT(11) NOT NULL AUTO_INCREMENT,
  c2 VARCHAR(10) DEFAULT NULL,
  PRIMARY KEY (c1)
) ENGINE=InnoDB;

假设有两个事务正在运行,每个事务将行插入到表中AUTO_INCREMENT列。一个事务正在使用INSERT…SELECT语句,该语句插入1000行,另一个是使用一个简单的INSERT语句插入一行:

Tx1: INSERT INTO t1 (c2) SELECT 1000 rows from another table ...
Tx2: INSERT INTO t1 (c2) VALUES ('xxx');

InnoDB无法预先告诉Tx1中的INSERT语句从SELECT中检索了多少行,并且它会在语句执行过程中每次分配一个自动递增值。使用一直保持到语句末尾的表级锁,一次只能执行一条引用table t1的INSERT语句,并且不同语句生成的自动递增编号不会交叉。由Tx1 INSERT…SELECT语句生成的自动递增值是连续的,而Tx2中INSERT语句使用的(单个)自动递增值比Tx1中使用的所有自动递增值是小或还是大,这取决于首先执行哪条语句。

只要SQL语句以二进制日志中相同的顺序执行(在使用基于语句的复制时,或在恢复场景中),结果就与Tx1和Tx2第一次运行时相同。因此,表级别的锁一直保持到语句结束,使得使用自动递增的INSERT语句可以安全地与基于语句的复制一起使用。然而,当多个事务同时执行insert语句时,这些表级锁限制了并发性和可伸缩性。

在前面的示例中,如果没有表级锁,那么Tx2中用于插入的自动递增列的值完全取决于语句执行的时间。如果Tx2的插入是在Tx1的插入运行时执行的(而不是在它开始之前或完成之后),那么两个INSERT语句分配的特定的自动递增值是不确定的,并且可能在不同的运行中有所不同。

在连续锁模式下,对于预先知道行数的“simple insert”语句InnoDB可以避免使用表级的AUTO-INC锁来处理,并保持执行的确定性和基于语句的复制的安全性。

如果你不使用二进制日志来重放SQL语句作为恢复或复制的一部分,那么交错锁模式可以用来消除所有表级的AUTO-INC锁,以获得更大的并发性和性能,但代价是允许语句分配的自动递增编号之间有间隙,并且可能通过交错并发执行语句分配编号。

.innodb_autoinc_lock_mode = 1 (“连续”锁模式)

这是默认的锁定模式。在这种模式下,“批量插入”使用特殊的AUTO-INC表级锁,并一直保持到语句结束。这适用于所有的INSERT…SELECT,REPLACE … SELECT和LOAD DATA语句。一次只能执行一个持有AUTO-INC锁的语句。如果批量插入操作的源表与目标表不同,则在源表中选择的第一行获得共享锁之后,在目标表上获得AUTO-INC锁。如果批量插入操作的源和目标是同一个表,那么在对所有选定行使用共享锁之后,会使用AUTO-INC锁。

“简单插入”(需要插入的行数是预先知道的)通过在互斥量(轻量级锁)的控制下获取所需的自动递增值的数量来避免表级的AUTO-INC锁,该互斥量只在分配过程中保持,直到语句完成。除非AUTO-INC锁被另一个事务持有,否则不会使用表级的AUTO-INC锁。如果另一个事务持有AUTO-INC锁,则“简单插入”会等待AUTO-INC锁,就像“批量插入”一样。

这种锁模式确保,如果INSERT语句的行数事先不知道(并且随着语句的执行分配了自动递增号),任何“类INSERT”语句分配的所有自动递增值都是连续的,并且基于语句的复制操作是安全的。

简而言之,这种锁模式显著提高了可伸缩性,同时可以安全地与基于语句的复制一起使用。此外,与“传统”锁模式一样,任何给定语句分配的自动递增数字都是连续的。与“传统”模式相比,任何使用自动递增的语句在语义上都没有变化,但有一个重要的例外。

例外情况是“混合模式插入”,在这种情况下,用户在多行“简单插入”中为某些(但不是全部)行显式地提供AUTO_INCREMENT列的值。对于这样的插入,InnoDB分配的自动增量值比要插入的行数要多。然而,所有自动赋值的值都是连续生成的(因而高于)最近执行的前一个语句自动递增生成的值。“多余”的数字会丢失。

.innodb_autoinc_lock_mode = 2(“交错”锁模式)

在这种锁模式下,没有“INSERT-like”语句使用表级AUTO-INC锁,并且多个语句可以同时执行。这是最快和最具可伸缩性的锁模式,但是当重放来自二进制日志中SQL语句执行基于语句的复制或恢复场景时,它并不安全。

在这种锁模式下,自动增量值保证在所有并发执行的“INSERT-like”语句中是唯一且单调递增的。但是,因为多个语句可以同时生成数字(也就是说,数字的分配是跨语句交叉的),任何给定语句插入的行生成的值都可能不是连续的。

如果唯一执行的语句是“简单插入”,其中要插入的行数是提前知道的,那么除了“混合模式插入”之外,为单个语句生成的行数没有间隔。然而,当执行“批量插入”时,任何给定语句分配的自动增量值可能存在间隙。

InnoDB AUTO_INCREMENT锁模式使用影响
.对复制使用自动增量

如果使用基于语句的复制,请将innodb_autoinc_lock_mode设置为0或1,并在主服务器和从服务器上使用相同的值。如果使用innodb_autoinc_lock_mode = 2 (” interleaved “),或者配置主、从不使用相同的锁模式,则不能确保从上的自动增量值与主上的相同。

如果您使用的是基于行或混合格式的复制,那么所有的自动增量锁模式都是安全的,因为基于行的复制对SQL语句的执行顺序不敏感(对于基于语句的复制来说不安全的任何语句混合格式使用基于行的复制来进行处理)。

.“丢失”自动增量值和序列间隙

在所有锁模式(0、1和2)中,如果生成自动递增值的事务回滚,则这些自动递增值将“丢失”。一旦为自动递增的列生成了值,无论“INSERT-like”语句是否完成,以及包含它的事务是否回滚,它都不能回滚。这些丢失的值不会被重用。因此,存储在表的AUTO_INCREMENT列中的值可能会有差距。

.为AUTO_INCREMENT列指定NULL或0
在所有的锁模式下(0、1和2),如果用户为INSERT语句中的AUTO_INCREMENT列指定了NULL或0,InnoDB将该行视为未指定值,并为其生成一个新值。

.给AUTO_INCREMENT列赋一个负值
在所有锁模式(0、1和2)中,如果给AUTO_INCREMENT列赋一个负值,则不会定义自动递增机制的行为。

.如果AUTO_INCREMENT值大于指定整数类型的最大整数
在所有锁模式(0、1和2)中,如果值大于可以存储在指定整数类型中的最大整数,则不定义自动递增机制的行为。

.“bulk inserts”的自动增量值存在间隔
当innodb_autoinc_lock_mode设置为0(“传统”)或1(“连续”)时,任何给定语句生成的自动增量值都是连续的,没有间隔,因为表级AUTOINC锁一直保持到语句结束,并且一次只能执行一个这样的语句。

当innodb_autoinc_lock_mode设置为2(“交错”)时,“bulk inserts”生成的自动增量值可能会有间隙,但仅当有并发执行“类似插入”语句时才会如此。

对于锁模式1或2,因为对于批量插入,可能不知道每个语句所需的自动增量值的确切数量,并且可能会高估因此连续语句之间可能会出现间隙。

.“混合模式插入”分配的自动增量值

考虑一个“混合模式插入”,其中一个“简单插入”指定了一些结果行(但不是全部)的自动增量值。这样的语句在锁模式0、1和2中的行为不同。例如,假设c1是表t1的AUTO_INCREMENT列,并且最近自动生成的序列号是100。

mysql> CREATE TABLE t1
    -> (
    ->   c1 INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
    ->   c2 CHAR(1)
    -> ) ENGINE = INNODB;
Query OK, 0 rows affected (0.01 sec)

mysql> insert into t1 values(100,'x');
Query OK, 1 row affected (0.00 sec)

mysql> select * from t1;
+-----+------+
| c1  | c2   |
+-----+------+
| 100 | x    |
+-----+------+
1 row in set (0.00 sec)

现在,考虑下面的“混合模式插入”语句:

mysql> INSERT INTO t1 (c1,c2) VALUES (1,'a'), (NULL,'b'), (5,'c'), (NULL,'d');
Query OK, 4 rows affected (0.00 sec)
Records: 4  Duplicates: 0  Warnings: 0

mysql> SELECT c1, c2 FROM t1 ORDER BY c2;
+-----+------+
| c1  | c2   |
+-----+------+
|   1 | a    |
| 101 | b    |
|   5 | c    |
| 102 | d    |
| 100 | x    |
+-----+------+
5 rows in set (0.00 sec)

下一个可用的自动递增值是103,因为自动递增值是每次分配一个,而不是在语句执行开始时一次性分配的。无论是否有并发执行的“INSERT-like”语句(任何类型),该结果都为true。

当innodb_autoinc_lock_mode设置为1(“连续”)时,这四个新行也是:

mysql> SELECT c1, c2 FROM t1 ORDER BY c2;
+-----+------+
| c1  | c2   |
+-----+------+
|   1 | a    |
| 101 | b    |
|   5 | c    |
| 102 | d    |
| 100 | x    |
+-----+------+
5 rows in set (0.01 sec)

然而,在本例中,下一个可用的自动增量值是105,而不是103,因为在处理语句时分配了四个自动增量值,但只使用了两个。无论是否并发执行“INSERT-like”语句(任何类型),这个结果都为真。

mysql> show create table t1;
+-------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table                                                                                                                                                                      |
+-------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| t1    | CREATE TABLE `t1` (
  `c1` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `c2` char(1) DEFAULT NULL,
  PRIMARY KEY (`c1`)
) ENGINE=InnoDB AUTO_INCREMENT=105 DEFAULT CHARSET=utf8mb4 |
+-------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

innodb_autoinc_lock_mode设置为模式2(“交错”),这四个新行是:

mysql> show variables like 'innodb_autoinc_lock_mode';
+--------------------------+-------+
| Variable_name            | Value |
+--------------------------+-------+
| innodb_autoinc_lock_mode | 2     |
+--------------------------+-------+
1 row in set (0.00 sec)

mysql> SELECT c1, c2 FROM t1 ORDER BY c2;
+-----+------+
| c1  | c2   |
+-----+------+
|   1 | a    |
|   x | b    |
|   5 | c    |
|   y | d    |
| 100 | x    |
+-----+------+
5 rows in set (0.00 sec)

x和y的值是唯一的,且大于之前生成的任何行。但是,x和y的具体值取决于并发执行语句生成的自动增量值的数量。

最后,考虑以下语句,当最近生成的序列号为4时发出:

mysql> truncate table t1;
Query OK, 0 rows affected (0.01 sec)

mysql> insert into t1 values(4,'x');
Query OK, 1 row affected (0.00 sec)

mysql> SELECT c1, c2 FROM t1 ORDER BY c2;
+----+------+
| c1 | c2   |
+----+------+
|  4 | x    |
+----+------+
1 row in set (0.00 sec)

mysql> show create table t1;
+-------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table                                                                                                                                                                    |
+-------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| t1    | CREATE TABLE `t1` (
  `c1` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `c2` char(1) DEFAULT NULL,
  PRIMARY KEY (`c1`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 |
+-------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

mysql> INSERT INTO t1 (c1,c2) VALUES (1,'a'), (NULL,'b'), (5,'c'), (NULL,'d');
ERROR 1062 (23000): Duplicate entry '5' for key 'PRIMARY'

对于任何innodb_autoinc_lock_mode设置,该语句都会生成一个ERROR 1062 (23000): Duplicate entry ‘5’ for key ‘PRIMARY’,因为5被分配给行(NULL, ‘b’),并且行(5,’c’)的插入失败。

.修改INSERT语句序列中间的AUTO_INCREMENT列值

在所有锁模式(0、1和2)中,在INSERT语句序列的中间修改AUTO_INCREMENT列值可能会导致“重复条目”错误。例如,如果您执行更新操作,将AUTO_INCREMENT列的值更改为大于当前最大自动递增值的值,则后续的插入操作如果没有指定未使用的自动递增值,可能会遇到“重复条目”错误。下面的例子演示了这种行为。

mysql> drop table t1;
Query OK, 0 rows affected (0.02 sec)

mysql> create table t1
    -> (c1 int not null auto_increment,
    -> primary key(c1)
    -> ) engine=innodb;
Query OK, 0 rows affected (0.01 sec)

mysql> INSERT INTO t1 VALUES(0), (0), (3);
Query OK, 3 rows affected (0.01 sec)
Records: 3  Duplicates: 0  Warnings: 0

mysql> SELECT c1 FROM t1;
+----+
| c1 |
+----+
|  1 |
|  2 |
|  3 |
+----+
3 rows in set (0.00 sec)

mysql> UPDATE t1 SET c1 = 4 WHERE c1 = 1;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql> SELECT c1 FROM t1;
+----+
| c1 |
+----+
|  2 |
|  3 |
|  4 |
+----+
3 rows in set (0.00 sec)

mysql> INSERT INTO t1 VALUES(0);
ERROR 1062 (23000): Duplicate entry '4' for key 'PRIMARY'

< ?pre>
InnoDB AUTO_INCREMENT计数器初始化

如果你为InnoDB表指定了一个AUTO_INCREMENT列,那么InnoDB数据字典中的表句柄中就会包含一个特殊的计数器,叫做自动递增计数器(auto-increment counter),用于为这一列赋值。这个计数器只存储在主内存中,而不是磁盘中。

为了在服务器重启后初始化一个自动递增计数器,InnoDB在第一次向包含AUTO_INCREMENT列的表中插入数据时,执行等价于下面的语句。
SELECT MAX(ai_col) FROM table_name FOR UPDATE;

InnoDB递增语句检索到的值,并将其分配给列和表的autoincrement计数器。缺省情况下,加1。这个默认值可以通过auto_increment_increment配置设置覆盖。

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

如果表为空,InnoDB使用值1。这个默认值可以被auto_increment_offset配置设置覆盖。

mysql> show variables like 'auto_increment_offset';
+-----------------------+-------+
| Variable_name         | Value |
+-----------------------+-------+
| auto_increment_offset | 1     |
+-----------------------+-------+
1 row in set (0.00 sec)

如果SHOW TABLE STATUS语句在自动递增计数器初始化之前检查了表,InnoDB会初始化该值,但不会递增。该值被存储起来,供后续插入使用。此初始化使用表上的普通排它锁定读取,锁持续到事务结束。InnoDB为新创建的表初始化自增计数器的过程与此相同。

在自动递增计数器被初始化之后,如果你没有显式地为AUTO_INCREMENT列指定一个值,InnoDB会递增计数器并将新值赋值给列。如果插入显式指定列值的行,且该值大于当前计数器值,则计数器设置为指定的列值。

只要服务器在运行,InnoDB就会使用内存中的自动递增计数器。当服务器停止并重新启动时,InnoDB会在第一次插入表时重新初始化每个表的计数器,如前所述。

服务器重启也会取消CREATE table和ALTER table语句中的AUTO_INCREMENT = N 表选项的影响,你可以在InnoDB表中使用它来设置初始的计数器值或改变当前的计数器值。

]]>
http://www.jydba.net/index.php/archives/3493/feed 0
MySQL参数名不正确导致启动时报The server quit without updating PID file pre http://www.jydba.net/index.php/archives/3491 http://www.jydba.net/index.php/archives/3491#respond Wed, 10 May 2023 01:51:07 +0000 http://www.jydba.net/?p=3491 在MySQL参数文件my.cnf中配置参数innodb_autoinc_lock_mode在,配置后重启服务时出现以下错误:

[root@localhost mysql]# service mysqld restart
Shutting down MySQL.... SUCCESS!
Starting MySQL..... ERROR! The server quit without updating PID file (/mysqldata/mysql/mysqld.pid).

由于查看参数文件my.cnf,发现参数变成了nnodb_autoinc_lock_mode=2,这是由于复制粘贴造成少了一个i字母

[mysql@localhost mysql]$ cat my.cnf
......
nnodb_autoinc_lock_mode=2
......

修改正确

[mysql@localhost mysql]$ vi my.cnf
......
innodb_autoinc_lock_mode=2
......

再重启服务

[root@localhost mysql]# service mysqld restart
 ERROR! MySQL server PID file could not be found!
Starting MySQL... SUCCESS!
]]>
http://www.jydba.net/index.php/archives/3491/feed 0
Oracle Linux 6.7 安装MySQL 8.0.33 http://www.jydba.net/index.php/archives/3489 http://www.jydba.net/index.php/archives/3489#respond Mon, 08 May 2023 08:35:16 +0000 http://www.jydba.net/?p=3489 在Oracle Linux 6.7中安装MySQL 8.0.33 mysql安装位置:/mysqlsoft/mysql,数据库文件数据位置:/mysqldata/mysql
1.首先下载安装介质

mysql-8.0.33-linux-glibc2.12-x86_64.tar.xz

2. 在根目录下创建文件夹mysqlsoft和数据库数据文件/mysqldata/mysql

[root@sjbf /]# mkdir -p /mysqlsoft
[root@sjbf /]# mkdir -p /mysqldata/mysql

3.上传介质mysql-8.0.33-linux-glibc2.28-x86_64.tar.gz到/mysqlsoft目录中并解压

[root@sjbf /]# cd /mysqlsoft
[root@sjbf mysqlsoft]# ll
total 527224
-rw-r--r-- 1 root root 539869923 May  5 09:50 mysql-8.0.33-linux-glibc2.12-x86_64.tar.xz

[root@sjbf mysqlsoft]# tar xvJf mysql-8.0.33-linux-glibc2.12-x86_64.tar.xz

[root@sjbf mysqlsoft]# ll
total 600560
drwxr-xr-x 9 root root      4096 May  6 03:49 mysql-8.0.33-linux-glibc2.12-x86_64
-rw-r--r-- 1 root root 614964216 May  5 15:28 mysql-8.0.33-linux-glibc2.12-x86_64.tar.xz

建议一般不要修改默认文件名,通过软连接来完成

[root@sjbf mysqlsoft]# ln -s mysql-8.0.33-linux-glibc2.12-x86_6 mysql
[root@sjbf mysqlsoft]# ll
total 600560
lrwxrwxrwx 1 root root        34 May  6 03:53 mysql -> mysql-8.0.33-linux-glibc2.12-x86_6
drwxr-xr-x 9 root root      4096 May  6 03:49 mysql-8.0.33-linux-glibc2.12-x86_64
-rw-r--r-- 1 root root 614964216 May  5 15:28 mysql-8.0.33-linux-glibc2.12-x86_64.tar.xz



[root@sjbf mysqlsoft]# cd mysql
[root@sjbf mysql]# ll
total 312
drwxr-xr-x  2 7161 31415   4096 Mar 17 02:46 bin
drwxr-xr-x  2 7161 31415   4096 Mar 17 02:46 docs
drwxr-xr-x  3 7161 31415   4096 Mar 17 02:46 include
drwxr-xr-x  6 7161 31415   4096 Mar 17 02:46 lib
-rw-r--r--  1 7161 31415 284945 Mar 17 01:22 LICENSE
drwxr-xr-x  4 7161 31415   4096 Mar 17 02:46 man
-rw-r--r--  1 7161 31415    666 Mar 17 01:22 README
drwxr-xr-x 28 7161 31415   4096 Mar 17 02:46 share
drwxr-xr-x  2 7161 31415   4096 Mar 17 02:46 support-files

4. 创建mysql用户与用户组

[root@sjbf /]# groupadd mysql
[root@sjbf /]# useradd -r -g mysql -s /bin/false mysql
[root@sjbf /]# id mysql
uid=492(mysql) gid=54323(mysql) groups=54323(mysql)

因为用户只用于所有权目的,而不是登录目的,useradd命令使用-r与-s /bin/false选项来创建一个用户没有登录服务器主机的权限。

5.修改/mysqlsoft/mysql与/mysqldata/mysql目录权限

[root@sjbf /]# chown -R mysql:mysql /mysqlsoft/mysql
[root@sjbf /]# chown -R mysql:mysql /mysqldata/mysql
[root@sjbf /]# chmod -R 775 /mysqlsoft/mysql
[root@sjbf /]# chmod -R 775 /mysqldata/mysql

6. MySQL对于libaio库有依赖性。台果这个libaio库没有安装那么数据目录初始化与后续的数据库服务启动将会失败,安装libaio库执行以下操作:
查询是否安装了libaio库

[root@sjbf /]# yum search libaio
Loaded plugins: aliases, changelog, kabi, presto, refresh-packagekit, security, tmprepo, ulninfo, verify, versionlock
Loading support for kernel ABI
=========================================================================================================== N/S Matched: libaio ===========================================================================================================
libaio.i686 : Linux-native asynchronous I/O access library
libaio.x86_64 : Linux-native asynchronous I/O access library
libaio-devel.i686 : Development files for Linux-native asynchronous I/O access
libaio-devel.x86_64 : Development files for Linux-native asynchronous I/O access

  Name and summary matches only, use "search all" for everything.

如果没有安装,可以执行下面的命令来安装

[root@sjbf /]# yum install libaio
Loaded plugins: aliases, changelog, kabi, presto, refresh-packagekit, security, tmprepo, ulninfo, verify, versionlock
Loading support for kernel ABI
Setting up Install Process
Package libaio-0.3.107-10.el6.x86_64 already installed and latest version
Nothing to do

7.配置mysql参数
只是设置几个简单的mysql运行参数

[root@sjbf mysql]# vi my.cnf
[mysqld]
basedir=/mysqlsoft/mysql
datadir=/mysqldata/mysql
bind-address=0.0.0.0
user=mysql
port=3306
mysqlx_port=33060
log-error=/mysqldata/mysql/mysql.err
pid-file=/mysqldata/mysql/mysqld.pid
socket = /mysqlsoft/mysql/mysql.sock
mysqlx_socket=/mysqlsoft/mysql/mysqlx.sock
character-set-server=utf8
default-storage-engine=INNODB

注意:log-error 一定要配置,因为如果mysql启动错误,可以从日志文件中找到错误原因。其次bind-address配置0.0.0.0是为了监听所有的连接。还有就是socket参数所指定的mysql.sock文件的路径最好设置为/tmp/mysql.sock,因为unix socket文件的缺省位置在/tmp目录中。

8.初始化mysql

[root@sjbf bin]# ./mysqld --user=mysql  --defaults-file=/mysqlsoft/mysql/my.cnf --basedir=/mysqlsoft/mysql --datadir=/mysqldata/mysql --initialize
2023-05-05T20:21:18.355164Z 0 [System] [MY-013169] [Server] /mysqlsoft/mysql-8.0.33-linux-glibc2.12-x86_64/bin/mysqld (mysqld 8.0.33) initializing of server in progress as process 26730
2023-05-05T20:21:18.412269Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2023-05-05T20:21:25.831475Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2023-05-05T20:21:42.025674Z 0 [ERROR] [MY-000067] [Server] unknown variable 'defaults-file=/mysqlsoft/mysql/my.cnf'.
2023-05-05T20:21:42.025812Z 0 [ERROR] [MY-013236] [Server] The designated data directory /mysqldata/mysql/ is unusable. You can remove all files that the server added to it.
2023-05-05T20:21:42.025914Z 0 [ERROR] [MY-010119] [Server] Aborting
2023-05-05T20:21:53.091946Z 0 [System] [MY-010910] [Server] /mysqlsoft/mysql-8.0.33-linux-glibc2.12-x86_64/bin/mysqld: Shutdown complete (mysqld 8.0.33)  MySQL Community Server - GPL.

调整一下参数顺序

[root@sjbf bin]# ./mysqld --defaults-file=/mysqlsoft/mysql/my.cnf --initialize --user=mysql --basedir=/mysqlsoft/mysql --datadir=/mysqldata/mysql



[root@sjbf mysql]# cat mysql.err
2023-05-05T20:26:01.800998Z 0 [System] [MY-013169] [Server] /mysqlsoft/mysql-8.0.33-linux-glibc2.12-x86_64/bin/mysqld (mysqld 8.0.33) initializing of server in progress as process 27188
2023-05-05T20:26:01.805553Z 0 [Warning] [MY-013242] [Server] --character-set-server: 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
2023-05-05T20:26:01.870227Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2023-05-05T20:26:09.160682Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2023-05-05T20:26:25.588664Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: #uVfq!szm7y/

其中[Note] A temporary password is generated for root@localhost:#uVfq!szm7y/ 的root@localhost: 后面跟的是mysql数据库登录的临时密码,各人安装生成的临时密码不一样。可以看到到日志文件没有报错,而且有了临时密码,表示初始化成功。

9. 如果想服务能够部署自动支持安全连接,使用mysql_ssl_rsa_setup工具来创建缺省SSL与RSA文件

[root@sjbf bin]# ./mysql_ssl_rsa_setup --datadir=/mysqldata/mysql

10.启动mysql服务

[root@sjbf /]# sh /mysqlsoft/mysql/support-files/mysql.server start
/mysqlsoft/mysql/support-files/mysql.server: line 239: my_print_defaults: command not found
/mysqlsoft/mysql/support-files/mysql.server: line 259: cd: /usr/local/mysql: No such file or directory
Starting MySQLCouldn't find MySQL server (/usr/local/mysql/bin/mysqld_safe)[FAILED]

启动mysql服务命令会报错,因为没有修改mysql的配置文件修改Mysql配置文件,修改前为以下内容

if test -z "$basedir"
then
  basedir=/usr/local/mysql
  bindir=/usr/local/mysql/bin
  if test -z "$datadir"
  then
    datadir=/usr/local/mysql/data
  fi
  sbindir=/usr/local/mysql/bin
  libexecdir=/usr/local/mysql/bin
else
  bindir="$basedir/bin"
  if test -z "$datadir"
  then
    datadir="$basedir/data"
  fi
  sbindir="$basedir/sbin"
  libexecdir="$basedir/libexec"
fi

修改后的内容如下

if test -z "$basedir"
then
  basedir=/mysqlsoft/mysql
  bindir=/mysqlsoft/mysql/bin
  if test -z "$datadir"
  then
    datadir=/mysqldata/mysql
  fi
  sbindir=/mysqlsoft/mysql/bin
  libexecdir=/mysqlsoft/mysql/bin
else
  bindir="$basedir/bin"
  if test -z "$datadir"
  then
    datadir="$basedir/data"
  fi
  sbindir="$basedir/sbin"
  libexecdir="$basedir/libexec"
fi

[root@sjbf /]# cp /mysqlsoft/mysql/support-files/mysql.server  /etc/init.d/mysqld
[root@sjbf /]# chmod 755 /etc/init.d/mysqld

启动MySQL

[root@sjbf /]# service mysqld start
Starting MySQL......[  OK  ]

11.配置环境变量

[root@sjbf /]#
# /etc/profile

# System wide environment and startup programs, for login setup
# Functions and aliases go in /etc/bashrc

# It's NOT a good idea to change this file unless you know what you
# are doing. It's much better to create a custom.sh shell script in
# /etc/profile.d/ to make custom changes to your environment, as this
# will prevent the need for merging in future updates.

export MYSQL_HOME=/mysqlsoft/mysql/
export PATH=$PATH:$MYSQL_HOME/bin

12.登录Mysql
初始化成功后,查看初始化密码

[root@sjbf ~]# cat /mysqldata/mysql/mysql.err | grep password
2023-05-05T20:26:25.588664Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: #uVfq!szm7y/

并输入刚刚复制的密码,但是 却提示不能通过mysql.sock文件实现连接

[root@sjbf bin]# ./mysqladmin -u root -p password
Enter password:
mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)'
Check that mysqld is running and that the socket: '/tmp/mysql.sock' exists!

这里就奇怪了,因为在my.cnf文件中设置的socket文件路径为/mysqlsoft/mysql/mysql.sock,但mysql所使用的文件不是启动服务所生成的。

使用-S选项来指定生成的mysql.sock文件进行登录是可以成功登录的

[root@sjbf ~]# mysql -S /mysqlsoft/mysql/mysql.sock -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.33

Copyright (c) 2000, 2023, Oracle and/or its affiliates.

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

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

mysql>

为了方便登录不每次指定-S参数可以在my.cnf文件中指定socket参数

[client]
socket = /mysqlsoft/mysql/mysql.sock

[root@sjbf tmp]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.0.33

Copyright (c) 2000, 2023, Oracle and/or its affiliates.

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

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

mysql>

13.重置root用户密码

[root@sjbf tmp]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.0.33

Copyright (c) 2000, 2023, Oracle and/or its affiliates.

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

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

mysql> set password=password("123456");
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'password("123456")' at line 1

用5.7的方法修改密码会报错

mysql> ALTER user 'root'@'localhost' IDENTIFIED BY '123456';
Query OK, 0 rows affected (0.14 sec)

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.03 sec)

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

Database changed

mysql> select host,user from user;
+-----------+------------------+
| host      | user             |
+-----------+------------------+
| localhost | mysql.infoschema |
| localhost | mysql.session    |
| localhost | mysql.sys        |
| localhost | root             |
+-----------+------------------+
4 rows in set (0.00 sec)

14.设置允许远程登录mysql
如果要远程访问数据库,只需要把拥有全部权限的root账号对应的记录的Host字段改为%就可以了

mysql> update user set host='%' where user='root';
Query OK, 1 row affected (0.13 sec)
Rows matched: 1  Changed: 1  Warnings: 0

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

mysql> ALTER USER 'root'@'%' IDENTIFIED BY '123456' PASSWORD EXPIRE NEVER;
Query OK, 0 rows affected (0.09 sec)

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

mysql> grant all privileges on *.* to 'root'@'%';
Query OK, 0 rows affected (0.14 sec)

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

测试远程登录

[root@sjbf tmp]# mysql -h 10.13.10.99 -P 3306 -uroot -p123456
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 16
Server version: 8.0.33 MySQL Community Server - GPL

Copyright (c) 2000, 2023, Oracle and/or its affiliates.

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

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



mysql> select host,user,plugin from user;
+-----------+------------------+-----------------------+
| host      | user             | plugin                |
+-----------+------------------+-----------------------+
| %         | root             | caching_sha2_password |
| localhost | mysql.infoschema | caching_sha2_password |
| localhost | mysql.session    | caching_sha2_password |
| localhost | mysql.sys        | caching_sha2_password |
+-----------+------------------+-----------------------+
4 rows in set (0.00 sec)

[root@sjbf tmp]# mysql -h 10.13.10.99 -P 3306 -uroot -p123456 --ssl-cert=/mysqldata/mysql/client-cert.pem --ssl-key=/mysqldata/mysql/client-key.pem
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 17
Server version: 8.0.33 MySQL Community Server - GPL

Copyright (c) 2000, 2023, Oracle and/or its affiliates.

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

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

mysql>
]]>
http://www.jydba.net/index.php/archives/3489/feed 0
在Oracle Linux 6.7操作系统上初始化MySQL 8.0.33时报’unknown variable ‘defaults-file’错误 http://www.jydba.net/index.php/archives/3487 http://www.jydba.net/index.php/archives/3487#respond Mon, 08 May 2023 08:22:39 +0000 http://www.jydba.net/?p=3487 在Oracle Linux 6.7操作系统上初始化MySQL 8.0.33时报’unknown variable ‘defaults-file’错误

[root@sjbf bin]# ./mysqld --user=mysql  --defaults-file=/mysqlsoft/mysql/my.cnf --basedir=/mysqlsoft/mysql --datadir=/mysqldata/mysql --initialize
2023-05-05T20:21:18.355164Z 0 [System] [MY-013169] [Server] /mysqlsoft/mysql-8.0.33-linux-glibc2.12-x86_64/bin/mysqld (mysqld 8.0.33) initializing of server in progress as process 26730
2023-05-05T20:21:18.412269Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2023-05-05T20:21:25.831475Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2023-05-05T20:21:42.025674Z 0 [ERROR] [MY-000067] [Server] =/mysqlsoft/mysql/my.cnf'.
2023-05-05T20:21:42.025812Z 0 [ERROR] [MY-013236] [Server] The designated data directory /mysqldata/mysql/ is unusable. You can remove all files that the server added to it.
2023-05-05T20:21:42.025914Z 0 [ERROR] [MY-010119] [Server] Aborting
2023-05-05T20:21:53.091946Z 0 [System] [MY-010910] [Server] /mysqlsoft/mysql-8.0.33-linux-glibc2.12-x86_64/bin/mysqld: Shutdown complete (mysqld 8.0.33)  MySQL Community Server - GPL.

把defaults-file参数调整为mysqld命令的第一个参数执行成功

[root@sjbf bin]# ./mysqld --defaults-file=/mysqlsoft/mysql/my.cnf --initialize --user=mysql --basedir=/mysqlsoft/mysql --datadir=/mysqldata/mysql

[root@sjbf mysql]# tail -f mysql.err
2023-05-05T20:26:01.800998Z 0 [System] [MY-013169] [Server] /mysqlsoft/mysql-8.0.33-linux-glibc2.12-x86_64/bin/mysqld (mysqld 8.0.33) initializing of server in progress as process 27188
2023-05-05T20:26:01.805553Z 0 [Warning] [MY-013242] [Server] --character-set-server: 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
2023-05-05T20:26:01.870227Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2023-05-05T20:26:09.160682Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2023-05-05T20:26:25.588664Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: #uVfq!szm7y/
]]>
http://www.jydba.net/index.php/archives/3487/feed 0
MySQL 5.7 将表从MyISAM存储引擎转换为InnoDB存储引擎 http://www.jydba.net/index.php/archives/3477 http://www.jydba.net/index.php/archives/3477#respond Fri, 28 Apr 2023 00:12:21 +0000 http://www.jydba.net/?p=3477 将表从MyISAM存储引擎转换为InnoDB存储引擎
如果你想将MyISAM表转换为InnoDB,以获得更好的可靠性和可伸缩性,那么在转换之前,请查看以下指南和技巧。
.调整MyISAM和InnoDB的内存使用
.处理过长或过短的事务
.处理死锁
.规划存储布局
.转换现有表
.克隆表的结构
.传送现有数据
.储存需求
.为每个表定义一个主键
.应用程序性能考虑
.了解与InnoDB表关联的文件

调整MyISAM和InnoDB的内存使用
当用户将MyISAM表转换为InnoDB表时,降低key_buffer_size配置选项的值,以释放缓存结果不再需要的内存。增加innodb_buffer_pool_size配置选项的值,该选项的作用类似于为InnoDB表分配缓存内存。InnoDB缓冲池缓存了表数据和索引数据,加快了查询的查找速度,并将查询结果保存在内存中以供重用。

在繁忙的服务器上,在关闭查询缓存的情况下运行基准测试。InnoDB缓冲池提供了类似的好处,所以查询缓存可能不必要地占用内存。

处理过长或过短的事务
因为MyISAM表不支持事务,所以您可能没有太注意自动提交配置选项以及COMMIT和ROLLBACK语句。这些关键字对于允许多个会话并发地读写InnoDB表非常重要,在写工作负载繁重的情况下提供大量的可伸缩性优势。

当事务处于打开状态时,系统会保留事务开始时看到的数据快照,如果系统插入、更新和删除数百万行,而事务继续运行,这可能会导致大量开销。因此,要注意避免事务运行时间过长:

.如果您使用mysql会话进行交互实验,当完成后请始终COMMIT(完成更改)或ROLLBACK(撤销更改)。关闭交互式会话,而不是让它们长时间开放,以避免意外地使事务长时间开放。

.确保应用程序中的任何错误处理程序也ROLLBACK未完成的更改或COMMIT已完成的更改。

.ROLLBACK是一个相对昂贵的操作,因为INSERT, UPDATE和DELETE操作在COMMIT之前被写入InnoDB表,并且期望大多数更改被成功提交并且很少回滚。在对大量数据进行实验时,避免对大量行进行更改,然后回滚这些更改。

.当使用INSERT语句顺序加载大量数据时,请定期提交结果,以避免事务持续数小时。在典型的数据仓库加载操作中,如果出现问题,您将截断表(使用truncate table)并从头开始,而不是执行ROLLBACK。

前面的技巧可以节省内存和磁盘空间,避免在太长的事务中浪费。当事务比应有的时间短时,问题是I/O过多。对于每次COMMIT, MySQL确保每个更改都被安全地记录到磁盘上,这涉及到一些I/O。

.对于大多数InnoDB表的操作,你应该设置autocommit=0。从效率的角度来看,当发出大量连续的INSERT、UPDATE或DELETE语句时,这避免了不必要的I/O。从安全的角度来看,如果你在mysql命令行或应用程序的异常处理中犯了错误,这允许你发出回滚语句来恢复丢失或混淆的数据。

.autocommit=1适合InnoDB表的情况是,当运行一系列查询以生成报告或分析统计数据时。在这种情况下,不存在与COMMIT或ROLLBACK相关的I/O惩罚, InnoDB可以自动优化只读工作负载。

.如果您进行了一系列相关的更改,请在最后使用COMMIT命令一次完成所有更改。例如,如果将相关的信息片段插入到几个表中,则在进行所有更改后执行一次COMMIT。或者,如果您运行了许多连续的INSERT语句,请在加载完所有数据后执行单个COMMIT;如果您要执行数百万条INSERT语句,也许可以通过每10,000或100,000条记录发出COMMIT来拆分巨大的事务,这样事务就不会变得太大。

.请记住,即使是SELECT语句也会打开一个事务,因此在交互式mysql会话中运行一些报告或调试查询后,发出COMMIT或关闭mysql会话。

处理死锁
你可能会在MySQL错误日志中看到提到“死锁”的警告消息,或者在SHOW ENGINE INNODB STATUS的输出中看到。尽管死锁的名字听起来很可怕,但对于InnoDB表来说,死锁并不是一个严重的问题,通常不需要任何纠正措施。当两个事务开始修改多个表,以不同的顺序访问表时,它们可能会达到一种状态,即每个事务都在等待另一个事务,而不能继续进行。当启用死锁检测(默认)时,MySQL立即检测到这种情况,并取消(回滚)“较小的”事务,允许另一个事务继续进行。如果使用innodb_deadlock_detect配置选项禁用了死锁检测,InnoDB依赖innodb_lock_wait_timeout设置在死锁发生的情况下回滚事务。

无论哪种方式,应用程序都需要错误处理逻辑来重新启动由于死锁而被强制取消的事务。当您像以前一样重新发出相同的SQL语句时,最初的计时问题将不再适用。要么是其他事务已经完成,您的事务可以继续,要么是其他事务仍在进行中,您的事务等待它完成。

如果死锁警告不断发生,则可以检查应用程序代码以重新排序
以一致的方式进行SQL操作,或者缩短事务。你可以使用innodb_print_all_deadlocks选项来测试,在MySQL错误日志中查看所有死锁警告,而不仅仅是SHOW ENGINE INNODB STATUS输出中的最后一个警告。

规划存储布局
为了从InnoDB表中获得最佳性能,您可以调整一些与存储布局相关的参数。

当您转换大型、频繁访问和保存重要数据的MyISAM表时,请调查并考虑innodb_file_per_table、innodb_file_format和innodb_page_size配置选项,以及CREATE TABLE语句的ROW_FORMAT和KEY_BLOCK_SIZE子句。

在最初的实验中,最重要的设置是innodb_file_per_table。当启用这个设置时,MySQL 5.6.6默认会在file-per–table表空间中隐式创建新的InnoDB表。与InnoDB系统表空间不同的是,在表被截断或删除时,操作系统可以通过file-per-table表空间回收磁盘空间。file-per-table表空间还支持Barracuda文件格式和相关特性,如表压缩、变长列的高效页外存储和大索引前缀。

您也可以将InnoDB表存储在共享的通用表空间中。通用表空间支持Barracuda文件格式,可以包含多个表。

转换现有表
使用ALTER table命令将一个非InnoDB表转换为InnoDB表。
ALTER TABLE table_name ENGINE=InnoDB;

不要将MySQL数据库中的MySQL系统表从MyISAM转换为InnoDB类型。这是一个不受支持的操作。类型。

克隆表的结构
你可能会为一个MyISAM表克隆一个InnoDB表,而不是使用ALTER table执行转换,以便在切换之前并行测试新旧表。

用相同的列和索引定义创建一个空的InnoDB表。使用SHOW CREATE TABLE table_name\G查看完整的CREATE TABLE语句。将ENGINE子句更改为引擎= INNODB。

转换现有表
为了将大量数据转移到上一节创建的空InnoDB表中,使用insert into innodb_table SELECT * FROM myisam_table ORDER BY primary_key_columns来插入记录。

也可以在插入数据后为InnoDB表创建索引。以前,创建新的二级索引对于InnoDB来说是一个很慢的操作,但是现在您可以在加载数据之后创建索引,而创建索引的开销相对较小。

如果你在副键上有UNIQUE约束,你可以通过在导入操作中暂时关闭唯一性检查来加速表的导入:

SET unique_checks=0;
... import operation ...
SET unique_checks=1;

对于大型表,这节省了磁盘I/O,因为InnoDB可以使用它的更改缓冲区来批量写入二级索引记录。确保数据不包含重复键。Unique_checks允许但不要求存储引擎忽略重复的键。

为了更好地控制插入过程,您可以将大表分段插入:

INSERT INTO newtable SELECT * FROM oldtable WHERE yourkey > something AND yourkey < = somethingelse;

插入所有记录后,可以重命名表。

在转换大表的过程中,增加InnoDB缓冲池的大小以减少磁盘I/O,最大不超过物理内存的80%。你也可以增加InnoDB日志文件的大小。

储存需求
如果您打算在转换过程中为InnoDB表中的数据创建多个临时副本,建议您以文件/表的方式创建表,以便在删除表时回收磁盘空间。当innodb_file_per_table配置选项被启用(默认)时,新创建的InnoDB表将隐式地创建在file-per-table表空间中。

无论您是直接转换MyISAM表还是创建一个克隆的InnoDB表,都要确保在转换过程中有足够的磁盘空间来容纳新旧表。InnoDB表比MyISAM表需要更多的磁盘空间。如果ALTER TABLE操作耗尽了空间,它将启动回滚,如果是磁盘绑定,则回滚可能需要数小时。对于插入,InnoDB使用insert buffer将辅助索引记录批量合并到索引中。这节省了大量的磁盘I/O。对于回滚,没有使用这种机制,回滚可能比插入时间长30倍。

在回滚失控的情况下,如果您的数据库中没有有价值的数据,那么建议终止数据库进程,而不是等待数百万个磁盘I/O操作完成。

为每个表定义一个主键
主键子句是影响MySQL查询性能以及表和索引空间使用的一个关键因素。主键唯一地标识表中的一行。表中的每一行都必须有一个主键值,并且任何两行都不能有相同的主键值。

这些是主键的指导原则,后面是更详细的解释。
.为每个表声明一个主键。通常,在WHERE子句中查询单行时,它是最重要的一列。

.在原始的CREATE TABLE语句中声明PRIMARY KEY子句,而不是稍后通过ALTER TABLE语句添加它。

.仔细选择列及其数据类型。首选数字列,而不是字符或字符串列。

.如果没有其他稳定的、唯一的、非空的数字列可供使用,请考虑使用自动递增列。

.如果怀疑主键列的值是否会改变,自动递增列也是一个不错的选择。更改主键列的值是一项代价高昂的操作,可能涉及重新安排表内和每个辅助索引内的数据。

考虑为任何还没有主键的表添加一个主键。根据表的最大投影大小,使用最小的实际数值类型。这可以使每一行稍微紧凑一些,对于大型表可以节省大量空间。如果表有辅助索引,那么节省的空间会成倍增加,因为主键值在每个辅助索引项中都是重复的。除了减少磁盘上的数据大小,小主键还可以让缓冲池容纳更多的数据,加快各种操作并提高并发性。

如果表中某些较长的列已经有了主键,比如VARCHAR,可以考虑添加一个新的unsigned AUTO_INCREMENT列,并切换主键到该列,即使该列在查询中没有被引用。这种设计改变可以在二级索引中节省大量空间。用户可以将之前的主键列指定为UNIQUE NOT NULL,以实施与主键子句相同的约束,即防止所有这些列中出现重复值或NULL值。

如果您将相关信息分散到多个表中,通常每个表使用相同的列作为其主键。例如,人事数据库可能有几个表,每个表都有一个员工编号的主键。销售数据库中可能有一些表的主键是客户编号,还有一些表的主键是订单编号。因为使用主键的查找非常快,所以可以为这样的表构造高效的连接查询。

应用程序性能考虑
InnoDB的可靠性和可扩展性比等价的MyISAM表需要更多的磁盘存储空间。您可以稍微改变列和索引的定义,以便更好地利用空间,减少处理结果集时的I/O和内存消耗,以及更好地利用索引查找的查询优化计划。

如果你设置了一个数字ID作为主键,使用这个值与其他表中的相关值进行交叉引用,尤其是在连接查询中。例如,与其接受一个国家名作为输入并进行查询以搜索相同的名称,不如进行一次查找以确定国家ID,然后进行其他查询(或单个连接查询)以跨几个表查找相关信息。与其将顾客或商品编号存储为数字字符串(可能会占用几个字节),不如将其转换为数字ID以便存储和查询。一个4字节的unsigned INT列可以索引超过40亿个元素。

]]>
http://www.jydba.net/index.php/archives/3477/feed 0
MySQL 5.7移动或复制InnoDB表 http://www.jydba.net/index.php/archives/3475 http://www.jydba.net/index.php/archives/3475#respond Thu, 27 Apr 2023 00:20:18 +0000 http://www.jydba.net/?p=3475 移动或复制InnoDB表
将部分或全部InnoDB表移动或复制到不同的服务器或实例的技术。例如,您可以将整个MySQL实例移动到一个更大、更快的服务器上;你可以将整个MySQL实例克隆到一个新的复制从服务器上;您可以将单个表复制到另一个实例以开发和测试应用程序,或者复制到数据仓库服务器以生成报告。

在Windows上,InnoDB总是在内部以小写形式存储数据库和表名。要将二进制格式的数据库从Unix移动到Windows或从Windows移动到Unix,请使用小写名称创建所有数据库和表。实现这一点的一个方便的方法是在创建任何数据库或表之前,在my.cnf或my.ini文件的[mysqld]部分添加以下一行:

[mysqld]
lower_case_table_names=1
mysql> show variables like 'lower_case_table%';
+------------------------+-------+
| Variable_name          | Value |
+------------------------+-------+
| lower_case_table_names | 1     |
+------------------------+-------+
1 row in set (0.01 sec)

传输表空间
传输表空间特性使用FLUSH TABLES…FOR EXPORT准备好从一个服务器实例复制到另一个服务器实例的InnoDB表。为了使用这个特性,InnoDB表创建时必须将innodb_file_per_table设置为ON,这样每个InnoDB表都有自己的表空间。

MySQL企业备份
MySQL企业备份产品允许您备份正在运行的MySQL数据库,最小化操作中断,同时生成数据库的一致快照。当MySQL Enterprise Backup正在复制表时,可以继续读写。此外,MySQL Enterprise Backup可以创建压缩备份文件,并备份表的子集。结合MySQL二进制日志,您可以执行时间点恢复。MySQL企业备份是MySQL企业订阅的一部分。

拷贝数据文件(冷备份方式)
你可以通过复制“冷备份”中列出的所有相关文件来移动InnoDB数据库。

InnoDB数据和日志文件在所有平台上都是二进制兼容的,具有相同的浮点数格式。如果浮点格式不同,但在表中没有使用FLOAT或DOUBLE数据类型,则过程是相同的:只需复制相关文件。

当移动或复制file-per-table的.ibd文件时,源系统和目标系统上的数据库目录名称必须相同。存储在InnoDB共享表空间中的表定义包含了数据库名称。存储在表空间文件中的事务id和日志序列号也因数据库而异。

要将.ibd文件和相关的表从一个数据库移动到另一个数据库,使用RENAME table语句:

RENAME TABLE db1.tbl_name TO db2.tbl_name;

如果你有一个.ibd文件的“干净”备份,你可以将它恢复到它最初的MySQL安装目录,如下所示:
1.在复制.ibd文件后,不能删除或截断表,因为这样做会更改存储在表空间中的表ID。

2.执行ALTER TABLE语句删除当前的.ibd文件:

ALTER TABLE tbl_name DISCARD TABLESPACE;

3.将备份的.ibd文件复制到适当的数据库目录。

4.执行ALTER TABLE语句,告诉InnoDB对表使用新的.ibd文件:

ALTER TABLE tbl_name IMPORT TABLESPACE;

ALTER TABLE…IMPORT TABLESPACE特性不会对导入的数据强制执行外键约束。

在这种情况下,“干净的”.ibd文件备份是指满足以下要求的备份:
.在.ibd文件中没有未提交修改的事务。
.在.ibd文件中没有未合并的插入缓冲区项。
.Purge已经从.ibd文件中删除了所有已删除标记的索引记录。
.Mysqld已将.ibd文件的所有修改页从缓冲池刷新到该文件。

您可以使用以下方法对.ibd文件进行干净备份:
1.停止mysqld服务器上的所有活动并提交所有事务。
2.等待,直到SHOW ENGINE INNODB STATUS显示数据库中没有活动事务,并且INNODB的主线程状态为Waiting for server activity。然后,您可以复制.ibd文件。

另一种复制。ibd文件的方法是使用MySQL企业备份产品:
1.使用MySQL Enterprise Backup备份InnoDB安装。
2.在备份机上启动第二个mysqld服务器,并让它清理备份中的.ibd文件。

导出和导入(mysqldump)
您可以使用mysqldump将表转储到一台机器上,然后在另一台机器上导入转储文件。使用此方法,格式是否不同或表是否包含浮点数据都无关紧要。

提高此方法性能的一种方法是在导入数据时关闭自动提交模式,假设表空间有足够的空间容纳导入事务生成的大回滚段。只有在导入整个表或表的一个段后才执行提交操作

]]>
http://www.jydba.net/index.php/archives/3475/feed 0
MySQL 5.7 InnoDB Tablespace Encryption http://www.jydba.net/index.php/archives/3468 http://www.jydba.net/index.php/archives/3468#respond Fri, 10 Mar 2023 08:54:50 +0000 http://www.jydba.net/?p=3468 InnoDB Tablespace Encryption

InnoDB支持对存储file-per-table表空间中的InnoDB表中的数据进行加密。该特性为物理表空间数据文件提供静态加密。

InnoDB表空间加密使用两层加密密钥架构,由主加密密钥和表空间密钥组成。当一个InnoDB表被加密时,表空间密钥被加密并存储在表空间头中。当应用程序或经过认证的用户想要访问加密的表空间数据时,InnoDB使用一个主加密密钥来解密表空间密钥。表空间密钥的解密版本永远不会改变,但主加密密钥可以根据需要改变。此操作称为主键旋转。

InnoDB表空间加密特性依赖于keyring插件进行主加密密钥管理。

所有MySQL版本都提供了keyring_file插件,该插件将主加密密钥数据存储在keyring_file_data配置选项指定的位置的keyring文件中。

非企业版MySQL中的InnoDB表空间加密特性使用keyring_file插件进行加密密钥管理,这并不是一个符合法规的解决方案。安全标准,如PCI,FIPS和其他要求使用密钥管理系统来保护、管理和保护密钥库或硬件安全模块(hsm)中的加密密钥。

MySQL企业版提供了keyring_okv插件,其中包括一个KMIP客户端(KMIP 1.1),它与Oracle密钥库(OKV)一起工作,提供加密密钥管理。当InnoDB表空间加密使用OKV进行加密密钥管理时,该特性被称为“MySQL企业”透明数据加密(TDE)。

一个安全、健壮的加密密钥管理解决方案(如OKV)对于安全性和符合各种安全标准至关重要。在其他好处中,使用密钥库可确保密钥安全存储,永远不会丢失,并且只有授权的密钥管理员知道。密钥库还维护加密密钥历史记录

InnoDB表空间加密支持AES (Advanced encryption Standard)块加密算法。它采用ECB (Electronic Codebook)块加密方式对表空间密钥进行加密CBC (Cipher Block chainaining)块加密方式,用于数据加密

InnoDB表空间加密前提条件

必须安装和配置keyring插件(keyring_file插件或keyring_okv插件)。Keyring插件安装在启动时使用–early-plugin-load选项执行。提前加载可以确保插件在InnoDB存储引擎初始化之前可用。

一次只能启用一个keyring插件。不支持启用多个密匙环插件。

一旦在MySQL实例中创建了加密表,在创建加密表时加载的keyring插件必须在InnoDB初始化之前使用–early-plugin-load选项继续加载。如果不这样做,会导致启动和恢复InnoDB时出现错误。

启用加密模块

mysql> INSTALL PLUGIN keyring_file soname 'keyring_file.so';
Query OK, 0 rows affected (0.09 sec)

创建密钥文件目录

[mysql@localhost ~]$ mkdir -p /mysqldata/mysql/mysql-keyring/
[mysql@localhost ~]$ chown -R mysql:mysql /mysqldata/mysql/mysql-keyring/
[mysql@localhost ~]$ chmod -R 775 /mysqldata/mysql/mysql-keyring/

设置加密key存放路径

mysql> set global keyring_file_data='/mysqldata/mysql/mysql-keyring/keyring';
Query OK, 0 rows affected (0.00 sec)

永久启用设置
上诉两个步骤都是临时的,重启服务都会失效,我们把配置写到配置文件里,确保重启服务后也能生效

[mysqld]
early-plugin-load=keyring_file.so
keyring_file_data=/mysqldata/mysql/mysql-keyring/keyring

查看key的存放路径

mysql> show global variables like '%keyring_file_data%';
+-------------------+----------------------------------------+
| Variable_name     | Value                                  |
+-------------------+----------------------------------------+
| keyring_file_data | /mysqldata/mysql/mysql-keyring/keyring |
+-------------------+----------------------------------------+
1 row in set (0.02 sec)

要验证keyring插件是否处于活动状态,请使用SHOW PLUGINS语句或查询INFORMATION_SCHEMA.PLUGINS表。例如:

mysql> show plugins;
+----------------------------+----------+--------------------+-----------------+---------+
| Name                       | Status   | Type               | Library         | License |
+----------------------------+----------+--------------------+-----------------+---------+
| keyring_file               | ACTIVE   | KEYRING            | keyring_file.so | GPL     |
| binlog                     | ACTIVE   | STORAGE ENGINE     | NULL            | GPL     |
| mysql_native_password      | ACTIVE   | AUTHENTICATION     | NULL            | GPL     |
| sha256_password            | ACTIVE   | AUTHENTICATION     | NULL            | GPL     |
| CSV                        | ACTIVE   | STORAGE ENGINE     | NULL            | GPL     |
| MEMORY                     | ACTIVE   | STORAGE ENGINE     | NULL            | GPL     |
| InnoDB                     | ACTIVE   | STORAGE ENGINE     | NULL            | GPL     |
| INNODB_TRX                 | ACTIVE   | INFORMATION SCHEMA | NULL            | GPL     |
| INNODB_LOCKS               | ACTIVE   | INFORMATION SCHEMA | NULL            | GPL     |
| INNODB_LOCK_WAITS          | ACTIVE   | INFORMATION SCHEMA | NULL            | GPL     |
| INNODB_CMP                 | ACTIVE   | INFORMATION SCHEMA | NULL            | GPL     |
| INNODB_CMP_RESET           | ACTIVE   | INFORMATION SCHEMA | NULL            | GPL     |
| INNODB_CMPMEM              | ACTIVE   | INFORMATION SCHEMA | NULL            | GPL     |
| INNODB_CMPMEM_RESET        | ACTIVE   | INFORMATION SCHEMA | NULL            | GPL     |
| INNODB_CMP_PER_INDEX       | ACTIVE   | INFORMATION SCHEMA | NULL            | GPL     |
| INNODB_CMP_PER_INDEX_RESET | ACTIVE   | INFORMATION SCHEMA | NULL            | GPL     |
| INNODB_BUFFER_PAGE         | ACTIVE   | INFORMATION SCHEMA | NULL            | GPL     |
| INNODB_BUFFER_PAGE_LRU     | ACTIVE   | INFORMATION SCHEMA | NULL            | GPL     |
| INNODB_BUFFER_POOL_STATS   | ACTIVE   | INFORMATION SCHEMA | NULL            | GPL     |
| INNODB_TEMP_TABLE_INFO     | ACTIVE   | INFORMATION SCHEMA | NULL            | GPL     |
| INNODB_METRICS             | ACTIVE   | INFORMATION SCHEMA | NULL            | GPL     |
| INNODB_FT_DEFAULT_STOPWORD | ACTIVE   | INFORMATION SCHEMA | NULL            | GPL     |
| INNODB_FT_DELETED          | ACTIVE   | INFORMATION SCHEMA | NULL            | GPL     |
| INNODB_FT_BEING_DELETED    | ACTIVE   | INFORMATION SCHEMA | NULL            | GPL     |
| INNODB_FT_CONFIG           | ACTIVE   | INFORMATION SCHEMA | NULL            | GPL     |
| INNODB_FT_INDEX_CACHE      | ACTIVE   | INFORMATION SCHEMA | NULL            | GPL     |
| INNODB_FT_INDEX_TABLE      | ACTIVE   | INFORMATION SCHEMA | NULL            | GPL     |
| INNODB_SYS_TABLES          | ACTIVE   | INFORMATION SCHEMA | NULL            | GPL     |
| INNODB_SYS_TABLESTATS      | ACTIVE   | INFORMATION SCHEMA | NULL            | GPL     |
| INNODB_SYS_INDEXES         | ACTIVE   | INFORMATION SCHEMA | NULL            | GPL     |
| INNODB_SYS_COLUMNS         | ACTIVE   | INFORMATION SCHEMA | NULL            | GPL     |
| INNODB_SYS_FIELDS          | ACTIVE   | INFORMATION SCHEMA | NULL            | GPL     |
| INNODB_SYS_FOREIGN         | ACTIVE   | INFORMATION SCHEMA | NULL            | GPL     |
| INNODB_SYS_FOREIGN_COLS    | ACTIVE   | INFORMATION SCHEMA | NULL            | GPL     |
| INNODB_SYS_TABLESPACES     | ACTIVE   | INFORMATION SCHEMA | NULL            | GPL     |
| INNODB_SYS_DATAFILES       | ACTIVE   | INFORMATION SCHEMA | NULL            | GPL     |
| INNODB_SYS_VIRTUAL         | ACTIVE   | INFORMATION SCHEMA | NULL            | GPL     |
| MyISAM                     | ACTIVE   | STORAGE ENGINE     | NULL            | GPL     |
| MRG_MYISAM                 | ACTIVE   | STORAGE ENGINE     | NULL            | GPL     |
| PERFORMANCE_SCHEMA         | ACTIVE   | STORAGE ENGINE     | NULL            | GPL     |
| ARCHIVE                    | ACTIVE   | STORAGE ENGINE     | NULL            | GPL     |
| BLACKHOLE                  | ACTIVE   | STORAGE ENGINE     | NULL            | GPL     |
| FEDERATED                  | DISABLED | STORAGE ENGINE     | NULL            | GPL     |
| partition                  | ACTIVE   | STORAGE ENGINE     | NULL            | GPL     |
| ngram                      | ACTIVE   | FTPARSER           | NULL            | GPL     |
+----------------------------+----------+--------------------+-----------------+---------+

mysql> SELECT PLUGIN_NAME, PLUGIN_STATUS
    -> FROM INFORMATION_SCHEMA.PLUGINS
    -> WHERE PLUGIN_NAME LIKE 'keyring%';
+--------------+---------------+
| PLUGIN_NAME  | PLUGIN_STATUS |
+--------------+---------------+
| keyring_file | ACTIVE        |
+--------------+---------------+
1 row in set (0.00 sec)

必须启用innodb_file_per_table选项(默认值)。InnoDB表空间加密只支持每表一个文件的表空间。或者,您可以指定TABLESPACE=’innodb_file_per_table’选项,用于创建加密表或修改现有表以启用加密。

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

在对生产数据使用InnoDB表空间加密特性之前,请确保已采取措施防止丢失主加密密钥。如果主加密密钥丢失,则无法恢复加密表空间文件中存储的数据。如果您正在使用keyring_file插件,建议您在创建第一个加密表之后以及主密钥旋转前后立即创建keyring文件的备份。keyring文件位置由keyring_file_data配置选项定义。如果您正在使用keyring_okv插件,请确保您已经执行了必要的keyring_okv插件和Oracle密钥库(OKV)配置。

开启和关闭InnoDB表空间加密

要为一个新的InnoDB表启用加密,在create table语句中指定encryption选项。

mysql> CREATE TABLE t1 (c1 INT) ENCRYPTION='Y';
Query OK, 0 rows affected (0.01 sec)

要对现有的InnoDB表启用加密,请在alter table语句中指定encryption选项。

mysql> alter table abc encryption='y';
Query OK, 1 row affected (0.04 sec)
Records: 1  Duplicates: 0  Warnings: 0

mysql> show create table abc;
+-------+-------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table                                                                                                            |
+-------+-------------------------------------------------------------------------------------------------------------------------+
| abc   | CREATE TABLE `abc` (
  `a` int(11) NOT NULL,
  PRIMARY KEY (`a`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ENCRYPTION='y' |
+-------+-------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

使用alter table设置encryption =’N’来禁用InnoDB表的加密功能

mysql> alter table abc encryption='n';
Query OK, 1 row affected (0.02 sec)
Records: 1  Duplicates: 0  Warnings: 0

mysql> show create table abc;
+-------+-------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table                                                                                                            |
+-------+-------------------------------------------------------------------------------------------------------------------------+
| abc   | CREATE TABLE `abc` (
  `a` int(11) NOT NULL,
  PRIMARY KEY (`a`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ENCRYPTION='n' |
+-------+-------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

InnoDB表空间加密和主密钥轮换
主加密密钥应该定期轮换,只要您怀疑密钥可能已被泄露。

主密钥轮换是一个原子的实例级操作。每次轮换主加密密钥时,MySQL实例中的所有表空间密钥都将重新加密并保存回各自的表空间头中。作为原子操作,一旦启动轮换操作,所有表空间密钥都必须重新加密成功。如果主密钥轮换因服务器故障而中断,InnoDB将在服务器重启时前滚该操作。

轮换主加密密钥只会更改主加密密钥并重新加密表空间密钥。它不解密或重新加密相关的表空间数据

轮换主加密密钥,执行以下命令:

[root@localhost ~]# cd /mysqldata/mysql/mysql-keyring/
[root@localhost mysql-keyring]# ll
total 4
-rw-r-----. 1 mysql mysql 155 Mar  3 17:20 keyring

mysql> ALTER INSTANCE ROTATE INNODB MASTER KEY;
Query OK, 0 rows affected (0.00 sec)

[root@localhost mysql-keyring]# ll
total 4
-rw-r-----. 1 mysql mysql 283 Mar 10 15:58 keyring

alter instance rotate innodb master key支持并发DML。但是,它不能与create table … encryption或alter table … encryption操作一起并发执行,采用锁来防止这些语句并发执行时可能产生的冲突。如果一个冲突的语句正在运行,那么它必须在另一个语句运行之前完成。

InnoDB表空间加密与恢复
ALTER INSTANCE ROTATE INNODB MASTER KEY语句仅在主数据库和从数据库所运行的MySQL版本支持表空间加密特性的复制环境中被支持。

成功的ALTER INSTANCE ROTATE INNODB MASTER KEY语句被写入二进制日志,用于在slave上复制。

如果一个ALTER INSTANCE ROTATE INNODB MASTER KEY语句失败,它不会被记录到二进制日志中,也不会被复制到slave上。

如果keyring插件安装在主节点上而从节点没有安装,复制ALTER INSTANCE ROTATE INNODB MASTER KEY操作失败。

如果keyring_file插件同时安装在主服务器和从服务器上,但是从服务器上没有keyring文件,假设keyring文件数据没有缓存在内存中,复制的ALTER INSTANCE ROTATE INNODB MASTER KEY语句将在从服务器上创建keyring文件。如果可用的话,ALTER INSTANCE INNODB MASTER KEY使用缓存在内存中的keyring文件数据。

识别使用InnoDB表空间加密的表
当在CREATE TABLE或ALTER TABLE语句中指定了ENCRYPTION选项时,它将记录在INFORMATION_SCHEMA.TABLES的CREATE_OPTIONS字段中。可以查询该字段以识别MySQL实例中的加密表。

mysql> SELECT TABLE_SCHEMA, TABLE_NAME, CREATE_OPTIONS FROM INFORMATION_SCHEMA.TABLES
    -> WHERE CREATE_OPTIONS LIKE '%ENCRYPTION="Y"%';
+--------------+------------+-------------------------------------------------------+
| TABLE_SCHEMA | TABLE_NAME | CREATE_OPTIONS                                        |
+--------------+------------+-------------------------------------------------------+
| test         | t1         | ENCRYPTION="Y"                                        |
| test         | ts02       | row_format=COMPRESSED KEY_BLOCK_SIZE=4 ENCRYPTION="Y" |
| test         | ts03       | COMPRESSION="zlib" ENCRYPTION="Y"                     |
+--------------+------------+-------------------------------------------------------+
3 rows in set (0.42 sec)

InnoDB表空间加密使用说明
a.如果服务器在正常运行期间退出或停止,建议使用之前配置的相同加密设置重新启动服务器。

b.第一个主加密密钥是在对第一个新表或现有表进行加密时生成的。

c.主密钥轮换会重新加密表空间密钥,但不会改变表空间密钥本身。要更改表空间密钥,必须使用alter table tbl_name encryption禁用并重新启用表加密,这是一个ALGORITHM=COPY操作来重建表。

d.Keyring_file插件使用说明
如果keyring文件为空或缺失,第一次执行ALTER INSTANCE ROTATE INNODB MASTER KEY将创建一个主加密密钥。

卸载keyring_file插件不会删除现有的keyring文件。

建议不要将keyring文件与表空间数据文件放在同一个目录下。keyring文件的位置由keyring_file_data选项指定。

在运行时修改keyring_file_data选项或使用新的keyring_file_data设置重新启动服务器可能导致以前加密的表不可访问,从而导致数据丢失。

InnoDB表空间加密限制
.系统目前只支持AES (Advanced Encryption Standard)加密算法。InnoDB表空间加密使用ECB (Electronic Codebook)块加密方式对表空间密钥进行加密,使用CBC (Cipher block Chaining)块加密方式对数据进行加密。

.修改表的ENCRYPTION属性是一个ALGORITHM=COPY操作。不支持ALGORITHM=INPLACE。

.InnoDB表空间加密只支持存储在file-per-table表空间中的InnoDB表。存储在其他InnoDB表空间类型中的表不支持加密,包括普通表空间、系统表空间、undo log表空间和临时表空间。

.不能将加密表从file-per-table表空间移动或复制到不支持的InnoDB表空间类型。

.表空间加密只适用于表空间中的数据。重做日志、undo日志或二进制日志中的数据不加密。

.目前不支持直接从keyring_file插件迁移到keyring_okv插件,反之亦然。更改密匙环插件需要解密表,卸载当前的密匙环插件,安装和配置其他密匙环插件,并重新加密表。

]]>
http://www.jydba.net/index.php/archives/3468/feed 0
龙芯麒麟源码编译MySQL生成软件包进行安装 http://www.jydba.net/index.php/archives/3448 http://www.jydba.net/index.php/archives/3448#respond Fri, 13 Jan 2023 00:51:55 +0000 http://www.jydba.net/?p=3448 查看是否已安装mariadb,若是已安装,需要卸载

[root@localhost yum.repos.d]# rpm -qa|grep mariadb
mariadb-10.3.9-8.p01.ky10.mips64el
mariadb-common-10.3.9-8.p01.ky10.mips64el
mariadb-errmessage-10.3.9-8.p01.ky10.mips64el
mariadb-connector-c-3.0.6-6.ky10.mips64el
mariadb-server-10.3.9-8.p01.ky10.mips64el

要是有,卸载:# yum remove mariadb

[root@localhost yum.repos.d]# yum remove mariadb
Warning: failed loading '/etc/yum.repos.d/kylin.repo', skipping.
Dependencies resolved.
=================================================================================================================================================================================================
 Package                                         Architecture                              Version                                              Repository                                  Size
=================================================================================================================================================================================================
Removing:
 mariadb                                         mips64el                                  3:10.3.9-8.p01.ky10                                  @anaconda                                   38 M
Removing dependent packages:
 mariadb-server                                  mips64el                                  3:10.3.9-8.p01.ky10                                  @anaconda                                   92 M
Removing unused dependencies:
 perl-DBD-MySQL                                  mips64el                                  4.046-6.ky10                                         @anaconda                                  327 k

Transaction Summary
=================================================================================================================================================================================================
Remove  3 Packages

Freed space: 129 M
Is this ok [y/N]: y
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                                                                         1/1
  Running scriptlet: mariadb-3:10.3.9-8.p01.ky10.mips64el                                                                                                                                    1/1
  Erasing          : mariadb-3:10.3.9-8.p01.ky10.mips64el                                                                                                                                    1/3
  Running scriptlet: mariadb-server-3:10.3.9-8.p01.ky10.mips64el                                                                                                                             2/3
  Erasing          : mariadb-server-3:10.3.9-8.p01.ky10.mips64el                                                                                                                             2/3
  Running scriptlet: mariadb-server-3:10.3.9-8.p01.ky10.mips64el                                                                                                                             2/3
  Erasing          : perl-DBD-MySQL-4.046-6.ky10.mips64el                                                                                                                                    3/3
  Running scriptlet: perl-DBD-MySQL-4.046-6.ky10.mips64el                                                                                                                                    3/3
  Verifying        : mariadb-3:10.3.9-8.p01.ky10.mips64el                                                                                                                                    1/3
  Verifying        : mariadb-server-3:10.3.9-8.p01.ky10.mips64el                                                                                                                             2/3
  Verifying        : perl-DBD-MySQL-4.046-6.ky10.mips64el                                                                                                                                    3/3

Removed:
  mariadb-3:10.3.9-8.p01.ky10.mips64el                         mariadb-server-3:10.3.9-8.p01.ky10.mips64el                         perl-DBD-MySQL-4.046-6.ky10.mips64el

Complete!

[root@localhost soft]# mkdir /mnt/cdrom
[root@localhost soft]# mount -o loop -t iso9660 Kylin-Server-10-SP1-Release-Build18-20210809-mips64el.iso /mnt/cdrom
mount: /mnt/cdrom: WARNING: source write-protected, mounted read-only.
[root@localhost soft]# cd /mnt/cdrom
[root@localhost cdrom]# ls
boot  boot.catalog  EFI  images  LICENSE  manual  Packages  repodata  TRANS.TBL

[root@localhost yum.repos.d]# cat kylin.repo
[ks10-local-iso]
name = Kylin Linux Advanced Server 10 - local
baseurl = file:///mnt/cdrom/
gpgcheck = 1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-kylin
enabled = 1

(2)下载源码包并解压

# wget https://cdn.mysql.com/archives/mysql-5.7/mysql-5.7.29.tar.gz
# tar -zxvf mysql-5.7.29.tar.gz

(3)yum安装编译所需要的工具和库

# yum install gcc gcc-c++ cmake ncurses-devel bison openssl-devel rpcgen

上面的软件要一个一个安装,一起可能有问题

[root@localhost yum.repos.d]# yum -y install gcc* gcc-c++ ncurses* ncurses-devel* cmake* bison* libgcrypt* perl* make* openssl-devel* rpcgen*
Last metadata expiration check: 0:01:56 ago on 2022年11月15日 星期二 23时22分05秒.
Package gcc-8.3.1-4.5.p03.ky10.mips64el is already installed.
Package ncurses-6.1-14.ky10.mips64el is already installed.
Package ncurses-base-6.1-14.ky10.noarch is already installed.
Package ncurses-libs-6.1-14.ky10.mips64el is already installed.
Package cmake-3.12.1-5.ky10.mips64el is already installed.
Package cmake-data-3.12.1-5.ky10.noarch is already installed.
Package cmake-filesystem-3.12.1-5.ky10.mips64el is already installed.
Package cmake-help-3.12.1-5.ky10.noarch is already installed.
Package cmake-rpm-macros-3.12.1-5.ky10.noarch is already installed.
Package libgcrypt-1.8.3-5.ky10.mips64el is already installed.
Package perl-4:5.28.0-434.ky10.mips64el is already installed.
Package perl-Algorithm-Diff-1.1903-14.ky10.noarch is already installed.
Package perl-Algorithm-Diff-help-1.1903-14.ky10.noarch is already installed.
Package perl-Archive-Tar-2.30-421.ky10.noarch is already installed.
Package perl-Authen-SASL-help-2.16-16.ky10.noarch is already installed.
Package perl-B-Debug-1.26-4.ky10.noarch is already installed.
Package perl-B-Debug-help-1.26-4.ky10.noarch is already installed.
Package perl-Business-ISBN-Data-help-20191107-2.ky10.noarch is already installed.
Package perl-Business-ISBN-help-3.005-1.ky10.noarch is already installed.
Package perl-CGI-help-4.46-1.ky10.noarch is already installed.
Package perl-CPAN-Meta-2.150010-419.ky10.noarch is already installed.
Package perl-CPAN-Meta-Requirements-2.140-419.ky10.noarch is already installed.
Package perl-CPAN-Meta-Requirements-help-2.140-419.ky10.noarch is already installed.
Package perl-CPAN-Meta-YAML-0.018-420.ky10.noarch is already installed.
Package perl-CPAN-Meta-YAML-help-0.018-420.ky10.noarch is already installed.
Package perl-CPAN-Meta-help-2.150010-419.ky10.noarch is already installed.
Package perl-Capture-Tiny-help-0.48-4.ky10.noarch is already installed.
Package perl-Carp-1.50-418.ky10.noarch is already installed.
Package perl-Carp-help-1.50-418.ky10.noarch is already installed.
Package perl-Class-Inspector-help-1.32-5.ky10.noarch is already installed.
Package perl-Class-Method-Modifiers-help-2.12-12.ky10.noarch is already installed.
Package perl-Class-XSAccessor-help-1.19-18.ky10.noarch is already installed.
Package perl-Compress-Bzip2-help-2.26-10.ky10.noarch is already installed.
Package perl-Compress-Raw-Bzip2-2.081-8.ky10.mips64el is already installed.
Package perl-Compress-Raw-Bzip2-help-2.081-8.ky10.noarch is already installed.
Package perl-Compress-Raw-Zlib-2.081-6.ky10.mips64el is already installed.
Package perl-Compress-Raw-Zlib-help-2.081-6.ky10.noarch is already installed.
Package perl-Config-General-help-2.63-1.ky10.noarch is already installed.
Package perl-Config-Perl-V-0.30-5.ky10.noarch is already installed.
Package perl-Config-Perl-V-help-0.30-5.ky10.noarch is already installed.
Package perl-Crypt-OpenSSL-Random-help-0.15-4.ky10.noarch is already installed.
Package perl-Crypt-PasswdMD5-help-1.4.0-14.ky10.noarch is already installed.
Package perl-DBD-MySQL-help-4.046-6.ky10.mips64el is already installed.
Package perl-DBD-SQLite-1.58-4.ky10.mips64el is already installed.
Package perl-DBD-SQLite-help-1.58-4.ky10.mips64el is already installed.
Package perl-DBI-1.642-2.ky10.mips64el is already installed.
Package perl-DBI-help-1.642-2.ky10.noarch is already installed.
Package perl-DB_File-1.842-2.ky10.mips64el is already installed.
Package perl-DB_File-help-1.842-2.ky10.noarch is already installed.
Package perl-Data-Dumper-2.172-3.ky10.mips64el is already installed.
Package perl-Data-Dumper-help-2.172-3.ky10.noarch is already installed.
Package perl-Data-Section-help-0.200007-6.ky10.noarch is already installed.
Package perl-Date-Calc-help-6.4-12.ky10.noarch is already installed.
Package perl-Devel-CheckLib-help-1.13-5.ky10.noarch is already installed.
Package perl-Devel-GlobalDestruction-help-0.14-8.ky10.noarch is already installed.
Package perl-Devel-PPPort-3.42-4.ky10.mips64el is already installed.
Package perl-Devel-PPPort-help-3.42-4.ky10.noarch is already installed.
Package perl-Devel-Size-help-0.82-4.ky10.noarch is already installed.
Package perl-Digest-1.17-419.ky10.noarch is already installed.
Package perl-Digest-MD5-2.55-419.ky10.mips64el is already installed.
Package perl-Digest-MD5-help-2.55-419.ky10.noarch is already installed.
Package perl-Digest-SHA-1:6.02-7.ky10.mips64el is already installed.
Package perl-Digest-SHA-help-1:6.02-7.ky10.noarch is already installed.
Package perl-Digest-SHA3-help-1.04-4.ky10.mips64el is already installed.
Package perl-Digest-help-1.17-419.ky10.noarch is already installed.
Package perl-Encode-4:2.98-9.ky10.mips64el is already installed.
Package perl-Encode-Locale-help-1.05-12.ky10.noarch is already installed.
Package perl-Encode-devel-4:2.98-9.ky10.mips64el is already installed.
Package perl-Encode-help-4:2.98-9.ky10.noarch is already installed.
Package perl-Env-1.04-397.ky10.noarch is already installed.
Package perl-Env-help-1.04-397.ky10.noarch is already installed.
Package perl-Error-1:0.17026-4.ky10.noarch is already installed.
Package perl-Error-help-1:0.17026-4.ky10.noarch is already installed.
Package perl-Exporter-5.73-420.ky10.noarch is already installed.
Package perl-Exporter-Tiny-help-1.002001-5.ky10.noarch is already installed.
Package perl-Exporter-help-5.73-420.ky10.noarch is already installed.
Package perl-ExtUtils-Command-1:7.42-2.ky10.noarch is already installed.
Package perl-ExtUtils-Config-help-0.008-19.ky10.noarch is already installed.
Package perl-ExtUtils-Helpers-0.026-13.ky10.noarch is already installed.
Package perl-ExtUtils-Install-2.14-419.ky10.noarch is already installed.
Package perl-ExtUtils-Install-help-2.14-419.ky10.noarch is already installed.
Package perl-ExtUtils-InstallPaths-help-0.012-9.ky10.noarch is already installed.
Package perl-ExtUtils-MakeMaker-1:7.42-2.ky10.noarch is already installed.
Package perl-ExtUtils-MakeMaker-help-1:7.42-2.ky10.noarch is already installed.
Package perl-ExtUtils-Manifest-1:1.71-4.ky10.noarch is already installed.
Package perl-ExtUtils-Manifest-help-1:1.71-4.ky10.noarch is already installed.
Package perl-ExtUtils-ParseXS-2:3.35-1.ky10.noarch is already installed.
Package perl-ExtUtils-ParseXS-help-2:3.35-1.ky10.noarch is already installed.
Package perl-Fedora-VSP-help-0.001-10.ky10.noarch is already installed.
Package perl-File-BaseDir-help-0.08-6.ky10.noarch is already installed.
Package perl-File-DesktopEntry-help-0.22-11.ky10.noarch is already installed.
Package perl-File-Fetch-0.56-4.ky10.noarch is already installed.
Package perl-File-Fetch-help-0.56-4.ky10.noarch is already installed.
Package perl-File-HomeDir-1.004-4.ky10.noarch is already installed.
Package perl-File-HomeDir-help-1.004-4.ky10.noarch is already installed.
Package perl-File-Path-2.16-4.ky10.noarch is already installed.
Package perl-File-Path-help-2.16-4.ky10.noarch is already installed.
Package perl-File-ReadBackwards-help-1.05-1.ky10.noarch is already installed.
Package perl-File-Remove-help-1.58-2.ky10.noarch is already installed.
Package perl-File-ShareDir-Install-help-0.13-4.ky10.noarch is already installed.
Package perl-File-ShareDir-help-1.116-4.ky10.noarch is already installed.
Package perl-File-Slurp-help-9999.19-22.ky10.noarch is already installed.
Package perl-File-Sync-help-0.11-20.ky10.noarch is already installed.
Package perl-File-Temp-1:0.230.800-4.ky10.noarch is already installed.
Package perl-File-Temp-help-1:0.230.800-4.ky10.noarch is already installed.
Package perl-File-Which-1.22-6.ky10.noarch is already installed.
Package perl-File-Which-help-1.22-6.ky10.noarch is already installed.
Package perl-Filter-2:1.59-2.ky10.mips64el is already installed.
Package perl-Filter-Simple-1:0.94-1.ky10.noarch is already installed.
Package perl-Filter-Simple-help-1:0.94-1.ky10.noarch is already installed.
Package perl-Font-TTF-help-1.06-9.ky10.noarch is already installed.
Package perl-GD-Barcode-help-1.15-30.ky10.noarch is already installed.
Package perl-GD-help-2.71-1.p01.ky10.noarch is already installed.
Package perl-GSSAPI-help-0.28-26.ky10.mips64el is already installed.
Package perl-Getopt-Long-2.50-419.ky10.noarch is already installed.
Package perl-Getopt-Long-help-2.50-419.ky10.noarch is already installed.
Package perl-Git-2.27.0-4.ky10.noarch is already installed.
Package perl-HTML-Parser-help-3.72-16.ky10.mips64el is already installed.
Package perl-HTML-Tagset-help-3.20-37.ky10.noarch is already installed.
Package perl-HTTP-Cookies-help-6.04-5.ky10.noarch is already installed.
Package perl-HTTP-Daemon-help-6.01-26.ky10.noarch is already installed.
Package perl-HTTP-Date-help-6.02-21.ky10.noarch is already installed.
Package perl-HTTP-Message-help-6.18-4.ky10.noarch is already installed.
Package perl-HTTP-Negotiate-help-6.01-22.ky10.noarch is already installed.
Package perl-HTTP-Tiny-0.076-3.ky10.noarch is already installed.
Package perl-HTTP-Tiny-help-0.076-3.ky10.noarch is already installed.
Package perl-IO-Compress-2.081-6.ky10.noarch is already installed.
Package perl-IO-Compress-help-2.081-6.ky10.noarch is already installed.
Package perl-IO-HTML-help-1.001-13.ky10.noarch is already installed.
Package perl-IO-Socket-INET6-help-2.72-15.ky10.noarch is already installed.
Package perl-IO-Socket-IP-0.39-420.ky10.noarch is already installed.
Package perl-IO-Socket-IP-help-0.39-420.ky10.noarch is already installed.
Package perl-IO-Socket-SSL-help-2.066-4.ky10.noarch is already installed.
Package perl-IO-stringy-help-2.111-12.ky10.noarch is already installed.
Package perl-IPC-Cmd-2:1.04-4.ky10.noarch is already installed.
Package perl-IPC-Cmd-help-2:1.04-4.ky10.noarch is already installed.
Package perl-IPC-SysV-2.07-5.ky10.mips64el is already installed.
Package perl-IPC-SysV-help-2.07-5.ky10.noarch is already installed.
Package perl-IPC-System-Simple-1.25-19.ky10.noarch is already installed.
Package perl-IPC-System-Simple-help-1.25-19.ky10.noarch is already installed.
Package perl-JSON-PP-1:4.04-2.ky10.noarch is already installed.
Package perl-JSON-PP-help-1:4.04-2.ky10.noarch is already installed.
Package perl-JSON-XS-help-1:3.04-6.ky10.noarch is already installed.
Package perl-JSON-help-2.97.001-6.ky10.noarch is already installed.
Package perl-LWP-MediaTypes-help-6.02-17.ky10.noarch is already installed.
Package perl-List-MoreUtils-XS-help-0.428-7.ky10.noarch is already installed.
Package perl-List-MoreUtils-help-0.428-5.ky10.noarch is already installed.
Package perl-Locale-Codes-3.58-2.ky10.noarch is already installed.
Package perl-Locale-Codes-help-3.58-2.ky10.noarch is already installed.
Package perl-Locale-Maketext-1:1.28-1.ky10.noarch is already installed.
Package perl-Locale-Maketext-help-1:1.28-1.ky10.noarch is already installed.
Package perl-MIME-Base64-3.15-418.ky10.mips64el is already installed.
Package perl-MIME-Base64-help-3.15-418.ky10.noarch is already installed.
Package perl-MRO-Compat-help-0.13-9.ky10.noarch is already installed.
Package perl-Math-BigInt-1:1.9998.13-5.ky10.noarch is already installed.
Package perl-Math-BigInt-FastCalc-0.500.700-4.ky10.mips64el is already installed.
Package perl-Math-BigInt-FastCalc-help-0.500.700-4.ky10.noarch is already installed.
Package perl-Math-BigInt-help-1:1.9998.13-5.ky10.noarch is already installed.
Package perl-Math-BigRat-0.2614-2.ky10.noarch is already installed.
Package perl-Math-BigRat-help-0.2614-2.ky10.noarch is already installed.
Package perl-Module-Build-Tiny-help-0.039-17.ky10.noarch is already installed.
Package perl-Module-Build-help-2:0.42.24-12.ky10.noarch is already installed.
Package perl-Module-CoreList-1:5.20180920-2.ky10.noarch is already installed.
Package perl-Module-CoreList-help-1:5.20180920-2.ky10.noarch is already installed.
Package perl-Module-Install-AuthorRequires-help-0.02-18.ky10.noarch is already installed.
Package perl-Module-Install-AuthorTests-help-0.002-18.ky10.noarch is already installed.
Package perl-Module-Install-ReadmeFromPod-help-0.30-12.ky10.noarch is already installed.
Package perl-Module-Install-ReadmeMarkdownFromPod-help-0.04-10.ky10.noarch is already installed.
Package perl-Module-Install-Repository-help-0.06-23.ky10.noarch is already installed.
Package perl-Module-Load-1:0.32-418.ky10.noarch is already installed.
Package perl-Module-Load-Conditional-0.68-418.ky10.noarch is already installed.
Package perl-Module-Load-Conditional-help-0.68-418.ky10.noarch is already installed.
Package perl-Module-Load-help-1:0.32-418.ky10.noarch is already installed.
Package perl-Module-Manifest-Skip-help-0.23-16.ky10.noarch is already installed.
Package perl-Module-Metadata-1.000036-3.ky10.noarch is already installed.
Package perl-Module-Metadata-help-1.000036-3.ky10.noarch is already installed.
Package perl-Module-Package-Au-help-2-16.ky10.noarch is already installed.
Package perl-Module-Package-help-0.30-22.ky10.noarch is already installed.
Package perl-Module-Runtime-help-0.016-5.ky10.noarch is already installed.
Package perl-Module-ScanDeps-help-1.27-6.p01.ky10.noarch is already installed.
Package perl-Moo-help-2.003004-8.ky10.noarch is already installed.
Package perl-Mozilla-CA-help-1:20180117-6.ky10.noarch is already installed.
Package perl-NTLM-help-1.09-20.ky10.noarch is already installed.
Package perl-Net-Daemon-1:0.48-2.ky10.noarch is already installed.
Package perl-Net-Daemon-help-1:0.48-2.ky10.noarch is already installed.
Package perl-Net-HTTP-help-6.18-4.ky10.noarch is already installed.
Package perl-Net-LibIDN-help-0.12-33.ky10.noarch is already installed.
Package perl-Net-SNMP-help-6.0.1-23.ky10.noarch is already installed.
Package perl-Net-SSLeay-help-1.88-5.ky10.noarch is already installed.
Package perl-NetAddr-IP-help-4.079-10.ky10.mips64el is already installed.
Package perl-Package-Constants-help-1:0.06-1.ky10.noarch is already installed.
Package perl-Package-Generator-help-1.106-14.ky10.noarch is already installed.
Package perl-Params-Check-1:0.38-418.ky10.noarch is already installed.
Package perl-Params-Check-help-1:0.38-418.ky10.noarch is already installed.
Package perl-Params-Util-help-1.07-26.ky10.noarch is already installed.
Package perl-Parse-Yapp-help-1.21-5.ky10.noarch is already installed.
Package perl-Path-Class-help-0.37-14.ky10.noarch is already installed.
Package perl-Path-Tiny-help-0.108-2.ky10.noarch is already installed.
Package perl-PathTools-3.75-4.ky10.mips64el is already installed.
Package perl-PathTools-help-3.75-4.ky10.noarch is already installed.
Package perl-Perl-OSType-1.010-421.ky10.noarch is already installed.
Package perl-Perl-OSType-help-1.010-421.ky10.noarch is already installed.
Package perl-PerlIO-via-QuotedPrint-0.08-397.ky10.noarch is already installed.
Package perl-PerlIO-via-QuotedPrint-help-0.08-397.ky10.noarch is already installed.
Package perl-Pod-Checker-4:1.73-398.ky10.noarch is already installed.
Package perl-Pod-Checker-help-4:1.73-398.ky10.noarch is already installed.
Package perl-Pod-Escapes-1:1.07-419.ky10.noarch is already installed.
Package perl-Pod-Escapes-help-1:1.07-419.ky10.noarch is already installed.
Package perl-Pod-Markdown-help-3.101-2.ky10.noarch is already installed.
Package perl-Pod-Parser-1.63-397.ky10.noarch is already installed.
Package perl-Pod-Parser-help-1.63-397.ky10.noarch is already installed.
Package perl-Pod-Perldoc-1:3.28-3.ky10.noarch is already installed.
Package perl-Pod-Perldoc-help-1:3.28-3.ky10.noarch is already installed.
Package perl-Pod-Simple-1:3.35-418.ky10.noarch is already installed.
Package perl-Pod-Simple-help-1:3.35-418.ky10.noarch is already installed.
Package perl-Pod-Usage-4:1.69-418.ky10.noarch is already installed.
Package perl-Pod-Usage-help-4:1.69-418.ky10.noarch is already installed.
Package perl-Readonly-help-2.05-8.ky10.noarch is already installed.
Package perl-Role-Tiny-help-2.001004-2.ky10.noarch is already installed.
Package perl-SGMLSpm-1.03ii-45.ky10.noarch is already installed.
Package perl-SGMLSpm-help-1.03ii-45.ky10.noarch is already installed.
Package perl-SNMP_Session-help-1.13-20.ky10.noarch is already installed.
Package perl-Scalar-List-Utils-3:1.52-2.ky10.mips64el is already installed.
Package perl-Scalar-List-Utils-help-3:1.52-2.ky10.noarch is already installed.
Package perl-Socket-4:2.029-2.ky10.mips64el is already installed.
Package perl-Socket-MsgHdr-help-0.05-5.ky10.noarch is already installed.
Package perl-Socket-help-4:2.029-2.ky10.noarch is already installed.
Package perl-Socket6-help-0.28-9.ky10.mips64el is already installed.
Package perl-Software-License-help-0.103013-7.ky10.noarch is already installed.
Package perl-Storable-1:3.15-2.ky10.mips64el is already installed.
Package perl-Storable-help-1:3.15-2.ky10.noarch is already installed.
Package perl-String-ShellQuote-help-1.04-26.ky10.noarch is already installed.
Package perl-Sub-Exporter-Progressive-help-0.001013-8.ky10.noarch is already installed.
Package perl-Sub-Exporter-help-0.987-18.ky10.noarch is already installed.
Package perl-Sub-Install-help-0.928-18.ky10.noarch is already installed.
Package perl-Sub-Name-help-0.21-10.ky10.mips64el is already installed.
Package perl-Sub-Quote-help-2.005001-4.ky10.noarch is already installed.
Package perl-Sys-CPU-help-0.61-19.ky10.noarch is already installed.
Package perl-Sys-MemInfo-help-0.99-9.ky10.noarch is already installed.
Package perl-Sys-Syslog-0.35-420.ky10.mips64el is already installed.
Package perl-Sys-Syslog-help-0.35-420.ky10.noarch is already installed.
Package perl-Term-ANSIColor-4.06-511.ky10.noarch is already installed.
Package perl-Term-ANSIColor-help-4.06-511.ky10.noarch is already installed.
Package perl-Term-Cap-1.17-510.ky10.noarch is already installed.
Package perl-Term-Cap-help-1.17-510.ky10.noarch is already installed.
Package perl-TermReadKey-2.38-2.ky10.mips64el is already installed.
Package perl-TermReadKey-help-2.38-2.ky10.noarch is already installed.
Package perl-Test-Deep-help-1.128-4.ky10.noarch is already installed.
Package perl-Test-FailWarnings-help-0.008-15.ky10.noarch is already installed.
Package perl-Test-Fatal-help-0.014-13.ky10.noarch is already installed.
Package perl-Test-Harness-1:3.43_01-3.ky10.noarch is already installed.
Package perl-Test-Harness-help-1:3.43_01-3.ky10.noarch is already installed.
Package perl-Test-InDistDir-help-1.112071-10.ky10.noarch is already installed.
Package perl-Test-LeakTrace-help-0.16-10.ky10.noarch is already installed.
Package perl-Test-NoWarnings-help-1.04-17.ky10.noarch is already installed.
Package perl-Test-Pod-Coverage-help-1.10-14.ky10.noarch is already installed.
Package perl-Test-Pod-help-1.52-4.ky10.noarch is already installed.
Package perl-Test-Requires-help-0.10-15.ky10.noarch is already installed.
Package perl-Test-Simple-2:1.302140-3.ky10.noarch is already installed.
Package perl-Test-Simple-help-2:1.302140-3.ky10.noarch is already installed.
Package perl-Text-Balanced-2.03-420.ky10.noarch is already installed.
Package perl-Text-Balanced-help-2.03-420.ky10.noarch is already installed.
Package perl-Text-Diff-1.45-7.ky10.noarch is already installed.
Package perl-Text-Diff-help-1.45-7.ky10.noarch is already installed.
Package perl-Text-Glob-help-0.11-7.ky10.noarch is already installed.
Package perl-Text-ParseWords-3.30-419.ky10.noarch is already installed.
Package perl-Text-ParseWords-help-3.30-419.ky10.noarch is already installed.
Package perl-Text-Tabs+Wrap-2013.0523-419.ky10.noarch is already installed.
Package perl-Text-Tabs+Wrap-help-2013.0523-419.ky10.noarch is already installed.
Package perl-Text-Template-help-1.53-4.ky10.noarch is already installed.
Package perl-Text-WrapI18N-help-0.06-33.ky10.noarch is already installed.
Package perl-Thread-Queue-3.13-3.ky10.noarch is already installed.
Package perl-Thread-Queue-help-3.13-3.ky10.noarch is already installed.
Package perl-Time-HiRes-1.9760-2.ky10.mips64el is already installed.
Package perl-Time-HiRes-help-1.9760-2.ky10.noarch is already installed.
Package perl-Time-Local-2:1.280-6.ky10.noarch is already installed.
Package perl-Time-Local-help-2:1.280-6.ky10.noarch is already installed.
Package perl-TimeDate-help-1:2.30-17.ky10.noarch is already installed.
Package perl-Types-Serialiser-help-1.0-18.ky10.noarch is already installed.
Package perl-URI-help-1.76-3.ky10.noarch is already installed.
Package perl-Unicode-Collate-1.25-4.ky10.mips64el is already installed.
Package perl-Unicode-Collate-help-1.25-4.ky10.noarch is already installed.
Package perl-Unicode-Normalize-1.26-419.ky10.mips64el is already installed.
Package perl-Unicode-Normalize-help-1.26-419.ky10.noarch is already installed.
Package perl-Unicode-UTF8-help-0.62-8.ky10.noarch is already installed.
Package perl-XML-LibXML-help-1:2.0132-5.ky10.mips64el is already installed.
Package perl-XML-NamespaceSupport-help-1.12-7.ky10.noarch is already installed.
Package perl-XML-Parser-1:2.44-3.ky10.mips64el is already installed.
Package perl-XML-Parser-help-1:2.44-3.ky10.noarch is already installed.
Package perl-XML-SAX-Base-help-1.09-7.ky10.noarch is already installed.
Package perl-XML-SAX-help-1.00-5.ky10.noarch is already installed.
Package perl-XML-Writer-help-0.625-14.ky10.noarch is already installed.
Package perl-XML-XPath-help-1.42-6.ky10.noarch is already installed.
Package perl-YAML-Tiny-help-1.73-4.ky10.noarch is already installed.
Package perl-YAML-help-1.26-5.ky10.noarch is already installed.
Package perl-autodie-2.29-398.ky10.noarch is already installed.
Package perl-autodie-help-2.29-398.ky10.noarch is already installed.
Package perl-bignum-0.50-4.ky10.noarch is already installed.
Package perl-bignum-help-0.50-4.ky10.noarch is already installed.
Package perl-common-sense-help-3.7.4-14.ky10.noarch is already installed.
Package perl-constant-1.33-421.ky10.noarch is already installed.
Package perl-constant-help-1.33-421.ky10.noarch is already installed.
Package perl-devel-4:5.28.0-434.ky10.mips64el is already installed.
Package perl-experimental-0.020-2.ky10.noarch is already installed.
Package perl-experimental-help-0.020-2.ky10.noarch is already installed.
Package perl-gettext-help-1.07-13.ky10.noarch is already installed.
Package perl-inc-latest-help-2:0.500-12.ky10.noarch is already installed.
Package perl-libintl-perl-help-1.29-6.ky10.noarch is already installed.
Package perl-libnet-3.11-420.ky10.noarch is already installed.
Package perl-libnet-help-3.11-420.ky10.noarch is already installed.
Package perl-libs-4:5.28.0-434.ky10.mips64el is already installed.
Package perl-libwww-perl-help-6.35-2.ky10.noarch is already installed.
Package perl-libxml-perl-help-0.08-36.ky10.noarch is already installed.
Package perl-parent-1:0.237-4.ky10.noarch is already installed.
Package perl-parent-help-1:0.237-4.ky10.noarch is already installed.
Package perl-perlfaq-5.20180915-5.ky10.noarch is already installed.
Package perl-perlfaq-help-5.20180915-5.ky10.noarch is already installed.
Package perl-podlators-1:4.11-5.ky10.noarch is already installed.
Package perl-podlators-help-1:4.11-5.ky10.noarch is already installed.
Package perl-strictures-help-2.000006-7.ky10.noarch is already installed.
Package perl-threads-1:2.22-419.ky10.mips64el is already installed.
Package perl-threads-help-1:2.22-419.ky10.noarch is already installed.
Package perl-threads-shared-1.59-2.ky10.mips64el is already installed.
Package perl-threads-shared-help-1.59-2.ky10.noarch is already installed.
Package perl-version-8:0.99.24-3.ky10.mips64el is already installed.
Package perl-version-help-8:0.99.24-3.ky10.noarch is already installed.
Package make-1:4.2.1-15.ky10.mips64el is already installed.

创建mysql用户与用户组

[root@localhost /]# groupadd mysql
groupadd:“mysql”组已存在
[root@localhost /]# id mysql
用户id=27(mysql) 组id=27(mysql) 组=27(mysql)

解压MySQL源码包

[root@localhost soft]# tar -zxvf  mysql-boost-5.7.39.tar.gz
[root@localhost soft]# ls -lrt
总用量 3643996
drwxr-xr-x 34 7161 31415       4096  6月  8 16:48 mysql-5.7.39
-rw-------  1 root root    53243335 11月 15 22:24 mysql-boost-5.7.39.tar.gz

[root@localhost /]# mv mysql-5.7.39 mysql5_7

[root@localhost /]# cd mysql5_7/
[root@localhost mysql5_7]# ls -lrt
总用量 560
-rw-r--r--  1 7161 31415     88  6月  8 16:37 VERSION
-rw-r--r--  1 7161 31415    566  6月  8 16:37 README
-rw-r--r--  1 7161 31415 255074  6月  8 16:37 LICENSE
-rw-r--r--  1 7161 31415    333  6月  8 16:37 INSTALL
-rw-r--r--  1 7161 31415  67369  6月  8 16:37 Doxyfile-perfschema
-rw-r--r--  1 7161 31415  25144  6月  8 16:37 configure.cmake
-rw-r--r--  1 7161 31415  14554  6月  8 16:37 config.h.cmake
-rw-r--r--  1 7161 31415  29939  6月  8 16:37 CMakeLists.txt
drwxr-xr-x  2 7161 31415   4096  6月  8 16:47 source_downloads
drwxr-xr-x  2 7161 31415   4096  6月  8 16:47 libservices
drwxr-xr-x  3 7161 31415   4096  6月  8 16:47 libmysqld
drwxr-xr-x  4 7161 31415   4096  6月  8 16:47 libmysql
drwxr-xr-x  3 7161 31415   4096  6月  8 16:47 libbinlogstandalone
drwxr-xr-x  5 7161 31415   4096  6月  8 16:47 libbinlogevents
drwxr-xr-x  5 7161 31415   4096  6月  8 16:47 include
drwxr-xr-x  8 7161 31415   4096  6月  8 16:47 extra
drwxr-xr-x  2 7161 31415   4096  6月  8 16:47 Docs
drwxr-xr-x  2 7161 31415   4096  6月  8 16:47 dbug
drwxr-xr-x  4 7161 31415   4096  6月  8 16:47 cmake
drwxr-xr-x  6 7161 31415   4096  6月  8 16:47 client
drwxr-xr-x  2 7161 31415   4096  6月  8 16:47 BUILD
drwxr-xr-x  2 7161 31415   4096  6月  8 16:47 sql-common
drwxr-xr-x  2 7161 31415   4096  6月  8 16:47 regex
drwxr-xr-x  4 7161 31415   4096  6月  8 16:47 rapid
drwxr-xr-x 18 7161 31415   4096  6月  8 16:47 plugin
drwxr-xr-x 10 7161 31415   4096  6月  8 16:47 packaging
drwxr-xr-x  2 7161 31415   4096  6月  8 16:47 mysys_ssl
drwxr-xr-x  2 7161 31415   4096  6月  8 16:47 mysys
drwxr-xr-x 10 7161 31415   4096  6月  8 16:47 mysql-test
drwxr-xr-x  2 7161 31415   4096  6月  8 16:47 testclients
drwxr-xr-x  4 7161 31415   4096  6月  8 16:47 support-files
drwxr-xr-x  2 7161 31415   4096  6月  8 16:47 strings
drwxr-xr-x  2 7161 31415   4096  6月  8 16:47 win
drwxr-xr-x  3 7161 31415   4096  6月  8 16:47 vio
drwxr-xr-x  5 7161 31415   4096  6月  8 16:47 unittest
drwxr-xr-x  8 7161 31415  28672  6月  8 16:47 sql
drwxr-xr-x  4 7161 31415   4096  6月  8 16:47 scripts
drwxr-xr-x 13 7161 31415   4096  6月  8 16:48 storage
drwxr-xr-x  2 7161 31415   4096  6月  8 16:48 man
drwxr-xr-x  3 7161 31415   4096  6月  8 16:48 boost

创建编译目录

[root@localhost mysql5_7]# mkdir bld
[root@localhost mysql5_7]# cd bld
[root@localhost bld]# pwd
/mysql5_7/bld
[root@localhost bld]# cd /
[root@localhost /]# ls -lrt
总用量 52088
drwxr-xr-x    2 root  root      4096  3月 27  2020 srv
lrwxrwxrwx    1 root  root         8  3月 27  2020 sbin -> usr/sbin
drwxr-xr-x    2 root  root      4096  3月 27  2020 media
lrwxrwxrwx    1 root  root         9  3月 27  2020 lib64 -> usr/lib64
lrwxrwxrwx    1 root  root         7  3月 27  2020 lib -> usr/lib
lrwxrwxrwx    1 root  root         7  3月 27  2020 bin -> usr/bin
drwx------.   2 root  root     16384 11月 15 12:13 lost+found
drwxr-xr-x   12 root  root      4096 11月 15 12:21 usr
drwxrwxrwx    2 root  root      4096 11月 15 12:28 box
drwx--x--x    3 root  root      4096 11月 15 12:32 sudo
dr-xr-xr-x.   6 root  root      4096 11月 15 12:33 boot
drwxr-xr-x   24 root  root      4096 11月 15 12:42 var
drwxr-xr-x    7 root  root      4096 11月 15 12:42 opt
dr-xr-xr-x  233 root  root         0 11月 15 19:09 proc
drwxr-xr-x.   4 root  root      4096 11月 15 21:09 backup
dr-xr-xr-x   13 root  root         0 11月 15 22:35 sys
drwxr-xr-x    3 root  root      4096 11月 15 22:55 mnt
drwxr-xr-x   17 root  root      5080 11月 15 22:55 dev
drwxrwxr-x    3 mysql mysql     4096 11月 15 23:37 mysqlsoft
drwx------    5 root  root      4096 11月 18 19:40 soft
drwxr-xr-x    3 root  root      4096 11月 18 21:06 home
drwxr-xr-x   45 root  root      1360 11月 18 21:06 run
drwxrwxr-x    5 mysql mysql     4096 11月 18 21:24 mysqldata
drwxr-xr-x  157 root  root     12288 11月 18 21:31 etc
dr-xr-x---   17 root  root      4096 11月 18 21:58 root
-rw-------    1 root  root  53243335 11月 18 22:24 mysql-boost-5.7.39.tar.gz
drwxrwxrwt   14 root  root       320 11月 18 22:26 tmp
drwxr-xr-x   35  7161 31415     4096 11月 18 22:26 mysql5_7

创建MySQL安装目录

[root@localhost /]# mkdir -p mysql57soft/msyql
[root@localhost /]# mkdir -p msyql57data/mysql
[root@localhost /]# chown -R mysql:mysql mysql57*
[root@localhost /]# ls -lrt
总用量 52096
drwxr-xr-x    2 root  root      4096  3月 27  2020 srv
lrwxrwxrwx    1 root  root         8  3月 27  2020 sbin -> usr/sbin
drwxr-xr-x    2 root  root      4096  3月 27  2020 media
lrwxrwxrwx    1 root  root         9  3月 27  2020 lib64 -> usr/lib64
lrwxrwxrwx    1 root  root         7  3月 27  2020 lib -> usr/lib
lrwxrwxrwx    1 root  root         7  3月 27  2020 bin -> usr/bin
drwx------.   2 root  root     16384 11月 15 12:13 lost+found
drwxr-xr-x   12 root  root      4096 11月 15 12:21 usr
drwxrwxrwx    2 root  root      4096 11月 15 12:28 box
drwx--x--x    3 root  root      4096 11月 15 12:32 sudo
dr-xr-xr-x.   6 root  root      4096 11月 15 12:33 boot
drwxr-xr-x   24 root  root      4096 11月 15 12:42 var
drwxr-xr-x    7 root  root      4096 11月 15 12:42 opt
dr-xr-xr-x  235 root  root         0 11月 15 19:09 proc
drwxr-xr-x.   4 root  root      4096 11月 15 21:09 backup
dr-xr-xr-x   13 root  root         0 11月 15 22:35 sys
drwxr-xr-x    3 root  root      4096 11月 15 22:55 mnt
drwxr-xr-x   17 root  root      5080 11月 15 22:55 dev
drwxrwxr-x    3 mysql mysql     4096 11月 15 23:37 mysqlsoft
drwx------    5 root  root      4096 11月 18 19:40 soft
drwxr-xr-x    3 root  root      4096 11月 18 21:06 home
drwxr-xr-x   45 root  root      1360 11月 18 21:06 run
drwxrwxr-x    5 mysql mysql     4096 11月 18 21:24 mysqldata
drwxr-xr-x  157 root  root     12288 11月 18 21:31 etc
dr-xr-x---   17 root  root      4096 11月 18 21:58 root
-rw-------    1 root  root  53243335 11月 18 22:24 mysql-boost-5.7.39.tar.gz
drwxrwxrwt   14 root  root       320 11月 18 22:26 tmp
drwxr-xr-x   35  7161 31415     4096 11月 18 22:26 mysql5_7
drwx------    3 mysql mysql     4096 11月 18 22:30 mysql57soft
drwx------    3 root  root      4096 11月 18 22:30 msyql57data

[root@localhost /]# cd mysql5_7/
[root@localhost mysql5_7]# ls -lrt
总用量 564
-rw-r--r--  1 7161 31415     88  6月  8 16:37 VERSION
-rw-r--r--  1 7161 31415    566  6月  8 16:37 README
-rw-r--r--  1 7161 31415 255074  6月  8 16:37 LICENSE
-rw-r--r--  1 7161 31415    333  6月  8 16:37 INSTALL
-rw-r--r--  1 7161 31415  67369  6月  8 16:37 Doxyfile-perfschema
-rw-r--r--  1 7161 31415  25144  6月  8 16:37 configure.cmake
-rw-r--r--  1 7161 31415  14554  6月  8 16:37 config.h.cmake
-rw-r--r--  1 7161 31415  29939  6月  8 16:37 CMakeLists.txt
drwxr-xr-x  2 7161 31415   4096  6月  8 16:47 source_downloads
drwxr-xr-x  2 7161 31415   4096  6月  8 16:47 libservices
drwxr-xr-x  3 7161 31415   4096  6月  8 16:47 libmysqld
drwxr-xr-x  4 7161 31415   4096  6月  8 16:47 libmysql
drwxr-xr-x  3 7161 31415   4096  6月  8 16:47 libbinlogstandalone
drwxr-xr-x  5 7161 31415   4096  6月  8 16:47 libbinlogevents
drwxr-xr-x  5 7161 31415   4096  6月  8 16:47 include
drwxr-xr-x  8 7161 31415   4096  6月  8 16:47 extra
drwxr-xr-x  2 7161 31415   4096  6月  8 16:47 Docs
drwxr-xr-x  2 7161 31415   4096  6月  8 16:47 dbug
drwxr-xr-x  4 7161 31415   4096  6月  8 16:47 cmake
drwxr-xr-x  6 7161 31415   4096  6月  8 16:47 client
drwxr-xr-x  2 7161 31415   4096  6月  8 16:47 BUILD
drwxr-xr-x  2 7161 31415   4096  6月  8 16:47 sql-common
drwxr-xr-x  2 7161 31415   4096  6月  8 16:47 regex
drwxr-xr-x  4 7161 31415   4096  6月  8 16:47 rapid
drwxr-xr-x 18 7161 31415   4096  6月  8 16:47 plugin
drwxr-xr-x 10 7161 31415   4096  6月  8 16:47 packaging
drwxr-xr-x  2 7161 31415   4096  6月  8 16:47 mysys_ssl
drwxr-xr-x  2 7161 31415   4096  6月  8 16:47 mysys
drwxr-xr-x 10 7161 31415   4096  6月  8 16:47 mysql-test
drwxr-xr-x  2 7161 31415   4096  6月  8 16:47 testclients
drwxr-xr-x  4 7161 31415   4096  6月  8 16:47 support-files
drwxr-xr-x  2 7161 31415   4096  6月  8 16:47 strings
drwxr-xr-x  2 7161 31415   4096  6月  8 16:47 win
drwxr-xr-x  3 7161 31415   4096  6月  8 16:47 vio
drwxr-xr-x  5 7161 31415   4096  6月  8 16:47 unittest
drwxr-xr-x  8 7161 31415  28672  6月  8 16:47 sql
drwxr-xr-x  4 7161 31415   4096  6月  8 16:47 scripts
drwxr-xr-x 13 7161 31415   4096  6月  8 16:48 storage
drwxr-xr-x  2 7161 31415   4096  6月  8 16:48 man
drwxr-xr-x  3 7161 31415   4096  6月  8 16:48 boost
drwx------  2 root root    4096 11月 18 22:26 bld
[root@localhost mysql5_7]# cd bld
[root@localhost bld]# ls -lrt
总用量 0
[root@localhost bld]# pwd
/mysql5_7/bld

编译安装
预编译

cmake .. -DCMAKE_INSTALL_PREFIX=/mysql57soft/mysql  -DMYSQL_DATADIR=/mysql57data/mysql  -DSYSCONFDIR=/mysql57soft/mysql/mysql.sock  -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/mysql5_7/boost/boost_1_59_0 -DWITH_INNOBASE_STORAGE_ENGINE=1  -DWITH_PARTITION_STORAGE_ENGINE=1  -DWITH_FEDERATED_STORAGE_ENGINE=1  -DWITH_BLACKHOLE_STORAGE_ENGINE=1  -DWITH_MYISAM_STORAGE_ENGINE=1  -DENABLED_LOCAL_INFILE=1  -DENABLE_DTRACE=0  -DDEFAULT_CHARSET=utf8mb4  -DDEFAULT_COLLATION=utf8mb4_general_ci  -DWITH_EMBEDDED_SERVER=1

编译打包

cmake --build . --config relwithdebinfo --target package

[ 96%] Building CXX object sql/CMakeFiles/sql.dir/mf_iocache.cc.o
[ 96%] Building CXX object sql/CMakeFiles/sql.dir/mysqld.cc.o
[ 96%] Building CXX object sql/CMakeFiles/sql.dir/mysqld_thd_manager.cc.o
[ 96%] Building CXX object sql/CMakeFiles/sql.dir/protocol_callback.cc.o
[ 96%] Built target mysqlserver
[ 96%] Building CXX object sql/CMakeFiles/sql.dir/signal_handler.cc.o
Scanning dependencies of target mysqltest_embedded
[ 96%] Building CXX object libmysqld/examples/CMakeFiles/mysqltest_embedded.dir/__/__/client/mysqltest.cc.o
[ 96%] Building CXX object sql/CMakeFiles/sql.dir/sql_audit.cc.o
[ 96%] Building CXX object sql/CMakeFiles/sql.dir/sql_client.cc.o
Scanning dependencies of target mysql_embedded
[ 96%] Building CXX object libmysqld/examples/CMakeFiles/mysql_embedded.dir/__/__/client/completion_hash.cc.o
[ 96%] Building CXX object libmysqld/examples/CMakeFiles/mysql_embedded.dir/__/__/client/mysql.cc.o
[ 96%] Linking CXX executable mysqltest_embedded
[ 96%] Building CXX object libmysqld/examples/CMakeFiles/mysql_embedded.dir/__/__/client/readline.cc.o
[ 96%] Linking CXX executable mysql_embedded
[ 96%] Built target mysqltest_embedded
Scanning dependencies of target mysql_client_test_embedded
[ 96%] Building C object libmysqld/examples/CMakeFiles/mysql_client_test_embedded.dir/__/__/testclients/mysql_client_test.c.o
[ 96%] Built target mysql_embedded
[ 96%] Building CXX object sql/CMakeFiles/sql.dir/srv_session.cc.o
[ 96%] Building CXX object sql/CMakeFiles/sql.dir/srv_session_service.cc.o
[ 96%] Building CXX object sql/CMakeFiles/sql.dir/srv_session_info_service.cc.o
[ 96%] Building CXX object sql/CMakeFiles/sql.dir/auth/sha2_password_common.cc.o
[ 97%] Building CXX object sql/CMakeFiles/sql.dir/mysqld_daemon.cc.o
[ 97%] Linking CXX static library ../archive_output_directory/libsql.a
[ 97%] Built target sql
Scanning dependencies of target mysqld
Scanning dependencies of target pfs_connect_attr-t
[ 97%] Building CXX object sql/CMakeFiles/mysqld.dir/main.cc.o
[ 97%] Building CXX object storage/perfschema/unittest/CMakeFiles/pfs_connect_attr-t.dir/__/__/__/sql/sql_builtin.cc.o
[ 97%] Linking CXX executable mysqld
[ 97%] Building CXX object storage/perfschema/unittest/CMakeFiles/pfs_connect_attr-t.dir/pfs_connect_attr-t.cc.o
[ 98%] Building C object storage/perfschema/unittest/CMakeFiles/pfs_connect_attr-t.dir/__/__/__/mysys/string.c.o
[ 98%] Linking CXX executable pfs_connect_attr-t
[100%] Linking CXX executable mysql_client_test_embedded
[100%] Built target mysqld
[100%] Built target pfs_connect_attr-t
[100%] Built target mysql_client_test_embedded
Run CPack packaging tool...
CPack: Create package using TGZ
CPack: Install projects
CPack: - Run preinstall target for: MySQL
CPack: - Install project: MySQL
CPack: Create package
CPack: - package: /mysql5_7/bld/mysql-5.7.39-linux-mips64el.tar.gz generated.

使用编译的软件包安装MySQL

[root@localhost/] tar -zxvf  /mysql5_7/bld/mysql-5.7.39-linux-mips64el.tar.gz
[root@localhost/] chown -R mysql:mysql mysql_5_7_39
[msyql@localhost/]cd mysql_5_7_39

配置mysql参数,只是设置几个简单的mysql运行参数

[mysql@localhost mysql_5_7_39]$ vi my.cnf
[mysqld]
basedir=/mysql57soft/mysql
datadir=/mysql57data/mysql
bind-address=0.0.0.0
user=mysql
port=3307
log-error=/mysql57data/mysql/mysql.err
pid-file=/mysql57data/mysql/mysqld.pid
socket = /mysql_5_7_39/mysql.sock
character-set-server=utf8mb4
default-storage-engine=INNODB
explicit_defaults_for_timestamp = true
########innodb settings########
innodb_page_size = 8192
innodb_buffer_pool_size = 2G
innodb_buffer_pool_instances = 1
innodb_buffer_pool_load_at_startup = 1
innodb_buffer_pool_dump_at_shutdown = 1
innodb_lru_scan_depth = 2000
innodb_lock_wait_timeout = 5
innodb_io_capacity = 4000
innodb_io_capacity_max = 8000
innodb_flush_method = O_DIRECT
innodb_file_format = Barracuda
innodb_file_format_max = Barracuda
innodb_log_group_home_dir =/mysql57data/redolog/
innodb_undo_directory =/mysql57data/undolog/
innodb_undo_logs = 128
innodb_undo_tablespaces = 3
innodb_flush_nei***ors = 1
innodb_log_file_size = 1G
innodb_log_buffer_size = 16777216
innodb_purge_threads = 4
innodb_large_prefix = 1
innodb_thread_concurrency = 64
innodb_print_all_deadlocks = 1
innodb_strict_mode = 1
innodb_sort_buffer_size = 67108864

[client]
port=3307
socket = /mysql_5_7_39/mysql.sock

[root@localhost bin]# ./mysqld  --defaults-file=/mysql_5_7_39/my.cnf --initialize --basedir=/mysql_5_7_39 --datadir=/mysql57data/mysql --user=mysql

[mysql@localhost mysql]$ tail -f mysql.err
 100 200 300 400 500 600 700 800 900 1000
 100 200 300 400 500 600 700 800 900 1000
2022-11-18T16:11:40.704291Z 0 [Warning] InnoDB: New log files created, LSN=39537
2022-11-18T16:11:40.837945Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2022-11-18T16:11:40.903126Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: afe493ab-675b-11ed-8fe7-0023a0002161.
2022-11-18T16:11:40.905754Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2022-11-18T16:11:41.512271Z 0 [Warning] A deprecated TLS version TLSv1 is enabled. Please use TLSv1.2 or higher.
2022-11-18T16:11:41.512309Z 0 [Warning] A deprecated TLS version TLSv1.1 is enabled. Please use TLSv1.2 or higher.
2022-11-18T16:11:41.513362Z 0 [Warning] CA certificate ca.pem is self signed.
2022-11-18T16:11:41.752239Z 1 [Note] A temporary password is generated for root@localhost: g)Pnh/m(24IZ

其中[Note] A temporary password is generated for root@localhost:后面跟的是mysql数据库登录的临时密码,各人安装生成的临时密码不一样。可以看到到日志文件没有报错,而且有了临时密码,表示初始化成功。

如果想服务能够部署自动支持安全连接,使用mysql_ssl_rsa_setup工具来创建缺省SSL与RSA文件

[root@localhost bin]# ./mysql_ssl_rsa_setup --datadir=/mysql57data/mysql

[root@localhost bin]# mysqld_safe --defaults-file=/mysql_5_7_39/my.cnf --user=mysql &
[2] 98394
[root@localhost bin]# 2022-11-18T16:23:50.107056Z mysqld_safe Logging to '/mysql57data/mysql/mysql.err'.
2022-11-18T16:23:50.154854Z mysqld_safe Starting mysqld daemon with databases from /mysql57data/mysql

[root@localhost bin]# netstat -ltnp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:3306            0.0.0.0:*               LISTEN      98228/mysqld
tcp        0      0 0.0.0.0:3307            0.0.0.0:*               LISTEN      98924/mysqld
tcp        0      0 0.0.0.0:111             0.0.0.0:*               LISTEN      3919/rpcbind
tcp        0      0 192.168.122.1:53        0.0.0.0:*               LISTEN      4934/dnsmasq
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      4530/sshd: /usr/sbi
tcp        0      0 127.0.0.1:631           0.0.0.0:*               LISTEN      4521/cupsd
tcp6       0      0 :::111                  :::*                    LISTEN      3919/rpcbind
tcp6       0      0 :::22                   :::*                    LISTEN      4530/sshd: /usr/sbi
tcp6       0      0 ::1:631                 :::*                    LISTEN      4521/cupsd

配置环境变量

[root@localhost /]# vi /etc/profile
export MYSQL_HOME=/mysql57soft/mysql/
export PATH=$PATH:$MYSQL_HOME/bin

[root@localhost /]# vi /etc/profile
[root@localhost /]# source /etc/profile

配置自动启动MySQL

[root@localhost /]# cp /mysql57soft/mysql/support-files/mysql.server  /etc/init.d/mysqld
[root@localhost /]# chmod 755 /etc/init.d/mysqld
[root@localhost ~]# systemctl enable mysqld
mysqld.service is not a native service, redirecting to /sbin/chkconfig.
Executing /sbin/chkconfig mysqld on

启动MySQL

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

登录MySQL

[root@localhost tmp]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.39

Copyright (c) 2000, 2022, Oracle and/or its affiliates.

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

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

mysql>
]]>
http://www.jydba.net/index.php/archives/3448/feed 0
龙芯源码编译MySQL http://www.jydba.net/index.php/archives/3443 http://www.jydba.net/index.php/archives/3443#respond Wed, 21 Dec 2022 00:25:33 +0000 http://www.jydba.net/?p=3443 在龙芯+麒麟操作系统环境使用源码编译MySQL5.7.39,其操作步骤如下:
查看是否已安装mariadb,若是已安装,需要卸载

[root@localhost yum.repos.d]# rpm -qa|grep mariadb
mariadb-10.3.9-8.p01.ky10.mips64el
mariadb-common-10.3.9-8.p01.ky10.mips64el
mariadb-errmessage-10.3.9-8.p01.ky10.mips64el
mariadb-connector-c-3.0.6-6.ky10.mips64el
mariadb-server-10.3.9-8.p01.ky10.mips64el

要是有,卸载:# yum remove mariadb

[root@localhost yum.repos.d]# yum remove mariadb
Warning: failed loading '/etc/yum.repos.d/kylin.repo', skipping.
Dependencies resolved.
=================================================================================================================================================================================================
 Package                                         Architecture                              Version                                              Repository                                  Size
=================================================================================================================================================================================================
Removing:
 mariadb                                         mips64el                                  3:10.3.9-8.p01.ky10                                  @anaconda                                   38 M
Removing dependent packages:
 mariadb-server                                  mips64el                                  3:10.3.9-8.p01.ky10                                  @anaconda                                   92 M
Removing unused dependencies:
 perl-DBD-MySQL                                  mips64el                                  4.046-6.ky10                                         @anaconda                                  327 k

Transaction Summary
=================================================================================================================================================================================================
Remove  3 Packages

Freed space: 129 M
Is this ok [y/N]: y
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                                                                         1/1
  Running scriptlet: mariadb-3:10.3.9-8.p01.ky10.mips64el                                                                                                                                    1/1
  Erasing          : mariadb-3:10.3.9-8.p01.ky10.mips64el                                                                                                                                    1/3
  Running scriptlet: mariadb-server-3:10.3.9-8.p01.ky10.mips64el                                                                                                                             2/3
  Erasing          : mariadb-server-3:10.3.9-8.p01.ky10.mips64el                                                                                                                             2/3
  Running scriptlet: mariadb-server-3:10.3.9-8.p01.ky10.mips64el                                                                                                                             2/3
  Erasing          : perl-DBD-MySQL-4.046-6.ky10.mips64el                                                                                                                                    3/3
  Running scriptlet: perl-DBD-MySQL-4.046-6.ky10.mips64el                                                                                                                                    3/3
  Verifying        : mariadb-3:10.3.9-8.p01.ky10.mips64el                                                                                                                                    1/3
  Verifying        : mariadb-server-3:10.3.9-8.p01.ky10.mips64el                                                                                                                             2/3
  Verifying        : perl-DBD-MySQL-4.046-6.ky10.mips64el                                                                                                                                    3/3

Removed:
  mariadb-3:10.3.9-8.p01.ky10.mips64el                         mariadb-server-3:10.3.9-8.p01.ky10.mips64el                         perl-DBD-MySQL-4.046-6.ky10.mips64el

Complete!

[root@localhost soft]# mkdir /mnt/cdrom
[root@localhost soft]# mount -o loop -t iso9660 Kylin-Server-10-SP1-Release-Build18-20210809-mips64el.iso /mnt/cdrom
mount: /mnt/cdrom: WARNING: source write-protected, mounted read-only.
[root@localhost soft]# cd /mnt/cdrom
[root@localhost cdrom]# ls
boot  boot.catalog  EFI  images  LICENSE  manual  Packages  repodata  TRANS.TBL

[root@localhost yum.repos.d]# cat kylin.repo
[ks10-local-iso]
name = Kylin Linux Advanced Server 10 - local
baseurl = file:///mnt/cdrom/
gpgcheck = 1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-kylin
enabled = 1

(2)下载源码包并解压

# wget https://cdn.mysql.com/archives/mysql-5.7/mysql-5.7.29.tar.gz
# tar -zxvf mysql-5.7.29.tar.gz

(3)yum安装编译所需要的工具和库

# yum install gcc gcc-c++ cmake ncurses-devel bison openssl-devel rpcgen

上面的软件要一个一个安装,一起可能有问题

[root@localhost yum.repos.d]# yum -y install gcc* gcc-c++ ncurses* ncurses-devel* cmake* bison* libgcrypt* perl* make* openssl-devel* rpcgen*
Last metadata expiration check: 0:01:56 ago on 2022年11月15日 星期二 23时22分05秒.
Package gcc-8.3.1-4.5.p03.ky10.mips64el is already installed.
Package ncurses-6.1-14.ky10.mips64el is already installed.
Package ncurses-base-6.1-14.ky10.noarch is already installed.
Package ncurses-libs-6.1-14.ky10.mips64el is already installed.
Package cmake-3.12.1-5.ky10.mips64el is already installed.
Package cmake-data-3.12.1-5.ky10.noarch is already installed.
Package cmake-filesystem-3.12.1-5.ky10.mips64el is already installed.
Package cmake-help-3.12.1-5.ky10.noarch is already installed.
Package cmake-rpm-macros-3.12.1-5.ky10.noarch is already installed.
Package libgcrypt-1.8.3-5.ky10.mips64el is already installed.
Package perl-4:5.28.0-434.ky10.mips64el is already installed.
Package perl-Algorithm-Diff-1.1903-14.ky10.noarch is already installed.
Package perl-Algorithm-Diff-help-1.1903-14.ky10.noarch is already installed.
Package perl-Archive-Tar-2.30-421.ky10.noarch is already installed.
Package perl-Authen-SASL-help-2.16-16.ky10.noarch is already installed.
Package perl-B-Debug-1.26-4.ky10.noarch is already installed.
Package perl-B-Debug-help-1.26-4.ky10.noarch is already installed.
Package perl-Business-ISBN-Data-help-20191107-2.ky10.noarch is already installed.
Package perl-Business-ISBN-help-3.005-1.ky10.noarch is already installed.
Package perl-CGI-help-4.46-1.ky10.noarch is already installed.
Package perl-CPAN-Meta-2.150010-419.ky10.noarch is already installed.
Package perl-CPAN-Meta-Requirements-2.140-419.ky10.noarch is already installed.
Package perl-CPAN-Meta-Requirements-help-2.140-419.ky10.noarch is already installed.
Package perl-CPAN-Meta-YAML-0.018-420.ky10.noarch is already installed.
Package perl-CPAN-Meta-YAML-help-0.018-420.ky10.noarch is already installed.
Package perl-CPAN-Meta-help-2.150010-419.ky10.noarch is already installed.
Package perl-Capture-Tiny-help-0.48-4.ky10.noarch is already installed.
Package perl-Carp-1.50-418.ky10.noarch is already installed.
Package perl-Carp-help-1.50-418.ky10.noarch is already installed.
Package perl-Class-Inspector-help-1.32-5.ky10.noarch is already installed.
Package perl-Class-Method-Modifiers-help-2.12-12.ky10.noarch is already installed.
Package perl-Class-XSAccessor-help-1.19-18.ky10.noarch is already installed.
Package perl-Compress-Bzip2-help-2.26-10.ky10.noarch is already installed.
Package perl-Compress-Raw-Bzip2-2.081-8.ky10.mips64el is already installed.
Package perl-Compress-Raw-Bzip2-help-2.081-8.ky10.noarch is already installed.
Package perl-Compress-Raw-Zlib-2.081-6.ky10.mips64el is already installed.
Package perl-Compress-Raw-Zlib-help-2.081-6.ky10.noarch is already installed.
Package perl-Config-General-help-2.63-1.ky10.noarch is already installed.
Package perl-Config-Perl-V-0.30-5.ky10.noarch is already installed.
Package perl-Config-Perl-V-help-0.30-5.ky10.noarch is already installed.
Package perl-Crypt-OpenSSL-Random-help-0.15-4.ky10.noarch is already installed.
Package perl-Crypt-PasswdMD5-help-1.4.0-14.ky10.noarch is already installed.
Package perl-DBD-MySQL-help-4.046-6.ky10.mips64el is already installed.
Package perl-DBD-SQLite-1.58-4.ky10.mips64el is already installed.
Package perl-DBD-SQLite-help-1.58-4.ky10.mips64el is already installed.
Package perl-DBI-1.642-2.ky10.mips64el is already installed.
Package perl-DBI-help-1.642-2.ky10.noarch is already installed.
Package perl-DB_File-1.842-2.ky10.mips64el is already installed.
Package perl-DB_File-help-1.842-2.ky10.noarch is already installed.
Package perl-Data-Dumper-2.172-3.ky10.mips64el is already installed.
Package perl-Data-Dumper-help-2.172-3.ky10.noarch is already installed.
Package perl-Data-Section-help-0.200007-6.ky10.noarch is already installed.
Package perl-Date-Calc-help-6.4-12.ky10.noarch is already installed.
Package perl-Devel-CheckLib-help-1.13-5.ky10.noarch is already installed.
Package perl-Devel-GlobalDestruction-help-0.14-8.ky10.noarch is already installed.
Package perl-Devel-PPPort-3.42-4.ky10.mips64el is already installed.
Package perl-Devel-PPPort-help-3.42-4.ky10.noarch is already installed.
Package perl-Devel-Size-help-0.82-4.ky10.noarch is already installed.
Package perl-Digest-1.17-419.ky10.noarch is already installed.
Package perl-Digest-MD5-2.55-419.ky10.mips64el is already installed.
Package perl-Digest-MD5-help-2.55-419.ky10.noarch is already installed.
Package perl-Digest-SHA-1:6.02-7.ky10.mips64el is already installed.
Package perl-Digest-SHA-help-1:6.02-7.ky10.noarch is already installed.
Package perl-Digest-SHA3-help-1.04-4.ky10.mips64el is already installed.
Package perl-Digest-help-1.17-419.ky10.noarch is already installed.
Package perl-Encode-4:2.98-9.ky10.mips64el is already installed.
Package perl-Encode-Locale-help-1.05-12.ky10.noarch is already installed.
Package perl-Encode-devel-4:2.98-9.ky10.mips64el is already installed.
Package perl-Encode-help-4:2.98-9.ky10.noarch is already installed.
Package perl-Env-1.04-397.ky10.noarch is already installed.
Package perl-Env-help-1.04-397.ky10.noarch is already installed.
Package perl-Error-1:0.17026-4.ky10.noarch is already installed.
Package perl-Error-help-1:0.17026-4.ky10.noarch is already installed.
Package perl-Exporter-5.73-420.ky10.noarch is already installed.
Package perl-Exporter-Tiny-help-1.002001-5.ky10.noarch is already installed.
Package perl-Exporter-help-5.73-420.ky10.noarch is already installed.
Package perl-ExtUtils-Command-1:7.42-2.ky10.noarch is already installed.
Package perl-ExtUtils-Config-help-0.008-19.ky10.noarch is already installed.
Package perl-ExtUtils-Helpers-0.026-13.ky10.noarch is already installed.
Package perl-ExtUtils-Install-2.14-419.ky10.noarch is already installed.
Package perl-ExtUtils-Install-help-2.14-419.ky10.noarch is already installed.
Package perl-ExtUtils-InstallPaths-help-0.012-9.ky10.noarch is already installed.
Package perl-ExtUtils-MakeMaker-1:7.42-2.ky10.noarch is already installed.
Package perl-ExtUtils-MakeMaker-help-1:7.42-2.ky10.noarch is already installed.
Package perl-ExtUtils-Manifest-1:1.71-4.ky10.noarch is already installed.
Package perl-ExtUtils-Manifest-help-1:1.71-4.ky10.noarch is already installed.
Package perl-ExtUtils-ParseXS-2:3.35-1.ky10.noarch is already installed.
Package perl-ExtUtils-ParseXS-help-2:3.35-1.ky10.noarch is already installed.
Package perl-Fedora-VSP-help-0.001-10.ky10.noarch is already installed.
Package perl-File-BaseDir-help-0.08-6.ky10.noarch is already installed.
Package perl-File-DesktopEntry-help-0.22-11.ky10.noarch is already installed.
Package perl-File-Fetch-0.56-4.ky10.noarch is already installed.
Package perl-File-Fetch-help-0.56-4.ky10.noarch is already installed.
Package perl-File-HomeDir-1.004-4.ky10.noarch is already installed.
Package perl-File-HomeDir-help-1.004-4.ky10.noarch is already installed.
Package perl-File-Path-2.16-4.ky10.noarch is already installed.
Package perl-File-Path-help-2.16-4.ky10.noarch is already installed.
Package perl-File-ReadBackwards-help-1.05-1.ky10.noarch is already installed.
Package perl-File-Remove-help-1.58-2.ky10.noarch is already installed.
Package perl-File-ShareDir-Install-help-0.13-4.ky10.noarch is already installed.
Package perl-File-ShareDir-help-1.116-4.ky10.noarch is already installed.
Package perl-File-Slurp-help-9999.19-22.ky10.noarch is already installed.
Package perl-File-Sync-help-0.11-20.ky10.noarch is already installed.
Package perl-File-Temp-1:0.230.800-4.ky10.noarch is already installed.
Package perl-File-Temp-help-1:0.230.800-4.ky10.noarch is already installed.
Package perl-File-Which-1.22-6.ky10.noarch is already installed.
Package perl-File-Which-help-1.22-6.ky10.noarch is already installed.
Package perl-Filter-2:1.59-2.ky10.mips64el is already installed.
Package perl-Filter-Simple-1:0.94-1.ky10.noarch is already installed.
Package perl-Filter-Simple-help-1:0.94-1.ky10.noarch is already installed.
Package perl-Font-TTF-help-1.06-9.ky10.noarch is already installed.
Package perl-GD-Barcode-help-1.15-30.ky10.noarch is already installed.
Package perl-GD-help-2.71-1.p01.ky10.noarch is already installed.
Package perl-GSSAPI-help-0.28-26.ky10.mips64el is already installed.
Package perl-Getopt-Long-2.50-419.ky10.noarch is already installed.
Package perl-Getopt-Long-help-2.50-419.ky10.noarch is already installed.
Package perl-Git-2.27.0-4.ky10.noarch is already installed.
Package perl-HTML-Parser-help-3.72-16.ky10.mips64el is already installed.
Package perl-HTML-Tagset-help-3.20-37.ky10.noarch is already installed.
Package perl-HTTP-Cookies-help-6.04-5.ky10.noarch is already installed.
Package perl-HTTP-Daemon-help-6.01-26.ky10.noarch is already installed.
Package perl-HTTP-Date-help-6.02-21.ky10.noarch is already installed.
Package perl-HTTP-Message-help-6.18-4.ky10.noarch is already installed.
Package perl-HTTP-Negotiate-help-6.01-22.ky10.noarch is already installed.
Package perl-HTTP-Tiny-0.076-3.ky10.noarch is already installed.
Package perl-HTTP-Tiny-help-0.076-3.ky10.noarch is already installed.
Package perl-IO-Compress-2.081-6.ky10.noarch is already installed.
Package perl-IO-Compress-help-2.081-6.ky10.noarch is already installed.
Package perl-IO-HTML-help-1.001-13.ky10.noarch is already installed.
Package perl-IO-Socket-INET6-help-2.72-15.ky10.noarch is already installed.
Package perl-IO-Socket-IP-0.39-420.ky10.noarch is already installed.
Package perl-IO-Socket-IP-help-0.39-420.ky10.noarch is already installed.
Package perl-IO-Socket-SSL-help-2.066-4.ky10.noarch is already installed.
Package perl-IO-stringy-help-2.111-12.ky10.noarch is already installed.
Package perl-IPC-Cmd-2:1.04-4.ky10.noarch is already installed.
Package perl-IPC-Cmd-help-2:1.04-4.ky10.noarch is already installed.
Package perl-IPC-SysV-2.07-5.ky10.mips64el is already installed.
Package perl-IPC-SysV-help-2.07-5.ky10.noarch is already installed.
Package perl-IPC-System-Simple-1.25-19.ky10.noarch is already installed.
Package perl-IPC-System-Simple-help-1.25-19.ky10.noarch is already installed.
Package perl-JSON-PP-1:4.04-2.ky10.noarch is already installed.
Package perl-JSON-PP-help-1:4.04-2.ky10.noarch is already installed.
Package perl-JSON-XS-help-1:3.04-6.ky10.noarch is already installed.
Package perl-JSON-help-2.97.001-6.ky10.noarch is already installed.
Package perl-LWP-MediaTypes-help-6.02-17.ky10.noarch is already installed.
Package perl-List-MoreUtils-XS-help-0.428-7.ky10.noarch is already installed.
Package perl-List-MoreUtils-help-0.428-5.ky10.noarch is already installed.
Package perl-Locale-Codes-3.58-2.ky10.noarch is already installed.
Package perl-Locale-Codes-help-3.58-2.ky10.noarch is already installed.
Package perl-Locale-Maketext-1:1.28-1.ky10.noarch is already installed.
Package perl-Locale-Maketext-help-1:1.28-1.ky10.noarch is already installed.
Package perl-MIME-Base64-3.15-418.ky10.mips64el is already installed.
Package perl-MIME-Base64-help-3.15-418.ky10.noarch is already installed.
Package perl-MRO-Compat-help-0.13-9.ky10.noarch is already installed.
Package perl-Math-BigInt-1:1.9998.13-5.ky10.noarch is already installed.
Package perl-Math-BigInt-FastCalc-0.500.700-4.ky10.mips64el is already installed.
Package perl-Math-BigInt-FastCalc-help-0.500.700-4.ky10.noarch is already installed.
Package perl-Math-BigInt-help-1:1.9998.13-5.ky10.noarch is already installed.
Package perl-Math-BigRat-0.2614-2.ky10.noarch is already installed.
Package perl-Math-BigRat-help-0.2614-2.ky10.noarch is already installed.
Package perl-Module-Build-Tiny-help-0.039-17.ky10.noarch is already installed.
Package perl-Module-Build-help-2:0.42.24-12.ky10.noarch is already installed.
Package perl-Module-CoreList-1:5.20180920-2.ky10.noarch is already installed.
Package perl-Module-CoreList-help-1:5.20180920-2.ky10.noarch is already installed.
Package perl-Module-Install-AuthorRequires-help-0.02-18.ky10.noarch is already installed.
Package perl-Module-Install-AuthorTests-help-0.002-18.ky10.noarch is already installed.
Package perl-Module-Install-ReadmeFromPod-help-0.30-12.ky10.noarch is already installed.
Package perl-Module-Install-ReadmeMarkdownFromPod-help-0.04-10.ky10.noarch is already installed.
Package perl-Module-Install-Repository-help-0.06-23.ky10.noarch is already installed.
Package perl-Module-Load-1:0.32-418.ky10.noarch is already installed.
Package perl-Module-Load-Conditional-0.68-418.ky10.noarch is already installed.
Package perl-Module-Load-Conditional-help-0.68-418.ky10.noarch is already installed.
Package perl-Module-Load-help-1:0.32-418.ky10.noarch is already installed.
Package perl-Module-Manifest-Skip-help-0.23-16.ky10.noarch is already installed.
Package perl-Module-Metadata-1.000036-3.ky10.noarch is already installed.
Package perl-Module-Metadata-help-1.000036-3.ky10.noarch is already installed.
Package perl-Module-Package-Au-help-2-16.ky10.noarch is already installed.
Package perl-Module-Package-help-0.30-22.ky10.noarch is already installed.
Package perl-Module-Runtime-help-0.016-5.ky10.noarch is already installed.
Package perl-Module-ScanDeps-help-1.27-6.p01.ky10.noarch is already installed.
Package perl-Moo-help-2.003004-8.ky10.noarch is already installed.
Package perl-Mozilla-CA-help-1:20180117-6.ky10.noarch is already installed.
Package perl-NTLM-help-1.09-20.ky10.noarch is already installed.
Package perl-Net-Daemon-1:0.48-2.ky10.noarch is already installed.
Package perl-Net-Daemon-help-1:0.48-2.ky10.noarch is already installed.
Package perl-Net-HTTP-help-6.18-4.ky10.noarch is already installed.
Package perl-Net-LibIDN-help-0.12-33.ky10.noarch is already installed.
Package perl-Net-SNMP-help-6.0.1-23.ky10.noarch is already installed.
Package perl-Net-SSLeay-help-1.88-5.ky10.noarch is already installed.
Package perl-NetAddr-IP-help-4.079-10.ky10.mips64el is already installed.
Package perl-Package-Constants-help-1:0.06-1.ky10.noarch is already installed.
Package perl-Package-Generator-help-1.106-14.ky10.noarch is already installed.
Package perl-Params-Check-1:0.38-418.ky10.noarch is already installed.
Package perl-Params-Check-help-1:0.38-418.ky10.noarch is already installed.
Package perl-Params-Util-help-1.07-26.ky10.noarch is already installed.
Package perl-Parse-Yapp-help-1.21-5.ky10.noarch is already installed.
Package perl-Path-Class-help-0.37-14.ky10.noarch is already installed.
Package perl-Path-Tiny-help-0.108-2.ky10.noarch is already installed.
Package perl-PathTools-3.75-4.ky10.mips64el is already installed.
Package perl-PathTools-help-3.75-4.ky10.noarch is already installed.
Package perl-Perl-OSType-1.010-421.ky10.noarch is already installed.
Package perl-Perl-OSType-help-1.010-421.ky10.noarch is already installed.
Package perl-PerlIO-via-QuotedPrint-0.08-397.ky10.noarch is already installed.
Package perl-PerlIO-via-QuotedPrint-help-0.08-397.ky10.noarch is already installed.
Package perl-Pod-Checker-4:1.73-398.ky10.noarch is already installed.
Package perl-Pod-Checker-help-4:1.73-398.ky10.noarch is already installed.
Package perl-Pod-Escapes-1:1.07-419.ky10.noarch is already installed.
Package perl-Pod-Escapes-help-1:1.07-419.ky10.noarch is already installed.
Package perl-Pod-Markdown-help-3.101-2.ky10.noarch is already installed.
Package perl-Pod-Parser-1.63-397.ky10.noarch is already installed.
Package perl-Pod-Parser-help-1.63-397.ky10.noarch is already installed.
Package perl-Pod-Perldoc-1:3.28-3.ky10.noarch is already installed.
Package perl-Pod-Perldoc-help-1:3.28-3.ky10.noarch is already installed.
Package perl-Pod-Simple-1:3.35-418.ky10.noarch is already installed.
Package perl-Pod-Simple-help-1:3.35-418.ky10.noarch is already installed.
Package perl-Pod-Usage-4:1.69-418.ky10.noarch is already installed.
Package perl-Pod-Usage-help-4:1.69-418.ky10.noarch is already installed.
Package perl-Readonly-help-2.05-8.ky10.noarch is already installed.
Package perl-Role-Tiny-help-2.001004-2.ky10.noarch is already installed.
Package perl-SGMLSpm-1.03ii-45.ky10.noarch is already installed.
Package perl-SGMLSpm-help-1.03ii-45.ky10.noarch is already installed.
Package perl-SNMP_Session-help-1.13-20.ky10.noarch is already installed.
Package perl-Scalar-List-Utils-3:1.52-2.ky10.mips64el is already installed.
Package perl-Scalar-List-Utils-help-3:1.52-2.ky10.noarch is already installed.
Package perl-Socket-4:2.029-2.ky10.mips64el is already installed.
Package perl-Socket-MsgHdr-help-0.05-5.ky10.noarch is already installed.
Package perl-Socket-help-4:2.029-2.ky10.noarch is already installed.
Package perl-Socket6-help-0.28-9.ky10.mips64el is already installed.
Package perl-Software-License-help-0.103013-7.ky10.noarch is already installed.
Package perl-Storable-1:3.15-2.ky10.mips64el is already installed.
Package perl-Storable-help-1:3.15-2.ky10.noarch is already installed.
Package perl-String-ShellQuote-help-1.04-26.ky10.noarch is already installed.
Package perl-Sub-Exporter-Progressive-help-0.001013-8.ky10.noarch is already installed.
Package perl-Sub-Exporter-help-0.987-18.ky10.noarch is already installed.
Package perl-Sub-Install-help-0.928-18.ky10.noarch is already installed.
Package perl-Sub-Name-help-0.21-10.ky10.mips64el is already installed.
Package perl-Sub-Quote-help-2.005001-4.ky10.noarch is already installed.
Package perl-Sys-CPU-help-0.61-19.ky10.noarch is already installed.
Package perl-Sys-MemInfo-help-0.99-9.ky10.noarch is already installed.
Package perl-Sys-Syslog-0.35-420.ky10.mips64el is already installed.
Package perl-Sys-Syslog-help-0.35-420.ky10.noarch is already installed.
Package perl-Term-ANSIColor-4.06-511.ky10.noarch is already installed.
Package perl-Term-ANSIColor-help-4.06-511.ky10.noarch is already installed.
Package perl-Term-Cap-1.17-510.ky10.noarch is already installed.
Package perl-Term-Cap-help-1.17-510.ky10.noarch is already installed.
Package perl-TermReadKey-2.38-2.ky10.mips64el is already installed.
Package perl-TermReadKey-help-2.38-2.ky10.noarch is already installed.
Package perl-Test-Deep-help-1.128-4.ky10.noarch is already installed.
Package perl-Test-FailWarnings-help-0.008-15.ky10.noarch is already installed.
Package perl-Test-Fatal-help-0.014-13.ky10.noarch is already installed.
Package perl-Test-Harness-1:3.43_01-3.ky10.noarch is already installed.
Package perl-Test-Harness-help-1:3.43_01-3.ky10.noarch is already installed.
Package perl-Test-InDistDir-help-1.112071-10.ky10.noarch is already installed.
Package perl-Test-LeakTrace-help-0.16-10.ky10.noarch is already installed.
Package perl-Test-NoWarnings-help-1.04-17.ky10.noarch is already installed.
Package perl-Test-Pod-Coverage-help-1.10-14.ky10.noarch is already installed.
Package perl-Test-Pod-help-1.52-4.ky10.noarch is already installed.
Package perl-Test-Requires-help-0.10-15.ky10.noarch is already installed.
Package perl-Test-Simple-2:1.302140-3.ky10.noarch is already installed.
Package perl-Test-Simple-help-2:1.302140-3.ky10.noarch is already installed.
Package perl-Text-Balanced-2.03-420.ky10.noarch is already installed.
Package perl-Text-Balanced-help-2.03-420.ky10.noarch is already installed.
Package perl-Text-Diff-1.45-7.ky10.noarch is already installed.
Package perl-Text-Diff-help-1.45-7.ky10.noarch is already installed.
Package perl-Text-Glob-help-0.11-7.ky10.noarch is already installed.
Package perl-Text-ParseWords-3.30-419.ky10.noarch is already installed.
Package perl-Text-ParseWords-help-3.30-419.ky10.noarch is already installed.
Package perl-Text-Tabs+Wrap-2013.0523-419.ky10.noarch is already installed.
Package perl-Text-Tabs+Wrap-help-2013.0523-419.ky10.noarch is already installed.
Package perl-Text-Template-help-1.53-4.ky10.noarch is already installed.
Package perl-Text-WrapI18N-help-0.06-33.ky10.noarch is already installed.
Package perl-Thread-Queue-3.13-3.ky10.noarch is already installed.
Package perl-Thread-Queue-help-3.13-3.ky10.noarch is already installed.
Package perl-Time-HiRes-1.9760-2.ky10.mips64el is already installed.
Package perl-Time-HiRes-help-1.9760-2.ky10.noarch is already installed.
Package perl-Time-Local-2:1.280-6.ky10.noarch is already installed.
Package perl-Time-Local-help-2:1.280-6.ky10.noarch is already installed.
Package perl-TimeDate-help-1:2.30-17.ky10.noarch is already installed.
Package perl-Types-Serialiser-help-1.0-18.ky10.noarch is already installed.
Package perl-URI-help-1.76-3.ky10.noarch is already installed.
Package perl-Unicode-Collate-1.25-4.ky10.mips64el is already installed.
Package perl-Unicode-Collate-help-1.25-4.ky10.noarch is already installed.
Package perl-Unicode-Normalize-1.26-419.ky10.mips64el is already installed.
Package perl-Unicode-Normalize-help-1.26-419.ky10.noarch is already installed.
Package perl-Unicode-UTF8-help-0.62-8.ky10.noarch is already installed.
Package perl-XML-LibXML-help-1:2.0132-5.ky10.mips64el is already installed.
Package perl-XML-NamespaceSupport-help-1.12-7.ky10.noarch is already installed.
Package perl-XML-Parser-1:2.44-3.ky10.mips64el is already installed.
Package perl-XML-Parser-help-1:2.44-3.ky10.noarch is already installed.
Package perl-XML-SAX-Base-help-1.09-7.ky10.noarch is already installed.
Package perl-XML-SAX-help-1.00-5.ky10.noarch is already installed.
Package perl-XML-Writer-help-0.625-14.ky10.noarch is already installed.
Package perl-XML-XPath-help-1.42-6.ky10.noarch is already installed.
Package perl-YAML-Tiny-help-1.73-4.ky10.noarch is already installed.
Package perl-YAML-help-1.26-5.ky10.noarch is already installed.
Package perl-autodie-2.29-398.ky10.noarch is already installed.
Package perl-autodie-help-2.29-398.ky10.noarch is already installed.
Package perl-bignum-0.50-4.ky10.noarch is already installed.
Package perl-bignum-help-0.50-4.ky10.noarch is already installed.
Package perl-common-sense-help-3.7.4-14.ky10.noarch is already installed.
Package perl-constant-1.33-421.ky10.noarch is already installed.
Package perl-constant-help-1.33-421.ky10.noarch is already installed.
Package perl-devel-4:5.28.0-434.ky10.mips64el is already installed.
Package perl-experimental-0.020-2.ky10.noarch is already installed.
Package perl-experimental-help-0.020-2.ky10.noarch is already installed.
Package perl-gettext-help-1.07-13.ky10.noarch is already installed.
Package perl-inc-latest-help-2:0.500-12.ky10.noarch is already installed.
Package perl-libintl-perl-help-1.29-6.ky10.noarch is already installed.
Package perl-libnet-3.11-420.ky10.noarch is already installed.
Package perl-libnet-help-3.11-420.ky10.noarch is already installed.
Package perl-libs-4:5.28.0-434.ky10.mips64el is already installed.
Package perl-libwww-perl-help-6.35-2.ky10.noarch is already installed.
Package perl-libxml-perl-help-0.08-36.ky10.noarch is already installed.
Package perl-parent-1:0.237-4.ky10.noarch is already installed.
Package perl-parent-help-1:0.237-4.ky10.noarch is already installed.
Package perl-perlfaq-5.20180915-5.ky10.noarch is already installed.
Package perl-perlfaq-help-5.20180915-5.ky10.noarch is already installed.
Package perl-podlators-1:4.11-5.ky10.noarch is already installed.
Package perl-podlators-help-1:4.11-5.ky10.noarch is already installed.
Package perl-strictures-help-2.000006-7.ky10.noarch is already installed.
Package perl-threads-1:2.22-419.ky10.mips64el is already installed.
Package perl-threads-help-1:2.22-419.ky10.noarch is already installed.
Package perl-threads-shared-1.59-2.ky10.mips64el is already installed.
Package perl-threads-shared-help-1.59-2.ky10.noarch is already installed.
Package perl-version-8:0.99.24-3.ky10.mips64el is already installed.
Package perl-version-help-8:0.99.24-3.ky10.noarch is already installed.
Package make-1:4.2.1-15.ky10.mips64el is already installed.

创建mysql用户与用户组

[root@localhost /]# groupadd mysql
groupadd:“mysql”组已存在
[root@localhost /]# id mysql
用户id=27(mysql) 组id=27(mysql) 组=27(mysql)

创建并修改/mysqlsoft/mysql与/mysqldata/mysql目录权限

[root@localhost /]# mkdir -p /mysqlsoft/mysql
[root@localhost /]# mkdir -p /mysqldata/mysql
[root@localhost /]# chown -R mysql:mysql /mysqlsoft
[root@localhost /]# chown -R mysql:mysql /mysqldata
[root@localhost /]# chmod -R 775 /mysqlsoft
[root@localhost /]# chmod -R 775 /mysqldata

解压MySQL源码包

[root@localhost soft]# tar -zxvf  mysql-boost-5.7.39.tar.gz
[root@localhost soft]# ls -lrt
总用量 3643996
drwxr-xr-x 34 7161 31415       4096  6月  8 16:48 mysql-5.7.39
-rw-------  1 root root    53243335 11月 15 22:24 mysql-boost-5.7.39.tar.gz

编译安装

[root@localhost mysql-5.7.39]# cmake . -DCMAKE_INSTALL_PREFIX=/mysqlsoft/mysql  -DMYSQL_DATADIR=/mysqldata/mysql  -DSYSCONFDIR=/mysqlsoft/mysql/mysql.sock  -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/soft/mysql-5.7.39/boost/boost_1_59_0 -DWITH_INNOBASE_STORAGE_ENGINE=1  -DWITH_PARTITION_STORAGE_ENGINE=1  -DWITH_FEDERATED_STORAGE_ENGINE=1  -DWITH_BLACKHOLE_STORAGE_ENGINE=1  -DWITH_MYISAM_STORAGE_ENGINE=1  -DENABLED_LOCAL_INFILE=1  -DENABLE_DTRACE=0  -DDEFAULT_CHARSET=utf8mb4  -DDEFAULT_COLLATION=utf8mb4_general_ci  -DWITH_EMBEDDED_SERVER=1
CMake Deprecation Warning at CMakeLists.txt:35 (CMAKE_POLICY):
  The OLD behavior for policy CMP0018 will be removed from a future version
  of CMake.

  The cmake-policies(7) manual explains that the OLD behaviors of all
  policies are deprecated and that a policy should be set to OLD only under
  specific short-term circumstances.  Projects should be ported to the NEW
  behavior and not rely on setting a policy to OLD.


CMake Deprecation Warning at CMakeLists.txt:41 (CMAKE_POLICY):
  The OLD behavior for policy CMP0022 will be removed from a future version
  of CMake.

  The cmake-policies(7) manual explains that the OLD behaviors of all
  policies are deprecated and that a policy should be set to OLD only under
  specific short-term circumstances.  Projects should be ported to the NEW
  behavior and not rely on setting a policy to OLD.


CMake Deprecation Warning at CMakeLists.txt:48 (CMAKE_POLICY):
  The OLD behavior for policy CMP0045 will be removed from a future version
  of CMake.

  The cmake-policies(7) manual explains that the OLD behaviors of all
  policies are deprecated and that a policy should be set to OLD only under
  specific short-term circumstances.  Projects should be ported to the NEW
  behavior and not rely on setting a policy to OLD.


CMake Deprecation Warning at CMakeLists.txt:49 (CMAKE_POLICY):
  The OLD behavior for policy CMP0042 will be removed from a future version
  of CMake.

  The cmake-policies(7) manual explains that the OLD behaviors of all
  policies are deprecated and that a policy should be set to OLD only under
  specific short-term circumstances.  Projects should be ported to the NEW
  behavior and not rely on setting a policy to OLD.


-- Running cmake version 3.12.1
-- Found Git: /usr/bin/git (found version "2.27.0")
-- Configuring with MAX_INDEXES = 64U
CMake Warning (dev) at CMakeLists.txt:146 (PROJECT):
  Policy CMP0048 is not set: project() command manages VERSION variables.
  Run "cmake --help-policy CMP0048" for policy details.  Use the cmake_policy
  command to set the policy and suppress this warning.

  The following variable(s) would be set to empty:

    CMAKE_PROJECT_VERSION
    CMAKE_PROJECT_VERSION_MAJOR
    CMAKE_PROJECT_VERSION_MINOR
    CMAKE_PROJECT_VERSION_PATCH
This warning is for project developers.  Use -Wno-dev to suppress it.

-- CMAKE_GENERATOR: Unix Makefiles
-- SIZEOF_VOIDP 8
-- MySQL 5.7.39
-- Packaging as: mysql-5.7.39-Linux-mips64el
-- DTRACE is disabled
-- Local boost dir /soft/mysql-5.7.39/boost/boost_1_59_0
-- Found /soft/mysql-5.7.39/boost/boost_1_59_0/boost/version.hpp
-- BOOST_VERSION_NUMBER is #define BOOST_VERSION 105900
-- BOOST_INCLUDE_DIR /soft/mysql-5.7.39/boost/boost_1_59_0
-- NUMA library missing or required version not available
-- ZLIB_VERSION (bundled) is 1.2.12
-- ZLIB_INCLUDE_DIR /soft/mysql-5.7.39/extra/zlib/zlib-1.2.12
-- ZLIB_LIBRARY zlib
-- OPENSSL_INCLUDE_DIR = /usr/include
-- OPENSSL_LIBRARY = /usr/lib64/libssl.so
-- CRYPTO_LIBRARY = /usr/lib64/libcrypto.so
-- OPENSSL_MAJOR_VERSION = 1
-- OPENSSL_MINOR_VERSION = 01
-- OPENSSL_FIX_VERSION = 01
-- SSL_LIBRARIES = /usr/lib64/libssl.so;/usr/lib64/libcrypto.so;dl
-- AWK_EXECUTABLE is /usr/bin/gawk
-- Found Git: /usr/bin/git
-- LIBEVENT_VERSION_STRING 2.1.11-stable
-- LIBEVENT_VERSION (bundled) 2.1.11
-- WITH_PROTOBUF=bundled
-- protobuf version is 2.6
-- You need to set WITH_CURL. This variable needs to point to curl library.
-- Creating LDAP authentication SASL client library.
-- Required SASL header is missing.Skipping the LDAP SASL client authentication plugin.
-- Library mysqlclient depends on OSLIBS -lpthread;m;rt;/usr/lib64/libssl.so;/usr/lib64/libcrypto.so;dl
-- MERGE_CONVENIENCE_LIBRARIES TARGET mysqlclient
-- MERGE_CONVENIENCE_LIBRARIES LIBS clientlib;dbug;strings;vio;mysys;mysys_ssl;zlib
-- MERGE_CONVENIENCE_LIBRARIES MYLIBS clientlib;dbug;strings;vio;mysys;mysys_ssl;zlib
-- RPC_INCLUDE_DIRS /usr/include/tirpc
-- Using Boost headers from /soft/mysql-5.7.39/boost/boost_1_59_0
-- Performing Test CXX_HAVE_SIGN_COMPARE
-- Performing Test CXX_HAVE_SIGN_COMPARE - Success
-- Performing Test CXX_HAVE_UNUSED_VARIABLE
-- Performing Test CXX_HAVE_UNUSED_VARIABLE - Success
-- MYSQLX - Text log of protobuf messages enabled
-- Performing Test HAVE_UNUSED_PARAMETER
-- Performing Test HAVE_UNUSED_PARAMETER - Success
-- Googletest was not found. gtest-based unit tests will be disabled. You can run cmake . -DENABLE_DOWNLOADS=1 to automatically download and build required components from source.
-- If you are inside a firewall, you may need to use an https proxy: export https_proxy=http://example.com:80
-- Performing Test HAVE_MISLEADING_INDENTATION
-- Performing Test HAVE_MISLEADING_INDENTATION - Success
-- Performing Test HAVE_NO_BUILTIN_MEMCMP
-- Performing Test HAVE_NO_BUILTIN_MEMCMP - Success
-- executable target mysqld debug_target /soft/debug/sql/mysqld
CMake Warning at cmake/bison.cmake:27 (MESSAGE):
  Bison executable not found in PATH
Call Stack (most recent call first):
  sql/CMakeLists.txt:603 (INCLUDE)


CMake Warning at cmake/bison.cmake:27 (MESSAGE):
  Bison executable not found in PATH
Call Stack (most recent call first):
  libmysqld/CMakeLists.txt:215 (INCLUDE)


-- Library mysqlserver depends on OSLIBS -lpthread;m;rt;/usr/lib64/libssl.so;/usr/lib64/libcrypto.so;dl;crypt
-- MERGE_CONVENIENCE_LIBRARIES TARGET mysqlserver
-- MERGE_CONVENIENCE_LIBRARIES LIBS dbug;strings;regex;mysys;mysys_ssl;vio;zlib;/usr/lib64/libssl.so;/usr/lib64/libcrypto.so;dl;crypt;archive_embedded;blackhole_embedded;csv_embedded;federated_embedded;heap_embedded;innobase_embedded;lz4_lib;myisam_embedded;myisammrg_embedded;partition_embedded;ngram_parser_embedded;sql_embedded
-- MERGE_CONVENIENCE_LIBRARIES MYLIBS dbug;strings;regex;mysys;mysys_ssl;vio;zlib;archive_embedded;blackhole_embedded;csv_embedded;federated_embedded;heap_embedded;innobase_embedded;lz4_lib;myisam_embedded;myisammrg_embedded;partition_embedded;ngram_parser_embedded;sql_embedded
-- library target mysqlserver debug_target /soft/debug/archive_output_directory/libmysqld.a
-- INSTALL mysqlclient.pc lib/pkgconfig
-- Skipping deb packaging on unsupported platform .
-- CMAKE_BUILD_TYPE: RelWithDebInfo
-- COMPILE_DEFINITIONS: _GNU_SOURCE;_FILE_OFFSET_BITS=64;HAVE_CONFIG_H;HAVE_TLSv13
-- CMAKE_C_FLAGS: -fPIC -fabi-version=2 -fno-omit-frame-pointer -fno-strict-aliasing -ffp-contract=off  -Wall -Wextra -Wformat-security -Wvla -Wimplicit-fallthrough=2 -Wwrite-strings -Wdeclaration-after-statement
-- CMAKE_CXX_FLAGS: -fPIC -std=gnu++03 -fabi-version=2 -fno-omit-frame-pointer -fno-strict-aliasing -ffp-contract=off  -Wall -Wextra -Wformat-security -Wvla -Wimplicit-fallthrough=2 -Woverloaded-virtual -Wno-unused-parameter
-- CMAKE_CXX_FLAGS_DEBUG: -DENABLED_DEBUG_SYNC -DSAFE_MUTEX
-- CMAKE_CXX_FLAGS_RELWITHDEBINFO: -ffunction-sections -fdata-sections
-- CMAKE_CXX_FLAGS_RELEASE: -ffunction-sections -fdata-sections
-- CMAKE_CXX_FLAGS_MINSIZEREL: -ffunction-sections -fdata-sections
-- CMAKE_C_LINK_FLAGS:
-- CMAKE_CXX_LINK_FLAGS:
-- CMAKE_EXE_LINKER_FLAGS
-- CMAKE_MODULE_LINKER_FLAGS
-- CMAKE_SHARED_LINKER_FLAGS
-- Configuring done
-- Generating done
-- Build files have been written to: /soft/mysql-5.7.39




[root@localhost mysql-5.7.39]# make -j 4


[root@localhost mysql-5.7.39]# make install

-- Installing: /mysqlsoft/mysql/mysql-test/./std_data/funcs_1/memory_tb3.txt
-- Installing: /mysqlsoft/mysql/mysql-test/./std_data/funcs_1/myisam_tb3.txt
-- Installing: /mysqlsoft/mysql/mysql-test/./std_data/funcs_1/ndb_tb3.txt
-- Installing: /mysqlsoft/mysql/mysql-test/./std_data/funcs_1/t3.txt
-- Installing: /mysqlsoft/mysql/mysql-test/./std_data/funcs_1/myisam_tb2.txt
-- Installing: /mysqlsoft/mysql/mysql-test/./std_data/funcs_1/myisam_tb4.txt
-- Installing: /mysqlsoft/mysql/mysql-test/./std_data/funcs_1/memory_tb4.txt
-- Installing: /mysqlsoft/mysql/mysql-test/./std_data/funcs_1/memory_tb2.txt
-- Installing: /mysqlsoft/mysql/mysql-test/./std_data/server8k-cert.pem
-- Installing: /mysqlsoft/mysql/mysql-test/./std_data/latin1.xml
-- Installing: /mysqlsoft/mysql/mysql-test/./std_data/bug16266.000001
-- Installing: /mysqlsoft/mysql/mysql-test/./std_data/replicated-bin.index
-- Installing: /mysqlsoft/mysql/mysql-test/./std_data/.mylogin.cnf
-- Installing: /mysqlsoft/mysql/mysql-test/./std_data/slave-relay-bin.000001
-- Installing: /mysqlsoft/mysql/mysql-test/./std_data/wl6219_55_innodb.frm
-- Installing: /mysqlsoft/mysql/mysql-test/./std_data/data_50722.zip
-- Installing: /mysqlsoft/mysql/mysql-test/./std_data/bug46565.ARZ
-- Installing: /mysqlsoft/mysql/mysql-test/./std_data/server-key-verify-pass.pem
-- Installing: /mysqlsoft/mysql/mysql-test/./std_data/server-key.pem
-- Installing: /mysqlsoft/mysql/mysql-test/./std_data/bug46565.frm
-- Installing: /mysqlsoft/mysql/mysql-test/./std_data/bug37631.MYI
-- Installing: /mysqlsoft/mysql/mysql-test/./std_data/server-cert-verify-fail.pem
-- Installing: /mysqlsoft/mysql/mysql-test/./std_data/bug21542698.dat
-- Installing: /mysqlsoft/mysql/mysql-test/./std_data/loaddata7.dat
-- Installing: /mysqlsoft/mysql/mysql-test/./std_data/expired-ca.pem
-- Installing: /mysqlsoft/mysql/mysql-test/./std_data/binlog_truncated_event.000001
-- Installing: /mysqlsoft/mysql/mysql-test/./std_data/loaddata_pair.dat
-- Installing: /mysqlsoft/mysql/./README-test
-- Up-to-date: /mysqlsoft/mysql/mysql-test/mtr
-- Up-to-date: /mysqlsoft/mysql/mysql-test/mysql-test-run
-- Installing: /mysqlsoft/mysql/mysql-test/lib/My/SafeProcess/my_safe_process
-- Up-to-date: /mysqlsoft/mysql/mysql-test/lib/My/SafeProcess/my_safe_process
-- Installing: /mysqlsoft/mysql/mysql-test/lib/My/SafeProcess/Base.pm
-- Installing: /mysqlsoft/mysql/support-files/mysqld_multi.server
-- Installing: /mysqlsoft/mysql/support-files/mysql-log-rotate
-- Installing: /mysqlsoft/mysql/support-files/magic
-- Installing: /mysqlsoft/mysql/share/aclocal/mysql.m4
-- Installing: /mysqlsoft/mysql/support-files/mysql.server

配置mysql参数,只是设置几个简单的mysql运行参数

[mysql@localhost mysql]$ cat my.cnf
[mysqld]
basedir=/mysqlsoft/mysql
datadir=/mysqldata/mysql
bind-address=0.0.0.0
user=mysql
port=3306
log-error=/mysqldata/mysql/mysql.err
pid-file=/mysqldata/mysql/mysqld.pid
socket = /mysqlsoft/mysql/mysql.sock
character-set-server=utf8mb4
default-storage-engine=INNODB
explicit_defaults_for_timestamp = true
########innodb settings########
innodb_page_size = 8192
innodb_buffer_pool_size = 4G
innodb_buffer_pool_instances = 2
innodb_buffer_pool_load_at_startup = 1
innodb_buffer_pool_dump_at_shutdown = 1
innodb_lru_scan_depth = 2000
innodb_lock_wait_timeout = 5
innodb_io_capacity = 4000
innodb_io_capacity_max = 8000
innodb_flush_method = O_DIRECT
innodb_file_format = Barracuda
innodb_file_format_max = Barracuda
innodb_log_group_home_dir =/msyqldata/redolog/
innodb_undo_directory =/mysqldata/undolog/
innodb_undo_logs = 128
innodb_undo_tablespaces = 3
innodb_flush_nei***ors = 1
innodb_log_file_size = 1G
innodb_log_buffer_size = 16777216
innodb_purge_threads = 4
innodb_large_prefix = 1
innodb_thread_concurrency = 64
innodb_print_all_deadlocks = 1
innodb_strict_mode = 1
innodb_sort_buffer_size = 67108864

[root@localhost bin]# ./mysqld  --defaults-file=/mysqlsoft/mysql/my.cnf --initialize --basedir=/mysqlsoft/mysql --datadir=/mysqldata/mysql --user=mysql

[mysql@localhost mysql]$ tail -f mysql.err
 100 200 300 400 500 600 700 800 900 1000
 100 200 300 400 500 600 700 800 900 1000
2022-11-18T13:26:36.602330Z 0 [Warning] InnoDB: New log files created, LSN=39537
2022-11-18T13:26:36.741745Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2022-11-18T13:26:36.806980Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: a0976fe4-6744-11ed-8ede-0023a0002161.
2022-11-18T13:26:36.809665Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2022-11-18T13:26:37.348420Z 0 [Warning] A deprecated TLS version TLSv1 is enabled. Please use TLSv1.2 or higher.
2022-11-18T13:26:37.348462Z 0 [Warning] A deprecated TLS version TLSv1.1 is enabled. Please use TLSv1.2 or higher.
2022-11-18T13:26:37.350930Z 0 [Warning] CA certificate ca.pem is self signed.
2022-11-18T13:26:37.589677Z 1 [Note] A temporary password is generated for root@localhost: KuOS*vY&V1Dx


其中[Note] A temporary password is generated for root@localhost:后面跟的是mysql数据库登录的临时密码,各人安装生成的临时密码不一样。可以看到到日志文件没有报错,而且有了临时密码,表示初始化成功。

如果想服务能够部署自动支持安全连接,使用mysql_ssl_rsa_setup工具来创建缺省SSL与RSA文件

[root@localhost bin]#  ./mysql_ssl_rsa_setup --datadir=/mysqldata/mysql

配置环境变量

[root@localhost /]# vi /etc/profile
export MYSQL_HOME=/mysqlsoft/mysql/
export PATH=$PATH:$MYSQL_HOME/bin

[root@localhost /]# vi /etc/profile
[root@localhost /]# source /etc/profile

配置自动启动MySQL

[root@localhost /]# cp /mysqlsoft/mysql/support-files/mysql.server  /etc/init.d/mysqld
[root@localhost /]# chmod 755 /etc/init.d/mysqld
[root@localhost ~]# systemctl enable mysqld
mysqld.service is not a native service, redirecting to /sbin/chkconfig.
Executing /sbin/chkconfig mysqld on

启动MySQL

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

登录MySQL并修改root用户密码

[root@localhost tmp]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.39

Copyright (c) 2000, 2022, Oracle and/or its affiliates.

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

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

mysql>
]]>
http://www.jydba.net/index.php/archives/3443/feed 0
benchmarksql 5.0压测MySQL http://www.jydba.net/index.php/archives/3439 http://www.jydba.net/index.php/archives/3439#respond Fri, 09 Dec 2022 00:15:55 +0000 http://www.jydba.net/?p=3439 在Oracle Linux 7.6使用benchmarksql 5.0压测MySQL 5.7

一.下载&编译安装

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

[root@localhost /]# java -version
java version "1.7.0_75"
OpenJDK Runtime Environment (rhel-2.5.4.2.0.1.el7_0-x86_64 u75-b13)
OpenJDK 64-Bit Server VM (build 24.75-b04, mixed mode)

因为自带jdk存储在/usr/lib/jvm下,需要将其删除。

[root@localhost lib]# mv jvm jvmold
[root@localhost lib]# java -version
-bash: /usr/bin/java: ???

2.安装JDK1.8

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

[root@localhost /]# mkdir /usr/java
[root@localhost /]# mv jdk1.8.0_131 /usr/java/
[root@localhost /]# vi /etc/profile
....
export JAVA_HOME=/usr/java/jdk1.8.0_131
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib:$CLASSPATH
export JAVA_PATH=${JAVA_HOME}/bin:${JRE_HOME}/bin
export PATH=$PATH:${JAVA_PATH}

[root@localhost /]# source /etc/profile
[root@localhost /]# java -version
java version "1.8.0_131"
Java(TM) SE Runtime Environment (build 1.8.0_131-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)

[root@localhost /]# unzip benchmarksql-5.0.zip
[root@localhost /]# cd benchmarksql-5.0/

修改benchmarksql源码

修改jTPCCConfig.java文件

[root@localhost benchmarksql-5.0]# vi src/client/jTPCCConfig.java
/*
* jTPCCConfig - Basic configuration parameters for jTPCC
*
* Copyright (C) 2003, Raul Barbosa
* Copyright (C) 2004-2016, Denis Lussier
* Copyright (C) 2016, Jan Wieck
*
*/

import java.text.*;

public interface jTPCCConfig
{
public final static String JTPCCVERSION = "5.0";

public final static int DB_UNKNOWN = 0,
DB_FIREBIRD = 1,
DB_ORACLE = 2,
DB_POSTGRES = 3,
DB_MYSQL =4;

public final static int NEW_ORDER = 1,
PAYMENT = 2,
ORDER_STATUS = 3,
DELIVERY = 4,
STOCK_LEVEL = 5;

public final static String[] nameTokens = {"BAR", "OUGHT", "ABLE", "PRI", "PRES", "ESE", "ANTI", "CALLY", "ATION", "EING"};

public final static SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

public final static int configCommitCount = 10000; // commit every n records in LoadData

public final static int configWhseCount = 10;
public final static int configItemCount = 100000; // tpc-c std = 100,000
public final static int configDistPerWhse = 10; // tpc-c std = 10
public final static int configCustPerDist = 3000; // tpc-c std = 3,000
}

修改benchmarksql-5.0/src/client/jTPCC.java,增加mysql相关部分

[root@localhost benchmarksql-5.0]# vi src/client/jTPCC.java
/*
* jTPCC - Open Source Java implementation of a TPC-C like benchmark
*
* Copyright (C) 2003, Raul Barbosa
* Copyright (C) 2004-2016, Denis Lussier
* Copyright (C) 2016, Jan Wieck
*
*/

import org.apache.log4j.*;

import java.io.*;
import java.nio.file.*;
import java.sql.*;
import java.util.*;
import java.util.regex.Pattern;
import java.text.*;

public class jTPCC implements jTPCCConfig
{
private static org.apache.log4j.Logger log = Logger.getLogger(jTPCC.class);
private static String resultDirName = null;
private static BufferedWriter resultCSV = null;
private static BufferedWriter runInfoCSV = null;
private static int runID = 0;

private int dbType = DB_UNKNOWN;
private int currentlyDisplayedTerminal;

private jTPCCTerminal[] terminals;
private String[] terminalNames;
private boolean terminalsBlockingExit = false;
private long terminalsStarted = 0, sessionCount = 0, transactionCount = 0;
private Object counterLock = new Object();

private long newOrderCounter = 0, sessionStartTimestamp, sessionEndTimestamp, sessionNextTimestamp=0, sessionNextKounter=0;
private long sessionEndTargetTime = -1, fastNewOrderCounter, recentTpmC=0, recentTpmTotal=0;
private boolean signalTerminalsRequestEndSent = false, databaseDriverLoaded = false;

private FileOutputStream fileOutputStream;
private PrintStream printStreamReport;
private String sessionStart, sessionEnd;
private int limPerMin_Terminal;

private double tpmC;
private jTPCCRandom rnd;
private OSCollector osCollector = null;

public static void main(String args[])
{
PropertyConfigurator.configure("log4j.properties");
new jTPCC();
}

private String getProp (Properties p, String pName)
{
String prop = p.getProperty(pName);
log.info("Term-00, " + pName + "=" + prop);
return(prop);
}

public jTPCC()
{

// load the ini file
Properties ini = new Properties();
try {
ini.load( new FileInputStream(System.getProperty("prop")));
} catch (IOException e) {
errorMessage("Term-00, could not load properties file");
}

log.info("Term-00, ");
log.info("Term-00, +-------------------------------------------------------------+");
log.info("Term-00, BenchmarkSQL v" + JTPCCVERSION);
log.info("Term-00, +-------------------------------------------------------------+");
log.info("Term-00, (c) 2003, Raul Barbosa");
log.info("Term-00, (c) 2004-2016, Denis Lussier");
log.info("Term-00, (c) 2016, Jan Wieck");
log.info("Term-00, +-------------------------------------------------------------+");
log.info("Term-00, ");
String iDB = getProp(ini,"db");
String iDriver = getProp(ini,"driver");
String iConn = getProp(ini,"conn");
String iUser = getProp(ini,"user");
String iPassword = ini.getProperty("password");

log.info("Term-00, ");
String iWarehouses = getProp(ini,"warehouses");
String iTerminals = getProp(ini,"terminals");

String iRunTxnsPerTerminal = ini.getProperty("runTxnsPerTerminal");
String iRunMins = ini.getProperty("runMins");
if (Integer.parseInt(iRunTxnsPerTerminal) ==0 && Integer.parseInt(iRunMins)!=0){
log.info("Term-00, runMins" + "=" + iRunMins);
}else if(Integer.parseInt(iRunTxnsPerTerminal) !=0 && Integer.parseInt(iRunMins)==0){
log.info("Term-00, runTxnsPerTerminal" + "=" + iRunTxnsPerTerminal);
}else{
errorMessage("Term-00, Must indicate either transactions per terminal or number of run minutes!");
};
String limPerMin = getProp(ini,"limitTxnsPerMin");
String iTermWhseFixed = getProp(ini,"terminalWarehouseFixed");
log.info("Term-00, ");
String iNewOrderWeight = getProp(ini,"newOrderWeight");
String iPaymentWeight = getProp(ini,"paymentWeight");
String iOrderStatusWeight = getProp(ini,"orderStatusWeight");
String iDeliveryWeight = getProp(ini,"deliveryWeight");
String iStockLevelWeight = getProp(ini,"stockLevelWeight");

log.info("Term-00, ");
String resultDirectory = getProp(ini, "resultDirectory");
String osCollectorScript = getProp(ini, "osCollectorScript");

log.info("Term-00, ");

if (iDB.equals("firebird"))
dbType = DB_FIREBIRD;
else if (iDB.equals("oracle"))
dbType = DB_ORACLE;
else if (iDB.equals("postgres"))
dbType = DB_POSTGRES;
else if (iDB.equals("mysql"))
dbType = DB_MYSQL;
else
{
log.error("unknown database type '" + iDB + "'");
return;

修改benchmarksql-5.0/src/client/jTPCCConnection.java, SQL子查询增加”AS L”别名,如下所示:

[root@localhost benchmarksql-5.0]# vi src/client/jTPCCConnection.java
switch (dbType)
{
case jTPCCConfig.DB_POSTGRES:
stmtStockLevelSelectLow = dbConn.prepareStatement(
"SELECT count(*) AS low_stock FROM (" +
" SELECT s_w_id, s_i_id, s_quantity " +
" FROM bmsql_stock " +
" WHERE s_w_id = ? AND s_quantity < ? AND s_i_id IN (" +
" SELECT ol_i_id " +
" FROM bmsql_district " +
" JOIN bmsql_order_line ON ol_w_id = d_w_id " +
" AND ol_d_id = d_id " +
" AND ol_o_id >= d_next_o_id - 20 " +
" AND ol_o_id < d_next_o_id " +
" WHERE d_w_id = ? AND d_id = ? " +
" ) " +
" ) AS L");
break;

default:
stmtStockLevelSelectLow = dbConn.prepareStatement(
"SELECT count(*) AS low_stock FROM (" +
" SELECT s_w_id, s_i_id, s_quantity " +
" FROM bmsql_stock " +
" WHERE s_w_id = ? AND s_quantity < ? AND s_i_id IN (" +
" SELECT ol_i_id " +
" FROM bmsql_district " +
" JOIN bmsql_order_line ON ol_w_id = d_w_id " +
" AND ol_d_id = d_id " +
" AND ol_o_id >= d_next_o_id - 20 " +
" AND ol_o_id < d_next_o_id " +
" WHERE d_w_id = ? AND d_id = ? " +
" ) " +
" )AS L"); // " )");
break;
}

[root@localhost benchmarksql-5.0]# ant
Buildfile: /benchmarksql-5.0/build.xml

init:
[mkdir] Created dir: /benchmarksql-5.0/build

compile:
[javac] Compiling 11 source files to /benchmarksql-5.0/build
[javac] /benchmarksql-5.0/src/client/jTPCCRandom.java:143: : EUC_CN [javac] * be able to represent 128 different characters. '#@!%%???'
[javac] ^
[javac] /benchmarksql-5.0/src/client/jTPCCRandom.java:143: : EUC_CN [javac] * be able to represent 128 different characters. '#@!%%???'
[javac] ^
[javac] /benchmarksql-5.0/src/client/jTPCCRandom.java:143: : EUC_CN [javac] * be able to represent 128 different characters. '#@!%%???'
[javac] ^
[javac] 3

BUILD FAILED
/benchmarksql-5.0/build.xml:24: Compile failed; see the compiler error output for details.

Total time: 1 second

修改字符集

[root@localhost benchmarksql-5.0]# cat /etc/oracle-release
Oracle Linux Server release 7.6
[root@localhost benchmarksql-5.0]# locale
LANG=zh_CN.gb2312
LC_CTYPE="zh_CN.gb2312"
LC_NUMERIC="zh_CN.gb2312"
LC_TIME="zh_CN.gb2312"
LC_COLLATE="zh_CN.gb2312"
LC_MONETARY="zh_CN.gb2312"
LC_MESSAGES="zh_CN.gb2312"
LC_PAPER="zh_CN.gb2312"
LC_NAME="zh_CN.gb2312"
LC_ADDRESS="zh_CN.gb2312"
LC_TELEPHONE="zh_CN.gb2312"
LC_MEASUREMENT="zh_CN.gb2312"
LC_IDENTIFICATION="zh_CN.gb2312"
LC_ALL=
[root@localhost benchmarksql-5.0]# cat /etc/sysconfig/i18n
cat: /etc/sysconfig/i18n: ???
[root@localhost benchmarksql-5.0]# cat cat /etc/locale.conf
cat: cat: ???
#LANG="en_US.UTF-8"
LANG="zh_CN.gb2312"
[root@localhost benchmarksql-5.0]# cat /etc/locale.conf
#LANG="en_US.UTF-8"
LANG="zh_CN.gb2312"
[root@localhost benchmarksql-5.0]# vi /etc/locale.conf
LANG="en_US.UTF-8"
#LANG="zh_CN.gb2312"

[root@localhost benchmarksql-5.0]# ant
Buildfile: /benchmarksql-5.0/build.xml

init:

compile:
[javac] Compiling 11 source files to /benchmarksql-5.0/build

dist:
[mkdir] Created dir: /benchmarksql-5.0/dist
[jar] Building jar: /benchmarksql-5.0/dist/BenchmarkSQL-5.0.jar

BUILD SUCCESSFUL
Total time: 2 seconds

添加mysql java connector驱动,mysql-connector-java-5.1.49.zip 需自行下载。

[root@localhost benchmarksql-5.0]# cd lib
[root@localhost lib]# ls
apache-log4j-extras-1.1.jar firebird log4j-1.2.17.jar oracle postgres
[root@localhost lib]# ls -lrt
total 820
drwxr-xr-x. 2 root root 43 May 26 2016 postgres
drwxr-xr-x. 2 root root 40 May 26 2016 oracle
-rwxr-xr-x. 1 root root 489883 May 26 2016 log4j-1.2.17.jar
drwxr-xr-x. 2 root root 58 May 26 2016 firebird
-rwxr-xr-x. 1 root root 346729 May 26 2016 apache-log4j-extras-1.1.jar
[root@localhost lib]# mkdir mysql

[root@localhost /]# unzip mysql-connector-java-5.1.49.zip

[root@localhost mysql-connector-java-5.1.49]# cp mysql-connector-java-5.1.49.jar /benchmarksql-5.0/lib/mysql/

[root@localhost mysql]# pwd
/benchmarksql-5.0/lib/mysql
[root@localhost mysql]# ls -lrt
total 984
-rw-r--r--. 1 root root 1006904 Nov 11 16:39 mysql-connector-java-5.1.49.jar

修改benchmarksql-5.0/run/runDatabaseBuild.sh,去掉extraHistID

[root@localhost benchmarksql-5.0]# vi run/runDatabaseBuild.sh
#!/bin/sh

if [ $# -lt 1 ] ; then
echo "usage: $(basename $0) PROPS [OPT VAL [...]]" >&2
exit 2
fi

PROPS="$1"
shift
if [ ! -f "${PROPS}" ] ; then
echo "${PROPS}: no such file or directory" >&2
exit 1
fi
DB="$(grep '^db=' $PROPS | sed -e 's/^db=//')"

BEFORE_LOAD="tableCreates"
#AFTER_LOAD="indexCreates foreignKeys extraHistID buildFinish"
AFTER_LOAD="indexCreates foreignKeys buildFinish"

for step in ${BEFORE_LOAD} ; do
./runSQL.sh "${PROPS}" $step
done

./runLoader.sh "${PROPS}" $*

for step in ${AFTER_LOAD} ; do
./runSQL.sh "${PROPS}" $step
done

修改funcs.sh 增加 mysql 数据库类型的驱动类文件目录。

[root@localhost benchmarksql-5.0]# vi run/funcs.sh
# ----
# $1 is the properties file
# ----
PROPS=$1
if [ ! -f ${PROPS} ] ; then
echo "${PROPS}: no such file" >&2
exit 1
fi

# ----
# getProp()
#
# Get a config value from the properties file.
# ----
function getProp()
{
grep "^${1}=" ${PROPS} | sed -e "s/^${1}=//"
}

# ----
# getCP()
#
# Determine the CLASSPATH based on the database system.
# ----
function setCP()
{
case "$(getProp db)" in
firebird)
cp="../lib/firebird/*:../lib/*"
;;
oracle)
cp="../lib/oracle/*"
if [ ! -z "${ORACLE_HOME}" -a -d ${ORACLE_HOME}/lib ] ; then
cp="${cp}:${ORACLE_HOME}/lib/*"
fi
cp="${cp}:../lib/*"
;;
postgres)
cp="../lib/postgres/*:../lib/*"
;;
mysql)
cp="../lib/mysql/*:../lib/*"
;;
esac
myCP=".:${cp}:../dist/*"
export myCP
}

# ----
# Make sure that the properties file does have db= and the value
# is a database, we support.
# ----
case "$(getProp db)" in
firebird|oracle|postgres|mysql)
;;
"") echo "ERROR: missing db= config option in ${PROPS}" >&2
exit 1
;;
*) echo "ERROR: unsupported database type 'db=$(getProp db)' in ${PROPS}" >&2
exit 1
;;
esac
"run/funcs.sh" 63L, 1177C written

配置测试文件,输入连接地址与用户名

[root@localhost run]# vi props.mysql
db=mysql
driver=com.mysql.jdbc.Driver
conn=jdbc:mysql://127.0.0.1:3306/test?useServerPrepStmts=true&useConfigs=maxPerformance&rewriteBatchedStatements=true
user=root
password=xxzx7817600
warehouses=100
loadWorkers=40
terminals=32
//To run specified transactions per terminal- runMins must equal zero
runTxnsPerTerminal=0
//To run for specified minutes- runTxnsPerTerminal must equal zero
runMins=10
//Number of total transactions per minute
limitTxnsPerMin=0
//Set to true to run in 4.x compatible mode. Set to false to use the
//entire configured database evenly.
terminalWarehouseFixed=true
//The following five values must add up to 100
//The default percentages of 45, 43, 4, 4 & 4 match the TPC-C spec
newOrderWeight=45
paymentWeight=43
orderStatusWeight=4
deliveryWeight=4
stockLevelWeight=4
// Directory name to create for collecting detailed result data.
// Comment this out to suppress.
resultDirectory=my_result_%tY-%tm-%td_%tH%tM%tS
osCollectorScript=./misc/os_collector_linux.py
osCollectorInterval=1
//osCollectorSSHAddr=user@dbhost
//osCollectorDevices=net_eth0 blk_sda

[mysql@localhost run]$ ./runDatabaseBuild.sh prop.mysql
# ------------------------------------------------------------
# Loading SQL file ./sql.common/tableCreates.sql
# ------------------------------------------------------------
Fri Nov 11 16:57:18 CST 2022 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
Unknown database 'benchmarksql'
Starting BenchmarkSQL LoadData

driver=com.mysql.jdbc.Driver
conn=jdbc:mysql://127.0.0.1:3306/test?useServerPrepStmts=true&useConfigs=maxPerformance&rewriteBatchedStatements=true
user=root
password=***********
warehouses=100
loadWorkers=40
fileLocation (not defined)
csvNullValue (not defined - using default 'NULL')

Fri Nov 11 16:57:19 CST 2022 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
ERROR: Unknown database 'benchmarksql'
# ------------------------------------------------------------
# Loading SQL file ./sql.common/indexCreates.sql
# ------------------------------------------------------------
Fri Nov 11 16:57:20 CST 2022 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
Unknown database 'benchmarksql'
# ------------------------------------------------------------
# Loading SQL file ./sql.common/foreignKeys.sql
# ------------------------------------------------------------
Fri Nov 11 16:57:22 CST 2022 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
Unknown database 'benchmarksql'
# ------------------------------------------------------------
# Loading SQL file ./sql.common/buildFinish.sql
# ------------------------------------------------------------
Fri Nov 11 16:57:23 CST 2022 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
Unknown database 'benchmarksql'

不建议在没有服务器身份验证的情况下建立SSL连接。根据MySQL 5.5。45+, 5.6.26+和5.7。6+要求如果未设置显式选项,默认情况下必须建立SSL连接。为了符合不使用SSL的现有应用程序,verifyServerCertificate属性设置为“false”。您需要通过设置useSSL=false显式禁用SSL,或者设置useSSL=true并为服务器证书验证提供信任库。

解决方案:
在url后面加上?useSSL=false即可

jdbc:mysql://localhost:3306/userDb?useSSL=false
----------------
[mysql@localhost run]$ vi prop.mysql
db=mysql
driver=com.mysql.jdbc.Driver
conn=jdbc:mysql://127.0.0.1:3306/test?useSSL=false&useServerPrepStmts=true&useConfigs=maxPerformance&rewriteBatchedStatements=true
user=root
password=xxzx7817600
warehouses=100
loadWorkers=40
terminals=32
//To run specified transactions per terminal- runMins must equal zero
runTxnsPerTerminal=0
//To run for specified minutes- runTxnsPerTerminal must equal zero
runMins=10
//Number of total transactions per minute
limitTxnsPerMin=0
//Set to true to run in 4.x compatible mode. Set to false to use the
//entire configured database evenly.
terminalWarehouseFixed=true
//The following five values must add up to 100
//The default percentages of 45, 43, 4, 4 & 4 match the TPC-C spec
newOrderWeight=45
paymentWeight=43
orderStatusWeight=4
deliveryWeight=4
stockLevelWeight=4
// Directory name to create for collecting detailed result data.
// Comment this out to suppress.
resultDirectory=my_result_%tY-%tm-%td_%tH%tM%tS
osCollectorScript=./misc/os_collector_linux.py
osCollectorInterval=1
//osCollectorSSHAddr=user@dbhost
//osCollectorDevices=net_eth0 blk_sda

[mysql@localhost run]$ ./runDatabaseBuild.sh props.mysql
# ------------------------------------------------------------
# Loading SQL file ./sql.common/tableCreates.sql
# ------------------------------------------------------------
create table bmsql_config (
cfg_name varchar(30) primary key,
cfg_value varchar(50)
);
create table bmsql_warehouse (
w_id integer not null,
w_ytd decimal(12,2),
w_tax decimal(4,4),
w_name varchar(10),
w_street_1 varchar(20),
w_street_2 varchar(20),
w_city varchar(20),
w_state char(2),
w_zip char(9)
);
create table bmsql_district (
d_w_id integer not null,
d_id integer not null,
d_ytd decimal(12,2),
d_tax decimal(4,4),
d_next_o_id integer,
d_name varchar(10),
d_street_1 varchar(20),
d_street_2 varchar(20),
d_city varchar(20),
d_state char(2),
d_zip char(9)
);
create table bmsql_customer (
c_w_id integer not null,
c_d_id integer not null,
c_id integer not null,
c_discount decimal(4,4),
c_credit char(2),
c_last varchar(16),
c_first varchar(16),
c_credit_lim decimal(12,2),
c_balance decimal(12,2),
c_ytd_payment decimal(12,2),
c_payment_cnt integer,
c_delivery_cnt integer,
c_street_1 varchar(20),
c_street_2 varchar(20),
c_city varchar(20),
c_state char(2),
c_zip char(9),
c_phone char(16),
c_since timestamp,
c_middle char(2),
c_data varchar(500)
);
create sequence bmsql_hist_id_seq;
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'sequence bmsql_hist_id_seq' at line 1
create table bmsql_history (
hist_id integer,
h_c_id integer,
h_c_d_id integer,
h_c_w_id integer,
h_d_id integer,
h_w_id integer,
h_date timestamp,
h_amount decimal(6,2),
h_data varchar(24)
);
create table bmsql_new_order (
no_w_id integer not null,
no_d_id integer not null,
no_o_id integer not null
);
create table bmsql_oorder (
o_w_id integer not null,
o_d_id integer not null,
o_id integer not null,
o_c_id integer,
o_carrier_id integer,
o_ol_cnt integer,
o_all_local integer,
o_entry_d timestamp
);
create table bmsql_order_line (
ol_w_id integer not null,
ol_d_id integer not null,
ol_o_id integer not null,
ol_number integer not null,
ol_i_id integer not null,
ol_delivery_d timestamp,
ol_amount decimal(6,2),
ol_supply_w_id integer,
ol_quantity integer,
ol_dist_info char(24)
);
create table bmsql_item (
i_id integer not null,
i_name varchar(24),
i_price decimal(5,2),
i_data varchar(50),
i_im_id integer
);
create table bmsql_stock (
s_w_id integer not null,
s_i_id integer not null,
s_quantity integer,
s_ytd integer,
s_order_cnt integer,
s_remote_cnt integer,
s_data varchar(50),
s_dist_01 char(24),
s_dist_02 char(24),
s_dist_03 char(24),
s_dist_04 char(24),
s_dist_05 char(24),
s_dist_06 char(24),
s_dist_07 char(24),
s_dist_08 char(24),
s_dist_09 char(24),
s_dist_10 char(24)
);
Starting BenchmarkSQL LoadData

driver=com.mysql.jdbc.Driver
conn=jdbc:mysql://127.0.0.1:3306/test?useSSL=false&useServerPrepStmts=true&useConfigs=maxPerformance&rewriteBatchedStatements=true
user=root
password=***********
warehouses=100
loadWorkers=40
fileLocation (not defined)
csvNullValue (not defined - using default 'NULL')

Worker 000: Loading ITEM
Worker 001: Loading Warehouse 1
Worker 002: Loading Warehouse 2
Worker 003: Loading Warehouse 3
Worker 004: Loading Warehouse 4
Worker 005: Loading Warehouse 5
Worker 006: Loading Warehouse 6
Worker 007: Loading Warehouse 7
Worker 008: Loading Warehouse 8
Worker 010: Loading Warehouse 10
Worker 009: Loading Warehouse 9
Worker 011: Loading Warehouse 11
Worker 012: Loading Warehouse 12
Worker 013: Loading Warehouse 13
Worker 014: Loading Warehouse 14
Worker 015: Loading Warehouse 15
Worker 016: Loading Warehouse 16
Worker 017: Loading Warehouse 17
Worker 018: Loading Warehouse 18
Worker 019: Loading Warehouse 19
Worker 020: Loading Warehouse 20
Worker 021: Loading Warehouse 21
Worker 022: Loading Warehouse 22
Worker 023: Loading Warehouse 23
Worker 024: Loading Warehouse 24
Worker 025: Loading Warehouse 25
Worker 026: Loading Warehouse 26
Worker 027: Loading Warehouse 27
Worker 028: Loading Warehouse 28
Worker 029: Loading Warehouse 29
Worker 030: Loading Warehouse 30
Worker 032: Loading Warehouse 31
Worker 031: Loading Warehouse 32
Worker 033: Loading Warehouse 33
Worker 034: Loading Warehouse 34
Worker 035: Loading Warehouse 35
Worker 036: Loading Warehouse 36
Worker 037: Loading Warehouse 37
Worker 038: Loading Warehouse 38
Worker 039: Loading Warehouse 39
Worker 000: Loading ITEM done
Worker 000: Loading Warehouse 40
# ------------------------------------------------------------
# Loading SQL file ./sql.common/indexCreates.sql
# ------------------------------------------------------------
alter table bmsql_warehouse add constraint bmsql_warehouse_pkey
primary key (w_id);
alter table bmsql_district add constraint bmsql_district_pkey
primary key (d_w_id, d_id);
alter table bmsql_customer add constraint bmsql_customer_pkey
primary key (c_w_id, c_d_id, c_id);
create index bmsql_customer_idx1
on bmsql_customer (c_w_id, c_d_id, c_last, c_first);
alter table bmsql_oorder add constraint bmsql_oorder_pkey
primary key (o_w_id, o_d_id, o_id);
create unique index bmsql_oorder_idx1
on bmsql_oorder (o_w_id, o_d_id, o_carrier_id, o_id);
alter table bmsql_new_order add constraint bmsql_new_order_pkey
primary key (no_w_id, no_d_id, no_o_id);
alter table bmsql_order_line add constraint bmsql_order_line_pkey
primary key (ol_w_id, ol_d_id, ol_o_id, ol_number);
alter table bmsql_stock add constraint bmsql_stock_pkey
primary key (s_w_id, s_i_id);
alter table bmsql_item add constraint bmsql_item_pkey
primary key (i_id);
# ------------------------------------------------------------
# Loading SQL file ./sql.common/foreignKeys.sql
# ------------------------------------------------------------
alter table bmsql_district add constraint d_warehouse_fkey
foreign key (d_w_id)
references bmsql_warehouse (w_id);
alter table bmsql_customer add constraint c_district_fkey
foreign key (c_w_id, c_d_id)
references bmsql_district (d_w_id, d_id);
alter table bmsql_history add constraint h_customer_fkey
foreign key (h_c_w_id, h_c_d_id, h_c_id)
references bmsql_customer (c_w_id, c_d_id, c_id);
alter table bmsql_history add constraint h_district_fkey
foreign key (h_w_id, h_d_id)
references bmsql_district (d_w_id, d_id);
alter table bmsql_new_order add constraint no_order_fkey
foreign key (no_w_id, no_d_id, no_o_id)
references bmsql_oorder (o_w_id, o_d_id, o_id);
alter table bmsql_oorder add constraint o_customer_fkey
foreign key (o_w_id, o_d_id, o_c_id)
references bmsql_customer (c_w_id, c_d_id, c_id);
alter table bmsql_order_line add constraint ol_order_fkey
foreign key (ol_w_id, ol_d_id, ol_o_id)
references bmsql_oorder (o_w_id, o_d_id, o_id);
alter table bmsql_order_line add constraint ol_stock_fkey
foreign key (ol_supply_w_id, ol_i_id)
references bmsql_stock (s_w_id, s_i_id);
alter table bmsql_stock add constraint s_warehouse_fkey
foreign key (s_w_id)
references bmsql_warehouse (w_id);
alter table bmsql_stock add constraint s_item_fkey
foreign key (s_i_id)
references bmsql_item (i_id);
# ------------------------------------------------------------
# Loading SQL file ./sql.common/buildFinish.sql
# ------------------------------------------------------------
-- ----
-- Extra commands to run after the tables are created, loaded,
-- indexes built and extra's created.
-- ----

[mysql@localhost run]$ ./runBenchmark.sh props.mysql
09:25:48,374 [main] INFO jTPCC : Term-00,
09:25:48,379 [main] INFO jTPCC : Term-00, +-------------------------------------------------------------+
09:25:48,379 [main] INFO jTPCC : Term-00, BenchmarkSQL v5.0
09:25:48,379 [main] INFO jTPCC : Term-00, +-------------------------------------------------------------+
09:25:48,379 [main] INFO jTPCC : Term-00, (c) 2003, Raul Barbosa
09:25:48,379 [main] INFO jTPCC : Term-00, (c) 2004-2016, Denis Lussier
09:25:48,384 [main] INFO jTPCC : Term-00, (c) 2016, Jan Wieck
09:25:48,385 [main] INFO jTPCC : Term-00, +-------------------------------------------------------------+
09:25:48,385 [main] INFO jTPCC : Term-00,
09:25:48,385 [main] INFO jTPCC : Term-00, db=mysql
09:25:48,385 [main] INFO jTPCC : Term-00, driver=com.mysql.jdbc.Driver
09:25:48,385 [main] INFO jTPCC : Term-00, conn=jdbc:mysql://127.0.0.1:3306/test?useSSL=false
09:25:48,385 [main] INFO jTPCC : Term-00, user=root
09:25:48,386 [main] INFO jTPCC : Term-00,
09:25:48,386 [main] INFO jTPCC : Term-00, warehouses=40
09:25:48,386 [main] INFO jTPCC : Term-00, terminals=10
09:25:48,388 [main] INFO jTPCC : Term-00, runMins=10
09:25:48,388 [main] INFO jTPCC : Term-00, limitTxnsPerMin=0
09:25:48,388 [main] INFO jTPCC : Term-00, terminalWarehouseFixed=true
09:25:48,389 [main] INFO jTPCC : Term-00,
09:25:48,389 [main] INFO jTPCC : Term-00, newOrderWeight=45
09:25:48,389 [main] INFO jTPCC : Term-00, paymentWeight=43
09:25:48,389 [main] INFO jTPCC : Term-00, orderStatusWeight=4
09:25:48,389 [main] INFO jTPCC : Term-00, deliveryWeight=4
09:25:48,389 [main] INFO jTPCC : Term-00, stockLevelWeight=4
09:25:48,389 [main] INFO jTPCC : Term-00,
09:25:48,389 [main] INFO jTPCC : Term-00, resultDirectory=my_result_%tY-%tm-%td_%tH%tM%tS
09:25:48,390 [main] INFO jTPCC : Term-00, osCollectorScript=./misc/os_collector_linux.py
09:25:48,390 [main] INFO jTPCC : Term-00,
09:25:48,529 [main] INFO jTPCC : Term-00, copied props.mysql to my_result_2022-11-14_092548/run.properties
09:25:48,529 [main] INFO jTPCC : Term-00, created my_result_2022-11-14_092548/data/runInfo.csv for runID 5
09:25:48,530 [main] INFO jTPCC : Term-00, writing per transaction results to my_result_2022-11-14_092548/data/result.csv
09:25:48,531 [main] INFO jTPCC : Term-00, osCollectorScript=./misc/os_collector_linux.py
09:25:48,532 [main] INFO jTPCC : Term-00, osCollectorInterval=1
09:25:48,532 [main] INFO jTPCC : Term-00, osCollectorSSHAddr=null
09:25:48,532 [main] INFO jTPCC : Term-00, osCollectorDevices=null
09:25:48,684 [main] INFO jTPCC : Term-00,
09:25:49,097 [main] INFO jTPCC : Term-00, C value for C_LAST during load: 182
09:25:49,098 [main] INFO jTPCC : Term-00, C value for C_LAST this run: 253
09:25:49,098 [main] INFO jTPCC : Term-00,
Term-00, Running Average tpmTOTAL: 32447.84 Current tpmTOTAL: 2146668 Memory Usage: 143MB / 203MB
09:35:49,526 [Thread-6] INFO jTPCC : Term-00,
09:35:49,526 [Thread-6] INFO jTPCC : Term-00,
09:35:49,527 [Thread-6] INFO jTPCC : Term-00, Measured tpmC (NewOrders) = 14913.98
09:35:49,527 [Thread-6] INFO jTPCC : Term-00, Measured tpmTOTAL = 32102.08
09:35:49,527 [Thread-6] INFO jTPCC : Term-00, Session Start = 2022-11-14 09:25:49
09:35:49,528 [Thread-6] INFO jTPCC : Term-00, Session End = 2022-11-14 09:35:49
09:35:49,528 [Thread-6] INFO jTPCC : Term-00, Transaction Count = 321069

]]>
http://www.jydba.net/index.php/archives/3439/feed 0
sysbench 测试MySQL http://www.jydba.net/index.php/archives/3432 http://www.jydba.net/index.php/archives/3432#respond Mon, 14 Nov 2022 01:02:23 +0000 http://www.jydba.net/?p=3432 sysbench 测试MySQL
1. 安装sysbench

https://github.com/akopytov/sysbench.git # 通过git clone得到源码

sftp> cd /soft
sftp> pwd
/soft
sftp> ls
boost_1_59_0          boost_1_59_0.zip      docker-17.03.0-ce.tgz
employees_db          employees_db-full-1.0.6.tar.bz2
libpcap-1.10.1        libpcap-1.10.1.tar.gz mysql-5.7.26
mysql-5.7.26.tar.gz   mysql-utilities-1.6.5 mysql-utilities-1.6.5.tar.gz
ngrep                 ngrep-master.zip      sg3_utils-1.41-1.x86_64.rpm
sg3_utils-libs-1.41-1.x86_64.rpm
sftp> lcd F:\
sftp> put sysbench-master.zip
Uploading sysbench-master.zip to /soft/sysbench-master.zip
  100% 2220KB   2220KB/s 00:00:00
F:/sysbench-master.zip: 2274128 bytes transferred in 0 seconds (2220 KB/s)

[root@localhost soft]# unzip sysbench-master.zip
[root@localhost soft]# mv sysbench-master sysbench

[root@localhost sysbench]# ./autogen.sh
autoreconf: Entering directory `.'
autoreconf: configure.ac: not using Gettext
autoreconf: running: aclocal -I m4
autoreconf: configure.ac: tracing
autoreconf: running: libtoolize --copy
libtoolize: putting auxiliary files in AC_CONFIG_AUX_DIR, `config'.
libtoolize: copying file `config/ltmain.sh'
libtoolize: putting macros in AC_CONFIG_MACRO_DIR, `m4'.
libtoolize: copying file `m4/libtool.m4'
libtoolize: copying file `m4/ltoptions.m4'
libtoolize: copying file `m4/ltsugar.m4'
libtoolize: copying file `m4/ltversion.m4'
libtoolize: copying file `m4/lt~obsolete.m4'
autoreconf: running: /usr/bin/autoconf
autoreconf: running: /usr/bin/autoheader
autoreconf: running: automake --add-missing --copy --no-force
configure.ac:59: installing 'config/ar-lib'
configure.ac:45: installing 'config/compile'
configure.ac:27: installing 'config/config.guess'
configure.ac:27: installing 'config/config.sub'
configure.ac:32: installing 'config/install-sh'
configure.ac:32: installing 'config/missing'
src/Makefile.am: installing 'config/depcomp'
parallel-tests: installing 'config/test-driver'
autoreconf: Leaving directory `.'

关联mysql的头文件和库

[root@localhost sysbench]# ./configure  --with-mysql-includes=/mysqlsoft/mysql/include/  --with-mysql-libs=/mysqlsoft/mysql/lib/
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking for style of include used by make... GNU
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking dependency style of gcc... gcc3
checking how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking minix/config.h usability... no
checking minix/config.h presence... no
checking for minix/config.h... no
checking whether it is safe to define __EXTENSIONS__... yes
checking for gcc... (cached) gcc
checking whether we are using the GNU C compiler... (cached) yes
checking whether gcc accepts -g... (cached) yes
checking for gcc option to accept ISO C89... (cached) none needed
checking dependency style of gcc... (cached) gcc3
checking for gcc option to accept ISO C99... -std=gnu99
checking how to run the C preprocessor... gcc -E
checking whether gcc -std=gnu99 and cc understand -c and -o together... yes
checking for a sed that does not truncate output... /usr/bin/sed
checking for C compiler vendor... gnu
checking for gcc architecture flag...
checking for x86 cpuid 0 output... d:756e6547:6c65746e:49656e69
checking for x86 cpuid 1 output... 306e7:2040800:9e982203:1fabfbff
checking whether C compiler accepts -march=ivybridge... no
checking whether C compiler accepts -march=core-avx-i... yes
checking for gcc architecture flag... -march=core-avx-i
checking for ar... ar
checking the archiver (ar) interface... ar
checking how to print strings... printf
checking for a sed that does not truncate output... (cached) /usr/bin/sed
checking for fgrep... /usr/bin/grep -F
checking for ld used by gcc -std=gnu99... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 1572864
checking whether the shell understands some XSI constructs... yes
checking whether the shell understands "+="... yes
checking how to convert x86_64-unknown-linux-gnu file names to x86_64-unknown-linux-gnu format... func_convert_file_noop
checking how to convert x86_64-unknown-linux-gnu file names to toolchain format... func_convert_file_noop
checking for /usr/bin/ld option to reload object files... -r
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for dlltool... no
checking how to associate runtime and link libraries... printf %s\n
checking for archiver @FILE support... @
checking for strip... strip
checking for ranlib... ranlib
checking command to parse /usr/bin/nm -B output from gcc -std=gnu99 object... ok
checking for sysroot... no
checking for mt... mt
checking if mt is a manifest tool... no
checking for dlfcn.h... yes
checking for objdir... .libs
checking if gcc -std=gnu99 supports -fno-rtti -fno-exceptions... no
checking for gcc -std=gnu99 option to produce PIC... -fPIC -DPIC
checking if gcc -std=gnu99 PIC flag -fPIC -DPIC works... yes
checking if gcc -std=gnu99 static flag -static works... no
checking if gcc -std=gnu99 supports -c -o file.o... yes
checking if gcc -std=gnu99 supports -c -o file.o... (cached) yes
checking whether the gcc -std=gnu99 linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
checking for pkg-config... yes
checking for C compiler vendor... (cached) gnu
checking whether to compile with MySQL support... yes
checking whether to compile with PostgreSQL support... no
checking for pkg-config... /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking whether to build with system or bundled LuaJIT... bundled
checking whether to build with system or bundled Concurrency Kit... bundled
checking whether SHM_HUGETLB is declared... yes
checking whether O_SYNC is declared... yes
checking for the pthreads library -lpthreads... no
checking whether pthreads work without any flags... no
checking whether pthreads work with -Kthread... no
checking whether pthreads work with -kthread... no
checking for the pthreads library -llthread... no
checking whether pthreads work with -pthread... yes
checking for joinable pthread attribute... PTHREAD_CREATE_JOINABLE
checking if more special flags are required for pthreads... no
checking for sqrt in -lm... yes
checking MySQL includes... (cached) /mysqlsoft/mysql/include/
checking MySQL libraries... (cached) /mysqlsoft/mysql/lib/
checking for library containing mysql_real_connect... -lmysqlclient
checking if mysql.h defines MYSQL_OPT_SSL_MODE... yes
checking libaio.h usability... no
checking libaio.h presence... no
checking for libaio.h... no
checking for ANSI C header files... (cached) yes
checking errno.h usability... yes
checking errno.h presence... yes
checking for errno.h... yes
checking fcntl.h usability... yes
checking fcntl.h presence... yes
checking for fcntl.h... yes
checking math.h usability... yes
checking math.h presence... yes
checking for math.h... yes
checking pthread.h usability... yes
checking pthread.h presence... yes
checking for pthread.h... yes
checking sched.h usability... yes
checking sched.h presence... yes
checking for sched.h... yes
checking signal.h usability... yes
checking signal.h presence... yes
checking for signal.h... yes
checking for stdlib.h... (cached) yes
checking for string.h... (cached) yes
checking sys/aio.h usability... no
checking sys/aio.h presence... no
checking for sys/aio.h... no
checking sys/ipc.h usability... yes
checking sys/ipc.h presence... yes
checking for sys/ipc.h... yes
checking sys/time.h usability... yes
checking sys/time.h presence... yes
checking for sys/time.h... yes
checking sys/mman.h usability... yes
checking sys/mman.h presence... yes
checking for sys/mman.h... yes
checking sys/shm.h usability... yes
checking sys/shm.h presence... yes
checking for sys/shm.h... yes
checking thread.h usability... no
checking thread.h presence... no
checking for thread.h... no
checking for unistd.h... (cached) yes
checking limits.h usability... yes
checking limits.h presence... yes
checking for limits.h... yes
checking libgen.h usability... yes
checking libgen.h presence... yes
checking for libgen.h... yes
checking for off_t... yes
checking whether time.h and sys/time.h may both be included... yes
checking for thread local storage (TLS) class... __thread
checking for __attribute__((format))... yes
checking for __attribute__((unused))... yes
checking for special C compiler options needed for large files... no
checking for _FILE_OFFSET_BITS value needed for large files... no
checking size of size_t... 8
checking size of bool... 1
checking for stdlib.h... (cached) yes
checking for unistd.h... (cached) yes
checking for sys/param.h... yes
checking for getpagesize... yes
checking for working mmap... yes
checking whether strerror_r is declared... yes
checking for strerror_r... yes
checking whether strerror_r returns char *... yes
checking for library containing clock_gettime... none required
checking for alarm... yes
checking for clock_gettime... yes
checking for directio... no
checking for fdatasync... yes
checking for gettimeofday... yes
checking for isatty... yes
checking for memalign... yes
checking for memset... yes
checking for posix_memalign... yes
checking for pthread_cancel... yes
checking for pthread_yield... yes
checking for setvbuf... yes
checking for sqrt... yes
checking for strdup... yes
checking for thr_setconcurrency... no
checking for valloc... yes
checking for pthread_once... yes
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating third_party/luajit/Makefile
config.status: creating third_party/concurrency_kit/Makefile
config.status: creating src/Makefile
config.status: creating src/drivers/Makefile
config.status: creating src/drivers/mysql/Makefile
config.status: creating src/drivers/pgsql/Makefile
config.status: creating src/tests/Makefile
config.status: creating src/tests/cpu/Makefile
config.status: creating src/tests/fileio/Makefile
config.status: creating src/tests/memory/Makefile
config.status: creating src/tests/threads/Makefile
config.status: creating src/tests/mutex/Makefile
config.status: creating src/lua/Makefile
config.status: creating src/lua/internal/Makefile
config.status: creating tests/Makefile
config.status: creating tests/include/config.sh
config.status: creating snap/snapcraft.yaml
config.status: creating config/config.h
config.status: executing depfiles commands
config.status: executing libtool commands
===============================================================================
sysbench version   : 1.1.0
CC                 : gcc -std=gnu99
CFLAGS             : -O3 -funroll-loops -ggdb3  -march=core-avx-i -Wall -Wextra -Wpointer-arith -Wbad-function-cast -Wstrict-prototypes -Wnested-externs -Wno-format-zero-length -Wundef -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wcast-align -Wvla   -pthread
CPPFLAGS           : -D_GNU_SOURCE   -I$(top_srcdir)/src -I$(abs_top_builddir)/third_party/luajit/inc -I$(abs_top_builddir)/third_party/concurrency_kit/include
LDFLAGS            : -L/usr/local/lib
LIBS               : -lm

prefix             : /usr/local
bindir             : ${prefix}/bin
libexecdir         : ${prefix}/libexec
mandir             : ${prefix}/share/man
datadir            : ${prefix}/share

MySQL support      : yes
PostgreSQL support : no

LuaJIT             : bundled
LUAJIT_CFLAGS      : -I$(abs_top_builddir)/third_party/luajit/inc
LUAJIT_LIBS        : $(abs_top_builddir)/third_party/luajit/lib/libluajit-5.1.a -ldl
LUAJIT_LDFLAGS     : -rdynamic

Concurrency Kit    : bundled
CK_CFLAGS          : -I$(abs_top_builddir)/third_party/concurrency_kit/include
CK_LIBS            : $(abs_top_builddir)/third_party/concurrency_kit/lib/libck.a
configure flags    :
===============================================================================

源码编译
make -j 4 # -j 4 表示用几个cpu核心进行编译

[root@localhost sysbench]# make -j 4

安装
make install # 默认安装到 /usr/local/bin , 如果有自定义目录,configure增加参数 –prefix=自定义目录

[root@localhost sysbench]# make install

添加LD_LIBRARY_PATH

[root@localhost ~]# echo "export LD_LIBRARY_PATH=/mysqlsoft/mysql/lib/:$LD_LIBRARY_PATH" >> ~/.bashrc
[root@localhost ~]# source ~/.bashrc
[root@localhost ~]# sysbench --version
sysbench 1.1.0
< ?pre>

3. 测试
[mysql@localhost lua]$ ./sysbench oltp_read_write.lua --mysql-host=127.0.0.1 --mysql-port=3306 --mysql-db=test --mysql-user=root --mysql-password=abcd1234 --table_size=250000 --tables=125 --threads=32 --events=0 --report-interval=1 --time=600 prepare
./sysbench: error while loading shared libraries: libmysqlclient.so.20: cannot open shared object file: No such file or directory

字面意思就是打不到共享库文件libmysqlclient.so.20.

查找一下本地有没有这个文件

[root@localhost ~]# find / -name 'libmysqlclient*'
/soft/mysql-5.7.26/libmysql/libmysqlclient.so.20.3.13
/soft/mysql-5.7.26/libmysql/libmysqlclient.so.20
/soft/mysql-5.7.26/libmysql/libmysqlclient.so
/soft/mysql-5.7.26/packaging/deb-in/libmysqlclient-dev.install.in
/soft/mysql-5.7.26/packaging/deb-in/libmysqlclient-dev.lintian-overrides.in
/soft/mysql-5.7.26/packaging/deb-in/libmysqlclient20-dbgsym.install.in
/soft/mysql-5.7.26/packaging/deb-in/libmysqlclient20.install.in
/soft/mysql-5.7.26/packaging/deb-in/libmysqlclient20.lintian-overrides.in
/soft/mysql-5.7.26/archive_output_directory/libmysqlclient.a
/mysqlsoft/mysql/lib/libmysqlclient.a
/mysqlsoft/mysql/lib/libmysqlclient.so.20.3.13
/mysqlsoft/mysql/lib/libmysqlclient.so.20
/mysqlsoft/mysql/lib/libmysqlclient.so

在/mysqlsoft/mysql/lib/下面有这个文件,解决方法是先建立一个软链接到/usr/local/lib

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

接着在/etc/ld.so.cnf中加入/usr/loca/lib这一行

[root@localhost ~]# vi /etc/ld.so.conf
include ld.so.conf.d/*.conf
/usr/loca/lib

执行/sbin/ldconfig -v更新下配置就可以了

[root@localhost ~]# /sbin/ldconfig -v
..........省略...........
        libfreeblpriv3.so -> libfreeblpriv3.so
        libncurses++.so.5 -> libncurses++.so.5.9
        libfreebl3.so -> libfreebl3.so
        libmenuw.so.5 -> libmenuw.so.5.9
        libgcc_s.so.1 -> libgcc_s-4.8.5-20150702.so.1
        libmenu.so.5 -> libmenu.so.5.9
        libdtrace-ctf.so.1 -> libdtrace-ctf.so.1.5.0
        libuuid.so.1 -> libuuid.so.1.3.0
/lib/sse2: (hwcap: 0x0000000004000000)
/lib64/sse2: (hwcap: 0x0000000004000000)
/lib64/tls: (hwcap: 0x8000000000000000)


重新运行生成测试数据脚本

[mysql@localhost lua]$ ./sysbench oltp_read_write.lua --mysql-host=127.0.0.1 --mysql-port=3306 --mysql-db=test --mysql-user=root --mysql-password=abcd1234 --table_size=250000 --tables=25 --threads=32 --events=0 --report-interval=1 --time=600 prepare
sysbench 1.1.0 (using bundled LuaJIT 2.1.0-beta3)

Initializing worker threads...

Creating table 'sbtest14'...Creating table 'sbtest10'...Creating table 'sbtest11'...Creating table 'sbtest9'...Creating table 'sbtest4'...Creating table 'sbtest6'...Creating table 'sbtest24'...Creating table 'sbtest3'...Creating table 'sbtest1'...Creating table 'sbtest25'...Creating table 'sbtest5'...Creating table 'sbtest15'...Creating table 'sbtest7'...Creating table 'sbtest16'...Creating table 'sbtest2'...Creating table 'sbtest8'...












Creating table 'sbtest18'...

Creating table 'sbtest13'...


Creating table 'sbtest23'...
Creating table 'sbtest17'...
Creating table 'sbtest20'...
Creating table 'sbtest21'...
Creating table 'sbtest12'...
Creating table 'sbtest19'...
Creating table 'sbtest22'...
Inserting 250000 records into 'sbtest13'
Inserting 250000 records into 'sbtest23'
Inserting 250000 records into 'sbtest3'
Inserting 250000 records into 'sbtest16'
Inserting 250000 records into 'sbtest11'
Inserting 250000 records into 'sbtest2'
Inserting 250000 records into 'sbtest10'
Inserting 250000 records into 'sbtest22'
Inserting 250000 records into 'sbtest9'
Inserting 250000 records into 'sbtest5'
Inserting 250000 records into 'sbtest7'
Inserting 250000 records into 'sbtest14'
Inserting 250000 records into 'sbtest15'
Inserting 250000 records into 'sbtest25'
Inserting 250000 records into 'sbtest18'
Inserting 250000 records into 'sbtest24'
Inserting 250000 records into 'sbtest21'
Inserting 250000 records into 'sbtest1'
Inserting 250000 records into 'sbtest17'
Inserting 250000 records into 'sbtest20'
Inserting 250000 records into 'sbtest8'
Inserting 250000 records into 'sbtest4'
Inserting 250000 records into 'sbtest19'
Inserting 250000 records into 'sbtest12'
Inserting 250000 records into 'sbtest6'
Creating a secondary index on 'sbtest2'...
Creating a secondary index on 'sbtest4'...
Creating a secondary index on 'sbtest3'...
Creating a secondary index on 'sbtest25'...
Creating a secondary index on 'sbtest11'...
Creating a secondary index on 'sbtest16'...
Creating a secondary index on 'sbtest13'...
Creating a secondary index on 'sbtest20'...
Creating a secondary index on 'sbtest7'...
Creating a secondary index on 'sbtest12'...
Creating a secondary index on 'sbtest17'...
Creating a secondary index on 'sbtest10'...
Creating a secondary index on 'sbtest6'...
Creating a secondary index on 'sbtest8'...
Creating a secondary index on 'sbtest1'...
Creating a secondary index on 'sbtest5'...
Creating a secondary index on 'sbtest9'...
Creating a secondary index on 'sbtest18'...
Creating a secondary index on 'sbtest19'...
Creating a secondary index on 'sbtest15'...
Creating a secondary index on 'sbtest24'...
Creating a secondary index on 'sbtest21'...
Creating a secondary index on 'sbtest14'...
Creating a secondary index on 'sbtest23'...
Creating a secondary index on 'sbtest22'...

运行测试脚本

[mysql@localhost lua]$ ./sysbench oltp_read_write.lua --mysql-host=127.0.0.1 --mysql-port=3306 --mysql-db=test --mysql-user=root --mysql-password=abcd1234 --table_size=250000 --tables=25 --threads=32 --events=0 --report-interval=1 --time=600 --percentile=95 --report-interval=1 run
sysbench 1.1.0 (using bundled LuaJIT 2.1.0-beta3)

Running the test with following options:
Number of threads: 32
Report intermediate results every 1 second(s)
Initializing random number generator from current time


Initializing worker threads...

Threads started!

[ 1s ] thds: 32 tps: 420.88 qps: 8842.27 (r/w/o: 6223.49/1745.85/872.93) lat (ms,95%): 132.49 err/s: 0.00 reconn/s: 0.00
[ 2s ] thds: 32 tps: 440.30 qps: 8782.91 (r/w/o: 6165.15/1739.17/878.59) lat (ms,95%): 132.49 err/s: 0.00 reconn/s: 0.00
[ 3s ] thds: 32 tps: 446.97 qps: 9031.33 (r/w/o: 6325.53/1809.87/895.93) lat (ms,95%): 127.81 err/s: 0.00 reconn/s: 0.00
[ 4s ] thds: 32 tps: 460.97 qps: 9095.42 (r/w/o: 6349.60/1826.88/918.94) lat (ms,95%): 132.49 err/s: 0.00 reconn/s: 0.00
[ 5s ] thds: 32 tps: 449.06 qps: 8969.11 (r/w/o: 6266.78/1801.22/901.11) lat (ms,95%): 123.28 err/s: 0.00 reconn/s: 0.00
[ 6s ] thds: 32 tps: 450.00 qps: 9064.95 (r/w/o: 6361.97/1802.99/900.00) lat (ms,95%): 118.92 err/s: 0.00 reconn/s: 0.00
[ 7s ] thds: 32 tps: 449.53 qps: 9007.52 (r/w/o: 6333.33/1776.13/898.05) lat (ms,95%): 123.28 err/s: 0.00 reconn/s: 0.00
[ 8s ] thds: 32 tps: 446.41 qps: 8827.02 (r/w/o: 6163.60/1769.61/893.81) lat (ms,95%): 121.08 err/s: 0.00 reconn/s: 0.00
[ 9s ] thds: 32 tps: 414.03 qps: 8322.70 (r/w/o: 5808.49/1686.14/828.07) lat (ms,95%): 127.81 err/s: 0.00 reconn/s: 0.00
[ 10s ] thds: 32 tps: 415.00 qps: 8302.07 (r/w/o: 5824.05/1648.01/830.01) lat (ms,95%): 132.49 err/s: 0.00 reconn/s: 0.00
[ 11s ] thds: 32 tps: 440.56 qps: 8794.13 (r/w/o: 6155.79/1757.23/881.11) lat (ms,95%): 121.08 err/s: 0.00 reconn/s: 0.00
[ 12s ] thds: 32 tps: 392.43 qps: 7793.52 (r/w/o: 5465.98/1542.69/784.86) lat (ms,95%): 132.49 err/s: 0.00 reconn/s: 0.00
[ 13s ] thds: 32 tps: 216.97 qps: 4355.35 (r/w/o: 3034.55/886.87/433.94) lat (ms,95%): 363.18 err/s: 0.00 reconn/s: 0.00
[ 14s ] thds: 32 tps: 192.01 qps: 3796.14 (r/w/o: 2662.10/750.03/384.01) lat (ms,95%): 397.39 err/s: 0.00 reconn/s: 0.00
[ 15s ] thds: 32 tps: 86.00 qps: 1767.09 (r/w/o: 1249.06/346.02/172.01) lat (ms,95%): 511.33 err/s: 0.00 reconn/s: 0.00
[ 16s ] thds: 32 tps: 71.00 qps: 1421.09 (r/w/o: 994.07/285.02/142.01) lat (ms,95%): 977.74 err/s: 0.00 reconn/s: 0.00
[ 17s ] thds: 32 tps: 115.98 qps: 2316.68 (r/w/o: 1620.78/463.94/231.97) lat (ms,95%): 646.19 err/s: 0.00 reconn/s: 0.00
[ 18s ] thds: 32 tps: 115.96 qps: 2267.18 (r/w/o: 1575.43/459.83/231.92) lat (ms,95%): 682.06 err/s: 0.00 reconn/s: 0.00
[ 19s ] thds: 32 tps: 120.06 qps: 2454.22 (r/w/o: 1727.86/486.24/240.12) lat (ms,95%): 493.24 err/s: 0.00 reconn/s: 0.00
[ 20s ] thds: 32 tps: 91.00 qps: 1779.97 (r/w/o: 1234.98/362.99/182.00) lat (ms,95%): 694.45 err/s: 0.00 reconn/s: 0.00
[ 21s ] thds: 32 tps: 47.99 qps: 966.87 (r/w/o: 678.91/191.97/95.99) lat (ms,95%): 1069.86 err/s: 0.00 reconn/s: 0.00
[ 22s ] thds: 32 tps: 65.01 qps: 1283.20 (r/w/o: 895.14/258.04/130.02) lat (ms,95%): 1149.76 err/s: 0.00 reconn/s: 0.00
[ 23s ] thds: 32 tps: 30.99 qps: 659.69 (r/w/o: 478.77/118.94/61.97) lat (ms,95%): 1032.01 err/s: 0.00 reconn/s: 0.00
[ 24s ] thds: 32 tps: 90.03 qps: 1850.71 (r/w/o: 1295.50/375.14/180.07) lat (ms,95%): 1352.03 err/s: 0.00 reconn/s: 0.00
[ 25s ] thds: 32 tps: 77.01 qps: 1500.11 (r/w/o: 1041.07/305.02/154.01) lat (ms,95%): 773.68 err/s: 0.00 reconn/s: 0.00
[ 26s ] thds: 32 tps: 90.00 qps: 1741.99 (r/w/o: 1212.00/350.00/180.00) lat (ms,95%): 450.77 err/s: 0.00 reconn/s: 0.00
[ 27s ] thds: 32 tps: 31.00 qps: 685.98 (r/w/o: 493.99/130.00/62.00) lat (ms,95%): 1453.01 err/s: 0.00 reconn/s: 0.00
[ 28s ] thds: 32 tps: 56.00 qps: 1068.04 (r/w/o: 736.03/220.01/112.00) lat (ms,95%): 1376.60 err/s: 0.00 reconn/s: 0.00
[ 29s ] thds: 32 tps: 36.00 qps: 752.99 (r/w/o: 535.00/146.00/72.00) lat (ms,95%): 1304.21 err/s: 0.00 reconn/s: 0.00
[ 30s ] thds: 32 tps: 32.00 qps: 621.99 (r/w/o: 432.00/126.00/64.00) lat (ms,95%): 1589.90 err/s: 0.00 reconn/s: 0.00
[ 31s ] thds: 32 tps: 26.00 qps: 541.01 (r/w/o: 379.01/110.00/52.00) lat (ms,95%): 1903.57 err/s: 0.00 reconn/s: 0.00
[ 32s ] thds: 32 tps: 23.00 qps: 429.00 (r/w/o: 296.00/87.00/46.00) lat (ms,95%): 1739.68 err/s: 0.00 reconn/s: 0.00
[ 33s ] thds: 32 tps: 16.00 qps: 347.00 (r/w/o: 253.00/62.00/32.00) lat (ms,95%): 1938.16 err/s: 0.00 reconn/s: 0.00
[ 34s ] thds: 32 tps: 54.00 qps: 1120.99 (r/w/o: 778.99/234.00/108.00) lat (ms,95%): 2539.17 err/s: 0.00 reconn/s: 0.00
[ 35s ] thds: 32 tps: 363.96 qps: 7212.21 (r/w/o: 5042.45/1441.84/727.92) lat (ms,95%): 164.45 err/s: 0.00 reconn/s: 0.00
[ 36s ] thds: 32 tps: 362.04 qps: 7243.81 (r/w/o: 5077.57/1442.16/724.08) lat (ms,95%): 164.45 err/s: 0.00 reconn/s: 0.00
[ 37s ] thds: 32 tps: 352.90 qps: 7110.99 (r/w/o: 4988.59/1416.60/705.80) lat (ms,95%): 158.63 err/s: 0.00 reconn/s: 0.00
[ 38s ] thds: 32 tps: 363.75 qps: 7270.06 (r/w/o: 5074.59/1467.97/727.50) lat (ms,95%): 155.80 err/s: 0.00 reconn/s: 0.00
[ 39s ] thds: 32 tps: 372.75 qps: 7467.08 (r/w/o: 5229.56/1493.02/744.50) lat (ms,95%): 155.80 err/s: 0.00 reconn/s: 0.00
[ 40s ] thds: 32 tps: 296.80 qps: 5913.04 (r/w/o: 4137.23/1181.21/594.60) lat (ms,95%): 186.54 err/s: 0.00 reconn/s: 0.00
[ 41s ] thds: 32 tps: 356.77 qps: 7188.59 (r/w/o: 5033.92/1441.13/713.55) lat (ms,95%): 158.63 err/s: 0.00 reconn/s: 0.00
[ 42s ] thds: 32 tps: 377.95 qps: 7489.91 (r/w/o: 5230.24/1503.78/755.89) lat (ms,95%): 142.39 err/s: 0.00 reconn/s: 0.00
[ 43s ] thds: 32 tps: 382.97 qps: 7599.32 (r/w/o: 5316.52/1518.86/763.93) lat (ms,95%): 153.02 err/s: 0.00 reconn/s: 0.00
[ 44s ] thds: 32 tps: 378.08 qps: 7641.59 (r/w/o: 5358.11/1526.32/757.16) lat (ms,95%): 144.97 err/s: 0.00 reconn/s: 0.00
[ 45s ] thds: 32 tps: 388.08 qps: 7789.51 (r/w/o: 5458.05/1554.30/777.15) lat (ms,95%): 142.39 err/s: 0.00 reconn/s: 0.00
[ 46s ] thds: 32 tps: 398.74 qps: 7983.89 (r/w/o: 5595.42/1590.98/797.49) lat (ms,95%): 132.49 err/s: 0.00 reconn/s: 0.00
[ 47s ] thds: 32 tps: 402.27 qps: 8038.38 (r/w/o: 5607.75/1626.09/804.54) lat (ms,95%): 132.49 err/s: 0.00 reconn/s: 0.00
[ 48s ] thds: 32 tps: 411.50 qps: 8199.11 (r/w/o: 5753.06/1623.04/823.01) lat (ms,95%): 130.13 err/s: 0.00 reconn/s: 0.00
[ 49s ] thds: 32 tps: 409.49 qps: 8186.82 (r/w/o: 5725.87/1641.97/818.98) lat (ms,95%): 125.52 err/s: 0.00 reconn/s: 0.00
[ 50s ] thds: 32 tps: 406.97 qps: 8123.41 (r/w/o: 5686.59/1622.88/813.94) lat (ms,95%): 127.81 err/s: 0.00 reconn/s: 0.00
[ 51s ] thds: 32 tps: 420.95 qps: 8411.07 (r/w/o: 5877.35/1692.81/840.91) lat (ms,95%): 121.08 err/s: 0.00 reconn/s: 0.00
[ 52s ] thds: 32 tps: 423.08 qps: 8431.50 (r/w/o: 5904.05/1680.30/847.15) lat (ms,95%): 123.28 err/s: 0.00 reconn/s: 0.00
[ 53s ] thds: 32 tps: 417.95 qps: 8478.98 (r/w/o: 5939.28/1703.79/835.90) lat (ms,95%): 125.52 err/s: 0.00 reconn/s: 0.00
[ 54s ] thds: 32 tps: 427.01 qps: 8537.15 (r/w/o: 5990.11/1693.03/854.02) lat (ms,95%): 121.08 err/s: 0.00 reconn/s: 0.00
[ 55s ] thds: 32 tps: 316.04 qps: 6210.76 (r/w/o: 4339.53/1239.15/632.08) lat (ms,95%): 200.47 err/s: 0.00 reconn/s: 0.00
[ 56s ] thds: 32 tps: 224.00 qps: 4544.02 (r/w/o: 3193.02/903.00/448.00) lat (ms,95%): 287.38 err/s: 0.00 reconn/s: 0.00
[ 57s ] thds: 32 tps: 194.00 qps: 3862.91 (r/w/o: 2691.94/782.98/387.99) lat (ms,95%): 350.33 err/s: 0.00 reconn/s: 0.00
[ 58s ] thds: 32 tps: 168.00 qps: 3388.08 (r/w/o: 2376.06/676.02/336.01) lat (ms,95%): 411.96 err/s: 0.00 reconn/s: 0.00
[ 59s ] thds: 32 tps: 114.99 qps: 2200.90 (r/w/o: 1529.93/440.98/229.99) lat (ms,95%): 569.67 err/s: 0.00 reconn/s: 0.00
[ 60s ] thds: 32 tps: 59.00 qps: 1226.05 (r/w/o: 868.04/240.01/118.01) lat (ms,95%): 580.02 err/s: 0.00 reconn/s: 0.00
[ 61s ] thds: 32 tps: 43.00 qps: 880.00 (r/w/o: 626.00/168.00/86.00) lat (ms,95%): 1533.66 err/s: 0.00 reconn/s: 0.00
[ 62s ] thds: 32 tps: 35.00 qps: 661.00 (r/w/o: 451.00/140.00/70.00) lat (ms,95%): 1903.57 err/s: 0.00 reconn/s: 0.00
[ 63s ] thds: 32 tps: 33.00 qps: 684.00 (r/w/o: 477.00/141.00/66.00) lat (ms,95%): 1427.08 err/s: 0.00 reconn/s: 0.00
[ 64s ] thds: 32 tps: 14.00 qps: 355.00 (r/w/o: 247.00/80.00/28.00) lat (ms,95%): 1803.47 err/s: 0.00 reconn/s: 0.00
[ 65s ] thds: 32 tps: 30.00 qps: 520.01 (r/w/o: 364.01/96.00/60.00) lat (ms,95%): 2585.31 err/s: 0.00 reconn/s: 0.00
[ 66s ] thds: 32 tps: 33.00 qps: 642.98 (r/w/o: 450.99/126.00/66.00) lat (ms,95%): 1618.78 err/s: 0.00 reconn/s: 0.00
[ 67s ] thds: 32 tps: 23.00 qps: 495.01 (r/w/o: 352.00/98.00/45.00) lat (ms,95%): 3208.88 err/s: 0.00 reconn/s: 0.00
[ 68s ] thds: 32 tps: 20.00 qps: 353.00 (r/w/o: 238.00/74.00/41.00) lat (ms,95%): 2159.29 err/s: 0.00 reconn/s: 0.00
[ 69s ] thds: 32 tps: 18.00 qps: 399.00 (r/w/o: 294.00/69.00/36.00) lat (ms,95%): 2159.29 err/s: 0.00 reconn/s: 0.00
[ 70s ] thds: 32 tps: 17.00 qps: 311.00 (r/w/o: 210.00/67.00/34.00) lat (ms,95%): 2985.89 err/s: 0.00 reconn/s: 0.00
[ 71s ] thds: 32 tps: 15.00 qps: 345.99 (r/w/o: 247.99/68.00/30.00) lat (ms,95%): 2632.28 err/s: 0.00 reconn/s: 0.00
[ 72s ] thds: 32 tps: 23.00 qps: 513.01 (r/w/o: 353.00/114.00/46.00) lat (ms,95%): 3040.14 err/s: 0.00 reconn/s: 0.00
[ 73s ] thds: 32 tps: 75.00 qps: 1474.01 (r/w/o: 1027.01/298.00/149.00) lat (ms,95%): 2362.72 err/s: 0.00 reconn/s: 0.00
[ 74s ] thds: 32 tps: 408.91 qps: 8116.21 (r/w/o: 5673.75/1624.64/817.82) lat (ms,95%): 137.35 err/s: 0.00 reconn/s: 0.00
[ 75s ] thds: 32 tps: 405.08 qps: 8147.58 (r/w/o: 5716.11/1620.31/811.16) lat (ms,95%): 130.13 err/s: 0.00 reconn/s: 0.00
[ 76s ] thds: 32 tps: 415.01 qps: 8294.11 (r/w/o: 5793.08/1671.02/830.01) lat (ms,95%): 123.28 err/s: 0.00 reconn/s: 0.00
[ 77s ] thds: 32 tps: 410.97 qps: 8212.34 (r/w/o: 5758.54/1631.87/821.93) lat (ms,95%): 125.52 err/s: 0.00 reconn/s: 0.00
[ 78s ] thds: 32 tps: 425.00 qps: 8493.92 (r/w/o: 5948.94/1695.98/848.99) lat (ms,95%): 125.52 err/s: 0.00 reconn/s: 0.00
[ 79s ] thds: 32 tps: 420.04 qps: 8408.77 (r/w/o: 5883.54/1685.15/840.08) lat (ms,95%): 125.52 err/s: 0.00 reconn/s: 0.00
[ 80s ] thds: 32 tps: 420.99 qps: 8447.77 (r/w/o: 5902.84/1701.95/842.98) lat (ms,95%): 116.80 err/s: 0.00 reconn/s: 0.00
[ 81s ] thds: 32 tps: 423.49 qps: 8470.71 (r/w/o: 5933.79/1690.95/845.97) lat (ms,95%): 118.92 err/s: 0.00 reconn/s: 0.00
[ 82s ] thds: 32 tps: 428.53 qps: 8574.58 (r/w/o: 6006.41/1710.11/858.06) lat (ms,95%): 118.92 err/s: 0.00 reconn/s: 0.00
[ 83s ] thds: 32 tps: 423.99 qps: 8455.88 (r/w/o: 5920.92/1686.98/847.99) lat (ms,95%): 123.28 err/s: 0.00 reconn/s: 0.00
[ 84s ] thds: 32 tps: 427.01 qps: 8547.17 (r/w/o: 5985.12/1709.03/853.02) lat (ms,95%): 118.92 err/s: 0.00 reconn/s: 0.00
[ 85s ] thds: 32 tps: 432.84 qps: 8644.74 (r/w/o: 6036.73/1742.34/865.67) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 86s ] thds: 32 tps: 424.06 qps: 8545.31 (r/w/o: 6006.92/1689.26/849.13) lat (ms,95%): 118.92 err/s: 0.00 reconn/s: 0.00
[ 87s ] thds: 32 tps: 439.04 qps: 8763.83 (r/w/o: 6126.58/1759.17/878.08) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 88s ] thds: 32 tps: 425.73 qps: 8453.71 (r/w/o: 5899.31/1702.93/851.47) lat (ms,95%): 114.72 err/s: 0.00 reconn/s: 0.00
[ 89s ] thds: 32 tps: 439.30 qps: 8777.91 (r/w/o: 6155.14/1744.17/878.59) lat (ms,95%): 108.68 err/s: 0.00 reconn/s: 0.00
[ 90s ] thds: 32 tps: 423.96 qps: 8585.13 (r/w/o: 6026.39/1710.83/847.91) lat (ms,95%): 114.72 err/s: 0.00 reconn/s: 0.00
[ 91s ] thds: 32 tps: 446.07 qps: 8862.44 (r/w/o: 6175.00/1797.29/890.14) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 92s ] thds: 32 tps: 420.96 qps: 8506.29 (r/w/o: 5970.50/1691.86/843.93) lat (ms,95%): 118.92 err/s: 0.00 reconn/s: 0.00
[ 93s ] thds: 32 tps: 447.03 qps: 8906.66 (r/w/o: 6223.46/1790.13/893.07) lat (ms,95%): 116.80 err/s: 0.00 reconn/s: 0.00
[ 94s ] thds: 32 tps: 425.02 qps: 8528.49 (r/w/o: 5974.35/1703.10/851.05) lat (ms,95%): 114.72 err/s: 0.00 reconn/s: 0.00
[ 95s ] thds: 32 tps: 446.98 qps: 8904.52 (r/w/o: 6240.67/1769.91/893.95) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 96s ] thds: 32 tps: 397.01 qps: 7899.15 (r/w/o: 5536.11/1569.03/794.02) lat (ms,95%): 130.13 err/s: 0.00 reconn/s: 0.00
[ 97s ] thds: 32 tps: 158.00 qps: 3164.01 (r/w/o: 2212.01/636.00/316.00) lat (ms,95%): 493.24 err/s: 0.00 reconn/s: 0.00
[ 98s ] thds: 32 tps: 169.99 qps: 3335.72 (r/w/o: 2322.81/672.94/339.97) lat (ms,95%): 623.33 err/s: 0.00 reconn/s: 0.00
[ 99s ] thds: 32 tps: 364.97 qps: 7267.36 (r/w/o: 5083.56/1453.87/729.94) lat (ms,95%): 186.54 err/s: 0.00 reconn/s: 0.00
[ 100s ] thds: 32 tps: 161.02 qps: 3277.33 (r/w/o: 2305.23/650.07/322.03) lat (ms,95%): 419.45 err/s: 0.00 reconn/s: 0.00
[ 101s ] thds: 32 tps: 106.01 qps: 2091.14 (r/w/o: 1465.10/414.03/212.01) lat (ms,95%): 623.33 err/s: 0.00 reconn/s: 0.00
[ 102s ] thds: 32 tps: 86.00 qps: 1720.00 (r/w/o: 1202.00/346.00/172.00) lat (ms,95%): 746.32 err/s: 0.00 reconn/s: 0.00
[ 103s ] thds: 32 tps: 49.00 qps: 978.95 (r/w/o: 684.96/195.99/97.99) lat (ms,95%): 893.56 err/s: 0.00 reconn/s: 0.00
[ 104s ] thds: 32 tps: 60.00 qps: 1250.08 (r/w/o: 888.06/242.02/120.01) lat (ms,95%): 1280.93 err/s: 0.00 reconn/s: 0.00
[ 105s ] thds: 32 tps: 62.00 qps: 1269.00 (r/w/o: 875.00/270.00/124.00) lat (ms,95%): 960.30 err/s: 0.00 reconn/s: 0.00
[ 106s ] thds: 32 tps: 38.00 qps: 719.01 (r/w/o: 517.01/126.00/76.00) lat (ms,95%): 1304.21 err/s: 0.00 reconn/s: 0.00
[ 107s ] thds: 32 tps: 40.00 qps: 849.99 (r/w/o: 601.99/168.00/80.00) lat (ms,95%): 1280.93 err/s: 0.00 reconn/s: 0.00
[ 108s ] thds: 32 tps: 34.00 qps: 603.00 (r/w/o: 407.00/128.00/68.00) lat (ms,95%): 1938.16 err/s: 0.00 reconn/s: 0.00
[ 109s ] thds: 32 tps: 43.00 qps: 863.01 (r/w/o: 610.01/167.00/86.00) lat (ms,95%): 1589.90 err/s: 0.00 reconn/s: 0.00
[ 110s ] thds: 32 tps: 33.00 qps: 672.98 (r/w/o: 460.99/146.00/66.00) lat (ms,95%): 1678.14 err/s: 0.00 reconn/s: 0.00
[ 111s ] thds: 32 tps: 45.00 qps: 905.99 (r/w/o: 635.00/181.00/90.00) lat (ms,95%): 1506.29 err/s: 0.00 reconn/s: 0.00
[ 112s ] thds: 32 tps: 403.96 qps: 8150.26 (r/w/o: 5710.48/1631.85/807.93) lat (ms,95%): 215.44 err/s: 0.00 reconn/s: 0.00
[ 113s ] thds: 32 tps: 420.64 qps: 8397.85 (r/w/o: 5880.00/1676.57/841.28) lat (ms,95%): 123.28 err/s: 0.00 reconn/s: 0.00
[ 114s ] thds: 32 tps: 422.35 qps: 8403.06 (r/w/o: 5878.94/1679.41/844.71) lat (ms,95%): 125.52 err/s: 0.00 reconn/s: 0.00
[ 115s ] thds: 32 tps: 425.99 qps: 8500.75 (r/w/o: 5956.82/1692.95/850.97) lat (ms,95%): 121.08 err/s: 0.00 reconn/s: 0.00
[ 116s ] thds: 32 tps: 424.80 qps: 8544.93 (r/w/o: 5961.16/1733.18/850.60) lat (ms,95%): 116.80 err/s: 0.00 reconn/s: 0.00
[ 117s ] thds: 32 tps: 431.22 qps: 8580.33 (r/w/o: 6001.03/1716.87/862.43) lat (ms,95%): 121.08 err/s: 0.00 reconn/s: 0.00
[ 118s ] thds: 32 tps: 424.89 qps: 8539.75 (r/w/o: 5990.42/1699.55/849.78) lat (ms,95%): 118.92 err/s: 0.00 reconn/s: 0.00
[ 119s ] thds: 32 tps: 442.95 qps: 8876.97 (r/w/o: 6208.28/1782.79/885.90) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 120s ] thds: 32 tps: 434.19 qps: 8659.88 (r/w/o: 6066.72/1725.77/867.39) lat (ms,95%): 114.72 err/s: 0.00 reconn/s: 0.00
[ 121s ] thds: 32 tps: 425.77 qps: 8521.47 (r/w/o: 5963.83/1705.09/852.55) lat (ms,95%): 118.92 err/s: 0.00 reconn/s: 0.00
[ 122s ] thds: 32 tps: 427.10 qps: 8543.91 (r/w/o: 5993.34/1696.38/854.19) lat (ms,95%): 114.72 err/s: 0.00 reconn/s: 0.00
[ 123s ] thds: 32 tps: 422.06 qps: 8469.29 (r/w/o: 5915.90/1709.26/844.13) lat (ms,95%): 123.28 err/s: 0.00 reconn/s: 0.00
[ 124s ] thds: 32 tps: 437.56 qps: 8684.22 (r/w/o: 6078.86/1731.25/874.12) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 125s ] thds: 32 tps: 434.44 qps: 8817.95 (r/w/o: 6166.26/1782.81/868.88) lat (ms,95%): 110.66 err/s: 0.00 reconn/s: 0.00
[ 126s ] thds: 32 tps: 437.97 qps: 8667.40 (r/w/o: 6072.58/1717.88/876.94) lat (ms,95%): 114.72 err/s: 0.00 reconn/s: 0.00
[ 127s ] thds: 32 tps: 446.95 qps: 8913.91 (r/w/o: 6224.24/1795.78/893.89) lat (ms,95%): 116.80 err/s: 0.00 reconn/s: 0.00
[ 128s ] thds: 32 tps: 431.13 qps: 8700.71 (r/w/o: 6117.90/1720.54/862.27) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 129s ] thds: 32 tps: 444.03 qps: 8874.52 (r/w/o: 6209.36/1777.10/888.05) lat (ms,95%): 114.72 err/s: 0.00 reconn/s: 0.00
[ 130s ] thds: 32 tps: 439.98 qps: 8677.59 (r/w/o: 6048.72/1751.92/876.96) lat (ms,95%): 110.66 err/s: 0.00 reconn/s: 0.00
[ 131s ] thds: 32 tps: 442.61 qps: 8922.13 (r/w/o: 6270.47/1764.44/887.22) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 132s ] thds: 32 tps: 431.41 qps: 8659.25 (r/w/o: 6045.76/1749.67/863.82) lat (ms,95%): 121.08 err/s: 0.00 reconn/s: 0.00
[ 133s ] thds: 32 tps: 444.97 qps: 8906.38 (r/w/o: 6257.56/1758.88/889.94) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 134s ] thds: 32 tps: 434.82 qps: 8629.48 (r/w/o: 6028.54/1731.29/869.65) lat (ms,95%): 118.92 err/s: 0.00 reconn/s: 0.00
[ 135s ] thds: 32 tps: 325.15 qps: 6502.92 (r/w/o: 4555.04/1297.58/650.29) lat (ms,95%): 219.36 err/s: 0.00 reconn/s: 0.00
[ 136s ] thds: 32 tps: 197.00 qps: 3920.05 (r/w/o: 2749.03/777.01/394.00) lat (ms,95%): 344.08 err/s: 0.00 reconn/s: 0.00
[ 137s ] thds: 32 tps: 166.00 qps: 3322.02 (r/w/o: 2317.02/673.01/332.00) lat (ms,95%): 612.21 err/s: 0.00 reconn/s: 0.00
[ 138s ] thds: 32 tps: 161.00 qps: 3236.99 (r/w/o: 2272.99/642.00/322.00) lat (ms,95%): 467.30 err/s: 0.00 reconn/s: 0.00
[ 139s ] thds: 32 tps: 115.00 qps: 2266.06 (r/w/o: 1583.04/453.01/230.01) lat (ms,95%): 590.56 err/s: 0.00 reconn/s: 0.00
[ 140s ] thds: 32 tps: 65.94 qps: 1379.65 (r/w/o: 979.04/268.74/131.87) lat (ms,95%): 746.32 err/s: 0.00 reconn/s: 0.00
[ 141s ] thds: 32 tps: 80.05 qps: 1572.02 (r/w/o: 1089.71/322.21/160.10) lat (ms,95%): 1129.24 err/s: 0.00 reconn/s: 0.00
[ 142s ] thds: 32 tps: 62.02 qps: 1207.38 (r/w/o: 840.26/243.08/124.04) lat (ms,95%): 943.16 err/s: 0.00 reconn/s: 0.00
[ 143s ] thds: 32 tps: 21.00 qps: 484.89 (r/w/o: 356.92/85.98/41.99) lat (ms,95%): 1258.08 err/s: 0.00 reconn/s: 0.00
[ 144s ] thds: 32 tps: 52.01 qps: 994.21 (r/w/o: 682.14/208.04/104.02) lat (ms,95%): 1589.90 err/s: 0.00 reconn/s: 0.00
[ 145s ] thds: 32 tps: 65.00 qps: 1286.00 (r/w/o: 895.00/261.00/130.00) lat (ms,95%): 1129.24 err/s: 0.00 reconn/s: 0.00
[ 146s ] thds: 32 tps: 49.00 qps: 1026.01 (r/w/o: 734.01/194.00/98.00) lat (ms,95%): 1013.60 err/s: 0.00 reconn/s: 0.00
[ 147s ] thds: 32 tps: 49.00 qps: 954.00 (r/w/o: 662.00/194.00/98.00) lat (ms,95%): 1032.01 err/s: 0.00 reconn/s: 0.00
[ 148s ] thds: 32 tps: 36.00 qps: 673.00 (r/w/o: 457.00/144.00/72.00) lat (ms,95%): 1129.24 err/s: 0.00 reconn/s: 0.00
[ 149s ] thds: 32 tps: 285.00 qps: 5838.91 (r/w/o: 4107.93/1160.98/569.99) lat (ms,95%): 759.88 err/s: 0.00 reconn/s: 0.00
[ 150s ] thds: 32 tps: 431.01 qps: 8534.14 (r/w/o: 5949.10/1723.03/862.01) lat (ms,95%): 125.52 err/s: 0.00 reconn/s: 0.00
[ 151s ] thds: 32 tps: 418.99 qps: 8429.71 (r/w/o: 5910.80/1680.94/837.97) lat (ms,95%): 125.52 err/s: 0.00 reconn/s: 0.00
[ 152s ] thds: 32 tps: 435.97 qps: 8661.40 (r/w/o: 6056.58/1732.88/871.94) lat (ms,95%): 118.92 err/s: 0.00 reconn/s: 0.00
[ 153s ] thds: 32 tps: 423.04 qps: 8415.83 (r/w/o: 5884.58/1685.17/846.08) lat (ms,95%): 123.28 err/s: 0.00 reconn/s: 0.00
[ 154s ] thds: 32 tps: 429.00 qps: 8617.08 (r/w/o: 6040.06/1719.02/858.01) lat (ms,95%): 118.92 err/s: 0.00 reconn/s: 0.00
[ 155s ] thds: 32 tps: 420.99 qps: 8442.80 (r/w/o: 5911.86/1688.96/841.98) lat (ms,95%): 118.92 err/s: 0.00 reconn/s: 0.00
[ 156s ] thds: 32 tps: 434.00 qps: 8754.04 (r/w/o: 6128.03/1758.01/868.00) lat (ms,95%): 116.80 err/s: 0.00 reconn/s: 0.00
[ 157s ] thds: 32 tps: 427.00 qps: 8528.95 (r/w/o: 5966.97/1707.99/854.00) lat (ms,95%): 121.08 err/s: 0.00 reconn/s: 0.00
[ 158s ] thds: 32 tps: 438.87 qps: 8697.43 (r/w/o: 6095.20/1725.49/876.74) lat (ms,95%): 121.08 err/s: 0.00 reconn/s: 0.00
[ 159s ] thds: 32 tps: 425.13 qps: 8604.65 (r/w/o: 6017.85/1735.53/851.26) lat (ms,95%): 114.72 err/s: 0.00 reconn/s: 0.00
[ 160s ] thds: 32 tps: 435.89 qps: 8634.77 (r/w/o: 6046.44/1716.56/871.78) lat (ms,95%): 116.80 err/s: 0.00 reconn/s: 0.00
[ 161s ] thds: 32 tps: 432.07 qps: 8660.41 (r/w/o: 6052.99/1745.28/862.14) lat (ms,95%): 118.92 err/s: 0.00 reconn/s: 0.00
[ 162s ] thds: 32 tps: 443.03 qps: 8727.68 (r/w/o: 6092.47/1747.14/888.07) lat (ms,95%): 114.72 err/s: 0.00 reconn/s: 0.00
[ 163s ] thds: 32 tps: 427.70 qps: 8692.99 (r/w/o: 6112.77/1724.81/855.41) lat (ms,95%): 118.92 err/s: 0.00 reconn/s: 0.00
[ 164s ] thds: 32 tps: 429.30 qps: 8623.98 (r/w/o: 6032.18/1733.20/858.60) lat (ms,95%): 118.92 err/s: 0.00 reconn/s: 0.00
[ 165s ] thds: 32 tps: 448.95 qps: 8934.08 (r/w/o: 6253.36/1783.82/896.91) lat (ms,95%): 108.68 err/s: 0.00 reconn/s: 0.00
[ 166s ] thds: 32 tps: 422.05 qps: 8482.93 (r/w/o: 5961.65/1676.18/845.09) lat (ms,95%): 114.72 err/s: 0.00 reconn/s: 0.00
[ 167s ] thds: 32 tps: 438.71 qps: 8749.14 (r/w/o: 6097.91/1775.81/875.41) lat (ms,95%): 114.72 err/s: 0.00 reconn/s: 0.00
[ 168s ] thds: 32 tps: 438.26 qps: 8761.25 (r/w/o: 6137.68/1747.05/876.53) lat (ms,95%): 118.92 err/s: 0.00 reconn/s: 0.00
[ 169s ] thds: 32 tps: 443.03 qps: 8753.58 (r/w/o: 6095.40/1771.12/887.06) lat (ms,95%): 114.72 err/s: 0.00 reconn/s: 0.00
[ 170s ] thds: 32 tps: 424.94 qps: 8679.79 (r/w/o: 6129.15/1699.76/850.88) lat (ms,95%): 114.72 err/s: 0.00 reconn/s: 0.00
[ 171s ] thds: 32 tps: 449.07 qps: 8890.40 (r/w/o: 6197.97/1795.28/897.14) lat (ms,95%): 106.75 err/s: 0.00 reconn/s: 0.00
[ 172s ] thds: 32 tps: 429.59 qps: 8561.89 (r/w/o: 6002.31/1699.39/860.19) lat (ms,95%): 118.92 err/s: 0.00 reconn/s: 0.00
[ 173s ] thds: 32 tps: 416.38 qps: 8465.72 (r/w/o: 5927.40/1705.55/832.76) lat (ms,95%): 134.90 err/s: 0.00 reconn/s: 0.00
[ 174s ] thds: 32 tps: 397.80 qps: 7907.96 (r/w/o: 5531.17/1581.19/795.59) lat (ms,95%): 164.45 err/s: 0.00 reconn/s: 0.00
[ 175s ] thds: 32 tps: 342.15 qps: 6691.89 (r/w/o: 4677.02/1330.57/684.30) lat (ms,95%): 215.44 err/s: 0.00 reconn/s: 0.00
[ 176s ] thds: 32 tps: 257.98 qps: 5235.61 (r/w/o: 3677.72/1041.92/515.96) lat (ms,95%): 325.98 err/s: 0.00 reconn/s: 0.00
[ 177s ] thds: 32 tps: 238.04 qps: 4708.83 (r/w/o: 3285.58/947.17/476.08) lat (ms,95%): 253.35 err/s: 0.00 reconn/s: 0.00
[ 178s ] thds: 32 tps: 137.00 qps: 2781.03 (r/w/o: 1959.02/548.01/274.00) lat (ms,95%): 493.24 err/s: 0.00 reconn/s: 0.00
[ 179s ] thds: 32 tps: 104.99 qps: 2092.87 (r/w/o: 1462.91/419.97/209.99) lat (ms,95%): 707.07 err/s: 0.00 reconn/s: 0.00
[ 180s ] thds: 32 tps: 67.00 qps: 1263.07 (r/w/o: 869.05/260.01/134.01) lat (ms,95%): 831.46 err/s: 0.00 reconn/s: 0.00
[ 181s ] thds: 32 tps: 35.00 qps: 815.95 (r/w/o: 595.96/149.99/70.00) lat (ms,95%): 1149.76 err/s: 0.00 reconn/s: 0.00
[ 182s ] thds: 32 tps: 59.00 qps: 1077.08 (r/w/o: 732.05/227.02/118.01) lat (ms,95%): 1129.24 err/s: 0.00 reconn/s: 0.00
[ 183s ] thds: 32 tps: 46.00 qps: 942.96 (r/w/o: 661.97/188.99/92.00) lat (ms,95%): 1129.24 err/s: 0.00 reconn/s: 0.00
[ 184s ] thds: 32 tps: 41.00 qps: 877.04 (r/w/o: 626.03/169.01/82.00) lat (ms,95%): 1235.62 err/s: 0.00 reconn/s: 0.00
[ 185s ] thds: 32 tps: 46.00 qps: 909.00 (r/w/o: 622.00/195.00/92.00) lat (ms,95%): 1533.66 err/s: 0.00 reconn/s: 0.00
[ 186s ] thds: 32 tps: 47.00 qps: 952.99 (r/w/o: 687.99/171.00/94.00) lat (ms,95%): 1327.91 err/s: 0.00 reconn/s: 0.00
[ 187s ] thds: 32 tps: 38.00 qps: 681.00 (r/w/o: 460.00/145.00/76.00) lat (ms,95%): 1304.21 err/s: 0.00 reconn/s: 0.00
[ 188s ] thds: 32 tps: 250.88 qps: 5211.60 (r/w/o: 3663.31/1046.52/501.77) lat (ms,95%): 816.63 err/s: 0.00 reconn/s: 0.00
[ 189s ] thds: 32 tps: 424.19 qps: 8348.83 (r/w/o: 5829.67/1672.77/846.39) lat (ms,95%): 125.52 err/s: 0.00 reconn/s: 0.00
[ 190s ] thds: 32 tps: 419.00 qps: 8383.92 (r/w/o: 5862.95/1680.98/839.99) lat (ms,95%): 118.92 err/s: 0.00 reconn/s: 0.00
[ 191s ] thds: 32 tps: 436.91 qps: 8757.17 (r/w/o: 6133.72/1749.63/873.82) lat (ms,95%): 118.92 err/s: 0.00 reconn/s: 0.00
[ 192s ] thds: 32 tps: 408.09 qps: 8137.78 (r/w/o: 5690.24/1631.36/816.18) lat (ms,95%): 127.81 err/s: 0.00 reconn/s: 0.00
[ 193s ] thds: 32 tps: 431.98 qps: 8735.52 (r/w/o: 6118.66/1752.90/863.95) lat (ms,95%): 110.66 err/s: 0.00 reconn/s: 0.00
[ 194s ] thds: 32 tps: 426.02 qps: 8428.45 (r/w/o: 5910.31/1667.09/851.05) lat (ms,95%): 118.92 err/s: 0.00 reconn/s: 0.00
[ 195s ] thds: 32 tps: 436.99 qps: 8836.73 (r/w/o: 6195.81/1765.95/874.97) lat (ms,95%): 116.80 err/s: 0.00 reconn/s: 0.00
[ 196s ] thds: 32 tps: 430.94 qps: 8607.82 (r/w/o: 6012.17/1733.76/861.88) lat (ms,95%): 114.72 err/s: 0.00 reconn/s: 0.00
[ 197s ] thds: 32 tps: 443.97 qps: 8820.33 (r/w/o: 6174.53/1757.87/887.93) lat (ms,95%): 114.72 err/s: 0.00 reconn/s: 0.00
[ 198s ] thds: 32 tps: 430.10 qps: 8566.95 (r/w/o: 5997.37/1710.39/859.20) lat (ms,95%): 118.92 err/s: 0.00 reconn/s: 0.00
[ 199s ] thds: 32 tps: 422.00 qps: 8554.08 (r/w/o: 5990.06/1719.02/845.01) lat (ms,95%): 116.80 err/s: 0.00 reconn/s: 0.00
[ 200s ] thds: 32 tps: 438.92 qps: 8751.31 (r/w/o: 6133.82/1739.66/877.83) lat (ms,95%): 114.72 err/s: 0.00 reconn/s: 0.00
[ 201s ] thds: 32 tps: 434.09 qps: 8669.80 (r/w/o: 6057.26/1745.36/867.18) lat (ms,95%): 110.66 err/s: 0.00 reconn/s: 0.00
[ 202s ] thds: 32 tps: 430.93 qps: 8631.61 (r/w/o: 6052.03/1716.72/862.86) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 203s ] thds: 32 tps: 437.06 qps: 8685.22 (r/w/o: 6070.85/1740.24/874.12) lat (ms,95%): 114.72 err/s: 0.00 reconn/s: 0.00
[ 204s ] thds: 32 tps: 434.97 qps: 8675.32 (r/w/o: 6063.52/1742.86/868.93) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 205s ] thds: 32 tps: 443.97 qps: 8898.37 (r/w/o: 6232.56/1776.87/888.94) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 206s ] thds: 32 tps: 431.02 qps: 8721.31 (r/w/o: 6112.22/1747.06/862.03) lat (ms,95%): 118.92 err/s: 0.00 reconn/s: 0.00
[ 207s ] thds: 32 tps: 455.54 qps: 9126.79 (r/w/o: 6395.54/1820.16/911.08) lat (ms,95%): 108.68 err/s: 0.00 reconn/s: 0.00
[ 208s ] thds: 32 tps: 445.41 qps: 8766.02 (r/w/o: 6131.61/1744.60/889.81) lat (ms,95%): 114.72 err/s: 0.00 reconn/s: 0.00
[ 209s ] thds: 32 tps: 442.95 qps: 8923.90 (r/w/o: 6249.23/1787.78/886.89) lat (ms,95%): 118.92 err/s: 0.00 reconn/s: 0.00
[ 210s ] thds: 32 tps: 456.05 qps: 9112.97 (r/w/o: 6359.68/1841.20/912.10) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 211s ] thds: 32 tps: 450.05 qps: 9037.01 (r/w/o: 6352.71/1784.20/900.10) lat (ms,95%): 118.92 err/s: 0.00 reconn/s: 0.00
[ 212s ] thds: 32 tps: 446.06 qps: 8813.26 (r/w/o: 6150.88/1770.25/892.13) lat (ms,95%): 121.08 err/s: 0.00 reconn/s: 0.00
[ 213s ] thds: 32 tps: 254.98 qps: 5113.60 (r/w/o: 3592.72/1010.92/509.96) lat (ms,95%): 404.61 err/s: 0.00 reconn/s: 0.00
[ 214s ] thds: 32 tps: 168.96 qps: 3423.17 (r/w/o: 2386.42/698.83/337.92) lat (ms,95%): 530.08 err/s: 0.00 reconn/s: 0.00
[ 215s ] thds: 32 tps: 195.04 qps: 3927.76 (r/w/o: 2748.53/789.15/390.08) lat (ms,95%): 520.62 err/s: 0.00 reconn/s: 0.00
[ 216s ] thds: 32 tps: 135.02 qps: 2668.30 (r/w/o: 1862.21/536.06/270.03) lat (ms,95%): 475.79 err/s: 0.00 reconn/s: 0.00
[ 217s ] thds: 32 tps: 103.00 qps: 2022.02 (r/w/o: 1433.01/383.00/206.00) lat (ms,95%): 669.89 err/s: 0.00 reconn/s: 0.00
[ 218s ] thds: 32 tps: 52.00 qps: 1046.99 (r/w/o: 733.00/210.00/104.00) lat (ms,95%): 960.30 err/s: 0.00 reconn/s: 0.00
[ 219s ] thds: 32 tps: 47.00 qps: 881.00 (r/w/o: 599.00/188.00/94.00) lat (ms,95%): 1453.01 err/s: 0.00 reconn/s: 0.00
[ 220s ] thds: 32 tps: 61.00 qps: 1279.00 (r/w/o: 911.00/246.00/122.00) lat (ms,95%): 1069.86 err/s: 0.00 reconn/s: 0.00
[ 221s ] thds: 32 tps: 23.00 qps: 487.00 (r/w/o: 342.00/99.00/46.00) lat (ms,95%): 1191.92 err/s: 0.00 reconn/s: 0.00
[ 222s ] thds: 32 tps: 30.00 qps: 613.00 (r/w/o: 431.00/122.00/60.00) lat (ms,95%): 1869.60 err/s: 0.00 reconn/s: 0.00
[ 223s ] thds: 32 tps: 40.00 qps: 714.01 (r/w/o: 489.00/145.00/80.00) lat (ms,95%): 2493.86 err/s: 0.00 reconn/s: 0.00
[ 224s ] thds: 32 tps: 41.00 qps: 829.01 (r/w/o: 584.01/163.00/82.00) lat (ms,95%): 1648.20 err/s: 0.00 reconn/s: 0.00
[ 225s ] thds: 32 tps: 30.00 qps: 617.99 (r/w/o: 430.00/128.00/60.00) lat (ms,95%): 2009.23 err/s: 0.00 reconn/s: 0.00
[ 226s ] thds: 32 tps: 92.98 qps: 1847.54 (r/w/o: 1289.68/371.91/185.95) lat (ms,95%): 1533.66 err/s: 0.00 reconn/s: 0.00
[ 227s ] thds: 32 tps: 441.10 qps: 8902.10 (r/w/o: 6242.47/1777.42/882.21) lat (ms,95%): 127.81 err/s: 0.00 reconn/s: 0.00
[ 228s ] thds: 32 tps: 431.60 qps: 8604.07 (r/w/o: 5999.47/1741.40/863.20) lat (ms,95%): 125.52 err/s: 0.00 reconn/s: 0.00
[ 229s ] thds: 32 tps: 437.83 qps: 8775.64 (r/w/o: 6159.64/1740.33/875.66) lat (ms,95%): 118.92 err/s: 0.00 reconn/s: 0.00
[ 230s ] thds: 32 tps: 443.53 qps: 8808.48 (r/w/o: 6159.33/1762.10/887.06) lat (ms,95%): 116.80 err/s: 0.00 reconn/s: 0.00
[ 231s ] thds: 32 tps: 440.03 qps: 8920.62 (r/w/o: 6244.43/1796.12/880.06) lat (ms,95%): 110.66 err/s: 0.00 reconn/s: 0.00
[ 232s ] thds: 32 tps: 457.02 qps: 9038.34 (r/w/o: 6320.24/1806.07/912.03) lat (ms,95%): 108.68 err/s: 0.00 reconn/s: 0.00
[ 233s ] thds: 32 tps: 449.00 qps: 9010.02 (r/w/o: 6334.01/1776.00/900.00) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 234s ] thds: 32 tps: 459.01 qps: 9214.26 (r/w/o: 6433.18/1863.05/918.03) lat (ms,95%): 116.80 err/s: 0.00 reconn/s: 0.00
[ 235s ] thds: 32 tps: 456.94 qps: 9134.79 (r/w/o: 6394.16/1826.76/913.88) lat (ms,95%): 106.75 err/s: 0.00 reconn/s: 0.00
[ 236s ] thds: 32 tps: 448.10 qps: 8913.41 (r/w/o: 6234.72/1783.48/895.22) lat (ms,95%): 110.66 err/s: 0.00 reconn/s: 0.00
[ 237s ] thds: 32 tps: 444.81 qps: 8983.83 (r/w/o: 6300.86/1792.34/890.63) lat (ms,95%): 116.80 err/s: 0.00 reconn/s: 0.00
[ 238s ] thds: 32 tps: 474.07 qps: 9357.31 (r/w/o: 6532.91/1877.26/947.13) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 239s ] thds: 32 tps: 452.02 qps: 9025.36 (r/w/o: 6327.25/1793.07/905.04) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 240s ] thds: 32 tps: 458.97 qps: 9312.31 (r/w/o: 6509.52/1884.86/917.93) lat (ms,95%): 104.84 err/s: 0.00 reconn/s: 0.00
[ 241s ] thds: 32 tps: 469.99 qps: 9402.71 (r/w/o: 6594.80/1867.94/939.97) lat (ms,95%): 110.66 err/s: 0.00 reconn/s: 0.00
[ 242s ] thds: 32 tps: 446.07 qps: 8993.38 (r/w/o: 6288.96/1813.28/891.14) lat (ms,95%): 106.75 err/s: 0.00 reconn/s: 0.00
[ 243s ] thds: 32 tps: 471.85 qps: 9319.07 (r/w/o: 6518.95/1856.42/943.70) lat (ms,95%): 108.68 err/s: 0.00 reconn/s: 0.00
[ 244s ] thds: 32 tps: 438.15 qps: 8863.00 (r/w/o: 6216.10/1769.60/877.30) lat (ms,95%): 116.80 err/s: 0.00 reconn/s: 0.00
[ 245s ] thds: 32 tps: 466.00 qps: 9214.07 (r/w/o: 6448.05/1834.01/932.01) lat (ms,95%): 114.72 err/s: 0.00 reconn/s: 0.00
[ 246s ] thds: 32 tps: 445.95 qps: 9029.00 (r/w/o: 6317.30/1819.80/891.90) lat (ms,95%): 108.68 err/s: 0.00 reconn/s: 0.00
[ 247s ] thds: 32 tps: 463.02 qps: 9192.39 (r/w/o: 6430.27/1837.08/925.04) lat (ms,95%): 110.66 err/s: 0.00 reconn/s: 0.00
[ 248s ] thds: 32 tps: 448.00 qps: 8982.97 (r/w/o: 6289.98/1795.99/897.00) lat (ms,95%): 108.68 err/s: 0.00 reconn/s: 0.00
[ 249s ] thds: 32 tps: 458.94 qps: 9148.77 (r/w/o: 6403.14/1827.75/917.88) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 250s ] thds: 32 tps: 443.08 qps: 8800.65 (r/w/o: 6168.16/1746.33/886.17) lat (ms,95%): 114.72 err/s: 0.00 reconn/s: 0.00
[ 251s ] thds: 32 tps: 347.95 qps: 7000.07 (r/w/o: 4904.35/1399.81/695.91) lat (ms,95%): 248.83 err/s: 0.00 reconn/s: 0.00
[ 252s ] thds: 32 tps: 354.01 qps: 7116.24 (r/w/o: 4966.17/1443.05/707.02) lat (ms,95%): 227.40 err/s: 0.00 reconn/s: 0.00
[ 253s ] thds: 32 tps: 181.02 qps: 3519.43 (r/w/o: 2477.31/679.08/363.04) lat (ms,95%): 467.30 err/s: 0.00 reconn/s: 0.00
[ 254s ] thds: 32 tps: 221.97 qps: 4457.40 (r/w/o: 3113.58/899.88/443.94) lat (ms,95%): 363.18 err/s: 0.00 reconn/s: 0.00
[ 255s ] thds: 32 tps: 173.02 qps: 3453.46 (r/w/o: 2424.33/683.09/346.05) lat (ms,95%): 404.61 err/s: 0.00 reconn/s: 0.00
[ 256s ] thds: 32 tps: 99.00 qps: 1967.93 (r/w/o: 1378.95/390.99/197.99) lat (ms,95%): 623.33 err/s: 0.00 reconn/s: 0.00
[ 257s ] thds: 32 tps: 46.00 qps: 995.02 (r/w/o: 708.02/195.00/92.00) lat (ms,95%): 893.56 err/s: 0.00 reconn/s: 0.00
[ 258s ] thds: 32 tps: 85.00 qps: 1623.01 (r/w/o: 1123.01/330.00/170.00) lat (ms,95%): 1280.93 err/s: 0.00 reconn/s: 0.00
[ 259s ] thds: 32 tps: 36.00 qps: 808.00 (r/w/o: 584.00/152.00/72.00) lat (ms,95%): 960.30 err/s: 0.00 reconn/s: 0.00
[ 260s ] thds: 32 tps: 71.00 qps: 1311.95 (r/w/o: 892.97/276.99/141.99) lat (ms,95%): 1561.52 err/s: 0.00 reconn/s: 0.00
[ 261s ] thds: 32 tps: 43.00 qps: 879.95 (r/w/o: 626.97/166.99/86.00) lat (ms,95%): 1213.57 err/s: 0.00 reconn/s: 0.00
[ 262s ] thds: 32 tps: 49.00 qps: 970.05 (r/w/o: 669.04/203.01/98.01) lat (ms,95%): 1327.91 err/s: 0.00 reconn/s: 0.00
[ 263s ] thds: 32 tps: 23.99 qps: 571.83 (r/w/o: 408.88/114.97/47.99) lat (ms,95%): 1089.30 err/s: 0.00 reconn/s: 0.00
[ 264s ] thds: 32 tps: 19.01 qps: 384.12 (r/w/o: 270.08/76.02/38.01) lat (ms,95%): 1618.78 err/s: 0.00 reconn/s: 0.00
[ 265s ] thds: 32 tps: 17.00 qps: 336.00 (r/w/o: 247.00/55.00/34.00) lat (ms,95%): 2449.36 err/s: 0.00 reconn/s: 0.00
[ 266s ] thds: 32 tps: 109.99 qps: 2150.81 (r/w/o: 1481.87/448.96/219.98) lat (ms,95%): 2778.39 err/s: 0.00 reconn/s: 0.00
[ 267s ] thds: 32 tps: 436.94 qps: 8725.82 (r/w/o: 6109.17/1742.76/873.88) lat (ms,95%): 125.52 err/s: 0.00 reconn/s: 0.00
[ 268s ] thds: 32 tps: 434.10 qps: 8742.95 (r/w/o: 6129.37/1745.39/868.19) lat (ms,95%): 118.92 err/s: 0.00 reconn/s: 0.00
[ 269s ] thds: 32 tps: 451.79 qps: 9034.80 (r/w/o: 6305.07/1826.15/903.58) lat (ms,95%): 114.72 err/s: 0.00 reconn/s: 0.00
[ 270s ] thds: 32 tps: 439.90 qps: 8808.91 (r/w/o: 6185.53/1743.59/879.79) lat (ms,95%): 114.72 err/s: 0.00 reconn/s: 0.00
[ 271s ] thds: 32 tps: 453.28 qps: 8949.54 (r/w/o: 6243.87/1802.12/903.56) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 272s ] thds: 32 tps: 447.02 qps: 9079.37 (r/w/o: 6377.26/1805.07/897.04) lat (ms,95%): 108.68 err/s: 0.00 reconn/s: 0.00
[ 273s ] thds: 32 tps: 460.99 qps: 9101.73 (r/w/o: 6361.81/1820.95/918.97) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 274s ] thds: 32 tps: 462.03 qps: 9244.63 (r/w/o: 6466.44/1851.13/927.06) lat (ms,95%): 110.66 err/s: 0.00 reconn/s: 0.00
[ 275s ] thds: 32 tps: 446.92 qps: 8997.47 (r/w/o: 6302.93/1800.69/893.85) lat (ms,95%): 108.68 err/s: 0.00 reconn/s: 0.00
[ 276s ] thds: 32 tps: 465.01 qps: 9314.25 (r/w/o: 6502.18/1882.05/930.03) lat (ms,95%): 110.66 err/s: 0.00 reconn/s: 0.00
[ 277s ] thds: 32 tps: 452.03 qps: 9001.56 (r/w/o: 6307.39/1791.11/903.06) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 278s ] thds: 32 tps: 461.97 qps: 9271.45 (r/w/o: 6501.61/1844.89/924.95) lat (ms,95%): 110.66 err/s: 0.00 reconn/s: 0.00
[ 279s ] thds: 32 tps: 455.03 qps: 9070.50 (r/w/o: 6359.35/1801.10/910.05) lat (ms,95%): 110.66 err/s: 0.00 reconn/s: 0.00
[ 280s ] thds: 32 tps: 453.91 qps: 9108.15 (r/w/o: 6366.71/1833.63/907.82) lat (ms,95%): 108.68 err/s: 0.00 reconn/s: 0.00
[ 281s ] thds: 32 tps: 448.11 qps: 8999.18 (r/w/o: 6305.53/1798.44/895.22) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 282s ] thds: 32 tps: 459.96 qps: 9245.14 (r/w/o: 6466.40/1858.83/919.91) lat (ms,95%): 106.75 err/s: 0.00 reconn/s: 0.00
[ 283s ] thds: 32 tps: 453.03 qps: 9010.68 (r/w/o: 6283.47/1822.14/905.07) lat (ms,95%): 110.66 err/s: 0.00 reconn/s: 0.00
[ 284s ] thds: 32 tps: 457.97 qps: 9133.39 (r/w/o: 6411.57/1803.88/917.94) lat (ms,95%): 110.66 err/s: 0.00 reconn/s: 0.00
[ 285s ] thds: 32 tps: 449.06 qps: 8962.21 (r/w/o: 6251.84/1815.25/895.12) lat (ms,95%): 116.80 err/s: 0.00 reconn/s: 0.00
[ 286s ] thds: 32 tps: 464.00 qps: 9270.07 (r/w/o: 6510.05/1829.01/931.01) lat (ms,95%): 108.68 err/s: 0.00 reconn/s: 0.00
[ 287s ] thds: 32 tps: 462.00 qps: 9237.01 (r/w/o: 6467.00/1846.00/924.00) lat (ms,95%): 108.68 err/s: 0.00 reconn/s: 0.00
[ 288s ] thds: 32 tps: 449.01 qps: 9027.14 (r/w/o: 6342.10/1787.03/898.01) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 289s ] thds: 32 tps: 474.84 qps: 9391.89 (r/w/o: 6535.83/1909.37/946.69) lat (ms,95%): 108.68 err/s: 0.00 reconn/s: 0.00
[ 290s ] thds: 32 tps: 438.14 qps: 8922.92 (r/w/o: 6273.05/1770.58/879.29) lat (ms,95%): 118.92 err/s: 0.00 reconn/s: 0.00
[ 291s ] thds: 32 tps: 463.99 qps: 9216.73 (r/w/o: 6443.81/1845.95/926.97) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 292s ] thds: 32 tps: 448.01 qps: 8943.27 (r/w/o: 6248.19/1798.05/897.03) lat (ms,95%): 116.80 err/s: 0.00 reconn/s: 0.00
[ 293s ] thds: 32 tps: 356.99 qps: 7107.77 (r/w/o: 4987.84/1405.95/713.98) lat (ms,95%): 196.89 err/s: 0.00 reconn/s: 0.00
[ 294s ] thds: 32 tps: 303.97 qps: 6086.48 (r/w/o: 4260.64/1217.90/607.95) lat (ms,95%): 282.25 err/s: 0.00 reconn/s: 0.00
[ 295s ] thds: 32 tps: 241.02 qps: 4832.46 (r/w/o: 3387.32/963.09/482.05) lat (ms,95%): 344.08 err/s: 0.00 reconn/s: 0.00
[ 296s ] thds: 32 tps: 193.01 qps: 3883.14 (r/w/o: 2732.10/765.03/386.01) lat (ms,95%): 363.18 err/s: 0.00 reconn/s: 0.00
[ 297s ] thds: 32 tps: 181.00 qps: 3562.02 (r/w/o: 2474.02/726.00/362.00) lat (ms,95%): 530.08 err/s: 0.00 reconn/s: 0.00
[ 298s ] thds: 32 tps: 115.00 qps: 2285.99 (r/w/o: 1610.99/445.00/230.00) lat (ms,95%): 580.02 err/s: 0.00 reconn/s: 0.00
[ 299s ] thds: 32 tps: 66.00 qps: 1339.95 (r/w/o: 933.96/273.99/131.99) lat (ms,95%): 831.46 err/s: 0.00 reconn/s: 0.00
[ 300s ] thds: 32 tps: 45.00 qps: 866.03 (r/w/o: 599.02/177.01/90.00) lat (ms,95%): 1304.21 err/s: 0.00 reconn/s: 0.00
[ 301s ] thds: 32 tps: 32.00 qps: 682.00 (r/w/o: 490.00/128.00/64.00) lat (ms,95%): 1352.03 err/s: 0.00 reconn/s: 0.00
[ 302s ] thds: 32 tps: 38.00 qps: 773.99 (r/w/o: 536.99/161.00/76.00) lat (ms,95%): 1453.01 err/s: 0.00 reconn/s: 0.00
[ 303s ] thds: 32 tps: 47.00 qps: 916.01 (r/w/o: 638.00/184.00/94.00) lat (ms,95%): 1708.63 err/s: 0.00 reconn/s: 0.00
[ 304s ] thds: 32 tps: 51.00 qps: 1007.01 (r/w/o: 709.01/196.00/102.00) lat (ms,95%): 1352.03 err/s: 0.00 reconn/s: 0.00
[ 305s ] thds: 32 tps: 42.00 qps: 838.00 (r/w/o: 586.00/168.00/84.00) lat (ms,95%): 1427.08 err/s: 0.00 reconn/s: 0.00
[ 306s ] thds: 32 tps: 26.00 qps: 541.00 (r/w/o: 375.00/114.00/52.00) lat (ms,95%): 1280.93 err/s: 0.00 reconn/s: 0.00
[ 307s ] thds: 32 tps: 138.87 qps: 2829.33 (r/w/o: 1995.12/556.47/277.74) lat (ms,95%): 1327.91 err/s: 0.00 reconn/s: 0.00
[ 308s ] thds: 32 tps: 442.38 qps: 8851.53 (r/w/o: 6177.26/1789.52/884.75) lat (ms,95%): 130.13 err/s: 0.00 reconn/s: 0.00
[ 309s ] thds: 32 tps: 438.72 qps: 8795.37 (r/w/o: 6169.05/1748.88/877.44) lat (ms,95%): 118.92 err/s: 0.00 reconn/s: 0.00
[ 310s ] thds: 32 tps: 450.28 qps: 9027.65 (r/w/o: 6310.95/1816.14/900.56) lat (ms,95%): 121.08 err/s: 0.00 reconn/s: 0.00
[ 311s ] thds: 32 tps: 419.05 qps: 8361.90 (r/w/o: 5858.63/1665.18/838.09) lat (ms,95%): 121.08 err/s: 0.00 reconn/s: 0.00
[ 312s ] thds: 32 tps: 448.96 qps: 8925.26 (r/w/o: 6224.49/1804.85/895.93) lat (ms,95%): 121.08 err/s: 0.00 reconn/s: 0.00
[ 313s ] thds: 32 tps: 452.94 qps: 8971.76 (r/w/o: 6288.13/1775.75/907.87) lat (ms,95%): 114.72 err/s: 0.00 reconn/s: 0.00
[ 314s ] thds: 32 tps: 439.06 qps: 8826.19 (r/w/o: 6184.83/1763.24/878.12) lat (ms,95%): 108.68 err/s: 0.00 reconn/s: 0.00
[ 315s ] thds: 32 tps: 435.87 qps: 8751.41 (r/w/o: 6126.19/1753.48/871.74) lat (ms,95%): 116.80 err/s: 0.00 reconn/s: 0.00
[ 316s ] thds: 32 tps: 449.10 qps: 8942.03 (r/w/o: 6254.42/1790.41/897.20) lat (ms,95%): 108.68 err/s: 0.00 reconn/s: 0.00
[ 317s ] thds: 32 tps: 454.96 qps: 9059.13 (r/w/o: 6343.39/1806.83/908.91) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 318s ] thds: 32 tps: 452.10 qps: 9212.10 (r/w/o: 6462.47/1843.42/906.21) lat (ms,95%): 106.75 err/s: 0.00 reconn/s: 0.00
[ 319s ] thds: 32 tps: 456.95 qps: 9078.91 (r/w/o: 6338.24/1826.78/913.89) lat (ms,95%): 110.66 err/s: 0.00 reconn/s: 0.00
[ 320s ] thds: 32 tps: 451.03 qps: 8983.58 (r/w/o: 6292.41/1791.12/900.06) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 321s ] thds: 32 tps: 461.85 qps: 9152.09 (r/w/o: 6380.97/1846.41/924.71) lat (ms,95%): 110.66 err/s: 0.00 reconn/s: 0.00
[ 322s ] thds: 32 tps: 456.09 qps: 9225.82 (r/w/o: 6484.28/1828.36/913.18) lat (ms,95%): 114.72 err/s: 0.00 reconn/s: 0.00
[ 323s ] thds: 32 tps: 437.90 qps: 8862.93 (r/w/o: 6203.55/1783.58/875.80) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 324s ] thds: 32 tps: 463.20 qps: 9225.93 (r/w/o: 6459.75/1839.78/926.39) lat (ms,95%): 104.84 err/s: 0.00 reconn/s: 0.00
[ 325s ] thds: 32 tps: 443.97 qps: 8873.44 (r/w/o: 6221.61/1763.89/887.94) lat (ms,95%): 114.72 err/s: 0.00 reconn/s: 0.00
[ 326s ] thds: 32 tps: 476.02 qps: 9391.41 (r/w/o: 6557.29/1883.08/951.04) lat (ms,95%): 106.75 err/s: 0.00 reconn/s: 0.00
[ 327s ] thds: 32 tps: 452.95 qps: 9054.09 (r/w/o: 6321.37/1831.82/900.91) lat (ms,95%): 121.08 err/s: 0.00 reconn/s: 0.00
[ 328s ] thds: 32 tps: 444.05 qps: 9010.98 (r/w/o: 6340.69/1776.19/894.10) lat (ms,95%): 114.72 err/s: 0.00 reconn/s: 0.00
[ 329s ] thds: 32 tps: 454.98 qps: 9086.55 (r/w/o: 6349.69/1826.91/909.95) lat (ms,95%): 114.72 err/s: 0.00 reconn/s: 0.00
[ 330s ] thds: 32 tps: 453.80 qps: 9161.87 (r/w/o: 6412.11/1842.17/907.59) lat (ms,95%): 110.66 err/s: 0.00 reconn/s: 0.00
[ 331s ] thds: 32 tps: 334.61 qps: 6412.56 (r/w/o: 4470.81/1272.52/669.22) lat (ms,95%): 150.29 err/s: 0.00 reconn/s: 0.00
[ 332s ] thds: 32 tps: 259.44 qps: 5338.96 (r/w/o: 3766.32/1053.77/518.87) lat (ms,95%): 520.62 err/s: 0.00 reconn/s: 0.00
[ 333s ] thds: 32 tps: 126.00 qps: 2512.03 (r/w/o: 1762.02/498.01/252.00) lat (ms,95%): 669.89 err/s: 0.00 reconn/s: 0.00
[ 334s ] thds: 32 tps: 196.99 qps: 3913.90 (r/w/o: 2730.93/788.98/393.99) lat (ms,95%): 419.45 err/s: 0.00 reconn/s: 0.00
[ 335s ] thds: 32 tps: 164.00 qps: 3271.05 (r/w/o: 2291.04/652.01/328.01) lat (ms,95%): 442.73 err/s: 0.00 reconn/s: 0.00
[ 336s ] thds: 32 tps: 127.98 qps: 2592.60 (r/w/o: 1824.72/511.92/255.96) lat (ms,95%): 601.29 err/s: 0.00 reconn/s: 0.00
[ 337s ] thds: 32 tps: 103.02 qps: 2018.31 (r/w/o: 1401.21/411.06/206.03) lat (ms,95%): 746.32 err/s: 0.00 reconn/s: 0.00
[ 338s ] thds: 32 tps: 75.99 qps: 1546.87 (r/w/o: 1089.91/305.97/150.99) lat (ms,95%): 623.33 err/s: 0.00 reconn/s: 0.00
[ 339s ] thds: 32 tps: 43.00 qps: 875.08 (r/w/o: 615.06/173.02/87.01) lat (ms,95%): 1089.30 err/s: 0.00 reconn/s: 0.00
[ 340s ] thds: 32 tps: 48.00 qps: 934.98 (r/w/o: 645.98/193.00/96.00) lat (ms,95%): 1589.90 err/s: 0.00 reconn/s: 0.00
[ 341s ] thds: 32 tps: 39.00 qps: 817.00 (r/w/o: 577.00/162.00/78.00) lat (ms,95%): 1533.66 err/s: 0.00 reconn/s: 0.00
[ 342s ] thds: 32 tps: 73.00 qps: 1369.00 (r/w/o: 944.00/279.00/146.00) lat (ms,95%): 1069.86 err/s: 0.00 reconn/s: 0.00
[ 343s ] thds: 32 tps: 36.94 qps: 768.70 (r/w/o: 552.07/142.76/73.88) lat (ms,95%): 1453.01 err/s: 0.00 reconn/s: 0.00
[ 344s ] thds: 32 tps: 32.05 qps: 669.14 (r/w/o: 475.81/129.22/64.11) lat (ms,95%): 1401.61 err/s: 0.00 reconn/s: 0.00
[ 345s ] thds: 32 tps: 31.00 qps: 601.00 (r/w/o: 412.00/127.00/62.00) lat (ms,95%): 1938.16 err/s: 0.00 reconn/s: 0.00
[ 346s ] thds: 32 tps: 236.00 qps: 4752.93 (r/w/o: 3315.95/967.99/468.99) lat (ms,95%): 1129.24 err/s: 0.00 reconn/s: 0.00
[ 347s ] thds: 32 tps: 431.83 qps: 8663.57 (r/w/o: 6066.59/1730.31/866.66) lat (ms,95%): 116.80 err/s: 0.00 reconn/s: 0.00
[ 348s ] thds: 32 tps: 432.17 qps: 8628.34 (r/w/o: 6049.34/1714.66/864.33) lat (ms,95%): 127.81 err/s: 0.00 reconn/s: 0.00
[ 349s ] thds: 32 tps: 442.97 qps: 8830.44 (r/w/o: 6168.61/1778.89/882.94) lat (ms,95%): 118.92 err/s: 0.00 reconn/s: 0.00
[ 350s ] thds: 32 tps: 443.00 qps: 8839.04 (r/w/o: 6190.03/1760.01/889.00) lat (ms,95%): 114.72 err/s: 0.00 reconn/s: 0.00
[ 351s ] thds: 32 tps: 453.91 qps: 9096.21 (r/w/o: 6358.75/1829.64/907.82) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 352s ] thds: 32 tps: 454.11 qps: 9129.29 (r/w/o: 6397.60/1823.46/908.23) lat (ms,95%): 108.68 err/s: 0.00 reconn/s: 0.00
[ 353s ] thds: 32 tps: 457.97 qps: 9164.38 (r/w/o: 6427.56/1820.88/915.94) lat (ms,95%): 110.66 err/s: 0.00 reconn/s: 0.00
[ 354s ] thds: 32 tps: 450.00 qps: 9100.08 (r/w/o: 6361.06/1839.02/900.01) lat (ms,95%): 114.72 err/s: 0.00 reconn/s: 0.00
[ 355s ] thds: 32 tps: 467.97 qps: 9200.38 (r/w/o: 6431.57/1832.88/935.94) lat (ms,95%): 106.75 err/s: 0.00 reconn/s: 0.00
[ 356s ] thds: 32 tps: 439.98 qps: 8848.53 (r/w/o: 6200.67/1767.91/879.95) lat (ms,95%): 114.72 err/s: 0.00 reconn/s: 0.00
[ 357s ] thds: 32 tps: 457.98 qps: 9201.60 (r/w/o: 6445.72/1839.92/915.96) lat (ms,95%): 108.68 err/s: 0.00 reconn/s: 0.00
[ 358s ] thds: 32 tps: 452.99 qps: 9041.75 (r/w/o: 6333.82/1801.95/905.97) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 359s ] thds: 32 tps: 464.72 qps: 9255.51 (r/w/o: 6475.16/1851.90/928.45) lat (ms,95%): 110.66 err/s: 0.00 reconn/s: 0.00
[ 360s ] thds: 32 tps: 450.38 qps: 8978.52 (r/w/o: 6276.26/1800.51/901.76) lat (ms,95%): 114.72 err/s: 0.00 reconn/s: 0.00
[ 361s ] thds: 32 tps: 460.65 qps: 9230.91 (r/w/o: 6450.05/1859.57/921.29) lat (ms,95%): 108.68 err/s: 0.00 reconn/s: 0.00
[ 362s ] thds: 32 tps: 453.28 qps: 9106.54 (r/w/o: 6371.88/1828.11/906.55) lat (ms,95%): 104.84 err/s: 0.00 reconn/s: 0.00
[ 363s ] thds: 32 tps: 456.06 qps: 9088.12 (r/w/o: 6369.79/1807.22/911.11) lat (ms,95%): 106.75 err/s: 0.00 reconn/s: 0.00
[ 364s ] thds: 32 tps: 454.99 qps: 9054.72 (r/w/o: 6332.81/1811.94/909.97) lat (ms,95%): 110.66 err/s: 0.00 reconn/s: 0.00
[ 365s ] thds: 32 tps: 458.95 qps: 9188.09 (r/w/o: 6447.36/1821.82/918.91) lat (ms,95%): 110.66 err/s: 0.00 reconn/s: 0.00
[ 366s ] thds: 32 tps: 446.09 qps: 8956.82 (r/w/o: 6253.27/1812.37/891.18) lat (ms,95%): 114.72 err/s: 0.00 reconn/s: 0.00
[ 367s ] thds: 32 tps: 456.96 qps: 9193.15 (r/w/o: 6453.40/1824.83/914.92) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 368s ] thds: 32 tps: 456.98 qps: 9053.52 (r/w/o: 6340.66/1799.90/912.95) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 369s ] thds: 32 tps: 445.00 qps: 8994.96 (r/w/o: 6300.97/1803.99/890.00) lat (ms,95%): 106.75 err/s: 0.00 reconn/s: 0.00
[ 370s ] thds: 32 tps: 440.06 qps: 8705.15 (r/w/o: 6084.80/1739.23/881.12) lat (ms,95%): 125.52 err/s: 0.00 reconn/s: 0.00
[ 371s ] thds: 32 tps: 263.00 qps: 5412.06 (r/w/o: 3787.04/1099.01/526.01) lat (ms,95%): 253.35 err/s: 0.00 reconn/s: 0.00
[ 372s ] thds: 32 tps: 179.99 qps: 3449.78 (r/w/o: 2423.85/665.96/359.98) lat (ms,95%): 467.30 err/s: 0.00 reconn/s: 0.00
[ 373s ] thds: 32 tps: 117.01 qps: 2376.10 (r/w/o: 1670.07/472.02/234.01) lat (ms,95%): 733.00 err/s: 0.00 reconn/s: 0.00
[ 374s ] thds: 32 tps: 227.00 qps: 4513.04 (r/w/o: 3156.03/903.01/454.00) lat (ms,95%): 383.33 err/s: 0.00 reconn/s: 0.00
[ 375s ] thds: 32 tps: 137.00 qps: 2786.01 (r/w/o: 1953.01/559.00/274.00) lat (ms,95%): 467.30 err/s: 0.00 reconn/s: 0.00
[ 376s ] thds: 32 tps: 96.00 qps: 1896.02 (r/w/o: 1331.01/373.00/192.00) lat (ms,95%): 669.89 err/s: 0.00 reconn/s: 0.00
[ 377s ] thds: 32 tps: 48.00 qps: 1009.98 (r/w/o: 710.99/203.00/96.00) lat (ms,95%): 1170.65 err/s: 0.00 reconn/s: 0.00
[ 378s ] thds: 32 tps: 55.00 qps: 1091.01 (r/w/o: 765.01/216.00/110.00) lat (ms,95%): 1453.01 err/s: 0.00 reconn/s: 0.00
[ 379s ] thds: 32 tps: 41.00 qps: 797.00 (r/w/o: 541.00/174.00/82.00) lat (ms,95%): 1708.63 err/s: 0.00 reconn/s: 0.00
[ 380s ] thds: 32 tps: 57.00 qps: 1102.01 (r/w/o: 777.01/211.00/114.00) lat (ms,95%): 1589.90 err/s: 0.00 reconn/s: 0.00
[ 381s ] thds: 32 tps: 44.00 qps: 848.00 (r/w/o: 583.00/177.00/88.00) lat (ms,95%): 1032.01 err/s: 0.00 reconn/s: 0.00
[ 382s ] thds: 32 tps: 43.00 qps: 973.00 (r/w/o: 679.00/208.00/86.00) lat (ms,95%): 1678.14 err/s: 0.00 reconn/s: 0.00
[ 383s ] thds: 32 tps: 42.00 qps: 771.00 (r/w/o: 550.00/137.00/84.00) lat (ms,95%): 1506.29 err/s: 0.00 reconn/s: 0.00
[ 384s ] thds: 32 tps: 30.00 qps: 544.00 (r/w/o: 375.00/109.00/60.00) lat (ms,95%): 1803.47 err/s: 0.00 reconn/s: 0.00
[ 385s ] thds: 32 tps: 58.00 qps: 1277.97 (r/w/o: 892.98/268.99/116.00) lat (ms,95%): 1708.63 err/s: 0.00 reconn/s: 0.00
[ 386s ] thds: 32 tps: 461.94 qps: 9151.86 (r/w/o: 6398.20/1830.77/922.89) lat (ms,95%): 121.08 err/s: 0.00 reconn/s: 0.00
[ 387s ] thds: 32 tps: 435.02 qps: 8701.33 (r/w/o: 6097.23/1733.07/871.03) lat (ms,95%): 125.52 err/s: 0.00 reconn/s: 0.00
[ 388s ] thds: 32 tps: 435.99 qps: 8751.87 (r/w/o: 6138.91/1742.97/869.99) lat (ms,95%): 127.81 err/s: 0.00 reconn/s: 0.00
[ 389s ] thds: 32 tps: 438.00 qps: 8757.91 (r/w/o: 6110.94/1768.98/877.99) lat (ms,95%): 116.80 err/s: 0.00 reconn/s: 0.00
[ 390s ] thds: 32 tps: 449.60 qps: 9049.02 (r/w/o: 6360.39/1789.42/899.21) lat (ms,95%): 110.66 err/s: 0.00 reconn/s: 0.00
[ 391s ] thds: 32 tps: 456.27 qps: 9070.36 (r/w/o: 6316.73/1841.09/912.54) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 392s ] thds: 32 tps: 438.18 qps: 8747.62 (r/w/o: 6142.54/1728.71/876.36) lat (ms,95%): 116.80 err/s: 0.00 reconn/s: 0.00
[ 393s ] thds: 32 tps: 453.94 qps: 9100.85 (r/w/o: 6360.20/1832.77/907.89) lat (ms,95%): 110.66 err/s: 0.00 reconn/s: 0.00
[ 394s ] thds: 32 tps: 440.02 qps: 8856.43 (r/w/o: 6211.30/1766.09/879.04) lat (ms,95%): 110.66 err/s: 0.00 reconn/s: 0.00
[ 395s ] thds: 32 tps: 465.96 qps: 9185.12 (r/w/o: 6411.39/1840.82/932.91) lat (ms,95%): 108.68 err/s: 0.00 reconn/s: 0.00
[ 396s ] thds: 32 tps: 441.05 qps: 8958.03 (r/w/o: 6274.72/1802.21/881.10) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 397s ] thds: 32 tps: 458.99 qps: 9066.88 (r/w/o: 6343.91/1804.98/917.99) lat (ms,95%): 108.68 err/s: 0.00 reconn/s: 0.00
[ 398s ] thds: 32 tps: 450.95 qps: 9041.94 (r/w/o: 6327.26/1813.79/900.89) lat (ms,95%): 108.68 err/s: 0.00 reconn/s: 0.00
[ 399s ] thds: 32 tps: 455.03 qps: 9153.70 (r/w/o: 6414.49/1827.14/912.07) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 400s ] thds: 32 tps: 454.92 qps: 9110.38 (r/w/o: 6380.87/1819.68/909.84) lat (ms,95%): 118.92 err/s: 0.00 reconn/s: 0.00
[ 401s ] thds: 32 tps: 452.13 qps: 9108.63 (r/w/o: 6369.84/1834.53/904.26) lat (ms,95%): 108.68 err/s: 0.00 reconn/s: 0.00
[ 402s ] thds: 32 tps: 455.96 qps: 9087.26 (r/w/o: 6363.48/1811.85/911.93) lat (ms,95%): 114.72 err/s: 0.00 reconn/s: 0.00
[ 403s ] thds: 32 tps: 455.04 qps: 9039.72 (r/w/o: 6330.51/1799.14/910.07) lat (ms,95%): 118.92 err/s: 0.00 reconn/s: 0.00
[ 404s ] thds: 32 tps: 454.78 qps: 9159.62 (r/w/o: 6414.93/1835.12/909.57) lat (ms,95%): 110.66 err/s: 0.00 reconn/s: 0.00
[ 405s ] thds: 32 tps: 456.17 qps: 9062.37 (r/w/o: 6325.35/1824.68/912.34) lat (ms,95%): 114.72 err/s: 0.00 reconn/s: 0.00
[ 406s ] thds: 32 tps: 458.64 qps: 9188.86 (r/w/o: 6445.99/1826.58/916.29) lat (ms,95%): 108.68 err/s: 0.00 reconn/s: 0.00
[ 407s ] thds: 32 tps: 443.35 qps: 8849.99 (r/w/o: 6189.89/1774.40/885.70) lat (ms,95%): 116.80 err/s: 0.00 reconn/s: 0.00
[ 408s ] thds: 32 tps: 464.05 qps: 9291.91 (r/w/o: 6496.63/1865.18/930.09) lat (ms,95%): 104.84 err/s: 0.00 reconn/s: 0.00
[ 409s ] thds: 32 tps: 452.97 qps: 8982.35 (r/w/o: 6300.54/1777.87/903.93) lat (ms,95%): 110.66 err/s: 0.00 reconn/s: 0.00
[ 410s ] thds: 32 tps: 457.99 qps: 9295.86 (r/w/o: 6499.90/1877.97/917.99) lat (ms,95%): 104.84 err/s: 0.00 reconn/s: 0.00
[ 411s ] thds: 32 tps: 446.03 qps: 8890.63 (r/w/o: 6242.44/1757.12/891.06) lat (ms,95%): 114.72 err/s: 0.00 reconn/s: 0.00
[ 412s ] thds: 32 tps: 469.97 qps: 9347.39 (r/w/o: 6526.58/1880.88/939.94) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 413s ] thds: 32 tps: 405.03 qps: 8162.53 (r/w/o: 5739.37/1612.10/811.05) lat (ms,95%): 164.45 err/s: 0.00 reconn/s: 0.00
[ 414s ] thds: 32 tps: 276.86 qps: 5471.28 (r/w/o: 3822.10/1095.46/553.72) lat (ms,95%): 257.95 err/s: 0.00 reconn/s: 0.00
[ 415s ] thds: 32 tps: 276.05 qps: 5509.90 (r/w/o: 3859.63/1098.18/552.09) lat (ms,95%): 325.98 err/s: 0.00 reconn/s: 0.00
[ 416s ] thds: 32 tps: 228.08 qps: 4550.66 (r/w/o: 3179.16/915.33/456.17) lat (ms,95%): 390.30 err/s: 0.00 reconn/s: 0.00
[ 417s ] thds: 32 tps: 233.00 qps: 4630.91 (r/w/o: 3231.94/932.98/465.99) lat (ms,95%): 383.33 err/s: 0.00 reconn/s: 0.00
[ 418s ] thds: 32 tps: 114.00 qps: 2342.97 (r/w/o: 1640.98/473.99/228.00) lat (ms,95%): 733.00 err/s: 0.00 reconn/s: 0.00
[ 419s ] thds: 32 tps: 130.00 qps: 2538.04 (r/w/o: 1777.03/501.01/260.00) lat (ms,95%): 669.89 err/s: 0.00 reconn/s: 0.00
[ 420s ] thds: 32 tps: 99.00 qps: 2038.02 (r/w/o: 1444.02/396.00/198.00) lat (ms,95%): 646.19 err/s: 0.00 reconn/s: 0.00
[ 421s ] thds: 32 tps: 58.00 qps: 1127.96 (r/w/o: 786.97/224.99/116.00) lat (ms,95%): 943.16 err/s: 0.00 reconn/s: 0.00
[ 422s ] thds: 32 tps: 63.00 qps: 1226.03 (r/w/o: 838.02/262.01/126.00) lat (ms,95%): 1050.76 err/s: 0.00 reconn/s: 0.00
[ 423s ] thds: 32 tps: 39.00 qps: 836.00 (r/w/o: 593.00/165.00/78.00) lat (ms,95%): 1618.78 err/s: 0.00 reconn/s: 0.00
[ 424s ] thds: 32 tps: 34.00 qps: 669.01 (r/w/o: 479.00/122.00/68.00) lat (ms,95%): 1739.68 err/s: 0.00 reconn/s: 0.00
[ 425s ] thds: 32 tps: 45.00 qps: 851.00 (r/w/o: 586.00/175.00/90.00) lat (ms,95%): 1618.78 err/s: 0.00 reconn/s: 0.00
[ 426s ] thds: 32 tps: 41.00 qps: 876.98 (r/w/o: 628.99/166.00/82.00) lat (ms,95%): 1069.86 err/s: 0.00 reconn/s: 0.00
[ 427s ] thds: 32 tps: 24.00 qps: 456.01 (r/w/o: 300.01/108.00/48.00) lat (ms,95%): 2045.74 err/s: 0.00 reconn/s: 0.00
[ 428s ] thds: 32 tps: 362.97 qps: 7400.37 (r/w/o: 5174.56/1499.87/725.94) lat (ms,95%): 580.02 err/s: 0.00 reconn/s: 0.00
[ 429s ] thds: 32 tps: 450.03 qps: 8820.64 (r/w/o: 6181.45/1739.13/900.07) lat (ms,95%): 116.80 err/s: 0.00 reconn/s: 0.00
[ 430s ] thds: 32 tps: 431.83 qps: 8742.54 (r/w/o: 6125.58/1753.31/863.66) lat (ms,95%): 114.72 err/s: 0.00 reconn/s: 0.00
[ 431s ] thds: 32 tps: 446.12 qps: 8816.39 (r/w/o: 6137.66/1786.48/892.24) lat (ms,95%): 121.08 err/s: 0.00 reconn/s: 0.00
[ 432s ] thds: 32 tps: 434.03 qps: 8709.59 (r/w/o: 6126.42/1715.12/868.06) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 433s ] thds: 32 tps: 440.02 qps: 8899.46 (r/w/o: 6239.32/1780.09/880.05) lat (ms,95%): 114.72 err/s: 0.00 reconn/s: 0.00
[ 434s ] thds: 32 tps: 436.00 qps: 8691.93 (r/w/o: 6075.95/1743.99/871.99) lat (ms,95%): 114.72 err/s: 0.00 reconn/s: 0.00
[ 435s ] thds: 32 tps: 457.00 qps: 9167.00 (r/w/o: 6420.00/1833.00/914.00) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 436s ] thds: 32 tps: 452.77 qps: 8992.41 (r/w/o: 6292.78/1794.08/905.54) lat (ms,95%): 106.75 err/s: 0.00 reconn/s: 0.00
[ 437s ] thds: 32 tps: 445.17 qps: 8992.53 (r/w/o: 6301.47/1800.71/890.35) lat (ms,95%): 110.66 err/s: 0.00 reconn/s: 0.00
[ 438s ] thds: 32 tps: 454.96 qps: 9083.18 (r/w/o: 6356.43/1816.84/909.92) lat (ms,95%): 110.66 err/s: 0.00 reconn/s: 0.00
[ 439s ] thds: 32 tps: 458.06 qps: 9149.28 (r/w/o: 6383.89/1849.26/916.13) lat (ms,95%): 110.66 err/s: 0.00 reconn/s: 0.00
[ 440s ] thds: 32 tps: 455.94 qps: 9083.84 (r/w/o: 6375.19/1797.77/910.88) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 441s ] thds: 32 tps: 449.09 qps: 8962.71 (r/w/o: 6269.20/1794.34/899.17) lat (ms,95%): 116.80 err/s: 0.00 reconn/s: 0.00
[ 442s ] thds: 32 tps: 464.97 qps: 9267.31 (r/w/o: 6479.52/1858.86/928.93) lat (ms,95%): 104.84 err/s: 0.00 reconn/s: 0.00
[ 443s ] thds: 32 tps: 440.03 qps: 8913.54 (r/w/o: 6234.38/1798.11/881.05) lat (ms,95%): 116.80 err/s: 0.00 reconn/s: 0.00
[ 444s ] thds: 32 tps: 462.97 qps: 9169.44 (r/w/o: 6431.61/1811.89/925.94) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 445s ] thds: 32 tps: 446.94 qps: 8934.80 (r/w/o: 6248.16/1793.76/892.88) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 446s ] thds: 32 tps: 457.04 qps: 9175.82 (r/w/o: 6429.57/1832.16/914.08) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 447s ] thds: 32 tps: 446.03 qps: 8907.57 (r/w/o: 6240.40/1774.11/893.06) lat (ms,95%): 118.92 err/s: 0.00 reconn/s: 0.00
[ 448s ] thds: 32 tps: 461.83 qps: 9257.64 (r/w/o: 6460.65/1874.32/922.67) lat (ms,95%): 116.80 err/s: 0.00 reconn/s: 0.00
[ 449s ] thds: 32 tps: 459.10 qps: 9089.89 (r/w/o: 6363.33/1807.38/919.19) lat (ms,95%): 116.80 err/s: 0.00 reconn/s: 0.00
[ 450s ] thds: 32 tps: 447.07 qps: 9039.40 (r/w/o: 6334.98/1810.28/894.14) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 451s ] thds: 32 tps: 457.88 qps: 9109.71 (r/w/o: 6398.39/1795.55/915.77) lat (ms,95%): 108.68 err/s: 0.00 reconn/s: 0.00
[ 452s ] thds: 32 tps: 446.96 qps: 8990.21 (r/w/o: 6277.45/1818.84/893.92) lat (ms,95%): 108.68 err/s: 0.00 reconn/s: 0.00
[ 453s ] thds: 32 tps: 236.10 qps: 4648.92 (r/w/o: 3262.35/914.38/472.20) lat (ms,95%): 337.94 err/s: 0.00 reconn/s: 0.00
[ 454s ] thds: 32 tps: 156.00 qps: 3128.99 (r/w/o: 2188.00/629.00/312.00) lat (ms,95%): 520.62 err/s: 0.00 reconn/s: 0.00
[ 455s ] thds: 32 tps: 153.00 qps: 3019.01 (r/w/o: 2107.01/606.00/306.00) lat (ms,95%): 657.93 err/s: 0.00 reconn/s: 0.00
[ 456s ] thds: 32 tps: 186.00 qps: 3719.95 (r/w/o: 2605.96/741.99/371.99) lat (ms,95%): 427.07 err/s: 0.00 reconn/s: 0.00
[ 457s ] thds: 32 tps: 166.00 qps: 3350.10 (r/w/o: 2351.07/667.02/332.01) lat (ms,95%): 419.45 err/s: 0.00 reconn/s: 0.00
[ 458s ] thds: 32 tps: 72.00 qps: 1501.97 (r/w/o: 1056.98/300.99/144.00) lat (ms,95%): 682.06 err/s: 0.00 reconn/s: 0.00
[ 459s ] thds: 32 tps: 69.00 qps: 1345.01 (r/w/o: 939.01/268.00/138.00) lat (ms,95%): 1708.63 err/s: 0.00 reconn/s: 0.00
[ 460s ] thds: 32 tps: 40.00 qps: 767.01 (r/w/o: 534.00/153.00/80.00) lat (ms,95%): 1304.21 err/s: 0.00 reconn/s: 0.00
[ 461s ] thds: 32 tps: 54.00 qps: 1089.98 (r/w/o: 759.99/222.00/108.00) lat (ms,95%): 1129.24 err/s: 0.00 reconn/s: 0.00
[ 462s ] thds: 32 tps: 53.00 qps: 1063.93 (r/w/o: 751.95/205.99/105.99) lat (ms,95%): 1258.08 err/s: 0.00 reconn/s: 0.00
[ 463s ] thds: 32 tps: 45.00 qps: 905.06 (r/w/o: 628.04/187.01/90.01) lat (ms,95%): 1258.08 err/s: 0.00 reconn/s: 0.00
[ 464s ] thds: 32 tps: 61.00 qps: 1181.99 (r/w/o: 825.99/234.00/122.00) lat (ms,95%): 1327.91 err/s: 0.00 reconn/s: 0.00
[ 465s ] thds: 32 tps: 24.00 qps: 558.00 (r/w/o: 410.00/100.00/48.00) lat (ms,95%): 1304.21 err/s: 0.00 reconn/s: 0.00
[ 466s ] thds: 32 tps: 54.00 qps: 1007.99 (r/w/o: 683.99/216.00/108.00) lat (ms,95%): 1533.66 err/s: 0.00 reconn/s: 0.00
[ 467s ] thds: 32 tps: 224.87 qps: 4592.31 (r/w/o: 3207.12/937.45/447.74) lat (ms,95%): 831.46 err/s: 0.00 reconn/s: 0.00
[ 468s ] thds: 32 tps: 455.26 qps: 9000.09 (r/w/o: 6298.56/1790.01/911.52) lat (ms,95%): 114.72 err/s: 0.00 reconn/s: 0.00
[ 469s ] thds: 32 tps: 448.98 qps: 9013.53 (r/w/o: 6309.67/1804.91/898.95) lat (ms,95%): 116.80 err/s: 0.00 reconn/s: 0.00
[ 470s ] thds: 32 tps: 435.03 qps: 8814.52 (r/w/o: 6186.37/1758.10/870.05) lat (ms,95%): 116.80 err/s: 0.00 reconn/s: 0.00
[ 471s ] thds: 32 tps: 452.01 qps: 8943.19 (r/w/o: 6246.14/1793.04/904.02) lat (ms,95%): 114.72 err/s: 0.00 reconn/s: 0.00
[ 472s ] thds: 32 tps: 447.97 qps: 8948.42 (r/w/o: 6266.59/1785.88/895.94) lat (ms,95%): 114.72 err/s: 0.00 reconn/s: 0.00
[ 473s ] thds: 32 tps: 451.99 qps: 9010.85 (r/w/o: 6302.90/1804.97/902.99) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 474s ] thds: 32 tps: 460.04 qps: 9194.76 (r/w/o: 6442.53/1831.15/921.08) lat (ms,95%): 108.68 err/s: 0.00 reconn/s: 0.00
[ 475s ] thds: 32 tps: 439.99 qps: 8900.70 (r/w/o: 6235.79/1784.94/879.97) lat (ms,95%): 110.66 err/s: 0.00 reconn/s: 0.00
[ 476s ] thds: 32 tps: 446.98 qps: 9030.69 (r/w/o: 6319.78/1816.94/893.97) lat (ms,95%): 108.68 err/s: 0.00 reconn/s: 0.00
[ 477s ] thds: 32 tps: 461.03 qps: 9164.53 (r/w/o: 6417.37/1825.11/922.05) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 478s ] thds: 32 tps: 455.01 qps: 9139.10 (r/w/o: 6406.07/1824.02/909.01) lat (ms,95%): 108.68 err/s: 0.00 reconn/s: 0.00
[ 479s ] thds: 32 tps: 466.98 qps: 9197.70 (r/w/o: 6421.79/1840.94/934.97) lat (ms,95%): 110.66 err/s: 0.00 reconn/s: 0.00
[ 480s ] thds: 32 tps: 439.98 qps: 8904.56 (r/w/o: 6249.69/1774.91/879.96) lat (ms,95%): 108.68 err/s: 0.00 reconn/s: 0.00
[ 481s ] thds: 32 tps: 457.97 qps: 9153.45 (r/w/o: 6401.62/1835.89/915.95) lat (ms,95%): 108.68 err/s: 0.00 reconn/s: 0.00
[ 482s ] thds: 32 tps: 446.02 qps: 8945.45 (r/w/o: 6251.31/1803.09/891.04) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 483s ] thds: 32 tps: 465.04 qps: 9233.72 (r/w/o: 6472.50/1832.14/929.07) lat (ms,95%): 110.66 err/s: 0.00 reconn/s: 0.00
[ 484s ] thds: 32 tps: 452.01 qps: 9015.10 (r/w/o: 6311.07/1798.02/906.01) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 485s ] thds: 32 tps: 451.00 qps: 9006.96 (r/w/o: 6295.97/1810.99/900.00) lat (ms,95%): 110.66 err/s: 0.00 reconn/s: 0.00
[ 486s ] thds: 32 tps: 459.01 qps: 9217.15 (r/w/o: 6455.10/1842.03/920.01) lat (ms,95%): 110.66 err/s: 0.00 reconn/s: 0.00
[ 487s ] thds: 32 tps: 448.90 qps: 8955.99 (r/w/o: 6277.59/1780.60/897.80) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 488s ] thds: 32 tps: 468.05 qps: 9351.95 (r/w/o: 6542.66/1875.19/934.09) lat (ms,95%): 106.75 err/s: 0.00 reconn/s: 0.00
[ 489s ] thds: 32 tps: 436.75 qps: 8818.91 (r/w/o: 6156.45/1786.97/875.49) lat (ms,95%): 110.66 err/s: 0.00 reconn/s: 0.00
[ 490s ] thds: 32 tps: 473.24 qps: 9442.70 (r/w/o: 6635.30/1860.93/946.47) lat (ms,95%): 110.66 err/s: 0.00 reconn/s: 0.00
[ 491s ] thds: 32 tps: 459.08 qps: 9083.57 (r/w/o: 6339.10/1826.32/918.16) lat (ms,95%): 116.80 err/s: 0.00 reconn/s: 0.00
[ 492s ] thds: 32 tps: 424.00 qps: 8456.08 (r/w/o: 5927.06/1681.02/848.01) lat (ms,95%): 130.13 err/s: 0.00 reconn/s: 0.00
[ 493s ] thds: 32 tps: 249.00 qps: 5069.05 (r/w/o: 3561.04/1010.01/498.01) lat (ms,95%): 344.08 err/s: 0.00 reconn/s: 0.00
[ 494s ] thds: 32 tps: 177.98 qps: 3512.54 (r/w/o: 2449.68/706.91/355.95) lat (ms,95%): 442.73 err/s: 0.00 reconn/s: 0.00
[ 495s ] thds: 32 tps: 153.00 qps: 3080.97 (r/w/o: 2156.98/617.99/306.00) lat (ms,95%): 502.20 err/s: 0.00 reconn/s: 0.00
[ 496s ] thds: 32 tps: 160.00 qps: 3194.96 (r/w/o: 2237.97/636.99/320.00) lat (ms,95%): 549.52 err/s: 0.00 reconn/s: 0.00
[ 497s ] thds: 32 tps: 136.02 qps: 2676.40 (r/w/o: 1866.28/538.08/272.04) lat (ms,95%): 590.56 err/s: 0.00 reconn/s: 0.00
[ 498s ] thds: 32 tps: 92.00 qps: 1850.01 (r/w/o: 1297.01/369.00/184.00) lat (ms,95%): 707.07 err/s: 0.00 reconn/s: 0.00
[ 499s ] thds: 32 tps: 80.00 qps: 1643.96 (r/w/o: 1168.97/314.99/160.00) lat (ms,95%): 1129.24 err/s: 0.00 reconn/s: 0.00
[ 500s ] thds: 32 tps: 79.00 qps: 1536.06 (r/w/o: 1063.04/315.01/158.01) lat (ms,95%): 1069.86 err/s: 0.00 reconn/s: 0.00
[ 501s ] thds: 32 tps: 45.00 qps: 894.95 (r/w/o: 624.97/179.99/90.00) lat (ms,95%): 977.74 err/s: 0.00 reconn/s: 0.00
[ 502s ] thds: 32 tps: 48.00 qps: 1026.04 (r/w/o: 730.03/200.01/96.00) lat (ms,95%): 1327.91 err/s: 0.00 reconn/s: 0.00
[ 503s ] thds: 32 tps: 79.00 qps: 1518.00 (r/w/o: 1047.00/313.00/158.00) lat (ms,95%): 1013.60 err/s: 0.00 reconn/s: 0.00
[ 504s ] thds: 32 tps: 45.00 qps: 872.99 (r/w/o: 610.99/172.00/90.00) lat (ms,95%): 1149.76 err/s: 0.00 reconn/s: 0.00
[ 505s ] thds: 32 tps: 32.00 qps: 644.97 (r/w/o: 439.98/140.99/64.00) lat (ms,95%): 1170.65 err/s: 0.00 reconn/s: 0.00
[ 506s ] thds: 32 tps: 25.00 qps: 482.03 (r/w/o: 345.02/87.01/50.00) lat (ms,95%): 1938.16 err/s: 0.00 reconn/s: 0.00
[ 507s ] thds: 32 tps: 31.00 qps: 680.00 (r/w/o: 491.00/127.00/62.00) lat (ms,95%): 1938.16 err/s: 0.00 reconn/s: 0.00
[ 508s ] thds: 32 tps: 428.94 qps: 8616.79 (r/w/o: 6025.15/1733.76/857.88) lat (ms,95%): 434.83 err/s: 0.00 reconn/s: 0.00
[ 509s ] thds: 32 tps: 438.98 qps: 8745.52 (r/w/o: 6120.66/1748.90/875.95) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 510s ] thds: 32 tps: 436.05 qps: 8840.06 (r/w/o: 6182.74/1783.21/874.10) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 511s ] thds: 32 tps: 445.01 qps: 8798.18 (r/w/o: 6157.12/1751.03/890.02) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 512s ] thds: 32 tps: 446.88 qps: 8890.62 (r/w/o: 6231.33/1765.53/893.76) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 513s ] thds: 32 tps: 450.13 qps: 9109.67 (r/w/o: 6364.86/1844.54/900.26) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 514s ] thds: 32 tps: 447.95 qps: 8979.92 (r/w/o: 6307.24/1776.79/895.89) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 515s ] thds: 32 tps: 439.97 qps: 8804.50 (r/w/o: 6148.65/1776.90/878.95) lat (ms,95%): 114.72 err/s: 0.00 reconn/s: 0.00
[ 516s ] thds: 32 tps: 462.09 qps: 9176.86 (r/w/o: 6426.30/1825.37/925.19) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 517s ] thds: 32 tps: 443.87 qps: 8880.34 (r/w/o: 6228.13/1765.47/886.73) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 518s ] thds: 32 tps: 452.05 qps: 9043.97 (r/w/o: 6322.68/1816.19/905.10) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 519s ] thds: 32 tps: 462.04 qps: 9197.77 (r/w/o: 6433.54/1840.15/924.08) lat (ms,95%): 110.66 err/s: 0.00 reconn/s: 0.00
[ 520s ] thds: 32 tps: 440.03 qps: 8840.59 (r/w/o: 6170.41/1790.12/880.06) lat (ms,95%): 116.80 err/s: 0.00 reconn/s: 0.00
[ 521s ] thds: 32 tps: 459.94 qps: 9246.73 (r/w/o: 6491.11/1835.75/919.87) lat (ms,95%): 110.66 err/s: 0.00 reconn/s: 0.00
[ 522s ] thds: 32 tps: 445.04 qps: 8887.87 (r/w/o: 6218.61/1779.17/890.09) lat (ms,95%): 106.75 err/s: 0.00 reconn/s: 0.00
[ 523s ] thds: 32 tps: 454.01 qps: 9121.17 (r/w/o: 6392.12/1821.03/908.02) lat (ms,95%): 110.66 err/s: 0.00 reconn/s: 0.00
[ 524s ] thds: 32 tps: 462.96 qps: 9160.20 (r/w/o: 6407.44/1826.84/925.92) lat (ms,95%): 106.75 err/s: 0.00 reconn/s: 0.00
[ 525s ] thds: 32 tps: 443.03 qps: 8944.63 (r/w/o: 6259.44/1799.13/886.06) lat (ms,95%): 108.68 err/s: 0.00 reconn/s: 0.00
[ 526s ] thds: 32 tps: 456.89 qps: 9118.80 (r/w/o: 6392.45/1812.56/913.78) lat (ms,95%): 110.66 err/s: 0.00 reconn/s: 0.00
[ 527s ] thds: 32 tps: 454.03 qps: 9089.51 (r/w/o: 6353.36/1828.10/908.05) lat (ms,95%): 110.66 err/s: 0.00 reconn/s: 0.00
[ 528s ] thds: 32 tps: 448.12 qps: 9008.38 (r/w/o: 6296.67/1815.48/896.24) lat (ms,95%): 108.68 err/s: 0.00 reconn/s: 0.00
[ 529s ] thds: 32 tps: 459.00 qps: 9093.93 (r/w/o: 6375.95/1799.99/917.99) lat (ms,95%): 110.66 err/s: 0.00 reconn/s: 0.00
[ 530s ] thds: 32 tps: 463.94 qps: 9155.72 (r/w/o: 6392.11/1837.74/925.87) lat (ms,95%): 108.68 err/s: 0.00 reconn/s: 0.00
[ 531s ] thds: 32 tps: 446.99 qps: 9114.86 (r/w/o: 6406.90/1811.97/895.99) lat (ms,95%): 114.72 err/s: 0.00 reconn/s: 0.00
[ 532s ] thds: 32 tps: 431.04 qps: 8696.90 (r/w/o: 6071.63/1763.18/862.09) lat (ms,95%): 118.92 err/s: 0.00 reconn/s: 0.00
[ 533s ] thds: 32 tps: 472.03 qps: 9296.53 (r/w/o: 6527.37/1825.10/944.05) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 534s ] thds: 32 tps: 394.00 qps: 7795.04 (r/w/o: 5434.03/1573.01/788.00) lat (ms,95%): 150.29 err/s: 0.00 reconn/s: 0.00
[ 535s ] thds: 32 tps: 228.99 qps: 4652.90 (r/w/o: 3267.93/926.98/457.99) lat (ms,95%): 383.33 err/s: 0.00 reconn/s: 0.00
[ 536s ] thds: 32 tps: 212.01 qps: 4219.17 (r/w/o: 2954.12/841.03/424.02) lat (ms,95%): 363.18 err/s: 0.00 reconn/s: 0.00
[ 537s ] thds: 32 tps: 167.00 qps: 3375.98 (r/w/o: 2381.99/660.00/334.00) lat (ms,95%): 467.30 err/s: 0.00 reconn/s: 0.00
[ 538s ] thds: 32 tps: 112.00 qps: 2198.98 (r/w/o: 1511.98/463.00/224.00) lat (ms,95%): 646.19 err/s: 0.00 reconn/s: 0.00
[ 539s ] thds: 32 tps: 80.00 qps: 1566.00 (r/w/o: 1092.00/314.00/160.00) lat (ms,95%): 861.95 err/s: 0.00 reconn/s: 0.00
[ 540s ] thds: 32 tps: 106.00 qps: 2184.93 (r/w/o: 1549.95/422.99/211.99) lat (ms,95%): 733.00 err/s: 0.00 reconn/s: 0.00
[ 541s ] thds: 32 tps: 65.00 qps: 1274.04 (r/w/o: 891.03/253.01/130.00) lat (ms,95%): 802.05 err/s: 0.00 reconn/s: 0.00
[ 542s ] thds: 32 tps: 82.00 qps: 1662.91 (r/w/o: 1169.94/328.98/163.99) lat (ms,95%): 1032.01 err/s: 0.00 reconn/s: 0.00
[ 543s ] thds: 32 tps: 53.00 qps: 1031.06 (r/w/o: 716.04/209.01/106.01) lat (ms,95%): 960.30 err/s: 0.00 reconn/s: 0.00
[ 544s ] thds: 32 tps: 57.00 qps: 1106.98 (r/w/o: 766.99/226.00/114.00) lat (ms,95%): 1191.92 err/s: 0.00 reconn/s: 0.00
[ 545s ] thds: 32 tps: 29.00 qps: 655.96 (r/w/o: 474.97/122.99/58.00) lat (ms,95%): 1708.63 err/s: 0.00 reconn/s: 0.00
[ 546s ] thds: 32 tps: 49.00 qps: 978.07 (r/w/o: 681.05/199.01/98.01) lat (ms,95%): 1401.61 err/s: 0.00 reconn/s: 0.00
[ 547s ] thds: 32 tps: 31.00 qps: 576.00 (r/w/o: 402.00/112.00/62.00) lat (ms,95%): 1739.68 err/s: 0.00 reconn/s: 0.00
[ 548s ] thds: 32 tps: 37.00 qps: 732.98 (r/w/o: 500.99/158.00/74.00) lat (ms,95%): 1648.20 err/s: 0.00 reconn/s: 0.00
[ 549s ] thds: 32 tps: 442.01 qps: 8873.15 (r/w/o: 6208.10/1781.03/884.01) lat (ms,95%): 363.18 err/s: 0.00 reconn/s: 0.00
[ 550s ] thds: 32 tps: 444.98 qps: 8857.51 (r/w/o: 6200.66/1766.90/889.95) lat (ms,95%): 116.80 err/s: 0.00 reconn/s: 0.00
[ 551s ] thds: 32 tps: 439.97 qps: 8860.49 (r/w/o: 6195.64/1785.90/878.95) lat (ms,95%): 110.66 err/s: 0.00 reconn/s: 0.00
[ 552s ] thds: 32 tps: 441.01 qps: 8841.22 (r/w/o: 6194.16/1764.04/883.02) lat (ms,95%): 114.72 err/s: 0.00 reconn/s: 0.00
[ 553s ] thds: 32 tps: 448.95 qps: 8966.93 (r/w/o: 6290.25/1778.79/897.89) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 554s ] thds: 32 tps: 445.54 qps: 8908.72 (r/w/o: 6224.54/1793.11/891.07) lat (ms,95%): 114.72 err/s: 0.00 reconn/s: 0.00
[ 555s ] thds: 32 tps: 445.56 qps: 8963.45 (r/w/o: 6286.05/1786.27/891.13) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 556s ] thds: 32 tps: 457.99 qps: 9131.73 (r/w/o: 6379.81/1836.94/914.97) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 557s ] thds: 32 tps: 448.01 qps: 8994.21 (r/w/o: 6299.15/1798.04/897.02) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 558s ] thds: 32 tps: 459.98 qps: 9176.64 (r/w/o: 6426.75/1829.93/919.96) lat (ms,95%): 108.68 err/s: 0.00 reconn/s: 0.00
[ 559s ] thds: 32 tps: 470.02 qps: 9253.36 (r/w/o: 6464.25/1849.07/940.04) lat (ms,95%): 110.66 err/s: 0.00 reconn/s: 0.00
[ 560s ] thds: 32 tps: 450.72 qps: 9126.42 (r/w/o: 6400.09/1824.88/901.45) lat (ms,95%): 108.68 err/s: 0.00 reconn/s: 0.00
[ 561s ] thds: 32 tps: 458.25 qps: 9218.02 (r/w/o: 6447.51/1854.01/916.50) lat (ms,95%): 106.75 err/s: 0.00 reconn/s: 0.00
[ 562s ] thds: 32 tps: 462.68 qps: 9199.65 (r/w/o: 6448.55/1825.74/925.36) lat (ms,95%): 108.68 err/s: 0.00 reconn/s: 0.00
[ 563s ] thds: 32 tps: 449.28 qps: 9016.67 (r/w/o: 6299.96/1819.14/897.56) lat (ms,95%): 108.68 err/s: 0.00 reconn/s: 0.00
[ 564s ] thds: 32 tps: 460.95 qps: 9207.07 (r/w/o: 6454.35/1829.82/922.91) lat (ms,95%): 110.66 err/s: 0.00 reconn/s: 0.00
[ 565s ] thds: 32 tps: 461.07 qps: 9259.33 (r/w/o: 6479.93/1857.27/922.13) lat (ms,95%): 106.75 err/s: 0.00 reconn/s: 0.00
[ 566s ] thds: 32 tps: 450.94 qps: 9028.75 (r/w/o: 6311.13/1815.75/901.88) lat (ms,95%): 110.66 err/s: 0.00 reconn/s: 0.00
[ 567s ] thds: 32 tps: 475.05 qps: 9414.06 (r/w/o: 6599.74/1864.21/950.11) lat (ms,95%): 108.68 err/s: 0.00 reconn/s: 0.00
[ 568s ] thds: 32 tps: 448.03 qps: 8993.62 (r/w/o: 6291.43/1806.12/896.06) lat (ms,95%): 110.66 err/s: 0.00 reconn/s: 0.00
[ 569s ] thds: 32 tps: 463.97 qps: 9260.44 (r/w/o: 6473.61/1858.89/927.94) lat (ms,95%): 116.80 err/s: 0.00 reconn/s: 0.00
[ 570s ] thds: 32 tps: 463.80 qps: 9242.01 (r/w/o: 6458.21/1856.20/927.60) lat (ms,95%): 110.66 err/s: 0.00 reconn/s: 0.00
[ 571s ] thds: 32 tps: 448.20 qps: 9147.04 (r/w/o: 6415.83/1834.81/896.40) lat (ms,95%): 108.68 err/s: 0.00 reconn/s: 0.00
[ 572s ] thds: 32 tps: 460.01 qps: 9024.27 (r/w/o: 6325.19/1779.05/920.03) lat (ms,95%): 110.66 err/s: 0.00 reconn/s: 0.00
[ 573s ] thds: 32 tps: 449.99 qps: 9067.88 (r/w/o: 6340.91/1826.98/899.99) lat (ms,95%): 110.66 err/s: 0.00 reconn/s: 0.00
[ 574s ] thds: 32 tps: 347.02 qps: 6845.43 (r/w/o: 4810.30/1341.08/694.04) lat (ms,95%): 116.80 err/s: 0.00 reconn/s: 0.00
[ 575s ] thds: 32 tps: 233.00 qps: 4645.04 (r/w/o: 3244.03/935.01/466.00) lat (ms,95%): 397.39 err/s: 0.00 reconn/s: 0.00
[ 576s ] thds: 32 tps: 196.00 qps: 3955.93 (r/w/o: 2772.95/791.99/390.99) lat (ms,95%): 419.45 err/s: 0.00 reconn/s: 0.00
[ 577s ] thds: 32 tps: 186.00 qps: 3637.05 (r/w/o: 2525.04/739.01/373.01) lat (ms,95%): 411.96 err/s: 0.00 reconn/s: 0.00
[ 578s ] thds: 32 tps: 157.00 qps: 3260.01 (r/w/o: 2303.01/643.00/314.00) lat (ms,95%): 511.33 err/s: 0.00 reconn/s: 0.00
[ 579s ] thds: 32 tps: 125.00 qps: 2578.93 (r/w/o: 1801.95/526.99/249.99) lat (ms,95%): 549.52 err/s: 0.00 reconn/s: 0.00
[ 580s ] thds: 32 tps: 94.00 qps: 1743.02 (r/w/o: 1217.02/338.00/188.00) lat (ms,95%): 831.46 err/s: 0.00 reconn/s: 0.00
[ 581s ] thds: 32 tps: 68.00 qps: 1370.90 (r/w/o: 965.93/268.98/135.99) lat (ms,95%): 1170.65 err/s: 0.00 reconn/s: 0.00
[ 582s ] thds: 32 tps: 86.01 qps: 1783.15 (r/w/o: 1236.11/375.03/172.01) lat (ms,95%): 759.88 err/s: 0.00 reconn/s: 0.00
[ 583s ] thds: 32 tps: 70.99 qps: 1347.77 (r/w/o: 959.83/245.96/141.98) lat (ms,95%): 995.51 err/s: 0.00 reconn/s: 0.00
[ 584s ] thds: 32 tps: 35.01 qps: 687.12 (r/w/o: 473.08/144.03/70.01) lat (ms,95%): 1327.91 err/s: 0.00 reconn/s: 0.00
[ 585s ] thds: 32 tps: 39.00 qps: 893.01 (r/w/o: 628.00/187.00/78.00) lat (ms,95%): 1376.60 err/s: 0.00 reconn/s: 0.00
[ 586s ] thds: 32 tps: 34.00 qps: 624.00 (r/w/o: 442.00/114.00/68.00) lat (ms,95%): 2082.91 err/s: 0.00 reconn/s: 0.00
[ 587s ] thds: 32 tps: 56.00 qps: 1084.00 (r/w/o: 752.00/220.00/112.00) lat (ms,95%): 1533.66 err/s: 0.00 reconn/s: 0.00
[ 588s ] thds: 32 tps: 28.00 qps: 522.00 (r/w/o: 350.00/116.00/56.00) lat (ms,95%): 1149.76 err/s: 0.00 reconn/s: 0.00
[ 589s ] thds: 32 tps: 23.00 qps: 506.00 (r/w/o: 380.00/80.00/46.00) lat (ms,95%): 1739.68 err/s: 0.00 reconn/s: 0.00
[ 590s ] thds: 32 tps: 292.94 qps: 5919.69 (r/w/o: 4115.09/1218.73/585.87) lat (ms,95%): 1050.76 err/s: 0.00 reconn/s: 0.00
[ 591s ] thds: 32 tps: 439.02 qps: 8742.39 (r/w/o: 6138.27/1726.08/878.04) lat (ms,95%): 118.92 err/s: 0.00 reconn/s: 0.00
[ 592s ] thds: 32 tps: 445.03 qps: 8846.51 (r/w/o: 6178.35/1778.10/890.05) lat (ms,95%): 114.72 err/s: 0.00 reconn/s: 0.00
[ 593s ] thds: 32 tps: 435.71 qps: 8847.08 (r/w/o: 6197.85/1777.81/871.42) lat (ms,95%): 118.92 err/s: 0.00 reconn/s: 0.00
[ 594s ] thds: 32 tps: 443.34 qps: 8681.58 (r/w/o: 6062.59/1733.31/885.67) lat (ms,95%): 118.92 err/s: 0.00 reconn/s: 0.00
[ 595s ] thds: 32 tps: 444.00 qps: 8976.99 (r/w/o: 6292.99/1795.00/889.00) lat (ms,95%): 106.75 err/s: 0.00 reconn/s: 0.00
[ 596s ] thds: 32 tps: 460.00 qps: 9136.96 (r/w/o: 6399.97/1816.99/920.00) lat (ms,95%): 116.80 err/s: 0.00 reconn/s: 0.00
[ 597s ] thds: 32 tps: 436.02 qps: 8766.38 (r/w/o: 6128.26/1767.08/871.04) lat (ms,95%): 110.66 err/s: 0.00 reconn/s: 0.00
[ 598s ] thds: 32 tps: 460.94 qps: 9206.79 (r/w/o: 6451.15/1832.76/922.88) lat (ms,95%): 108.68 err/s: 0.00 reconn/s: 0.00
[ 599s ] thds: 32 tps: 437.99 qps: 8836.73 (r/w/o: 6200.81/1759.95/875.97) lat (ms,95%): 112.67 err/s: 0.00 reconn/s: 0.00
[ 600s ] thds: 32 tps: 450.99 qps: 9061.70 (r/w/o: 6318.79/1845.94/896.97) lat (ms,95%): 106.75 err/s: 0.00 reconn/s: 0.00
SQL statistics:
    queries performed:
        read:                            2592128
        write:                           740608
        other:                           370304
        total:                           3703040
    transactions:                        185152 (308.53 per sec.)
    queries:                             3703040 (6170.56 per sec.)
    ignored errors:                      0      (0.00 per sec.)
    reconnects:                          0      (0.00 per sec.)

Throughput:
    events/s (eps):                      308.5280
    time elapsed:                        600.1141s
    total number of events:              185152

Latency (ms):
         min:                                    8.88
         avg:                                  103.70
         max:                                 3847.36
         95th percentile:                      253.35
         sum:                             19200637.19

Threads fairness:
    events (avg/stddev):           5786.0000/53.95
    execution time (avg/stddev):   600.0199/0.03

清理测试数据

[mysql@localhost lua]$ ./sysbench oltp_read_write.lua --mysql-host=127.0.0.1 --mysql-port=3306 --mysql-db=test --mysql-user=root --mysql-password=abcd1234 --table_size=250000 --tables=25 --threads=32 --events=0 --report-interval=1 --time=600 --percentile=95 --report-interval=1 cleanup
sysbench 1.1.0 (using bundled LuaJIT 2.1.0-beta3)

Dropping table 'sbtest1'...
Dropping table 'sbtest2'...
Dropping table 'sbtest3'...
Dropping table 'sbtest4'...
Dropping table 'sbtest5'...
Dropping table 'sbtest6'...
Dropping table 'sbtest7'...
Dropping table 'sbtest8'...
Dropping table 'sbtest9'...
Dropping table 'sbtest10'...
Dropping table 'sbtest11'...
Dropping table 'sbtest12'...
Dropping table 'sbtest13'...
Dropping table 'sbtest14'...
Dropping table 'sbtest15'...
Dropping table 'sbtest16'...
Dropping table 'sbtest17'...
Dropping table 'sbtest18'...
Dropping table 'sbtest19'...
Dropping table 'sbtest20'...
Dropping table 'sbtest21'...
Dropping table 'sbtest22'...
Dropping table 'sbtest23'...
Dropping table 'sbtest24'...
Dropping table 'sbtest25'...
]]>
http://www.jydba.net/index.php/archives/3432/feed 0
sysbench 测试MySQL磁盘IOPS http://www.jydba.net/index.php/archives/3430 http://www.jydba.net/index.php/archives/3430#respond Tue, 08 Nov 2022 09:31:53 +0000 http://www.jydba.net/?p=3430 sysbench 测试MySQL磁盘IOPS
1. 安装

https://github.com/akopytov/sysbench.git # 通过git clone得到源码

2. 上传到MySQL服务器并解压

[root@localhost soft]# unzip sysbench-master.zip
[root@localhost soft]# mv sysbench-master sysbench

[root@localhost sysbench]# ./autogen.sh
autoreconf: Entering directory `.'
autoreconf: configure.ac: not using Gettext
autoreconf: running: aclocal -I m4
autoreconf: configure.ac: tracing
autoreconf: running: libtoolize --copy
libtoolize: putting auxiliary files in AC_CONFIG_AUX_DIR, `config'.
libtoolize: copying file `config/ltmain.sh'
libtoolize: putting macros in AC_CONFIG_MACRO_DIR, `m4'.
libtoolize: copying file `m4/libtool.m4'
libtoolize: copying file `m4/ltoptions.m4'
libtoolize: copying file `m4/ltsugar.m4'
libtoolize: copying file `m4/ltversion.m4'
libtoolize: copying file `m4/lt~obsolete.m4'
autoreconf: running: /usr/bin/autoconf
autoreconf: running: /usr/bin/autoheader
autoreconf: running: automake --add-missing --copy --no-force
configure.ac:59: installing 'config/ar-lib'
configure.ac:45: installing 'config/compile'
configure.ac:27: installing 'config/config.guess'
configure.ac:27: installing 'config/config.sub'
configure.ac:32: installing 'config/install-sh'
configure.ac:32: installing 'config/missing'
src/Makefile.am: installing 'config/depcomp'
parallel-tests: installing 'config/test-driver'
autoreconf: Leaving directory `.'

2.1 关联mysql的头文件和库

[root@localhost sysbench]# ./configure  --with-mysql-includes=/mysqlsoft/mysql/include/  --with-mysql-libs=/mysqlsoft/mysql/lib/
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking for style of include used by make... GNU
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking dependency style of gcc... gcc3
checking how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking minix/config.h usability... no
checking minix/config.h presence... no
checking for minix/config.h... no
checking whether it is safe to define __EXTENSIONS__... yes
checking for gcc... (cached) gcc
checking whether we are using the GNU C compiler... (cached) yes
checking whether gcc accepts -g... (cached) yes
checking for gcc option to accept ISO C89... (cached) none needed
checking dependency style of gcc... (cached) gcc3
checking for gcc option to accept ISO C99... -std=gnu99
checking how to run the C preprocessor... gcc -E
checking whether gcc -std=gnu99 and cc understand -c and -o together... yes
checking for a sed that does not truncate output... /usr/bin/sed
checking for C compiler vendor... gnu
checking for gcc architecture flag...
checking for x86 cpuid 0 output... d:756e6547:6c65746e:49656e69
checking for x86 cpuid 1 output... 306e7:2040800:9e982203:1fabfbff
checking whether C compiler accepts -march=ivybridge... no
checking whether C compiler accepts -march=core-avx-i... yes
checking for gcc architecture flag... -march=core-avx-i
checking for ar... ar
checking the archiver (ar) interface... ar
checking how to print strings... printf
checking for a sed that does not truncate output... (cached) /usr/bin/sed
checking for fgrep... /usr/bin/grep -F
checking for ld used by gcc -std=gnu99... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 1572864
checking whether the shell understands some XSI constructs... yes
checking whether the shell understands "+="... yes
checking how to convert x86_64-unknown-linux-gnu file names to x86_64-unknown-linux-gnu format... func_convert_file_noop
checking how to convert x86_64-unknown-linux-gnu file names to toolchain format... func_convert_file_noop
checking for /usr/bin/ld option to reload object files... -r
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for dlltool... no
checking how to associate runtime and link libraries... printf %s\n
checking for archiver @FILE support... @
checking for strip... strip
checking for ranlib... ranlib
checking command to parse /usr/bin/nm -B output from gcc -std=gnu99 object... ok
checking for sysroot... no
checking for mt... mt
checking if mt is a manifest tool... no
checking for dlfcn.h... yes
checking for objdir... .libs
checking if gcc -std=gnu99 supports -fno-rtti -fno-exceptions... no
checking for gcc -std=gnu99 option to produce PIC... -fPIC -DPIC
checking if gcc -std=gnu99 PIC flag -fPIC -DPIC works... yes
checking if gcc -std=gnu99 static flag -static works... no
checking if gcc -std=gnu99 supports -c -o file.o... yes
checking if gcc -std=gnu99 supports -c -o file.o... (cached) yes
checking whether the gcc -std=gnu99 linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
checking for pkg-config... yes
checking for C compiler vendor... (cached) gnu
checking whether to compile with MySQL support... yes
checking whether to compile with PostgreSQL support... no
checking for pkg-config... /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking whether to build with system or bundled LuaJIT... bundled
checking whether to build with system or bundled Concurrency Kit... bundled
checking whether SHM_HUGETLB is declared... yes
checking whether O_SYNC is declared... yes
checking for the pthreads library -lpthreads... no
checking whether pthreads work without any flags... no
checking whether pthreads work with -Kthread... no
checking whether pthreads work with -kthread... no
checking for the pthreads library -llthread... no
checking whether pthreads work with -pthread... yes
checking for joinable pthread attribute... PTHREAD_CREATE_JOINABLE
checking if more special flags are required for pthreads... no
checking for sqrt in -lm... yes
checking MySQL includes... (cached) /mysqlsoft/mysql/include/
checking MySQL libraries... (cached) /mysqlsoft/mysql/lib/
checking for library containing mysql_real_connect... -lmysqlclient
checking if mysql.h defines MYSQL_OPT_SSL_MODE... yes
checking libaio.h usability... no
checking libaio.h presence... no
checking for libaio.h... no
checking for ANSI C header files... (cached) yes
checking errno.h usability... yes
checking errno.h presence... yes
checking for errno.h... yes
checking fcntl.h usability... yes
checking fcntl.h presence... yes
checking for fcntl.h... yes
checking math.h usability... yes
checking math.h presence... yes
checking for math.h... yes
checking pthread.h usability... yes
checking pthread.h presence... yes
checking for pthread.h... yes
checking sched.h usability... yes
checking sched.h presence... yes
checking for sched.h... yes
checking signal.h usability... yes
checking signal.h presence... yes
checking for signal.h... yes
checking for stdlib.h... (cached) yes
checking for string.h... (cached) yes
checking sys/aio.h usability... no
checking sys/aio.h presence... no
checking for sys/aio.h... no
checking sys/ipc.h usability... yes
checking sys/ipc.h presence... yes
checking for sys/ipc.h... yes
checking sys/time.h usability... yes
checking sys/time.h presence... yes
checking for sys/time.h... yes
checking sys/mman.h usability... yes
checking sys/mman.h presence... yes
checking for sys/mman.h... yes
checking sys/shm.h usability... yes
checking sys/shm.h presence... yes
checking for sys/shm.h... yes
checking thread.h usability... no
checking thread.h presence... no
checking for thread.h... no
checking for unistd.h... (cached) yes
checking limits.h usability... yes
checking limits.h presence... yes
checking for limits.h... yes
checking libgen.h usability... yes
checking libgen.h presence... yes
checking for libgen.h... yes
checking for off_t... yes
checking whether time.h and sys/time.h may both be included... yes
checking for thread local storage (TLS) class... __thread
checking for __attribute__((format))... yes
checking for __attribute__((unused))... yes
checking for special C compiler options needed for large files... no
checking for _FILE_OFFSET_BITS value needed for large files... no
checking size of size_t... 8
checking size of bool... 1
checking for stdlib.h... (cached) yes
checking for unistd.h... (cached) yes
checking for sys/param.h... yes
checking for getpagesize... yes
checking for working mmap... yes
checking whether strerror_r is declared... yes
checking for strerror_r... yes
checking whether strerror_r returns char *... yes
checking for library containing clock_gettime... none required
checking for alarm... yes
checking for clock_gettime... yes
checking for directio... no
checking for fdatasync... yes
checking for gettimeofday... yes
checking for isatty... yes
checking for memalign... yes
checking for memset... yes
checking for posix_memalign... yes
checking for pthread_cancel... yes
checking for pthread_yield... yes
checking for setvbuf... yes
checking for sqrt... yes
checking for strdup... yes
checking for thr_setconcurrency... no
checking for valloc... yes
checking for pthread_once... yes
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating third_party/luajit/Makefile
config.status: creating third_party/concurrency_kit/Makefile
config.status: creating src/Makefile
config.status: creating src/drivers/Makefile
config.status: creating src/drivers/mysql/Makefile
config.status: creating src/drivers/pgsql/Makefile
config.status: creating src/tests/Makefile
config.status: creating src/tests/cpu/Makefile
config.status: creating src/tests/fileio/Makefile
config.status: creating src/tests/memory/Makefile
config.status: creating src/tests/threads/Makefile
config.status: creating src/tests/mutex/Makefile
config.status: creating src/lua/Makefile
config.status: creating src/lua/internal/Makefile
config.status: creating tests/Makefile
config.status: creating tests/include/config.sh
config.status: creating snap/snapcraft.yaml
config.status: creating config/config.h
config.status: executing depfiles commands
config.status: executing libtool commands
===============================================================================
sysbench version   : 1.1.0
CC                 : gcc -std=gnu99
CFLAGS             : -O3 -funroll-loops -ggdb3  -march=core-avx-i -Wall -Wextra -Wpointer-arith -Wbad-function-cast -Wstrict-prototypes -Wnested-externs -Wno-format-zero-length -Wundef -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wcast-align -Wvla   -pthread
CPPFLAGS           : -D_GNU_SOURCE   -I$(top_srcdir)/src -I$(abs_top_builddir)/third_party/luajit/inc -I$(abs_top_builddir)/third_party/concurrency_kit/include
LDFLAGS            : -L/usr/local/lib
LIBS               : -lm

prefix             : /usr/local
bindir             : ${prefix}/bin
libexecdir         : ${prefix}/libexec
mandir             : ${prefix}/share/man
datadir            : ${prefix}/share

MySQL support      : yes
PostgreSQL support : no

LuaJIT             : bundled
LUAJIT_CFLAGS      : -I$(abs_top_builddir)/third_party/luajit/inc
LUAJIT_LIBS        : $(abs_top_builddir)/third_party/luajit/lib/libluajit-5.1.a -ldl
LUAJIT_LDFLAGS     : -rdynamic

Concurrency Kit    : bundled
CK_CFLAGS          : -I$(abs_top_builddir)/third_party/concurrency_kit/include
CK_LIBS            : $(abs_top_builddir)/third_party/concurrency_kit/lib/libck.a
configure flags    :
===============================================================================

2.2 编译源码
[root@localhost sysbench]# make -j 4

2.3 安装(默认安装到 /usr/local/bin , 如果有自定义目录,configure增加参数 –prefix=自定义目录)
[root@localhost sysbench]# make install

添加LD_LIBRARY_PATH

[root@localhost ~]# echo "export LD_LIBRARY_PATH=/mysqlsoft/mysql/lib/:$LD_LIBRARY_PATH" >> ~/.bashrc

[root@localhost ~]# source ~/.bashrc
[root@localhost ~]# sysbench –version
sysbench 1.1.0

3. 测试
生成测试文件

[root@localhost ~]# sysbench  fileio   help
sysbench 1.1.0 (using bundled LuaJIT 2.1.0-beta3)

fileio options:
  --file-num=N                  number of files to create [128]
  --file-block-size=N           block size to use in all IO operations [16384]
  --file-total-size=SIZE        total size of files to create [2G]
  --file-test-mode=STRING       test mode {seqwr, seqrewr, seqrd, rndrd, rndwr, rndrw}
  --file-io-mode=STRING         file operations mode {sync,async,mmap} [sync]
  --file-extra-flags=[LIST,...] list of additional flags to use to open files {sync,dsync,direct} []
  --file-fsync-freq=N           do fsync() after this number of requests (0 - don't use fsync()) [100]
  --file-fsync-all[=on|off]     do fsync() after each write operation [off]
  --file-fsync-end[=on|off]     do fsync() at the end of test [on]
  --file-fsync-mode=STRING      which method to use for synchronization {fsync, fdatasync} [fsync]
  --file-merged-requests=N      merge at most this number of IO requests if possible (0 - don't merge) [0]
  --file-rw-ratio=N             reads/writes ratio for combined test [1.5]

其他说明

  # --file-num=N                  创建文件数
  # --file-block-size=N           block size大小
  # --file-total-size=SIZE        文件数的大小总和
  # --file-test-mode=STRING       测试模式 {seqwr, seqrewr, seqrd, rndrd, rndwr, rndrw} (顺序写,顺序读写,顺序读,随机读,随机写,随机读写)
  # --file-io-mode=STRING         文件操作方式 {sync,async,mmap}
  # --file-extra-flags=STRING     打开文件的额外标志 {sync,dsync,direct} []
  # --file-fsync-freq=N           多少请求后执行fsync。默认是0,不执行
  # --file-fsync-all=[on|off]     是否每次操作后都执行fsync
  # --file-fsync-end=[on|off]     测完成后执行fsync,默认是on
  # --file-fsync-mode=STRING      同步的方法 {fsync, fdatasync}默认是 [fsync]
  # --file-merged-requests=N      最多多少IO请求被合并,默认为0,不合并
  # --file-rw-ratio=N             读写比例默认是 [1.5],即 3:2
[root@localhost ~]# sysbench  fileio --file-num=4 --file-block-size=8K --file-total-size=1G --file-test-mode=rndrd --file-extra-flags=direct prepare
sysbench 1.1.0 (using bundled LuaJIT 2.1.0-beta3)

4 files, 262144Kb each, 1024Mb total
Creating files for the test...
Extra file open flags: directio
Creating file test_file.0
Creating file test_file.1
Creating file test_file.2
Creating file test_file.3
1073741824 bytes written in 29.00 seconds (35.30 MiB/sec).

开始测试(–time=30简单测试,测试30秒 –report-interval=3 # 每3秒产生报告)

[root@localhost ~]# sysbench  fileio  --file-num=4  --file-block-size=8K  --file-total-size=1G  --file-test-mode=rndrd  --file-extra-flags=direct  --threads=4 --time=30 --report-interval=3  run
sysbench 1.1.0 (using bundled LuaJIT 2.1.0-beta3)

Running the test with following options:
Number of threads: 4
Report intermediate results every 3 second(s)
Initializing random number generator from current time


Extra file open flags: directio
4 files, 256MiB each
1GiB total file size
Block size 8KiB
Number of IO requests: 0
Read/Write ratio for combined random IO test: 1.50
Periodic FSYNC enabled, calling fsync() each 100 requests.
Calling fsync() at the end of test, Enabled.
Using synchronous I/O mode
Doing random read test
Initializing worker threads...

Threads started!

[ 3s ] reads: 4.48 MiB/s writes: 0.00 MiB/s fsyncs: 0.00/s latency (ms,95%): 15.268
[ 6s ] reads: 4.39 MiB/s writes: 0.00 MiB/s fsyncs: 0.00/s latency (ms,95%): 15.828
[ 9s ] reads: 4.61 MiB/s writes: 0.00 MiB/s fsyncs: 0.00/s latency (ms,95%): 14.995
[ 12s ] reads: 4.73 MiB/s writes: 0.00 MiB/s fsyncs: 0.00/s latency (ms,95%): 13.953
[ 15s ] reads: 4.77 MiB/s writes: 0.00 MiB/s fsyncs: 0.00/s latency (ms,95%): 13.953
[ 18s ] reads: 4.81 MiB/s writes: 0.00 MiB/s fsyncs: 0.00/s latency (ms,95%): 14.207
[ 21s ] reads: 4.82 MiB/s writes: 0.00 MiB/s fsyncs: 0.00/s latency (ms,95%): 14.728
[ 24s ] reads: 4.84 MiB/s writes: 0.00 MiB/s fsyncs: 0.00/s latency (ms,95%): 14.995
[ 27s ] reads: 5.09 MiB/s writes: 0.00 MiB/s fsyncs: 0.00/s latency (ms,95%): 13.953
[ 30s ] reads: 5.16 MiB/s writes: 0.00 MiB/s fsyncs: 0.00/s latency (ms,95%): 14.207

Throughput:
         read:  IOPS=610.59 4.77 MiB/s (5.00 MB/s) #4.77*1024/8;
         write: IOPS=0.00 0.00 MiB/s (0.00 MB/s)
         fsync: IOPS=0.00

Latency (ms):
         min:                                  0.18
         avg:                                  6.54
         max:                                 45.86
         95th percentile:                     14.46
         sum:                             119902.59

]]>
http://www.jydba.net/index.php/archives/3430/feed 0
MySQL 5.7配置SSL连接 http://www.jydba.net/index.php/archives/3422 http://www.jydba.net/index.php/archives/3422#respond Fri, 16 Sep 2022 00:29:53 +0000 http://www.jydba.net/?p=3422 MySQL 5.7配置SSL连接

如果想服务能够部署自动支持安全连接,使用mysql_ssl_rsa_setup工具来创建缺省SSL与RSA文件

[root@cs2 bin]# ./mysql_ssl_rsa_setup --datadir=/mysqldata/mysql
Generating a 2048 bit RSA private key
......................................................................+++
..............................................................+++
writing new private key to 'ca-key.pem'
-----
Generating a 2048 bit RSA private key
.............+++
..............+++
writing new private key to 'server-key.pem'
-----
Generating a 2048 bit RSA private key
.....................................+++
................................................+++
writing new private key to 'client-key.pem'
-----





启动mysql

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

测试远程登录

-bash-4.2$ mysql -h 10.11.13.19 -P 3306 -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.22 MySQL Community Server (GPL)

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

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

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

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

Database changed
mysql> SELECT DISTINCT CONCAT('User: [', user, '''@''', host, '];') AS USER_HOST FROM user;
+------------------------------------+
| USER_HOST                          |
+------------------------------------+
| User: [root'@'%];                  |
| User: [mysql.session'@'localhost]; |
| User: [mysql.sys'@'localhost];     |
+------------------------------------+
3 rows in set (0.05 sec)

通过ssl登录mysql服务器

[mysql@localhost ~]$ mysql -h 10.11.13.19 -P 3306 -u root -pabcd123 --ssl-cert=client-cert.pem --ssl-key=client-key.pem
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 7
Server version: 5.7.26-log Source distribution

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

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

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

mysql> \s
--------------
mysql  Ver 14.14 Distrib 5.7.26, for Linux (x86_64) using  EditLine wrapper

Connection id:          7
Current database:
Current user:           root@10.11.13.19
SSL:                    Not in use
Current pager:          stdout
Using outfile:          ''
Using delimiter:        ;
Server version:         5.7.26-log Source distribution
Protocol version:       10
Connection:             10.11.13.19 via TCP/IP
Server characterset:    utf8mb4
Db     characterset:    utf8mb4
Client characterset:    gb2312
Conn.  characterset:    gb2312
TCP port:               3306
Uptime:                 14 min 11 sec

Threads: 2  Questions: 13  Slow queries: 0  Opens: 108  Flush tables: 1  Open tables: 101  Queries per second avg: 0.015
--------------

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

mysql> show variables like 'require_secure_transport';
+--------------------------+-------+
| Variable_name            | Value |
+--------------------------+-------+
| require_secure_transport | OFF   |
+--------------------------+-------+
1 row in set (0.00 sec)

mysql> show variables like '%ssl%';
+---------------+-----------------+
| Variable_name | Value           |
+---------------+-----------------+
| have_openssl  | DISABLED        |
| have_ssl      | DISABLED        |
| ssl_ca        | ca.pem          |
| ssl_capath    |                 |
| ssl_cert      | server-cert.pem |
| ssl_cipher    |                 |
| ssl_crl       |                 |
| ssl_crlpath   |                 |
| ssl_key       | server-key.pem  |
+---------------+-----------------+

从上面的查询结果可以看到SSL: Not in use,have_ssl和have_openssl为DISABLED,这说明实际上是没有启用ssl。

这是因为通过执行mysql_ssl_rsa_setup命令产生的pem文件的权限为root用户而不是mysql用户造成的,将这些pem文件的权限修改为mysql用户与组 权限不要太大,只用户权限为rw,组与其它用户需要r权限

[root@localhost mysql]# ls -lrt
30172
-rw-r-----. 1 mysql mysql 104857600 321 16:25 ib_logfile1
-rw-r-----. 1 mysql mysql 104857600 321 16:25 ib_logfile2
drwxr-x---. 2 mysql mysql        48 321 16:25 undo
-rw-r-----. 1 mysql mysql        56 321 16:25 auto.cnf
drwxr-x---. 2 mysql mysql      8192 321 16:25 performance_schema
drwxr-x---. 2 mysql mysql      4096 321 16:25 mysql
drwxr-x---. 2 mysql mysql      8192 321 16:25 sys
-rw-r-----. 1 mysql mysql       177 321 16:25 binlog.000001
-rw-r--r--. 1 mysql mysql      1679 321 16:26 ca-key.pem
-rw-r--r--. 1 mysql mysql      1107 321 16:26 ca.pem
-rw-r--r--. 1 root  root       1679 321 16:26 server-key.pem
-rw-r--r--. 1 root  root       1107 321 16:26 server-cert.pem
-rw-r--r--. 1 root  root      1675 321 16:26 client-key.pem
-rw-r--r--. 1 root  root      1107 321 16:26 client-cert.pem
-rw-r--r--. 1 root  root      1675 321 16:26 private_key.pem
-rw-r--r--. 1 root  root       451 321 16:26 public_key.pem
-rw-r-----. 1 mysql mysql    114688 524 17:00 ts2.ibd
-rw-r-----. 1 mysql mysql     98304 524 17:01 ts1.ibd
drwxr-x---. 2 mysql mysql        32 524 17:11 test
-rw-r-----. 1 mysql mysql      9352 621 10:46 binlog.000002
-rw-r-----. 1 mysql mysql       177 621 10:46 binlog.000003
-rw-r-----. 1 mysql mysql       154 9 9 19:55 binlog.000004
-rw-r-----. 1 mysql mysql       177 9 9 20:23 binlog.000005
-rw-r-----. 1 mysql mysql       177 9 9 20:38 binlog.000006
-rw-r-----. 1 mysql mysql       177 9 9 20:44 binlog.000007
-rw-r-----. 1 mysql mysql       122 9 9 20:44 ib_buffer_pool
-rw-r-----. 1 mysql mysql       248 9 9 20:44 binlog.index
-rw-r-----. 1 mysql mysql       154 9 9 20:44 binlog.000008
-rw-r-----. 1 mysql mysql         6 9 9 20:44 mysqld.pid
-rw-r-----. 1 mysql mysql  12582912 9 9 20:44 ibtmp1
-rw-r-----. 1 mysql mysql  10485760 9 9 20:44 ibdata1
-rw-r-----. 1 mysql mysql 104857600 9 9 20:44 ib_logfile0
-rw-r-----. 1 mysql mysql    107011 9 9 20:54 mysql.err

[root@localhost mysql]# chown -R mysql:mysql *.pem
[root@localhost mysql]# ls -lrt
30172
-rw-r-----. 1 mysql mysql 104857600 321 16:25 ib_logfile1
-rw-r-----. 1 mysql mysql 104857600 321 16:25 ib_logfile2
drwxr-x---. 2 mysql mysql        48 321 16:25 undo
-rw-r-----. 1 mysql mysql        56 321 16:25 auto.cnf
drwxr-x---. 2 mysql mysql      8192 321 16:25 performance_schema
drwxr-x---. 2 mysql mysql      4096 321 16:25 mysql
drwxr-x---. 2 mysql mysql      8192 321 16:25 sys
-rw-r-----. 1 mysql mysql       177 321 16:25 binlog.000001
-rw-r--r--. 1 mysql mysql      1679 321 16:26 ca-key.pem
-rw-r--r--. 1 mysql mysql      1107 321 16:26 ca.pem
-rw-r--r--. 1 mysql mysql      1679 321 16:26 server-key.pem
-rw-r--r--. 1 mysql mysql      1107 321 16:26 server-cert.pem
-rw-r--r--. 1 mysql mysql      1675 321 16:26 client-key.pem
-rw-r--r--. 1 mysql mysql      1107 321 16:26 client-cert.pem
-rw-r--r--. 1 mysql mysql      1675 321 16:26 private_key.pem
-rw-r--r--. 1 mysql mysql       451 321 16:26 public_key.pem
-rw-r-----. 1 mysql mysql    114688 524 17:00 ts2.ibd
-rw-r-----. 1 mysql mysql     98304 524 17:01 ts1.ibd
drwxr-x---. 2 mysql mysql        32 524 17:11 test
-rw-r-----. 1 mysql mysql      9352 621 10:46 binlog.000002
-rw-r-----. 1 mysql mysql       177 621 10:46 binlog.000003
-rw-r-----. 1 mysql mysql       154 9 9 19:55 binlog.000004
-rw-r-----. 1 mysql mysql       177 9 9 20:23 binlog.000005
-rw-r-----. 1 mysql mysql       177 9 9 20:38 binlog.000006
-rw-r-----. 1 mysql mysql       177 9 9 20:44 binlog.000007
-rw-r-----. 1 mysql mysql       122 9 9 20:44 ib_buffer_pool
-rw-r-----. 1 mysql mysql       248 9 9 20:44 binlog.index
-rw-r-----. 1 mysql mysql       154 9 9 20:44 binlog.000008
-rw-r-----. 1 mysql mysql         6 9 9 20:44 mysqld.pid
-rw-r-----. 1 mysql mysql  12582912 9 9 20:44 ibtmp1
-rw-r-----. 1 mysql mysql  10485760 9 9 20:44 ibdata1
-rw-r-----. 1 mysql mysql 104857600 9 9 20:44 ib_logfile0
-rw-r-----. 1 mysql mysql    107011 9 9 20:54 mysql.err

pem文件权限太多可能会出现如下错误

[mysql@localhost mysql]$ mysql -h 10.11.13.19 -P 3306 -u root -pabcd123 --ssl-cert=/mysqldata/mysql/client-cert.pem --ssl-key=/mysqldata/mysql/client-key.pem
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 2026 (HY000): SSL connection error: SSL_CTX_set_default_verify_paths failed


[root@localhost mysql]# service mysqld restart
Shutting down MySQL.. SUCCESS!
Starting MySQL.. SUCCESS!

[mysql@localhost mysql]$ mysql -h 10.11.13.19 -P 3306 -u root -pabcd123 --ssl-cert=/mysqldata/mysql/client-cert.pem --ssl-key=/mysqldata/mysql/client-key.pem
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.26-log Source distribution

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

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

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

mysql> \s
--------------
mysql  Ver 14.14 Distrib 5.7.26, for Linux (x86_64) using  EditLine wrapper

Connection id:          4
Current database:
Current user:           root@10.11.13.19
SSL:                    Cipher in use is DHE-RSA-AES256-SHA
Current pager:          stdout
Using outfile:          ''
Using delimiter:        ;
Server version:         5.7.26-log Source distribution
Protocol version:       10
Connection:             10.11.13.19 via TCP/IP
Server characterset:    utf8mb4
Db     characterset:    utf8mb4
Client characterset:    gb2312
Conn.  characterset:    gb2312
TCP port:               3306
Uptime:                 59 sec

Threads: 2  Questions: 11  Slow queries: 0  Opens: 108  Flush tables: 1  Open tables: 101  Queries per second avg: 0.186
--------------

创建用户限制用户必须用ssl登录

mysql> create user 'jy'@'%' identified by "123";
Query OK, 0 rows affected (0.02 sec)

mysql> grant all on *.* to 'jy'@'%' require ssl;
Query OK, 0 rows affected, 1 warning (0.02 sec)

虽然要求用ssl但是还是可以使用密码登录,是因为mysql.user表中的ssl_type=ANY

[mysql@localhost ~]$  mysql -h 10.11.13.19 -P 3306 -u jy -p123
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 7
Server version: 5.7.26-log Source distribution

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

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

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

mysql> \s
--------------
mysql  Ver 14.14 Distrib 5.7.26, for Linux (x86_64) using  EditLine wrapper

Connection id:          7
Current database:
Current user:           jy@10.11.13.19
SSL:                    Cipher in use is DHE-RSA-AES256-SHA
Current pager:          stdout
Using outfile:          ''
Using delimiter:        ;
Server version:         5.7.26-log Source distribution
Protocol version:       10
Connection:             10.11.13.19 via TCP/IP
Server characterset:    utf8mb4
Db     characterset:    utf8mb4
Client characterset:    gb2312
Conn.  characterset:    gb2312
TCP port:               3306
Uptime:                 50 min 18 sec

Threads: 2  Questions: 69  Slow queries: 0  Opens: 139  Flush tables: 1  Open tables: 132  Queries per second avg: 0.022
--------------

mysql> select * from user where user='jy'\G
ERROR 1046 (3D000): No database selected
mysql> select * from mysql.user where user='root'\G
*************************** 1. row ***************************
                  Host: %
                  User: jy
           Select_priv: Y
           Insert_priv: Y
           Update_priv: Y
           Delete_priv: Y
           Create_priv: Y
             Drop_priv: Y
           Reload_priv: Y
         Shutdown_priv: Y
          Process_priv: Y
             File_priv: Y
            Grant_priv: Y
       References_priv: Y
            Index_priv: Y
            Alter_priv: Y
          Show_db_priv: Y
            Super_priv: Y
 Create_tmp_table_priv: Y
      Lock_tables_priv: Y
          Execute_priv: Y
       Repl_slave_priv: Y
      Repl_client_priv: Y
      Create_view_priv: Y
        Show_view_priv: Y
   Create_routine_priv: Y
    Alter_routine_priv: Y
      Create_user_priv: Y
            Event_priv: Y
          Trigger_priv: Y
Create_tablespace_priv: Y
              ssl_type: ANY
            ssl_cipher:
           x509_issuer:
          x509_subject:
         max_questions: 0
           max_updates: 0
       max_connections: 0
  max_user_connections: 0
                plugin: mysql_native_password
 authentication_string: *1AA476D99C1600C9D984E248FBF2FDE3A0BB256E
      password_expired: N
 password_last_changed: 2022-03-21 16:27:48
     password_lifetime: NULL
        account_locked: N
1 row in set (0.00 sec)

修改用户jy的ssl类型为x509

mysql> alter user 'jy'@'%' require x509
    -> ;
Query OK, 0 rows affected (0.01 sec)

在不指定ssl密钥时就不能登录了

[mysql@localhost ~]$ mysql -h 10.11.13.19 -P 3306 -u jy -p123
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 1045 (28000): Access denied for user 'jy'@'10.11.13.19' (using password: YES)
[mysql@localhost ~]$  mysql -h 10.11.13.19 -P 3306 -u jy -p123 --ssl
mysql: [Warning] Using a password on the command line interface can be insecure.
WARNING: --ssl is deprecated and will be removed in a future version. Use --ssl-mode instead.
ERROR 1045 (28000): Access denied for user 'jy'@'10.11.13.19' (using password: YES)

指定ssl密钥进行登录

[mysql@localhost ~]$  mysql -h 10.11.13.19 -P 3306 -u jy -p123 --ssl-cert=/mysqldata/mysql/client-cert.pem --ssl-key=/mysqldata/mysql/client-key.pem
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 5.7.26-log Source distribution

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

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

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

mysql> exit

如果指定ssl密钥进行登录时不指定密钥完整路径时会出现如下错误

[mysql@localhost ~]$  mysql -h 10.11.13.19 -P 3306 -u jy -p123 --ssl-cert=client-cert.pem --ssl-key=client-key.pem
mysql: [Warning] Using a password on the command line interface can be insecure.
mysql: [ERROR] SSL error: Unable to get certificate from 'client-cert.pem'
ERROR 2026 (HY000): SSL connection error: Unable to get certificate
]]>
http://www.jydba.net/index.php/archives/3422/feed 0
MySQL 拷贝一个InnoDB分区表到另一个实例 http://www.jydba.net/index.php/archives/3416 http://www.jydba.net/index.php/archives/3416#respond Mon, 11 Apr 2022 01:03:40 +0000 http://www.jydba.net/?p=3416 拷贝一个InnoDB分区表到另一个实例
这个过程演示了如何将一个InnoDB分区表从一个正在运行的MySQL服务器实例复制到另一个正在运行的实例。同样的过程,只要稍微做些调整,就可以在同一个实例上对InnoDB分区表执行完全恢复。

1.在源实例上,如果不存在分区表,则创建分区表。在下面的例子中,创建了一个包含三个分区(p0, p1, p2)的表

mysql> use test;
Database changed
mysql> create table t1(i int) engine=innodb partition by key(i) partitions 3;
Query OK, 0 rows affected (0.38 sec)

mysql> insert into t1 values(1),(2),(3),(4),(5),(6),(7),(8),(9);
Query OK, 9 rows affected (0.03 sec)
Records: 9  Duplicates: 0  Warnings: 0
mysql> select * from t1;
+------+
| i    |
+------+
|    4 |
|    5 |
|    1 |
|    6 |
|    7 |
|    2 |
|    3 |
|    8 |
|    9 |
+------+
9 rows in set (0.00 sec)

在/mysqldata/mysql/test目录中,对于三个分区都有一个单独的表空间(.ibd)文件:

[root@localhost ~]# cd /mysqldata/mysql/test
[root@localhost test]# ls -lrt
总用量 304
-rw-r-----. 1 mysql mysql    67 3月  15 16:53 db.opt
-rw-r-----. 1 mysql mysql  8554 3月  16 15:43 t1.frm
-rw-r-----. 1 mysql mysql 98304 3月  16 15:43 t1#P#p1.ibd
-rw-r-----. 1 mysql mysql 98304 3月  16 15:43 t1#P#p2.ibd
-rw-r-----. 1 mysql mysql 98304 3月  16 15:43 t1#P#p0.ibd

2.在目标实例上,创建相同的分区表:

mysql> use test;
Database changed
mysql> create table t1(i int) engine=innodb partition by key(i) partitions 3;
Query OK, 0 rows affected (0.20 sec)

在/mysqldata/mysql/test目录中,对于三个分区都有一个单独的表空间(.ibd)文件:

[root@localhost ~]# cd /mysqldata/mysql/test
[root@localhost test]# ls -lrt
总用量 304
-rw-r-----. 1 mysql mysql    67 3月  15 16:55 db.opt
-rw-r-----. 1 mysql mysql  8554 3月  16 15:45 t1.frm
-rw-r-----. 1 mysql mysql 98304 3月  16 15:45 t1#P#p0.ibd
-rw-r-----. 1 mysql mysql 98304 3月  16 15:45 t1#P#p1.ibd
-rw-r-----. 1 mysql mysql 98304 3月  16 15:45 t1#P#p2.ibd

3.在目标实例上,丢弃分区表的表空间。(在将表空间导入目标实例之前,必须丢弃附加到接收表的表空间。)

mysql> alter table t1 discard tablespace;
Query OK, 0 rows affected (0.09 sec)

组成分区表表空间的三个.ibd文件从/mysqldata/mysql/tes目录中被丢弃,留下以下文件

[root@localhost ~]# cd /mysqldata/mysql/test
[root@localhost test]# ls -lrt
总用量 16
-rw-r-----. 1 mysql mysql   67 3月  15 16:55 db.opt
-rw-r-----. 1 mysql mysql 8554 3月  16 15:45 t1.frm

4.在源实例上,运行FLUSH TABLES… FOR EXPORT用于暂停分区表并创建.cfg元数据文件

mysql> flush tables t1 for export;
Query OK, 0 rows affected (0.01 sec)

在源实例的/mysqldata/mysql/test目录中创建元数据(.cfg)文件,每个表空间(.ibd)文件对应一个元数据文件

[root@localhost ~]# cd /mysqldata/mysql/test
[root@localhost test]# ls -lrt
总用量 316
-rw-r-----. 1 mysql mysql    67 3月  15 16:53 db.opt
-rw-r-----. 1 mysql mysql  8554 3月  16 15:43 t1.frm
-rw-r-----. 1 mysql mysql 98304 3月  16 15:43 t1#P#p1.ibd
-rw-r-----. 1 mysql mysql 98304 3月  16 15:43 t1#P#p2.ibd
-rw-r-----. 1 mysql mysql 98304 3月  16 15:43 t1#P#p0.ibd
-rw-r-----. 1 mysql mysql   375 3月  16 16:00 t1#P#p1.cfg
-rw-r-----. 1 mysql mysql   375 3月  16 16:00 t1#P#p0.cfg
-rw-r-----. 1 mysql mysql   375 3月  16 16:00 t1#P#p2.cfg

FLUSH TABLES……FOR EXPORT语句确保对指定表的更改已刷新到磁盘,以便在实例运行时可以进行二进制表拷贝。当运行FLUSH TABLES … FOR EXPORT时,InnoDB会在数据库目录中为表的表空间文件生成一个.cfg元数据文件。.cfg文件中包含导入表空间文件时验证模式的元数据。FLUSH TABLES … FOR EXPORT只能在表上运行,而不能在单独的表分区上运行。

5.将.ibd和.cfg文件从源实例数据库目录复制到目标实例数据库目录。例如

[root@localhost test]# scp t1*.{ibd,cfg} mysql@192.168.1.243:/mysqldata/mysql/test/
mysql@192.168.1.243's password:
t1#P#p0.ibd                                                                                                                                                                                              100%   96KB  96.0KB/s   00:00
t1#P#p1.ibd                                                                                                                                                                                              100%   96KB  96.0KB/s   00:00
t1#P#p2.ibd                                                                                                                                                                                              100%   96KB  96.0KB/s   00:00
t1#P#p0.cfg                                                                                                                                                                                              100%  375     0.4KB/s   00:00
t1#P#p1.cfg                                                                                                                                                                                              100%  375     0.4KB/s   00:00
t1#P#p2.cfg                                                                                                                                                                                              100%  375     0.4KB/s   00:00
[root@localhost test]#

[root@localhost test]# ls -lrt
总用量 316
-rw-r-----. 1 mysql mysql    67 3月  15 16:55 db.opt
-rw-r-----. 1 mysql mysql  8554 3月  16 15:45 t1.frm
-rw-r-----. 1 mysql mysql 98304 3月  16 16:06 t1#P#p0.ibd
-rw-r-----. 1 mysql mysql 98304 3月  16 16:06 t1#P#p1.ibd
-rw-r-----. 1 mysql mysql 98304 3月  16 16:06 t1#P#p2.ibd
-rw-r-----. 1 mysql mysql   375 3月  16 16:06 t1#P#p0.cfg
-rw-r-----. 1 mysql mysql   375 3月  16 16:06 t1#P#p1.cfg
-rw-r-----. 1 mysql mysql   375 3月  16 16:06 t1#P#p2.cfg

6.在源实例上,使用unlock tables语句来释放由flush tables … for export所获取的锁:

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

在源实例上释放锁时,会向mysql日志文件写入删除.cfg文件的信息:

2022-03-16T08:08:27.653352Z 10 [Note] InnoDB: Deleting the meta-data file './test/t1#P#p0.cfg'
2022-03-16T08:08:27.653656Z 10 [Note] InnoDB: Deleting the meta-data file './test/t1#P#p1.cfg'
2022-03-16T08:08:27.654214Z 10 [Note] InnoDB: Deleting the meta-data file './test/t1#P#p2.cfg'
2022-03-16T08:08:27.654256Z 10 [Note] InnoDB: Resuming purge

7.在目标实例上,导入表空间:

mysql> select * from t1;
ERROR 1814 (HY000): Tablespace has been discarded for table 't1'
mysql> alter table t1 discard tablespace;
Query OK, 0 rows affected (0.09 sec)

mysql> alter table t1 import tablespace;
Query OK, 0 rows affected (0.46 sec)

mysql> select * from t1;
+------+
| i    |
+------+
|    4 |
|    5 |
|    1 |
|    6 |
|    7 |
|    2 |
|    3 |
|    8 |
|    9 |
+------+
9 rows in set (0.01 sec)
]]>
http://www.jydba.net/index.php/archives/3416/feed 0
MySQL 传输表空间 http://www.jydba.net/index.php/archives/3414 http://www.jydba.net/index.php/archives/3414#respond Sat, 09 Apr 2022 01:38:20 +0000 http://www.jydba.net/?p=3414 将file-per-table表空间复制到另一个实例
如何将一个file-per-table表空间从一个MySQL实例复制到另一个实例中,也就是众所周知的可传输表空间特性。

有很多原因可以解释为什么你可以将一个InnoDB文件表空间复制到不同的实例中:
.在不增加生产服务器额外负载的情况下运行报表。

.在新的从服务器上为表设置相同的数据

.在出现问题或错误后恢复表或分区的备份版本。

.作为一种比mysqldump命令导入更快的移动数据的方法。数据立即可用,而不需要重新插入和重建索引

.将每个file-per-table表空间移动到具有更适合系统需求的存储介质的服务器。例如,您可能希望在SSD设备上有繁忙的表,或者在高容量HDD设备上有大型表。

限制和使用说明
.只有当innodb_file_per_table设置为ON(默认设置)时,才可以拷贝表空间。驻留在共享系统表空间中的表不能被静默。

.当一个表被静默时,只允许在受影响的表上执行只读事务

.在导入表空间时,页面大小必须与导入实例的页面大小相匹配。

.当foreign_key_checks设置为1时,对于父-子(主-外键)关系的表空间不支持DISCARD TABLESPACE。在丢弃父-子表的表空间之前,设置foreign_key_checks=0。分区InnoDB表不支持外键。

.ALTER TABLE……IMPORT TABLESPACE不会对导入的数据强制外键约束。如果表之间存在外键约束,那么所有表都应该在同一(逻辑)时间点导出。分区InnoDB表不支持外键。

.ALTER TABLE……IMPORT TABLESPACE 和 ALTER TABLE…IMPORT PARTITION…TABLESPACE不需要.cfg元数据文件来导入一个表空间。但是,如果导入时没有.cfg文件,则不会执行元数据检查,并且会发出类似于下面的警告:

Message: InnoDB: IO Read error: (2, No such file or directory) Error opening '.\
test\t.cfg', will attempt to import without schema verification
1 row in set (0.00 sec)

在期待没用模式不匹配的情况下,不使用.cfg文件进行导入可能会更方便。此外,在无法从.ibd文件收集元数据的崩溃恢复场景中,不需要.cfg文件就可以导入。

.由于.cfg元数据文件的限制,当为分区表导入表空间文件时,不会对分区类型或分区定义差异报告模式不匹配。列差异被报告。

.当在子分区表上运行ALTER TABLE … DISCARD PARTITION … TABLESPACE和ALTER TABLE … IMPORT PARTITION … TABLESPACE,分区和子分区表名都是允许的。当指定分区名时,该分区的子分区将包含在操作中。

.如果两个实例都有GA(通用可用性)状态,并且它们的版本在同一系列可以从另一个MySQL服务器实例导入表空间文件。否则,该文件必须是在导入它的同一个服务器实例上所创建

.在复制场景中,innodb_file_per_table必须在主节点和从节点上都设置为ON。

.在Windows环境下,InnoDB内部存储数据库、表空间和表名时使用小写字母。为了避免在区分大小写的操作系统(如Linux、UNIX)上的导入问题,请在创建数据库、表空间和表时使用小写名称。一种方便的方法是在创建数据库、表空间或表之前,在my.cnf或my.ini文件的[mysqld]部分中添加下面这一行:

[mysqld]
lower_case_table_names=1

.alter table … discard tablespace和alter table … import tabelspace不支持属于InnoDB通用表空间中的表。

.InnoDB表的默认行格式可以通过innodb_default_row_format配置选项进行配置。如果导入的表没有明确定义行格式(ROW_FORMAT),或者使用了ROW_FORMAT=DEFAULT,那么如果源实例上的innodb_default_row_format设置与目标实例上的innodb_default_row_format设置不一致,可能会导致模式不匹配错误

.在使用InnoDB表空间加密特性导出加密的表空间时,InnoDB除了生成一个.cfg元数据文件外,还会生成一个.cfp文件。在目标实例上执行ALTER TABLE…IMPORT TABLESPACE之前,必须将.cfp文件与.cfg文件和表空间文件一起复制到目标实例中。cfp文件包含一个传输密钥和一个加密的表空间密钥。在导入时,InnoDB使用传输密钥来解密表空间密钥。

传输表空间示例
例如1:复制一个InnoDB表到另一个实例
这个过程演示了如何将一个普通的InnoDB表从一个正在运行的MySQL服务器实例复制到另一个正在运行的实例。可以使用相同的过程在相同的实例上执行全表恢复,只是做了一些小小的调整。
1. 在源实例上,如果不存在表,则创建一个表:

mysql> use test;
Database changed
mysql> create table t(c1 int) engine=innodb;
Query OK, 0 rows affected (0.12 sec)

mysql> insert into t values(1);
Query OK, 1 row affected (0.16 sec)

2.在目标实例上,如果不存在表,则创建表:

mysql> use test;
Database changed
mysql> create table t(c1 int) engine=innodb;
Query OK, 0 rows affected (0.09 sec)

3.在目标实例上,丢弃现有的表空间。(在导入表空间之前,InnoDB必须丢弃连接到接收表空间的表空间。)

[mysql@localhost test]$ ls -lrt
总用量 112
-rw-r-----. 1 mysql mysql    67 3月  15 16:55 db.opt
-rw-r-----. 1 mysql mysql  8556 3月  15 16:57 t.frm
-rw-r-----. 1 mysql mysql 98304 3月  15 16:57 t.ibd

mysql> alter table t discard tablespace;
Query OK, 0 rows affected (0.17 sec)



[mysql@localhost test]$ ls -lrt
总用量 16
-rw-r-----. 1 mysql mysql   67 3月  15 16:55 db.opt
-rw-r-----. 1 mysql mysql 8556 3月  15 16:57 t.frm

4.在源实例上,运行FLUSH TABLES…FOR EXPORT将暂停表并创建.cfg元数据文件

mysql> flush tables t for export;
Query OK, 0 rows affected (0.00 sec)


[mysql@localhost test]$ ls -lrt
总用量 116
-rw-r-----. 1 mysql mysql    67 3月  15 16:53 db.opt
-rw-r-----. 1 mysql mysql  8556 3月  15 16:54 t.frm
-rw-r-----. 1 mysql mysql 98304 3月  15 16:54 t.ibd
-rw-r-----. 1 mysql mysql   371 3月  15 17:00 t.cfg

在InnoDB数据目录下创建元数据(.cfg)
注意:FLUSH TABLES …… FOR EXPORT在MySQL 5.6.6版本中可用。该语句确保对指定表的更改已刷新到磁盘,以便在实例运行时可以生成二进制表副本。当FLUSH TABLES … FOR EXPORT时,InnoDB会在表所在的数据库目录中生成一个.cfg文件。cfg文件中包含导入表空间文件时用于模式验证的元数据。

5.将.ibd文件和.cfg元数据文件从源实例复制到目标实例

[mysql@localhost test]$ scp t.{ibd,cfg} mysql@192.168.1.243:/mysqldata/mysql/test/
mysql@192.168.1.243's password:
t.ibd                                                                                                                                                                                                    100%   96KB  96.0KB/s   00:00
t.cfg                                                                                                                                                                                                    100%  371     0.4KB/s   00:00
[mysql@localhost test]$

在释放共享锁之前必须复制.ibd与.cfg文件。

6.在源实例上,使用unlock tables语句来释放由flush tables … for export所获取的锁:

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

7.在目标实例上,导入表空间:
mysql> alter table t import tablespace;
Query OK, 0 rows affected (0.15 sec)

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

mysql> select * from t;
+------+
| c1   |
+------+
|    1 |
+------+
1 row in set (0.00 sec)

可以看到表t从一个实例迁移到另一个实例上。

]]>
http://www.jydba.net/index.php/archives/3414/feed 0
MySQL InnoDB File-Per-Table表空间 http://www.jydba.net/index.php/archives/3377 http://www.jydba.net/index.php/archives/3377#respond Fri, 11 Mar 2022 00:57:19 +0000 http://www.jydba.net/?p=3377 InnoDB File-Per-Table表空间
过去,所有InnoDB表和索引都存储在系统表空间中。这种整体的方法针对的是完全专用于数据库处理的机器,通过精心规划的数据增长,分配给MySQL的任何磁盘存储永远不会被用于其他用途。InnoDB的file-per-table表空间特性提供了一个更灵活的替代方案,每个InnoDB表及其索引都存储在一个单独的.ibd数据文件中。每个这样的.ibd数据文件代表一个单独的表空间。这个特性是由innodb_file_per_table配置选项控制的,在MySQL 5.6.6及更高版本中默认启用。

file-per-table表空间的优点
.当truncate或drop存储在file-per-table表空间中的表时,可以回收磁盘空间。truncate或drop存储在共享系统表空间中的表会在系统表空间数据文件(ibdata文件)内部创建空闲空间,这些空间只能用于新的InnoDB数据。

.在存储在file-per-table表空间文件中的表上运行TRUNCATE TABLE操作会更快。

.您可以将特定的表存储在单独的存储设备上,以实现I/O优化、空间管理或备份目的。在以前的版本中,您必须将整个数据库目录移动到其他驱动器,并在MySQL数据目录中创建符号链接。在MySQL 5.6.6及更高版本中,你可以使用
create table… data directory=absolute_path_to_directory。

.你可以运行OPTIMIZE TABLE来压缩或重新创建一个file-per-table表空间。当你运行一个OPTIMIZE TABLE时,InnoDB会创建一个新的.ibd文件,该文件带有一个临时名称,只使用存储实际数据所需的空间。当优化完成后,InnoDB会删除旧的.ibd文件,并用新文件替换它。如果以前的.ibd文件显著增长,但实际数据只占其大小的一部分,那么运行OPTIMIZE TABLE可以回收未使用的空间。

.你可以移动单个InnoDB表,而不是整个数据库

.你可以将InnoDB表从一个MySQL实例复制到另一个实例(称为可迁移表空间特性)。

.在file-per-table表空间中创建的表使用Barracuda文件格式。Barracuda文件格式支持压缩和动态行格式等特性

.可以使用动态行格式为具有大型BLOB或TEXT列的表启用更高效的存储。

.file-per-table表空间可以在发生损坏、服务器无法重启或备份和二进制日志不可用时提高成功恢复的机会并节省时间。

.在复制或备份表时,file-per-table表空间可以方便地报告每个表的状态。

.可以在文件系统级别监控表大小,而不需要访问MySQL。

.当innodb_flush_method设置为O_DIRECT时,普通的Linux文件系统不允许并发写入单个文件。因此,使用file-per-table表空间和innodb_flush_method可能会提高性能。

.系统表空间存储数据字典和undo日志,受InnoDB表空间大小限制。使用file-per_table表空间,每个表都有自己的表空间,这为增长提供了空间。

file-per-table表空间的潜在缺点
.使用file-per-table表空间,每个表可能有未使用的空间,这些空间只能由同一表的行使用。如果管理不当,可能会造成空间的浪费。

.fsync操作必须在每个打开的表上运行,而不是单个文件上。因为每个文件都有一个单独的fsync操作,所以对多个表的写操作不能合并成一个单独的I/O操作。这可能需要InnoDB执行更多的fsync操作。

.mysqld必须为每个表保留一个打开的文件句柄,如果在file-per-table表空间中有很多表,这可能会影响性能。

.使用了更多的文件描述符

.innodb_file_per_table在MySQL 5.6.6及更高版本中是默认启用的。如果向后兼容MySQL 5.5或5.1是一个问题,你可以考虑禁用它。禁用innodb_file_per_table功能可以防止在ALTER TABLE重新创建InnoDB表(ALGORITHM=COPY)时,阻止alter table将InnoDB表从系统表空间移动到单独的.ibd文件中。

例如,当重构InnoDB表的聚集索引时,表会使用innodb_file_per_table的当前设置重新创建。此行为在添加或删除InnoDB二级索引时不适用。当不重建表而创建二级索引时,无论当前的innodb_file_per_table设置是什么,索引都被存储在与表数据相同的文件中。此行为也不适用于使用CREATE TABLE…TABLESPACE或ALTER TABLE …TABLESPACE语法添加到系统表空间中的表。这些表不受innodb_file_per_table设置的影响。

.如果许多表都在增长,可能会出现更多的碎片,这可能会影响DROP TABLE和表扫描性能。但是,在管理碎片时,将文件放在它们自己的表空间中可以提高性能。

.在删除file-per-table表空间时会扫描缓冲池,对于大小为几十gb的缓冲池来说,这可能需要几秒钟的时间。扫描是用一个宽的内部锁执行的,这可能会延迟其他操作。系统表空间中的表不受影响。

.innodb_autoextend_increment变量定义了自动扩展的共享表空间文件满时的扩展大小(以MB为单位),但不适用于file-per-table表空间文件,不管是否设置了innodb_autoextend_increment,这些文件都是自动扩展的。最初的扩展是少量的,之后扩展以4MB的增量出现。

启用与禁用file-per-table表空间
innodb_file_per_table选项默认是启用的。

为了在启动时设置innodb_file_per_table选项,可以在启动服务时使用–innodb_file_per_table命令行选项或者在my.cnf文件中[mysqld]部分增加以下一行内容:

[mysqld]
innodb_file_per_table=1

你也可以在服务器运行时动态设置innodb_file_per_table:

mysql> SET GLOBAL innodb_file_per_table=1;
Query OK, 0 rows affected (0.00 sec)

启用innodb_file_per_table时,可以将InnoDB表存储在tbl_name.ibd文件。不像MyISAM存储引擎,它有单独的tbl_name.MYD和tbl_name.MYI文件用于索引和数据,InnoDB将数据和索引一起存储在一个.ibd文件中。仍然像往常一样创建tbl_name.frm文件。

如果在启动选项中禁用innodb_file_per_table并重启服务器或者使用set global命令来禁用它,除非你显式的使用create table … tablespace选项将表存放在file-per-table表空间或通用表空间否则innodb将在系统表空间创建新表。

你总是可以读取和写入任何InnoDB表,不管file-per-table设置情况。

如果要将表从系统表空间移动到自己的表空间,需要修改innodb_file_per_table的设置,然后重新创建表:

mysql> SET GLOBAL innodb_file_per_table=1;
mysql> ALTER TABLE table_name ENGINE=InnoDB;

使用CREATE TABLE…TABLESPACE或ALTER TABLE…TABLESPACE语法添加表到系统表空间不受innodb_file_per_table设置的影响。要将这些表从系统表空间移动到file-per-table表空间,必须使用ALTER TABLE…TABLESPACE语法。

InnoDB总是需要系统表空间,因为它把它的内部数据字典和undo日志放在那里。.ibd文件不够InnoDB操作。

当一个表从系统表空间移到它自己的.ibd文件时,组成系统表空间的数据文件保持相同的大小。InnoDB表以前占用的空间可以被新的InnoDB数据重用,但是不会被操作系统回收使用。当将较大的InnoDB表移出系统表空间(磁盘空间有限)时,你可能更喜欢启用innodb_file_per_table并使用mysqldump命令重新创建整个实例。如上所述,使用CREATE TABLE…TABLESPACE或者ALTER TABLE…表空间语法不受innodb_file_per_table设置的影响。这些桌子必须单独移动。

在数据目录外创建逐file-per-table表空间
要在MySQL数据目录之外的特定位置创建一个新的InnoDB file-per-table表空间,使用有data directory = absolute_path_to_directory子句的CREATE TABLE语句的来实现。

提前计划位置,因为您不能在ALTER TABLE语句中使用DATA DIRECTORY子句。您指定的目录可以位于具有特定性能或容量特征的另一个存储设备上,例如快速SSD或大容量HDD。

在目标目录中,MySQL创建一个与数据库名称对应的子目录,在该子目录中为新表创建一个.ibd文件。在MySQL DATADIR目录下的数据库目录中,MySQL创建了一个table_name.Isl文件包含表路径名。.isl文件被MySQL视为一个符号链接。(InnoDB表不支持使用实际的符号链接。)

下面的例子演示了如何在MySQL数据目录外创建一个file-per-table表空间。它显示了在指定目录中创建的.ibd,以及在MySQL数据目录下的数据库目录中创建的.isl。

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


mysql> create table t_cs(c1 int primary key) data directory='/data';
Query OK, 0 rows affected (0.22 sec)


[root@localhost mysql]# pwd
/data/mysql
[root@localhost mysql]# ls -lrt
总用量 96
-rw-r-----. 1 mysql mysql 98304 3月   8 16:09 t_cs.ibd

[root@localhost mysql]# ls -lrt t_cs*
-rw-r-----. 1 mysql mysql 8556 3月   8 16:09 t_cs.frm
-rw-r-----. 1 mysql mysql   20 3月   8 16:09 t_cs.isl

你也可以使用CREATE TABLE…TABLESPACE与DATA DIRECTORY子句结合,在MySQL数据目录之外创建一个file-per-table表空间。为此,你必须指定innodb_file_per_table作为表空间名。

mysql> create table t_cs_3(c1 int primary key) tablespace=innodb_file_per_table data directory='/data';
Query OK, 0 rows affected (0.28 sec)

[root@localhost mysql]# ls -lrt t_cs_2*
-rw-r-----. 1 mysql mysql 98304 3月   8 16:14 t_cs_2.ibd

[root@localhost mysql]# ls -lrt t_cs_2*
-rw-r-----. 1 mysql mysql 8556 3月   8 16:14 t_cs_2.frm
-rw-r-----. 1 mysql mysql   22 3月   8 16:14 t_cs_2.isl

使用这个方法时,你不需要启用innodb_file_per_table。

使用说明:
.MySQL最初保存的.ibd文件是打开的,防止您卸载设备,但如果服务器繁忙,可能最终会关闭表。小心不要在MySQL运行时意外地卸载外部设备,或者在设备断开连接时启动MySQL。当关联的.ibd文件丢失时,试图访问表会导致严重错误,需要重新启动服务器。

如果.ibd文件仍然不在预期的路径上,服务器重启可能会失败。在本例中,手动删除数据库目录中的table_name.isl文件重新启动后,执行DROPTABLE命令删除.frm文件,并从数据字典中删除该表的信息。

.在将表存放在NFS挂载的卷上之前,请查看在使用NFS和MySQL中列出的潜在问题。

.如果您使用LVM快照、文件复制或其他基于文件的机制来备份.ibd文件,请始终使用FLUSH TABLES…FOR EXPORT语句,以确保在备份发生之前将缓存在内存中的所有更改刷新到磁盘。

.DATA DIRECTORY子句是一种支持替代符号链接的方法,符号链接一直存在问题,从来没有被支持用于单独的InnoDB表。

]]>
http://www.jydba.net/index.php/archives/3377/feed 0
MySQL 修改InnoDB重做日志文件的数量或大小 http://www.jydba.net/index.php/archives/3375 http://www.jydba.net/index.php/archives/3375#respond Fri, 11 Mar 2022 00:53:26 +0000 http://www.jydba.net/?p=3375 修改InnoDB重做日志文件的数量或大小
修改你的InnoDB重做日志文件的数量或大小,请执行以下步骤:
1.停止MySQL服务器,并确保它没有错误地关闭

mysql> show variables like 'innodb_log_file%';
+---------------------------+----------+
| Variable_name             | Value    |
+---------------------------+----------+
| innodb_log_file_size      | 50331648 |
| innodb_log_files_in_group | 2        |
+---------------------------+----------+
2 rows in set (0.00 sec)


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

2.编辑my.cnf以更改日志文件配置。如果需要修改日志文件大小,请配置innodb_log_file_size。要增加日志文件的数量,可以配置

innodb_log_files_in_group。

[mysql@localhost mysql]$ vi my.cnf
....
innodb_log_file_size=100m
innodb_log_files_in_group=3

3.重新启动MySQL服务器
如果InnoDB检测到innodb_log_file_size大小与重做日志文件大小不同,它会写一个日志检查点,关闭并删除旧的日志文件,创建新的大小的志文件,并打开新的日志文件。

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


日志文件显示如下:

[mysql@localhost mysql]$ tail -f mysql.err
2022-03-02T02:44:15.775252Z 0 [Warning] Insecure configuration for --secure-file-priv: Current value does not restrict location of generated files. Consider setting it to a valid, non-empty path.
2022-03-02T02:44:15.775476Z 0 [Note] /mysqlsoft/mysql/bin/mysqld (mysqld 5.7.26-log) starting as process 613 ...
2022-03-02T02:44:15.787224Z 0 [Note] InnoDB: PUNCH HOLE support available
2022-03-02T02:44:15.787311Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2022-03-02T02:44:15.787376Z 0 [Note] InnoDB: Uses event mutexes
2022-03-02T02:44:15.787395Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2022-03-02T02:44:15.787411Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2022-03-02T02:44:15.788175Z 0 [Note] InnoDB: Number of pools: 1
2022-03-02T02:44:15.788515Z 0 [Note] InnoDB: Using CPU crc32 instructions
2022-03-02T02:44:15.793577Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2022-03-02T02:44:15.812360Z 0 [Note] InnoDB: Completed initialization of buffer pool
2022-03-02T02:44:15.817437Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
2022-03-02T02:44:15.862640Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
2022-03-02T02:44:16.043532Z 0 [Warning] InnoDB: Resizing redo log from 2*3072 to 3*6400 pages, LSN=2494312
2022-03-02T02:44:16.169341Z 0 [Warning] InnoDB: Starting to delete and rewrite log files.
2022-03-02T02:44:16.200462Z 0 [Note] InnoDB: Setting log file ./ib_logfile101 size to 100 MB
2022-03-02T02:44:16.200745Z 0 [Note] InnoDB: Progress in MB:
 100
2022-03-02T02:44:26.280622Z 0 [Note] InnoDB: Setting log file ./ib_logfile1 size to 100 MB
2022-03-02T02:44:26.281005Z 0 [Note] InnoDB: Progress in MB:
 100
2022-03-02T02:44:37.028157Z 0 [Note] InnoDB: Setting log file ./ib_logfile2 size to 100 MB
2022-03-02T02:44:37.029053Z 0 [Note] InnoDB: Progress in MB:
 100
2022-03-02T02:44:47.532468Z 0 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
2022-03-02T02:44:47.532675Z 0 [Warning] InnoDB: New log files created, LSN=2494312
2022-03-02T02:44:47.533502Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2022-03-02T02:44:47.533760Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2022-03-02T02:44:48.119249Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2022-03-02T02:44:48.121693Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
2022-03-02T02:44:48.121740Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
2022-03-02T02:44:48.122598Z 0 [Note] InnoDB: Waiting for purge to start
2022-03-02T02:44:48.172771Z 0 [Note] InnoDB: page_cleaner: 1000ms intended loop took 32356ms. The settings might not be optimal. (flushed=0 and evicted=0, during the time.)
2022-03-02T02:44:48.186082Z 0 [Note] InnoDB: 5.7.26 started; log sequence number 2494303
2022-03-02T02:44:48.186431Z 0 [Note] InnoDB: Loading buffer pool(s) from /mysqldata/mysql/ib_buffer_pool
2022-03-02T02:44:48.186776Z 0 [Note] Plugin 'FEDERATED' is disabled.
2022-03-02T02:44:48.366419Z 0 [Note] Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them.
2022-03-02T02:44:48.367248Z 0 [Warning] CA certificate ca.pem is self signed.
2022-03-02T02:44:48.369110Z 0 [Note] Server hostname (bind-address): '*'; port: 3306
2022-03-02T02:44:48.371083Z 0 [Note] IPv6 is available.
2022-03-02T02:44:48.371145Z 0 [Note]   - '::' resolves to '::';
2022-03-02T02:44:48.371213Z 0 [Note] Server socket created on IP: '::'.
2022-03-02T02:44:48.430720Z 0 [Note] InnoDB: Buffer pool(s) load completed at 220302 10:44:48
2022-03-02T02:44:48.434777Z 0 [Note] Failed to start slave threads for channel ''
2022-03-02T02:44:48.452218Z 0 [Note] Event Scheduler: Loaded 0 events
2022-03-02T02:44:48.452566Z 0 [Note] /mysqlsoft/mysql/bin/mysqld: ready for connections.
Version: '5.7.26-log'  socket: '/mysqlsoft/mysql/mysql.sock'  port: 3306  Source distribution

其中以下部分显示了服务器重置日志文件的大小与数量

2022-03-02T02:44:16.043532Z 0 [Warning] InnoDB: Resizing redo log from 2*3072 to 3*6400 pages, LSN=2494312
2022-03-02T02:44:16.169341Z 0 [Warning] InnoDB: Starting to delete and rewrite log files.
2022-03-02T02:44:16.200462Z 0 [Note] InnoDB: Setting log file ./ib_logfile101 size to 100 MB
2022-03-02T02:44:16.200745Z 0 [Note] InnoDB: Progress in MB:
 100
2022-03-02T02:44:26.280622Z 0 [Note] InnoDB: Setting log file ./ib_logfile1 size to 100 MB
2022-03-02T02:44:26.281005Z 0 [Note] InnoDB: Progress in MB:
 100
2022-03-02T02:44:37.028157Z 0 [Note] InnoDB: Setting log file ./ib_logfile2 size to 100 MB
2022-03-02T02:44:37.029053Z 0 [Note] InnoDB: Progress in MB:
 100
2022-03-02T02:44:47.532468Z 0 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
2022-03-02T02:44:47.532675Z 0 [Warning] InnoDB: New log files created, LSN=2494312


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

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

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

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

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

mysql> show variables like 'innodb_log_file%';
+---------------------------+-----------+
| Variable_name             | Value     |
+---------------------------+-----------+
| innodb_log_file_size      | 104857600 |
| innodb_log_files_in_group | 3         |
+---------------------------+-----------+
2 rows in set (0.01 sec)
]]>
http://www.jydba.net/index.php/archives/3375/feed 0
MySQL 减少InnoDB系统表空间的大小 http://www.jydba.net/index.php/archives/3373 http://www.jydba.net/index.php/archives/3373#respond Fri, 11 Mar 2022 00:51:45 +0000 http://www.jydba.net/?p=3373 减少InnoDB系统表空间的大小
不能从系统表空间中删除数据文件。若要减少系统表空间大小,请使用此过程:
1.使用mysqldump将所有的包括MySQL数据库中的InnoDB表dump出来,在5.6当前版本中,包括5张InnoDB表:

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

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

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

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

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

mysql> show variables like 'innodb_data%';
+-----------------------+------------------------------------+
| Variable_name         | Value                              |
+-----------------------+------------------------------------+
| innodb_data_file_path | ibdata1:76M;ibdata2:50M:autoextend |
| innodb_data_home_dir  |                                    |
+-----------------------+------------------------------------+
2 rows in set (0.01 sec)

mysql> SELECT TABLE_NAME from INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='mysql' and ENGINE='InnoDB';
+---------------------------+
| TABLE_NAME                |
+---------------------------+
| engine_cost               |
| gtid_executed             |
| help_category             |
| help_keyword              |
| help_relation             |
| help_topic                |
| innodb_index_stats        |
| innodb_table_stats        |
| plugin                    |
| server_cost               |
| servers                   |
| slave_master_info         |
| slave_relay_log_info      |
| slave_worker_info         |
| time_zone                 |
| time_zone_leap_second     |
| time_zone_name            |
| time_zone_transition      |
| time_zone_transition_type |
+---------------------------+
19 rows in set (0.00 sec)



[mysql@localhost ~]$ mysqldump  -uroot -pxxzx7817600 --all-databases > all_db_dump_20220223.sql
mysqldump: [Warning] Using a password on the command line interface can be insecure.

2.停止MySQL服务器

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

3.删除所有已经存在的表空间文件(*.ibd),包括ibdata和ib_log文件。不要忘记删除MySQL数据库中的*.ibd文件。

[mysql@localhost mysql]$ find ./mysql -name "*.ibd"
./mysql/plugin.ibd
./mysql/servers.ibd
./mysql/help_topic.ibd
./mysql/help_category.ibd
./mysql/help_relation.ibd
./mysql/help_keyword.ibd
./mysql/time_zone_name.ibd
./mysql/time_zone.ibd
./mysql/time_zone_transition.ibd
./mysql/time_zone_transition_type.ibd
./mysql/time_zone_leap_second.ibd
./mysql/innodb_table_stats.ibd
./mysql/innodb_index_stats.ibd
./mysql/slave_relay_log_info.ibd
./mysql/slave_master_info.ibd
./mysql/slave_worker_info.ibd
./mysql/gtid_executed.ibd
./mysql/server_cost.ibd
./mysql/engine_cost.ibd
[mysql@localhost mysql]$ find ./mysql -name "*.ibd"    | xargs -n 1 rm -f

[mysql@localhost mysql]$ rm -rf ibdata*
[mysql@localhost mysql]$ rm -rf ib_log*
[mysql@localhost mysql]$ ls -lrt ibdata*
ls: 无法访问ibdata*: 没有那个文件或目录
[mysql@localhost mysql]$ ls -lrt ib_log*
ls: 无法访问ib_log*: 没有那个文件或目录

4.删除InnoDB表的.frm文件

[mysql@localhost mysql]$ rm -rf mysql/plugin..frm
[mysql@localhost mysql]$ rm -rf mysql/servers..frm
[mysql@localhost mysql]$ rm -rf mysql/help_topic..frm
[mysql@localhost mysql]$ rm -rf mysql/help_category..frm
[mysql@localhost mysql]$ rm -rf mysql/help_relation.frm
[mysql@localhost mysql]$ rm -rf mysql/help_keyword.frm
[mysql@localhost mysql]$ rm -rf mysql/time_zone_name.frm
[mysql@localhost mysql]$ rm -rf mysql/time_zone.frm
[mysql@localhost mysql]$ rm -rf mysql/time_zone_transition.frm
[mysql@localhost mysql]$ rm -rf mysql/time_zone_transition_type.frm
[mysql@localhost mysql]$ rm -rf mysql/time_zone_leap_second.frm
[mysql@localhost mysql]$ rm -rf mysql/innodb_table_stats.frm
[mysql@localhost mysql]$ rm -rf mysql/innodb_index_stats.frm
[mysql@localhost mysql]$ rm -rf mysql/slave_relay_log_info.frm
[mysql@localhost mysql]$ rm -rf mysql/slave_master_info.frm
[mysql@localhost mysql]$ rm -rf mysql/slave_worker_info.frm
[mysql@localhost mysql]$ rm -rf mysql/gtid_executed.frm
[mysql@localhost mysql]$ rm -rf mysql/server_cost.frm
[mysql@localhost mysql]$ rm -rf mysql/engine_cost.frm

5.配置一个新表空间

[mysql@localhost mysql]$ vi my.cnf
.......
innodb_data_file_path = ibdata1:10M:autoextend

6.重启MySQL服务器

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

7.导入dump文件

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

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

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

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

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

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

mysql> show variables like 'innodb_data%';
+-----------------------+------------------------+
| Variable_name         | Value                  |
+-----------------------+------------------------+
| innodb_data_file_path | ibdata1:10M:autoextend |
| innodb_data_home_dir  |                        |
+-----------------------+------------------------+
2 rows in set (0.01 sec)

InnoDB系统表空间的文件变回原来的ibdata1了

mysql> SELECT TABLE_NAME from INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='mysql' and ENGINE='InnoDB';
+---------------------------+
| TABLE_NAME                |
+---------------------------+
| engine_cost               |
| gtid_executed             |
| help_category             |
| help_keyword              |
| help_relation             |
| help_topic                |
| innodb_index_stats        |
| innodb_table_stats        |
| plugin                    |
| server_cost               |
| servers                   |
| slave_master_info         |
| slave_relay_log_info      |
| slave_worker_info         |
| time_zone                 |
| time_zone_leap_second     |
| time_zone_name            |
| time_zone_transition      |
| time_zone_transition_type |
+---------------------------+
19 rows in set (0.01 sec)

注意:如果您的数据库只使用InnoDB引擎,那么可能更简单的方法是转储所有数据库,停止服务器,删除所有数据库和InnoDB日志文件,重新启动服务器,并导入转储文件。

]]>
http://www.jydba.net/index.php/archives/3373/feed 0
MySQL 增加InnoDB系统表空间大小 http://www.jydba.net/index.php/archives/3371 http://www.jydba.net/index.php/archives/3371#respond Fri, 11 Mar 2022 00:50:04 +0000 http://www.jydba.net/?p=3371 增加InnoDB系统表空间大小
增加InnoDB系统表空间大小的最简单的方法是从一开始就配置为自动扩展。在表空间定义中为最后一个数据文件指定autoextend属性。当InnoDB用完空间时,会自动增加64MB的文件大小。可以通过设置innodb_autoextend_increment系统变量的值来更改增量大小,该变量以兆字节为单位度量。

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

通过添加另一个数据文件,可以按定义的数量扩展系统表空间:
1.关闭MySQL服务器

2.如果上一个数据文件是用autoextend关键字定义的,那么根据它实际增长的大小,将其定义更改为使用固定大小。检查数据文件的大小,将其四舍四入到最接近的1024*1024字节(= 1MB)的倍数,并在innodb_data_file_path中显式指定这个四舍五入的大小。

3.在innodb_data_file_path的末尾添加一个新的数据文件,可以选择使该文件自动扩展。只有innodb_data_file_path中的最后一个数据文件可以被指定为自动扩展。

4.重新启动MySQL服务器。

例如,这个表空间只有一个自动扩展的数据文件ibdata1

mysql> show variables like 'innodb_data%';
+-----------------------+------------------------+
| Variable_name         | Value                  |
+-----------------------+------------------------+
| innodb_data_file_path | ibdata1:12M:autoextend |
| innodb_data_home_dir  |                        |
+-----------------------+------------------------+
2 rows in set (0.00 sec)

假设这个数据文件随着时间的推移增长到76MB。下面是修改原始数据文件以使用固定大小并添加新的自动扩展数据文件后的配置行

innodb_data_home_dir =
innodb_data_file_path =  ibdata1:76M;ibdata2:50M:autoextend

当您向系统表空间配置添加一个新的数据文件时,请确保文件名没有引用现有的文件。当您重启服务器时,InnoDB会创建并初始化该文件

a.关闭MySQL服务器

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

b.检查数据文件的大小

[mysql@localhost mysql]$ du -sh ibdata1
76M     ibdata1

c.在innodb_data_file_path的末尾添加一个新的数据文件,可以选择使该文件自动扩展。

innodb_data_file_path =  ibdata1:76M;ibdata2:50M:autoextend

d.重启MySQL服务器

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

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

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

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

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

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

mysql> show variables like 'innodb_data%';
+-----------------------+------------------------------------+
| Variable_name         | Value                              |
+-----------------------+------------------------------------+
| innodb_data_file_path | ibdata1:76M;ibdata2:50M:autoextend |
| innodb_data_home_dir  |                                    |
+-----------------------+------------------------------------+
2 rows in set (0.01 sec)

[root@localhost mysql]# ls -lrt ibdata*
-rw-r-----. 1 mysql mysql 52428800 2月  23 11:13 ibdata2
-rwxr-xr-x. 1 mysql mysql 79691776 2月  23 11:13 ibdata1
]]>
http://www.jydba.net/index.php/archives/3371/feed 0
MySQL 配置索引页的合并阈值 http://www.jydba.net/index.php/archives/3368 http://www.jydba.net/index.php/archives/3368#respond Fri, 11 Mar 2022 00:47:58 +0000 http://www.jydba.net/?p=3368 配置索引页的合并阈值
您可以为索引页配置MERGE_THRESHOLD值。如果一个索引页的“page-full”百分比低于MERGE_THRESHOLD值,当一个行被删除或当一个行被UPDATE 操作缩短时,InnoDB会尝试合并这个索引页和相邻的索引页。默认的MERGE_THRESHOLD值是50,这是以前的硬编码值。MERGE_THRESHOLD最小值为1,最大值为50。

当索引页的页满百分比低于50%(默认的MERGE_THRESHOLD设置)时,InnoDB会尝试将索引页与相邻页合并。如果两个页面都接近50%的满,那么在页面合并后不久就会发生页面分割。如果频繁发生这种合并-分割行为,则会对性能产生不利影响。为了避免频繁的合并分割,你可以降低MERGE_THRESHOLD值,这样InnoDB尝试页面合并的百分比就会降低。以较低的页满百分比合并页面会在索引页中留下更多的空间,并有助于减少合并-分割行为。

可以为一个表或单个索引定义索引页的MERGE_THRESHOLD。为单个索引定义的MERGE_THRESHOLD值优先于为表定义的MERGE_THRESHOLD值。如果未定义,MERGE_THRESHOLD值默认为50。

设置表的MERGE_THRESHOLD
可以使用CREATE TABLE语句的table_option COMMENT子句为一个表设置MERGE_THRESHOLD值。例如:

CREATE TABLE t1 (
id INT,
KEY id_index (id)
) COMMENT='MERGE_THRESHOLD=45';

还可以使用ALTER TABLE的table_option COMMENT子句为现有表设置MERGE_THRESHOLD值

CREATE TABLE t1 (
id INT,
KEY id_index (id)
);

ALTER TABLE t1 COMMENT='MERGE_THRESHOLD=40';

为单个索引设置MERGE_THRESHOLD
要为单个索引设置MERGE_THRESHOLD值,可以使用带有CREATE TABLE、ALTER TABLE或CREATE INDEX的index_option COMMENT子句,如下面的示例所示:
.使用CREATE TABLE为单个索引设置MERGE_THRESHOLD:

mysql> CREATE TABLE t1 (
    -> id INT,
    -> KEY id_index (id) COMMENT 'MERGE_THRESHOLD=40'
    -> );
Query OK, 0 rows affected (0.11 sec)

.使用ALTER TABLE为单个索引设置MERGE_THRESHOLD:

mysql> CREATE TABLE t1 (
    -> id INT,
    -> KEY id_index (id)
    -> );
ALTER TABLE t1 DROP KEY id_index;
ALTER TABLE t1 ADD KEY id_index (id) COMMENT 'MERGE_THRESHOLD=40';Query OK, 0 rows affected (0.17 sec)

mysql> ALTER TABLE t1 DROP KEY id_index;
Query OK, 0 rows affected (0.05 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql> ALTER TABLE t1 ADD KEY id_index (id) COMMENT 'MERGE_THRESHOLD=40';
Query OK, 0 rows affected (0.09 sec)
Records: 0  Duplicates: 0  Warnings: 0

使用CREATE INDEX为单个索引设置MERGE_THRESHOLD:

mysql> CREATE TABLE t1 (id INT);
Query OK, 0 rows affected (0.14 sec)

mysql> CREATE INDEX id_index ON t1 (id) COMMENT 'MERGE_THRESHOLD=40';
Query OK, 0 rows affected (0.11 sec)
Records: 0  Duplicates: 0  Warnings: 0

不能在索引级别修改GEN_CLUST_INDEX的MERGE_THRESHOLD值,GEN_CLUST_INDEX是InnoDB在创建InnoDB表时,在没有主键或唯一键索引的情况下创建的聚集索引。只能通过设置表的MERGE_THRESHOLD来修改GEN_CLUST_INDEX的MERGE_THRESHOLD值

查询索引的MERGE_THRESHOLD值
当前索引的MERGE_THRESHOLD值可以通过查询INNODB_SYS_INDEXES表获得。例如:

mysql> SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_INDEXES WHERE NAME='id_index' \G
*************************** 1. row ***************************
       INDEX_ID: 265
           NAME: id_index
       TABLE_ID: 267
           TYPE: 0
       N_FIELDS: 1
        PAGE_NO: 4
          SPACE: 269
MERGE_THRESHOLD: 40
1 row in set (0.00 sec)

如果使用table_option COMMENT子句显式定义,可以使用SHOW CREATE TABLE查看表的MERGE_THRESHOLD值

mysql> SHOW CREATE TABLE t1 \G
*************************** 1. row ***************************
       Table: t1
Create Table: CREATE TABLE `t1` (
  `id` int(11) DEFAULT NULL,
  KEY `id_index` (`id`) COMMENT 'MERGE_THRESHOLD=40'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4
1 row in set (0.00 sec)

在索引级别定义的MERGE_THRESHOLD值优先于为表定义的MERGE_THRESHOLD值。如果未定义,MERGE_THRESHOLD默认为50% (MERGE_THRESHOLD=50,这是以前的硬编码值。

同样,如果使用index_option COMMENT子句显式地定义,也可以使用SHOW INDEX查看索引的MERGE_THRESHOLD值:

mysql> show index from t1 \G
*************************** 1. row ***************************
        Table: t1
   Non_unique: 1
     Key_name: id_index
 Seq_in_index: 1
  Column_name: id
    Collation: A
  Cardinality: 0
     Sub_part: NULL
       Packed: NULL
         Null: YES
   Index_type: BTREE
      Comment:
Index_comment: MERGE_THRESHOLD=40
1 row in set (0.00 sec)

测量MERGE_THRESHOLD设置的效果:

INNODB_METRICS表提供了两个计数器,可以用来衡量MERGE_THRESHOLD设置对索引页合并的影响。

mysql> SELECT NAME, COMMENT FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE NAME like '%index_page_merge%';
+-----------------------------+----------------------------------------+
| NAME                        | COMMENT                                |
+-----------------------------+----------------------------------------+
| index_page_merge_attempts   | Number of index page merge attempts    |
| index_page_merge_successful | Number of successful index page merges |
+-----------------------------+----------------------------------------+
2 rows in set (0.00 sec)

当降低MERGE_THRESHOLD值时,目标是:
.页面合并尝试和成功合并的次数更少
.尝试合并和成功合并页面的次数相同

太小的MERGE_THRESHOLD设置由于大量的空页面空间导致大量的数据文件。

]]>
http://www.jydba.net/index.php/archives/3368/feed 0
MySQL 配置InnoDB配置非持久优化器统计信息参数 http://www.jydba.net/index.php/archives/3366 http://www.jydba.net/index.php/archives/3366#respond Fri, 11 Mar 2022 00:44:30 +0000 http://www.jydba.net/?p=3366 配置非持久优化器统计信息参数
本节介绍如何配置非持久优化器统计信息。当innodb_stats_persistent=OFF或使用STATS_PERSISTENT=0创建或修改单个表时,优化器统计信息不会被持久化到磁盘。相反,统计信息存储在内存中,并且在服务器关闭时丢失。统计数据还由某些操作在某些条件下定期更新。

从MySQL 5.6.6开始,默认情况下,优化器统计数据被持久化到磁盘上,由innodb_stats_persistent配置选项启用。

优化器数据更新
在以下情况出现时非持久化的优化器统计信息会被更新:
.执行analyze table

.运行show table status,show index,或者在innodb_stats_on_metadata选项被启用时查询information_schema.tables或information_schema.statistics表。

MySQL 5.6.6中,当持久化优化器统计信息被启用时,innodb_stats_on_metadata默认设置为OFF。启用innodb_stats_on_metadata可能会降低具有大量表或索引的模式的访问速度,并降低涉及InnoDB表的查询的执行计划的稳定性。innodb_stats_on_metadata使用SET语句全局配置。set global innodb_stats_on_metadata=ON

innodb_stats_on_metadata只适用于优化器统计信息配置为非持久化(当innodb_stats_persistent被禁用时)。

.启动mysql客户端时启用–auto-rehash选项,这是默认设置。auto-rehash选项会打开所有InnoDB表,打开表的操作会导致统计数据重新计算。为了提高mysql客户端的启动和更新统计信息时间,你可以使用–disable-auto-rehash选项关闭auto-rehash。自动auto-rehash特性允许交互用户自动完成数据库、表和列名的命名。

.表第一次打开。

.InnoDB检测到有1 / 16的表在上次统计数据更新后被修改。

配置采样页面数
MySQL查询优化器使用关于键分布的估计统计信息,根据索引的相对选择性为执行计划选择索引。当InnoDB更新优化器统计数据时,它会从表上的每个索引中随机取样,以估计索引的基数。(这种技术被称为随机潜水。)

为了控制统计信息评估的质量(从而为查询优化器提供更好的信息),可以使用参数innodb_stats_transient_sample_pages更改抽样页面的数量。默认的抽样页面数是8,这可能不足以产生准确的评估,导致查询优化器的索引选择很差。这种技术对于大型表和连接中使用的表尤其重要。对这样的表进行不必要的全表扫描可能会造成严重的性能问题。

当innodb_stats_transient_sample_pages =0时,innodb_stats_persistent的值会影响所有InnoDB表和索引的索引采样。当您更改索引样本大小时,请注意以下潜在的重大影响。
.小值像1或2可以导致不精确的基数评估

.增加innodb_stats_transient_sample_pages的值可能需要更多的磁盘读取。大于8(比如100)的值会导致打开表或执行SHOW table STATUS所需的时间显著放缓。

.优化器可能会根据索引选择性的不同估计选择非常不同的查询计划

无论innodb_stats_transient_sample_pages的值是什么,设置该选项并保持该值。选择一个值,它可以为数据库中的所有表提供合理准确的估计,而不需要过多的I/O。因为除了在执行ANALYZE TABLE时,统计数据会在其他时间自动重新计算,所以增加索引样本大小,运行ANALYZE TABLE,然后再次减少样本大小是没有意义的。

较小的表通常比较大的表需要更少的索引样本。如果你的数据库有很多大的表,考虑使用一个更大的innodb_stats_transient_sample_pages值。

评估InnoDB表analyze table的复杂度
InnoDB表的ANALYZE TABLE复杂度依赖于:
.采样的页面数,由innodb_stats_persistent_sample_pages定义

.表中索引列的数目

.分区数。如果表没有分区,则认为分区数为1。

使用这些参数,估计ANALYZE TABLE复杂度的近似公式是
innodb_stats_persistent_sample_pages的值*表中索引的列数*分区数

通常,结果值越大,ANALYZE TABLE的执行时间就越长

innodb_stats_persistent_sample_pages定义了在全局级别上采样的页面数量。要设置单个表的采样页数,请使用有STATS_SAMPLE_PAGES选项的CREATE TABLE或ALTER TABLE的语句。

如果innodb_stats_persistent=OFF,则由innodb_stats_transient_sample_pages定义采样的页面数

要了解估算ANALYZE TABLE复杂度的更深入的方法,请考虑以下示例:
在大O符号中,ANALYZE TABLE的复杂度被描述为:

O(n_sample
* (n_cols_in_uniq_i
+ n_cols_in_non_uniq_i
+ n_cols_in_pk * (1 + n_non_uniq_i))
* n_part)

.n_sample是采样的页面数(由innodb_stats_persistent_sample_pages定义)

.n_cols_in_uniq_i是所有唯一索引中所有列的总数(不计算主键列)

.n_cols_in_non_uniq_i是所有非唯一索引中所有列的总数

.n_cols_in_pk是主键中的列数(如果没有定义主键,InnoDB会在内部创建一个单列主键)

.n_non_uniq_i是表中非唯一索引的个数

.n_part是分区的数量。如果没有定义分区,则将表视为单个分区。

现在,考虑下面的表(表t),它有一个主键(2列)、一个唯一索引(2列)和两个非唯一索引(各有两列):

mysql> CREATE TABLE t (
    -> a INT,
    -> b INT,
    -> c INT,
    -> d INT,
    -> e INT,
    -> f INT,
    -> g INT,
    -> h INT,
    -> PRIMARY KEY (a, b),
    -> UNIQUE KEY i1uniq (c, d),
    -> KEY i2nonuniq (e, f),
    -> KEY i3nonuniq (g, h)
    -> );
Query OK, 0 rows affected (0.13 sec)

对于上述算法所需的列和索引数据,查询mysql.innodb_index_stats来查看表t的持久索引统计信息。n_diff_pfx%显示了每个索引列的统计信息。
例如,列a和列b用于计算主键索引。对于非唯一索引,除了用户定义的列外,还要统计主键列(a,b)。

mysql> select index_name, stat_name, stat_description
    -> from mysql.innodb_index_stats
    -> where
    -> database_name='mysql' and
    -> table_name='t' and
    -> stat_name like 'n_diff_pfx%';
+------------+--------------+------------------+
| index_name | stat_name    | stat_description |
+------------+--------------+------------------+
| PRIMARY    | n_diff_pfx01 | a                |
| PRIMARY    | n_diff_pfx02 | a,b              |
| i1uniq     | n_diff_pfx01 | c                |
| i1uniq     | n_diff_pfx02 | c,d              |
| i2nonuniq  | n_diff_pfx01 | e                |
| i2nonuniq  | n_diff_pfx02 | e,f              |
| i2nonuniq  | n_diff_pfx03 | e,f,a            |
| i2nonuniq  | n_diff_pfx04 | e,f,a,b          |
| i3nonuniq  | n_diff_pfx01 | g                |
| i3nonuniq  | n_diff_pfx02 | g,h              |
| i3nonuniq  | n_diff_pfx03 | g,h,a            |
| i3nonuniq  | n_diff_pfx04 | g,h,a,b          |
+------------+--------------+------------------+
12 rows in set (0.01 sec)

根据上面显示的索引统计数据和表定义,可以确定以下值:
.n_cols_in_uniq_i,不计算主键列的所有唯一索引中所有列的总数为2 (c和d)

.n_cols_in_non_uniq_i,所有非唯一索引中所有列的总数,为4 (e、f、g和h)

.n_cols_in_pk,主键中的列数是2(a和b)

.n_non_uniq_i,表中非唯一索引的数量为2 (i2nonuniq和i3nonuniq))

.n_part, 分区数,为1

现在可以计算innodb_stats_persistent_sample_pages *(2 + 4 + 2 *(1 + 2)) * 1来确定扫描的叶页数。如果将innodb_stats_persistent_sample_pages设置为默认值20,并将默认的页面大小设置为16 KiB (innodb_page_size=16384),那么你可以估计为表t读取20 * 12 * 16384字节,或者大约4 MiB。

所有4MiB可能不是从磁盘读取的,因为一些叶页可能已经缓存在缓冲池中。

]]>
http://www.jydba.net/index.php/archives/3366/feed 0
基于mysqld_multi实现MySQL 5.7.24多实例多进程配置 http://www.jydba.net/index.php/archives/3362 http://www.jydba.net/index.php/archives/3362#respond Tue, 22 Feb 2022 02:36:55 +0000 http://www.jydba.net/?p=3362 MySQL多实例的原理

mysql多实例,简单理解就是在一台服务器上,mysql服务开启多个不同的端口(如3306、3307、3308)运行多个服务进程。这些 mysql 服务进程通过不同的 socket来监听不同的数据端口,进而互不干涉的提供各自的服务。

在同一台服务器上,mysql 多实例会去共用一套 mysql 应用程序,因此你在部署 mysql 的时候只需要部署一次mysql程序即可,无需多次部署。但是,mysql多实例之间会各自使用不同的 my.cnf配置文件、启动程序和数据文件。在提供服务方面,mysql多实例在逻辑上看起来是各自独立,互不干涉的,并且多个实例之间是根据配置文件的设定值,来获取相关服务器的硬件资源。

优点如下:

有效利用服务器资源
当单个服务器资源过剩时,可以充分利用剩余的资源来提供更多的服务
节约服务器资源
当公司资金紧张,但数据库又需要数据库之间各自提供服务时,并且还想使用主从同步等技术,此时多实例就再好不过了
方便后期架构扩展
当公司的某个项目才启动时,启动初期并不一定有很大的用户量,因此可以先用一组物理数据库服务器,在上面部署多个实例,方便后续架构扩展、迁移

缺点如下:
资源互相抢占问题
当某个服务实例并发很高或者有慢查询时,整个实例会消耗更多的内存、CPU和IO资源,这将导致服务器上的其它实例提供服务的质量下降
mysql 多实例在生产环境下的应用场景!

当一个公司业务访问量不太大,又想节俭成本,并且还希望不同业务的数据库服务能够各自尽量独立,提供服务能够互相不受影响。另外还需要应用主从同步等技术来提供数据库备份或读写分离服务,以及方便后期业务量增大时,数据库架构的扩展和迁移。此时,Mysql 多实例就再好不过了。比如,我们可以通过在 3 台服务器部署 6-9 个实例,然后交叉做主从同步备份及读写分离,来实现 6-9 台服务器才能够达到的效果

公司业务访问量不是太大的时候,服务器的资源基本都是过剩状态。此时就很适合 mysql 多实例的应用。如果对 SQL语句优化做的比较好,mysql 多实例是一个很值得去使用的技术。即使后期业务并发很大,只要合理分配好系统资源,也不会有太大的问题

为了规避 mysql 对 SMP 架构不支持的缺陷,我们可以使用 mysql 多实例绑定处理器的办法(NUMA处理器必须支持,不过现在大部分处理器都支持的)将不同的数据库分配到不同的实例上提供数据服务;

传统游戏行业的 MMO/MMORPG以及Web Game,会将每个服都对应一个数据库,而且可能经常要做很多数据查询和数据订正工作。此时,为了减少维护而出错的概率,我们也可以采用多实例的部署方式,按区的概念来分配数据库。

Mysql多实例实现的3种方式

1、基于多配置文件

通过使用多个配置文件来启动不同的进程,以此来实现多实例。

优点:逻辑简单,配置简单

缺点:管理起来不方便

2、基于mysqld_multi
通过官方自带的 mysqld_multi 工具,使用单独配置文件来实现多实例

优点: 便于集中管理管理

缺点: 不方便针对每个实例配置进行定制

3、基于IM
使用 MySQL 实例管理器(MYSQLMANAGER),这个方法好像比较好不过也有点复杂

优点:便于集中管理

缺点:耦合度高。IM一挂,实例全挂/
不方便针对每个实例配置进行定制

MySQL本身就可以通过多实例方式运行,只要修改启动脚本和配置文件,把端口、basedir、datadir 文件夹分开后,多个实例的运行就会互不影响。但是这种方式操作起来太过繁杂,所以MySQL官方提供了一个mysqld_multi 的程序来辅助实现多实例操作。

一、创建并初始化数据目录
几个实例要分开运行,必然要把数据库文件放到不同目录中,所以第一步是要建立各个实例的数据目录,这里假设我们要运行三个实例,端口分别是3306,3307,3308,为了方便维护,我们把数据文件夹也按照端口号来命名:

[root@localhost ~]# mkdir -p /data/mysql/{3306,3307,3308}
[root@localhost ~]# chown mysql:mysql /data/mysql/{3306,3307,3308}
[root@localhost ~]# ls -ld /data/mysql/{3306,3307,3308}
drwxr-xr-x 2 mysql mysql 6 12月  7 16:37 /data/mysql/3306
drwxr-xr-x 2 mysql mysql 6 12月  7 16:37 /data/mysql/3307
drwxr-xr-x 2 mysql mysql 6 12月  7 16:37 /data/mysql/3308

通过配置文件指定并初始化数据目录

[root@localhost ~]# cp /etc/my.cnf /data/mysql/3308.cnf
[root@localhost ~]# vim /data/mysql/3308.cnf
[mysqld]
port=3308
datadir=/data/mysql/3308/
socket=/tmp/mysql3308.sock
symbolic-links=0

[mysqld_safe]
log-error=/data/mysql/3308.log
pid-file=/usr/local/mysql/data/3308.pid

[client]
port=3308
socket=/tmp/mysql3308.sock

[root@localhost ~]# mysqld --defaults-file=/data/mysql/3308.cnf --initialize-insecure --user=mysql

初始化完成之后,后续的配置不需要3308.cnf文件,实例的参数会在my.cnf中集中配置。注意,data目录在初始化前,必须为空,不然初始化是会报错

重复上面两个步骤,把3307、3306目录初始化好。

[root@localhost ~]# cat /data/mysql/3306.cnf
[mysqld]
port=3306
datadir=/data/mysql/3306/
socket=/tmp/mysql3306.sock
symbolic-links=0

[mysqld_safe]
log-error=/data/mysql/3306.log
pid-file=/usr/local/mysql/data/3306.pid

[client]
port=3306
socket=/tmp/mysql3306.sock
[root@localhost ~]# cat /data/mysql/3307.cnf
[mysqld]
port=3307
datadir=/data/mysql/3307/
socket=/tmp/mysql3307.sock
symbolic-links=0

[mysqld_safe]
log-error=/data/mysql/3307.log
pid-file=/usr/local/mysql/data/3307.pid

[client]
port=3307
socket=/tmp/mysql3307.sock
[root@localhost ~]# mysqld --defaults-file=/data/mysql/3307.cnf --initialize-insecure --user=mysql
[root@localhost ~]# mysqld --defaults-file=/data/mysql/3306.cnf --initialize-insecure --user=mysql

二、配置my.cnf文件集中管理多个实例

[root@localhost ~]# cp /etc/my.cnf /etc/my.cnf.bak
[root@localhost ~]# vim /etc/my.cnf
[mysqld_multi]
mysqld=/usr/local/mysql/bin/mysqld_safe
mysqladmin=/usr/local/mysql/bin/mysqladmin

[mysqld1]
port=3306
socket=/tmp/mysql3306.sock
datadir=/data/mysql/3306/
skip-external-locking
log-bin=/data/mysql/3306/mysql-bin
server-id=3306
user=mysql

[mysqld2]
port=3307
socket=/tmp/mysql3307.sock
datadir=/data/mysql/3307/
skip-external-locking
log-bin=/data/mysql/3307/mysql-bin
server-id=3307
user=mysql

[mysqld3]
port=3308
socket=/tmp/mysql3308.sock
datadir=/data/mysql/3308/
skip-external-locking
log-bin=/data/mysql/3308/mysql-bin
server-id=3308
user=mysql

[mysql]
no-auto-rehash

mysqld_multi的配置文件和一般MySQL配置不同,没有[mysqld]段,取而代之的是[mysqld1]、[mysqld2]等配置段,每个配置段代表一个MySQL实例。

三、管理多个MySQL实例
1,启动多个MySQL实例
启动多个实例时需要一个启动脚本,这个脚本一般在/usr/local/mysql/support-files目录下的mysqld_multi.server文件

[root@localhost ~]# cp /usr/local/mysql/support-files/mysqld_multi.server /etc/init.d/mysqld_multi

启动多个MySQL实例

[root@localhost ~]# /etc/init.d/mysqld_multi start 1-3

启动三个MySQL实例,注意这里的数字和my.cnf中的[mysqldN]对应,1-3就是启动[mysqld1]、[mysqld2]、[mysqld3]配置段的MySQL实例。

[root@localhost ~]# netstat -lnpt | grep -E "3306|3307|3308"
tcp6       0      0 :::3306                 :::*                    LISTEN      2744/mysqld
tcp6       0      0 :::3307                 :::*                    LISTEN      65502/mysqld
tcp6       0      0 :::3308                 :::*                    LISTEN      65499/mysqld

查看端口,看MySQL有没有正常启动,如果没有启动或报错,一般报错详细日志存在各个实例data目录下的主机名.err文件中,打开此文件查找错误原因,逐步排错就可以了。

2,关闭多个MySQL实例

[root@localhost ~]# /etc/init.d/mysqld_multi stop 1-3
[root@localhost ~]# netstat -lnpt | grep -E "3306|3307|3308"

也可以使用以下命令:

killall -u mysql 或者 kill -9 the-mysql-pid

四、root账户管理
前面初始化数据库时用的是–initialize-insecure参数,所以我们初始化的数据库,root账户是没有密码的,要先改密码为123456:

mysqladmin -uroot password '123456' -S /tmp/mysql3306.sock
mysqladmin -uroot password '123456' -S /tmp/mysql3307.sock
mysqladmin -uroot password '123456' -S /tmp/mysql3308.sock

或者:

mysqladmin -uroot password '123456' -P3306 -h127.0.0.1
mysqladmin -uroot password '123456' -P3307 -h127.0.0.1
mysqladmin -uroot password '123456' -P3308 -h127.0.0.1

五、连接mysql多实例:

[root@localhost ~]# mysql -u root -p123456 -S /tmp/mysql3306.sock
[root@localhost ~]# mysql -u root -p123456 -S /tmp/mysql3307.sock
[root@localhost ~]# mysql -u root -p123456 -S /tmp/mysql3308.sock
]]>
http://www.jydba.net/index.php/archives/3362/feed 0
mysqldump 数据库备份程序 http://www.jydba.net/index.php/archives/3360 http://www.jydba.net/index.php/archives/3360#respond Tue, 22 Feb 2022 02:32:01 +0000 http://www.jydba.net/?p=3360 mysqldump 数据库备份程序
mysqldump客户端工具执行逻辑备份,生成一组SQL语句可以用来执行重新创建原数据库对象定义和表数据。它dumps一个或多个MySQL数据库的备份或者传输到另外的服务器。mysqldump命令也可以生成CSV或,其它文本或XML格式的输出

mysqldump的优点是在还原之前它可以方便与灵活的查看或者编辑输出。可以克隆数据库来给开发人员和DBA使用,或者提供测试环境。它并不是一种用来备份大量数据的快速或可扩展的方案。使用大数据大小,即使备份操作花费的时间合理,但还原数据可能非常缓慢因为重放SQL语句调用磁盘I/O来执行插入操作,索引创建等等。

对于大规模的备份和还原,物理备份更合适,可以以它们的原有格式来复制数据文件来快速完成还原操作:
.如果你的表主要是InnoDB表,或者如果你有一种混合的InnoDB与MyISAM表,可以考虑MySQL企业级备份产品的mysqlbackup命令。它为InnoDB备份提供了最好的性能并且破坏性最小,它也可以从MyISAM和其它存储引擎中备份数据表,并且它提供了许多不同的选项来适应不同的备份场景。

mysqldump可以逐行检索和dump表的内容或者它可以在dump它之前从一个表与内存的缓存中来检索整个内容。如果dump一个大表从内存中的缓存中检索可能是一个问题。为了逐行dump表,使用–quick选项(或–opt,它启用–quick)–opt选项(因此–quick)缺省被启用,因此启用内存缓存,使用–skip-quick选项.

如果使用一个最近版本的mysqldump来生成一个dump被加载到一个旧版本的MySQL服务器中,使用–skip-opt选项来代替–extended-insert选项。

有三种常用方式来使用mysqldump命令来完成对一个或多个表,一个或多个数据库,或整个MySQL服务器来进行dump:

shell> mysqldump [options] db_name [tbl_name ...]
shell> mysqldump [options] --databases db_name ...
shell> mysqldump [options] --all-databases

为了dump整个数据库,在db_name后面不要接任何表名,或者使用–database或–all-databases选项。

mysqldump支持以下选项,它可以在命令行或在选项文件中的[mysqldump]与[client]组中进行指定。

mysqldump选项:
–add-drop-database 在每个create database语句之前加上drop database语句

–add-drop-table 在每个create table语句之前加上drop table语句

–add-drop-trigger 在每个create trigger语句之前加上drop table语句

–add-locks 使用lock tables与unlock tables语句来包围每个表的dump

–all-databases dump所有数据库中的所有表

–allow-keywords 允许创建关键字列名

–apply-slave-statements 在change master语句之前包含stop slave,在结束输出之前包含start slave

–bind-address 使用特定的网络接口来连接MySQL服务器

–character-sets-dir 安装字符集的目录

–comments 添加注释到dump文件中

–compact 产生更紧凑的输出

–compatible 产生的输出将与其它的数据库系统或者旧版本的MySQL服务器更兼容

–complete-insert 使用完整的insert语句包括列名

–compress 对在客户端和服务器之间发送的所有信息进行压缩

–create-options 在create table语句中包含所有的MySQL特定的表选项

–databases 将所有的命名参数解释为数据库名

–debug 写调试日志

–debug-check 当程序退出时打印调试信息

–debug-info 当程序退出时打印调试信息,内存与CPU统计信息

–default-auth 要使用的身份认证插件

–default-character-set 指定的缺省字符集

–default-extra-file 除了常用的选项文件外还要读取的选项文件

–default-file 只读指定的选项文件

–default-group-suffix 选项组后缀值

–delete-master-logs 在一个主复制服务器上,在执行dump操作后删除binary日志文件

–disable-keys 对于每个表,围绕insert语句使用语句来禁用与启用关键字

–dump-date 如果–comments被指定,包含dump日期作为”Dump completed on”注释

–dump-slave 包含change master语句来列出slave’s master相关的二进制日志

–enable-cleartext-plugin 使用cleartext身份认证插件

–events 来自转储数据库的转储事件

–extended-insert 使用多行插入语法

–fields-enclosed-by 这个选项与–tab选项一起使用并且与load data infile相关子句有相同的意思

–fields-escaped-by 这个选项与–tab选项一起使用并且与load data infile相关子句有相同的意思

–fields-optionally-enclosed-by 这个选项与–tab选项一起使用并且与load data infile相关子句有相同的意思。

–fields-terminated-by 这个选项与–tab选项一起使用并且与load data infile相关子句有相同的意思

–flush-logs 在开始dump之前清空MySQL服务器的日志文件

–flush-privileges 在dump MySQL数据库后发布一个flush privileges语句。

–force 在一个表被dump时即使出现错误也会继续

–help 显示帮助信息并退出

–hex-blob 使用十六进制表示法来dump二进制列

–host 要连接的主机(IP地址或主机名)

–ignore-error 忽略特定的错误信息

–ignore-table 不dump指定的表

–include-master-host-port 在使用–dump-slave生成的change master语句中包含master_host/master_port选项

–insert-ignore 写insert ignore而不是insert语句

–lines-terminated-by 这个选项与–tab选项一起使用并且有与load data infile相关子句相同的意思

–lock-all-tables 跨所有数据库锁定所有表

–lock-tables 在dump他们之前锁定所有表

–log-error 将警告与错误追加到指定文件

–master-data 输出所写入的二进制日志文件名与位置

–max_allowed_packet 发送到到服务器或从服务器接收到的最大包长度

-net_buffer_length TCP/IP与socket通信的缓冲大小

–no-autocommit 对于每个dump表的insert语句包含了set autocommit=0与commit语句

–no-create-db 不写create database语句

–no-create-info 对于重建的每个dump表不写create table语句

–no-data 不dump表的内容

–no-defaults 不读取选项文件

–no-set-names 与–skip-set-charset相同

–no-tablespaces 在输出中不写入任何create logfile group或create tablespace语句

–opt 对于–add-drop-table –add-locks –create-options –disable-kyes –extended-insert –lock-tables –quick –sset-charset的速记法

–order-by-primary 通过主键或它的第一个唯一索引排序来dump每个表的行记录

–password 当连接服务器时使用的密码

–pipe 在Windows上,使用命名管道连接服务器

–plugin-dir 插件被安装的目录

–port 用于连接的TCP/IP端口号

–print-defaults 打印缺省选项

–protocol 使用的连接协议

–quick 从服务器中一次一行地检索数据

–quote-names 引号内的标识符

–replace 写replace语句而不是insert语句

–result-file 指示输出到指定文件

–routines 从被dump的数据库中dump存储程序(过程与函数)

–secure-auth 不使用旧格式发送密码到服务器

–set-charset 添加set names default_character_set到输出中

–set-gtid-purged 是否向输出添加set @@global.gtid_purged

–shared-memory-base-name 用于共享内存连接的共享内存名

–single-transaction 在从服务器dump数据之前执行begin sql语句

–skip-add-drop-table 在每个create table语句之前不添加drop table语句

–skip-add-locks 不添加锁

–skip-comments 不添加注释到dump文件

–skip-compact 不产生更多紧凑输出

–skip-disable-keys 不禁用关键字

–skip-extended-insert 关闭扩展插入

–skip-opt 关闭–opt选项集

–skip-quick 不从服务器一次一行地检索表的行

–skip-quote-names 不要引用标识符

–skip-set-charset 不写set names语句

–skip-triggers 不dump触发器

–skip-tz-utc 关闭tz-utc

–socket 对于本地连接,使用的Unix socket文件

–ssl 启用加密连接

–ssl-ca 包含可信SSL CA列表的文件路径

–ssl-capath 包含PEM格式可信SSL CA认证的目录路径

–ssl-cert 包含PEM格式X509认证的文件路径

–ssl-cipher 用于连接加密的允许密码列表

–ssl-crl 包含证书撤销列表的文件路径

–ssl-crlpath 包含证书撤销列表文件的目录的路径

–ssl-key 包含PEM格式的X509 钥匙的文件路径

–ssl-mode 连接服务器的安全状态

–ssl-verify-server-cert 根据连接到服务器时使用的主机名验证服务器证书公共名称值

–tab 生成用制表符分隔的数据文件

–tables 覆盖–database或-B选项

–tls-version 对于加密连接允许的连接协议

–triggers 对于每个被dump的表dump触发器

–tz-utc 添加set time_zone=’+00:00’到dump文件

–user 连接服务器时所使用的用户名

–verbose 详细模式

–version 显示版本信息并退出

–where 通过指定where条件只dump所选择的行

–xml 生成XML输出

1、备份命令
格式:mysqldump -h主机名 -P端口 -u用户名 -p密码 –database 数据库名 > 文件名.sql

例如: mysqldump -h 192.168.1.100 -p 3306 -uroot -ppassword --database cmdb > /data/backup/cmdb.sql

2、备份压缩
导出的数据有可能比较大,不好备份到远程,这时候就需要进行压缩
格式:mysqldump -h主机名 -P端口 -u用户名 -p密码 –database 数据库名 | gzip > 文件名.sql.gz

例如: mysqldump -h192.168.1.100 -p 3306 -uroot -ppassword --database cmdb | gzip > /data/backup/cmdb.sql.gz

3、备份同个库多个表
格式:mysqldump -h主机名 -P端口 -u用户名 -p密码 –database 数据库名 表1 表2 …. > 文件名.sql

例如 mysqldump -h192.168.1.100 -p3306 -uroot -ppassword cmdb t1 t2 > /data/backup/cmdb_t1_t2.sql

4、同时备份多个库
格式:mysqldump -h主机名 -P端口 -u用户名 -p密码 –databases 数据库名1 数据库名2 数据库名3 > 文件名.sql

例如:mysqldump -h192.168.1.100 -uroot -ppassword --databases cmdb bbs blog > /data/backup/mutil_db.sql

5、备份实例上所有的数据库
格式:mysqldump -h主机名 -P端口 -u用户名 -p密码 –all-databases > 文件名.sql

例如:mysqldump -h192.168.1.100 -p3306 -uroot -ppassword --all-databases > /data/backup/all_db.sql

6、备份数据出带删除数据库或者表的sql备份
格式:mysqldump -h主机名 -P端口 -u用户名 -p密码 –add-drop-table –add-drop-database 数据库名 > 文件名.sql

例如:mysqldump -uroot -ppassword --add-drop-table --add-drop-database cmdb > /data/backup/all_db.sql

7、备份数据库结构,不备份数据
格式:mysqldump -h主机名 -P端口 -u用户名 -p密码 –no-data 数据库名1 数据库名2 数据库名3 > 文件名.sql

例如:mysqldump --no-data –databases db1 db2 cmdb > /data/backup/structure.sql
]]>
http://www.jydba.net/index.php/archives/3360/feed 0
mysqlimport 数据导入程序 http://www.jydba.net/index.php/archives/3358 http://www.jydba.net/index.php/archives/3358#respond Tue, 22 Feb 2022 02:28:48 +0000 http://www.jydba.net/?p=3358 mysqlimport 数据导入程序
mysqlimport客户端提供了一个命令行接口来执行load data infile SQL语句。大多数的mysqlimport直接与load data infile语法的子句相关。

其使用语法为:

shell>mysqlimport [options] db_name textfile1 [textfile2 ...]


mysql -e 'create table imptest(id int,n varchar(30))'  mysql


[mysql@localhost ~]$ mysql -uroot -pxxzx7817600 -e 'create table imptest(id int,n varchar(30))'  mysql
mysql: [Warning] Using a password on the command line interface can be insecure.

[mysql@localhost ~]$ vi imptest.txt
100 Max Sydow
101 Count Dracula

[mysql@localhost ~]$ od -c imptest.txt
0000000   1   0   0       M   a   x       S   y   d   o   w  \n   1   0
0000020   1       C   o   u   n   t       D   r   a   c   u   l   a  \n
0000040

[mysql@localhost ~]$ mysqlimport --local mysql imptest.txt -uroot -pxxzx7817600  --fields-terminated-by="|"
mysqlimport: [Warning] Using a password on the command line interface can be insecure.
mysql.imptest: Records: 2  Deleted: 0  Skipped: 0  Warnings: 0


[mysql@localhost ~]$ mysql -uroot -pxxzx7817600 -e 'SELECT * FROM imptest' mysql
mysql: [Warning] Using a password on the command line interface can be insecure.
+------+---------------+
| id   | n             |
+------+---------------+
|  100 | Max Sydow     |
|  101 | Count Dracula |
+------+---------------+

[mysql@localhost ~]$ mysqlimport --help
mysqlimport  Ver 3.7 Distrib 5.7.26, for Linux (x86_64)
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.

Loads tables from text files in various formats.  The base name of the
text file must be the name of the table that should be used.
If one uses sockets to connect to the MySQL server, the server will open and
read the text file directly. In other cases the client will open the text
file. The SQL command 'LOAD DATA INFILE' is used to import the rows.

Usage: mysqlimport [OPTIONS] database textfile...
Default options are read from the following files in the given order:
/etc/my.cnf /etc/mysql/my.cnf /mysqlsoft/mysql/etc/my.cnf /mysqlsoft/mysql/my.cnf ~/.my.cnf
The following groups are read: mysqlimport client
The following options may be given as the first argument:
--print-defaults        Print the program argument list and exit.
--no-defaults           Don't read default options from any option file,
                        except for login file.
--defaults-file=#       Only read default options from the given file #.
--defaults-extra-file=# Read this file after the global files are read.
--defaults-group-suffix=#
                        Also read groups with concat(group, suffix)
--login-path=#          Read this path from the login file.
  --bind-address=name IP address to bind to.
  --character-sets-dir=name
                      Directory for character set files.
  --default-character-set=name
                      Set the default character set.
  -c, --columns=name  Use only these columns to import the data to. Give the
                      column names in a comma separated list. This is same as
                      giving columns to LOAD DATA INFILE.
  -C, --compress      Use compression in server/client protocol.
  -#, --debug[=#]     This is a non-debug version. Catch this and exit.
  --debug-check       This is a non-debug version. Catch this and exit.
  --debug-info        This is a non-debug version. Catch this and exit.
  --default-auth=name Default authentication client-side plugin to use.
  -d, --delete        First delete all rows from table.
  --enable-cleartext-plugin
                      Enable/disable the clear text authentication plugin.
  --fields-terminated-by=name
                      Fields in the input file are terminated by the given
                      string.
  --fields-enclosed-by=name
                      Fields in the import file are enclosed by the given
                      character.
  --fields-optionally-enclosed-by=name
                      Fields in the input file are optionally enclosed by the
                      given character.
  --fields-escaped-by=name
                      Fields in the input file are escaped by the given
                      character.
  -f, --force         Continue even if we get an SQL error.
  -?, --help          Displays this help and exits.
  -h, --host=name     Connect to host.
  -i, --ignore        If duplicate unique key was found, keep old row.
  --ignore-lines=#    Ignore first n lines of data infile.
  --lines-terminated-by=name
                      Lines in the input file are terminated by the given
                      string.
  -L, --local         Read all files through the client.
  -l, --lock-tables   Lock all tables for write (this disables threads).
  --low-priority      Use LOW_PRIORITY when updating the table.
  -p, --password[=name]
                      Password to use when connecting to server. If password is
                      not given it's asked from the tty.
  --plugin-dir=name   Directory for client-side plugins.
  -P, --port=#        Port number to use for connection or 0 for default to, in
                      order of preference, my.cnf, $MYSQL_TCP_PORT,
                      /etc/services, built-in default (3306).
  --protocol=name     The protocol to use for connection (tcp, socket, pipe,
                      memory).
  -r, --replace       If duplicate unique key was found, replace old row.
  --secure-auth       Refuse client connecting to server if it uses old
                      (pre-4.1.1) protocol. Deprecated. Always TRUE
  -s, --silent        Be more silent.
  -S, --socket=name   The socket file to use for connection.
  --ssl-mode=name     SSL connection mode.
  --ssl               Deprecated. Use --ssl-mode instead.
                      (Defaults to on; use --skip-ssl to disable.)
  --ssl-verify-server-cert
                      Deprecated. Use --ssl-mode=VERIFY_IDENTITY instead.
  --ssl-ca=name       CA file in PEM format.
  --ssl-capath=name   CA directory.
  --ssl-cert=name     X509 cert in PEM format.
  --ssl-cipher=name   SSL cipher to use.
  --ssl-key=name      X509 key in PEM format.
  --ssl-crl=name      Certificate revocation list.
  --ssl-crlpath=name  Certificate revocation list path.
  --tls-version=name  TLS version to use, permitted values are: TLSv1, TLSv1.1
  --use-threads=#     Load files in parallel. The argument is the number of
                      threads to use for loading data.
  -u, --user=name     User for login if not current user.
  -v, --verbose       Print info about the various stages.
  -V, --version       Output version information and exit.

Variables (--variable-name=value)
and boolean options {FALSE|TRUE}  Value (after reading options)
--------------------------------- ----------------------------------------
bind-address                      (No default value)
character-sets-dir                (No default value)
default-character-set             auto
columns                           (No default value)
compress                          FALSE
default-auth                      (No default value)
delete                            FALSE
enable-cleartext-plugin           FALSE
fields-terminated-by              (No default value)
fields-enclosed-by                (No default value)
fields-optionally-enclosed-by     (No default value)
fields-escaped-by                 (No default value)
force                             FALSE
host                              (No default value)
ignore                            FALSE
ignore-lines                      0
lines-terminated-by               (No default value)
local                             FALSE
lock-tables                       FALSE
low-priority                      FALSE
plugin-dir                        (No default value)
port                              0
replace                           FALSE
secure-auth                       TRUE
silent                            FALSE
socket                            (No default value)
ssl                               TRUE
ssl-verify-server-cert            FALSE
ssl-ca                            (No default value)
ssl-capath                        (No default value)
ssl-cert                          (No default value)
ssl-cipher                        (No default value)
ssl-key                           (No default value)
ssl-crl                           (No default value)
ssl-crlpath                       (No default value)
tls-version                       (No default value)
use-threads                       0
user                              (No default value)
verbose                           FALSE
]]>
http://www.jydba.net/index.php/archives/3358/feed 0
mysqlpump 数据库备份程序 http://www.jydba.net/index.php/archives/3356 http://www.jydba.net/index.php/archives/3356#respond Tue, 22 Feb 2022 02:27:31 +0000 http://www.jydba.net/?p=3356 mysqlpump工具执行逻辑备份,生成一组SQL语句集可以被用来执行重建源数据库对象定义和表数据。它将dump一个或多个MySQL数据库备份或者传输到另一个MySQL服务器。

mysqlpump有以下功能:
.并行处理数据库和数据库对象,提高dump速度。

.更好地控制那个数据库和数据库对象(表,存储过程,用户账号)将被dump。

.创建压缩输出

.进程指示器

.对于dump文件重新加载,通过在行数据插入后通过添加索引可以为InnoDB表快速的创建第二索引

缺省情况下,mysqlpump会dump所有数据库。为了显性指定其行为,使用–all-databases选项

shell>mysqlpump --all-databases

为了dump单个数据库,或数据库中特定的表,在命令行中指定数据库名,紧接着指定表名:

shell>mysqlpump db_name

shell>mysqlpump db_name tab_name1 tab_name2 ...

为了将所有的命名参数作为数据库名,使用–databases选项

shell>mysqlpump --databases db_name1 db_name2 ...

缺省情况下,mysqlpump不会dump用户账号定义,即使你dump了mysql系统数据库包含了授权表。为了dump授权表内容以逻辑格式的形式create user和grant语句输出,使用–users选项并压制所有数据库的dump:

shell>mysqlpump --exclude-databases=%  --users

上面命令中的%是一个通配符对于–exclude-databases选项来匹配所有数据库的名字.

为了重加一个dump文件,执行它所包含的语句。例如,使用mysql工具

[mysql@localhost ~]$ mysqlpump --host=192.168.1.250 --port=33306 -uroot -p123456 mysql imptest >imptest_dump.sql
mysqlpump: [Warning] Using a password on the command line interface can be insecure.
Dump progress: 1/1 tables, 0/2 rows
Dump completed in 1259 milliseconds
[mysql@localhost ~]$ ls -lrt
总用量 3532
drwxrwxr-x. 2 mysql mysql       6 9月   6 13:03 perl5
-rw-r--r--. 1 mysql mysql 3605196 10月 21 17:27 backup.sql
-rw-r--r--. 1 mysql mysql      32 10月 28 11:46 imptest.txt
-rw-r--r--. 1 mysql mysql    1253 10月 29 14:49 imptest_dump.sql
[mysql@localhost ~]$ cat imptest_dump.sql
-- Dump created by MySQL pump utility, version: 5.7.26, Linux (x86_64)
-- Dump start time: Tue Oct 29 14:49:10 2019
-- Server version: 5.7.26

SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE;
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
SET @@SESSION.SQL_LOG_BIN= 0;
SET @OLD_TIME_ZONE=@@TIME_ZONE;
SET TIME_ZONE='+00:00';
SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT;
SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS;
SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION;
SET NAMES utf8mb4;
CREATE DATABASE /*!32312 IF NOT EXISTS*/ `mysql` /*!40100 DEFAULT CHARACTER SET latin1 */;
CREATE TABLE `mysql`.`imptest` (
`id` int(11) DEFAULT NULL,
`n` varchar(30) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1
;
INSERT INTO `mysql`.`imptest` VALUES (100,"Max Sydow"),(101,"Count Dracula");
SET TIME_ZONE=@OLD_TIME_ZONE;
SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT;
SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS;
SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
SET SQL_MODE=@OLD_SQL_MODE;
-- Dump end time: Tue Oct 29 14:49:11 2019


[mysql@localhost ~]$ mysql --host=192.168.1.250 --port=33306 -uroot -p123456 mysql 

]]> http://www.jydba.net/index.php/archives/3356/feed 0 mysqlslap 负载模拟客户端 http://www.jydba.net/index.php/archives/3354 http://www.jydba.net/index.php/archives/3354#respond Tue, 22 Feb 2022 02:25:52 +0000 http://www.jydba.net/?p=3354 mysqlslap是一种诊断程序用来模拟MySQL服务器的客户端负载并报告每个阶段的时间。它模拟多个客户端同时访问MySQL服务。

mysqlslap语法如下:

Usage: mysqlslap [OPTIONS]

它有许多选项可以使用:

有些选项比如–create或–query能够让你指这一个字符串包含一个SQL语句或一个文件来包含SQL语句。如果你指定一个文件,缺省情况是它必须每行包含一个SQL语句(也就是说隐式语句分隔符是换行符)。使用–delimiter选项来指定不同的分隔符,它能让你指定一个语句跨越多行或者将多个语句放入一行。在文件中不能包含注释,mysqlslap不能解析它们。

mysqlslap运行分为三个阶段
1.创建方案,表和可选的任何存储过程或用于测试的数据。这个阶段使用单个客房端连接。

2.运行负载测试,这个阶段可以使用多个客户端连接。

3.清除(断开连接,如果指定删除表)。这个阶段使用单个客户端连接。

例如:
假设你创建和查询SQL语句,而且想使用50个客户端来执行查询并且每个语句执行200次(在单行中输入命令):

mysqlslap  --delimiter=";" --create="create table a(b int);insert into a values(11)" --query="select * from a"  --concurrency=50 --iterations=200

执行结果如下:

[mysql@localhost ~]$ mysqlslap -h192.168.1.250 -P33306 -uroot -p123456 mysql --delimiter=";" --create="create table a(b int);insert into a values(11)" --query="select * from a"  --concurrency=50 --iterations=200
mysqlslap: [Warning] Using a password on the command line interface can be insecure.
Benchmark
        Average number of seconds to run all queries: 0.268 seconds
        Minimum number of seconds to run all queries: 0.257 seconds
        Maximum number of seconds to run all queries: 0.370 seconds
        Number of clients running queries: 50
        Average number of queries per client: 1

让mysqlslap来使用一个有两个INT列和三个varchar列的表来构建查询SQL语句。使用五个客户端每个客户端查询20次。不创建表或不插入数据(使用之前的测试方案和数据):

mysqlslap --concurrency=5 --iterations=20 --number-int-cols=2 --number-char-cols=3 --auto-generate-sql

执行结果如下:

[mysql@localhost ~]$ mysqlslap -h192.168.1.250 -P33306 -uroot -p123456 mysql --concurrency=5 --iterations=20 --number-int-cols=2 --number-char-cols=3 --auto-generate-sql
mysqlslap: [Warning] Using a password on the command line interface can be insecure.
Benchmark
        Average number of seconds to run all queries: 0.247 seconds
        Minimum number of seconds to run all queries: 0.182 seconds
        Maximum number of seconds to run all queries: 0.361 seconds
        Number of clients running queries: 5
        Average number of queries per client: 0

为了告诉程序从指定的文件中加载创建,插入和查询的SQL语句,这里给–create选项指定create.sql文件,它包含了由分号隔开的多个创建表的语句和多个插入语句。–query选项指定的query.sql文件包含由分号隔开的多个查询语句。运行所有加载的语句,然后使用五个客户端运行查询文件中的所有查询(每个运行五次):

mysqlslap --concurrency=5 --iterations=5 --query=query.sql --create=create.sql --delimiter=";"

执行结果如下:

[mysql@localhost ~]$ mysqlslap -h192.168.1.250 -P33306 -uroot -p123456 mysql --concurrency=5 --iterations=5 --query=query.sql --create=create.sql --delimiter=";"
mysqlslap: [Warning] Using a password on the command line interface can be insecure.
Benchmark
        Average number of seconds to run all queries: 0.035 seconds
        Minimum number of seconds to run all queries: 0.034 seconds
        Maximum number of seconds to run all queries: 0.038 seconds
        Number of clients running queries: 5
        Average number of queries per client: 5

mysqlslap支持以下选项,可以在命令行指定或在选项文件中通过[mysqlslap]和[client]组来指定

[mysql@localhost ~]$ mysqlslap --help
mysqlslap  Ver 1.0 Distrib 5.7.26, for Linux (x86_64)
Copyright (c) 2005, 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.

Run a query multiple times against the server.

Usage: mysqlslap [OPTIONS]

Default options are read from the following files in the given order:
/etc/my.cnf /etc/mysql/my.cnf /mysqlsoft/mysql/etc/my.cnf /mysqlsoft/mysql/my.cnf ~/.my.cnf
The following groups are read: mysqlslap client
The following options may be given as the first argument:
--print-defaults        Print the program argument list and exit.
--no-defaults           Don't read default options from any option file,
                        except for login file.
--defaults-file=#       Only read default options from the given file #.
--defaults-extra-file=# Read this file after the global files are read.
--defaults-group-suffix=#
                        Also read groups with concat(group, suffix)
--login-path=#          Read this path from the login file.
  -?, --help          Display this help and exit.
  -a, --auto-generate-sql
                      Generate SQL where not supplied by file or command line.
  --auto-generate-sql-add-autoincrement
                      Add an AUTO_INCREMENT column to auto-generated tables.
  --auto-generate-sql-execute-number=#
                      Set this number to generate a set number of queries to
                      run.
  --auto-generate-sql-guid-primary
                      Add GUID based primary keys to auto-generated tables.
  --auto-generate-sql-load-type=name
                      Specify test load type: mixed, update, write, key, or
                      read; default is mixed.
  --auto-generate-sql-secondary-indexes=#
                      Number of secondary indexes to add to auto-generated
                      tables.
  --auto-generate-sql-unique-query-number=#
                      Number of unique queries to generate for automatic tests.
  --auto-generate-sql-unique-write-number=#
                      Number of unique queries to generate for
                      auto-generate-sql-write-number.
  --auto-generate-sql-write-number=#
                      Number of row inserts to perform for each thread (default
                      is 100).
  --commit=#          Commit records every X number of statements.
  -C, --compress      Use compression in server/client protocol.
  -c, --concurrency=name
                      Number of clients to simulate for query to run.
  --create=name       File or string to use create tables.
  --create-schema=name
                      Schema to run tests in.
  --csv[=name]        Generate CSV output to named file or to stdout if no file
                      is named.
  -#, --debug[=#]     This is a non-debug version. Catch this and exit.
  --debug-check       This is a non-debug version. Catch this and exit.
  -T, --debug-info    This is a non-debug version. Catch this and exit.
  --default-auth=name Default authentication client-side plugin to use.
  -F, --delimiter=name
                      Delimiter to use in SQL statements supplied in file or
                      command line.
  --detach=#          Detach (close and reopen) connections after X number of
                      requests.
  --enable-cleartext-plugin
                      Enable/disable the clear text authentication plugin.
  -e, --engine=name   Storage engine to use for creating the table.
  -h, --host=name     Connect to host.
  -i, --iterations=#  Number of times to run the tests.
  --no-drop           Do not drop the schema after the test.
  -x, --number-char-cols=name
                      Number of VARCHAR columns to create in table if
                      specifying --auto-generate-sql.
  -y, --number-int-cols=name
                      Number of INT columns to create in table if specifying
                      --auto-generate-sql.
  --number-of-queries=#
                      Limit each client to this number of queries (this is not
                      exact).
  --only-print        Do not connect to the databases, but instead print out
                      what would have been done.
  -p, --password[=name]
                      Password to use when connecting to server. If password is
                      not given it's asked from the tty.
  --plugin-dir=name   Directory for client-side plugins.
  -P, --port=#        Port number to use for connection.
  --post-query=name   Query to run or file containing query to execute after
                      tests have completed.
  --post-system=name  system() string to execute after tests have completed.
  --pre-query=name    Query to run or file containing query to execute before
                      running tests.
  --pre-system=name   system() string to execute before running tests.
  --protocol=name     The protocol to use for connection (tcp, socket, pipe,
                      memory).
  -q, --query=name    Query to run or file containing query to run.
  --secure-auth       Refuse client connecting to server if it uses old
                      (pre-4.1.1) protocol. Deprecated. Always TRUE
  -s, --silent        Run program in silent mode - no output.
  -S, --socket=name   The socket file to use for connection.
  --sql-mode=name     Specify sql-mode to run mysqlslap tool.
  --ssl-mode=name     SSL connection mode.
  --ssl               Deprecated. Use --ssl-mode instead.
                      (Defaults to on; use --skip-ssl to disable.)
  --ssl-verify-server-cert
                      Deprecated. Use --ssl-mode=VERIFY_IDENTITY instead.
  --ssl-ca=name       CA file in PEM format.
  --ssl-capath=name   CA directory.
  --ssl-cert=name     X509 cert in PEM format.
  --ssl-cipher=name   SSL cipher to use.
  --ssl-key=name      X509 key in PEM format.
  --ssl-crl=name      Certificate revocation list.
  --ssl-crlpath=name  Certificate revocation list path.
  --tls-version=name  TLS version to use, permitted values are: TLSv1, TLSv1.1
  -u, --user=name     User for login if not current user.
  -v, --verbose       More verbose output; you can use this multiple times to
                      get even more verbose output.
  -V, --version       Output version information and exit.
]]>
http://www.jydba.net/index.php/archives/3354/feed 0
mysqlbinlog 处理二进制日志文件的工具 http://www.jydba.net/index.php/archives/3352 http://www.jydba.net/index.php/archives/3352#respond Tue, 22 Feb 2022 02:18:29 +0000 http://www.jydba.net/?p=3352 mysqlbinlog 处理二进制日志文件的工具
服务器的二进制日志文件由用来描述修改数据库内容的事件组成。服务器以二进制方式来写这些文件。为了以文本格式来显示这些内容,可以使用mysqlbinlog工具。也可以使用mysqlbinlog来显示在复制环境中由从从slave服务器所写入中relay日志文件中的内容,因为其格式与二进制日志文件格式一样。

mysqlbinlog的使用语法如下:

Usage: mysqlbinlog [options] log-files

下面的命令用来显示名为binlog.000001的二进制日志文件的内容:

[mysql@localhost ~]$ mysqlbinlog  /mysqldata/mysql/binlog.000001
/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
DELIMITER /*!*/;
# at 4
#191115 15:39:01 server id 1  end_log_pos 123 CRC32 0x2d9d7b4f  Start: binlog v 4, server v 5.7.26-log created 191115 15:39:01 at startup
# Warning: this binlog is either in use or was not closed properly.
ROLLBACK/*!*/;
BINLOG '
FVbOXQ8BAAAAdwAAAHsAAAABAAQANS43LjI2LWxvZwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAVVs5dEzgNAAgAEgAEBAQEEgAAXwAEGggAAAAICAgCAAAACgoKKioAEjQA
AU97nS0=
'/*!*/;
# at 123
#191115 15:39:01 server id 1  end_log_pos 154 CRC32 0x42dcd61c  Previous-GTIDs
# [empty]
# at 154
#191115 15:51:15 server id 1  end_log_pos 219 CRC32 0x5bc0b021  Anonymous_GTID  last_committed=0        sequence_number=1       rbr_only=no
SET @@SESSION.GTID_NEXT= 'ANONYMOUS'/*!*/;
# at 219
#191115 15:51:15 server id 1  end_log_pos 308 CRC32 0x7261eacb  Query   thread_id=2     exec_time=0     error_code=0
use `mysql`/*!*/;
SET TIMESTAMP=1573804275/*!*/;
SET @@session.pseudo_thread_id=2/*!*/;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
SET @@session.sql_mode=1436549152/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C gb2312 *//*!*/;
SET @@session.character_set_client=24,@@session.collation_connection=24,@@session.collation_server=45/*!*/;
SET @@session.lc_time_names=0/*!*/;
SET @@session.collation_database=DEFAULT/*!*/;
truncate table person
/*!*/;
# at 308
#191115 15:51:38 server id 1  end_log_pos 373 CRC32 0x6d2e39aa  Anonymous_GTID  last_committed=1        sequence_number=2       rbr_only=no
SET @@SESSION.GTID_NEXT= 'ANONYMOUS'/*!*/;
# at 373
#191115 15:51:38 server id 1  end_log_pos 454 CRC32 0x7871c2ea  Query   thread_id=2     exec_time=0     error_code=0
SET TIMESTAMP=1573804298/*!*/;
BEGIN
/*!*/;
# at 454
# at 486
#191115 15:51:38 server id 1  end_log_pos 486 CRC32 0xb746cd30  Intvar
SET INSERT_ID=1/*!*/;
#191115 15:51:38 server id 1  end_log_pos 654 CRC32 0x0e926042  Query   thread_id=2     exec_time=0     error_code=0
SET TIMESTAMP=1573804298/*!*/;
insert into person(last_name,first_name,birth,death) values('yong','jing','1985-02-28',null)
/*!*/;
# at 654
#191115 15:51:38 server id 1  end_log_pos 736 CRC32 0xc5450308  Query   thread_id=2     exec_time=0     error_code=0
SET TIMESTAMP=1573804298/*!*/;
COMMIT
/*!*/;
# at 736
#191115 15:51:45 server id 1  end_log_pos 801 CRC32 0xc2c892b8  Anonymous_GTID  last_committed=2        sequence_number=3       rbr_only=no
SET @@SESSION.GTID_NEXT= 'ANONYMOUS'/*!*/;
# at 801
#191115 15:51:45 server id 1  end_log_pos 882 CRC32 0x51a9cd5c  Query   thread_id=2     exec_time=0     error_code=0
SET TIMESTAMP=1573804305/*!*/;
BEGIN
/*!*/;
# at 882
# at 914
#191115 15:51:45 server id 1  end_log_pos 914 CRC32 0x40a98fae  Intvar
SET INSERT_ID=2/*!*/;
#191115 15:51:45 server id 1  end_log_pos 1082 CRC32 0x3396c40d         Query   thread_id=2     exec_time=0     error_code=0
SET TIMESTAMP=1573804305/*!*/;
insert into person(last_name,first_name,birth,death) values('yan','huang','1990-08-25',null)
/*!*/;
# at 1082
#191115 15:51:45 server id 1  end_log_pos 1164 CRC32 0xf6f6efad         Query   thread_id=2     exec_time=0     error_code=0
SET TIMESTAMP=1573804305/*!*/;
COMMIT
/*!*/;
# at 1164
#191115 15:51:53 server id 1  end_log_pos 1229 CRC32 0x55b50dbe         Anonymous_GTID  last_committed=3        sequence_number=4       rbr_only=no
SET @@SESSION.GTID_NEXT= 'ANONYMOUS'/*!*/;
# at 1229
#191115 15:51:53 server id 1  end_log_pos 1310 CRC32 0xd0f6a335         Query   thread_id=2     exec_time=0     error_code=0
SET TIMESTAMP=1573804313/*!*/;
BEGIN
/*!*/;
# at 1310
# at 1342
#191115 15:51:53 server id 1  end_log_pos 1342 CRC32 0xfad94baf         Intvar
SET INSERT_ID=3/*!*/;
#191115 15:51:53 server id 1  end_log_pos 1508 CRC32 0x26c5b3bb         Query   thread_id=2     exec_time=0     error_code=0
SET TIMESTAMP=1573804313/*!*/;
insert into person(last_name,first_name,birth,death) values('yali','ye','1994-12-23',null)
/*!*/;
# at 1508
#191115 15:51:53 server id 1  end_log_pos 1590 CRC32 0xbb6a2b4c         Query   thread_id=2     exec_time=0     error_code=0
SET TIMESTAMP=1573804313/*!*/;
COMMIT
/*!*/;
SET @@SESSION.GTID_NEXT= 'AUTOMATIC' /* added by mysqlbinlog */ /*!*/;
DELIMITER ;
# End of log file
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/;

上面输出了binlog.000001二进制日志文件中所包含的内容。对于基于语句的日志,事件信息包括SQL语句,执行语句的服务器ID,语句被执行的时间戳,执行时间等。对于基于行记录的日志,事件信息指示行的改变而不是SQL语句。

# at 486
#191115 15:51:38 server id 1  end_log_pos 486 CRC32 0xb746cd30  Intvar SET INSERT_ID=1/*!*/;
#191115 15:51:38 server id 1  end_log_pos 654 CRC32 0x0e926042  Query   thread_id=2
exec_time=0     error_code=0 SET TIMESTAMP=1573804298/*!*/;

第一行,at后面的数字指示事件在二进制日志文件中的偏移量或开始位置。

第二行是以日期和时间开始指示语句开始执行的时间。对于复制来说,这个时间戳将传播到从属服务器。server id是事件起源服务器的server_id值。end_log_pos指示下一个事件开始的位置(它是当前事件的终止位置+1)。thread_id那个线程来执行这个事件。exec_time是在主服务器上执行事件所花费的时间。在从属服务器上,它是从属服务器上执行结束时间减去主服务器上的执行开始时间的差值。这种差值可以作为一种指示来表示复制进程落后于主服务器多长时间。error_code指示执行事件的结果。零意味着没有出现错误。

mysqlbinglog的输出可以用来重新执行日志文件中的语句(例如,通过使用mysql工具)。这在服务器崩溃时用来恢复是很有用的。

正常来说,使用mysqlbinlog直接读取二进制日志文件并应用它们到本地MySQL服务器。它也可以通过使用–read-from-remote-server选项来从远程服务器上读取二进制日志文件。为了读取远程二进制日志文件,连接参数选项可以被指定用来指示如何连接服务器。这些选项有–host,–password,–port,–protocol,–socket和–user,除非使用了–read-from-remote-server选项否则它们会被忽略。

当对一个大的二进制日志文件执行mysqlbinlog时,要小心注意文件系统是否有足够的空间来存储结果文件。为了配置目录给mysqlbinlog临时使用存储文件,使用TMPDIR环境变量。

使用mysqlbinlog备份二进制日志文件
缺省情况下,mysqlbinlog读取二进制日志文件并以文本格式来显示它的内容。这能让你更容易使用文件来检查发生的事件和重新执行它们(例如,通过使用输出作为mysql的输入)。mysqlbinlog可以直接从本地文件系统中读取日志文件或者使用–read-from-remote-server选项来连接远程服务器并从远程服务器上读取二进制日志文件。

mysqlbinlog以文本格式将内容输出到标准输出,或者如果指定了–result-file=file_name选项会将内容写入文件。

mysqlbinlog可以读了二进制日志文件并将其包含的内容以二进制格式而不是文本格式写入新文件。这种能力可以让你以原来的格式来备份二进制日志文件。mysqlbinlog可以生成静态备份,在备份一组日志文件时当备份完最后的文件时而停止。它也可以生成一种连续(live)备份,当备份到最后的日志文件时仍然保持对服务器的连接并当生成新的事件时继续复制新的事件。在连续备份操作时,mysqlbinlog会运行到连接中断为止(比如,服务器退出)或mysqlbinlog被强制中断为止。当连接中断,mysqlbinlog不会进行等待并重新进行连接,不像从属复制服务器那样。为了在服务器重启之后继续一个live备份,必须重新启动mysqlbinlog。

二进制日志文件备份要求在调用mysqlbinlog时最少要使用两个选项:
.–read-from-remote-server(或-R)选项来告诉mysqlbinlog连接到一个服务器并读取它的二进制日志文件(这类似于一个从属复制服务器连接到它的主服务器).

.–raw选项告诉mysqlbinlog以原始(二进制)格式输出,而不是文本格式。

与–read-from-remote-server一起通常还指定其它选项:–host指示服务器运行在哪里,并且可能需要指定连接选项–user和password。

与–raw联合使用的几个其它选项:
.–stop-never:在读取到最后日志文件后保持对服务器的连接并继续读取新的事件。

.–stop-never-slave-server-id=id:当–stop-never被使用时mysqlbinlog报告的服务器ID,缺省值65535。这可以避免与从属服务器或其它的mysqlbinlog进程的ID冲突。

.–result-file:输出文件名的前缀

为了使用mysqlbinlog来备份服务器的二进制日志文件,你必须指定在服务器上真实存在的文件名。如果你不知道文件名,连接到服务器并使用show binary logs语句来查看当前的日志文件名。

mysql> show binary logs;
+---------------+-----------+
| Log_name      | File_size |
+---------------+-----------+
| binlog.000001 |      2530 |
+---------------+-----------+
1 row in set (0.00 sec)

使用这些信息可以使用mysqlbinlog来备份二进制日志文件到当前目录:
为了对binlog.000130到binlog.000132的日志文件进行静态备份,使用以下命令:

mysqlbinlog --read-from-remote-server --host=host_name --raw binlog.000130 binlog.000131 binlog.000132


mysqlbinlog --read-from-remote-server --host=host_name --raw --to-last-log binlog.000130

第一个命令显式指定每个文件名。第二个只指定了第一个日志文件并使用了–to-last-log来读取到最后一个日志文件。在这些命令之间的差异是在mysqlbinlog到达binlog.000132的末尾之前如果服务器打开了binlog.000133文件,第一个命令将不会读取,但第二个命令会读取。

为了进行live备份mysqlbinlog从binlog.000130开始备份现有的日志文件,然后保持对服务器的连接来复制生成的新事件:

mysqlbinlog --read-from-remote-server --host=host_name --raw --stop-never binlog.000130

使用–stop-never选项,不需要指定–to-last-log来读取最后的日志文件因为这个选项是隐含的

输出文件名
在没有使用–raw选项时,mysqlbinlog会生成文本格式的输出,如果指定–result-file选项,指定将所有输出写入一个文件中。使用–raw选项时,mysqlbinlog会将服务器的每个日志文件转换成一个二进制输出文件。缺省情况下,mysqlbinlog会在当前目录中生成与源日志文件同名的文件。为了修改输出文件名,使用–result-file选项。与–raw联合使用,–result-file选项值将作为前缀来命名输出文件名。

现在对远程服务器中的binlog.000001日志文件进行备份

[mysql@localhost ~]$ mysqlbinlog --read-from-remote-server --host=192.168.1.250 --raw binlog.000001 --result-file=jy_
[mysql@localhost ~]$ ls -lrt
-rw-r-----. 1 mysql mysql    2530 11月 22 10:24 jy_binlog.000001

可以看到备份的日志文件为以jy_为前缀,其文件名为jy_binlog.000001

使用mysqldump+mysqlbinlog执行备份与还原操作
下面将介绍一个简单的例子显示如何使用mysqldump与mysqlbinlog一起来备份MySQL服务器的数据和二进制日志文件以及在数据丢失时如何使用备份来还原数据。

现在主机上的MySQL服务器的第一个二进制日志文件为binlog.000001

mysql> show binary logs;
+---------------+-----------+
| Log_name      | File_size |
+---------------+-----------+
| binlog.000001 |      2530 |
+---------------+-----------+
1 row in set (0.01 sec)

使用mysqlbinlog来对二进制日志文件执行连续备份:

[mysql@localhost ~]$ mysqlbinlog --read-from-remote-server --host=192.168.1.250 --raw  --stop-never binlog.000001

[mysql@localhost ~]$ ls -lrt

-rw-r-----. 1 mysql mysql    2530 11月 22 10:38 binlog.000001

创建了一个名为t的测试表并插入了三行记录

mysql> select * from t;
+----+----------+------+
| id | name     | date |
+----+----------+------+
|  1 | jingyong | NULL |
|  2 | yeyali   | NULL |
|  3 | huangyan | NULL |
+----+----------+------+
3 rows in set (0.00 sec)

使用mysqldump来创建一个dump文件作为对MySQL服务器的数据快照。使用–all-databases,–events和–routines来备份所有的数据,–master-data=2用来指示在dump文件中包括当前的二进制日志文件。

[mysql@localhost ~]$ mysqldump --host=192.168.1.250 --port=3306 -uroot -pxxzx7817600 --all-databases --events --routines --master-data=2> dump_mysql.sql
mysqldump: [Warning] Using a password on the command line interface can be insecure.
[mysql@localhost ~]$ ls -lrt
-rw-r--r--. 1 mysql mysql 3290497 11月 22 10:51 dump_mysql.sql

现在删除mysql库中的表t

mysql> drop table t;
Query OK, 0 rows affected (0.18 sec)

mysql> desc t;
ERROR 1146 (42S02): Table 'mysql.t' doesn't exist

现在假设mysql库中的表t丢失了,使用最近的dump文件来还原数据:

[mysql@localhost ~]$ mysql --host=192.168.1.250 --port=3306 -uroot -pxxzx7817600  mysql 

还原数据后mysql.t表就恢复了

mysql> desc t;
+-------+-------------+------+-----+---------+-------+
| Field | Type        | Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+-------+
| id    | int(11)     | NO   |     | NULL    |       |
| name  | varchar(20) | NO   |     | NULL    |       |
| date  | date        | YES  |     | NULL    |       |
+-------+-------------+------+-----+---------+-------+
3 rows in set (0.01 sec)

mysql> select * from t;
+----+----------+------+
| id | name     | date |
+----+----------+------+
|  1 | jingyong | NULL |
|  2 | yeyali   | NULL |
|  3 | huangyan | NULL |
+----+----------+------+
3 rows in set (0.00 sec)

现在向mysql.t表中插入一条记录并删除这条记录,然后使用备份的二进制日志文件来重新执行事件来恢复这条记录

mysql> insert into t value(4,'wenyao',NULL);
Query OK, 1 row affected (0.03 sec)

mysql> select * from t;
+----+----------+------+
| id | name     | date |
+----+----------+------+
|  1 | jingyong | NULL |
|  2 | yeyali   | NULL |
|  3 | huangyan | NULL |
|  4 | wenyao   | NULL |
+----+----------+------+
4 rows in set (0.00 sec)

mysql> delete from t where id=4;
Query OK, 1 row affected (0.13 sec)

mysql> select * from t;
+----+----------+------+
| id | name     | date |
+----+----------+------+
|  1 | jingyong | NULL |
|  2 | yeyali   | NULL |
|  3 | huangyan | NULL |
+----+----------+------+
3 rows in set (0.01 sec)

我们需要找到插入这条记录在日志文件中的开始与结束的位置

# at 3306211
#191122 11:04:34 server id 1  end_log_pos 3306323 CRC32 0x88f89864      Query   thread_id=11    exec_time=0     error_code=0
SET TIMESTAMP=1574391874/*!*/;
insert into t value(4,'wenyao',NULL)
/*!*/;
# at 3306323
#191122 11:04:34 server id 1  end_log_pos 3306354 CRC32 0x966500de      Xid = 1041
COMMIT/*!*/;
# at 3306354
#191122 11:07:26 server id 1  end_log_pos 3306419 CRC32 0x1f3e6e28      Anonymous_GTID  last_committed=160      sequence_number=161     rbr_only=no
SET @@SESSION.GTID_NEXT= 'ANONYMOUS'/*!*/;
# at 3306419
#191122 11:07:26 server id 1  end_log_pos 3306500 CRC32 0x883ecef4      Query   thread_id=11    exec_time=0     error_code=0
SET TIMESTAMP=1574392046/*!*/;
BEGIN
/*!*/;
# at 3306500
#191122 11:07:26 server id 1  end_log_pos 3306600 CRC32 0xecae0a57      Query   thread_id=11    exec_time=0     error_code=0
SET TIMESTAMP=1574392046/*!*/;
delete from t where id=4

从上面的日志文件内容可以看到插入的开始位置为3306211,结束位置为3306323

现在当前备份的二进制日志文件名为binlog.000001,重新执行事件的命令如下:

[mysql@localhost ~]$ mysqlbinlog --start-position=3306211 --stop-position=3306323 binlog.000001 | mysql --host=192.168.1.250 --port=3306 -uroot -pxxzx7817600  mysql
mysql: [Warning] Using a password on the command line interface can be insecure.

现在检查mysql.t表中的记录,可以看到被删除的这条记录恢复了。

mysql> select * from t;
+----+----------+------+
| id | name     | date |
+----+----------+------+
|  1 | jingyong | NULL |
|  2 | yeyali   | NULL |
|  3 | huangyan | NULL |
|  4 | wenyao   | NULL |
+----+----------+------+
4 rows in set (0.00 sec)

设置msyqlbinlog 服务器ID
在使用--read-from-remote-server选项来调用mysqlbinlog时,mysqlbinlog会连接到一个MySQL服务器,指定了一个服务器ID来标识它并且从该服务器获取所需要的二进制日志文件。可以使用mysqlbinlog以以下几种方式来从服务器中获取日志文件:
.对文件集指定显式的名字。对每个文件,mysqlbinlog会执行连接操作并执行binlog dump命令。服务器会发送文件并断开连接。每个文件都有一个连接。

.指定开始文件与--to-last-log选项,mysqlbinlog会执行连接并对所有的日志文件执行binlog dump命令。服务器会发送所有日志文件并断开连接

.指定开始文件与--stop-never选项(隐式实现--to-last-log选项的功能),mysqlbinlog会执行连接并对所有日志文件执行binlog dump命令。服务器会发送所有日志文件,但在发送最后一个日志文件后不会断开与服务器的连接。

只有使用--read-from-remote-server选项时,mysqlbinlog使用一个为0的server ID进行连接,它将告诉服务器在发送所请求的日志文件后断开连接。

使用--read-from-remote-server与--stop-never选项时,mysqlbinlog将使用一个非0的server ID进行连接,因此在最后的日志文件发送之后服务器不会断开连接。缺省的server ID为65535,但这个可以通过使用
--stop-never-slave-server-id选项来修改。

因此,对于使用前两种方式来获取日志文件人,因为mysqlbinlog指定的server ID为0,所有服务器会断开连接,如果--stop-never选项被指定因为mysqlbinlog指定一个非0的server ID,所以服务器将不会断开连接。

]]> http://www.jydba.net/index.php/archives/3352/feed 0 MySQL Binary Log http://www.jydba.net/index.php/archives/3350 http://www.jydba.net/index.php/archives/3350#respond Tue, 22 Feb 2022 00:37:34 +0000 http://www.jydba.net/?p=3350 binary log包含用来描述数据库改变比如表创建操作或表数据改变的事件信息。除非使用基于行的日志,它还可能包含潜在可能发生改变的语句(例如,delete没有匹配的行记录)。binary log也包含关于每个语句更新数据所花费的时间。binary log有两个重要的目的:
.用于复制,主复制服务器上的binary log提供了被发往从服务器的数据改变的记录。主服务器将binary log中包含的事件发送给它的从服务器,从服务器执行这些事件使用相同的数据改变应用到从服务器。

.用于需要使用binary log来执行的特定恢复操作。在一个备份还原之后,在binary log中的事件记录了在备份之后所发生的改变,使用binary log来重新执行这些改变。这些事件从备份时间点起记录了数据库的更新。

当启用binary log后会使用服务器的性能稍稍有所下降。然而,binary log的好处就是能让你配置复制并且对于恢复操作来说比起这稍稍的性能下降更重要。

binary log通常对于意外停机具有弹性因为只有完成的事务会被记录或读回。写入binary log的语句中的密码由服务器重写,不会以明文形式出现。

为了启用binary log,使用–log-bin[=base_name]选项来启动服务器。如果base_name没有指定,默认名字是pid-file选项的值(它的默认名字是主机名)后面跟着-bin。如果给定了基本名,则服务器将文件写入数据目录中,除非给定的基本名包含一个前导绝对路径名以指定另一个目录。建议您显式地指定一个基本名称,而不是使用默认的主机名。

如果在日志名称中提供扩展名(例如,——log-bin=base_name.extension),扩展名将被静默删除并忽略。

mysqld将数字扩展追加到二进制日志基名以生成二进制日志文件名。每次服务器创建一个新的日志文件时,这个数字都会增加,从而创建一个有序的文件序列。服务器每次启动或刷新日志时,都会在这个系列中创建一个新文件。当当前日志的大小达到max_binlog_size时,服务器还会自动创建一个新的二进制日志文件。如果使用大事务因为一个事务是以一个片段写入文件而不会跨文件写入所以binary log文件可能会超过max_binlog_size的大小。

为了保持对那些被使用的binary log文件的跟踪,mysqld也会创建一个binary log索引文件它包含所有被使用的binary log文件。默认情况下这里使用基本名作为binary 日志文件名并带有’.index’扩展名。你可以使用–log-bin-index[=file_name]选项来改变binary log索引文件名。在mysqld正在运行时不能手动编辑这个文件。

术语”binary log file”通常表示包含数据库事件的单独编号的日志文件。术语句”binary log”集体表示一组binary log文件和索引文件。

有super权限的客户端可以通过使用set sql_log_bin=0来对它的语句禁用binary log。

默认情况下,服务器会记录事件的长度以及事件本身,并使用它来验证事件是否被正确写入。也可以通过设置binlog_checksum系统变量让服务器对事件写checksums。当从binary log加读时,主服务器默认会使用事件长度,但如果启用了master_verify_checksum系统变量也会使用checksums。从服务器IO线和也会验证从主服务器所接收到的事件。如果启用了slave_sql_verify_checksum系统变量并可用可以使用从SQL线程使用chechsums。

服务器评估–binlog-do-db和–binlog-ignore-db选项的方式与–replicate-do-db和–replicate-ignore-db选项。

一个复制从服务器默认情况下不会将从复制主服务器所接收到的任何数据修改写入它的binary log。为了记录这些修改,可以在启动从服务器时使用–log-slave-updates选项外加–log-bin选项。在链式复制中,当一个从属节点也充当其他从属节点的主节点时,将执行此操作。

可以使用reset master语句或purge binary logs来删除所有binary log文件。

如果你将使用复制,直到你确定没有从服务器仍然需要使用它们之前你将不应该删除旧的binary log文件。例如如果你的从服务器同步没有落后三天,你可以在主服务器上执行mysqladmin flush-logs并且删除任何超过三天的日志。可以手动删了日志文件,但最好使用purgebinary logs,它能为你安全地更新binary log索引文件。

在一个语句或事务完成后但在任何锁被释放或任何提交完成前会立即写入binary log。这可以确保日志以提交顺序被记录。

对非事务性表的更新在执行后立即存储在二进制日志中。

在未提交事务中,对事务表比如InnoDB表的所有更新(update,delete或insert)会被缓存直到服务器收到commit语句为止。在这时,mysqld会在commit执行之前将整个事务写入binary log。

对于非事务表的修改不能被回滚。如果一个被回滚的事务包含对非事务表的修改,整个事务在最后用ROLLBACK语句记录,以确保复制了对这些表的修改。

当处理事务的线程开始时,它将为binlog_cache_size分配一个buffer来缓存语句。如果语句大于这个buffer,线程会打开一个临时文件来存储事务。当线程结束时临时文件会被删除。

binlog_cache_use状态变量显示了使用这个缓冲区(可能还有一个临时文件)来存储语句的事务数。binlog_cache_disk_use状态变量显示了这些事务中有多少事务实际上使用了临时文件。这两个变量可以被用来调整binlog_cache_size的大小使其足够大避免使用临时文件。

mysql> show variables like 'binlog_cache_size';
+-------------------+---------+
| Variable_name     | Value   |
+-------------------+---------+
| binlog_cache_size | 4194304 |
+-------------------+---------+
1 row in set (0.00 sec)

max_binlog_cache_size系统变量(默认值为4GB,这也是最大值)可以被用来限制用于缓存多语句事务的总大小。如果事务大于这么多字节,则会失败并回滚。最小值是4096。

如果将使用binary log和基于行日志,并发插入比如create … select或insert … select语句会被转换为正常插入。这样做是为了确保您可以通过在备份操作期间应用日志来重新创建表的精确副本。如果使用基于语句的日志记录,则将原始语句写入日志。

默认情况下每次写入(sync_binlog=1)时binary log会被同步到磁盘。如果sync_binlog没有启用,操作系统或机器(不仅仅是MySQL服务器)崩溃, 二进制日志的最后一条语句可能会丢失。为了防止这个问题,启用sync_binlog系统变量来在每N个提交组之后同步二进制日志到磁盘。sync_binlog最安全的值是1(默认值),但这也是最慢的。

例如,如果您使用InnoDB表,MySQL服务器处理一个COMMIT语句,它会按顺序将许多准备好的事务写到二进制日志中,同步二进制日志,然后将这个事务提交到InnoDB中。如果服务器在这两个操作之间崩溃,事务会在重启时由InnoDB回滚,但仍然存在于二进制日志中。假设——innodb_support_xa设置为1 为默认值,这个问题已经解决了,。虽然这个选项与InnoDB中XA事务的支持有关,但它也确保了二进制日志和InnoDB数据文件是同步的。为了提供更大程度的安全性,MySQL服务器还应该配置为在提交事务之前将二进制日志和InnoDB日志同步到磁盘。默认情况下,InnoDB日志是同步的,sync_binlog=1可用于同步二进制日志。这个选项的效果是,在崩溃后重新启动时,在执行事务回滚之后,MySQL服务器扫描最新的二进制日志文件来收集事务xid值,并计算二进制日志文件中的最后一个有效位置。然后,MySQL服务器告诉InnoDB完成所有已成功写入二进制日志的事务,并将二进制日志截断到最后一个有效位置。这确保了二进制日志反映了InnoDB表的准确数据,因此从数据库与主数据库保持同步,因为它没有收到一条回滚的语句。

如果MySQL服务器在崩溃恢复时发现二进制日志比应该的短,那么它至少缺少一个成功提交的InnoDB事务。如果sync_binlog=1和磁盘/文件系统在被请求时执行实际的同步(有些没有),则不会发生这种情况,因此服务器将打印一条错误消息The binary log file_name is shorter than its expected size。在这种情况下,这个二进制日志不正确,应该从主数据的新快照重新启动复制。

以下系统变量的会话值被写入二进制日志,并在解析二进制日志时由复制从属服务器执行:

.sql_mode(除了NO_DIR_IN_CREATE模式不被复制)
.foreign_key_checks
.unique_checks
.character_set_client
.collation_connection
.collation_database
.collation_server
.sql_auto_is_null

binary log格式
服务器使用几种日志格式来记录二进制日志中的信息。所使用的确切格式取决于所使用的MySQL版本。有三种日志格式:
.MySQL中的复制功能最初是基于从主到从的SQL语句传播。这称为基于语句的日志记录。通过使用——binlog-format=STATEMENT启动服务器,可以使用这种格式。
.在基于行的日志记录中,主进程将事件写入二进制日志,以指示各个表行是如何受到影响的。因此,表总是使用主键来确保有效地标识行,这一点很重要。通过使用——binlogformat=ROW启动服务器,可以使它使用基于行的日志记录。
.还有第三个选项:混合日志记录。对于混合日志记录,默认使用基于语句的日志记录,但是在某些情况下,日志记录模式会自动切换到基于行,如下所述。通过使用选项——binlogformat=MIXED启动mysqld,可以使MySQL显式地使用混合日志记录好坏参半。日志格式也可以由所使用的存储引擎设置或限制。这有助于消除在使用不同存储引擎的主从之间复制某些语句时出现的问题。

对于基于语句的复制,复制不确定语句可能会有问题。在决定给定的语句对于基于语句的复制是否安全时,MySQL决定是否可以保证使用基于语句的日志来复制语句。如果MySQL不能做到这一点,它会将该语句标记为可能不可靠,并发出警告。

Statement may not be safe to log in statement format.

可以使用MySQL的基于行的复制来避免这些问题。

设置Binary log格式
可以在启动MySQL服务器时使用–binlog-format=type来显式选项binary log格式,type支持以下取值:
.STATEMENT基于语句记录日志
.ROW基于行记录记录日志
.MIXED使用混合格式记录日志

日志格式也可以在运行时切换。设置binlog_format系统变量的全局值,以指定更改之后连接的客户端的日志格式

mysql> select @@binlog_format;
+-----------------+
| @@binlog_format |
+-----------------+
| MIXED           |
+-----------------+
1 row in set (0.00 sec)

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


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

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 16
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> select @@binlog_format;
+-----------------+
| @@binlog_format |
+-----------------+
| STATEMENT       |
+-----------------+
1 row in set (0.00 sec)


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

mysql> select @@binlog_format;
+-----------------+
| @@binlog_format |
+-----------------+
| MIXED           |
+-----------------+
1 row in set (0.00 sec)

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

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 17
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> select @@binlog_format;
+-----------------+
| @@binlog_format |
+-----------------+
| ROW             |
+-----------------+
1 row in set (0.00 sec)


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

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

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 18
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> select @@binlog_format;
+-----------------+
| @@binlog_format |
+-----------------+
| MIXED           |
+-----------------+
1 row in set (0.00 sec)

单个客户端通过设置binlog_format会话值可以控制自己语句的日志格式:

mysql> SET SESSION binlog_format = 'STATEMENT';
mysql> SET SESSION binlog_format = 'ROW';
mysql> SET SESSION binlog_format = 'MIXED';

每个MySQL服务器都可以设置自己的并且只有自己的二进制日志格式(无论binlog_format是用全局还是会话范围设置的)。这意味着更改复制主服务器上的日志格式并不会导致从服务器更改日志格式以匹配。(使用语句模式时,不复制binlog_format系统变量;当使用混合或行日志记录模式时,它被复制,但被从服务器忽略)。在复制正在进行时更改主服务器上的二进制日志格式,或者不更改从服务器上的日志格式,都可能导致复制失败,出现错误比如:

Error executing row event: 'Cannot execute statement: impossible to write to binary log since statement is in row format and BINLOG_FORMAT= STATEMENT.'

为了修改全局或会话级binlog_format值,必须要有super权限。客户端可能希望在每个会话的基础上设置二进制日志记录的原因有几个:
.对数据库进行许多小更改的会话可能希望使用基于行的日志记录
.执行与WHERE子句中的许多行匹配的更新的会话可能希望使用基于语句的日志记录,因为记录几个语句比记录许多行更有效
.有些语句需要在主服务器上执行大量时间,但是只修改了几行。因此,使用基于行的日志记录来复制它们可能是有益的

在出现以下情况时您无法在运行时切换复制格式时:
.从存储的函数或触发器中
.如果启用了NDB存储引擎
.如果会话当前处于基于行的复制模式,并且有打开的临时表

尝试在这些情况中切换格式会导致错误.

如果当前正在使用InnoDB表并且事务隔离级别为read committed或read uncommitted时,只能使用基于行的日志记录。它可以修改日志格式为基于语句的日志,但是在运行时这样做会导致很快就会出错因为InnoDB不能再执行插入。

当存在任何临时表时,不建议在运行时切换复制格式,因为仅在使用基于语句的复制时才记录临时表,而使用基于行的复制时则不记录临时表。对于混合复制,通常会记录临时表;除非使用用户定义函数(udf)和UUID()函数。

将二进制日志格式设置为ROW后,使用基于行的格式将许多更改写入二进制日志。但是,有些更改仍然使用基于语句的格式。例如包括所有DDL(数据定义语言)语句,如CREATE TABLE、ALTER TABLE或DROP TABLE。

对于能够进行基于行的复制的服务器,可以使用——binlog-row-event-max-size选项。行以块的形式存储到二进制日志中,块的大小(以字节为单位)不超过此选项的值。该值必须是256的倍数。默认值是8192。

在使用基于语句的日志记录进行复制时,如果语句设计为数据修改是不确定的,则主从上的数据可能会有所不同;也就是说,它由查询优化器决定。通常,即使在复制之外,这也不是一个好的实践。

Mixed Binary Logging Format
当以混合日志格式运行时,服务器在以下条件下自动从基于语句的日志切换到基于行的日志:
.当一个函数包含UUID()。
.当一个或多个表使用AUTO_INCREMENT列被更新并且有一个触发器或存储函数被调用时,像其它不安全语句一样,如果binlog_format=STATEMENT会生成警告。
.当视图主体需要基于行的复制时,创建视图的语句也会使用它。例如,当创建视图的语句使用UUID()函数时,就会发生这种情况
.当涉及到对UDF的调用时
.如果一个语句是按行记录的,并且执行该语句的会话有任何临时表,则按行记录将用于所有后续语句(访问临时表的语句除外),直到该会话使用的所有临时表都被删除为止。不管是否实际记录了任何临时表,his都是正确的。无法使用基于行的格式记录临时表;因此,一旦使用了基于行的日志记录,使用该表的所有后续语句都是不安全的。服务器通过将会话期间执行的所有语句视为不安全的,直到会话不再持有任何临时表,从而近似于这种情况。
.使用FOUND_ROWS()或ROW_COUNT()时
.当使用USER()、CURRENT_USER()或CURRENT_USER时
.当一个语句引用一个或多个系统变量时

例外:以下系统变量在与会话范围(仅)一起使用时,不会导致日志格式切换

 auto_increment_increment
 auto_increment_offset
 character_set_client
 character_set_connection
 character_set_database
 character_set_server
 collation_connection
 collation_database
 collation_server
 foreign_key_checks
 identity
 last_insert_id
 lc_time_names
 pseudo_thread_id
 sql_auto_is_null
 time_zone
 timestamp
 unique_checks

.当其中一个表是mysql数据库中的日志表时
.使用LOAD_FILE()函数时

注意:
如果您试图使用基于语句的日志记录来执行应该使用基于行的日志记录的语句,则会生成一个警告。该警告在客户机中(在SHOW WARNINGS的输出中)和通过mysqld错误日志显示。每次执行这样的语句时,都会向SHOW WARNINGS表添加一个警告。但是,只有为每个客户端会话生成警告的第一个语句被写入错误日志,以防止日志泛滥。

除了上面的决策之外,各个引擎还可以确定在更新表中的信息时使用的日志格式。单个引擎的日志功能可以定义如下:
.如果一个引擎支持基于行的日志记录,则该引擎被认为是支持行日志记录的。
.如果一个引擎支持基于语句的日志记录,那么该引擎就被称为支持语句日志记录

给定的存储引擎可以支持日志格式中的一种或两种。下表列出了每个引擎支持的格式:

存储引擎                           支持基于行日志记录                支持基于语句日志记录
ARCHIVE                            Yes                               Yes
BLACKHOLE                          Yes                               Yes
CSV                                Yes                               Yes
EXAMPLE                            Yes                               NO
FEDERATED                          Yes                               Yes
HEAP                               Yes                               Yes
InnoDB                             Yes                               当事务隔离级别为REPEATABLE READ或SERIALIZABLE时为Yes
                                                                     否则为No
MyISAM                             Yes                               Yes
MERGE                              Yes                               Yes
NDB                                Yes                               No

要记录语句和使用的日志模式是根据语句的类型(安全的、不安全的或二进制注入的)、二进制日志格式(语句、行或混合的)和存储引擎的日志功能(语句支持、行支持、两者都支持或两者都不支持)来确定的。(二进制注入指的是记录必须使用行格式记录的更改。)

语句可能被记录,也可能没有警告;失败的语句不会被记录,但会在日志中生成错误。这在下面的决策表中显示,其中SLC表示“支持语句日志记录”,RLC表示“支持行日志记录”。

当确定产生一个警告时,就会产生一个标准的MySQL警告(可以使用SHOW WARNINGS)。信息也被写入mysqld错误日志。对于每个客户端连接的每个错误实例,只记录一个错误,以防止日志泛滥。日志消息包括尝试的SQL语句。

如果从服务器启动时使用log_error_verbosity设置来显示警告,从服务器会打印消息到错误日志中来提供状态信息,比如例如二进制日志和中继日志坐标,它在何处开始工作,何时切换到另一个中继日志,何时在断开连接后重新连接,对于基于语句的日志记录不安全的语句,等等。

改变mysql数据库表的日志格式
mysql数据库授权表中的内容可以直接(使用insert或delete)或间接(使用grant或create user)修改。影响mysql数据库表的语句会使用以下规则写入binary log:
.根据设置的binlog_format系统变量对mysql数据库表进行数据修改的维护语句直接被记录。这与语句有关比如insert,update,delete,replace,do,load data infile,select和truncate table。

.对mysql数据库进行修改的语句会间接地作为语句被记录而不管binlog_format的设置。这与语句有关比如grant,revoke,set password,rename user,create(除了create table … select之外的所有形式),alter(所有形式)和drop(所有形式)。

create table … select它是由数据定义和数据维护语句组成的。create table部分使用语句格式被记录而select部分根据binlog_format设置情况来记录。

]]>
http://www.jydba.net/index.php/archives/3350/feed 0
MySQL 通用查询日志 http://www.jydba.net/index.php/archives/3348 http://www.jydba.net/index.php/archives/3348#respond Tue, 22 Feb 2022 00:31:34 +0000 http://www.jydba.net/?p=3348 通用查询日志是mysqld所生成的记录。当客户端连接或断开时和从客户端接收到每个SQL语句时服务器会写信息到通用查询日志。当怀疑客户端有错误并且想了解客户端发送给mysqld的信息时通用查询日志非常有用。

当一个客户端连接时显示的每一行也包括using connection_type来指示建立连接的协议。connection_type是TCP/IP(不使用SSL的TCP/IP连接),SSL/TLS(使用SSL的TCP/IP连接),Socket(Unix socket file连接),Named Pipe(Windows命名管道连接),或Shared Memory(Windows共享内存连接)。

mysqld以它所接收到的语句顺序将它们写入通用查询日志,这可能不同于语句被执行的顺序。这个日志顺序与二进制日志顺序相反,语句会在执行之后但在任何锁被释放之前被写入通用查询日志。另外查询日志可能包含那些只查询数据但从没被写入二进制日志的语句。

当在一个复制主服务器上使用基于语句的二进制日志时,通过从服务器所接收到的语句会被写入每个从服务器的查询日志中。如果客户端使用mysqlbinlog工具读取事件并将它们传递给服务器,那么语句会被写入主服务器的查询日志中。

然而当使用基于行记录的二进制日志时,更新会被当作行改变被发送而不是SQL语句,并且当binlog_format为ROW时这些语句从来不会被写入查询日志。当这个变量设置为MIXED时依赖于语句的使用,指定的更新也可能不会被写入查询日志。

默认情况下,通用查询日志是被禁用的。为了显式指定初始化通用查询日志状态,使用–general_log[={0|1}]。没有参数或者参数为1,–general_log启用日志。当这个参数为0,这个选项将禁用日志。为了指定一个日志文件名,使用–general_log_file=file_name。为了指定日志目录,使用–log-output。

如果对通用查询日志文件没有指定文件名,默认名字为host_name.log。除非指定一个绝对路径来指定不同的目录否则服务器将在数据目录中创建日志文件名。

为了在运行时禁用或启用通用查询日志或改变日志文件名,使用全局general_log和general_log_file系统变量。设置general_log为0(或OFF)来禁用日志或1(或ON)来启用日志。设置general_log_file指定日志文件名。如果一个日志文件已经被opne,将会关闭它并打开新文件。

当通用查询日志被启用时,服务器将输出写入到由–log-output选项或log_output系统变量所指定的任何目录。如果启用日志,服务器将打开日志文件并将启动信息写入日志文件。然而除非FILE日志目录被选定否则更多的查询日志不会写入日志文件。如果日志目录为NONE,即使通用查询日志被启用服务器也不会将查询写入日志文件。如果日志目录值不包括FILE,设置日志文件名不会影响日志记录。

服务器重启和日志刷新不会导致生成新的通用查询日志文件(虽然刷新会关闭和重新打开日志文件)。为了重命名文件并创建新文件,使用以下命令:

shell> mv host_name.log host_name-old.log
shell> mysqladmin flush-logs
shell> mv host_name-old.log backup-directory

在Windows上,使用rename而不是mv

通过禁用日志也可以在运行时重命名通用查询日志

set global general_log='OFF';

当禁用日志后,在外部重命名日志文件,例如,通过命令行。然后再次启用日志:

set global general_log='ON';

这种方法可以在任何平台上工作并且不需要重启服务器。

对于当前连接会话级变量sql_log_off可以被设置为ON或OFF来启用或禁用通用查询日志。

写入通用查询日志的语句中的密码由服务器重写,不会以明文形式出现。密码重写对于通用查询日志来说是可以禁上的通过在服务器启动时使用–log-raw选项。这个选项对于诊断来说非常有用,为了查看服务器所接收到的精确语句文本,但由于安全原因不建议在生产环境中使用。

密码重写的一个含义是,不能被解析的语句(例如,由于语法错误)不会被写入通用查询日志,因为它们不能被认为是没有密码的。需要记录所有语句(包括有错误的语句)的用例应该使用——log-raw选项,记住这也可以绕过密码重写。

只有在预期使用纯文本密码时才会发生密码重写。对于具有期望密码散列值的语法的语句,不发生重写。如果为这种语法错误地提供了纯文本密码,则按给定的方式记录密码,而不进行重写。例如,如下所示记录下的语句,因为需要密码散列值

CREATE USER 'user1'@'localhost' IDENTIFIED BY PASSWORD 'not-so-secret';

log_timestamps系统变量控制首写入通用查询日志中信息的时区(对慢查询日志文件和错误日志也一样)。它不会影响写入日志表中的通用查询日志和慢查询日志信息的时区,但从这些表中检索行记录使用convert_tz()或设置会话变量time_zone系统变量可以将本地系统时区转换为任何你所期待的时区。

]]>
http://www.jydba.net/index.php/archives/3348/feed 0
MySQL Slow Query log(慢查询日志) http://www.jydba.net/index.php/archives/3346 http://www.jydba.net/index.php/archives/3346#respond Tue, 22 Feb 2022 00:29:09 +0000 http://www.jydba.net/?p=3346 慢查询日志由执行时间超过long_query_time秒且至少有min_examined_row_limit行被检查的SQL语句组成。long_query_time的最小值与默认值为0和10。它也可以指定为微秒。对于写入文件的日志,时间信息会被记录并且包含微秒部分。对于写入日志表的记录,只有整数时间被记录,微秒部分被忽略。

默认情况下,管理语句不会被记录,也不会记录不使用索引进行查询的语句。可以使用log_slow_admin_statements和log_queries_not_using_indexes来改变这种行为。

获取初始锁的时间不计算为执行时间。mysqld会在语句执行完成和所有锁被释放完成后将语句写入慢查询日志,因此日志顺序可能与语句的执行顺序不一致。

默认情况下,慢查询日志是被禁用的。为了显式指定初始化慢查询日志状态,使用–slow_query_log={0|1}。不使用参数值或参数值为1时,–slow_query_log启用日志。使用参数值为0时,禁用日志。为了指定慢查询日志文件名,使用–slow_query_log_file=file_name。为了指定日志目录,使用–log-output。

mysql> show variables like 'slow_query%';
+---------------------+-------------------------------------+
| Variable_name       | Value                               |
+---------------------+-------------------------------------+
| slow_query_log      | OFF                                 |
| slow_query_log_file | /mysqldata/mysql/localhost-slow.log |
+---------------------+-------------------------------------+
2 rows in set (0.01 sec)


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

如果没有为慢查询日志文件指定文件名,默认文件名为host_name-slow.log。除非使用绝对路私名指定不同的目录否则将在数据目录下创建默认文件。

为了禁用或启用慢查询日志或在运行时改变日志文件名,使用全局的slow_query_log和slow_query_log_file系统变量。设置slow_query_log为0(或OFF)来禁用日志,设置为1(或ON)来启用日志。设置slow_query_log_file来指定日志文件名。如果一个日志文件已经打开 ,它将关闭再打开新文件。

当慢查询日志被启用时,服务器将输出写入到由–log-output选项或log_output系统变量所指定的任何目录中。如果启用了日志,服务器打开日志文件并将启动信息写入文件中。然而,除非FILE日志目录被选择否则查询的进一步日志不会记录在文件中。如果目录为NONE,即使慢查询日志被启用也不会记录查询。如果日志目录不包含FILE,设置日志文件名不会影响日志功能。

如果使用–log-short-format选项,服务器会写少量信息到慢查询日志中。

为了在写入到慢查询日志中的语句中包含慢速管理语句,使用log_slow_admin_statements系统变量。管理语句包括alter table,
analyze table,check table,create index, drop index,optimizer table和repair table。

为了将不使用索引的语句写入慢查询日志中,可以启用log_queries_not_using_indexes系统变量。当这样的查询被写入时,慢查询日志可能增长很快。通过设置log_throttle_queries_not_using_indexes系统变量来对这些查询设置速率限制是有可能的。默认情况下,这个变量为0,这意味着没有限制。正值对不使用索引的查询的日志记录施加了每分钟的限制。第一个这样的查询打开一个60秒的窗口,在这个窗口内,服务器将查询记录到给定的限制,然后抑制其他查询。如果在窗口结束时存在被抑制的查询,服务器将记录一个摘要,指出有多少查询以及在这些查询中花费的累计时间。当服务器记录下一个不使用索引的查询时,下一个60秒窗口开始。

服务器按照以下顺序使用控制参数来决定是否向慢速查询日志写入查询:
1.查询必须不是管理语句或者log_slow_admin_statements必须被启用。
2.查询必须至少花了long_query_time所设定的秒数或者启用log_queries_not_using_indexes和没有使用索引的查询
3.查询必须至少检查了min_examined_row_limit所设置的行数。
4.根据log_throttle_queries_not_using_indexes设置必须不能被禁止。

log_timestamps系统变量控制着写入慢查询日志(通用查询日志和错误日志也一样)中信息所包含的时间戳中的时区信息。它不会影响写入通用查询日志和写入日志表中慢查询日志信息中的时区信息,但从这些日志表中检索数据通过使用convert_tz()或通过设置time_zone系统变量可以从本地系统时区转换成你所期待的任何时区。

所有日志行都包含一个时间戳。

服务器不会将由查询缓存处理的查询写入慢速查询日志,也不会将由于表只有零行或一行而无法从索引中获益的查询写入慢速查询日志。

默认情况下,复制从服务器不会将复制的查询写入慢速查询日志。为了改变这种行为,可以使用log_slow_slave_statements系统变量。

写入慢速查询日志的语句中的密码由服务器重写,不会以明文形式出现。

慢速查询日志可用于查找执行时间较长的查询,因此可以进行优化。然而,检查一个长的慢查询日志可能成为一项困难的任务。为了简化这一过程,可以使用mysqldumpslow命令处理一个慢速查询日志文件,以总结日志中出现的查询

]]>
http://www.jydba.net/index.php/archives/3346/feed 0
MySQl 配置InnoDB持久化的优化器统计信息 http://www.jydba.net/index.php/archives/3342 http://www.jydba.net/index.php/archives/3342#respond Sun, 20 Feb 2022 08:05:37 +0000 http://www.jydba.net/?p=3342 配置InnoDB的优化器统计信息
介绍如何为InnoDB表配置持久化和非持久化的优化器统计信息。

持久性优化器统计数据将被持久保存可以跨跃服务器的重启,从而实现更大的计划稳定性和更一致的查询性能。持久性优化器统计数据还提供了控制和灵活性以及这些额外的好处:
.您可以使用innodb_stats_auto_recalc配置选项来控制是否在对表进行重大更改后自动更新统计信息

.您可以使用STATS_PERSISTENT、STATS_AUTO_RECALC和STATS_SAMPLE_PAGES子句以及CREATE TABLE和ALTER TABLE语句为单个表配置优化器统计信息

.您可以在mysql.innodb_table_stats和mysql.innodb_index_stats表中查询优化器的统计数据

mysql> select * from mysql.innodb_table_stats;
ERROR 2006 (HY000): MySQL server has gone away
No connection. Trying to reconnect...
Connection id:    6
Current database: mysql

+---------------+-------------------+---------------------+--------+----------------------+--------------------------+
| database_name | table_name        | last_update         | n_rows | clustered_index_size | sum_of_other_index_sizes |
+---------------+-------------------+---------------------+--------+----------------------+--------------------------+
| cs            | address           | 2021-06-03 16:17:22 |      3 |                    1 |                        0 |
| cs            | articles          | 2021-01-12 16:39:07 |      2 |                    1 |                        0 |
| cs            | bit_test          | 2021-06-18 16:28:55 |      2 |                    1 |                        0 |
| cs            | individual        | 2021-05-27 17:20:38 |      8 |                    1 |                        0 |
| cs            | person            | 2021-06-03 16:13:47 |      2 |                    1 |                        0 |
| cs            | person1           | 2021-05-27 17:02:34 |      3 |                    1 |                        0 |
| cs            | rewrite_rules     | 2020-07-15 17:34:15 |      3 |                    1 |                        0 |
| cs            | sequence          | 2021-01-18 10:45:15 |      0 |                    1 |                        0 |
| cs            | t                 | 2021-09-13 22:27:49 |      0 |                    1 |                        0 |
| cs            | t1                | 2021-07-06 16:00:24 |      2 |                    1 |                        0 |
| cs            | test              | 2021-06-23 15:47:12 |      0 |                    1 |                        0 |
| cs            | test2             | 2021-06-23 15:57:48 |      2 |                    1 |                        0 |
| d1            | T1                | 2021-08-06 17:16:37 |      0 |                    1 |                        0 |
| d1            | child             | 2021-08-17 16:27:43 |      2 |                    1 |                        0 |
| d1            | t                 | 2021-08-17 17:30:55 |      0 |                    1 |                        0 |
| d1            | t1                | 2021-08-09 16:18:51 |      0 |                    1 |                        0 |
| mysql         | articles          | 2021-01-08 15:21:02 |      8 |                    1 |                        1 |
| mysql         | child             | 2021-03-01 11:39:44 |      0 |                    1 |                        1 |
| mysql         | client_firms#P#r0 | 2021-03-01 10:13:09 |      0 |                    1 |                        0 |
| mysql         | client_firms#P#r1 | 2021-03-01 10:13:09 |      0 |                    1 |                        0 |
| mysql         | client_firms#P#r2 | 2021-03-01 10:13:09 |      0 |                    1 |                        0 |
| mysql         | client_firms#P#r3 | 2021-03-01 10:13:09 |      0 |                    1 |                        0 |
| mysql         | count             | 2020-01-06 10:45:24 |      0 |                    1 |                        0 |
| mysql         | cs                | 2020-04-02 18:58:57 |      0 |                    1 |                        0 |
| mysql         | customer          | 2021-03-01 11:43:54 |      0 |                    1 |                        0 |
| mysql         | gtid_executed     | 2019-06-17 14:28:37 |      0 |                    1 |                        0 |
| mysql         | imptest           | 2019-10-28 11:47:04 |      2 |                    1 |                        0 |
| mysql         | jemp              | 2021-04-26 08:12:27 |      4 |                    1 |                        1 |
| mysql         | lc#P#p0           | 2021-03-01 10:20:18 |      0 |                    1 |                        0 |
| mysql         | lc#P#p1           | 2021-03-01 10:20:18 |      0 |                    1 |                        0 |
| mysql         | lc#P#p2           | 2021-03-01 10:20:18 |      0 |                    1 |                        0 |
| mysql         | lc#P#p3           | 2021-03-01 10:20:18 |      0 |                    1 |                        0 |
| mysql         | my_stopwords      | 2021-01-08 16:42:36 |      0 |                    1 |                        0 |
| mysql         | new_table         | 2021-01-13 16:53:36 |      0 |                    1 |                        0 |
| mysql         | opening_lines     | 2021-01-08 16:46:10 |      8 |                    1 |                        1 |
| mysql         | parent            | 2021-03-01 11:39:33 |      0 |                    1 |                        0 |
| mysql         | product           | 2021-03-01 11:43:50 |      0 |                    1 |                        0 |
| mysql         | product_order     | 2021-03-01 11:44:23 |      0 |                    1 |                        2 |
| mysql         | rc#P#p0           | 2021-02-26 11:21:58 |      0 |                    1 |                        0 |
| mysql         | rc#P#p1           | 2021-02-26 11:21:58 |      0 |                    1 |                        0 |
| mysql         | rc#P#p2           | 2021-02-26 11:21:58 |      0 |                    1 |                        0 |
| mysql         | rc#P#p3           | 2021-02-26 11:21:58 |      0 |                    1 |                        0 |
| mysql         | rc#P#p4           | 2021-02-26 11:21:58 |      0 |                    1 |                        0 |
| mysql         | sales             | 2021-01-20 17:00:50 |      0 |                    1 |                        0 |
| mysql         | t                 | 2021-04-26 15:37:14 |      0 |                    1 |                        0 |
| mysql         | t1                | 2021-04-26 11:04:17 |      0 |                    1 |                        0 |
| mysql         | t2                | 2021-04-26 11:05:46 |      0 |                    1 |                        0 |
| mysql         | t3                | 2021-04-26 11:05:58 |      0 |                    1 |                        0 |
| mysql         | t4                | 2021-04-26 11:11:41 |      0 |                    1 |                        0 |
| mysql         | t5                | 2020-10-10 16:24:57 |      0 |                    1 |                        0 |
| mysql         | test              | 2020-01-07 10:56:04 |      0 |                    1 |                        0 |
| mysql         | total             | 2021-02-19 15:22:54 |      0 |                    1 |                        0 |
| mysql         | triangle          | 2021-03-01 14:57:31 |      3 |                    1 |                        0 |
| query_rewrite | rewrite_rules     | 2020-07-15 16:36:38 |      3 |                    1 |                        0 |
| sys           | sys_config        | 2019-06-17 14:28:41 |      6 |                    1 |                        0 |
+---------------+-------------------+---------------------+--------+----------------------+--------------------------+
55 rows in set (0.04 sec)

mysql> select * from mysql.innodb_index_stats;
+---------------+-------------------+------------------+---------------------+--------------+------------+-------------+-----------------------------------+
| database_name | table_name        | index_name       | last_update         | stat_name    | stat_value | sample_size | stat_description                  |
+---------------+-------------------+------------------+---------------------+--------------+------------+-------------+-----------------------------------+
| cs            | address           | PRIMARY          | 2021-06-03 16:17:22 | n_diff_pfx01 |          3 |           1 | address_id                        |
| cs            | address           | PRIMARY          | 2021-06-03 16:17:22 | n_leaf_pages |          1 |        NULL | Number of leaf pages in the index |
| cs            | address           | PRIMARY          | 2021-06-03 16:17:22 | size         |          1 |        NULL | Number of pages in the index      |
| cs            | articles          | GEN_CLUST_INDEX  | 2021-01-12 16:39:07 | n_diff_pfx01 |          2 |           1 | DB_ROW_ID                         |
| cs            | articles          | GEN_CLUST_INDEX  | 2021-01-12 16:39:07 | n_leaf_pages |          1 |        NULL | Number of leaf pages in the index |
| cs            | articles          | GEN_CLUST_INDEX  | 2021-01-12 16:39:07 | size         |          1 |        NULL | Number of pages in the index      |
| cs            | bit_test          | GEN_CLUST_INDEX  | 2021-06-18 16:28:55 | n_diff_pfx01 |          2 |           1 | DB_ROW_ID                         |
| cs            | bit_test          | GEN_CLUST_INDEX  | 2021-06-18 16:28:55 | n_leaf_pages |          1 |        NULL | Number of leaf pages in the index |
| cs            | bit_test          | GEN_CLUST_INDEX  | 2021-06-18 16:28:55 | size         |          1 |        NULL | Number of pages in the index      |
| cs            | individual        | PRIMARY          | 2021-05-27 17:20:38 | n_diff_pfx01 |          8 |           1 | individual_id                     |
| cs            | individual        | PRIMARY          | 2021-05-27 17:20:38 | n_leaf_pages |          1 |        NULL | Number of leaf pages in the index |
| cs            | individual        | PRIMARY          | 2021-05-27 17:20:38 | size         |          1 |        NULL | Number of pages in the index      |
| cs            | person            | PRIMARY          | 2021-06-03 16:13:47 | n_diff_pfx01 |          2 |           1 | person_id                         |
| cs            | person            | PRIMARY          | 2021-06-03 16:13:47 | n_leaf_pages |          1 |        NULL | Number of leaf pages in the index |
| cs            | person            | PRIMARY          | 2021-06-03 16:13:47 | size         |          1 |        NULL | Number of pages in the index      |
| cs            | person1           | PRIMARY          | 2021-05-27 17:02:34 | n_diff_pfx01 |          3 |           1 | person_id                         |
| cs            | person1           | PRIMARY          | 2021-05-27 17:02:34 | n_leaf_pages |          1 |        NULL | Number of leaf pages in the index |
| cs            | person1           | PRIMARY          | 2021-05-27 17:02:34 | size         |          1 |        NULL | Number of pages in the index      |
| cs            | rewrite_rules     | PRIMARY          | 2020-07-15 17:34:15 | n_diff_pfx01 |          3 |           1 | id                                |
| cs            | rewrite_rules     | PRIMARY          | 2020-07-15 17:34:15 | n_leaf_pages |          1 |        NULL | Number of leaf pages in the index |
| cs            | rewrite_rules     | PRIMARY          | 2020-07-15 17:34:15 | size         |          1 |        NULL | Number of pages in the index      |
| cs            | sequence          | GEN_CLUST_INDEX  | 2021-01-18 10:45:15 | n_diff_pfx01 |          0 |           1 | DB_ROW_ID                         |
| cs            | sequence          | GEN_CLUST_INDEX  | 2021-01-18 10:45:15 | n_leaf_pages |          1 |        NULL | Number of leaf pages in the index |
| cs            | sequence          | GEN_CLUST_INDEX  | 2021-01-18 10:45:15 | size         |          1 |        NULL | Number of pages in the index      |
| cs            | t                 | GEN_CLUST_INDEX  | 2021-09-13 22:27:49 | n_diff_pfx01 |          0 |           1 | DB_ROW_ID                         |
| cs            | t                 | GEN_CLUST_INDEX  | 2021-09-13 22:27:49 | n_leaf_pages |          1 |        NULL | Number of leaf pages in the index |
| cs            | t                 | GEN_CLUST_INDEX  | 2021-09-13 22:27:49 | size         |          1 |        NULL | Number of pages in the index      |
| cs            | t1                | GEN_CLUST_INDEX  | 2021-07-06 16:00:24 | n_diff_pfx01 |          2 |           1 | DB_ROW_ID                         |
| cs            | t1                | GEN_CLUST_INDEX  | 2021-07-06 16:00:24 | n_leaf_pages |          1 |        NULL | Number of leaf pages in the index |
| cs            | t1                | GEN_CLUST_INDEX  | 2021-07-06 16:00:24 | size         |          1 |        NULL | Number of pages in the index      |
| cs            | test              | PRIMARY          | 2021-06-23 15:47:12 | n_diff_pfx01 |          0 |           1 | id                                |
| cs            | test              | PRIMARY          | 2021-06-23 15:47:12 | n_leaf_pages |          1 |        NULL | Number of leaf pages in the index |
| cs            | test              | PRIMARY          | 2021-06-23 15:47:12 | size         |          1 |        NULL | Number of pages in the index      |
| cs            | test2             | PRIMARY          | 2021-06-23 15:57:48 | n_diff_pfx01 |          1 |           1 | id                                |
| cs            | test2             | PRIMARY          | 2021-06-23 15:57:48 | n_diff_pfx02 |          2 |           1 | id,ts                             |
| cs            | test2             | PRIMARY          | 2021-06-23 15:57:48 | n_leaf_pages |          1 |        NULL | Number of leaf pages in the index |
| cs            | test2             | PRIMARY          | 2021-06-23 15:57:48 | size         |          1 |        NULL | Number of pages in the index      |
| d1            | T1                | GEN_CLUST_INDEX  | 2021-08-06 17:16:37 | n_diff_pfx01 |          0 |           1 | DB_ROW_ID                         |
| d1            | T1                | GEN_CLUST_INDEX  | 2021-08-06 17:16:37 | n_leaf_pages |          1 |        NULL | Number of leaf pages in the index |
| d1            | T1                | GEN_CLUST_INDEX  | 2021-08-06 17:16:37 | size         |          1 |        NULL | Number of pages in the index      |
| d1            | child             | PRIMARY          | 2021-08-17 16:27:43 | n_diff_pfx01 |          2 |           1 | id                                |
| d1            | child             | PRIMARY          | 2021-08-17 16:27:43 | n_leaf_pages |          1 |        NULL | Number of leaf pages in the index |
| d1            | child             | PRIMARY          | 2021-08-17 16:27:43 | size         |          1 |        NULL | Number of pages in the index      |
| d1            | t                 | GEN_CLUST_INDEX  | 2021-08-17 17:30:55 | n_diff_pfx01 |          0 |           1 | DB_ROW_ID                         |
| d1            | t                 | GEN_CLUST_INDEX  | 2021-08-17 17:30:55 | n_leaf_pages |          1 |        NULL | Number of leaf pages in the index |
| d1            | t                 | GEN_CLUST_INDEX  | 2021-08-17 17:30:55 | size         |          1 |        NULL | Number of pages in the index      |
| d1            | t1                | GEN_CLUST_INDEX  | 2021-08-09 16:18:51 | n_diff_pfx01 |          0 |           1 | DB_ROW_ID                         |
| d1            | t1                | GEN_CLUST_INDEX  | 2021-08-09 16:18:51 | n_leaf_pages |          1 |        NULL | Number of leaf pages in the index |
| d1            | t1                | GEN_CLUST_INDEX  | 2021-08-09 16:18:51 | size         |          1 |        NULL | Number of pages in the index      |
| mysql         | articles          | FTS_DOC_ID_INDEX | 2021-01-08 15:21:02 | n_diff_pfx01 |          8 |           1 | FTS_DOC_ID                        |
| mysql         | articles          | FTS_DOC_ID_INDEX | 2021-01-08 15:21:02 | n_leaf_pages |          1 |        NULL | Number of leaf pages in the index |
| mysql         | articles          | FTS_DOC_ID_INDEX | 2021-01-08 15:21:02 | size         |          1 |        NULL | Number of pages in the index      |
| mysql         | articles          | PRIMARY          | 2021-01-08 15:21:02 | n_diff_pfx01 |          8 |           1 | id                                |
| mysql         | articles          | PRIMARY          | 2021-01-08 15:21:02 | n_leaf_pages |          1 |        NULL | Number of leaf pages in the index |
| mysql         | articles          | PRIMARY          | 2021-01-08 15:21:02 | size         |          1 |        NULL | Number of pages in the index      |
| mysql         | child             | GEN_CLUST_INDEX  | 2021-03-01 11:39:44 | n_diff_pfx01 |          0 |           1 | DB_ROW_ID                         |
| mysql         | child             | GEN_CLUST_INDEX  | 2021-03-01 11:39:44 | n_leaf_pages |          1 |        NULL | Number of leaf pages in the index |
| mysql         | child             | GEN_CLUST_INDEX  | 2021-03-01 11:39:44 | size         |          1 |        NULL | Number of pages in the index      |
| mysql         | child             | par_ind          | 2021-03-01 11:39:44 | n_diff_pfx01 |          0 |           1 | parent_id                         |
| mysql         | child             | par_ind          | 2021-03-01 11:39:44 | n_diff_pfx02 |          0 |           1 | parent_id,DB_ROW_ID               |
| mysql         | child             | par_ind          | 2021-03-01 11:39:44 | n_leaf_pages |          1 |        NULL | Number of leaf pages in the index |
| mysql         | child             | par_ind          | 2021-03-01 11:39:44 | size         |          1 |        NULL | Number of pages in the index      |
| mysql         | client_firms#P#r0 | GEN_CLUST_INDEX  | 2021-03-01 10:13:09 | n_diff_pfx01 |          0 |           1 | DB_ROW_ID                         |
| mysql         | client_firms#P#r0 | GEN_CLUST_INDEX  | 2021-03-01 10:13:09 | n_leaf_pages |          1 |        NULL | Number of leaf pages in the index |
| mysql         | client_firms#P#r0 | GEN_CLUST_INDEX  | 2021-03-01 10:13:09 | size         |          1 |        NULL | Number of pages in the index      |
| mysql         | client_firms#P#r1 | GEN_CLUST_INDEX  | 2021-03-01 10:13:09 | n_diff_pfx01 |          0 |           1 | DB_ROW_ID                         |
| mysql         | client_firms#P#r1 | GEN_CLUST_INDEX  | 2021-03-01 10:13:09 | n_leaf_pages |          1 |        NULL | Number of leaf pages in the index |
| mysql         | client_firms#P#r1 | GEN_CLUST_INDEX  | 2021-03-01 10:13:09 | size         |          1 |        NULL | Number of pages in the index      |
| mysql         | client_firms#P#r2 | GEN_CLUST_INDEX  | 2021-03-01 10:13:09 | n_diff_pfx01 |          0 |           1 | DB_ROW_ID                         |
| mysql         | client_firms#P#r2 | GEN_CLUST_INDEX  | 2021-03-01 10:13:09 | n_leaf_pages |          1 |        NULL | Number of leaf pages in the index |
| mysql         | client_firms#P#r2 | GEN_CLUST_INDEX  | 2021-03-01 10:13:09 | size         |          1 |        NULL | Number of pages in the index      |
| mysql         | client_firms#P#r3 | GEN_CLUST_INDEX  | 2021-03-01 10:13:09 | n_diff_pfx01 |          0 |           1 | DB_ROW_ID                         |
| mysql         | client_firms#P#r3 | GEN_CLUST_INDEX  | 2021-03-01 10:13:09 | n_leaf_pages |          1 |        NULL | Number of leaf pages in the index |
| mysql         | client_firms#P#r3 | GEN_CLUST_INDEX  | 2021-03-01 10:13:09 | size         |          1 |        NULL | Number of pages in the index      |
| mysql         | count             | GEN_CLUST_INDEX  | 2020-01-06 10:45:24 | n_diff_pfx01 |          0 |           1 | DB_ROW_ID                         |
| mysql         | count             | GEN_CLUST_INDEX  | 2020-01-06 10:45:24 | n_leaf_pages |          1 |        NULL | Number of leaf pages in the index |
| mysql         | count             | GEN_CLUST_INDEX  | 2020-01-06 10:45:24 | size         |          1 |        NULL | Number of pages in the index      |
| mysql         | cs                | GEN_CLUST_INDEX  | 2020-04-02 18:58:57 | n_diff_pfx01 |          0 |           1 | DB_ROW_ID                         |
| mysql         | cs                | GEN_CLUST_INDEX  | 2020-04-02 18:58:57 | n_leaf_pages |          1 |        NULL | Number of leaf pages in the index |
| mysql         | cs                | GEN_CLUST_INDEX  | 2020-04-02 18:58:57 | size         |          1 |        NULL | Number of pages in the index      |
| mysql         | customer          | PRIMARY          | 2021-03-01 11:43:54 | n_diff_pfx01 |          0 |           1 | id                                |
| mysql         | customer          | PRIMARY          | 2021-03-01 11:43:54 | n_leaf_pages |          1 |        NULL | Number of leaf pages in the index |
| mysql         | customer          | PRIMARY          | 2021-03-01 11:43:54 | size         |          1 |        NULL | Number of pages in the index      |
| mysql         | gtid_executed     | PRIMARY          | 2019-06-17 14:28:37 | n_diff_pfx01 |          0 |           1 | source_uuid                       |
| mysql         | gtid_executed     | PRIMARY          | 2019-06-17 14:28:37 | n_diff_pfx02 |          0 |           1 | source_uuid,interval_start        |
| mysql         | gtid_executed     | PRIMARY          | 2019-06-17 14:28:37 | n_leaf_pages |          1 |        NULL | Number of leaf pages in the index |
| mysql         | gtid_executed     | PRIMARY          | 2019-06-17 14:28:37 | size         |          1 |        NULL | Number of pages in the index      |
| mysql         | imptest           | GEN_CLUST_INDEX  | 2019-10-28 11:47:04 | n_diff_pfx01 |          2 |           1 | DB_ROW_ID                         |
| mysql         | imptest           | GEN_CLUST_INDEX  | 2019-10-28 11:47:04 | n_leaf_pages |          1 |        NULL | Number of leaf pages in the index |
| mysql         | imptest           | GEN_CLUST_INDEX  | 2019-10-28 11:47:04 | size         |          1 |        NULL | Number of pages in the index      |
| mysql         | jemp              | GEN_CLUST_INDEX  | 2021-04-26 08:12:27 | n_diff_pfx01 |          4 |           1 | DB_ROW_ID                         |
| mysql         | jemp              | GEN_CLUST_INDEX  | 2021-04-26 08:12:27 | n_leaf_pages |          1 |        NULL | Number of leaf pages in the index |
| mysql         | jemp              | GEN_CLUST_INDEX  | 2021-04-26 08:12:27 | size         |          1 |        NULL | Number of pages in the index      |
| mysql         | jemp              | i                | 2021-04-26 08:12:27 | n_diff_pfx01 |          4 |           1 | g                                 |
| mysql         | jemp              | i                | 2021-04-26 08:12:27 | n_diff_pfx02 |          4 |           1 | g,DB_ROW_ID                       |
| mysql         | jemp              | i                | 2021-04-26 08:12:27 | n_leaf_pages |          1 |        NULL | Number of leaf pages in the index |
| mysql         | jemp              | i                | 2021-04-26 08:12:27 | size         |          1 |        NULL | Number of pages in the index      |
| mysql         | lc#P#p0           | GEN_CLUST_INDEX  | 2021-03-01 10:20:18 | n_diff_pfx01 |          0 |           1 | DB_ROW_ID                         |
| mysql         | lc#P#p0           | GEN_CLUST_INDEX  | 2021-03-01 10:20:18 | n_leaf_pages |          1 |        NULL | Number of leaf pages in the index |
| mysql         | lc#P#p0           | GEN_CLUST_INDEX  | 2021-03-01 10:20:18 | size         |          1 |        NULL | Number of pages in the index      |
| mysql         | lc#P#p1           | GEN_CLUST_INDEX  | 2021-03-01 10:20:18 | n_diff_pfx01 |          0 |           1 | DB_ROW_ID                         |
| mysql         | lc#P#p1           | GEN_CLUST_INDEX  | 2021-03-01 10:20:18 | n_leaf_pages |          1 |        NULL | Number of leaf pages in the index |
| mysql         | lc#P#p1           | GEN_CLUST_INDEX  | 2021-03-01 10:20:18 | size         |          1 |        NULL | Number of pages in the index      |
| mysql         | lc#P#p2           | GEN_CLUST_INDEX  | 2021-03-01 10:20:18 | n_diff_pfx01 |          0 |           1 | DB_ROW_ID                         |
| mysql         | lc#P#p2           | GEN_CLUST_INDEX  | 2021-03-01 10:20:18 | n_leaf_pages |          1 |        NULL | Number of leaf pages in the index |
| mysql         | lc#P#p2           | GEN_CLUST_INDEX  | 2021-03-01 10:20:18 | size         |          1 |        NULL | Number of pages in the index      |
| mysql         | lc#P#p3           | GEN_CLUST_INDEX  | 2021-03-01 10:20:18 | n_diff_pfx01 |          0 |           1 | DB_ROW_ID                         |
| mysql         | lc#P#p3           | GEN_CLUST_INDEX  | 2021-03-01 10:20:18 | n_leaf_pages |          1 |        NULL | Number of leaf pages in the index |
| mysql         | lc#P#p3           | GEN_CLUST_INDEX  | 2021-03-01 10:20:18 | size         |          1 |        NULL | Number of pages in the index      |
| mysql         | my_stopwords      | GEN_CLUST_INDEX  | 2021-01-08 16:42:36 | n_diff_pfx01 |          0 |           1 | DB_ROW_ID                         |
| mysql         | my_stopwords      | GEN_CLUST_INDEX  | 2021-01-08 16:42:36 | n_leaf_pages |          1 |        NULL | Number of leaf pages in the index |
| mysql         | my_stopwords      | GEN_CLUST_INDEX  | 2021-01-08 16:42:36 | size         |          1 |        NULL | Number of pages in the index      |
| mysql         | new_table         | GEN_CLUST_INDEX  | 2021-01-13 16:53:36 | n_diff_pfx01 |          0 |           1 | DB_ROW_ID                         |
| mysql         | new_table         | GEN_CLUST_INDEX  | 2021-01-13 16:53:36 | n_leaf_pages |          1 |        NULL | Number of leaf pages in the index |
| mysql         | new_table         | GEN_CLUST_INDEX  | 2021-01-13 16:53:36 | size         |          1 |        NULL | Number of pages in the index      |
| mysql         | opening_lines     | FTS_DOC_ID_INDEX | 2021-01-08 16:46:10 | n_diff_pfx01 |          8 |           1 | FTS_DOC_ID                        |
| mysql         | opening_lines     | FTS_DOC_ID_INDEX | 2021-01-08 16:46:10 | n_leaf_pages |          1 |        NULL | Number of leaf pages in the index |
| mysql         | opening_lines     | FTS_DOC_ID_INDEX | 2021-01-08 16:46:10 | size         |          1 |        NULL | Number of pages in the index      |
| mysql         | opening_lines     | PRIMARY          | 2021-01-08 16:46:10 | n_diff_pfx01 |          8 |           1 | id                                |
| mysql         | opening_lines     | PRIMARY          | 2021-01-08 16:46:10 | n_leaf_pages |          1 |        NULL | Number of leaf pages in the index |
| mysql         | opening_lines     | PRIMARY          | 2021-01-08 16:46:10 | size         |          1 |        NULL | Number of pages in the index      |
| mysql         | parent            | PRIMARY          | 2021-03-01 11:39:33 | n_diff_pfx01 |          0 |           1 | id                                |
| mysql         | parent            | PRIMARY          | 2021-03-01 11:39:33 | n_leaf_pages |          1 |        NULL | Number of leaf pages in the index |
| mysql         | parent            | PRIMARY          | 2021-03-01 11:39:33 | size         |          1 |        NULL | Number of pages in the index      |
| mysql         | product           | PRIMARY          | 2021-03-01 11:43:50 | n_diff_pfx01 |          0 |           1 | category                          |
| mysql         | product           | PRIMARY          | 2021-03-01 11:43:50 | n_diff_pfx02 |          0 |           1 | category,id                       |
| mysql         | product           | PRIMARY          | 2021-03-01 11:43:50 | n_leaf_pages |          1 |        NULL | Number of leaf pages in the index |
| mysql         | product           | PRIMARY          | 2021-03-01 11:43:50 | size         |          1 |        NULL | Number of pages in the index      |
| mysql         | product_order     | PRIMARY          | 2021-03-01 11:44:23 | n_diff_pfx01 |          0 |           1 | no                                |
| mysql         | product_order     | PRIMARY          | 2021-03-01 11:44:23 | n_leaf_pages |          1 |        NULL | Number of leaf pages in the index |
| mysql         | product_order     | PRIMARY          | 2021-03-01 11:44:23 | size         |          1 |        NULL | Number of pages in the index      |
| mysql         | product_order     | customer_id      | 2021-03-01 11:44:23 | n_diff_pfx01 |          0 |           1 | customer_id                       |
| mysql         | product_order     | customer_id      | 2021-03-01 11:44:23 | n_diff_pfx02 |          0 |           1 | customer_id,no                    |
| mysql         | product_order     | customer_id      | 2021-03-01 11:44:23 | n_leaf_pages |          1 |        NULL | Number of leaf pages in the index |
| mysql         | product_order     | customer_id      | 2021-03-01 11:44:23 | size         |          1 |        NULL | Number of pages in the index      |
| mysql         | product_order     | product_category | 2021-03-01 11:44:23 | n_diff_pfx01 |          0 |           1 | product_category                  |
| mysql         | product_order     | product_category | 2021-03-01 11:44:23 | n_diff_pfx02 |          0 |           1 | product_category,product_id       |
| mysql         | product_order     | product_category | 2021-03-01 11:44:23 | n_diff_pfx03 |          0 |           1 | product_category,product_id,no    |
| mysql         | product_order     | product_category | 2021-03-01 11:44:23 | n_leaf_pages |          1 |        NULL | Number of leaf pages in the index |
| mysql         | product_order     | product_category | 2021-03-01 11:44:23 | size         |          1 |        NULL | Number of pages in the index      |
| mysql         | rc#P#p0           | GEN_CLUST_INDEX  | 2021-02-26 11:21:58 | n_diff_pfx01 |          0 |           1 | DB_ROW_ID                         |
| mysql         | rc#P#p0           | GEN_CLUST_INDEX  | 2021-02-26 11:21:58 | n_leaf_pages |          1 |        NULL | Number of leaf pages in the index |
| mysql         | rc#P#p0           | GEN_CLUST_INDEX  | 2021-02-26 11:21:58 | size         |          1 |        NULL | Number of pages in the index      |
| mysql         | rc#P#p1           | GEN_CLUST_INDEX  | 2021-02-26 11:21:58 | n_diff_pfx01 |          0 |           1 | DB_ROW_ID                         |
| mysql         | rc#P#p1           | GEN_CLUST_INDEX  | 2021-02-26 11:21:58 | n_leaf_pages |          1 |        NULL | Number of leaf pages in the index |
| mysql         | rc#P#p1           | GEN_CLUST_INDEX  | 2021-02-26 11:21:58 | size         |          1 |        NULL | Number of pages in the index      |
| mysql         | rc#P#p2           | GEN_CLUST_INDEX  | 2021-02-26 11:21:58 | n_diff_pfx01 |          0 |           1 | DB_ROW_ID                         |
| mysql         | rc#P#p2           | GEN_CLUST_INDEX  | 2021-02-26 11:21:58 | n_leaf_pages |          1 |        NULL | Number of leaf pages in the index |
| mysql         | rc#P#p2           | GEN_CLUST_INDEX  | 2021-02-26 11:21:58 | size         |          1 |        NULL | Number of pages in the index      |
| mysql         | rc#P#p3           | GEN_CLUST_INDEX  | 2021-02-26 11:21:58 | n_diff_pfx01 |          0 |           1 | DB_ROW_ID                         |
| mysql         | rc#P#p3           | GEN_CLUST_INDEX  | 2021-02-26 11:21:58 | n_leaf_pages |          1 |        NULL | Number of leaf pages in the index |
| mysql         | rc#P#p3           | GEN_CLUST_INDEX  | 2021-02-26 11:21:58 | size         |          1 |        NULL | Number of pages in the index      |
| mysql         | rc#P#p4           | GEN_CLUST_INDEX  | 2021-02-26 11:21:58 | n_diff_pfx01 |          0 |           1 | DB_ROW_ID                         |
| mysql         | rc#P#p4           | GEN_CLUST_INDEX  | 2021-02-26 11:21:58 | n_leaf_pages |          1 |        NULL | Number of leaf pages in the index |
| mysql         | rc#P#p4           | GEN_CLUST_INDEX  | 2021-02-26 11:21:58 | size         |          1 |        NULL | Number of pages in the index      |
| mysql         | sales             | GEN_CLUST_INDEX  | 2021-01-20 17:00:50 | n_diff_pfx01 |          0 |           1 | DB_ROW_ID                         |
| mysql         | sales             | GEN_CLUST_INDEX  | 2021-01-20 17:00:50 | n_leaf_pages |          1 |        NULL | Number of leaf pages in the index |
| mysql         | sales             | GEN_CLUST_INDEX  | 2021-01-20 17:00:50 | size         |          1 |        NULL | Number of pages in the index      |
| mysql         | t                 | GEN_CLUST_INDEX  | 2021-04-26 15:37:14 | n_diff_pfx01 |          0 |           1 | DB_ROW_ID                         |
| mysql         | t                 | GEN_CLUST_INDEX  | 2021-04-26 15:37:14 | n_leaf_pages |          1 |        NULL | Number of leaf pages in the index |
| mysql         | t                 | GEN_CLUST_INDEX  | 2021-04-26 15:37:14 | size         |          1 |        NULL | Number of pages in the index      |
| mysql         | t1                | PRIMARY          | 2021-04-26 11:04:17 | n_diff_pfx01 |          0 |           1 | c1                                |
| mysql         | t1                | PRIMARY          | 2021-04-26 11:04:17 | n_leaf_pages |          1 |        NULL | Number of leaf pages in the index |
| mysql         | t1                | PRIMARY          | 2021-04-26 11:04:17 | size         |          1 |        NULL | Number of pages in the index      |
| mysql         | t2                | PRIMARY          | 2021-04-26 11:05:46 | n_diff_pfx01 |          0 |           1 | c1                                |
| mysql         | t2                | PRIMARY          | 2021-04-26 11:05:46 | n_leaf_pages |          1 |        NULL | Number of leaf pages in the index |
| mysql         | t2                | PRIMARY          | 2021-04-26 11:05:46 | size         |          1 |        NULL | Number of pages in the index      |
| mysql         | t3                | PRIMARY          | 2021-04-26 11:05:58 | n_diff_pfx01 |          0 |           1 | c1                                |
| mysql         | t3                | PRIMARY          | 2021-04-26 11:05:58 | n_leaf_pages |          1 |        NULL | Number of leaf pages in the index |
| mysql         | t3                | PRIMARY          | 2021-04-26 11:05:58 | size         |          1 |        NULL | Number of pages in the index      |
| mysql         | t4                | PRIMARY          | 2021-04-26 11:11:41 | n_diff_pfx01 |          0 |           1 | c1                                |
| mysql         | t4                | PRIMARY          | 2021-04-26 11:11:41 | n_leaf_pages |          1 |        NULL | Number of leaf pages in the index |
| mysql         | t4                | PRIMARY          | 2021-04-26 11:11:41 | size         |          1 |        NULL | Number of pages in the index      |
| mysql         | t5                | GEN_CLUST_INDEX  | 2020-10-10 16:24:57 | n_diff_pfx01 |          0 |           1 | DB_ROW_ID                         |
| mysql         | t5                | GEN_CLUST_INDEX  | 2020-10-10 16:24:57 | n_leaf_pages |          1 |        NULL | Number of leaf pages in the index |
| mysql         | t5                | GEN_CLUST_INDEX  | 2020-10-10 16:24:57 | size         |          1 |        NULL | Number of pages in the index      |
| mysql         | test              | GEN_CLUST_INDEX  | 2020-01-07 10:56:04 | n_diff_pfx01 |          0 |           1 | DB_ROW_ID                         |
| mysql         | test              | GEN_CLUST_INDEX  | 2020-01-07 10:56:04 | n_leaf_pages |          1 |        NULL | Number of leaf pages in the index |
| mysql         | test              | GEN_CLUST_INDEX  | 2020-01-07 10:56:04 | size         |          1 |        NULL | Number of pages in the index      |
| mysql         | total             | GEN_CLUST_INDEX  | 2021-02-19 15:22:54 | n_diff_pfx01 |          0 |           1 | DB_ROW_ID                         |
| mysql         | total             | GEN_CLUST_INDEX  | 2021-02-19 15:22:54 | n_leaf_pages |          1 |        NULL | Number of leaf pages in the index |
| mysql         | total             | GEN_CLUST_INDEX  | 2021-02-19 15:22:54 | size         |          1 |        NULL | Number of pages in the index      |
| mysql         | triangle          | GEN_CLUST_INDEX  | 2021-03-01 14:57:31 | n_diff_pfx01 |          3 |           1 | DB_ROW_ID                         |
| mysql         | triangle          | GEN_CLUST_INDEX  | 2021-03-01 14:57:31 | n_leaf_pages |          1 |        NULL | Number of leaf pages in the index |
| mysql         | triangle          | GEN_CLUST_INDEX  | 2021-03-01 14:57:31 | size         |          1 |        NULL | Number of pages in the index      |
| query_rewrite | rewrite_rules     | PRIMARY          | 2020-07-15 16:36:38 | n_diff_pfx01 |          3 |           1 | id                                |
| query_rewrite | rewrite_rules     | PRIMARY          | 2020-07-15 16:36:38 | n_leaf_pages |          1 |        NULL | Number of leaf pages in the index |
| query_rewrite | rewrite_rules     | PRIMARY          | 2020-07-15 16:36:38 | size         |          1 |        NULL | Number of pages in the index      |
| sys           | sys_config        | PRIMARY          | 2019-06-17 14:28:41 | n_diff_pfx01 |          6 |           1 | variable                          |
| sys           | sys_config        | PRIMARY          | 2019-06-17 14:28:41 | n_leaf_pages |          1 |        NULL | Number of leaf pages in the index |
| sys           | sys_config        | PRIMARY          | 2019-06-17 14:28:41 | size         |          1 |        NULL | Number of pages in the index      |
+---------------+-------------------+------------------+---------------------+--------------+------------+-------------+-----------------------------------+
191 rows in set (0.00 sec)

.可以查看mysql.innodb_table_stats和mysql.innodb_index_stats表的last_update列查看统计信息最后一次更新的时间。

.您可以手动修改mysql.innodb_table_stats和mysql.innodb_index_stats表强制执行特定的查询优化计划或在不修改数据库的情况下测试可选计划。

默认情况下,持久化优化器统计特性是启用的(innodb_stats_persistent=ON)。

非持久优化器统计信息在每次服务器重启时和一些其他操作之后被清除,并在下一个表访问时重新计算。因此,在重新计算统计信息时可能会产生不同的估计,导致执行计划中的不同选择和查询性能的变化

本节还提供了有关估计ANALYZE TABLE复杂度的信息,这在试图在准确的统计数据和ANALYZE TABLE执行时间之间取得平衡时可能很有用。

配置持久优化器统计信息参数
持久性优化器统计信息特性将统计信息存储到磁盘,并在服务器重启时保持这些统计信息的持久性,从而提高了计划的稳定性,这样优化器就更有可能在每次给定查询时做出一致的选择。

当innodb_stats_persistent=ON或使用STATS_PERSISTENT=1创建或修改单个表时,优化器统计信息被持久化到磁盘。innodb_stats_persistent默认启用。

以前,在每次服务器重启和一些其他操作之后,都会清除优化器统计信息,并在下一个表访问时重新计算。因此,在重新计算统计信息时可能会产生不同的估计,导致查询执行计划中的不同选择,从而导致查询性能的变化。

持久性统计信息存储在mysql.innodb_table_stats和mysql.innodb_index_stats表中。

要恢复使用非持久优化器统计信息,可以使用ALTER TABLE tbl_name STATS_PERSISTENT=0语句修改表。

为持久优化器统计信息配置自动统计信息计算
innodb_stats_auto_recalc配置选项在默认情况下是启用的,它决定是否在表发生重大更改(超过10%的行)时自动计算统计数据。您还可以在CREATE TABLE或ALTER TABLE语句中使用STATS_AUTO_RECALC子句为单个表配置自动统计信息重新计算。innodb_stats_auto_recalc默认启用。

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

由于自动统计信息重新计算的异步特性(发生在后台),即使启用了innodb_stats_auto_recalc,当DML操作影响一个表的10%以上时,统计数据可能不会立即重新计算。在某些情况下,统计信息的重新计算可能会延迟几秒钟。如果在更改表的重要部分后需要立即更新统计信息,则运行analyze table来启动同步(前台)统计信息的重新计算。

如果innodb_stats_auto_recalc被禁用,那么在对索引的列进行大量更改之后,为每个适用的表发出ANALYZE TABLE语句,以确保优化器统计数据的准确性。您可以在将代表性数据加载到表中之后,在设置脚本中运行此语句,并在DML操作显著改变了索引列的内容之后定期运行它,或者在活动较少的时候调度运行它。当一个新的索引被添加到一个现有的表时,索引统计信息被计算并添加到innodb_index_stats表中,而不管innodb_stats_auto_recalc的值是多少。

要确保在创建新索引时收集统计信息,可以启用innodb_stats_auto_recalc选项,也可以在启用持久统计模式时,在创建每个新索引后运行ANALYZE TABLE。

为个别表配置优化器统计信息参数
innodb_stats_persistent,innodb_stats_auto_recalc和innodb_stats_persistent_sample_pages是全局配置选项。要覆盖这些系统范围的设置,并为各个表配置优化器统计信息参数,可以在CREATE TABLE或ALTER TABLE语句中定义STATS_PERSISTENT、STATS_AUTO_RECALC和STATS_SAMPLE_PAGES子句来实现。
.STATS_PERSISTENT指定InnoDB表是否启用持久化统计信息。默认值导致表的持久统计信息设置由innodb_stats_persistent配置选项决定。值1启用表的持久统计,而值0关闭此特性。在通过CREATE TABLE或ALTER TABLE语句启用持久统计信息后,在将代表性数据加载到表中之后,发出ANALYZE TABLE语句来计算统计信息

.STATS_AUTO_RECALC指定是否自动重新计算InnoDB表的持久统计信息。默认值导致表的持久统计信息设置由innodb_stats_auto_recalc配置选项决定。当表中10%的数据发生变化时,值1将导致重新计算统计数据。0可以防止对该表进行自动重新计算;使用此设置,在对表进行实质性更改后,发出一条ANALYZE TABLE语句来重新计算统计数据。

.STATS_SAMPLE_PAGES指定在估计索引列的基数和其他统计信息(例如由ANALYZE TABLE计算的统计信息)时要抽样的索引页数。

三个子句都在下面的CREATE TABLE示例中指定:

mysql> CREATE TABLE t1 (
    ->  id  int(8) NOT NULL auto_increment,
    ->  data  varchar(255),
    ->  date  datetime,
    -> PRIMARY KEY ( id ),
    -> INDEX  DATE_IX  ( date )
    -> ) ENGINE=InnoDB,
    -> STATS_PERSISTENT=1,
    -> STATS_AUTO_RECALC=1,
    -> STATS_SAMPLE_PAGES=25;
Query OK, 0 rows affected (0.09 sec)

配置InnoDB优化器统计信息的采样页面数
MySQL查询优化器使用关于键分布的估计统计信息,根据索引的相对选择性为执行计划选择索引。像ANALYZE TABLE这样的操作会导致InnoDB从表上的每个索引中随机取样页,以估计索引的基数。(这种技术被称为随机潜水。)

为了控制统计信息估计的质量(从而为查询优化器提供更好的信息),可以使用参数innodb_stats_persistent_sample_pages更改采样页面的数量,这个参数可以在运行时设置

Innodb_stats_persistent_sample_pages的默认值是20。作为一般指导原则,当遇到以下问题时,请考虑修改此参数:
1.统计数据不够准确,优化器会选择次优计划,如EXPLAIN输出所示。通过比较索引的实际基数(在索引列上运行SELECT DISTINCT返回)和mysql.innodb_index_stats持久化统计表提供的估计,可以检查统计信息的准确性。

如果确定统计信息不够准确,则应该增加innodb_stats_persistent_sample_pages的值,直到统计信息估计足够准确。然而,过多地增加innodb_stats_persistent_sample_pages可能会导致ANALYZE TABLE运行缓慢

2.ANALYZE TABLE太慢。在这种情况下,innodb_stats_persistent_sample_pages应该减少,直到ANALYZE TABLE的执行时间是可接受的。然而,过多地降低该值可能会导致第一个问题:不准确的统计数据和不够理想的查询执行计划

如果无法在精确的统计数据和ANALYZE TABLE执行时间之间取得平衡,那么可以考虑减少表中索引列的数量,或者限制分区的数量,以降低ANALYZE TABLE的复杂性。表主键中的列数也需要考虑,因为主键列被附加到每个非唯一索引。

在持久性统计信息计算中包括删除标记的记录
默认情况下,InnoDB在计算统计信息读取未提交的数据。在一个未提交事务从表中删除行的情况下,InnoDB在计算行估计和索引统计时,会排除被标记删除的记录,这可能会导致使用READ UNCOMMITTED以外的事务隔离级别并发操作表的其他事务的执行计划不是最优的。为了避免这种情况,可以启用innodb_stats_include_delete_marked,以确保在计算持久优化器统计数据时,InnoDB包含有标记删除的记录。

当innodb_stats_include_delete_marked被启用后,analyze table在计算统计信息时会考虑被标记为删除的记录。

innodb_stats_include_delete_marked是一个全局设置会影响所有的innodb表,并且它只应用于持久性优化器统计。

innodb_stats_include_delete_marked是在MySQL 5.7.16中引入的。

InnoDB持久化统计信息表
持久统计特性依赖于mysql数据库的内部管理表innodb_table_stats和innodb_index_stats。这些表在所有安装、升级和从源构建过程中自动设置。

mysql> desc innodb_table_stats;
+--------------------------+---------------------+------+-----+-------------------+-----------------------------+
| Field                    | Type                | Null | Key | Default           | Extra                       |
+--------------------------+---------------------+------+-----+-------------------+-----------------------------+
| database_name            | varchar(64)         | NO   | PRI | NULL              |                             |
| table_name               | varchar(199)        | NO   | PRI | NULL              |                             |
| last_update              | timestamp           | NO   |     | CURRENT_TIMESTAMP | on update CURRENT_TIMESTAMP |
| n_rows                   | bigint(20) unsigned | NO   |     | NULL              |                             |
| clustered_index_size     | bigint(20) unsigned | NO   |     | NULL              |                             |
| sum_of_other_index_sizes | bigint(20) unsigned | NO   |     | NULL              |                             |
+--------------------------+---------------------+------+-----+-------------------+-----------------------------+
6 rows in set (0.00 sec)



mysql> desc innodb_index_stats;
+------------------+---------------------+------+-----+-------------------+-----------------------------+
| Field            | Type                | Null | Key | Default           | Extra                       |
+------------------+---------------------+------+-----+-------------------+-----------------------------+
| database_name    | varchar(64)         | NO   | PRI | NULL              |                             |
| table_name       | varchar(199)        | NO   | PRI | NULL              |                             |
| index_name       | varchar(64)         | NO   | PRI | NULL              |                             |
| last_update      | timestamp           | NO   |     | CURRENT_TIMESTAMP | on update CURRENT_TIMESTAMP |
| stat_name        | varchar(64)         | NO   | PRI | NULL              |                             |
| stat_value       | bigint(20) unsigned | NO   |     | NULL              |                             |
| sample_size      | bigint(20) unsigned | YES  |     | NULL              |                             |
| stat_description | varchar(1024)       | NO   |     | NULL              |                             |
+------------------+---------------------+------+-----+-------------------+-----------------------------+
8 rows in set (0.00 sec)

innodb_table_stats和innodb_index_stats表都包含一个last_update列,显示InnoDB上次更新索引统计信息的时间,如下例所示:

mysql> select * from innodb_table_stats \G
*************************** 1. row ***************************
           database_name: cs
              table_name: address
             last_update: 2021-06-03 16:17:22
                  n_rows: 3
    clustered_index_size: 1
sum_of_other_index_sizes: 0

mysql> select * from innodb_index_stats where table_name='address' \G
*************************** 1. row ***************************
   database_name: cs
      table_name: address
      index_name: PRIMARY
     last_update: 2021-06-03 16:17:22
       stat_name: n_diff_pfx01
      stat_value: 3
     sample_size: 1
stat_description: address_id
*************************** 2. row ***************************
   database_name: cs
      table_name: address
      index_name: PRIMARY
     last_update: 2021-06-03 16:17:22
       stat_name: n_leaf_pages
      stat_value: 1
     sample_size: NULL
stat_description: Number of leaf pages in the index
*************************** 3. row ***************************
   database_name: cs
      table_name: address
      index_name: PRIMARY
     last_update: 2021-06-03 16:17:22
       stat_name: size
      stat_value: 1
     sample_size: NULL
stat_description: Number of pages in the index
3 rows in set (0.00 sec)

innodb_table_stats和innodb_index_stats是普通表,可以手动更新。手动更新统计信息的能力使得在不修改数据库的情况下强制执行特定的查询优化计划或测试备选计划成为可能。如果您手动更新统计信息,请执行FLUSH TABLE tbl_name命令让MySQL重新加载更新后的统计信息。

持久性统计信息被认为是本地信息,因为它们与服务器实例相关。因此,当自动统计信息重新计算发生时,innodb_table_stats和innodb_index_stats表不会被复制。如果您运行ANALYZE TABLE来启动统计信息的同步重新计算,那么这个语句将被复制(
除非您抑制了对它的日志记录),并在复制从服务器上进行重新计算。

InnoDB持久化统计信息表示例
innodb_table_stats表每个表包含一行。下面的例子演示了收集到的数据。

表t1包含一个主索引(列a、b)二级索引(列c、d)和唯一索引(列e、f):

mysql> CREATE TABLE t1 (
    -> a INT, b INT, c INT, d INT, e INT, f INT,
    -> PRIMARY KEY (a, b), KEY i1 (c, d), UNIQUE KEY i2uniq (e, f)
    -> ) ENGINE=INNODB;
Query OK, 0 rows affected (0.14 sec)

插入五行样本数据后,表如下所示:

mysql> insert into t1 values(1,1,10,11,100,101),(1,2,10,11,200,102),(1,3,10,11,100,103),(1,4,10,12,200,104),(1,5,10,12,100,105);
Query OK, 5 rows affected (0.12 sec)
Records: 5  Duplicates: 0  Warnings: 0

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

mysql> select * from t1;
+---+---+------+------+------+------+
| a | b | c    | d    | e    | f    |
+---+---+------+------+------+------+
| 1 | 1 |   10 |   11 |  100 |  101 |
| 1 | 2 |   10 |   11 |  200 |  102 |
| 1 | 3 |   10 |   11 |  100 |  103 |
| 1 | 4 |   10 |   12 |  200 |  104 |
| 1 | 5 |   10 |   12 |  100 |  105 |
+---+---+------+------+------+------+
5 rows in set (0.00 sec)

要立即更新统计信息,运行ANALYZE TABLE(如果启用了innodb_stats_auto_recalc,假设改变的表行达到10%的阈值,统计信息会在几秒钟内自动更新)

mysql> analyze table t1;
+----------+---------+----------+----------+
| Table    | Op      | Msg_type | Msg_text |
+----------+---------+----------+----------+
| mysql.t1 | analyze | status   | OK       |
+----------+---------+----------+----------+
1 row in set (0.03 sec)


mysql> select * from innodb_table_stats where table_name='t1' and database_name='mysql';
+---------------+------------+---------------------+--------+----------------------+--------------------------+
| database_name | table_name | last_update         | n_rows | clustered_index_size | sum_of_other_index_sizes |
+---------------+------------+---------------------+--------+----------------------+--------------------------+
| mysql         | t1         | 2022-02-17 14:52:13 |      5 |                    1 |                        2 |
+---------------+------------+---------------------+--------+----------------------+--------------------------+
1 row in set (0.01 sec)

表t1的表统计信息显示InnoDB最后更新表统计信息的时间为(2022-02-17 14:52:13),表中的行记录数为5,集簇索引大小为1个索引页,其它索引大小为2个索引页。

mysql> select * from innodb_table_stats where table_name='t1' and database_name='mysql' \G
*************************** 1. row ***************************
           database_name: mysql
              table_name: t1
             last_update: 2022-02-17 14:52:13
                  n_rows: 5
    clustered_index_size: 1
sum_of_other_index_sizes: 2
1 row in set (0.01 sec)

innodb_index_stats表包含每个索引的多行。innodb_index_stats表中的每一行都提供了与特定索引统计相关的数据,在stat_name列中显示命名,在stat_description列中显示描述。例如:

mysql> select * from innodb_index_stats where table_name='t1' and database_name='mysql';
+---------------+------------+------------+---------------------+--------------+------------+-------------+-----------------------------------+
| database_name | table_name | index_name | last_update         | stat_name    | stat_value | sample_size | stat_description                  |
+---------------+------------+------------+---------------------+--------------+------------+-------------+-----------------------------------+
| mysql         | t1         | PRIMARY    | 2022-02-17 14:52:13 | n_diff_pfx01 |          1 |           1 | a                                 |
| mysql         | t1         | PRIMARY    | 2022-02-17 14:52:13 | n_diff_pfx02 |          5 |           1 | a,b                               |
| mysql         | t1         | PRIMARY    | 2022-02-17 14:52:13 | n_leaf_pages |          1 |        NULL | Number of leaf pages in the index |
| mysql         | t1         | PRIMARY    | 2022-02-17 14:52:13 | size         |          1 |        NULL | Number of pages in the index      |
| mysql         | t1         | i1         | 2022-02-17 14:52:13 | n_diff_pfx01 |          1 |           1 | c                                 |
| mysql         | t1         | i1         | 2022-02-17 14:52:13 | n_diff_pfx02 |          2 |           1 | c,d                               |
| mysql         | t1         | i1         | 2022-02-17 14:52:13 | n_diff_pfx03 |          2 |           1 | c,d,a                             |
| mysql         | t1         | i1         | 2022-02-17 14:52:13 | n_diff_pfx04 |          5 |           1 | c,d,a,b                           |
| mysql         | t1         | i1         | 2022-02-17 14:52:13 | n_leaf_pages |          1 |        NULL | Number of leaf pages in the index |
| mysql         | t1         | i1         | 2022-02-17 14:52:13 | size         |          1 |        NULL | Number of pages in the index      |
| mysql         | t1         | i2uniq     | 2022-02-17 14:52:13 | n_diff_pfx01 |          2 |           1 | e                                 |
| mysql         | t1         | i2uniq     | 2022-02-17 14:52:13 | n_diff_pfx02 |          5 |           1 | e,f                               |
| mysql         | t1         | i2uniq     | 2022-02-17 14:52:13 | n_leaf_pages |          1 |        NULL | Number of leaf pages in the index |
| mysql         | t1         | i2uniq     | 2022-02-17 14:52:13 | size         |          1 |        NULL | Number of pages in the index      |
+---------------+------------+------------+---------------------+--------------+------------+-------------+-----------------------------------+
14 rows in set (0.01 sec)

stat_name列显示了以下类型的统计信息:
.size: 当tat_name=size时, stat_value列显示索引中的总页数。

.n_leaf_pages: 当stat_name=n_leaf_pages时, stat_value列显示索引中叶页的数量。

.n_diff_pfxNN: 当stat_name=n_diff_pfx01时,stat_value列显示索引中第一列的distinct值的数量。当stat_name=n_diff_pfx02时,stat_value列显示索引中前两列的distinct值的数量。另外,stat_name=n_diff_pfxNN,stat_description列显示了被计数的索引列的逗号分隔列表。

为了进一步说明n_diff_pfxNN统计数据所提供的基数数据,考虑t1表示例。如下所示,用一个主索引(列a、b)、一个辅助索引(列c、d)和一个唯一索引(列e、f)创建了t1表。

mysql> CREATE TABLE t1 (
    -> a INT, b INT, c INT, d INT, e INT, f INT,
    -> PRIMARY KEY (a, b), KEY i1 (c, d), UNIQUE KEY i2uniq (e, f)
    -> ) ENGINE=INNODB;
Query OK, 0 rows affected (0.14 sec)


插入五行样本数据后,表如下所示:

mysql> insert into t1 values(1,1,10,11,100,101),(1,2,10,11,200,102),(1,3,10,11,100,103),(1,4,10,12,200,104),(1,5,10,12,100,105);
Query OK, 5 rows affected (0.12 sec)
Records: 5  Duplicates: 0  Warnings: 0

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

mysql> select * from t1;
+---+---+------+------+------+------+
| a | b | c    | d    | e    | f    |
+---+---+------+------+------+------+
| 1 | 1 |   10 |   11 |  100 |  101 |
| 1 | 2 |   10 |   11 |  200 |  102 |
| 1 | 3 |   10 |   11 |  100 |  103 |
| 1 | 4 |   10 |   12 |  200 |  104 |
| 1 | 5 |   10 |   12 |  100 |  105 |
+---+---+------+------+------+------+
5 rows in set (0.00 sec)

当查询index_name,stat_name,stat_value和stat_description且where条件为stat_name like ‘n_diff%’,返回结果如下:

mysql> select index_name,stat_name,stat_value,stat_description from innodb_index_stats where table_name='t1' and
    -> database_name='mysql' and stat_name like 'n_diff%';
+------------+--------------+------------+------------------+
| index_name | stat_name    | stat_value | stat_description |
+------------+--------------+------------+------------------+
| PRIMARY    | n_diff_pfx01 |          1 | a                |
| PRIMARY    | n_diff_pfx02 |          5 | a,b              |
| i1         | n_diff_pfx01 |          1 | c                |
| i1         | n_diff_pfx02 |          2 | c,d              |
| i1         | n_diff_pfx03 |          2 | c,d,a            |
| i1         | n_diff_pfx04 |          5 | c,d,a,b          |
| i2uniq     | n_diff_pfx01 |          2 | e                |
| i2uniq     | n_diff_pfx02 |          5 | e,f              |
+------------+--------------+------------+------------------+
8 rows in set (0.00 sec)

对于primary索引,这里有两个n_diff%行。行数等于索引中的列数。

注意:对于非唯一索引 ,InnoDB会附加主键索引的列到非唯一索引中。

.当index_name=PRIMARY和stat_name=n_diff_pfx01时,stat_value值为1,这说明索引中第一个列(a)包含一个distinct值。列a的distinct值可以通过查看表t1中的列a的值来进行确认,只有单个distinct值1。计数列(a)显示在结果集的stat_description列中。

.当index_name=PRIMAY和stat_name=n_diff_pfx02时,stat_value值为5,这说明索引中前两列包含五个distinct值。列a和b的distinct值可以通过查看表t1中的列a和b的值来进行确认,有五个distinct值(1,1),(1,2),(1,3),(1,4),(1,5)。计数列(a,)显示在结果集的stat_description列中。

对于二级索引(i1),有4个n_diff%行。二级索引只定义了两个列(c,d),但是二级索引有四个n_diff%行,因为InnoDB将所有非唯一的索引都以主键作为后缀。因此,二级索引列(c,d)和主键列(a,b)有4个n_diff%行,而不是2个。
.当index_name=i1和stat_name=n_diff_pfx01时,stat_value的值为1,这说明索引中第一列(c)包含一个distinct值。列c的distinct值可以通过查看表t1中的列c的数据来进行确认。计数列c在stat_description列中显示。

.当index_name=i1和stat_name=n_diff_pfx02时,stat_value的值为2,这说明索引中前两列(c,d)包含两个distinct值。列c和d的distinct值可以通过查看表t1中的列c和d的数据来进行确认。计数列(c,d)在stat_description列中显示

.当index_name=i1和stat_name=n_diff_pfx03,stat_value的值为2,这说明索引中前三列(c,d,a)包含两个distinct值。列c,d和a的distinct值可以通过查看表t1中列c,d和a的数据来进行确认,有两个distinct值(10,11,1)和(10,12,1)。计数列(c,d,a)在stat_desciption列中显示

.当index_name=i1和stat_name=n_diff_pfx04,stat_value的值为5,这说明索引中四列(c,d,a,b)包含五个distinct值。列c,d,a和b的distinct值可以通过查看表t1中列c,d,a和b的数据来进行确认,有五个distinct值(10,11,1,1)和(10,11,1,2),(10,11,1,3),(10,12,1,4)和(10,12,1,5)。计数列(c,d,a,b)在stat_description列中显示

对于唯一索引(i2uniq),有两个n_diff%行。
.当index_name=i2uniq和stat_name=n_diff_pfx01时,stat_value值为2,这说明索引中第一列(e)包含两个distinct值。列e的distinct值可以通过查看表t1的列e的数据来进行确认,有两个distinct值(100)和(200)。计数列e在stat_description列中显示。

.当index_name=i2uniq和stat_name=n_diff_pfx02时,stat_value值为5,这说明索引中两列(e,f)包含五个distinct值。列e和f的distinct值可以通过查看表t1的列e和f的数据来进行确认,有五个distinct值(100,101),(200,102),(100,103),(200,104)和(100,105)。计数列(e,f)在stat_description列中显示。

使用innodb_index_stats表获取索引大小
表、分区或子分区的索引大小可以使用innodb_index_stats表来检索。在下面的例子中,检索表t1的索引大小。

mysql> select sum(stat_value) pages,index_name,sum(stat_value)*@@innodb_page_size size
    -> from mysql.innodb_index_stats where table_name='t1' and database_name='mysql' and stat_name='size' group by index_name;

+-------+------------+-------+
| pages | index_name | size  |
+-------+------------+-------+
|     1 | PRIMARY    | 16384 |
|     1 | i1         | 16384 |
|     1 | i2uniq     | 16384 |
+-------+------------+-------+
3 rows in set (0.04 sec)

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

对于分区或子分区,可以使用带有修改后的WHERE子句的相同查询来检索索引大小。例如,下面的查询检索表t1的分区的索引大小

mysql> select sum(stat_value) pages,index_name,sum(stat_value)*@@innodb_page_size size
    -> from mysql.innodb_index_stats where table_name like't1#P%' and database_name='mysql' and stat_name='size' group by index_name;
Empty set (0.01 sec)
]]>
http://www.jydba.net/index.php/archives/3342/feed 0
MySQL 配置InnoDB清理调度 http://www.jydba.net/index.php/archives/3340 http://www.jydba.net/index.php/archives/3340#respond Sun, 20 Feb 2022 08:03:45 +0000 http://www.jydba.net/?p=3340 配置InnoDB清理调度
InnoDB自动执行的清除操作(一种垃圾收集)可以由一个或多个独立的线程执行,而不是作为主线程的一部分。使用独立线程可以使主数据库操作独立于后台的维护工作运行,从而提高了可伸缩性。

要控制这个特性,请增加配置选项innodb_purge_threads的值。如果DML操作集中在一个或几个表上,请将设置设置得低一些,这样线程就不会为了访问繁忙的表而相互竞争。如果DML操作分布在多个表中,则增加设置。它的最大值是32。Innodb_purge_threads是非动态配置选项,这意味着它不能在运行时配置。

还有一个相关的配置选项,innodb_purge_batch_size,默认值为300,最大值为5000。此选项主要用于清洗操作的试验和调优,一般用户不应该对此感兴趣。

]]>
http://www.jydba.net/index.php/archives/3340/feed 0
MySQL 配置自旋锁轮询 http://www.jydba.net/index.php/archives/3338 http://www.jydba.net/index.php/archives/3338#respond Sun, 20 Feb 2022 08:03:12 +0000 http://www.jydba.net/?p=3338 配置自旋锁轮询
很多InnoDB的互斥锁和rw-lock会被预留一段时间。在多核系统上,线程在睡觉前持续检查它是否可以获得互斥锁或rw-lock,这样会更有效率。如果互斥锁或rw-lock在此轮询期间可用,线程可以立即在同一时间片中继续运行。然而,由共享对象的多个线程进行过于频繁的轮询会导致缓存乒乓现象,不同的处理器会使彼此缓存的部分失效。InnoDB通过在两次轮询之间随机等待时间来最小化这个问题。延迟被实现为一个忙碌的循环。

您可以使用参数innodb_spin_wait_delay来控制测试互斥锁或rw-lock之间的最大延迟。延迟循环的持续时间取决于C编译器和目标处理器。(在100MHz奔腾时代,延迟单位是一微秒。)在所有处理器核心共享高速缓存内存的系统中,可以通过设置innodb_spin_wait_delay=0来减少最大延迟或禁用繁忙循环。在具有多个处理器芯片的系统上,缓存失效的影响可能更加显著,您可能会增加最大延迟。

innodb_spin_wait_delay默认值为6。自旋等待延迟是一个动态的、全局的参数,你可以在MySQL选项文件(my.cnf或my.ini)中指定,或者在运行时使用SET global innodb_spin_wait_delay=delay命令来更改,其中delay是所需的最大延迟。更改设置需要超级权限。

]]>
http://www.jydba.net/index.php/archives/3338/feed 0