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

centos7 安装mongoDB

时间:2019-01-05 13:33:02      阅读:226      评论:0      收藏:0      [点我收藏+]

标签:chm   bpa   cst   hup   centos   private   index   x86_64   systemctl   

1官网下载: https://www.mongodb.com/download-center/community

2上传至目录 /opt/mongoDb 下

3解压

tar zxvf mongodb-linux-x86_64-4.0.5.tgz

4添加配置文件

vim /opt/mongoDB/mongodb-linux-x86_64-4.0.5/bin/mongodb.conf

 

# 数据库文件路径
dbpath = /opt/mongoDB/mongodb-linux-x86_64-4.0.5/data
# 日志文件路径
logpath = /opt/mongoDB/mongodb-linux-x86_64-4.0.5/logs/mongodb.log
# 是否追加日志
logappend=true
# 端口
port=27017
# 是否后台程序启动
fork=true
# 是否启动授权认证
auth=true
# 开启链接权限
bind_ip=0.0.0.0

5配置mongodb服务

vim /lib/systemd/system/mongodb.service

  

[Unit]

Description=mongodb
After=network.target remote-fs.target nss-lookup.target

[Service]
Type=forking
ExecStart=/opt/mongoDB/mongodb-linux-x86_64-4.0.5/bin/mongod --config /opt/mongoDB/mongodb-linux-x86_64-4.0.5/bin/mongodb.conf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/opt/mongoDB/mongodb-linux-x86_64-4.0.5/bin/mongod --shutdown --config /opt/mongoDB/mongodb-linux-x86_64-4.0.5/bin/mongodb.conf
PrivateTmp=true

[Install]
WantedBy=multi-user.target

6设置权限

chmod 754 mongodb.service 

7启动关闭服务,设置开机启动

#启动服务 

systemctl start mongodb.service   

#关闭服务   
systemctl stop mongodb.service   
#开机启动   
systemctl enable mongodb.service

 

centos7 安装mongoDB

标签:chm   bpa   cst   hup   centos   private   index   x86_64   systemctl   

原文地址:https://www.cnblogs.com/liuq1991/p/10223963.html

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