赞
踩
- sysbench测试三部曲:
-
- prepare -> run -> cleanup
-
- 帮助信息
-
- [root@localhost ~]# 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]
- --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]
- --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
- --tx-rate=N deprecated alias for --rate [0]
- --max-requests=N deprecated alias for --events [0]
- --max-time=N deprecated alias for --time [0]
- --num-threads=N deprecated alias for --threads [1]
-
- Pseudo-Random Numbers Generator options:
- --rand-type=STRING random numbers distribution {uniform,gaussian,special,pareto} [special]
- --rand-spec-iter=N number of iterations used for numbers generation [12]
- --rand-spec-pct=N percentage of values to be treated as 'special' (for special distribution) [1]
- --rand-spec-res=N percentage of 'special' values to use (for special distribution) [75]
- --rand-seed=N seed for random number generator. When 0, the current time is used as a RNG seed. [0]
- --rand-pareto-h=N parameter h for pareto distribution [0.2]
-
- 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
- pgsql - PostgreSQL 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-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]
-
- pgsql options:
- --pgsql-host=STRING PostgreSQL server host [localhost]
- --pgsql-port=N PostgreSQL server port [5432]
- --pgsql-user=STRING PostgreSQL user [sbtest]
- --pgsql-password=STRING PostgreSQL password []
- --pgsql-db=STRING PostgreSQL database name [sbtest]
-
- 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.
-
- Sysbench的测试主要包括以下几个方面:
-
- 1、磁盘io性能
-
- 2、cpu性能
-
- 3、内存分配及传输速度
-
- 4、POSIX线程性能
-
- 5、调度程序性能
-
- 6、数据库性能(OLTP基准测试).
- 使用示例:
-
- 1.准备三个10G的文件
-
- sysbench fileio --max-requests=1000000 --num-threads=4 --file-num=3 --file- total-size=30G --file-test-mode=rndwr prepare
-
- 2.测试cpu性能
-
- sysbench --threads=4 cpu --cpu-max-prime=10000000 run
-
- 3.测试内存顺序读
-
- sysbench --threads=4 memory --memory-total-size=6G --memory-oper=read -- memory-access-mode=seq run
-
- 4.测试内存随机读
-
- sysbench --threads=4 --test=memory --memory-total-size=6G --memory- oper=read --memory-access-mode=rnd run
-
- 5.测试内存性能顺序写
-
- sysbench --threads=4 --test=memory --memory-total-size=6G --memory- oper=write --memory-access-mode=seq run
-
- 6.测试内存性能随机写
-
- sysbench --threads=4 --test=memory --memory-total-size=6G --memory-oper=write --memory-access-mode=rnd run
-
- 7.测试硬盘随机读写
-
- sysbench fileio --max-requests=1000000 --num-threads=4 --file-num=3 --file-total-size=30G --file-test-mode=rndrw run
-
- 8.测试硬盘随机读
-
- sysbench fileio --max-requests=1000000 --num-threads=4 --file-num=3 --file-total-size=30G --file-test-mode=rndrd run
-
- 9.测试硬盘随机写
-
- sysbench fileio --max-requests=1000000 --num-threads=4 --file-num=3 --file-total-size=30G --file-test-mode=rndwr run
-
- 10.测试硬盘顺序重写
-
- sysbench fileio --max-requests=1000000 --threads=4 --file-num=3 --file-total-size=30G --file-test-mode=seqrewr run
-
- 11.测试硬盘顺序读
-
- sysbench fileio --max-requests=1000000 --num-threads=4 --file-num=3 --file-total-size=30G --file-test-mode=seqrd run
-
- 12.测试硬盘性能顺序写
-
- sysbench fileio --max-requests=1000000 --num-threads=4 --file-num=3 --file-total-size=30G --file-test-mode=seqwr run
-
- 针对数据库性能的测试
-
- mysql数据库
-
- 1.创建测试库
-
- mysql> create database sysbench_test;
-
- 2.准备测试数据
-
- sysbench /usr/share/sysbench/oltp_read_write.lua --tables=3 --table_size=10000000 --mysql-user=root --mysql-password=123456 --mysql-host=192.168.80.100 --mysql-port=3306 --mysql-db=sysbench_test prepare
-
- 3.数据库测试
-
- sysbench /usr/share/sysbench/oltp_point_select.lua --tables=3 --table_size=10000000 --mysql-user=root --mysql-password=123456 --mysql-host=192.168.80.100 --mysql-port=3306 --mysql-db=sysbench_test --threads=128 --time=100 --report-interval=5 run
-
-
- 关注指标:
-
- response time avg:平均响应时间(后面的95%的大小可以通过–percentile=98的方式去更改)。
- transactions:精确的说是这一项后面的TPS,但如果使用了–skip-trx=on,这项事务数为0,需要用total number of events去除以总时间,得到tps(其实还可以分为读tps和写tps)。
- queries:用它除以总时间,得到吞吐量QPS。
-
-
- #清理数据
-
- sysbench /usr/share/sysbench/oltp_read_write.lua --tables=3 --table_size=10000000 --mysql-user=root --mysql-password=123456 --mysql-host=192.168.80.100 --mysql-port=3306 --mysql-db=sysbench_test cleanup
-
-
- 各个脚本的测试用途:
-
- oltp_read_write:测试数据库的总和读写tps
-
- oltp_read_only:测试数据库的只读性能
-
- oltp_delete: 测试数据库删除性能
-
- oltp_update_index:测试数据库更新索引字段等的性能
-
- oltp_insert: 测试数据库数据插入性能
-
- oltp_write_only:测试数据库的写入性能
-
- oltp_point_select:测试数据库的查询性能
- postgresql数据库
-
- 1.准备创建表和数据:
- sysbench --db-driver=pgsql --time=1 --threads=1000 --report-interval=5 --pgsql-host=192.168.1.100 --pgsql-port=5001 --pgsql-user=testpgs --pgsql-password=123456 --pgsql-db=test_db --tables=1 --table_size=1000000 oltp_read_write --db-ps-mode=disable prepare
-
- 2.测试数据库的只读性能,使用的是oltp_read_only模式:
- sysbench --db-driver=pgsql --time=1 --threads=1000 --report-interval=5 --pgsql-host=192.168.1.100 --pgsql-port=5001 --pgsql-user=testpgs --pgsql-password=123456 --pgsql-db=test_db --tables=1 --table_size=1000000 oltp_read_only --db-ps-mode=disable run
-
-
- SQL statistics:
- queries performed:
- read: 25242
- write: 0
- other: 3606
- total: 28848
- transactions: 1803 (859.40 per sec.)
- queries: 28848 (13750.37 per sec.)
- ignored errors: 0 (0.00 per sec.)
- reconnects: 0 (0.00 per sec.)
-
- General statistics:
- total time: 2.0931s
- total number of events: 1803
-
- Latency (ms):
- min: 204.65
- avg: 865.57
- max: 1312.73
- 95th percentile: 1191.92
- sum: 1560630.86
-
- 3. 测试数据库的删除性能,使用的是oltp_delete模式:
- sysbench --db-driver=pgsql --time=1 --threads=1000 --report-interval=5 --pgsql-host=192.168.1.100 --pgsql-port=5001 --pgsql-user=testpgs --pgsql-password=123456 --pgsql-db=test_db --tables=1 --table_size=1000000 oltp_delete --db-ps-mode=disable run
-
- SQL statistics:
- queries performed:
- read: 0
- write: 11506
- other: 9290
- total: 20796
- transactions: 20796 (16813.13 per sec.)
- queries: 20796 (16813.13 per sec.)
- ignored errors: 0 (0.00 per sec.)
- reconnects: 0 (0.00 per sec.)
-
- General statistics:
- total time: 1.2349s
- total number of events: 20796
-
- Latency (ms):
- min: 3.16
- avg: 51.30
- max: 255.24
- 95th percentile: 58.92
- sum: 1066896.74
-
-
- 4.测试数据库的更新索引字段的性能,使用的是oltp_update_index模式:
- sysbench --db-driver=pgsql --time=1 --threads=1000 --report-interval=5 --pgsql-host=192.168.1.100 --pgsql-port=5001 --pgsql-user=testpgs --pgsql-password=123456 --pgsql-db=test_db --tables=1 --table_size=1000000 oltp_update_index --db-ps-mode=disable run
-
- SQL statistics:
- queries performed:
- read: 0
- write: 17355
- other: 0
- total: 17355
- transactions: 17355 (14499.51 per sec.)
- queries: 17355 (14499.51 per sec.)
- ignored errors: 0 (0.00 per sec.)
- reconnects: 0 (0.00 per sec.)
-
- General statistics:
- total time: 1.1948s
- total number of events: 17355
-
- Latency (ms):
- min: 5.27
- avg: 61.99
- max: 244.16
- 95th percentile: 75.82
- sum: 1075762.57
-
- 5.测试数据库的更新非索引字段的性能,使用的是oltp_update_non_index模式:
- sysbench --db-driver=pgsql --time=1 --threads=1000 --report-interval=5 --pgsql-host=192.168.1.100 --pgsql-port=5001 --pgsql-user=testpgs --pgsql-password=123456 --pgsql-db=test_db --tables=1 --table_size=1000000 oltp_update_non_index --db-ps-mode=disable run
-
- SQL statistics:
- queries performed:
- read: 0
- write: 17801
- other: 0
- total: 17801
- transactions: 17801 (14435.25 per sec.)
- queries: 17801 (14435.25 per sec.)
- ignored errors: 0 (0.00 per sec.)
- reconnects: 0 (0.00 per sec.)
-
- General statistics:
- total time: 1.2312s
- total number of events: 17801
-
- Latency (ms):
- min: 13.85
- avg: 60.14
- max: 261.74
- 95th percentile: 82.96
- sum: 1070611.81
-
- 6.测试数据库的插入性能,使用的是oltp_insert模式:
- sysbench --db-driver=pgsql --time=1 --threads=1000 --report-interval=5 --pgsql-host=192.168.1.100 --pgsql-port=5001 --pgsql-user=testpgs --pgsql-password=123456 --pgsql-db=test_db --tables=1 --table_size=1000000 oltp_insert --db-ps-mode=disable run
-
- SQL statistics:
- queries performed:
- read: 0
- write: 19685
- other: 0
- total: 19685
- transactions: 19685 (16335.50 per sec.)
- queries: 19685 (16335.50 per sec.)
- ignored errors: 0 (0.00 per sec.)
- reconnects: 0 (0.00 per sec.)
-
- General statistics:
- total time: 1.2000s
- total number of events: 19685
-
- Latency (ms):
- min: 4.49
- avg: 52.90
- max: 228.04
- 95th percentile: 77.19
- sum: 1041424.34
-
- 7.测试数据库的写入性能,使用的是oltp_write_only模式:
- sysbench --db-driver=pgsql --time=1 --threads=1000 --report-interval=5 --pgsql-host=192.168.1.100 --pgsql-port=5001 --pgsql-user=testpgs --pgsql-password=123456 --pgsql-db=test_db --tables=1 --table_size=1000000 oltp_write_only --db-ps-mode=disable run
-
- SQL statistics:
- queries performed:
- read: 0
- write: 17940
- other: 9112
- total: 27052
- transactions: 4480 (3374.72 per sec.)
- queries: 27052 (20377.87 per sec.)
- ignored errors: 43 (32.39 per sec.)
- reconnects: 0 (0.00 per sec.)
-
- General statistics:
- total time: 1.3226s
- total number of events: 4480
-
- Latency (ms):
- min: 65.01
- avg: 248.24
- max: 702.04
- 95th percentile: 314.45
- sum: 1112124.54
-
-
- 8.测试数据库的综合读写TPS,使用的是oltp_read_write模式
- sysbench --db-driver=pgsql --time=1 --threads=1000 --report-interval=5 --pgsql-host=192.168.1.100 --pgsql-port=5001 --pgsql-user=testpgs --pgsql-password=123456 --pgsql-db=test_db --tables=1 --table_size=1000000 oltp_read_write --db-ps-mode=disable run
-
- SQL statistics:
- queries performed:
- read: 25004
- write: 7114
- other: 3588
- total: 35706
- transactions: 1779 (899.49 per sec.)
- queries: 35706 (18053.45 per sec.)
- ignored errors: 7 (3.54 per sec.)
- reconnects: 0 (0.00 per sec.)
-
- General statistics:
- total time: 1.9728s
- total number of events: 1779
-
- Latency (ms):
- min: 199.06
- avg: 854.98
- max: 1804.89
- 95th percentile: 1191.92
- sum: 1521010.69
-
-
- 9.测试数据库的综合读写TPS,使用的是oltp_read_write模式:
- sysbench --db-driver=pgsql --time=1 --threads=500 --report-interval=5 --pgsql-host=192.168.1.100 --pgsql-port=5001 --pgsql-user=testpgs --pgsql-password=123456 --pgsql-db=test_db --tables=1 --table_size=1000000 oltp_read_write --db-ps-mode=disable run
-
- SQL statistics:
- queries performed:
- read: 11704
- write: 3333
- other: 1677
- total: 16714
- transactions: 833 (601.84 per sec.)
- queries: 16714 (12075.74 per sec.)
- ignored errors: 3 (2.17 per sec.)
- reconnects: 0 (0.00 per sec.)
-
- General statistics:
- total time: 1.3792s
- total number of events: 833
-
- Latency (ms):
- min: 293.30
- avg: 731.76
- max: 1353.39
- 95th percentile: 1170.65
- sum: 609554.21
-
- 9.使用上面的命令,sysbench工具会根据你的指令构造出各种各样的SQL语句去更新或者查询1张测试表里的数据,同时监测出数据库的压测性能指标,最后完成压测之后,可以执行下面的cleanup命令,清理数据。
- sysbench --db-driver=pgsql --time=1 --threads=1000 --report-interval=5 --pgsql-host=192.168.1.100 --pgsql-port=5001 --pgsql-user=testpgs --pgsql-password=123456 --pgsql-db=test_db --tables=1 --table_size=1000000 oltp_read_write --db-ps-mode=disable cleanup
- Oracle数据库
-
- 针对Oracle数据库的测试,sysbench需要编译安装,开启支持,默认不支持针对Oracle数据库的测试
-
- sysbench版本:0.5
-
- 1.安装依赖
-
- yum -y install make automake libtool pkgconfig libaio-devel
- yum -y install mariadb-devel openssl-devel
- yum -y install postgresql-devel
-
- 2.下载源码编译安装
- git clone https://github.com/akopytov/sysbench.git
-
- 或者
-
- git clone https://gitee.com/rtoax/sysbench.git
-
- ./autogen.sh
- ./configure
- make -j 6 #-j参数可加规定多少线程同时编译
- make install
-
- -----------------------------------------------------------------------------
- #附上配置的帮助信息
-
- [root@localhost sysbench]# ./configure --help
- `configure' configures sysbench 0.5 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-rpath do not hardcode runtime library paths
- --disable-largefile omit support for large files
- --enable-profiling Toggle profiling [default=off]
- --enable-coverage Toggle coverage [default=off]
- --disable-pedantic-warnings
- Toggle pedanticness [default=on]
- --enable-iso-pedantic-warnings
- Toggle iso pedanticness [default=off]
- --enable-unreachable Enable warnings about unreachable code [default=no]
- --disable-fail Turn warnings into failures [default=no]
- --disable-go-crazy Enables extra little warnings that might be too much
- [default=on]
-
- Optional Packages:
- --with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
- --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
- --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-extra-ldflags additional linker flags, e.g. -all-static
- --with-mysql compile with MySQL support (default is enabled)
- --with-drizzle compile with Drizzle support (default is enabled)
- --with-attachsql compile with libattachsql support (default is
- enabled)
- --with-oracle compile with Oracle support (default is disabled)
- --with-pgsql compile with PostgreSQL support (default is
- disabled)
- --with-lua Compile with Lua scripting support (default is
- enabled)
- --with-mysql-includes path to MySQL header files
- --with-mysql-libs path to MySQL libraries
- --with-gnu-ld assume the C compiler uses GNU ld default=no
- --with-libdrizzle-prefix[=DIR] search for libdrizzle in DIR/include and DIR/lib
- --without-libdrizzle-prefix don't search for libdrizzle in includedir and libdir
- --with-libattachsql-prefix[=DIR] search for libattachsql in DIR/include and DIR/lib
- --without-libattachsql-prefix don't search for libattachsql in includedir and libdir
- --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
-
- 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 <sysbench-developers@lists.launchpad.net>.
- --------------------------------------------------------------------------------
- 3.Oracle数据库相关操作
- #配置扩展源
- wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
- #配置oracle数据库源
- wget -O /etc/yum.repos.d/Oracle.repo http://public-yum.oracle.com/public-yum-ol7.repo
- #安装依赖包
- yum install -y oracle-database-preinstall-19c
- #安装数据库,需上传rpm
- rpm -ivh oracle-database-ee-19c*.rpm
- #配置,创建数据库
- /etc/init.d/oracledb_ORCLCDB-19c configure
- 注:RPM安装默认的数据文件路径是/opt/oracle/oradata目录,确保空间充足
- #切换用户
- su -oracle
- #添加环境变量
- cat >> ~/.bashrc << EOF
- export ORACLE_BASE=/opt/oracle
- export ORACLE_HOME=/opt/oracle/product/19c/dbhome_1
- export ORACLE_SID=ORCLCDB
- export PATH=$ORACLE_HOME/bin:$PATH:$HOME/.local/bin:$HOME/bin
- EOF
- source /home/oracle/.bash_profile
- #测试
- sqlplus / as sysdba
- #创建用户
- CREATE USER c##sysbench IDENTIFIED BY 123456789;
- #给用户授权
- GRANT CONNECT, RESOURCE, DBA TO c##sysbench;
- 2.编译支持oracle的sysbench
- #开启oracle支持,关闭mysql
- ./configure –with-oracle –libdir=/opt/oracle/product/19c/dbhome_1/lib –without-mysql
- #加上oracle的动态库
- make ORA_LIBS=/opt/oracle/product/19c/dbhome_1/lib/libclntsh.so
- #安装
- make install
- #查看帮助信息中是否已经支持oracle
- sysbench –help
- 3.使用示例
- #准备
- sysbench --test=oltp --db-driver=oracle --oltp_tables_count=8 --oltp-table-size=100000 --oracle-db=racdb --oracle-user=monkey --oracle-password=xxxxx prepare
- #压力测试
- sysbench --test=oltp --db-driver=oracle --oltp-tables-count=8 --oltp-table-size=100000 --oracle-db=racdb --oracle-user=monkey --oracle-password=xxxxx --max-time=900 --max-requests=10000000 --num-threads=40 --report-interval=10 run
- #清理数据
- sysbench --test=oltp --db-driver=oracle --oltp_tables_count=8 --oracle-db=racdb --oracle-user=monkey --oracle-password=xxxxx cleanup
参考资料:
Oracle 数据库 sysbench 压力测试 - 杨哥哥 - 博客园
sysbench安装及压测MySQL、Oracle_鹏老板的博客-CSDN博客_sysbench安装
sysbench对oracle进行压力测试 - monkey6 - 博客园
sysbench压测Oracle(安装与使用示例)_51CTO博客_sysbench测试oracle
MySQL性能压测工具SysBench详解(非常详细)_mysql sysbench_林凡尘coding的博客-CSDN博客
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。