vdbench在ARM服务器上出现共享库aarch64.so问题

在ARM服务器上,运行vdbench出现共享库不匹配的解决方法

报错如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
[root@axing vdbench50407]# ./vdbench -t

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
Vdbench distribution: vdbench50407 Tue June 05 9:49:29 MDT 2018
For documentation, see 'vdbench.pdf'.

00:17:40.900 Created output directory '/vdbench50407/output'
00:17:41.008 input argument scanned: '-f/tmp/parmfile'
00:17:41.072 Starting slave: /vdbench50407/vdbench SlaveJvm -m localhost -n localhost-10-210914-00.17.40.873 -l localhost-0 -p 5570
00:17:41.094
00:17:41.094 File /vdbench50407/linux/aarch64.so does not exist.
00:17:41.094 This may be an OS that a shared library currently
00:17:41.094 is not available for. You may have to do your own compile.
00:17:41.094 t: java.lang.UnsatisfiedLinkError: Can't load library: /vdbench50407/linux/aarch64.so
00:17:41.094
00:17:41.094 Loading of shared library /vdbench50407/linux/aarch64.so failed.
00:17:41.094 There may be issues related to a cpu type not being
00:17:41.094 acceptable to Vdbench, e.g. MAC PPC vs. X86
00:17:41.094 Contact me at the Oracle Vdbench Forum for support.
00:17:41.094
00:17:41.595
00:17:41.595 Failure loading shared library
00:17:41.595
java.lang.RuntimeException: Failure loading shared library
at Vdb.common.failure(common.java:350)
at Vdb.common.get_shared_lib(common.java:1103)
at Vdb.Native.<clinit>(Native.java:31)
at Vdb.common.signal_caller(common.java:737)
at Vdb.ConnectSlaves.connectToSlaves(ConnectSlaves.java:98)
at Vdb.Vdbmain.masterRun(Vdbmain.java:814)
at Vdb.Vdbmain.main(Vdbmain.java:628)
[root@axing vdbench50407]#

原因

是vdbench根目录下linux/linux64.so是为x86编译的,需要重新编译linux64.so为ARM版本;

1
2
3
4
5
6
7
[root@axing linux]# pwd  
/vdbench50407/linux
[root@axing linux]# ls
config.sh linux32.so linux64.so sparc64.so
[root@axing linux]# file linux64.so
linux64.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), statically linked, BuildID[sha1] =34a31f32956f21153c372a95e73c02e84ddd29f8, not stripped
[root@axing linux]#

解决办法 —— ARM版本的aarch64.so编译(仅适用于vdbench50407版本)

下载vdbench源码包:下载地址
解压后进入vdbench目录,创建linux目录;

1
2
3
4
5
6
7
8
9
10
// 解压源码包,-d:指定解压到指定目录  
[root@axing ~]# ls
vdbench50407.src.zip vdbench50407.zip
[root@axing ~]# unzip vdbench50407.src.zip -d /vdbench

// 进入解压后源码包目录
[root@axing ~]# cd /vdbench

// 创建存放aarch64.so的目录
[root@axing vdbench]# mkdir linux

进入Jni修改make.linux
主要修改点:
1、vdbench源码目录;
2、java路径;
3、去除-m32和m64选项;

1
2
3
4
[root@axing vdbench]# cd src/Jni/  
[root@axing Jni]# pwd
/vdbench/src/Jni
[root@axing Jni]# vim make.linux

示例如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
vdb=/vdbench  
java=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.242.b08-1.h5.ky10.aarch64/
jni=$vdb/src/Jni

echo target directory: $vdb

INCLUDES32="-w -DLINUX -I$java/include -I/$java/include/linux -I/usr/include/ -fPIC"
INCLUDES64="-w -DLINUX -I$java/include -I/$java/include/linux -I/usr/include/ -fPIC"

cd /tmp
rm *.o 2>/dev/null

echo Compiling 32 bit

rm $vdb/linux/linux32.so 2>/dev/null
gcc ${INCLUDES32} -c $jni/vdbjni.c
gcc ${INCLUDES32} -c $jni/vdblinux.c
gcc ${INCLUDES32} -c $jni/vdb_dv.c
gcc ${INCLUDES32} -c $jni/vdb.c
gcc ${INCLUDES32} -c $jni/chmod.c

echo Linking 32 bit
echo

gcc -o $vdb/linux/linux32.so vdbjni.o vdblinux.o vdb_dv.o vdb.o chmod.o -lm -shared -lrt

chmod 777 $vdb/linux/linux32.so

cd /tmp
rm *.o 2>/dev/null

echo Compiling 64 bit
rm $vdb/linux/linux64.so 2>/dev/null
gcc ${INCLUDES64} -c $jni/vdbjni.c
gcc ${INCLUDES64} -c $jni/vdblinux.c
gcc ${INCLUDES64} -c $jni/vdb_dv.c
gcc ${INCLUDES64} -c $jni/vdb.c
gcc ${INCLUDES64} -c $jni/chmod.c

echo Linking 64 bit
echo

gcc -o $vdb/linux/linux64.so vdbjni.o vdblinux.o vdb_dv.o vdb.o chmod.o -lm -shared -lrt

chmod 777 $vdb/linux/linux64.so 2>/dev/null

执行make.linux,会在/vdbench/linux/下生成linux32.so和linux64.so文件。

1
2
3
4
5
6
7
8
9
10
11
[root@axing Jni]# ./make.linux
target directory: /vdbench
Compiling 32 bit
Linking 32 bit

Compiling 64 bit
Linking 64 bit

[root@axing Jni]# cd /vdbench/linux/
[root@axing linux]# ls
linux32.so linux64.so

这里我们只需要使用到64位的文件。重命名linux64.so并复制到二进制包(注意不是源码包)的linux/目录下即可。

1
2
3
4
5
6
7
8
// 重命名并拷贝编译后的linux64.so到vdbench二进制包目录下
[root@axing linux]# cp linux64.so aarch64.so
[root@axing linux]# ls
aarch64.so linux32.so linux64.so
[root@axing linux]# cp aarch64.so /vdbench50407/linux/
[root@axing linux]# ls /vdbench50407/linux/
aarch64.so config.sh linux32.so linux64.so sparc64.so
[root@axing linux]#

执行测试:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// 执行vdbench脚本需要用到csh,如果没有需要先安装
[root@axing vdbench50407]# csh
-bash: csh: command not found
[root@axing vdbench50407]# yum install -y csh

// 执行vdbench脚本测试,-t:测试一下工具能不能用
[root@axing vdbench50407]# ./vdbench -t


Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
Vdbench distribution: vdbench50407 Tue June 05 9:49:29 MDT 2018
For documentation, see 'vdbench.pdf'.

00:28:42.406 input argument scanned: '-f/tmp/parmfile'
00:28:42.454 Starting slave: /vdbench50407/vdbench SlaveJvm -m localhost -n localhost-10-210914-00.28.42.310 -l localhost-0 -p 5570
00:28:42.685 All slaves are now connected
00:28:44.001 Starting RD=rd1; I/O rate: 100; elapsed=5; For loops: None

Sep 14, 2021 interval i/o MB/sec bytes read resp read write read write resp queue cpu% cpu%
rate 1024**2 i/o pct time resp resp max max stddev depth sys+u sys
00:28:45.037 1 51.0 0.05 1024 43.14 0.003 0.003 0.003 0.01 0.01 0.002 0.0 10.0 0.9
00:28:46.006 2 88.0 0.09 1024 57.95 0.003 0.003 0.003 0.01 0.01 0.001 0.0 3.5 1.0
00:28:47.006 3 108.0 0.11 1024 48.15 0.003 0.003 0.003 0.01 0.01 0.001 0.0 1.5 0.0
00:28:48.006 4 101.0 0.10 1024 53.47 0.003 0.002 0.003 0.01 0.01 0.001 0.0 1.0 0.0
00:28:49.009 5 88.0 0.09 1024 56.82 0.002 0.002 0.003 0.01 0.01 0.001 0.0 0.5 0.0
00:28:49.025 avg_2-5 96.3 0.09 1024 53.77 0.003 0.002 0.003 0.01 0.01 0.001 0.0 1.6 0.3
00:28:49.867 Vdbench execution completed successfully. Output directory: /vdbench50407/output