Centos7下快速安装Mongo3.2

Centos7下快速安装Mongo3.2

**一般安装Mongo推荐源码安装,有时候为了快部署测试环境,或者仅仅是想装个mongo shell,这时候yum安装是最合适的方式,
下面介绍一下如何在Centos 7 下用yum的方式快速安装Mongo。
**

MongoDB 3.2 一共有五个包:
mongodb-org-3.2.10-1.el7.x86_64.rpm         #元数据包 上面记录下以下4个包的依赖关系                           
mongodb-org-server-3.2.10-1.el7.x86_64.rpm  #mongod服务端程序,以及相关的配置和初始化脚本。                          
mongodb-org-shell-3.2.10-1.el7.x86_64.rpm   #mongo shell 客户端环境                           
mongodb-org-tools-3.2.10-1.el7.x86_64.rpm   #最大的一个包,有关Mongo的工具:包括 mongoimport mongostat等                          
mongodb-org-mongos-3.2.10-1.el7.x86_64.rpm  #mongos程序 用来分片的路由                     

1.配置yum源

vi /etc/yum.repos.d/mongodb-org-3.2.repo
[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

2.yum 安装 MongoDB

yum -y install mongodb-org 

#我这里只安装mogno shell
[root@localhost scripts]# yum install mongodb-org-shell
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.sohu.com
 * extras: mirrors.sohu.com
 * updates: mirrors.sohu.com
正在解决依赖关系
--> 正在检查事务
---> 软件包 mongodb-org-shell.x86_64.0.3.2.16-1.el7 将被 安装
--> 解决依赖关系完成

依赖关系解决

=============================================================================================================================
 Package   架构   版本 源   大小
=============================================================================================================================
正在安装:
 mongodb-org-shell x86_64 3.2.16-1.el7 mongodb-org-3.2 6.8 M

事务概要
=============================================================================================================================
安装  1 软件包

总下载量:6.8 M
安装大小:20 M
Is this ok [y/d/N]: y
Downloading packages:
No Presto metadata available for mongodb-org-3.2
警告:/var/cache/yum/x86_64/7/mongodb-org-3.2/packages/mongodb-org-shell-3.2.16-1.el7.x86_64.rpm: 头V3 RSA/SHA1 Signature, 密钥 ID ea312927: NOKEY
mongodb-org-shell-3.2.16-1.el7.x86_64.rpm 的公钥尚未安装
mongodb-org-shell-3.2.16-1.el7.x86_64.rpm | 6.8 MB  00:02:15 
从 https://www.mongodb.org/static/pgp/server-3.2.asc 检索密钥
导入 GPG key 0xEA312927:
 用户ID : "MongoDB 3.2 Release Signing Key <packaging@mongodb.com>"
 指纹   : 42f3 e95a 2c4f 0827 9c49 60ad d68f a50f ea31 2927
 来自   : https://www.mongodb.org/static/pgp/server-3.2.asc
是否继续?[y/N]:y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  正在安装: mongodb-org-shell-3.2.16-1.el7.x86_641/1 
  验证中  : mongodb-org-shell-3.2.16-1.el7.x86_641/1 

已安装:
  mongodb-org-shell.x86_64 0:3.2.16-1.el7

完毕!

3.验证安装

[root@localhost scripts]# mongo --host xx.x.xxx.xxx
MongoDB shell version: 3.2.16
connecting to: xx.x.xxx.xxx:27017/test
Welcome to the MongoDB shell.
For interactive help, type "help".
For more comprehensive documentation, see
http://docs.mongodb.org/
Questions? Try the support group
http://groups.google.com/group/mongodb-user