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

debian安装mongoDB

时间:2019-03-12 10:44:14      阅读:634      评论:0      收藏:0      [点我收藏+]

标签:white   local   while   style   usr   ror   net   服务器   success   

wget http://fastdl.mongodb.org/linux/mongodb-linux-i686-1.8.2.tgz
tar zxf mongodb-linux-i686-1.8.2.tgz
mv mongodb-linux-i686-1.8.2 /usr/local/mongodb
mkdir /data/mongodb
touch /var/log/mongodb/mongod.log
vim /etc/mongod.conf
    插入内容
    systemLog:
       destination: file
       path: "/var/log/mongodb/mongod.log"
       logAppend: true
    storage:
       dbPath: "/data/mongodb"
       journal:
          enabled: true
    processManagement:
       fork: true
    net:
       bindIpAll: true
       port: 27017
    setParameter:
       enableLocalhostAuthBypass: false
添加rc.local文件
cat <<EOF >/etc/rc.local
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
exit 0
EOF
赋予权限
chmod +x /etc/rc.local
启动rc.local服务
systemctl start rc-local
启动mongodb服务
/usr/local/mongodb/bin/mongod --config=/etc/mongod.conf
如果出现
mongod: error while loading shared libraries: libcurl.so.4: cannot open shared object file: No such file or directory
需要安装curl
apt-get install curl
切换到admin目录
use admin
添加管理用户root(所有)
db.createUser({user: "root",pwd: "*******",roles: [ { role: "root", db: "admin" } ]});
添加数据获取用户zz_api(读写)
db.createUser({user: "zz_api",pwd: "*******",roles: [ { role: "readWrite", db: "zz_web" } ]});
添加爬虫用户zz_spider(读写)
db.createUser({user: "zz_spider",pwd: "*******",roles: [ { role: "readWrite", db: "zz_web" } ]});
创建zz_web数据库
use zz_web
退出
exit
添加开机自启
vim /etc/rc.local
在exit 0之前添加
/usr/local/mongodb/bin/mongod --auth --config=/etc/mongodb.conf >/dev/null 2>&1
退出重启服务器测试

debian安装mongoDB

标签:white   local   while   style   usr   ror   net   服务器   success   

原文地址:https://www.cnblogs.com/phpk/p/10514992.html

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