【Mysql】安裝tokudb引擎

小亮520cl發表於2016-08-03

平臺支援:

    TokuDB 只能在 64-bit Linux 下使用.
最小記憶體要求:
    TokuDB 需要至少1GB 的實體記憶體,當然這裡建議最好是 2GB 


安裝tokuDB   

      tokuDB記憶體分配需要jemalloc支援(一般安裝percona mysql以後自己就有,如果沒有則需要額外安裝)    

    

 1 安裝jemalloc
  1.          yum install jemalloc
         編譯安裝參考:http://blog.itpub.net/29096438/viewspace-2122906/

    

 2:安裝tokudb
  1. 二進位制包安裝:
  2. 下載:
  3. [root@host-192-168-1-56 plugin]# wget

解壓複製tokudb.so至mysql plugin目錄即可
[root@host-192-168-1-56 plugin]# cp ha_tokudb.so /home/data/mysql/lib/plugin/

修改核心配置,禁用transparent_hugepage,不關閉的話可能會導致TokuDB記憶體洩露(建議寫到 /etc/rc.local 中,重啟後仍可生效):
echo never > /sys/kernel/mm/redhat_transparent_hugepage/defrag
echo never > /sys/kernel/mm/redhat_transparent_hugepage/enabled
echo never > /sys/kernel/mm/transparent_hugepage/enabled
echo never > /sys/kernel/mm/transparent_hugepage/defrag

安裝即可
mysql> INSTALL PLUGIN tokudb_file_map SONAME 'ha_tokudb.so';
Query OK, 0 rows affected (0.07 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> INSTALL PLUGIN tokudb SONAME 'ha_tokudb.so';
Query OK, 0 rows affected (0.38 sec)


mysql> show engines;
+--------------------+---------+----------------------------------------------------------------+--------------+------+------------+
| Engine             | Support | Comment                                                        | Transactions | XA   | Savepoints |
+--------------------+---------+----------------------------------------------------------------+--------------+------+------------+
| MRG_MYISAM         | YES     | Collection of identical MyISAM tables                          | NO           | NO   | NO         |
| CSV                | YES     | CSV storage engine                                             | NO           | NO   | NO         |
| MyISAM             | YES     | MyISAM storage engine                                          | NO           | NO   | NO         |
| BLACKHOLE          | YES     | /dev/null storage engine (anything you write to it disappears) | NO           | NO   | NO         |
| MEMORY             | YES     | Hash based, stored in memory, useful for temporary tables      | NO           | NO   | NO         |
| TokuDB             | YES     | Tokutek TokuDB Storage Engine with Fractal Tree(tm) Technology | YES          | YES  | YES        |
| FEDERATED          | NO      | Federated MySQL storage engine                                 | NULL         | NULL | NULL       |
| ARCHIVE            | YES     | Archive storage engine                                         | NO           | NO   | NO         |
| InnoDB             | DEFAULT | Supports transactions, row-level locking, and foreign keys     | YES          | YES  | YES        |
| PERFORMANCE_SCHEMA | YES     | Performance Schema                                             | NO           | NO   | NO         |
+--------------------+---------+----------------------------------------------------------------+--------------+------+------------+
10 rows in set (0.04 sec)

4 配置檔案tokudb引數設定
  1. [mysqld_safe]
    malloc-lib=/usr/local/mysql/lib/libjemalloc.so
    plugin-dir =/usr/local/mysql/lib/mysql/plugin/

  2. #tokudb
  3. #把TokuDB datadir以及logdir和MySQL的datadir分開,美觀點,也可以不分開,註釋掉本行以及下面2行即可
  4. tokudb-data-dir = /data/mysql/zabbix_3306/tokudbData
  5. tokudb-log-dir = /data/mysql/zabbix_3306/tokudbLog
  6.  
  7. #TokuDB的行模式,建議用 FAST 就足夠了,如果磁碟空間很緊張,建議用 SMALL
  8. #tokudb_row_format = tokudb_small
  9. tokudb_row_format = tokudb_fast
  10. tokudb_cache_size = 44G
  11.  
  12. #其他大部分配置其實可以不用修改的,只需要幾個關鍵配置即可
  13. tokudb_commit_sync = 0
  14. tokudb_directio = 1
  15. tokudb_read_block_size = 128K
  16. tokudb_read_buf_size = 128K

若將上述引數寫在[mysqld]下,則show engines中tokudb引擎不存在了了,失效了
若將上述引數寫在[mysqld_safe]下,tokudb引擎還存在,也能建立tokudb表,但是這些引數配置是沒生效的。。。。。。。待解決


注意:
  1. mysql版本:mysql官方社群版5.6.24 搭建成功後 新建表就重啟,建標就重啟

    1. 錯誤日誌:遇到了bug?
    2. Version: '5.6.24-log'  socket: '/home/data/mydata/3308/mysql.sock'  port: 3308  Source distribution
      08:44:47 UTC - mysqld got signal 11 ;
      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.
      We will try our best to scrape up some info that will hopefully help
      diagnose the problem, but since we have already crashed, 
      something is definitely wrong and this may fail.


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


  2. 解決辦法:換成percona server 社群版5.6.24得以解決




參考:
http://blog.csdn.net/mr__fang/article/details/41121245

   

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29096438/viewspace-2122921/,如需轉載,請註明出處,否則將追究法律責任。

相關文章