TokuDB引擎安装起来貌似有点麻烦,在这里做个笔记,安装几步走

    • Percona MySQL5.6安装

    • TokuDB引擎安装
      第一步咱们直接省略,跟官方版本MySQL5.6安装方法基本相同,下面来写下安装TokuDB引擎安装。
      一、关闭内存大页

    1. echo never > /sys/kernel/mm/transparent_hugepage/enabled
    2. echo never > /sys/kernel/mm/transparent_hugepage/defrag

    查看下

    1. root@ptest:~# cat /sys/kernel/mm/transparent_hugepage/enabled
    2. always madvise [never]
    3. root@ptest:~# cat /sys/kernel/mm/transparent_hugepage/defrag
    4. always madvise [never]

    二、安装jemalloc
    上传jemalloc安装包jemalloc-4.2.1.tar,这里听锐志兄说3.6版本以上会出问题,但我这里貌似没有问题。
    上传后直接解压编译安装就可以了。
    导入:

    1. export LD_PRELOAD=/usr/local/lib/libjemalloc.so

    查看是否导入成功:

    1. #lsof -n | grep jemalloc

    更改MySQL配置文件:(参考老叶的配置文件)

    1. #
    2. #my.cnf
    3. #
    4. # Percona-5.6.17, TokuDB-7.1.6,用于Zabbix数据库参考配置
    5. # 我的服务器配置:E5-2620 * 2,64G内存,1T可用磁盘空间(建议datadir所在分区设置为xfs文件系统)
    6. # TokuDB版本:Percona-5.6.17, TokuDB-7.1.6(插件加载模式)
    7. #
    8. # created by yejr(http://imysql.com), 2014/06/24
    9. #
    10. [client]
    11. port = 3306
    12. socket = mysql.sock
    13. #default-character-set=utf8
    14. [mysql]
    15. prompt="\\u@\\h \\D \\R:\\m:\\s [\\d]>
    16. #pager="less -i -n -S"
    17. tee=/home/mysql/query.log
    18. no-auto-rehash
    19. [mysqld]
    20. open_files_limit = 8192
    21. max_connect_errors = 100000
    22. #buffer & cache
    23. table_open_cache = 2048
    24. table_definition_cache = 2048
    25. max_heap_table_size = 96M
    26. sort_buffer_size = 2M
    27. join_buffer_size = 2M
    28. tmp_table_size = 96M
    29. key_buffer_size = 8M
    30. read_buffer_size = 2M
    31. read_rnd_buffer_size = 16M
    32. bulk_insert_buffer_size = 32M
    33. #innodb
    34. #只有部分小表保留InnoDB引擎,因此InnoDB Buffer Pool设置为1G基本上够了
    35. innodb_buffer_pool_size = 1G
    36. innodb_buffer_pool_instances = 1
    37. innodb_data_file_path = ibdata1:1G:autoextend
    38. innodb_flush_log_at_trx_commit = 1
    39. innodb_log_buffer_size = 64M
    40. innodb_log_file_size = 256M
    41. innodb_log_files_in_group = 2
    42. innodb_file_per_table = 1
    43. innodb_status_file = 1
    44. transaction_isolation = READ-COMMITTED
    45. innodb_flush_method = O_DIRECT
    46. #tokudb
    47. malloc-lib= /usr/local/mysql/lib/mysql/libjemalloc.so
    48. plugin-dir = /usr/local/mysql/lib/mysql/plugin/
    49. plugin-load=ha_tokudb.so
    50. #把TokuDB datadir以及logdir和MySQL的datadir分开,美观点,也可以不分开,注释掉本行以及下面2行即可
    51. tokudb-data-dir = /data/mysql/zabbix_3306/tokudbData
    52. tokudb-log-dir = /data/mysql/zabbix_3306/tokudbLog
    53. #TokuDB的行模式,建议用 FAST 就足够了,如果磁盘空间很紧张,建议用 SMALL
    54. #tokudb_row_format = tokudb_small
    55. tokudb_row_format = tokudb_fast
    56. tokudb_cache_size = 44G
    57. #其他大部分配置其实可以不用修改的,只需要几个关键配置即可
    58. tokudb_commit_sync = 0
    59. tokudb_directio = 1
    60. tokudb_read_block_size = 128K
    61. tokudb_read_buf_size = 128K

    重启MySQL
    三、安装TokuDB引擎

    1. ps_tokudb_admin --enable -uroot -p -S /tmp/mysql3306.sock

    输出如下:

    1. [root@localhost bin]# ps_tokudb_admin --enable -uroot -p -S /tmp/mysql3306.sock
    2. Enter password:
    3. Checking SELinux status...
    4. INFO: SELinux is in permissive mode.
    5. cat: mysql.pid: No such file or directory
    6. Checking if Percona Server is running with jemalloc enabled...
    7. WARNING: The file /proc//environ is not readable so impossible to check LD_PRELOAD for jemalloc.
    8. Possibly running inside container so assuming jemalloc is preloaded and continuing...
    9. If there will be an error during plugin installation try to restart mysql service and run this script again.
    10. Checking transparent huge pages status on the system...
    11. INFO: Transparent huge pages are currently disabled on the system.
    12. Checking if thp-setting=never option is already set in config file...
    13. INFO: Option thp-setting=never is set in the config file.
    14. Checking TokuDB engine plugin status...
    15. INFO: TokuDB engine plugin is not installed.
    16. Installing TokuDB engine...
    17. INFO: Successfully installed TokuDB engine plugin.

    表示TokuDB安装成功,我们进入MySQL查看:

    1. root@localhost [(none)]>show engines;
    2. +--------------------+---------+----------------------------------------------------------------------------+--------------+------+------------+
    3. | Engine | Support | Comment | Transactions | XA | Savepoints |
    4. +--------------------+---------+----------------------------------------------------------------------------+--------------+------+------------+
    5. | FEDERATED | NO | Federated MySQL storage engine | NULL | NULL | NULL |
    6. | CSV | YES | CSV storage engine | NO | NO | NO |
    7. | MyISAM | YES | MyISAM storage engine | NO | NO | NO |
    8. | BLACKHOLE | YES | /dev/null storage engine (anything you write to it disappears) | NO | NO | NO |
    9. | MRG_MYISAM | YES | Collection of identical MyISAM tables | NO | NO | NO |
    10. | TokuDB | YES | Percona TokuDB Storage Engine with Fractal Tree(tm) Technology | YES | YES | YES |
    11. | MEMORY | YES | Hash based, stored in memory, useful for temporary tables | NO | NO | NO |
    12. | ARCHIVE | YES | Archive storage engine | NO | NO | NO |
    13. | PERFORMANCE_SCHEMA | YES | Performance Schema | NO | NO | NO |
    14. | InnoDB | DEFAULT | Percona-XtraDB, Supports transactions, row-level locking, and foreign keys | YES | YES | YES |
    15. +--------------------+---------+----------------------------------------------------------------------------+--------------+------+------------+
    16. 10 rows in set (0.00 sec)

    至此,TokuDB安装成功,后续会给大家带来InnoDB与TokuDB引擎的性能测试对比。