BenchmarkSQL 支持多个 schema

1 minute read

背景

benchmarksql 默认编译好的,还有配置都是用的benchmarksql 这个schema,如果我们想对一个数据库用多个schema来压性能,就需要开多个benchmarksql终端来压。

这里就涉及到benchmarksql需要支持多个schema,每个benchmarksql连一个schema。

目录结构:

drwxr-xr-x 2 digoal users 4096 Jan 10 13:24 build  
-rwxr-xr-x 1 digoal users 1112 Jan 10 13:24 build.xml  
drwxr-xr-x 2 digoal users 4096 Jan 10 13:24 dist  
-rw-r--r-- 1 digoal users  128 Jan 10 13:24 env_java.sh  
-rwxr-xr-x 1 digoal users 1927 Jan 10 13:24 HOW-TO-RUN.txt  
drwxr-xr-x 2 digoal users 4096 Jan 10 13:24 lib  
-rwxr-xr-x 1 digoal users 2825 Jan 10 13:24 README.txt  
drwxr-xr-x 3 digoal users 4096 Jan 10 13:24 run  
drwxr-xr-x 6 digoal users 4096 Jan 10 13:24 src  

需要修改的地方:

src/LoadData/LoadData.java  
src/client/jTPCCTerminal.java  
run/props.ora  
run/props.pg  
run/sqlIndexCreates  
run/sqlIndexDrops  
run/sqlTableCopies  
run/sqlTableCreates  
run/sqlTableDrops  
run/sqlTableTruncates  

把所有的benchmarksql替换成新的schema name,例如 test01

sed -i "s/benchmarksql/test01/g" src/LoadData/LoadData.java  
sed -i "s/benchmarksql/test01/g" src/client/jTPCCTerminal.java  
sed -i "s/benchmarksql/test01/g" run/props.ora  
sed -i "s/benchmarksql/test01/g" run/props.pg  
sed -i "s/benchmarksql/test01/g" run/sqlIndexCreates  
sed -i "s/BENCHMARKSQL/TEST01/g" run/sqlIndexCreates  
sed -i "s/benchmarksql/test01/g" run/sqlIndexDrops  
sed -i "s/benchmarksql/test01/g" run/sqlTableCopies  
sed -i "s/benchmarksql/test01/g" run/sqlTableCreates  
sed -i "s/benchmarksql/test01/g" run/sqlTableDrops  
sed -i "s/benchmarksql/test01/g" run/sqlTableTruncates  

然后使用ant重新打包工程,如果没有安装ant,可以用yum install -y ant安装它。

benchmarksql需要依赖jre7,前面提到过,所以也需要先安装jre7

下载benchmarksql

http://sourceforge.net/projects/benchmarksql/

下载安装 JDK7

http://www.oracle.com/technetwork/cn/java/javase/downloads/jdk7-downloads-1880260.html  
wget http://download.oracle.com/otn-pub/java/jdk/7u79-b15/jdk-7u79-linux-x64.rpm  
rpm -ivh jdk-7u79-linux-x64.rpm  

检查包安装位置(使用rpm安装时也可以直接指定位置)

rpm -ql jdk  
...  
/usr/java/jdk1.7.0_79/bin/java  
...  

配置JAVA环境变量,将ORACLE jdbc驱动拷贝到benchmark/run目录

$  cp ~/oracle/product/12.1.0/db_1/jdbc/lib/ojdbc6.jar   benchmarksql/run/  
$  cp ~/oracle/product/12.1.0/db_1/jdbc/lib/ojdbc7.jar   benchmarksql/run/  
  
$  export JAVA_HOME=/usr/java/jdk1.7.0_79  
$  export PATH=$JAVA_HOME/bin:$PATH  
$  export CLASSPATH=.:./ojdbc6.jar:./ojdbc7.jar:$CLASSPATH  

修改runSQL.sh,加上$CLASSPATH,否则会报oracle驱动CLASS不存在的错误。

$  vi runSQL.sh  
myCP="../lib/postgresql-9.3-1101.jdbc41.jar"  
myCP="$myCP:../dist/BenchmarkSQL-4.1.jar"  
  
myOPTS="-Dprop=$1"  
myOPTS="$myOPTS -DcommandFile=$2"  
  
java -cp .:$myCP:$CLASSPATH $myOPTS ExecJDBC  
  
$ vi runLoader.sh   
java -cp .:$CLASSPATH:../lib/postgresql-9.3-1101.jdbc41.jar:../dist/BenchmarkSQL-4.1.jar -Dprop=$1 LoadData $2 $3 $4 $5  

使用ant重新打包benchmarksql.jar

$ant -buildfile ./build.xml   
Buildfile: ./build.xml  
Trying to override old definition of task javac  
  
init:  
  
compile:  
    [javac] Compiling 16 source files to /soft/digoal/soft_bak/benchmarksql-4.1.0_oracle01/build  
    [javac] Note: /soft/digoal/soft_bak/benchmarksql-4.1.0_oracle01/src/client/jTPCCTerminal.java uses unchecked or unsafe operations.  
    [javac] Note: Recompile with -Xlint:unchecked for details.  
  
dist:  
      [jar] Building jar: /soft/digoal/soft_bak/benchmarksql-4.1.0_oracle01/dist/BenchmarkSQL-4.1.jar  
  
BUILD SUCCESSFUL  
Total time: 2 seconds  

现在,使用的是test01这个schema了。

Flag Counter

digoal’s 大量PostgreSQL文章入口