zoukankan      html  css  js  c++  java
  • 基准测试工具 sysbench 之一 git安装

    os:centos 7.4
    mysql: 5.7

    sysbench是一个模块化的、跨平台、多线程基准测试工具,主要用于评估测试各种不同系统参数下的数据库负载情况。
    在不同硬件环境或数据库,提供一个基准性能参考。

    ##下载、安装sysbench

    安装依赖包

    # yum -y install bzr make automake libtool pkgconfig libaio-devel openssl-devel
    
    
    
    # cd /tmp
    # git clone https://github.com/akopytov/sysbench
    # cd sysbench
    # git branch -a
    * master
      remotes/origin/0.4
      remotes/origin/0.5
      remotes/origin/1.0
      remotes/origin/HEAD -> origin/master
      remotes/origin/master
      remotes/origin/travis_ppc64le
    
    # ./autogen.sh  
    # ./configure
    # make
    # make check
    # make install
    
    

    configure 有很多选项,也可以针对不同类型的数据库。不同数据库的依赖包也不一样。

    for mysql

    ./configure --with-mysql --with-mysql-includes=/usr/local/mysql/include --with-mysql-libs=/usr/local/mysql/lib
    

    for postgresql

    ./configure --with-pgsql --with-pgsql-includes=/usr/pgsql9.6/include --with-pgsql-libs=/usr/pgsql9.6/lib
    

    ##验证

    sysbench 的帮助文档

    # sysbench --version
    sysbench 1.1.0-e6e6a02
    # sysbench --help
    Usage:
      sysbench [options]... [testname] [command]
    
    Commands implemented by most tests: prepare run cleanup help
    
    General options:
      --threads=N                     number of threads to use [1]
      --events=N                      limit for total number of events [0]
      --time=N                        limit for total execution time in seconds [10]
      --warmup-time=N                 execute events for this many seconds with statistics disabled before the actual benchmark run with statistics enabled [0]
      --forced-shutdown=STRING        number of seconds to wait after the --time limit before forcing shutdown, or 'off' to disable [off]
      --thread-stack-size=SIZE        size of stack per thread [64K]
      --thread-init-timeout=N         wait time in seconds for worker threads to initialize [30]
      --rate=N                        average transactions rate. 0 for unlimited rate [0]
      --report-interval=N             periodically report intermediate statistics with a specified interval in seconds. 0 disables intermediate reports [0]
      --report-checkpoints=[LIST,...] dump full statistics and reset all counters at specified points in time. The argument is a list of comma-separated values representing the amount of time in seconds elapsed from start of test when report checkpoint(s) must be performed. Report checkpoints are off by default. []
      --debug[=on|off]                print more debugging info [off]
      --validate[=on|off]             perform validation checks where possible [off]
      --help[=on|off]                 print help and exit [off]
      --version[=on|off]              print version and exit [off]
      --config-file=FILENAME          File containing command line options
      --luajit-cmd=STRING             perform LuaJIT control command. This option is equivalent to 'luajit -j'. See LuaJIT documentation for more information
    
    Pseudo-Random Numbers Generator options:
      --rand-type=STRING   random numbers distribution {uniform, gaussian, special, pareto, zipfian} to use by default [special]
      --rand-seed=N        seed for random number generator. When 0, the current time is used as an RNG seed. [0]
      --rand-spec-iter=N   number of iterations for the special distribution [12]
      --rand-spec-pct=N    percentage of the entire range where 'special' values will fall in the special distribution [1]
      --rand-spec-res=N    percentage of 'special' values to use for the special distribution [75]
      --rand-pareto-h=N    shape parameter for the Pareto distribution [0.2]
      --rand-zipfian-exp=N shape parameter (exponent, theta) for the Zipfian distribution [0.8]
    
    Log options:
      --verbosity=N verbosity level {5 - debug, 0 - only critical messages} [3]
    
      --percentile=N       percentile to calculate in latency statistics (1-100). Use the special value of 0 to disable percentile calculations [95]
      --histogram[=on|off] print latency histogram in report [off]
    
    General database options:
    
      --db-driver=STRING  specifies database driver to use ('help' to get list of available drivers) [mysql]
      --db-ps-mode=STRING prepared statements usage mode {auto, disable} [auto]
      --db-debug[=on|off] print database-specific debug information [off]
    
    
    Compiled-in database drivers:
      mysql - MySQL driver
    
    mysql options:
      --mysql-host=[LIST,...]          MySQL server host [localhost]
      --mysql-port=[LIST,...]          MySQL server port [3306]
      --mysql-socket=[LIST,...]        MySQL socket
      --mysql-user=STRING              MySQL user [sbtest]
      --mysql-password=STRING          MySQL password []
      --mysql-db=STRING                MySQL database name [sbtest]
      --mysql-ssl[=on|off]             use SSL connections, if available in the client library [off]
      --mysql-ssl-key=STRING           path name of the client private key file
      --mysql-ssl-ca=STRING            path name of the CA file
      --mysql-ssl-cert=STRING          path name of the client public key certificate file
      --mysql-ssl-cipher=STRING        use specific cipher for SSL connections []
      --mysql-compression[=on|off]     use compression, if available in the client library [off]
      --mysql-debug[=on|off]           trace all client library calls [off]
      --mysql-ignore-errors=[LIST,...] list of errors to ignore, or "all" [1213,1020,1205]
      --mysql-dry-run[=on|off]         Dry run, pretend that all MySQL client API calls are successful without executing them [off]
    
    Compiled-in tests:
      fileio - File I/O test
      cpu - CPU performance test
      memory - Memory functions speed test
      threads - Threads subsystem performance test
      mutex - Mutex performance test
    
    See 'sysbench <testname> help' for a list of options for each test.
    

    主要包括如下的测试:

    fileio - File I/O test
    cpu - CPU performance test
    memory - Memory functions speed test
    threads - Threads subsystem performance test
    mutex - Mutex performance test

    ###fileio测试
    参考 /usr/local/share/sysbench/tests/t/test_fileio.t

    # cd /tmp
    # sysbench fileio help
    # sysbench fileio --file-num=4 --file-total-size=32M prepare
    # sysbench fileio --file-num=4 --file-total-size=32M --events=150 --file-test-mode=rndrw run
    # sysbench fileio --file-num=4 --file-total-size=32M --events=150 --file-test-mode=rndrd run
    # sysbench fileio --file-num=4 --file-total-size=32M --events=150 --file-test-mode=seqrd run
    # sysbench fileio --file-num=4 --file-total-size=32M --events=150 --file-test-mode=rndwr run
    # sysbench fileio --file-num=4 --file-total-size=32M --events=150 --file-test-mode=rndwr --validate run | grep Validation
    # sysbench fileio --file-num=4 --file-total-size=32M cleanup
    
    # sysbench fileio --file-num=4 --file-total-size=32M --verbosity=2 --file-total-size=1M prepare
    # sysbench fileio --file-num=4 --file-total-size=32M --verbosity=2 --file-test-mode=seqwr --events=1 run
    # sysbench fileio --file-num=4 --file-total-size=32M --verbosity=2 cleanup
    
    

    ###cpu测试
    参考 /usr/local/share/sysbench/tests/t/test_cpu.t

    # sysbench cpu help
    # sysbench cpu --cpu-max-prime=1000 --events=100 --threads=2 run
    

    ###memory测试
    参考 /usr/local/share/sysbench/tests/t/test_memory.t

    # args="memory --memory-block-size=4K --memory-total-size=1G --events=1 --time=0 --threads=2"
    # if [ "$(uname -s)" = "Linux" ]
      then
        sysbench $args help | grep hugetlb
      else
        echo "  --memory-hugetlb[=on|off]   allocate memory from HugeTLB pool [off]"
      fi
      
    
    # sysbench memory --memory-block-size=4K --memory-total-size=1G --events=1 --time=0 --threads=2 --memory-oper=read run
    # sysbench memory --memory-block-size=4K --memory-total-size=1G --events=1 --time=0 --threads=2 --memory-oper=write run  
    
    # sysbench memory --memory-block-size=4K --memory-total-size=1G --events=1 --time=0 --threads=2 --memory-scope=local --memory-oper=read run
    # sysbench memory --memory-block-size=4K --memory-total-size=1G --events=1 --time=0 --threads=2 --memory-scope=local --memory-oper=write run
    
    

    ###threads测试
    参考 /usr/local/share/sysbench/tests/t/test_threads.t

    # sysbench threads --events=100 --threads=2 run
    

    ###mutex测试
    参考 /usr/local/share/sysbench/tests/t/test_mutex.t

    # sysbench mutex --events=10 --threads=2 run
    

    参考:
    https://github.com/akopytov/sysbench/releases/latest
    https://github.com/akopytov/sysbench

    ./configure 选项如下

    # ./configure --help
    `configure' configures sysbench 1.1.0 to adapt to many kinds of systems.
    
    Usage: ./configure [OPTION]... [VAR=VALUE]...
    
    To assign environment variables (e.g., CC, CFLAGS...), specify them as
    VAR=VALUE.  See below for descriptions of some of the useful variables.
    
    Defaults for the options are specified in brackets.
    
    Configuration:
      -h, --help              display this help and exit
          --help=short        display options specific to this package
          --help=recursive    display the short help of all the included packages
      -V, --version           display version information and exit
      -q, --quiet, --silent   do not print `checking ...' messages
          --cache-file=FILE   cache test results in FILE [disabled]
      -C, --config-cache      alias for `--cache-file=config.cache'
      -n, --no-create         do not create output files
          --srcdir=DIR        find the sources in DIR [configure dir or `..']
    
    Installation directories:
      --prefix=PREFIX         install architecture-independent files in PREFIX
                              [/usr/local]
      --exec-prefix=EPREFIX   install architecture-dependent files in EPREFIX
                              [PREFIX]
    
    By default, `make install' will install all the files in
    `/usr/local/bin', `/usr/local/lib' etc.  You can specify
    an installation prefix other than `/usr/local' using `--prefix',
    for instance `--prefix=$HOME'.
    
    For better control, use the options below.
    
    Fine tuning of the installation directories:
      --bindir=DIR            user executables [EPREFIX/bin]
      --sbindir=DIR           system admin executables [EPREFIX/sbin]
      --libexecdir=DIR        program executables [EPREFIX/libexec]
      --sysconfdir=DIR        read-only single-machine data [PREFIX/etc]
      --sharedstatedir=DIR    modifiable architecture-independent data [PREFIX/com]
      --localstatedir=DIR     modifiable single-machine data [PREFIX/var]
      --libdir=DIR            object code libraries [EPREFIX/lib]
      --includedir=DIR        C header files [PREFIX/include]
      --oldincludedir=DIR     C header files for non-gcc [/usr/include]
      --datarootdir=DIR       read-only arch.-independent data root [PREFIX/share]
      --datadir=DIR           read-only architecture-independent data [DATAROOTDIR]
      --infodir=DIR           info documentation [DATAROOTDIR/info]
      --localedir=DIR         locale-dependent data [DATAROOTDIR/locale]
      --mandir=DIR            man documentation [DATAROOTDIR/man]
      --docdir=DIR            documentation root [DATAROOTDIR/doc/sysbench]
      --htmldir=DIR           html documentation [DOCDIR]
      --dvidir=DIR            dvi documentation [DOCDIR]
      --pdfdir=DIR            pdf documentation [DOCDIR]
      --psdir=DIR             ps documentation [DOCDIR]
    
    Program names:
      --program-prefix=PREFIX            prepend PREFIX to installed program names
      --program-suffix=SUFFIX            append SUFFIX to installed program names
      --program-transform-name=PROGRAM   run sed PROGRAM on installed program names
    
    System types:
      --build=BUILD     configure for building on BUILD [guessed]
      --host=HOST       cross-compile to build programs to run on HOST [BUILD]
      --target=TARGET   configure for building compilers for TARGET [HOST]
    
    Optional Features:
      --disable-option-checking  ignore unrecognized --enable/--with options
      --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
      --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
      --enable-silent-rules   less verbose build output (undo: "make V=1")
      --disable-silent-rules  verbose build output (undo: "make V=0")
      --enable-dependency-tracking
                              do not reject slow dependency extractors
      --disable-dependency-tracking
                              speeds up one-time build
      --enable-shared[=PKGS]  build shared libraries [default=yes]
      --enable-static[=PKGS]  build static libraries [default=yes]
      --enable-fast-install[=PKGS]
                              optimize for fast installation [default=yes]
      --disable-libtool-lock  avoid locking (might break parallel builds)
      --enable-largefile      enable large files support (default is enabled)
      --enable-aio            enable Linux asynchronous I/O support (default is
                              enabled)
      --disable-largefile     omit support for large files
      --enable-coverage       Toggle coverage [default=no]
      --enable-asan           Enable AddressSanitizer [default=no]
      --enable-msan           Enable MemorySanitizer [default=no]
      --disable-fail          Turn warnings into failures [default=no]
    
    Optional Packages:
      --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
      --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
      --with-gcc-arch=<arch>  use architecture <arch> for gcc -march/-mtune,
                              instead of guessing
      --with-pic[=PKGS]       try to use only PIC/non-PIC objects [default=use
                              both]
      --with-gnu-ld           assume the C compiler uses GNU ld [default=no]
      --with-sysroot=DIR Search for dependent libraries within DIR
                            (or the compiler's sysroot if not specified).
      --with-lib-prefix[=DIR] search for libraries in DIR/include and DIR/lib
      --without-lib-prefix    don't search for libraries in includedir and libdir
      --with-mysql            compile with MySQL support (default is enabled)
      --with-pgsql            compile with PostgreSQL support (default is
                              disabled)
      --with-system-luajit    Use system-provided LuaJIT headers and library
                              (requires pkg-config)
      --with-system-ck        Use system-provided Concurrency Kit headers and
                              library (requires pkg-config)
      --with-mysql-includes   path to MySQL header files
      --with-mysql-libs       path to MySQL libraries
      --with-pgsql-includes   path to PostgreSQL header files
      --with-pgsql-libs       path to PostgreSQL libraries
      --with-debug            Add debug code/turns off optimizations (yes|no)
                              [default=no]
    
    Some influential environment variables:
      CC          C compiler command
      CFLAGS      C compiler flags
      LDFLAGS     linker flags, e.g. -L<lib dir> if you have libraries in a
                  nonstandard directory <lib dir>
      LIBS        libraries to pass to the linker, e.g. -l<library>
      CPPFLAGS    (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
                  you have headers in a nonstandard directory <include dir>
      CPP         C preprocessor
      PKG_CONFIG  path to pkg-config utility
      PKG_CONFIG_PATH
                  directories to add to pkg-config's search path
      PKG_CONFIG_LIBDIR
                  path overriding pkg-config's built-in search path
      LUAJIT_CFLAGS
                  C compiler flags for LUAJIT, overriding pkg-config
      LUAJIT_LIBS linker flags for LUAJIT, overriding pkg-config
      CK_CFLAGS   C compiler flags for CK, overriding pkg-config
      CK_LIBS     linker flags for CK, overriding pkg-config
    
    Use these variables to override the choices made by `configure' or to help
    it to find libraries and programs with nonstandard names/locations.
    
    Report bugs to <https://github.com/akopytov/sysbench/issues>.
    sysbench home page: <https://github.com/akopytov/sysbench>.
    
  • 相关阅读:
    Linux Shell 重定向输入和输出
    NDK Cmake
    测试
    20行Python代码爬取王者荣耀全英雄皮肤
    SSH开发模式——Struts2(第一小节)
    JavaWeb开发——软件国际化(动态元素国际化)
    JavaWeb开发——软件国际化(文本元素国际化)
    DBUtils框架的使用(下)
    DBUtils框架的使用(上)
    SSH开发模式——Struts2(第二小节)
  • 原文地址:https://www.cnblogs.com/ctypyb2002/p/9792902.html
Copyright © 2011-2022 走看看