Coder Social home page Coder Social logo

sysbench-docker's Introduction

sysbench on Docker

Sysbench 1.0.17 on Docker environment.

Example Usage

Requirement

Create a MySQL database and user for sysbench:

mysql> CREATE SCHEMA sbtest;
mysql> CREATE USER sbtest@'%' IDENTIFIED BY 'password';
mysql> GRANT ALL PRIVILEGES ON sbtest.* to sbtest@'%';

Or simply use the respective MySQL's image environment variables to create the database and user when running the MySQL container.

Docker

Prepare the sysbench database:

$ docker run \
--rm=true \
--name=sb-prepare \
severalnines/sysbench \
sysbench \
--db-driver=mysql \
--oltp-table-size=100000 \
--oltp-tables-count=24 \
--threads=1 \
--mysql-host=10.0.0.51 \
--mysql-port=3306 \
--mysql-user=sbtest \
--mysql-password=password \
/usr/share/sysbench/tests/include/oltp_legacy/parallel_prepare.lua \
run

Run the benchmark for MySQL:

$ docker run \
--name=sb-run \
severalnines/sysbench \
sysbench \
--db-driver=mysql \
--report-interval=2 \
--mysql-table-engine=innodb \
--oltp-table-size=100000 \
--oltp-tables-count=24 \
--threads=64 \
--time=99999 \
--mysql-host=10.0.0.51 \
--mysql-port=3306 \
--mysql-user=sbtest \
--mysql-password=password \
/usr/share/sysbench/tests/include/oltp_legacy/oltp.lua \
run

Kubernetes

You can run sysbench data preparation as a Job:

apiVersion: batch/v1
kind: Job
metadata:
  name: sysbench-prepare
spec:
  template:
    metadata:
      name: sysbench-prepare
    spec:
      containers:
      - name: sysbench-prepare
        image: severalnines/sysbench
        command:
        - sysbench
        - --db-driver=mysql
        - --oltp-table-size=100000
        - --oltp-tables-count=24
        - --threads=1
        - --mysql-host=galera
        - --mysql-port=3306
        - --mysql-user=sbtest
        - --mysql-password=password
        - /usr/share/sysbench/tests/include/oltp_legacy/parallel_prepare.lua
        - run
      restartPolicy: Never

Post the job to Kubernetes:

$ kubectl create -f sysbench-prepare-job.yml

Once the sysbench database is prepared, run the benchmark for MySQL through a Pod:

apiVersion: v1
kind: Pod
metadata:
  labels:
    app: sysbench
  name: sysbench
spec:
  containers:
  - command:
    - sysbench
    - --db-driver=mysql
    - --report-interval=2
    - --mysql-table-engine=innodb
    - --oltp-table-size=100000
    - --oltp-tables-count=24
    - --threads=64
    - --time=99999
    - --mysql-host=galera
    - --mysql-port=3306
    - --mysql-user=sbtest
    - --mysql-password=password
    - /usr/share/sysbench/tests/include/oltp_legacy/oltp.lua
    - run
    image: severalnines/sysbench
    name: sysbench
  restartPolicy: Never

Post the job to Kubernetes:

$ kubectl create -f sysbench-pod.yml

See the sysbench reporting output using kubectl:

$ kubectl logs -f sysbench

sysbench-docker's People

Contributors

ashraf-s9s avatar fipar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

sysbench-docker's Issues

ERROR: Table 'sbtest1' already exists

You can reproduce this on Docker Playground running:

docker network create my-net

docker run \
  --name mysql \
  --network my-net \
  --rm \
  -e MYSQL_ALLOW_EMPTY_PASSWORD='1' \
  -e MYSQL_DATABASE=sbtest \
  -e MYSQL_USER=sbtest \
  -e MYSQL_PASSWORD=password \
  -p 3306:3306 \
  -d mysql:5.7

docker run \
  --network my-net \
  --name=sb-prepare \
  --rm \
  severalnines/sysbench \
  sysbench \
  --db-driver=mysql \
  --oltp-table-size=100 \
  --oltp-tables-count=24 \
  --threads=1 \
  --mysql-host=mysql \
  --mysql-port=3306 \
  --mysql-user=sbtest \
  --mysql-password=password \
  /usr/share/sysbench/tests/include/oltp_legacy/parallel_prepare.lua \
  run

The output of the last command (sysbench) is:

sysbench 1.0.17 (using bundled LuaJIT 2.1.0-beta2)

Running the test with following options:
Number of threads: 1
Initializing random number generator from current time


Initializing worker threads...

Threads started!

thread prepare0
Creating table 'sbtest1'...
Inserting 100 records into 'sbtest1'
Creating secondary indexes on 'sbtest1'...
Creating table 'sbtest2'...
Inserting 100 records into 'sbtest2'
Creating secondary indexes on 'sbtest2'...
Creating table 'sbtest3'...
Inserting 100 records into 'sbtest3'
Creating secondary indexes on 'sbtest3'...
Creating table 'sbtest4'...
Inserting 100 records into 'sbtest4'
Creating secondary indexes on 'sbtest4'...
Creating table 'sbtest5'...
Inserting 100 records into 'sbtest5'
Creating secondary indexes on 'sbtest5'...
Creating table 'sbtest6'...
Inserting 100 records into 'sbtest6'
Creating secondary indexes on 'sbtest6'...
Creating table 'sbtest7'...
Inserting 100 records into 'sbtest7'
Creating secondary indexes on 'sbtest7'...
Creating table 'sbtest8'...
Inserting 100 records into 'sbtest8'
Creating secondary indexes on 'sbtest8'...
Creating table 'sbtest9'...
Inserting 100 records into 'sbtest9'
Creating secondary indexes on 'sbtest9'...
Creating table 'sbtest10'...
Inserting 100 records into 'sbtest10'
Creating secondary indexes on 'sbtest10'...
Creating table 'sbtest11'...
Inserting 100 records into 'sbtest11'
Creating secondary indexes on 'sbtest11'...
Creating table 'sbtest12'...
Inserting 100 records into 'sbtest12'
Creating secondary indexes on 'sbtest12'...
Creating table 'sbtest13'...
Inserting 100 records into 'sbtest13'
Creating secondary indexes on 'sbtest13'...
Creating table 'sbtest14'...
Inserting 100 records into 'sbtest14'
Creating secondary indexes on 'sbtest14'...
Creating table 'sbtest15'...
Inserting 100 records into 'sbtest15'
Creating secondary indexes on 'sbtest15'...
Creating table 'sbtest16'...
Inserting 100 records into 'sbtest16'
Creating secondary indexes on 'sbtest16'...
Creating table 'sbtest17'...
Inserting 100 records into 'sbtest17'
Creating secondary indexes on 'sbtest17'...
Creating table 'sbtest18'...
Inserting 100 records into 'sbtest18'
Creating secondary indexes on 'sbtest18'...
Creating table 'sbtest19'...
Inserting 100 records into 'sbtest19'
Creating secondary indexes on 'sbtest19'...
Creating table 'sbtest20'...
Inserting 100 records into 'sbtest20'
Creating secondary indexes on 'sbtest20'...
Creating table 'sbtest21'...
Inserting 100 records into 'sbtest21'
Creating secondary indexes on 'sbtest21'...
Creating table 'sbtest22'...
Inserting 100 records into 'sbtest22'
Creating secondary indexes on 'sbtest22'...
Creating table 'sbtest23'...
Inserting 100 records into 'sbtest23'
Creating secondary indexes on 'sbtest23'...
Creating table 'sbtest24'...
Inserting 100 records into 'sbtest24'
Creating secondary indexes on 'sbtest24'...
thread prepare0
Creating table 'sbtest1'...
FATAL: mysql_drv_query() returned error 1050 (Table 'sbtest1' already exists) for query 'CREATE TABLE sbtest1 (
id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
k INTEGER UNSIGNED DEFAULT '0' NOT NULL,
c CHAR(120) DEFAULT '' NOT NULL,
pad CHAR(60) DEFAULT '' NOT NULL,
PRIMARY KEY (id)
) /*! ENGINE = innodb MAX_ROWS = 1000000 */ '
FATAL: `thread_run' function failed: /usr/share/sysbench/tests/include/oltp_legacy/common.lua:66: db_query() failed
Error in my_thread_global_end(): 1 threads didn't exit

I expect this to run without an error.

C:\Program Files\Docker\Docker\Resources\bin\docker.exe: Error response from daemon: OCI runtime create failed: container_linux.go:345: starting container process caused "exec: \"--db-driver=mysql\": executable file not found in $PATH": unknown.

This image in windows10 docker running error:
Steps to reproduce the behavior

C:\Program Files\Docker\Docker\Resources\bin\docker.exe: Error response from daemon: OCI runtime create failed: container_linux.go:345: starting container process caused "exec: \"--db-driver=mysql\": executable file not found in $PATH": unknown.
PS C:\WINDOWS\system32> docker run --rm=true --name=sb-prepare  severalnines/sysbench --db-driver=mysql --oltp-table-size=100000 --oltp-tables-count=24 --thread=1 --mysql-host=localhost --mysql-user=sbtest --mysql-password=12345 /usr/share/sysbench/tests/include/oltp_legacy/parallel_prepare.lua run
C:\Program Files\Docker\Docker\Resources\bin\docker.exe: Error response from daemon: OCI runtime create failed: container_linux.go:345: starting container process caused "exec: \"--db-driver=mysql\": executable file not found in $PATH": unknown.

Output of docker version:

PS C:\WINDOWS\system32> docker version
Client: Docker Engine - Community
 Version:           19.03.2
 API version:       1.40
 Go version:        go1.12.8
 Git commit:        6a30dfc
 Built:             Thu Aug 29 05:26:49 2019
 OS/Arch:           windows/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          19.03.2
  API version:      1.40 (minimum version 1.12)
  Go version:       go1.12.8
  Git commit:       6a30dfc
  Built:            Thu Aug 29 05:32:21 2019
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          v1.2.6
  GitCommit:        894b81a4b802e4eb2a91d1ce216b8817763c29fb
 runc:
  Version:          1.0.0-rc8
  GitCommit:        425e105d5a03fabd737a126ad93d62a9eeede87f
 docker-init:
  Version:          0.18.0
  GitCommit:        fec3683

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.