aerospike学习(0)-编译与运行

引言

开源代码编译起来并不是直接通过,很多报错,把坑记录一下。

编译

首先不能使用mac进行编译,不支持。需要选linux。

分支切换

1
2
3
checkout origin/hotfix/7.0.0分支
fq2 git submodule update --init
make

问题1. libtool安装目录问题

1
2
3
4
5
6
7
8
9
10
11
12
13
14
[libin11@dev03 jansson]$ autoreconf -i
src/Makefile.am:6: error: Libtool library used but 'LIBTOOL' is undefined
src/Makefile.am:6: The usual way to define 'LIBTOOL' is to add 'LT_INIT'
src/Makefile.am:6: to 'configure.ac' and run 'aclocal' and 'autoconf' again.
src/Makefile.am:6: If 'LT_INIT' is in 'configure.ac', make sure

fix:
On many distros, including CentOS7, the seven macro files for libtools are installed under /usr/share/aclocal rather than under /usr/local/share/aclocal. Consequently, they aren't found when the package you are building sets prefix to /usr/local.
To fix this if you already have a /usr/local/share/aclocal directory, type the following as root:

for file in argz libtool ltdl ltoptions ltsugar ltversion lt~obsolete
do
ln -s /usr/share/aclocal/$file.m4 /usr/local/share/aclocal/$file.m4
done

https://superuser.com/questions/565988/autoconf-libtool-and-an-undefined-ac-prog-libtool

问题2. 编译absl失败

-S2_FLAGS = -DCMAKE_CXX_STANDARD=17 -DCMAKE_BUILD_TYPE=RelWithDebInfo
+S2_FLAGS = -DCMAKE_CXX_STANDARD=17 -DCMAKE_BUILD_TYPE=RelWithDebInfo -DABSL_PROPAGATE_CXX_STD=ON

问题3. 编译absl失败2

1
2
3
4
5
6
7
8
9
10
11
12
cmake -S /data/libin11/work/aerospike-server/modules/abseil-cpp -B /data/libin11/work/aerospike-server/modules/abseil-cpp/build -DCMAKE_CXX_STANDARD=17 -DCMAKE_BUILD_TYPE=RelWithDebInfo -DABSL_PROPAGATE_CXX_STD=ON -DCMAKE_INSTALL_PREFIX=/data/libin11/work/aerospike-server/modules/abseil-cpp/installation -DABSL_ENABLE_INSTALL=ON -DCMAKE_INSTALL_MESSAGE=LAZY -DCMAKE_TARGET_MESSAGES=OFF
-- Configuring done (0.2s)
-- Generating done (0.3s)
-- Build files have been written to: /data/libin11/work/aerospike-server/modules/abseil-cpp/build
cmake --build /data/libin11/work/aerospike-server/modules/abseil-cpp/build -- --no-print-directory
[ 0%] Building CXX object absl/base/CMakeFiles/log_severity.dir/log_severity.cc.o
In file included from /data/libin11/work/aerospike-server/modules/abseil-cpp/absl/base/config.h:86:0,
from /data/libin11/work/aerospike-server/modules/abseil-cpp/absl/base/attributes.h:37,
from /data/libin11/work/aerospike-server/modules/abseil-cpp/absl/base/log_severity.h:21,
from /data/libin11/work/aerospike-server/modules/abseil-cpp/absl/base/log_severity.cc:15:
/data/libin11/work/aerospike-server/modules/abseil-cpp/absl/base/policy_checks.h:57:2: error: #error "This package requires GCC 7 or higher."
#error "This package requires GCC 7 or higher."

fix:
step1. 升级g++版本

  1. yum 安装g++ 9
    sudo yum install devtoolset-9-gcc devtoolset-9-gcc-c++

  2. 指定新安装为默认版本
    在/etc/bashrc中增加:
    source /opt/rh/devtoolset-9/enable

问题4:安装absl失败

1
2
3
4
5
6
7
8
9
10
11
12
13
14
ar /data/libin11/work/aerospike-server/modules/abseil-cpp/installation/lib/libabsl.a /data/libin11/work/aerospike-server/modules/abseil-cpp/installation/lib/libabsl_*.a
ls /data/libin11/work/aerospike-server/modules/abseil
-cpp/installation/lib/libabsl_*.a
ls: cannot access /data/libin11/work/aerospike-server/modules/abseil-cpp/installation/lib/libabsl_*.a: No such file or directory

fix:
修改make_in/Makefile.vars,从installation/lib64下查找
-ifeq ($(OS),$(filter $(OS), el8 el9 amzn2023))
- ABSL_LIB_DIR = $(ABSL)/installation/lib64
-else
- ABSL_LIB_DIR = $(ABSL)/installation/lib
-endif
+
+ABSL_LIB_DIR = $(ABSL)/installation/lib64

问题5:编译as源码失败

1
2
3
base/signal.c: In function ‘log_siginfo’:
base/signal.c:283:52: error: ‘BUS_MCEERR_AR’ undeclared (first use in this function)
283 | if (info->si_signo == SIGBUS && (info->si_code == BUS_MCEERR_AR ||

fix:
简单fix,将as/src/base/signal.c中相关的代码注释掉

二、运行

问题1:ssd运行失败
fix:

  • 切换到root用户,sudo -iu root
  • 初始化分区
    ○ blkdiscard -z –length 8MiB /dev/nvme0n1
    ○ 参考:https://aerospike.com/docs/server/operations/configure/storage/ssd_init
  • 创建文件目录:
    1
    2
    3
    4
    5
    6
    mkdir -p  log/aerospike
    mkdir -p run/aerospike/
    mkdir -p /opt/aerospike
    mkdir -p /opt/aerospike/usr/udf/lua
    mkdir -p /opt/aerospike/smd
    ./asd --config-file aerospike_ssd.conf

配置文件参考。基于ssd

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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
service {
user root
group root
pidfile run/aerospike/asd.pid
proto-fd-max 15000
cluster-name cakery
}

logging {
# Log file must be an absolute path.
file log/aerospike/aerospike.log {
context any info
}
}

network {
service {
address any
port 3000
}

heartbeat {
mode multicast
multicast-group 239.1.99.222
port 9918

# To use unicast-mesh heartbeats, remove the 3 lines above, and see
# aerospike_mesh.conf for alternative.

interval 150
timeout 10
}

fabric {
port 3001
}

# info {
# port 3003
# }
}

namespace test {
replication-factor 3

# Warning - legacy data in defined raw partition devices will be erased.
# These partitions must not be mounted by the file system.
#index-type flash {
# mounts-budget 1T
# mount /dev/nvme0n1
#}

storage-engine device {
# Use one or more lines like those below with actual device paths.
#device /dev/nvme0n1
device /dev/nvme0n1p1
device /dev/nvme0n1p2
device /dev/nvme0n1p3
device /dev/nvme0n1p4
cold-start-empty true
# write-block-size 128K
}
}