centos 安装mongodb

来源:互联网 发布:南粤大数据 编辑:程序博客网 时间:2024/05/17 08:38
1、解压
tar xzf redis-2.8.3.tar.gz

2、添加mongo.cof
# 指定数据库路径dbpath=/mortred/mongodb-3.4.1/data # 指定服务端口号,默认端口27017port=27017 #设置每个数据库将被保存在一个单独的目录directoryperdb=true # 启用验证(注意,后面要改成true)auth=false #以守护进程的方式运行MongoDB,创建服务器进程fork=true #提供http接口httpinterface=true # 指定MongoDB日志文件,注意是指定文件不是目录logpath=/mortred/mongodb-3.4.1/logs/mongo.log # 使用追加的方式写日志logappend=true



3、新建文件/etc/init.d/mongodb
#!/bin/sh# chkconfig: 2345 80 90 # description: mongodbstart(){/mortred/mongodb-3.4.1/bin/mongod -f /mortred/mongodb-3.4.1/mongodb.conf}stop(){/mortred/mongodb-3.4.1/bin/mongod -f /mortred/mongodb-3.4.1/mongodb.conf --shutdown}case "$1" instart)start;;stop)stop;;restrat)stopstart;;*)echo "please use start|stop|restrat"exit 1esac



4、设置开机启动
chmod +x /etc/init.d/mongodb
sudo chkconfig mongodb on  

5、启动
service mongodb start
0 0
原创粉丝点击