码迷,mamicode.com
首页 > 数据库 > 详细

MongoDB安装

时间:2019-11-17 01:31:41      阅读:107      评论:0      收藏:0      [点我收藏+]

标签:环境   init   reload   fork   创建数据库   style   fun   database   ret   

1.解压软件包

tar -zxvf mongodb-linux-x86_64-4.0.0.tgz

2.重命名

[root@nam-qa2 software]# mv mongodb-linux-x86_64-4.0.0 mongodb

3.配置环境变量

#Set Mongodb
MONGODB_HOME=/software/mongodb
PATH=$PATH:$MONGODB_HOME/bin

 4.创建数据库目录以及日志目录

cd /software/mongodb
$ touch mongodb.conf
$ mkdir db
$ mkdir log
$ cd log
$ touch mongodb.log

5.创建配置文件

port=27017
dbpath= /software/mongodb/db
logpath= /software/mongodb/log/mongodb.log
logappend=true
fork=true
maxConns=100
noauth=true
journal=true
storageEngine=wiredTiger
bind_ip = 0.0.0.0

 6.启动服务测试

cd /software/mongodb
bin/mongod -f /software/mongodb/mongo.conf

 

 

[Unit]  
Description=mongodb  
After=network.target remote-fs.target nss-lookup.target  
  
[Service]  
Type=forking  
ExecStart=/software/mongodb/bin/mongod --config /software/mongodb/bin/mongodb.conf  
ExecReload=/bin/kill -s HUP $MAINPID  
ExecStop=/software/mongodb/bin/mongod --shutdown --config /software/mongodb/bin/mongodb.conf  
PrivateTmp=true  
[Install]  
WantedBy=multi-user.target

 

 

#!/bin/sh
#
#mongod - Startup script for mongod
#
# chkconfig: - 85 15
# description: Mongodb database.
# processname: mongod
# Source function library
 
. /etc/rc.d/init.d/functions
# things from mongod.conf get there by mongod reading it
# OPTIONS
OPTIONS=" --dbpath=/software/mongodb/ --logpath=/software/mongodb/log/mongodb.log --logappend &"
#mongod
mongod="/software/mongodb/bin/mongod"
lockfile=/var/lock/subsys/mongod
start()
{
  echo -n $"Starting mongod: "
  daemon $mongod $OPTIONS
  RETVAL=$?
  echo
  [ $RETVAL -eq 0 ] && touch $lockfile
}
 
stop()
{
  echo -n $"Stopping mongod: "
  killproc $mongod -QUIT
  RETVAL=$?
  echo
  [ $RETVAL -eq 0 ] && rm -f $lockfile
}
 
restart () {
        stop
        start
}
ulimit -n 12000
RETVAL=0
 
case "$1" in
  start)
    start
    ;;
  stop)
    stop
    ;;
  restart|reload|force-reload)
    restart
    ;;
  condrestart)
    [ -f $lockfile ] && restart || :
    ;;
  status)
    status $mongod
    RETVAL=$?
    ;;
  *)
    echo "Usage: $0 {start|stop|status|restart|reload|force-reload|condrestart}"
    RETVAL=1
esac
exit $RETVAL

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

MongoDB安装

标签:环境   init   reload   fork   创建数据库   style   fun   database   ret   

原文地址:https://www.cnblogs.com/wongandy/p/11874725.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!