淺測TokuDB

來源:互聯網
上載者:User

標籤:

一. 計劃:

TokuDB文檔描述其具備的高insert效能、高壓縮比、hot schema changes等特性較符合日誌類項目的應用情境,耳聽眼見終是虛,實測是必須的。

目前TokuDB僅支援MySQL5.5.x與MariaDB5.5.x,相比較之下Percona的支援要好很多,但仍然需要分開下載進行安裝。此次的測試內容:MySQL5.6.22(innoDB) Vs. TokuDB for Percona5.6.22。

1. 軟硬體環境資訊:

虛擬機器 ********
CPU
CPUX5660  @ 2.80GHz
邏輯CPU個數 4
記憶體 4G
系統 Red Hat Enterprise Linux Server release 6.1 (Santiago)
核心 2.6.32-131.0.15.el6.x86_64
IO調度 none
檔案系統 ext4

2. Linux下簡單的物理IO測速:

[[email protected] ~]$ time ddif=/dev/zero of=test.dbf bs=8k count=600000 oflag=direct600000+0 records in600000+0 recordsout4915200000 bytes(4.9 GB) copied, 381.327 s, 12.9 MB/s real    6m21.335suser    0m0.292ssys     0m12.690s

二.  DB安裝

1. MySQL5.6.22環境準備

1). DB Config

innodb_buffer_pool_size = 3000M

2). Installing MySQL(略)

[[email protected] ~]# /etc/init.d/mysqld start

2. Pecona5.6.22 and TokuDB環境準備

    1). Prerequisites

詳見手冊9.2.1

安裝Jemalloc:

[[email protected] ~]# wget http://www.canonware.com/download/jemalloc/jemalloc-3.6.0.tar.bz2[[email protected] ~]# tar xjf jemalloc-3.6.0.tar.bz2 [[email protected] ~]# cd jemalloc-3.6.0[[email protected] ~]# ./configure[[email protected] ~]# make && make install[[email protected] ~]# echo ‘/usr/local/lib‘ > /etc/ld.so.conf.d/local.conf[[email protected] ~]# ldconfig

    2). DB Config

tokudb_cache_size = 3Gtokudb_directio = ONtokudb_row_format = tokudb_fasttokudb_write_status_frequency = 1tokudb_read_status_frequency = 1

    3). Installing Percona(安裝部分略)

[[email protected] ~]# /etc/init.d/perconad start

    4). Installing TokuDB Plugin

mysql> INSTALL PLUGIN TokuDB SONAME ‘ha_tokudb.so‘;ERROR 1123 (HY000): Can‘t initialize function ‘TokuDB‘; Plugin initialization function failed.

        4.1). troubleshooting

[[email protected] ~]# vi data/wifimydb01prod.err Version: ‘5.6.22-71.0‘  socket: ‘/tmp/mysql.sock‘  port: 3306  Percona Server (GPL), Release 71.0, Revision 726Transparent huge pages are enabled, according to /sys/kernel/mm/redhat_transparent_hugepage/enabled2015-01-22 18:44:50 11824 [ERROR] TokuDB: Huge pages are enabled, disable them before continuing2015-01-22 18:44:50 11824 [ERROR] ************************************************************2015-01-22 18:44:50 11824 [ERROR]2015-01-22 18:44:50 11824 [ERROR]                         @@@@@@@@@@@2015-01-22 18:44:50 11824 [ERROR]                       @@‘         ‘@@2015-01-22 18:44:50 11824 [ERROR]                      @@    _     _  @@2015-01-22 18:44:50 11824 [ERROR]                      |    (.)   (.)  |2015-01-22 18:44:50 11824 [ERROR]                      |             ` |2015-01-22 18:44:50 11824 [ERROR]                      |        >    ‘ |2015-01-22 18:44:50 11824 [ERROR]                      |     .----.    |2015-01-22 18:44:50 11824 [ERROR]                      ..   |.----.|  ..2015-01-22 18:44:50 11824 [ERROR]                       ..  ‘      ‘ ..2015-01-22 18:44:50 11824 [ERROR]                         .._______,.2015-01-22 18:44:50 11824 [ERROR]2015-01-22 18:44:50 11824 [ERROR] TokuDB will not run with transparent huge pages enabled.2015-01-22 18:44:50 11824 [ERROR] Please disable them to continue.2015-01-22 18:44:50 11824 [ERROR] (echo never > /sys/kernel/mm/transparent_hugepage/enabled)2015-01-22 18:44:50 11824 [ERROR]2015-01-22 18:44:50 11824 [ERROR] ************************************************************2015-01-22 18:44:50 11824 [ERROR] Plugin ‘TokuDB‘ init function returned error.2015-01-22 18:44:50 11824 [ERROR] Plugin ‘TokuDB‘ registration as a STORAGE ENGINE failed.2015-01-22 18:44:50 11824 [Note] Shutting down plugin ‘TokuDB‘......[[email protected] ~]# vi /etc/rc.localecho never > /sys/kernel/mm/redhat_transparent_hugepage/defragecho never > /sys/kernel/mm/redhat_transparent_hugepage/enabledmysql> INSTALL PLUGIN TokuDB SONAME ‘ha_tokudb.so‘;Query OK, 0 rows affected (0.12 sec)mysql> INSTALL PLUGIN tokudb_file_map SONAME ‘ha_tokudb.so‘;Query OK, 0 rows affected (0.00 sec)mysql> INSTALL PLUGIN tokudb_fractal_tree_info SONAME ‘ha_tokudb.so‘;Query OK, 0 rows affected (0.00 sec)mysql> INSTALL PLUGIN tokudb_fractal_tree_block_map SONAME ‘ha_tokudb.so‘;Query OK, 0 rows affected (0.00 sec)mysql> INSTALL PLUGIN tokudb_trx SONAME ‘ha_tokudb.so‘;Query OK, 0 rows affected (0.00 sec)mysql> INSTALL PLUGIN tokudb_locks SONAME ‘ha_tokudb.so‘;Query OK, 0 rows affected (0.00 sec)mysql> INSTALL PLUGIN tokudb_lock_waits SONAME ‘ha_tokudb.so‘;Query OK, 0 rows affected (0.00 sec)mysql> SET GLOBAL default_storage_engine=TokuDB;Query OK, 0 rows affected (0.00 sec)

 三. 基測工具準備

    3.1) Installing Sysbench

[[email protected] ~]# git clone https://github.com/zatrazz/sysbench.git[[email protected] ~]# ./autogen.sh[[email protected] ~]# ./configure --prefix=/usr/local/sysbench --with-mysql-includes=/usr/local/mysql/include --with-mysql-libs=/usr/local/mysql/lib[[email protected] ~]# make && make install[[email protected] ~]$ export LD_LIBRARY_PATH=/usr/local/mysql/lib[[email protected] ~]$ /usr/local/sysbench/bin/sysbench --help

    3.2) Installing Gnuplot 

[[email protected] ~]# yum install gnuplot

四. 測試

    4.1) INSERT( innodb單表)測試

        a) 測試指令碼

[[email protected] ~]$ /usr/local/sysbench/bin/sysbench --test=/home/ming.liu/sysbench/sysbench/tests/db/insert.lua --mysql-host=localhost --mysql-port=3306 --mysql-user=ming --mysql-password=ming --mysql-db=sbtest4 --num-threads=1 --oltp-tables-count=1 --mysql-table-engine=innodb --oltp-table-size=100000000 prepare[[email protected] ~]$ time for i in 1 2 4 8 16 32 64 128; do /usr/local/sysbench/bin/sysbench --test=/home/ming.liu/sysbench/sysbench/tests/db/insert.lua --mysql-table-engine=innodb --mysql-host=localhost --mysql-port=3306 --mysql-user=ming --mysql-password=ming --mysql-db=sbtest4 --oltp_tables_count=1 --oltp-table-size=100000000 --rand-init=on --num-threads=${i} --oltp-read-only=off  --rand-type=uniform --max-time=360 --max-requests=0 --percentile=99 run >> sysbench_test_insert_InnoDB.log ; done

        b) 繪圖

[[email protected] ~]$ cat sysbench_test_insert_innodb.log | egrep " cat|threads:|read/write requests:" | tr -d "\n" | sed ‘s/Number of threads: /\n/g‘ | sed ‘s/\[/\n/g‘ | sed ‘s/[A-Za-z\/]\{1,\}://g‘| sed ‘s/ \.//g‘ | awk ‘{print $1 $4}‘ | sed ‘s/(/\t/g‘ > sysbench_test_insert_innoDB.csv[[email protected] ~]$ vi innodb_insert_mygraph# output as png imageset terminal png # save file to "benchmark.png"set output "sysbench_test_insert_InnoDB_benchmark.png" # graph titleset title "Benchmark for Sysbench" # aspect ratio for image sizeset size 1,1 # enable grid on y and x axisset grid yset grid x # x-axis labelset xlabel "Threads" # y-axis labelset ylabel "read/write(Insert) per sec." # plot data from sysbench.csvplot "sysbench_test_insert_innoDB.csv" using (log($1)):2:xtic(1) with linesp notitle[[email protected] ~]$ gnuplot innodb_insert_mygraph

        c) 圖示

    4.2) INSERT( tokudb單表)測試

        a) 測試指令碼

[[email protected] ~]$ /usr/local/sysbench/bin/sysbench --test=/home/ming.liu/sysbench/sysbench/tests/db/insert.lua --mysql-host=localhost --mysql-port=3306 --mysql-user=ming --mysql-password=ming --mysql-db=sbtest2 --num-threads=1 --oltp-tables-count=1 --mysql-table-engine=tokudb --oltp-table-size=100000000 prepare[[email protected] ~]$ time for i in 1 2 4 8 16 32 64 128; do /usr/local/sysbench/bin/sysbench --test=/home/ming.liu/sysbench/sysbench/tests/db/insert.lua --mysql-table-engine=tokudb --mysql-host=localhost --mysql-port=3306 --mysql-user=ming --mysql-password=ming --mysql-db=sbtest2 --oltp_tables_count=1 --oltp-table-size=100000000 --rand-init=on --num-threads=${i} --oltp-read-only=off  --rand-type=uniform --max-time=360 --max-requests=0 --percentile=99 run >> sysbench_test_insert_tokudb.log ; done

        b) 繪圖

[[email protected] ~]$ vi tokudb_insert_mygraph# output as png imageset terminal png # save file to "benchmark.png"set output "sysbench_test_insert_tokuDB_benchmark.png" # graph titleset title "Benchmark for Sysbench" # aspect ratio for image sizeset size 1,1 # enable grid on y and x axisset grid yset grid x # x-axis labelset xlabel "Threads" # y-axis labelset ylabel "read/write(Insert) per sec." # plot data from sysbench.csvplot "sysbench_test_insert_tokuDB.csv" using (log($1)):2:xtic(1) with linesp notitle

        c1) 圖示1(參數 tokudb_directio = ON)

        c2) 圖示2(參數 tokudb_directio = OFF)

5. 測試小結

1. TokuDB在寫操作(Insert)的表現優於InnoDB,在並發增長的情況下表現亦優於InnoDB。

2. 在此次實際測試中,InnoDB峰值約為11000 per sec,TokuDB峰值約為15000 per sec,並發超過4以後,效能均有不同程度的下降。

3. 在資料壓縮方面,同時產生2千萬行資料,TokuDB表大小約為3.1G,InnoDB表大小約為4.8G。這裡需說明的是測試中TokuDB所啟用的壓縮選項為’fast’,而InnoDB未啟用壓縮。InnoDB也具有壓縮功能,只不過壓縮行為是TokuDB的預設行為。在本文測試中並未使用InnoDB的壓縮格式。

4. 對測試造成的影響的問題因素:1. 共用儲存的IO控制與爭用對測試過程的影響。

淺測TokuDB

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.