年底了,整理了一下mongodb安装脚本:
mongodb-v2.2.2
v8引擎-3.16.9
jemalloc内存管理模块-3.2.0
#tudou@xiaomi.com=>百度网盘下载链接
csdn下载链接点击打开链接
因为v8不在支持scons编译,这里只能使用gyp编译成动态链接库。另外使用jemalloc必须在启动mongod之前添加到环境变量中去。
install.sh
yum -y install numactl vim-enhanced python make pcre scons boost-devel boost-filesystem gcc gcc-c++ glibc glibc-devel libstdc++ libpcap libpcap-devel libaio libaio-devel
/usr/sbin/groupadd -g 1004 mongodb
/usr/sbin/useradd -g mongodb mongodb -u 1004 -s /sbin/nologin
cd ./jemalloc-3.2.0
./configure
make && make install
cd ../v8-3.16.9
make x64.release snapshot=on library=shared
cp out/x64.release/lib.target/libv8.* /usr/local/lib
cp -r include/* /usr/include/
sed '1s/$/ \\/' -i /etc/ld.so.conf
echo '/usr/local/lib' >> /etc/ld.so.conf
/sbin/ldconfig -v
cd ../mongodb-src-r2.2.2
mkdir -p /opt/soft/mongodb-2.2.2
scons all --usev8 mode=release debuggersupport=off snapshot=on profilingsupport=off
scons --prefix=/opt/soft/mongodb-2.2.2 --full --usev8 install mode=release debuggersupport=off snapshot=on profilingsupport=off
echo 'export PATH=$PATH:/opt/soft/mongodb-2.2.2/bin' >> /etc/profile
source /etc/profile
~
mongod_safe.sh
#!/bin/sh
while true; do
count=`ps aux|grep "/opt/soft/mongodb-2.2.2/bin/mongod -f /etc/mongodb.conf"|grep -v grep|wc -l`
if [ "${count}" == "0" ]; then
su mongodb -c "export LD_PRELOAD='/usr/local/lib/libjemalloc.so' && numactl --interleave=all /opt/soft/mongodb-2.2.2/bin/mongod -f /etc/mongodb.conf"
sleep 60
else
sleep 5
fi
done