Skip to content

Installation

rockeet edited this page Aug 23, 2018 · 22 revisions

Installing on Ubuntu 16.04.2 LTS

1. Setting up prerequisites

Install deps

sudo apt-get update
sudo apt-get install g++ cmake libbz2-dev libaio-dev bison \
                     zlib1g-dev libsnappy-dev 
sudo apt-get install libgflags-dev libreadline6-dev libncurses5-dev \
                     libssl-dev liblz4-dev gdb git

2. Clone the project and submodules

git clone https://github.com/Terark/terarksql
cd terarksql
git submodule init
git submodule update
cd mysql-5.6
git submodule init
git submodule update

3. Get TerarkDB package

Download TerarkDB package and unpack: (assume you downloaded terark-zip-rocksdb-Linux-x86_64-g++-4.8-bmi2-0.tgz)

cd /download/dir # where terark-zip-rocksdb-Linux-x86_64-g++-4.8-bmi2-0.tgz lies in
tar xzf terark-zip-rocksdb-Linux-x86_64-g++-4.8-bmi2-0.tgz
export WITH_TERARKDB=/download/dir/terark-zip-rocksdb-Linux-x86_64-g++-4.8-bmi2-0

TODO: now downloaded terark-zip-rocksdb is not needed during compiling MyRocks

to export WITH_TERARKDB to enviroment variables in order to add terark library when compile.

4. Make and install

mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo -DWITH_SSL=system \
         -DWITH_ZLIB=bundled -DMYSQL_MAINTAINER_MODE=0 \
         -DENABLED_LOCAL_INFILE=1 -DENABLE_DTRACE=0 \
         -DCMAKE_CXX_FLAGS="-march=native" \
         -DCMAKE_INSTALL_PREFIX=/usr/local/terarksql
make
sudo make install

5. And mysql user and mysql group

Create mysql user and user group if there not exist in the os:

groupadd mysql
useradd -g mysql mysql

6. Set up my.cnf

To enable RocksDB storage engine, you need to set at least the following parameters in /usr/local/terarksql/my.cnf.

[mysqld]
rocksdb
default-storage-engine=rocksdb
skip-innodb
default-tmp-storage-engine=MyISAM
collation-server=latin1_bin #(or utf8_bin, binary)

log-bin
binlog-format=ROW

and there a example of my.cnf:

[mysqld]
rocksdb
default-storage-engine=rocksdb
skip-innodb
default-tmp-storage-engine=MyISAM
collation-server=latin1_bin

user = mysql
bind-address = 0.0.0.0

back_log = 600
max_connections = 6000

datadir = /usr/local/terarksql/data
log-bin = /usr/local/terarksql/data/mysql

binlog-format=ROW
secure_file_priv=""

7. Initlize MySQL

cd /usr/local/terarksql
sudo env \
  LD_LIBRARY_PATH=/path/to/terark-zip-rocksdb-package/lib:$LD_LIBRARY_PATH \
  scripts/mysql_install_db --defaults-file=path/to/my.cnf

8. Add TerarkZipTable_localTempdir enviroment variables to enable TerarkZipTable

To enable Terark algorithms, you need to set the environment variables. Only TerarkZipTable_localTempDir are required, the rest of them could be left as default, it shall works good in most cases:

mkdir terark-tempdir
sudo chown -R mysql:mysql terark-tempdir
sudo env \
  LD_LIBRARY_PATH=/path/to/terark-zip-rocksdb-package/lib:$LD_LIBRARY_PATH \
  TerarkZipTable_localTempDir=$PWD/terark-tempdir \
  support-files/mysql.server start

More options can be found here.

9. Check whether TerarkDB works

mysql -uroot -h0.0.0.0 -e\
"select * from information_schema.ROCKSDB_CF_OPTIONS
  where OPTION_TYPE='TABLE_FACTORY_NAME';"

If the output is:

+------------+--------------------+----------------+
| CF_NAME    | OPTION_TYPE        | VALUE          |
+------------+--------------------+----------------+
| __system__ | TABLE_FACTORY_NAME | TerarkZipTable |
| default    | TABLE_FACTORY_NAME | TerarkZipTable |
+------------+--------------------+----------------+

it means TerarkDB works.

And you can run

select * from information_schema.ROCKSDB_TF_OPTIONS;

in mysql client commandline to check the TerarkZipTable options you set before.