一、配置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

二、mongodb安装
yum install -y mongodb-org
默认安装四个包
---> Package mongodb-org-mongos.x86_64 0:3.2.8-1.el6 will be installed
---> Package mongodb-org-server.x86_64 0:3.2.8-1.el6 will be installed
---> Package mongodb-org-shell.x86_64 0:3.2.8-1.el6 will be installed
---> Package mongodb-org-tools.x86_64 0:3.2.8-1.el6 will be installed

安装特定版本及组件
yum install -y mongodb-org-3.2.10 mongodb-org-server-3.2.10 mongodb-org-shell-3.2.10 mongodb-org-mongos-3.2.10 mongodb-org-tools-3.2.10

三、修改配置文件
systemLog:
   destination: file
   path: "/mongodb/rs1/logs/mongod.log"
   logAppend: true
   logRotate: "rename"
storage:
   dbPath: "/mongodb/rs1/data/"
   journal:
      enabled: true
   directoryPerDB: true
   syncPeriodSecs: 60
   engine: wiredTiger # MongoDB 3.0版本开始务必使用WT引擎
   wiredTiger:
      engineConfig:
         cacheSizeGB: 16
         statisticsLogDelaySecs: 0
         journalCompressor: snappy
         directoryForIndexes: true
      collectionConfig:
         blockCompressor: snappy
      indexConfig:
         prefixCompression: true
operationProfiling:
   slowOpThresholdMs: 200
   mode: slowOp
security:
   keyFile: /mongodb/rs1/keyfile
   authorization: enabled
processManagement:
   fork: true
   pidFilePath: /mongodb/rs1/data/mongodb.pid
net:
   bindIp: 192.168.110.133
   port: 28017
# 配置replication set
replication:
   oplogSizeMB: 1024
   replSetName: rs1

四、生产keyfile文件
[root@mhamaster rs1]# openssl rand -base64 755 > keyfile
[root@mhamaster rs1]# chmod 400 keyfile

启动实例
mongd -f /etc/mongod.conf

登录mongo
mongo --host 127.0.0.1 --port 28017

创建管理员用户
admin = db.getSiblingDB("admin")
admin.createUser(
...   {
...     user: "fred",
...     pwd: "changeme1",
...     roles: [ { role: "userAdminAnyDatabase", db: "admin" } ]
...   }
... )

mongo --host 127.0.0.1 --port 28017 -u "fred" -p"changeme1" --authenticationDatabase "admin"

三、error解决
如果遇到
[Errno 14] problem making ssl connection
Trying other mirror.
解决办法:
yum upgrade ca-certificade
备注:
ERROR: child process failed, exited with error number 1
keyfile文件缺失或生成方式以及文件权限可能有问题
==================================
openssl rand -base64 755 > keyfile
chmod 400 keyfile
09-22 20:32