Foreword
The previous article talked about YCSB’s performance test of MySQL on the RISC-V server (RISC-V public beta platform released · Use YCSB to test the performance of MySQL on SG2042). In this article, we continue to discuss the applications of RISC-V+ database in depth. We will continue to use the HS-2 platform to test the compatibility of database software on the RISC-V server.
The databases involved in this experiment are as follows:
Redis
MongoDB5
PostgreSQL
TiDB
MySQL/MariaDB
The experimental machine configuration is as follows:
Processor: SG2042 (64 cores)
Memory: 32GB
Operating system: Ubuntu 22.10 (GNU/Linux 6.1.31 riscv64)
1. MySQL/MariaDB
In the previous article, in order to test the YCSB (Yahoo! Cloud Serving Benchmark) performance testing software, the compatibility of MySQL on the RISC-V server was tested.
MySQL Database Service is a fully managed database service that can deploy cloud-native applications using the world’s most popular open source database. It is 100% developed, managed and supported by MySQL.
Install MySQL directly using the package manager:
sudo apt-get install mysql-server
Of course, in addition to the package manager installation, we also tried to compile and install MySQL, but the result indicated that the compilation failed. Therefore, MySQL cannot be directly compiled to install, it needs to be patched before compiling.
At the same time, the compatibility of MariaDB, a general open-source relational database management system, on the RISC-V server was also tested. It is one of the most popular database servers in the world, MariaDB is released under the GPLv2 open-source license and is guaranteed to remain open source.
First try installing directly through the package manager:
sudo apt-get install mariadb-server
After installing and running normally through the package manager, try to install MariaDB by compiling.
First download the MariaDB source code package and unzip it:
wget https://dlm.mariadb.com/3239838/MariaDB/mariadb-11.0.2/source/mariadb-11.0.2.tar.gz
Enter the MariaDB source code folder:
tar -xzvf mariadb-11.0.2.tar.gz
Run the cmake and compile it:
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mariadb -DMYSQL_DATADIR=/home/mariadb
-DSYSCONFDIR=/etc -DWITHOUT_TOKUDB=1 -DWITH_INNOBASE_STORAGE_ENGINE=1
-DWITH_ARCHIVE_STPRAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1
-DWIYH_READLINE=1 -DWIYH_SSL=system -DVITH_ZLIB=system -DWITH_LOBWRAP=0
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DDEFAULT_CHARSET=utf8
-DDEFAULT_COLLATION=utf8_general_ci
make -j64
sudo make install -j1
Open the configuaration file and edit:
vim /home/mariadb/my.cnf
Start the server and test whether it can connect the database server:
sudo /usr/local/mariadb/bin/mysqld_safe --user=mysql --skip-grant-tables
/usr/local/mariadb/bin/mariadb
Successfully connect!
2. Redis
Next is Redis, which is called REmote DIctionary Server (Redis), written by Salvatore Sanfilippo. It is an open source, written in ANSI C language, complies with the BSD protocol, supports network, memory-based, distributed, optional persistence key-value pair (Key-Value) storage database, and provides multiple languages APIs.
Redis is often called a data structure server because values can be of types such as String, Hash, list, sets, and sorted sets.
Install Redis via APT:
sudo apt install redis-server
Start the Redis service:
sudo servcie redis-server start
Enter the redis-cli:
redis-cli
Installing is success if can enter the Redis Shell
Compie and install:
wget https://github.com/redis/redis/archive/refs/tags/7.0.12.tar.gz
Unzip:
tar -xzvf 7.0.12.tar.gz
Enter the Redis folder:
cd redis-7.0.12/
Compilation:
make BUILD_TLS=yes USE_SYSTEMD=yes -j64
Test(optional):
make test
Install:
sudo make install
Start the server:
redis-server
redis-server & (run at background)
run redis-benchmark stress test(100,000 requests, 20 clients)output as CSV
redis-benchmark -n 100000 -c 20 --csv
Results are as follows:
Therefore, Redis can be installed through APT installation or compilation installation.
3. MongoDB
Next is MongoDB, which is a database based on distributed file storage. Written in C++ language. Designed to provide scalable, high-performance data storage solutions for WEB applications. MongoDB is a product between a relational database and a non-relational database. It is the most feature-rich among non-relational databases and is most like a relational database.
Install MongoDB via APT:
sudo apt install mongodb
The result indicates that installation through apt is not supported, so we choose to compile and install from source code.
Download the source code package:
wget https://fastdl.mongodb.org/src/mongodb-src-r6.0.8.tar.gz
Unzip:
tar -xzvf mongodb-src-r6.0.8.tar.gz
Enter the mongodb source code folder:
cd mongodb-src-r6.0.8/
Compilation:
python3 buildscripts/scons.py install-mongod -j64
Compilation failed:
After installing the relevant packages, it still fails to compile.
4. PostgreSQL
Then is PostgreSQL, a free object-relational database server (ORDBMS) released under a flexible BSD license. PostgreSQL developers pronounce it post-gress-Q-L. PostgreSQL’s Slogan is “the world’s most advanced open-source relational database”.
Install via APT:
apt-get install postgresql postgresql-client
Test:
sudo -i -u postgres
psql
Compile and install:
Download the source code:
wget https://ftp.postgresql.org/pub/source/v15.3/postgresql-15.3.tar.gz
Unzip:
tar -xzvf postgresql-15.3.tar.gz
New pg folder:
mkdir pg
Enter it:
cd postgresql-15.3/
Configure it:
./configure --prefix=/home/perfxlab01/pg
Compile and install:
make world -j64
make install-world -j64
enter ~/pg/
Initialize database:
./bin/initdb -D ./data/
Start database:
bin/pg_ctl -D ./data/ -l logfile start
After successfully start the database, the next step is to test the database performance. PostgreSQL, like Redis, also comes with a stress test program.
Create a new database for stress testing:
bin/psql -U postgres -h localhost
(Enter psql shell)
CREATE DATABASE test;
(Exit psql shell)
Initialize the database for stress testing:
bin/pgbench -i test
Start the stress test:
bin/pgbench -c 100 -T 300 -j 64 test
The stress test results are as follows:
pgbench (15.3)
transaction type: <builtin: TPC-B (sort of)>
scaling factor: 1
query mode: simple
number of clients: 100
number of threads: 64
maximum number of tries: 1
duration: 300 s
number of transactions actually processed: 93122
number of failed transactions: 0 (0.000%)
latency average = 322.405 ms
initial connection time = 156.199 ms
tps = 310.168586 (without initial connection time)
statement latencies in milliseconds and failures:
0.005 0 \set aid random(1, 100000 * :scale)
0.002 0 \set bid random(1, 1 * :scale)
0.002 0 \set tid random(1, 10 * :scale)
0.002 0 \set delta random(-5000, 5000)
0.201 0 BEGIN;
1.144 0 UPDATE pgbench_accounts SET abalance = abalance + :delta WHERE aid = :aid;
0.429 0 SELECT abalance FROM pgbench_accounts WHERE aid = :aid;
290.788 0 UPDATE pgbench_tellers SET tbalance = tbalance + :delta WHERE tid = :tid;
26.624 0 UPDATE pgbench_branches SET bbalance = bbalance + :delta WHERE bid = :bid;
0.432 0 INSERT INTO pgbench_history (tid, bid, aid, delta, mtime) VALUES (:tid, :bid, :aid, :delta, CURRENT_TIMESTAMP);
2.556 0 END;
5. TiDB
Next is TiDB. TiDB is an open source distributed relational database independently designed and developed by PingCAP. The database is written in Go language.
Download the latest version of the TiDB source code package, unzip it and enter the source code folder, then compile:
The compilation failed:
tar -xzvf tidb-7.1.1.tar.gz
cd tidb-7.1.1/
make
At the same time, SOPHGO and PingCap together are working on software porting.
Summarization:
Through this experiment, the following results were obtained.
Database | APT installation/script installation | Compile and install |
---|---|---|
Redis | √ | √ |
MongoDB | × | × |
PostgreSQL | √ | √ |
TiDB | √ | √ |
MySQL | √ | × |
MariaDB | √ | √ |
-
last time I mentioned that MySQL does not support direct compilation and installation, and can only be compiled by applying the patch provided by Ubuntu (see MySQL server fails to build on RISC-V 64 for details), while MariaDB is installed through compilation or package management There are two ways to install the device. However, after compiling and installing, further manual configuration is required (see reference materials for the tutorial), and the installation system through the package manager will automatically configure it for you, and it will work out of the box. Therefore, it is recommended to install MySQL/MariaDB through APT (package manager). More time-saving and convenient.
-
Among the four database software tested so far, MongoDB only has a software package suitable for Ubuntu 22.04 LTS, while TiDB does not support riscv64 whether it is installed by script or compiled. Therefore, we hope that the support of these two databases on the RISC-V architecture will be strengthened.
-
The most outstanding performers in this compatibility test are PostgreSQL and Redis. Both of them compiled smoothly and can run normally. It shows that the compatibility of these two databases with riscv64 is very good. Especially for PostgreSQL, some community members in the PostgreSQL BuildFarm have successfully compiled using the compiler on the riscv64 platform. Therefore, it is inevitable that PostgreSQL can be successfully compiled and run on the riscv64 platform.
-
Both Redis and PostgreSQL come with their own stress testing tools. Redis’s redis-benchmark sets the stress test parameters, and then just wait for the test results to be released. Compared with redis-benchmark, PostgreSQL’s pgbench only needs to set the stress test parameters. Just add the two steps of creating a test database and initializing the test database. Therefore, the built-in stress test program is a plus for these two databases, because using the built-in stress test program can help users understand the performance of the server in terms of databases.
References:
Introduction to MariaDB
MariaDB 简介 - MariaDB.org
Redis tutorial
Redis 教程 | 菜鸟教程
MongoDB official website
https://www.mongodb.com/zh-cn
MongoDB developer community
When to upload version on Debian? - Drivers - MongoDB Developer Community Forums
mongodb-server binary package in Ubuntu Focal riscv64
mongodb-server : riscv64 : Focal (20.04) : Ubuntu
MySQL server fails to build on RISC-V 64
https://bugs.mysql.com/bug.php?id=100356
Deploy Mariadb database to Linux (source code compilation and installation)
部署mariadb数据库到linux(源码编译安装) - asml - 博客园
PostgreSQL BuildFarm Status
PostgreSQL BuildFarm Status
PostgreSQL BuildFarm Status History
PostgreSQL BuildFarm History
End of text