Home  >   Blog  >   Programming   >   TokuDB in MariaDB (on Ubuntu)

2019-04-07

TokuDB in MariaDB (on Ubuntu)


TokuDB is a high-performance, scalable storage engine for MySQL/MariaDB. Since the engine is optimized for a large volume of data, nowadays it would become a reasonable option to build an in-house big data analytics solution.

As the first step toward making sure its effectiveness and efficiency, I simply tried to enable the storage engine in MariaDB running on an AWS EC2 instance. Let me share the whole procedure so that everyone can easily deep-dive into TokuDB itself, rather than some troublesome chores.

First, create an AWS EC2 instance with a security group that accepts port=3306 inbound request, and install the components as:

sudo apt-get update
sudo apt-get install mariadb-server mariadb-plugin-tokudb

Second, un-comment plugin-load-add in /etc/mysql/mariadb.conf.d/tokudb.cnf:

[mariadb]
# See https://mariadb.com/kb/en/how-to-enable-tokudb-in-mariadb/
# for instructions how to enable TokuDB
#
# See https://mariadb.com/kb/en/tokudb-differences/ for differences
# between TokuDB in MariaDB and TokuDB from http://www.tokutek.com/

plugin-load-add=ha_tokudb.so

Meanwhile, update bind-address configured in /etc/mysql/mariadb.conf.d/50-server.cnf as follows:

# this is read by the standalone daemon and embedded servers
[server]

# this is only for the mysqld standalone daemon
[mysqld]

#
# * Basic Settings
#
user            = mysql
pid-file        = /var/run/mysqld/mysqld.pid
socket          = /var/run/mysqld/mysqld.sock
port            = 3306
basedir         = /usr
datadir         = /var/lib/mysql
tmpdir          = /tmp
lc-messages-dir = /usr/share/mysql
skip-external-locking

# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
bind-address            = 0.0.0.0

Run the server:

# https://support.rackspace.com/how-to/installing-mysql-server-on-ubuntu/
# sudo ufw allow mysql
sudo systemctl restart mysql
sudo mysql

Next, create a user in the MySQL console:

CREATE USER 'username'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON *.* TO 'username'@'localhost' WITH GRANT OPTION;
CREATE USER 'username'@'%' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON *.* TO 'username'@'%' WITH GRANT OPTION;
FLUSH PRIVILEGES;

Create and see a dummy table with the TokuDB engine:

create database foo;
use foo;

CREATE TABLE sample_tokudb (
  id int NOT NULL AUTO_INCREMENT,
  name varchar(128),
  age integer,
  PRIMARY KEY (id)
) ENGINE=TokuDB;

INSERT INTO sample_tokudb (name, age) VALUES ('Joe', 28);
INSERT INTO sample_tokudb (name, age) VALUES ('Katie', 30);
INSERT INTO sample_tokudb (name, age) VALUES ('Tom', 26);

-- make sure if it's created with the TokuDB engine
SHOW TABLE STATUS WHERE Name = 'sample_tokudb';

Finally, we can remotely connect to a TokuDB-enabled table hosted by the MariaDB server:

mysql -u username -h $EC2_HOST -d sample_tokudb -p

We are now ready to play with the high-performance storage engine.

References

  Share


  Support (Thank you!)

  Gift a cup of coffee

Note that, as an Amazon Associate, I earn from qualifying purchases on amazon.ca.

  See also

2022-12-08
Mentoring on @ADPList. Here's What I Think. #ADPListWrapped
2019-01-14
Feeding User-Item Interactions to Python-Based Streaming Recommendation Engine via Faust
2018-10-26
Apache Hivemall at #ODSCEurope, #RecSys2018, and #MbedConnect

  More

Last updated: 2022-09-02

  Author: Takuya Kitazawa

Takuya Kitazawa is a freelance software developer, minimalistic traveler, ultralight hiker & runner, and craft beer enthusiast. While my area of specialty is in data & AI ethics and machine learning productization, I have worked full-stack throughout the career e.g., as a frontend/backend engineer, OSS developer, technical evangelist, solution architect, data scientist, and product manager. You can find what I am doing lately at my "now" page, and your inquiry is always welcome at [email protected], including comments on my blog posts.

  Schedule a call with me

  Disclaimer

  • Opinions are my own and do not represent the views of organizations I am/was belonging to.
  • I am doing my best to ensure the accuracy and fair use of the information. However, there might be some errors or biased subjective statements because the main purpose of this blog is to jot down my personal thoughts as soon as possible before conducting an extensive investigation. Visitors understand the limitations and rely on any information at their own risk.
  • That said, if there is any issue with the content, please contact me so I can take the necessary action.