安裝Mongodb3.0.6單例項
[root@b28-17-51 ~]#mkdir -p /export/data
[root@b28-17-51 ~]#mkdir -p /export/log
[root@b28-17-51 export]#tar -xvf mongodb-linux-x86_64-3.0.6.tgz
[root@b28-17-51 export]#mv mongodb-linux-x86_64-3.0.6 mongodb
[root@b28-17-51 log]#touch mongodb.log
[root@b28-17-51 mongodb]#mkdir etc
[root@b28-17-51 etc]#touch mongodb.pid
[root@b28-17-51 etc]# vi mongod.conf
logpath=/export/log/mongodb.log
logappend=true
fork = true
dbpath=/export/data/db
pidfilepath = /export/mongodb/etc/mongodb.pid
rest = true
httpinterface = true
port = 27017
[root@b28-17-51 export]#numactl --interleave=all /export/mongodb/bin/mongod --config /export/mongodb/etc/mongod.conf
設定Mongodb啟動命令:
[root@b28-17-51 export]#groupadd mongodb
[root@b28-17-51 export]#useradd -m mongodb -g mongodb
指令碼如下:
[root@yoon ~]# cd /etc/init.d/
[root@yoon init.d]# vi mongod
#!/bin/bash
# mongod - Startup script for mongod
# chkconfig: 35 80 15
# description: Mongo is a scalable, document-oriented database.
# processname: mongod
#config: /export/mongodb/etc/mongod.conf
# pidfile: /export/mongodb/etc/mongodb.pid
source /etc/rc.d/init.d/functions
# things from mongod.conf get there by mongod reading it
if [ $(id -u) != "0" ]; then
echo "Permission Denied! Please use root to run again!"
exit 1
fi
test -d /export/mongodb || (mkdir -p /export/mongodb ; chown mongod:mongod /export/mongodb)
# NOTE: if you change any OPTIONS here, you get what you pay for:
# this script assumes all options are in the config file.
CONFIGFILE="/export/mongodb/etc/mongod.conf"
SYSCONFIG="/etc/sysconfig/mongod"
export PATH=$PATH:/export/mongodb/bin/
DBPATH=`awk -F= '/^dbpath/{print $2}' "$CONFIGFILE"`
OPTIONS=" --config $CONFIGFILE"
mongod=${MONGOD-/export/mongodb/bin/mongod}
echo "db path is: "$DBPATH
echo $mongod
MONGO_USER=mongodb
MONGO_GROUP=mongodb
[ -f "$SYSCONFIG" ] && source "$SYSCONFIG"
super() {
su - $MONGO_USER -c "PATH=$PATH:/export/mongodb/bin/; $*"
}
start()
{
echo -n $"Starting mongod: "
# echo -n "$MONGO_USER" "numactl --interleave=all"
# daemon --user "$MONGO_USER" "numactl --interleave=all" $mongod $OPTIONS
# daemon --user "$MONGO_USER" $mongod $OPTIONS
#
# su - $MONGO_USER -c "$mongod $OPTIONS" -m -p
# su - $MONGO_USER
# $mongod $OPTIONS
daemon --user "$MONGO_USER" "numactl --interleave=all" $mongod $OPTIONS
# super $mongod $OPTIONS
echo $mongod$OPTIONS
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/mongod
}
stop()
{
echo -n $"Stopping mongod: "
killproc -p "$DBPATH"/mongod.lock -d 300 /export/mongodb/bin/mongod
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/mongod
}
restart () {
stop
start
}
ulimit -n 12000
RETVAL=0
case "$1" in
start)
start
;;
stop)
stop
;;
restart|reload|force-reload)
restart
;;
condrestart)
[ -f /var/lock/subsys/mongod ] && restart || :
;;
status)
status $mongod
RETVAL=$?
;;
*)
echo "Usage: $0 {start|stop|status|restart|reload|force-reload|condrestart}"
RETVAL=1
esac
exit $RETVAL
==========================================
[root@yoon ~]# service mongod start
[root@yoon ~]# service mongod stop
===============================================
設定開機自動啟動Mongodb
[root@yoon ~]# chkconfig --add mongod
[root@yoon ~]# chkconfig mongod on
[root@yoon ~]# chkconfig mongod --list
mongod 0:off 1:off 2:on 3:on 4:on 5:on 6:off
[root@b28-17-51 ~]#mkdir -p /export/log
[root@b28-17-51 export]#tar -xvf mongodb-linux-x86_64-3.0.6.tgz
[root@b28-17-51 export]#mv mongodb-linux-x86_64-3.0.6 mongodb
[root@b28-17-51 log]#touch mongodb.log
[root@b28-17-51 mongodb]#mkdir etc
[root@b28-17-51 etc]#touch mongodb.pid
[root@b28-17-51 etc]# vi mongod.conf
logpath=/export/log/mongodb.log
logappend=true
fork = true
dbpath=/export/data/db
pidfilepath = /export/mongodb/etc/mongodb.pid
rest = true
httpinterface = true
port = 27017
[root@b28-17-51 export]#numactl --interleave=all /export/mongodb/bin/mongod --config /export/mongodb/etc/mongod.conf
設定Mongodb啟動命令:
[root@b28-17-51 export]#groupadd mongodb
[root@b28-17-51 export]#useradd -m mongodb -g mongodb
指令碼如下:
[root@yoon ~]# cd /etc/init.d/
[root@yoon init.d]# vi mongod
#!/bin/bash
# mongod - Startup script for mongod
# chkconfig: 35 80 15
# description: Mongo is a scalable, document-oriented database.
# processname: mongod
#config: /export/mongodb/etc/mongod.conf
# pidfile: /export/mongodb/etc/mongodb.pid
source /etc/rc.d/init.d/functions
# things from mongod.conf get there by mongod reading it
if [ $(id -u) != "0" ]; then
echo "Permission Denied! Please use root to run again!"
exit 1
fi
test -d /export/mongodb || (mkdir -p /export/mongodb ; chown mongod:mongod /export/mongodb)
# NOTE: if you change any OPTIONS here, you get what you pay for:
# this script assumes all options are in the config file.
CONFIGFILE="/export/mongodb/etc/mongod.conf"
SYSCONFIG="/etc/sysconfig/mongod"
export PATH=$PATH:/export/mongodb/bin/
DBPATH=`awk -F= '/^dbpath/{print $2}' "$CONFIGFILE"`
OPTIONS=" --config $CONFIGFILE"
mongod=${MONGOD-/export/mongodb/bin/mongod}
echo "db path is: "$DBPATH
echo $mongod
MONGO_USER=mongodb
MONGO_GROUP=mongodb
[ -f "$SYSCONFIG" ] && source "$SYSCONFIG"
super() {
su - $MONGO_USER -c "PATH=$PATH:/export/mongodb/bin/; $*"
}
start()
{
echo -n $"Starting mongod: "
# echo -n "$MONGO_USER" "numactl --interleave=all"
# daemon --user "$MONGO_USER" "numactl --interleave=all" $mongod $OPTIONS
# daemon --user "$MONGO_USER" $mongod $OPTIONS
#
# su - $MONGO_USER -c "$mongod $OPTIONS" -m -p
# su - $MONGO_USER
# $mongod $OPTIONS
daemon --user "$MONGO_USER" "numactl --interleave=all" $mongod $OPTIONS
# super $mongod $OPTIONS
echo $mongod$OPTIONS
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/mongod
}
stop()
{
echo -n $"Stopping mongod: "
killproc -p "$DBPATH"/mongod.lock -d 300 /export/mongodb/bin/mongod
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/mongod
}
restart () {
stop
start
}
ulimit -n 12000
RETVAL=0
case "$1" in
start)
start
;;
stop)
stop
;;
restart|reload|force-reload)
restart
;;
condrestart)
[ -f /var/lock/subsys/mongod ] && restart || :
;;
status)
status $mongod
RETVAL=$?
;;
*)
echo "Usage: $0 {start|stop|status|restart|reload|force-reload|condrestart}"
RETVAL=1
esac
exit $RETVAL
==========================================
[root@yoon ~]# service mongod start
[root@yoon ~]# service mongod stop
===============================================
設定開機自動啟動Mongodb
[root@yoon ~]# chkconfig --add mongod
[root@yoon ~]# chkconfig mongod on
[root@yoon ~]# chkconfig mongod --list
mongod 0:off 1:off 2:on 3:on 4:on 5:on 6:off
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/28939273/viewspace-1973672/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 5.6單例項安裝單例
- Redis單例項安裝Redis單例
- mysql 5.7單例項安裝MySql單例
- oracle單例項12.2.0.1安裝Oracle單例
- oracle 11g 單例項安裝Oracle單例
- 單機環境安裝配置ASM例項ASM
- 19C 單例項資料庫安裝單例資料庫
- mysql-5.6.31安裝(單例項 Linux)MySql單例Linux
- ORACLE 單例項完全解除安裝資料庫Oracle單例資料庫
- 【安裝】AIX安裝單例項11gR2 GRID+DBAI單例
- Oracle 11G資料庫單例項安裝Oracle資料庫單例
- Window下安裝Oracle ASM單例項資料庫OracleASM單例資料庫
- Oracle 12C 單例項安裝文件( 官方文件)Oracle單例
- Memcached安裝與使用例項
- oracle 11g 單例項資料庫的安裝Oracle單例資料庫
- Oracle 10g 安裝及單例項遷移到RACOracle 10g單例
- oracle例項安裝到 4% 不能繼續安裝Oracle
- oracle11g安裝 單例項 系統centos7Oracle單例CentOS
- ORACLE-LINUX環境字元介面單例項安裝OracleLinux字元單例
- Oracle 12C 單例項資料庫靜默安裝Oracle單例資料庫
- Oracle 11.2.4.0 ADG 單例項安裝(COPY建立備庫)Oracle單例
- Linux下安裝 Docker例項LinuxDocker
- 【Oracle】ASM例項安裝入門OracleASM
- BIND 9快速安裝例項(轉)
- 【PSU】Oracle打PSU及解除安裝PSU(單例項)Oracle單例
- AIX下安裝單例項ORACLE10gR2資料庫AI單例Oracle資料庫
- oracle 多個例項安裝監聽Oracle
- 清除安裝失敗的asm例項ASM
- 單例項刪除ASM例項單例ASM
- 11.2.0.4單例項ASM安裝報錯ohasd failed to ... line 73.單例ASMAI
- oracle19c安裝 單例項 系統centos7 非cdbOracle單例CentOS
- 12C 單例項-測試庫-圖形介面-安裝步驟單例
- 圖解 Mac+VMwareFusion+Oracle12cR1+PSU 單例項安裝圖解MacOracle單例
- 單例與單例項之爭單例
- 單例項物件動態裝載問題?單例物件
- mysqld_multi安裝多個mysql例項MySql
- Qmail+LDAP安裝配置例項(一)(轉)AILDA
- Oracle 11GR2 在CentOS 7 上的單例項靜默安裝OracleCentOS單例