Mongodb的安装和启动

1、官方下载地址:https://www.mongodb.com/download-center

2、官方安装文档:https://docs.mongodb.com/manual/tutorial/install-mongodb-on-red-hat/

3、官方使用文档:https://docs.mongodb.com/manual/

4、官方中文文档:http://docs.mongoing.com/manual-zh/index.html

4、yum安装:

[mongodb-org-3.2]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.2/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-3.2.asc

yum list | grep mongodb 中各.rpm包的作用

#包含所有的mongodb中所有的安装包
mongodb-org    A metapackage that will automatically install the four component packages listed below.

#仅是mongodb的服务端
mongodb-org-server    Contains the mongod daemon and associated configuration and init scripts.

#mongodb的例子
mongodb-org-mongos    Contains the mongos daemon.

#mongodb的shell命令行
mongodb-org-shell    Contains the mongo shell.

#mongodb的工具
mongodb-org-tools    Contains the following MongoDB tools: mongoimport bsondump, mongodump, mongoexport, mongofiles, mongooplog, mongoperf, mongorestore, mongostat, and mongotop.

5、开机自动启动

chkconfig mongod on

6、mongodb的启动、停止、重启

systemctl start mongodb
systemctl stop mongodb
systemctl restart mongodb

也可以指定 conf文件启动
/usr/bin/mongod -f /etc/mongod.conf

7、编译文件安装与启动

编写mongod.conf文件,参考:Mongodb的配置注意:创建要先创建mongod用户组和mongod用户,为启动mongodb使用,因为如果使用root启动,那shell工具mogo将无法使用.

#groupadd mongod
# useradd -g mongod mongod

#chown -R mongod:mongod /usr/local/mongod

# mkdir -p /var/log/mongod
# chown -R mongod:mongod /var/log/mongod

# mkdir -p /data/mongod
# chown -R mongod:mongod /data/mongod

# mkdir -p /run/mongod
# chown -R mongod:mongod /run/mongod

#启动
# /usr/local/mongod/bin/mongod -f /usr/local/mongod/mongod.conf --httpinterface

8、其他的2个系统设置,参考:Mongodb安装过程中的问题

发表评论

电子邮件地址不会被公开。 必填项已用*标注

您可以使用这些HTML标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>