SysBench on CentOS – HowTo

If you want to test server performance, you can think about SysBench. SysBench is a modular, cross-platform and multi-threaded benchmark tool for evaluating OS parameters that are important for a system running a database under intensive load. The idea of this benchmark suite is to quickly get an impression about system performance without setting up complex database benchmarks or even without installing a database at all.

Current features allow to test the following system parameters:

* file I/O performance
* scheduler performance
* memory allocation and transfer speed
* POSIX threads implementation performance
* database server performance (OLTP benchmark)
(Primarily written for MySQL server benchmarking, SysBench will be further extended to support multiple database backends, distributed benchmarks and third-party plug-in modules)

I couldn’t find CentOS RPM so here are few tips how to install it manually.

Download Sysbench (current version is 0.4.12)

# wget http://garr.dl.sourceforge.net/sourceforge/sysbench/sysbench-0.4.12.tar.gz

Then unpack it and install with

# tar -xvzf sysbench-0.4.12.tar.gz
# cd sysbench-0.4.12
# libtoolize --force --copy 
# ./autogen.sh
# ./configure
# make
# make install

To test CPU performance you can try

# sysbench --test=cpu --cpu-max-prime=20000 run

For MySQL test, you’ll need to prepare database for testing with

# sysbench --test=oltp --mysql-table-engine=innodb --oltp-table-size=500000 --mysql-user=test_database --mysql-password=test_database_password --mysql-socket=/var/lib/mysql/mysql.sock prepare

(replace test_database with valid username and test_database_password with valid password)

This command will create sample table inside test_database and it will have 500 000 rows (InnoDB engine).

sysbench 0.4.12:  multi-threaded system evaluation benchmark
 
No DB drivers specified, using mysql
Creating table 'test-database'...
Creating 500000 records in table 'test-database'...

Now to start read test

# sysbench --num-threads=16 --max-requests=100000 --test=oltp --oltp-table-size=500000 --mysql-socket=/var/lib/mysql/mysql.sock --oltp-read-only --mysql-user=test_database --mysql-password=test_database_password run

For read-write test you can try

# sysbench --num-threads=16 --max-requests=10000 --test=oltp --oltp-table-size=500000 --mysql-socket=/var/lib/mysql/mysql.sock --oltp-test-mode=complex --mysql-user=test_database --mysql-password=test_database_password run

More info about specific parameters can be found in official docs (http://sysbench.sourceforge.net/docs/)

Basic MySQL operations I

In this post, I will present few basic commands for MySQL administration. You’ll see how to create a database, create user, assign a database for specific user, etc. First I suppose that you have root password set and that you know it… (in next posts I will present few steps to set this password or to recover it…)

Log in to mysql console:

 
[root@hydra mysql]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 248
Server version: 5.0.45 Source distribution
 
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
 
mysql>

Here you can see server version (in this case 5.0.45). With next command you can see all databases

 
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| birds              |
| mysql              |
| private             |
| bdd1             |
| test               |
+--------------------+
6 rows in set (0.05 sec)
 
mysql>

If you want to create a new database, enter next command (remember that all SQL commands must be terminated with ; )

mysql> create database db1;
Query OK, 1 row affected (0.00 sec)

Now we need to assign a user to newly created database. Also, we need to grant him all privileges for this database but restrict access and operations on another databases (except test database)

mysql> CREATE USER 'db1'@'localhost' IDENTIFIED BY 'db1pass';
Query OK, 0 rows affected (0.02 sec)
 
mysql> GRANT ALL PRIVILEGES ON db1.* TO 'db1'@'localhost' IDENTIFIED BY 'db1pass';
Query OK, 0 rows affected (0.01 sec)
 
mysql> quit;
Bye

After this you can repeat step from the beginning and test new user account. In next posts I will present phpMyadmin