根据mongodb官网提供的教程安装:
1.创建mongdb-org-3.4.repo
2.使得selinux的config为disabled
3.yum -y install mongodbxxxxxx
4.配置/etc/mongod.conf
5.service mongod start
[root@bogon yum.repos.d]# touch mongodb-org-3.4.repo
[root@bogon yum.repos.d]# ls
CentOS-Base.repo CentOS-Debuginfo.repo CentOS-Media.repo CentOS-Vault.repo
CentOS-CR.repo CentOS-fasttrack.repo CentOS-Sources.repo
mongodb-org-3.4.repo
[root@bogon yum.repos.d]#
vi mongodb-org-3.4.repo
[root@bogon yum.repos.d]#
yum install -y mongodb-org
已加载插件:fastestmirror, langpacks
base | 3.6 kB 00:00:00
extras | 3.4 kB 00:00:00
mongodb-org-3.4 | 2.4 kB 00:00:00
updates | 3.4 kB 00:00:00
(1/5): base/7/x86_64/group_gz | 155 kB 00:00:02
(2/5): extras/7/x86_64/primary_db | 183 kB 00:00:02
(3/5): mongodb-org-3.4/7/primary_db | 8.5 kB 00:00:02
(4/5): updates/7/x86_64/primary_db | 1.2 MB 00:00:03
(5/5): base/7/x86_64/primary_db | 5.6 MB 00:00:08
Determining fastest mirrors
* base: mirrors.163.com
* extras: mirrors.163.com
* updates: mirrors.163.com
正在解决依赖关系
--> 正在检查事务
---> 软件包 mongodb-org.x86_64.0.3.4.0-1.el7 将被 安装
--> 正在处理依赖关系 mongodb-org-tools = 3.4.0,它被软件包 mongodb-org-3.4.0-1.el7.x86_64 需要
--> 正在处理依赖关系 mongodb-org-shell = 3.4.0,它被软件包 mongodb-org-3.4.0-1.el7.x86_64 需要
--> 正在处理依赖关系 mongodb-org-server = 3.4.0,它被软件包 mongodb-org-3.4.0-1.el7.x86_64 需要
--> 正在处理依赖关系 mongodb-org-mongos = 3.4.0,它被软件包 mongodb-org-3.4.0-1.el7.x86_64 需要
--> 正在检查事务
---> 软件包 mongodb-org-mongos.x86_64.0.3.4.0-1.el7 将被 安装
---> 软件包 mongodb-org-server.x86_64.0.3.4.0-1.el7 将被 安装
---> 软件包 mongodb-org-shell.x86_64.0.3.4.0-1.el7 将被 安装
---> 软件包 mongodb-org-tools.x86_64.0.3.4.0-1.el7 将被 安装
--> 解决依赖关系完成
依赖关系解决
===============================================================================================================================================================
Package 架构 版本 源 大小
===============================================================================================================================================================
正在安装:
mongodb-org x86_64 3.4.0-1.el7 mongodb-org-3.4 5.8 k
为依赖而安装:
mongodb-org-mongos x86_64 3.4.0-1.el7 mongodb-org-3.4 12 M
mongodb-org-server x86_64 3.4.0-1.el7 mongodb-org-3.4 20 M
mongodb-org-shell x86_64 3.4.0-1.el7 mongodb-org-3.4 11 M
mongodb-org-tools x86_64 3.4.0-1.el7 mongodb-org-3.4 49 M
事务概要
===============================================================================================================================================================
安装 1 软件包 (+4 依赖软件包)
总下载量:91 M
安装大小:257 M
Downloading packages:
警告:/var/cache/yum/x86_64/7/mongodb-org-3.4/packages/mongodb-org-3.4.0-1.el7.x86_64.rpm: 头V3 RSA/SHA1 Signature, 密钥 ID a15703c6: NOKEY/s | 0 B --:--:-- ETA
mongodb-org-3.4.0-1.el7.x86_64.rpm 的公钥尚未安装
(1/5): mongodb-org-3.4.0-1.el7.x86_64.rpm | 5.8 kB 00:00:01
(2/5): mongodb-org-mongos-3.4.0-1.el7.x86_64.rpm | 12 MB 00:01:27
(3/5): mongodb-org-shell-3.4.0-1.el7.x86_64.rpm | 11 MB 00:00:47
(4/5): mongodb-org-server-3.4.0-1.el7.x86_64.rpm | 20 MB 00:02:27
(5/5): mongodb-org-tools-3.4.0-1.el7.x86_64.rpm | 49 MB 00:02:10
---------------------------------------------------------------------------------------------------------------------------------------------------------------
总计 352 kB/s | 91 MB 00:04:25
从 https://www.mongodb.org/static/pgp/server-3.4.asc 检索密钥
导入 GPG key 0xA15703C6:
用户ID : "MongoDB 3.4 Release Signing Key <[email protected]>"
指纹 : 0c49 f373 0359 a145 1858 5931 bc71 1f9b a157 03c6
来自 : https://www.mongodb.org/static/pgp/server-3.4.asc
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
正在安装 : mongodb-org-server-3.4.0-1.el7.x86_64 1/5
Created symlink from /etc/systemd/system/multi-user.target.wants/mongod.service to /usr/lib/systemd/system/mongod.service.
正在安装 : mongodb-org-tools-3.4.0-1.el7.x86_64 2/5
正在安装 : mongodb-org-mongos-3.4.0-1.el7.x86_64 3/5
正在安装 : mongodb-org-3.4.0-1.el7.x86_64 5/5
验证中 : mongodb-org-shell-3.4.0-1.el7.x86_64 1/5
验证中 : mongodb-org-mongos-3.4.0-1.el7.x86_64 2/5
验证中 : mongodb-org-tools-3.4.0-1.el7.x86_64 3/5
验证中 : mongodb-org-server-3.4.0-1.el7.x86_64 4/5
验证中 : mongodb-org-3.4.0-1.el7.x86_64 5/5
已安装:
mongodb-org.x86_64 0:3.4.0-1.el7
作为依赖被安装:
mongodb-org-mongos.x86_64 0:3.4.0-1.el7 mongodb-org-server.x86_64 0:3.4.0-1.el7 mongodb-org-shell.x86_64 0:3.4.0-1.el7
mongodb-org-tools.x86_64 0:3.4.0-1.el7
完毕!
[root@bogon yum.repos.d]#
cd /etc/selinux/
[root@bogon selinux]# ls
config semanage.conf targeted
[root@bogon selinux]#
cat config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
#SELINUX=enforcing
# SELINUXTYPE= can take one of three two values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
#SELINUXTYPE=targeted
SELINUX=disabled
[root@bogon lib]#
service mongod start
Redirecting to /bin/systemctl start mongod.service
[root@bogon lib]#
ps -ef | grep mongod
mongod 5727 1 3 11:10 ? 00:00:00 /usr/bin/mongod --quiet -f /etc/mongod.conf run
root 5745 5416 0 11:10 pts/2 00:00:00 grep --color=auto mongod
[root@bogon lib]# cd /var/log/mongodb/
[root@bogon mongodb]# ls
mongod.log
[root@bogon mongodb]#
cat mongod.log
2016-12-18T11:10:29.254+0800 I CONTROL [main] ***** SERVER RESTARTED *****
2016-12-18T11:10:29.261+0800 I CONTROL [initandlisten] MongoDB starting : pid=5727 port=27017 dbpath=/var/lib/mongo 64-bit host=bogon
2016-12-18T11:10:29.261+0800 I CONTROL [initandlisten] db version v3.4.0
2016-12-18T11:10:29.261+0800 I CONTROL [initandlisten] git version: f4240c60f005be757399042dc12f6addbc3170c1
2016-12-18T11:10:29.261+0800 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.1e-fips 11 Feb 2013
2016-12-18T11:10:29.261+0800 I CONTROL [initandlisten] allocator: tcmalloc
2016-12-18T11:10:29.261+0800 I CONTROL [initandlisten] modules: none
2016-12-18T11:10:29.261+0800 I CONTROL [initandlisten] build environment:
2016-12-18T11:10:29.261+0800 I CONTROL [initandlisten] distmod: rhel70
2016-12-18T11:10:29.261+0800 I CONTROL [initandlisten] distarch: x86_64
2016-12-18T11:10:29.261+0800 I CONTROL [initandlisten] target_arch: x86_64
2016-12-18T11:10:29.270+0800 I CONTROL [initandlisten] options: { command: [ "run" ], config: "/etc/mongod.conf", net: { bindIp: "127.0.0.1", port: 27017 }, p
rocessManagement: { fork: true, pidFilePath: "/var/run/mongodb/mongod.pid" }, storage: { dbPath: "/var/lib/mongo", journal: { enabled: true } }, systemLog: { d
estination: "file", logAppend: true, path: "/var/log/mongodb/mongod.log", quiet: true } }
2016-12-18T11:10:29.294+0800 I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=879M,session_max=20000,eviction=(threads_max=4),config_base=f
alse,statistics=(fast),log=(enabled=true,archive=true,path=journal,compressor=snappy),file_manager=(close_idle_time=100000),checkpoint=(wait=60,log_size=2GB),s
tatistics_log=(wait=0),
2016-12-18T11:10:29.333+0800 I CONTROL [initandlisten]
2016-12-18T11:10:29.333+0800 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database.
2016-12-18T11:10:29.333+0800 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted.
2016-12-18T11:10:29.333+0800 I CONTROL [initandlisten]
2016-12-18T11:10:29.333+0800 I CONTROL [initandlisten]
2016-12-18T11:10:29.333+0800 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
2016-12-18T11:10:29.333+0800 I CONTROL [initandlisten] ** We suggest setting it to 'never'
2016-12-18T11:10:29.333+0800 I CONTROL [initandlisten]
2016-12-18T11:10:29.333+0800 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2016-12-18T11:10:29.333+0800 I CONTROL [initandlisten] ** We suggest setting it to 'never'
2016-12-18T11:10:29.333+0800 I CONTROL [initandlisten]
2016-12-18T11:10:29.381+0800 I FTDC [initandlisten] Initializing full-time diagnostic data capture with directory '/var/lib/mongo/diagnostic.data'
2016-12-18T11:10:29.400+0800 I INDEX [initandlisten] build index on: admin.system.version properties: { v: 2, key: { version: 1 }, name: "incompatible_with_
version_32", ns: "admin.system.version" }
2016-12-18T11:10:29.401+0800 I INDEX [initandlisten] building index using bulk method; build may temporarily use up to 500 megabytes of RAM
2016-12-18T11:10:29.402+0800 I INDEX [initandlisten] build index done. scanned 0 total records. 0 secs
2016-12-18T11:10:29.403+0800 I COMMAND [initandlisten] setting featureCompatibilityVersion to 3.4
2016-12-18T11:10:29.405+0800 I NETWORK [thread1] waiting for connections on port 27017
卸载mongodb
1.service mongod stop
2.sudo yum erase $(rpm -qa | grep mongodb-org)
3.移除日志数据文件
sudo rm -r /var/log/mongodb
sudo rm -r /var/lib/mongo