Слияние кода завершено, страница обновится автоматически
installPath="/usr/local/mongodb3.2.8"
sourceFile="mongodb-linux-x86_64-rhel62-3.2.8.tgz"
pathFile="mongodb-linux-x86_64-rhel62-3.2.8"
serviceFile="/etc/init.d/mongodb"
configFile=$installPath"/mongodb.conf"
pidFile=/var/run/mongodb.pid
dbpath=/www/mongodb/db
logpath=/www/mongodb/log/
if [ ! -d $dbpath ];then
mkdir -p $dbpath
fi
if [ ! -d $logpath ];then
mkdir -p $logpath
fi
if [ ! -d $installPath ];then
mkdir -p $installPath
else
rm -rf $installPath/*
printf "删除 $installPath\n"
fi
if [ -f $sourceFile ];then
tar -zxvf $sourceFile
mv -f $pathFile/* $installPath
if [ $? == 0 ];then
echo "
logappend=true
fork = true
#port = 27017
# 数据库文件位置
dbpath=${dbpath}
logpath=${logpath}log.log
cpu = true
#noauth = true
auth = true
# 详细记录输出
#verbose = true
# Diagnostic/debugging option 动态调试项
#nocursors = true
# Ignore query hints 忽略查询提示
#nohints = true
# 禁用http界面,默认为localhost:28017
#nohttpinterface = true
# 关闭服务器端脚本,这将极大的限制功能
# Turns off server-side scripting. This will result in greatly limited
# functionality
#noscripting = true
# 关闭扫描表,任何查询将会是扫描失败
# Turns off table scans. Any query that would do a table scan fails.
#notablescan = true
# 关闭数据文件预分配
# Disable data file preallocation.
#noprealloc = true
# 为新数据库指定.ns文件的大小,单位:MB
# Specify .ns file size for new databases.
# nssize =
#指定存储身份验证信息的密钥文件的路径
#keyFile=/path/to/keyfile
" > $configFile
echo "#!/bin/sh
# chkconfig: 2345 80 90
# description: mongodb auto run
#
mongodbPath=$installPath/bin
mongodFile=\$mongodbPath\"/mongod\"
configFile=$installPath/mongodb.conf
pidFile=$pidFile
function start(){
if [ -f \"\$configFile\" ];then
if [ -f \$mongodFile ];then
\$mongodFile --config \$configFile --pidfilepath=$pidFile
if [ \$? == 0 ];then
echo -e \"\033[32;49;1m [启动成功] \033[39;49;0m\"
else
printf \"启动失败\n\"
fi
else
printf \"服务文件 \$mongodFile 不存在\n\"
fi
else
printf \"配置文件不存在\n\"
fi
}
function stop(){
if [ -f \"\$pidFile\" ]; then
pid=\`cat \$pidFile\`
if [ -n \"\$pid\" ];then
kill -15 \$pid
if [ \$? == 0 ];then
printf \"\t server stop OK \n\"
return 0
fi
fi
printf \"\t server stop FAIL \n\"
return 2
fi
printf \"\t server is not run\n\"
return 3
}
case \$1 in
start )
start
;;
stop)
stop
;;
restart)
stop
sleep 1
start
;;
*)
start
;;
esac
">$serviceFile
chmod +x $serviceFile;
fi
else
printf "$sourceFile 不存在\n"
fi
Вы можете оставить комментарий после Вход в систему
Неприемлемый контент может быть отображен здесь и не будет показан на странице. Вы можете проверить и изменить его с помощью соответствующей функции редактирования.
Если вы подтверждаете, что содержание не содержит непристойной лексики/перенаправления на рекламу/насилия/вульгарной порнографии/нарушений/пиратства/ложного/незначительного или незаконного контента, связанного с национальными законами и предписаниями, вы можете нажать «Отправить» для подачи апелляции, и мы обработаем ее как можно скорее.
Опубликовать ( 0 )