Skip to content

Commit

Permalink
fix Oracle support
Browse files Browse the repository at this point in the history
  • Loading branch information
wuwen5 committed Apr 12, 2024
1 parent 2d2a38b commit 3b6630d
Show file tree
Hide file tree
Showing 8 changed files with 309 additions and 210 deletions.
132 changes: 98 additions & 34 deletions README-Oracle.md
Original file line number Diff line number Diff line change
@@ -1,54 +1,118 @@
**WARNING: Oracle support is unmaintained as of sysbench 1.0. You may
want to
try [sysbench 0.5](https://github.com/akopytov/sysbench/tree/0.5)
instead. The corresponding code and instructions below are still in the
source tree in case somebody wants to update them. Patches are always
welcome! **

--------------------------------------------------------------
Oracle Build steps
Oracle Build steps
--------------------------------------------------------------

Using Ubuntu 14.04 - intructions dated for 21/09/2016 (Was built on AWS
in an r3.xlarge These actions were done against 0.5 checkout)
## 安装Oracle客户端

* Setup Oracle Instant Client -
### Oracle客户端下载地址
https://www.oracle.com/database/technologies/instant-client/downloads.html

The following RPM's and upload them to the server:
- oracle-instantclient12.1-basic-12.1.0.2.0-1.x86_64.rpm
- oracle-instantclient12.1-devel-12.1.0.2.0-1.x86_64.rpm
### 使用RPM安装方式,将以下RPM上传到服务器:
- oracle-instantclient19.22-basic-19.22.0.0.0-1.x86_64.rpm
- oracle-instantclient19.22-devel-19.22.0.0.0-1.x86_64.rpm

```
alien -i oracle-instantclient12.1-basic-12.1.0.2.0-1.x86_64.rpm
alien -i oracle-instantclient12.1-devel-12.1.0.2.0-1.x86_64.rpm
yum -y localinstall oracle-instantclient19.22-basic-19.22.0.0.0-1.x86_64.rpm
yum -y localinstall oracle-instantclient19.22-devel-19.22.0.0.0-1.x86_64.rpm
```

* Install Cuda - http://www.r-tutor.com/gpu-computing/cuda-installation/cuda7.5-ubuntu
### 使用zip 安装方式

```
wget http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1404/x86_64/cuda-repo-ubuntu1404_7.5-18_amd64.deb
sudo dpkg -i cuda-repo-ubuntu1404_7.5-18_amd64.deb
sudo apt-get update
sudo apt-get install cuda
export CUDA_HOME=/usr/local/cuda-7.5
export LD_LIBRARY_PATH=${CUDA_HOME}/lib64
PATH=${CUDA_HOME}/bin:${PATH}
export PATH
echo "/usr/lib/oracle/12.1/client64/lib" > /etc/ld.so.conf.d/oracle-client-12.1.conf
unzip instantclient-basic-linux.x64-19.22.0.0.0dbru.zip
unzip instantclient-sdk-linux.x64-19.22.0.0.0dbru.zip
```

```
echo "/root/instantclient_19_22" > /etc/ld.so.conf.d/oracle-instantclient.conf
ldconfig
```

* Build sysbench
Use the following `configure` option to build with Oracle support:
## 编译&安装 Sysbench
```
./configure --with-oracle="/usr/lib/oracle/12.1/client64"
./autogen.sh
#使用--with-oracle 支持oracle, 通过--with-oracle-includes --with-oracle-libs指定Oracle客户端路径 (如未安装mysql客户端驱动,可--without-mysql排除默认的mysql支持)
#--with-oracle-libs=lib路径,如rpm安装方式,可指定为/usr/lib/oracle/19.22/client64/lib
#--with-oracle-includes=include路径,如rpm安装方式,可指定为/usr/include/oracle/19.22/client64
./configure --with-oracle --with-oracle-libs=/root/instantclient_19_22 --with-oracle-includes=/root/instantclient_19_22/sdk/include --without-mysql
make -j
make install
```

Run the following commands to allow sysbench use the full number of cores:
## 验证使用
- 查看帮助信息,是否有oracle相关的选项,以及是否支持oracle
```shell
sysbench --help
```
```
sudo sh -c 'for x in /sys/class/net/eth0/queues/rx-*; do echo ffffffff> $x/rps_cpus; done'
sudo sh -c "echo 32768 > /proc/sys/net/core/rps_sock_flow_entries"
sudo sh -c "echo 4096 > /sys/class/net/eth0/queues/rx-0/rps_flow_cnt"
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, pareto, zipfian} to use by default [uniform]
--rand-seed=N seed for random number generator. When 0, the current time is used as an RNG seed. [0]
--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)
--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:
oracle - Oracle driver
oracle options:
--oracle-user=STRING Oracle user [SYSDBA]
--oracle-password=STRING Oracle password [SYSDBA]
--oracle-db=STRING Oracle 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.
```

- 测试初始化数据
```shell
# 测试初始化数据
sysbench oltp_point_select --tables=10 --table-size=10000 --db-driver=oracle --oracle-db=192.168.x.x:1521/orcl --oracle-user=XXX --oracle-password=XXX prepare

# 测试Point_Select **(注意:如发生段错误(Segmentation fault),需通过--thread-stack-size指定合适线程栈大小,如 --thread-stack-size=512K)**
sysbench oltp_point_select --tables=10 --table-size=10000 --db-driver=oracle --oracle-db=192.168.x.x:1521/orcl --oracle-user=XXX --oracle-password=XXX --report-interval=10 --thread-stack-size=512K run

#清理测试数据
sysbench oltp_point_select --tables=10 --db-driver=oracle --oracle-db=192.168.x.x:1521/orcl --oracle-user=XXX --oracle-password=XXX cleanup
```
18 changes: 10 additions & 8 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,8 @@ SB_CHECK_MYSQL

SB_CHECK_DM

SB_CHECK_ORACLE

AS_IF([test x$with_pgsql != xno], [
AC_CHECK_PGSQL([$with_pgsql])
USE_PGSQL=1
Expand All @@ -219,14 +221,14 @@ AS_IF([test x$with_pgsql != xno], [
AM_CONDITIONAL(USE_PGSQL, test x$with_pgsql != xno)
AC_SUBST([USE_PGSQL])

AS_IF([test x$with_oracle != xno], [
AC_DEFINE(USE_ORACLE,1,[Define to 1 if you want to compile with Oracle support])
ORA_LIBS="-L${sb_with_oracle}/lib -lclntsh"
ORA_CFLAGS="-I${with_oracle}/include -I${with_oracle}/rdbms/demo -I${with_oracle}/rdbms/public"
AC_SUBST([ORA_LIBS])
AC_SUBST([ORA_CFLAGS])
])
AM_CONDITIONAL(USE_ORACLE, test x$with_oracle != xno)
#AS_IF([test x$with_oracle != xno], [
# AC_DEFINE(USE_ORACLE,1,[Define to 1 if you want to compile with Oracle support])
# ORA_LIBS="-L${sb_with_oracle}/lib -lclntsh"
# ORA_CFLAGS="-I${with_oracle}/include -I${with_oracle}/rdbms/demo -I${with_oracle}/rdbms/public"
# AC_SUBST([ORA_LIBS])
# AC_SUBST([ORA_CFLAGS])
#])
#AM_CONDITIONAL(USE_ORACLE, test x$with_oracle != xno)

# Check for libaio
AC_CHECK_AIO
Expand Down
83 changes: 83 additions & 0 deletions m4/sb_check_oracle.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
dnl ---------------------------------------------------------------------------
dnl Macro: SB_CHECK_ORACLE
dnl First check if the Oracle root directory is specified with --with-oracle.
dnl Otherwise check for custom Oracle paths in --with-oracle-includes and
dnl --with-oracle-libs. If some paths are not specified explicitly, try to get
dnl them from oracle_config.
dnl ---------------------------------------------------------------------------

AC_DEFUN([SB_CHECK_ORACLE],[
AS_IF([test "x$with_oracle" != xno], [
# Check for custom Oracle root directory
if test [ "x$with_oracle" != xyes -a "x$with_oracle" != xno ]
then
ac_cv_oracle_root=`echo "$with_oracle" | sed -e 's+/$++'`
if test [ -d "$ac_cv_oracle_root/include" -a \
-d "$ac_cv_oracle_root/liboracle_r" ]
then
ac_cv_oracle_includes="$ac_cv_oracle_root/include"
ac_cv_oracle_libs="$ac_cv_oracle_root/liboracle_r"
elif test [ -x "$ac_cv_oracle_root/bin/oracle_config" ]
then
oracleconfig="$ac_cv_oracle_root/bin/oracle_config"
else
AC_MSG_ERROR([invalid Oracle root directory: $ac_cv_oracle_root])
fi
fi
# Check for custom includes path
if test [ -z "$ac_cv_oracle_includes" ]
then
AC_ARG_WITH([oracle-includes],
AC_HELP_STRING([--with-oracle-includes], [path to oracle header files]),
[ac_cv_oracle_includes=$withval])
fi
if test [ -n "$ac_cv_oracle_includes" ]
then
AC_CACHE_CHECK([ORACLE includes], [ac_cv_oracle_includes], [ac_cv_oracle_includes=""])
ORACLE_CFLAGS="-I$ac_cv_oracle_includes"
fi
# Check for custom library path
if test [ -z "$ac_cv_oracle_libs" ]
then
AC_ARG_WITH([oracle-libs],
AC_HELP_STRING([--with-oracle-libs], [path to oracle libraries]),
[ac_cv_oracle_libs=$withval])
fi
if test [ -n "$ac_cv_oracle_libs" ]
then
# Trim trailing '.libs' if user passed it in --with-oracle-libs option
ac_cv_oracle_libs=`echo ${ac_cv_oracle_libs} | sed -e 's/.libs$//' \
-e 's+.libs/$++'`
AC_CACHE_CHECK([ORACLE libraries], [ac_cv_oracle_libs], [ac_cv_oracle_libs=""])
save_LDFLAGS="$LDFLAGS"
save_LIBS="$LIBS"
LDFLAGS="-L$ac_cv_oracle_libs -lclntsh -Wl,-rpath=$ac_cv_oracle_libs"
LIBS=""
ORA_LIBS="$LDFLAGS $LIBS"
LIBS="$save_LIBS"
LDFLAGS="$save_LDFLAGS"
fi
AC_DEFINE([USE_ORACLE], 1,
[Define to 1 if you want to compile with ORACLE support])
USE_ORACLE=1
AC_SUBST([ORA_LIBS])
AC_SUBST([ORACLE_CFLAGS])
SAVE_CFLAGS="${CFLAGS}"
CFLAGS="${CFLAGS} ${ORACLE_CFLAGS}"
])
CFLAGS="${SAVE_CFLAGS}"
AM_CONDITIONAL([USE_ORACLE], test "x$with_oracle" != xno)
AC_SUBST([USE_ORACLE])
])
4 changes: 2 additions & 2 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ xoroshiro128plus.h
sysbench_LDADD = tests/fileio/libsbfileio.a tests/threads/libsbthreads.a \
tests/memory/libsbmemory.a tests/cpu/libsbcpu.a \
tests/mutex/libsbmutex.a \
$(mysql_ldadd) $(pgsql_ldadd) ${dm_ldadd} $(ora_ldadd) \
$(mysql_ldadd) $(pgsql_ldadd) $(dm_ldadd) $(ora_ldadd) \
$(LUAJIT_LIBS) $(CK_LIBS)

sysbench_LDFLAGS = $(mysql_ldflags) \
$(pgsql_ldflags) $(ora_ldflags) $(LUAJIT_LDFLAGS)
$(pgsql_ldflags) $(LUAJIT_LDFLAGS)
2 changes: 1 addition & 1 deletion src/drivers/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ if USE_ORACLE
ORACLE_DIR = oracle
endif

SUBDIRS = $(MYSQL_DIR) $(PGSQL_DIR) ${DM_DIR} $(ORACLE_DIR)
SUBDIRS = $(MYSQL_DIR) $(PGSQL_DIR) $(DM_DIR) $(ORACLE_DIR)
20 changes: 20 additions & 0 deletions src/drivers/oracle/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright (C) 2005 MySQL AB
# Copyright (C) 2005-2008 Alexey Kopytov <akopytov@gmail.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

noinst_LIBRARIES = libsboracle.a

libsboracle_a_SOURCES = drv_oracle.c
libsboracle_a_CPPFLAGS = $(ORACLE_CFLAGS) $(AM_CPPFLAGS)
Loading

0 comments on commit 3b6630d

Please sign in to comment.