Skip to content

Commit

Permalink
Merge pull request #1 from wuwen5/oracle
Browse files Browse the repository at this point in the history
Oracle
  • Loading branch information
wuwen5 authored Apr 12, 2024
2 parents e66c33b + 3b6630d commit 7f32574
Show file tree
Hide file tree
Showing 10 changed files with 1,314 additions and 10 deletions.
118 changes: 118 additions & 0 deletions README-Oracle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
--------------------------------------------------------------
Oracle Build steps
--------------------------------------------------------------

## 安装Oracle客户端

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

### 使用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

```
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
```

### 使用zip 安装方式

```
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
```

## 编译&安装 Sysbench
```
./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
```

## 验证使用
- 查看帮助信息,是否有oracle相关的选项,以及是否支持oracle
```shell
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, 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
```
24 changes: 24 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,17 @@ AS_IF([test "x$with_dm" != "xno"],
[dm_support=no])
AC_MSG_RESULT([$dm_support])

# Check if we should compile with Oracle support
AC_ARG_WITH([oracle],
AS_HELP_STRING([--with-oracle],
[compile with Oracle support (default is disabled)]),
[], [with_oracle=no])
AC_MSG_CHECKING([whether to compile with Oracle support])
AS_IF([test "x$with_oracle" != "xno"],
[oracle_support=yes],
[oracle_support=no])
AC_MSG_RESULT([$oracle_support])

# Set LuaJIT flags
SB_LUAJIT

Expand Down Expand Up @@ -198,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 @@ -208,6 +221,15 @@ 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)

# Check for libaio
AC_CHECK_AIO
AM_CONDITIONAL(USE_AIO, test x$enable_aio = xyes)
Expand Down Expand Up @@ -412,6 +434,7 @@ src/drivers/Makefile
src/drivers/mysql/Makefile
src/drivers/pgsql/Makefile
src/drivers/dm/Makefile
src/drivers/oracle/Makefile
src/tests/Makefile
src/tests/cpu/Makefile
src/tests/fileio/Makefile
Expand Down Expand Up @@ -443,6 +466,7 @@ AC_MSG_RESULT([])
AC_MSG_RESULT([MySQL support : ${mysql_support}])
AC_MSG_RESULT([PostgreSQL support : ${pgsql_support}])
AC_MSG_RESULT([DM support : ${dm_support}])
AC_MSG_RESULT([Oracle support : ${oracle_support}])
AC_MSG_RESULT([])
AC_MSG_RESULT([LuaJIT : ${sb_use_luajit}])
AC_MSG_RESULT([LUAJIT_CFLAGS : ${LUAJIT_CFLAGS}])
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])
])
6 changes: 5 additions & 1 deletion src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ if USE_DM
dm_ldadd = drivers/dm/libsbdm.a $(DM_LIBS)
endif

if USE_ORACLE
ora_ldadd = drivers/oracle/libsboracle.a $(ORA_LIBS)
endif

sysbench_SOURCES = sysbench.c sysbench.h sb_timer.c sb_timer.h \
sb_options.c sb_options.h sb_logger.c sb_logger.h sb_list.h db_driver.h \
db_driver.c sb_histogram.c sb_histogram.h sb_rand.c sb_rand.h \
Expand All @@ -48,7 +52,7 @@ 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} \
$(mysql_ldadd) $(pgsql_ldadd) $(dm_ldadd) $(ora_ldadd) \
$(LUAJIT_LIBS) $(CK_LIBS)

sysbench_LDFLAGS = $(mysql_ldflags) \
Expand Down
3 changes: 3 additions & 0 deletions src/db_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ int db_register(void)
#ifdef USE_DM
register_driver_dm(&drivers);
#endif
#ifdef USE_ORACLE
register_driver_oracle(&drivers);
#endif

/* Register command line options for each driver */
SB_LIST_FOR_EACH(pos, &drivers)
Expand Down
4 changes: 4 additions & 0 deletions src/db_driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -346,4 +346,8 @@ int register_driver_pgsql(sb_list_t *);
int register_driver_dm(sb_list_t *);
#endif

#ifdef USE_ORACLE
int register_driver_oracle(sb_list_t *);
#endif

#endif /* DB_DRIVER_H */
6 changes: 5 additions & 1 deletion src/drivers/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,8 @@ if USE_DM
DM_DIR = dm
endif

SUBDIRS = $(MYSQL_DIR) $(PGSQL_DIR) ${DM_DIR}
if USE_ORACLE
ORACLE_DIR = oracle
endif

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 7f32574

Please sign in to comment.