I was trying to get OLTP-Bench working with PostgreSQL on Ubuntu 14.04. For some reason, the project’s wiki was not working properly at the time; so I wanted to document my experience here.
Installing software packages
If you need to install PostgreSQL on Ubuntu, here is a nice guide. For illustration purposes, we will use TPC-C benchmark. You may need to set a password for the default user (e.g. postgres).
You also need to install some tools such as Git, Ant, and Java (JDK).
$ sudo apt-get install openjdk-7-jdk git ant
Creating database
You also need to crate a database for the benchmark lets call it “tpcc”. This can be created as follows:
$ sudo -i -u postgres
$ createdb tpcc; exit
Downloading and Building OLTP-Bench software
Go back to the home directory:
$ cd ~
Get the source code:
$ git clone https://github.com/oltpbenchmark/oltpbench
$ cd oltpbench
Build it using Apache Ant:
$ ant
If the building process was successful, you are ready to run the benchmark.
Running a benchmark (Example TPC-C)
First, we need to modify the sample config file called “config/sample_tpcc_config.xml”, and replace the connection information with the correct information. Assuming “postgres” for the username with the same as the password, here is an example:
<!-- Connection details --> <!-- MySQL <dbtype>mysql</dbtype> <driver>com.mysql.jdbc.Driver</driver> <DBUrl>jdbc:mysql://localhost:3306/tpcc</DBUrl> <username>tpcc</username> <password>tpcc</password> <isolation>TRANSACTION_SERIALIZABLE</isolation> --> <dbtype>postgres</dbtype> <driver>org.postgresql.Driver</driver> <DBUrl>jdbc:postgresql://127.0.0.1:5432/tpcc</DBUrl> <DBName>tpcc</DBName> <username>postgres</username> <password>postgres</password> <terminals>10</terminals>
Loading Data
Load data into PostgreSQL; using the following:
$ ./oltpbenchmark -b tpcc -c config/sample_tpcc_config.xml --create=true --load=true
Running the Benchmark
You can run the benchmark using the following:
$ ./oltpbenchmark -b tpcc -c config/sample_tpcc_config.xml --execute=true -s 5 -o outputfile