日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

MySQL 5.1.24rc + innodb plugin尝鲜

發布時間:2025/3/20 数据库 23 豆豆
生活随笔 收集整理的這篇文章主要介紹了 MySQL 5.1.24rc + innodb plugin尝鲜 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

1. 前言

oracle 收購 innobase 后,沉寂了將近2年,innodb開發團隊一直是在修改bug等,也沒見到什么動作。
前幾天,他們終于宣布,發布最新的innodb plugin for MySQL 5.1,這個plugin其實等同于innodb引擎,只是可以plugin的方式安裝,也可以自己編譯。 innodb plugin 的一些主要新特性有:
  • Fast index creation: add or drop indexes without copying the data
  • Data compression: shrink tables, to significantly reduce storage and i/o
  • New row format: fully off-page storage of long BLOB, TEXT, and VARCHAR columns
  • File format management: protects upward and downward compatibility
  • INFORMATION_SCHEMA tables: information about compression and locking
    • Other changes for flexibility, ease of use and reliability
    • Dynamic control of innodb_file_per_table
    • TRUNCATE TABLE re-creates the *.ibd file to reclaim space
    • “Strict mode” to prevent mistakes
其實第一個特性應該是:Fast index creation: add or drop (secondary) indexes without copying the data 才確切。 下載地址為:http://www.innodb.com/support/downloads/download-innodb-plugin,可以下載直接可用的 .so 文件,也可以下載源碼自己編譯,這里,我是自己下載源碼回來編譯。

2. 安裝

[@s1.yejr.com ~]# tar zxf mysql-5.1.24-rc.tar.gz [@s1.yejr.com ~]# tar zxf innodb_plugin-1.0.0-5.1.tar.gz [@s1.yejr.com ~]# cd mysql-5.1.24-rc/storage/innobase [@s1.yejr.com ~]# cp -rf ../../../innodb_plugin-1.0.0-5.1/* . 檢查 innobase 目錄下的 Makefile,原來的 MKDIR_P 有問題,需要修改 MKDIR_P 值 MKDIR_P = @MKDIR_P@ 為 MKDIR_P = mkdir -p -- 開始編譯、安裝 #設置一下 CFLAGS 和 CXXFLAGS,尤其要注意打開 HAVE_DLOPEN 選項 [@s1.yejr.com ~]# CFLAGS='-O2 -DHAVE_DLOPEN -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 \ -fexceptions -fstack-protector –param=ssp-buffer-size=4 -m64 -mtune=generic' [@s1.yejr.com ~]# CXXFLAGS='-O2 -DHAVE_DLOPEN -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 \ -fexceptions -fstack-protector –param=ssp-buffer-size=4 -m64 -mtune=generic' [@s1.yejr.com ~]# cd ../../ [@s1.yejr.com ~]# ./configure --prefix=/usr/local/mysql --with-extra-charsets=complex \ --enable-thread-safe-client --enable-local-infile --localstatedir=/home/mysql \ --libexecdir=/usr/local/mysql/bin/ --with-embedded-server --with-innodb \ --with-partition --without-plugin-archive --without-plugin-blackhole --with-big-tables \ --disable-shared --without-man --without-doc --with-client-ldflags=-all-static \ --with-mysqld-ldflags=-all-static --without-geometry --without-bench \ --without-test && make && make install-strip 安裝完畢。

3. 配置

以下是 innodb 相關的幾個主要配置: transaction_isolation = READ-COMMITTED innodb_additional_mem_pool_size = 16M innodb_buffer_pool_size = 12G innodb_data_file_path = ibdata1:1024M:autoextend innodb_file_io_threads = 4 innodb_thread_concurrency = 16 innodb_flush_log_at_trx_commit = 1 innodb_log_buffer_size = 16M innodb_log_file_size = 256M innodb_log_files_in_group = 3 innodb_max_dirty_pages_pct = 90 innodb_lock_wait_timeout = 120 innodb_file_per_table=1 innodb_rollback_on_timeout 其他的不再細說。

4. 測試

4.1 功能測試

測試在線增刪索引: mysql> select count(*) from sbtest; +----------+ | count(*) | +----------+ | 1000000 | +----------+ 1 row in set (0.27 sec) mysql> desc sbtest; +-------+------------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-------+------------------+------+-----+---------+----------------+ | id | int(10) unsigned | NO | PRI | NULL | auto_increment | | k | int(10) unsigned | NO | MUL | 0 | | | c | char(120) | NO | | | | | pad | char(60) | NO | | | | +-------+------------------+------+-----+---------+----------------+ mysql> alter table sbtest add index (c , pad); Query OK, 0 rows affected (16.96 sec) Records: 0 Duplicates: 0 Warnings: 0 mysql> alter table sbtest drop index c; Query OK, 0 rows affected (0.52 sec) Records: 0 Duplicates: 0 Warnings: 0 mysql> alter table sbtest add index (k); Query OK, 0 rows affected (4.13 sec) Records: 0 Duplicates: 0 Warnings: 0 mysql> alter table sbtest drop index k; Query OK, 0 rows affected (0.06 sec) Records: 0 Duplicates: 0 Warnings: 0

4.2 性能測試

4.2.1 測試 4 個線程并發的情況 [@s1.yejr.com ~]# sysbench --test=oltp --mysql-table-engine=innodb --oltp-table-size=1000000 \ --mysql-socket=/tmp/mysql.sock --mysql-user=root --mysql-db=test --num-threads=4 run OLTP test statistics:queries performed:read: 140000write: 50000other: 20000total: 210000transactions: 10000 (1189.56 per sec.)deadlocks: 0 (0.00 per sec.)read/write requests: 190000 (22601.68 per sec.)other operations: 20000 (2379.12 per sec.) Test execution summary:total time: 8.4065stotal number of events: 10000total time taken by event execution: 33.5053per-request statistics:min: 0.0025savg: 0.0034smax: 0.0150sapprox. 95 percentile: 0.0044s Threads fairness:events (avg/stddev): 2500.0000/96.33execution time (avg/stddev): 8.3763/0.00
4.2.2 測試 8 個線程并發的情況 [@s1.yejr.com ~]# sysbench --test=oltp --mysql-table-engine=innodb --oltp-table-size=1000000 \ --mysql-socket=/tmp/mysql.sock --mysql-user=root --mysql-db=test --num-threads=8 run OLTP test statistics:queries performed:read: 140014write: 50005other: 20002total: 210021transactions: 10001 (1689.60 per sec.)deadlocks: 0 (0.00 per sec.)read/write requests: 190019 (32102.34 per sec.)other operations: 20002 (3379.19 per sec.) Test execution summary:total time: 5.9192stotal number of events: 10001total time taken by event execution: 47.1426per-request statistics:min: 0.0031savg: 0.0047smax: 0.0465sapprox. 95 percentile: 0.0069s Threads fairness:events (avg/stddev): 1250.1250/16.00execution time (avg/stddev): 5.8928/0.00
4.2.3 測試 16 個線程并發的情況 [@s1.yejr.com ~]# sysbench --test=oltp --mysql-table-engine=innodb --oltp-table-size=1000000 \ --mysql-socket=/tmp/mysql.sock --mysql-user=root --mysql-db=test --num-threads=16 run OLTP test statistics:queries performed:read: 140000write: 50000other: 20000total: 210000transactions: 10000 (1401.51 per sec.)deadlocks: 0 (0.00 per sec.)read/write requests: 190000 (26628.65 per sec.)other operations: 20000 (2803.02 per sec.) Test execution summary:total time: 7.1352stotal number of events: 10000total time taken by event execution: 113.8354per-request statistics:min: 0.0037savg: 0.0114smax: 0.0467sapprox. 95 percentile: 0.0174s Threads fairness:events (avg/stddev): 625.0000/7.13execution time (avg/stddev): 7.1147/0.00
可以看到,并發線程設定為 8 的時候,測試結果最佳。

5. 和 mysql 5.0.45 對比一下,看看誰的性能更好點

5.1 功能測試

測試在線增刪索引: mysql> select count(*) from sbtest; +----------+ | count(*) | +----------+ | 1000000 | +----------+ 1 row in set (0.27 sec) mysql> desc sbtest; +-------+------------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-------+------------------+------+-----+---------+----------------+ | id | int(10) unsigned | NO | PRI | NULL | auto_increment | | k | int(10) unsigned | NO | MUL | 0 | | | c | char(120) | NO | | | | | pad | char(60) | NO | | | | +-------+------------------+------+-----+---------+----------------+ mysql> alter table sbtest add index (c , pad); Query OK, 1000000 rows affected (25.65 sec) Records: 1000000 Duplicates: 0 Warnings: 0 mysql> alter table sbtest drop index c; Query OK, 1000000 rows affected (14.75 sec) Records: 1000000 Duplicates: 0 Warnings: 0 mysql> alter table sbtest add index (k); Query OK, 1000000 rows affected (15.05 sec) Records: 0 Duplicates: 0 Warnings: 0 mysql> alter table sbtest drop index k; Query OK, 1000000 rows affected (11.85 sec) Records: 1000000 Duplicates: 0 Warnings: 0
在增、刪索引時,可以看到產生了臨時文件,相當于完全重建了一次數據表。 -rw-rw---- 1 mysql mysql 8632 Apr 23 16:44 #sql-62b_1.frm -rw-rw---- 1 mysql mysql 83886080 Apr 23 16:44 #sql-62b_1.ibd 而在 5.1.24rc + innodb plugin 的情況卻只產生了類似 #sql-62b_1.frm 的臨時文件,表記錄排序則放在內存中完成;只有對數據表的主鍵(或作為 cluster index 的那個索引)進行修改時,才會重建整個表。

5.2 性能測試

5.2.1 測試 4 個線程并發的情況 [@s1.yejr.com ~]# sysbench --test=oltp --mysql-table-engine=innodb --oltp-table-size=1000000 \ --mysql-socket=/tmp/mysql.sock --mysql-user=root --mysql-db=test --num-threads=4 run OLTP test statistics:queries performed:read: 140000write: 50000other: 20000total: 210000transactions: 10000 (1226.83 per sec.)deadlocks: 0 (0.00 per sec.)read/write requests: 190000 (23309.82 per sec.)other operations: 20000 (2453.67 per sec.) Test execution summary:total time: 8.1511stotal number of events: 10000total time taken by event execution: 32.4817per-request statistics:min: 0.0024savg: 0.0032smax: 0.0100sapprox. 95 percentile: 0.0043s Threads fairness:events (avg/stddev): 2500.0000/57.68execution time (avg/stddev): 8.1204/0.00
5.2.2 測試 8 個線程并發的情況 [@s1.yejr.com ~]# sysbench --test=oltp --mysql-table-engine=innodb --oltp-table-size=1000000 \ --mysql-socket=/tmp/mysql.sock --mysql-user=root --mysql-db=test --num-threads=8 run OLTP test statistics:queries performed:read: 140000write: 50000other: 20000total: 210000transactions: 10000 (1774.08 per sec.)deadlocks: 0 (0.00 per sec.)read/write requests: 190000 (33707.44 per sec.)other operations: 20000 (3548.15 per sec.) Test execution summary:total time: 5.6367stotal number of events: 10000total time taken by event execution: 44.8875per-request statistics:min: 0.0029savg: 0.0045smax: 0.0162sapprox. 95 percentile: 0.0066s Threads fairness:events (avg/stddev): 1250.0000/12.97execution time (avg/stddev): 5.6109/0.00
5.2.3 測試 16 個線程并發的情況 [@s1.yejr.com ~]# sysbench --test=oltp --mysql-table-engine=innodb --oltp-table-size=1000000 \ --mysql-socket=/tmp/mysql.sock --mysql-user=root --mysql-db=test --num-threads=16 run OLTP test statistics:queries performed:read: 140014write: 50005other: 20002total: 210021transactions: 10001 (1416.24 per sec.)deadlocks: 0 (0.00 per sec.)read/write requests: 190019 (26908.63 per sec.)other operations: 20002 (2832.49 per sec.) Test execution summary:total time: 7.0616stotal number of events: 10001total time taken by event execution: 112.6000per-request statistics:min: 0.0035savg: 0.0113smax: 0.0265sapprox. 95 percentile: 0.0174s Threads fairness:events (avg/stddev): 625.0625/8.90execution time (avg/stddev): 7.0375/0.00 可以看到,mysql 5.0.45 下的 innodb 會比 5.1.24rc 下的 innodb 總體性能稍微好一些。

本文轉自葉金榮51CTO博客,原文鏈接:http://blog.51cto.com/imysql/308626,如需轉載請自行聯系原作者

總結

以上是生活随笔為你收集整理的MySQL 5.1.24rc + innodb plugin尝鲜的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。