时间:2021-07-01 10:21:17 帮助过:88人阅读
默认的mongo下的代码是通过网上下载binary packge做rpm的,但是我们要的是从soure开始,需要修改下rpm下的mongodb-org.spec 文件
主要修改的内容是
1. 添加了build的命令,里面配置了aarch64的编译方法,把wiredtiger和mmapv1的store engine都开了, -j job数根据自己的配置调整
2. 修改了install的路径,并对结果进行了strip(默认的scons的strip没找到,不知道咋搞)
3. 删除了一些没有的tools
patch 如下:
diff --git a/rpm/mongodb-org.spec b/rpm/mongodb-org.spec index 66ff4ca..c548e79 100644 --- a/rpm/mongodb-org.spec +++ b/rpm/mongodb-org.spec @@ -164,10 +164,18 @@ This package provides the MongoDB static library and header files needed to deve %setup %build +TOOLCHAIN=toolchain路径 +scons --release --dbg=off MONGO_VERSION=3.4.2 CC=$TOOLCHAIN/aarch64-linux-gnu-gcc CXX=$TOOLCHAIN/aarch64-linux-gnu-g++ TARGET_ARCH=aarch64 --mmapv1=on --wiredtiger=on --disable-warnings-as-errors -j6 CF LAGS="-march=armv8-a+crc -mtune=generic" core tools VERBOSE=on %install -mkdir -p $RPM_BUILD_ROOT/usr -cp -rv bin $RPM_BUILD_ROOT/usr +TOOLCHAIN=toolchain路径 +scons --release --dbg=off MONGO_VERSION=3.4.2 CC=$TOOLCHAIN/aarch64-linux-gnu-gcc CXX=$TOOLCHAIN/aarch64-linux-gnu-g++ TARGET_ARCH=aarch64 --mmapv1=on --wiredtiger=on --disable-warnings-as-errors -j6 CFLAGS="-march=armv8-a+crc -mtune=generic" install +$TOOLCHAIN/aarch64-linux-gnu-strip build/install/bin/mongod +$TOOLCHAIN/aarch64-linux-gnu-strip build/install/bin/mongo +$TOOLCHAIN/aarch64-linux-gnu-strip build/install/bin/mongos +$TOOLCHAIN/aarch64-linux-gnu-strip build/install/bin/mongoperf +mkdir -p $RPM_BUILD_ROOT/usr/bin +cp -rv build/install/bin $RPM_BUILD_ROOT/usr/ mkdir -p $RPM_BUILD_ROOT/usr/share/man/man1 cp debian/*.1 $RPM_BUILD_ROOT/usr/share/man/man1/ # FIXME: remove this rm when mongosniff is back in the package @@ -222,10 +230,8 @@ fi %attr(0755,mongod,mongod) %dir /var/log/mongodb %attr(0755,mongod,mongod) %dir /var/run/mongodb %attr(0640,mongod,mongod) %config(noreplace) %verify(not md5 size mtime) /var/log/mongodb/mongod.log -%doc GNU-AGPL-3.0 +%doc GNU-AGPL-3.0.txt %doc README -%doc THIRD-PARTY-NOTICES -%doc MPL-2 @@ -243,16 +249,7 @@ fi %defattr(-,root,root,-) #%doc README GNU-AGPL-3.0.txt -%{_bindir}/bsondump -%{_bindir}/mongodump -%{_bindir}/mongoexport -%{_bindir}/mongofiles -%{_bindir}/mongoimport -%{_bindir}/mongooplog %{_bindir}/mongoperf -%{_bindir}/mongorestore -%{_bindir}/mongotop -%{_bindir}/mongostat %{_mandir}/man1/bsondump.1* %{_mandir}/man1/mongodump.1*
接下来编译代码就行了
rpmbuild -ba --target=aarch64 -D"dynamic_version r3.4.2" -D "dynamic_release r3.4.2" -D "_arch aarch64" rpm/mongodb-org.spec
PS.
因为mongodb用了不少的模版,编译的时候需要相当多的内存,要有心理准备:P
编译完成后,rpm包就可以直接用来安装了
[raspberry pi3] aarch64 mongodb 编译和安装
标签:网上 actor pen hive 基本 rpmbuild off 接下来 isa