Quantcast
Channel: Percona Database Performance Blog
Viewing all articles
Browse latest Browse all 1810

Getting Started with RocksDB in Percona Server for MySQL

$
0
0
RocksDB in Percona Server for MySQL

RocksDB in Percona Server for MySQLYou may have read MyRocks Use Case: Big Dataset and been intrigued enough to want to evaluate RocksDB with InnoDB.  It has several advantages including requiring less storage space.

So how do you start?

On a fresh install of Percona Server for MySQL, install RocksDB by entering sudo apt install percona-server-rocksdb:

percona@DellXPS:~$ sudo apt install percona-server-rocksdb
[sudo] password for percona:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
percona-server-rocksdb
0 upgraded, 1 newly installed, 0 to remove and 32 not upgraded.
Need to get 65.3 MB of archives.
After this operation, 292 MB of additional disk space will be used.
Get:1 http://repo.percona.com/ps-80/apt focal/main amd64 percona-server-rocksdb amd64 8.0.29-21-1.focal [65.3 MB]
Fetched 65.3 MB in 8s (8531 kB/s)
Selecting previously unselected package percona-server-rocksdb.
(Reading database ... 78308 files and directories currently installed.)
Preparing to unpack .../percona-server-rocksdb_8.0.29-21-1.focal_amd64.deb ...
Unpacking percona-server-rocksdb (8.0.29-21-1.focal) ...
Setting up percona-server-rocksdb (8.0.29-21-1.focal) ...


* This release of Percona Server is distributed with RocksDB storage engine.
* Run the following script to enable the RocksDB storage engine in Percona Server:

ps-admin --enable-rocksdb -u <mysql_admin_user> -p[mysql_admin_pass] [-S <socket>] [-h <host> -P <port>]

Next, we can enable RocksDB by typing sudo ps-admin –enable-rocksdb -u -p:

percona@DellXPS:~$ sudo ps-admin --enable-rocksdb -u root -p
Enter password:

Checking if RocksDB plugin is available for installation ...
INFO: ha_rocksdb.so library for RocksDB found at /usr/lib/mysql/plugin/ha_rocksdb.so.

Checking RocksDB engine plugin status...
INFO: RocksDB engine plugin is not installed.

Installing RocksDB engine...
INFO: Successfully installed RocksDB engine plugin.

Now it is time to fire up a CLI for MySQL to run SHOW ENGINES to double-check that RocksDB is ready.

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

And now we can use RocksDB.

mysql> create schema rocks;
Query OK, 1 row affected (0.01 sec)

mysql> use rocks;
Database changed
mysql> create table r1 (id int, foo char(25)) engine=rocksdb;
Query OK, 0 rows affected (0.01 sec)

mysql> insert into r1 (id,foo) values (1,'test'),(2,'wow'),(3,'q');
Query OK, 3 rows affected (0.01 sec)
Records: 3  Duplicates: 0  Warnings: 0

mysql> select * from r1;
+------+------+
| id   | foo  |
+------+------+
|    1 | test |
|    2 | wow  |
|    3 | q    |
+------+------+
3 rows in set (0.00 sec)

Now how does this compare to Innodb? Well, I created a table like the one above but using InnoDB. Populated with the same three lines of data, the results do show a difference. I am sure with larger data sets that the saving with RocksDB would be substantially larger.

mysql> SELECT table_name AS `Table`, 
              round(((data_length + index_length) / 1024 / 1024), 2) `Size (MB)` 
       FROM information_schema.TABLES 
       WHERE table_schema = "rocks";
+-------+-----------+
| Table | Size (MB) |
+-------+-----------+
| i1    |      0.02 |
| r1    |      0.00 |
+-------+-----------+
2 rows in set (0.00 sec)

So give it a try and let me know your results.


Viewing all articles
Browse latest Browse all 1810

Trending Articles