脚踏实地、勇往直前!
全部博文(1005)
分类: NOSQL
2014-10-17 13:06:26
安装mongodb
1.下载
mongodb-linux-x86_64-2.6.5.tgz
2.创建用户
[root@node2 soft]# groupadd mongo
[root@node2 soft]# useradd -g mongo mongo
[root@node2 ~]# passwd mongo
3.解压缩
[root@node2 soft]# tar -zxvf mongodb-linux-x86_64-2.6.5.tgz
4.创建mongodb目录
mkdir -p /db/mongodb
5.将mongodb迁移到相应目录
mv mongodb-linux-x86_64-2.6.5 /db/mongodb/mongodb
chown -R mongo:mongo ./mongodb
6.使用mongo用户登录创建数据文件和日志文件
[mongo@node2 db]$ mkdir -p /db/mongodb/data
[mongo@node2 db]$ mkdir -p /db/mongodb/log
[mongo@node2 db]$ mkdir -p /db/mongodb/conf
[mongo@node2 db]$ touch /db/mongodb/log/logs
mongodb配置文件参数
8.启动mongodb(mongo用户)
./mongod -f /opt/mongodb/conf/master.cnf
权限问题,使用sudo启动
[mongo@node2 ~]$ mongod --dbpath=/db/mongodb/data --logpath=/db/mongodb/log/logs --logappend --port=27017 --fork
We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:
#1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great responsibility.
[sudo] password for mongo:
mongo is not in the sudoers file. This incident will be reported.
解决办法:
A.chmod u+w /etc/sudoers
B.编辑sudoers文件
vi /etc/sudoers
找到这行 root ALL=(ALL) ALL,在他下面添加xxx ALL=(ALL) ALL (这里的xxx是你的用户名)
如:
## Allow root to run any commands anywhere
root ALL=(ALL) ALL
mongo ALL=(ALL) ALL
C.撤销权限
chmod u-w /etc/sudoers
9.再次启动
[mongo@node2 ~]$ sudo mongod --dbpath=/db/mongodb/data --logpath=/db/mongodb/log/logs --logappend --port=27017 --fork
10.关闭
[mongo@node2 ~]$ sudo mongo admin --eval "db.shutdownServer()"
-- The End --