centos6.4安裝Tokudb

longqidong發表於2014-08-14
在percona官網下載帶有Tokudb的二進位制包,也可以選擇原始碼編譯。tokudb有單獨的包,但是percona-Server包中已經包含了Tokudb,所以就不需要下載了。
我這裡下載的是最新的包,5.6.19-67
解壓 tar -zxvf Percona-Server-5.6.19-rel67.0-618.Linux.x86_64.tar.gz
將解壓資料夾,複製到/usr/local下面,此時可以重新命名,我這裡重新命名為  /usr/local/Percona-Mysql/
將啟動指令碼複製到/etc/init.d/下面
cd /usr/local/Percona-Mysql/
cp support-files/mysql.server /etc/init.d/
在/etc/下面建立配置檔案/etc/my.cnf。具體的配置內容參考了葉金榮的一遍文章,每一項引數的意義後續
在仔細研究。最後附配置檔案內容.


接下來和mysql一樣,初始化DB,執行scripts/mysql_install_db  --user=mysql --datadir=/data/mysql --basedir=/usr/local/Percona-Mysql/
初始化完成後,此時啟動mysql服務會失敗。
找不到/usr/local/Percona-Server-5.6.19-rel67.0-618.Linux.x86_64/bin/mysqld檔案,
這是因為mysql.server啟動指令碼,預設尋找/usr/local/Percona-Server-5.6.19-rel67.0-618.Linux.x86_64 目錄,而我在上面複製的時候已經更名為
/usr/local/Percona-Mysql。
所以修改/etc/init.d/mysql.server啟動指令碼中basedir和bindir為:
basedir=/usr/local/Percona-Mysql
bindir=/usr/local/Percona-Mysql/bin


預設這兩個值為空




然後再次啟動
報錯資訊如下:


[root@test Percona-Mysql]# /etc/init.d/mysql.server start
./bin/my_print_defaults: error while loading shared libraries: libssl.so.6:  cannot open shared object file: No such file or directory
Starting MySQL (Percona Server). ERROR! The server quit without updating PID file (/usr/local/Percona-Mysql/data/test.pid).
[root@test Percona-Mysql]# 
[root@test Percona-Mysql]# 


安裝libssl.so.6 ,yum -y install libssl.so.6


[root@test Percona-Mysql]# find / -name "libssl.so*"
/usr/lib64/libssl.so
/usr/lib64/libssl.so.1.0.0
/usr/lib64/libssl.so.6
/usr/lib64/libssl.so.10
/usr/lib/libssl.so.0.9.8e
/usr/lib/libssl.so.6
[root@test Percona-Mysql]# 


建立一個so檔案連結。
[root@test Percona-Mysql]# 
[root@test Percona-Mysql]# ln -s /usr/lib64/libssl.so /usr/lib64/libssl.so.6
[root@test Percona-Mysql]# ldconfig 
[root@test Percona-Mysql]# /etc/init.d/mysql.server start
./bin/my_print_defaults: error while loading shared libraries: libcrypto.so.6: cannot open shared object file: No such file or directory
Starting MySQL (Percona Server). ERROR! The server quit without updating PID file (/usr/local/Percona-Mysql/data/test.pid).


[root@test Percona-Mysql]# 
啟動還是報錯
尋找是否存在這個so檔案
[root@test Percona-Mysql]# find / -name "libcrypto.so*"
/usr/lib64/libcrypto.so
/usr/lib64/libcrypto.so.10
/usr/lib64/libcrypto.so.1.0.0
/usr/lib/libcrypto.so.6
/usr/lib/libcrypto.so.0.9.8e
[root@test Percona-Mysql]# 
既然有,那就建立一個連線,再次啟動。錯誤消失。這裡要注意一點,在64位機器上,使用的是/usr/lib64下面的so檔案。如果將/usr/lib/下面so檔案複製過去,
會報錯,引用了32位的so檔案。


so檔案的錯誤消失了,還是啟動失敗。
2014-08-14 18:30:42 38866 [Note] Server hostname (bind-address): '*'; port: 3306
2014-08-14 18:30:42 38866 [Note] IPv6 is available.
2014-08-14 18:30:42 38866 [Note]   - '::' resolves to '::';
2014-08-14 18:30:42 38866 [Note] Server socket created on IP: '::'.
2014-08-14 18:30:42 38866 [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.user' doesn't exist
140814 18:30:42 mysqld_safe mysqld from pid file /usr/local/Percona-Mysql//data/test.pid ended
這是因為scripts/mysql_install_db  --user=mysql --datadir=/data/mysql --basedir=/usr/local/Percona-Mysql/ 指定的datadir為/data/mysql
而在配置檔案中沒有指定,因此報錯。在配置檔案中加上datadir = /data/mysql即可。


接下來啟動還是失敗。錯誤日誌如下:
2014-08-14 18:34:20 39955 [Note] InnoDB: Waiting for purge to start
2014-08-14 18:34:20 39955 [Note] InnoDB:  Percona XtraDB () 5.6.19-rel67.0 started; log sequence number 1626008
2014-08-14 18:34:20 39955 [ERROR] /usr/local/Percona-Mysql/bin/mysqld: unknown variable 'malloc-lib=/usr/local/Percona-Mysql/lib/mysql/libjemalloc.so'
2014-08-14 18:34:20 39955 [ERROR] Aborting


報錯找不到malloc-lib 引數,
我的tokudb部分引數配置如下:
[mysqld]下面:
#tokudb
malloc_lib = /usr/local/Percona-Mysql/lib/mysql/libjemalloc.so
plugin_dir = /usr/local/Percona-Mysql/lib/mysql/plugin/
plugin_load=ha_tokudb.so




tokudb_data-dir = /data/zabbix/tokudbData
tokudb_log-dir = /data/zabbix/tokudbLog




tokudb_row_format = tokudb_small
tokudb_row_format = tokudb_fast
tokudb_cache_size = 44G 


tokudb_commit_sync = 0
tokudb_directio = 1
tokudb_read_block_size = 128K
tokudb_read_buf_size = 128K


因為這個引數找了不少資料都沒解決,最後諮詢了葉金榮,需要將malloc_lib = /usr/local/Percona-Mysql/lib/mysql/libjemalloc.so 
放在[mysqld_safe]部分下面。而且只能將這一項放在這下面,其他還是放在[mysqld]下面
然後啟動,順利了。
"root@127.0.0.1 Thu Aug 14 22:39:25 2014 22:39:25 [(none)]>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         |
| MEMORY             | YES     | Hash based, stored in memory, useful for temporary tables                  | NO           | NO   | NO         |
| BLACKHOLE          | YES     | /dev/null storage engine (anything you write to it disappears)             | NO           | NO   | NO         |
| MyISAM             | YES     | MyISAM storage engine                                                      | NO           | NO   | NO         |
| TokuDB             | YES     | Tokutek TokuDB Storage Engine with Fractal Tree(tm) Technology             | YES          | YES  | YES        |
| InnoDB             | DEFAULT | Percona-XtraDB, Supports transactions, row-level locking, and foreign keys | YES          | YES  | YES        |
| ARCHIVE            | YES     | Archive storage engine                                                     | NO           | NO   | NO         |
| FEDERATED          | NO      | Federated MySQL storage engine                                             | NULL         | NULL | NULL       |
| PERFORMANCE_SCHEMA | YES     | Performance Schema                                                         | NO           | NO   | NO         |
+--------------------+---------+----------------------------------------------------------------------------+--------------+------+------------+
10 rows in set (0.00 sec)


後面查了[mysqld] 和 [mysqld_safe]配置的區別,這部分在官方文件都有說明,官方文件明確支出malloc_lib
只能放在 [mysqld_safe]下面才能生效。有問題查官方文件是最簡潔的辦法。


tokudb安裝順利完成,後附配置檔案
[mysqld]
open_files_limit = 8192
max_connect_errors = 100000


#buffer & cache
table_open_cache = 2048
table_definition_cache = 2048
max_heap_table_size = 96M
sort_buffer_size = 2M
join_buffer_size = 2M
tmp_table_size = 96M
key_buffer_size = 8M
read_buffer_size = 2M
read_rnd_buffer_size = 16M
bulk_insert_buffer_size = 32M
basedir=/usr/local/Percona-Mysql/
datadir=/data/mysql
#innodb
#只有部分小表保留InnoDB引擎,因此InnoDB Buffer Pool設定為1G基本上夠了
innodb_buffer_pool_size = 1G
innodb_buffer_pool_instances = 1
innodb_data_file_path = ibdata1:1G:autoextend
innodb_flush_log_at_trx_commit = 1
innodb_log_buffer_size = 64M
innodb_log_file_size = 256M
innodb_log_files_in_group = 2
innodb_file_per_table = 1
innodb_status_file = 1
transaction_isolation = READ-COMMITTED
innodb_flush_method = O_DIRECT


#tokudb
plugin_dir = /usr/local/Percona-Mysql/lib/mysql/plugin/
plugin_load=ha_tokudb.so


#把TokuDB datadir以及logdir和MySQL的datadir分開,美觀點,也可以不分開,註釋掉本行以及下面2行即可
tokudb_data-dir = /data/zabbix/tokudbData
tokudb_log-dir = /data/zabbix/tokudbLog


#TokuDB的行模式,建議用 FAST 就足夠了,如果磁碟空間很緊張,建議用 SMALL
tokudb_row_format = tokudb_small
tokudb_row_format = tokudb_fast
tokudb_cache_size = 44G


#其他大部分配置其實可以不用修改的,只需要幾個關鍵配置即可
tokudb_commit_sync = 0
tokudb_directio = 1
tokudb_read_block_size = 128K
tokudb_read_buf_size = 128K

[mysqld_safe]  #這裡要特別注意,一般很少接觸到這部分引數
malloc_lib = /usr/local/Percona-Mysql/lib/mysql/libjemalloc.so.1 











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

相關文章