1:4.0版本下载指定rpm文件
https://repo.mongodb.org/yum/redhat/7Server/mongodb-org/4.0/x86_64/RPMS/
2:centos7 安装指定版本的MongoDB (完整版 此处下载mongo4.0.10)
添加mongo源
cd /etc/yum.repos.d/ vi mongodb-org-4.0.repo
mongodb-org-4.0.repo内容为
[mongodb-org-4.0] name=MongoDB Repository baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/4.0/x86_64/ gpgcheck=1 enabled=1 gpgkey=https://www.mongodb.org/static/pgp/server-4.0.asc
yum 直接安装 带上版本号即可
sudo yum install -y mongodb-org-4.0.10 mongodb-org-server-4.0.10 mongodb-org-shell-4.0.10 mongodb-org-mongos-4.0.10 mongodb-org-tools-4.0.10
安装的详细信息如下
[root@localhost yum.repos.d]# sudo yum install -y mongodb-org-4.0.10 mongodb-org-server-4.0.10 mongodb-org-shell-4.0.10 mongodb-org-mongos-4.0.10 mongodb-org-tools-4.0.10 已加载插件:fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: mirrors.tuna.tsinghua.edu.cn * extras: mirrors.tuna.tsinghua.edu.cn * updates: mirrors.tuna.tsinghua.edu.cn base | 3.6 kB 00:00:00 extras | 2.9 kB 00:00:00 mongodb-org-4.0 | 2.5 kB 00:00:00 mysql-connectors-community | 2.5 kB 00:00:00 mysql-tools-community | 2.5 kB 00:00:00 mysql57-community-dmr | 2.5 kB 00:00:00 updates | 2.9 kB 00:00:00 正在解决依赖关系 --> 正在检查事务 ---> 软件包 mongodb-org.x86_64.0.4.0.10-1.el7 将被 安装 ---> 软件包 mongodb-org-mongos.x86_64.0.4.0.10-1.el7 将被 安装 ---> 软件包 mongodb-org-server.x86_64.0.4.0.10-1.el7 将被 安装 ---> 软件包 mongodb-org-shell.x86_64.0.4.0.10-1.el7 将被 安装 ---> 软件包 mongodb-org-tools.x86_64.0.4.0.10-1.el7 将被 安装 --> 解决依赖关系完成 依赖关系解决 ============================================================================================================================================================================================= Package 架构 版本 源 大小 ============================================================================================================================================================================================= 正在安装: mongodb-org x86_64 4.0.10-1.el7 mongodb-org-4.0 5.8 k mongodb-org-mongos x86_64 4.0.10-1.el7 mongodb-org-4.0 12 M mongodb-org-server x86_64 4.0.10-1.el7 mongodb-org-4.0 21 M mongodb-org-shell x86_64 4.0.10-1.el7 mongodb-org-4.0 13 M mongodb-org-tools x86_64 4.0.10-1.el7 mongodb-org-4.0 46 M 事务概要 ============================================================================================================================================================================================= 安装 5 软件包 总下载量:93 M 安装大小:257 M Downloading packages: 警告:/var/cache/yum/x86_64/7/mongodb-org-4.0/packages/mongodb-org-4.0.10-1.el7.x86_64.rpm: 头V3 RSA/SHA1 Signature, 密钥 ID e52529d4: NOKEY ] 105 kB/s | 208 kB 00:15:03 ETA mongodb-org-4.0.10-1.el7.x86_64.rpm 的公钥尚未安装 (1/5): mongodb-org-4.0.10-1.el7.x86_64.rpm | 5.8 kB 00:00:03 (2/5): mongodb-org-mongos-4.0.10-1.el7.x86_64.rpm | 12 MB 00:01:05 (3/5): mongodb-org-server-4.0.10-1.el7.x86_64.rpm | 21 MB 00:01:48 (4/5): mongodb-org-shell-4.0.10-1.el7.x86_64.rpm | 13 MB 00:01:18 (5/5): mongodb-org-tools-4.0.10-1.el7.x86_64.rpm | 46 MB 00:02:40 --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 总计 349 kB/s | 93 MB 00:04:32 从 https://www.mongodb.org/static/pgp/server-4.0.asc 检索密钥 导入 GPG key 0xE52529D4: 用户ID : "MongoDB 4.0 Release Signing Key <packaging@mongodb.com>" 指纹 : 9da3 1620 334b d75d 9dcb 49f3 6881 8c72 e525 29d4 来自 : https://www.mongodb.org/static/pgp/server-4.0.asc Running transaction check Running transaction test Transaction test succeeded Running transaction 警告:RPM 数据库已被非 yum 程序修改。 ** 发现 2 个已存在的 RPM 数据库问题, 'yum check' 输出如下: 2:postfix-2.10.1-7.el7.x86_64 有缺少的需求 libmysqlclient.so.18()(64bit) 2:postfix-2.10.1-7.el7.x86_64 有缺少的需求 libmysqlclient.so.18(libmysqlclient_18)(64bit) 正在安装 : mongodb-org-shell-4.0.10-1.el7.x86_64 1/5 正在安装 : mongodb-org-mongos-4.0.10-1.el7.x86_64 2/5 正在安装 : mongodb-org-tools-4.0.10-1.el7.x86_64 3/5 正在安装 : mongodb-org-server-4.0.10-1.el7.x86_64 4/5 Created symlink from /etc/systemd/system/multi-user.target.wants/mongod.service to /usr/lib/systemd/system/mongod.service. 正在安装 : mongodb-org-4.0.10-1.el7.x86_64 5/5 验证中 : mongodb-org-4.0.10-1.el7.x86_64 1/5 验证中 : mongodb-org-server-4.0.10-1.el7.x86_64 2/5 验证中 : mongodb-org-tools-4.0.10-1.el7.x86_64 3/5 验证中 : mongodb-org-mongos-4.0.10-1.el7.x86_64 4/5 验证中 : mongodb-org-shell-4.0.10-1.el7.x86_64 5/5 已安装: mongodb-org.x86_64 0:4.0.10-1.el7 mongodb-org-mongos.x86_64 0:4.0.10-1.el7 mongodb-org-server.x86_64 0:4.0.10-1.el7 mongodb-org-shell.x86_64 0:4.0.10-1.el7 mongodb-org-tools.x86_64 0:4.0.10-1.el7 完毕!
验证
systemctl start mongod.service
systemctl status mongod.service
● mongod.service - MongoDB Database Server Loaded: loaded (/usr/lib/systemd/system/mongod.service; enabled; vendor preset: disabled) Active: active (running) since 三 2020-08-12 19:20:51 CST; 12s ago Docs: https://docs.mongodb.org/manual Process: 8164 ExecStart=/usr/bin/mongod $OPTIONS (code=exited, status=0/SUCCESS) Process: 8162 ExecStartPre=/usr/bin/chmod 0755 /var/run/mongodb (code=exited, status=0/SUCCESS) Process: 8159 ExecStartPre=/usr/bin/chown mongod:mongod /var/run/mongodb (code=exited, status=0/SUCCESS) Process: 8155 ExecStartPre=/usr/bin/mkdir -p /var/run/mongodb (code=exited, status=0/SUCCESS) Main PID: 8167 (mongod) Tasks: 27 CGroup: /system.slice/mongod.service └─8167 /usr/bin/mongod -f /etc/mongod.conf 8月 12 19:20:50 localhost.localdomain systemd[1]: Starting MongoDB Database Server... 8月 12 19:20:51 localhost.localdomain mongod[8164]: about to fork child process, waiting until server is ready for connections. 8月 12 19:20:51 localhost.localdomain mongod[8164]: forked process: 8167 8月 12 19:20:51 localhost.localdomain systemd[1]: Started MongoDB Database Server.
3:离线安装方式(完整版) 安装指定版本的mongo 这里安装mongo4.0.19
先下载好rpm文件
yum install --downloadonly --downloaddir=/song/mongo4.0.19 mongodb-org-4.0.19 mongodb-org-server-4.0.19 mongodb-org-shell-4.0.19 mongodb-org-mongos-4.0.19 mongodb-org-tools-4.0.19
执行安装
[root@localhost mongo4.0.19]# rpm -ivh mongodb-org-server-4.0.19-1.el7.x86_64.rpm warning: mongodb-org-server-4.0.19-1.el7.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID e52529d4: NOKEY Preparing... ################################# [100%] Updating / installing... 1:mongodb-org-server-4.0.19-1.el7 ################################# [100%] Created symlink from /etc/systemd/system/multi-user.target.wants/mongod.service to /usr/lib/systemd/system/mongod.service. [root@localhost mongo4.0.19]# rpm -ivh mongodb-org-tools-4.0.19-1.el7.x86_64.rpm warning: mongodb-org-tools-4.0.19-1.el7.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID e52529d4: NOKEY Preparing... ################################# [100%] Updating / installing... 1:mongodb-org-tools-4.0.19-1.el7 ################################# [100%] [root@localhost mongo4.0.19]# rpm -ivh mongodb-org-shell-4.0.19-1.el7.x86_64.rpm warning: mongodb-org-shell-4.0.19-1.el7.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID e52529d4: NOKEY Preparing... ################################# [100%] Updating / installing... 1:mongodb-org-shell-4.0.19-1.el7 ################################# [100%] [root@localhost mongo4.0.19]# rpm -ivh mongodb-org-mongos-4.0.19-1.el7.x86_64.rpm warning: mongodb-org-mongos-4.0.19-1.el7.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID e52529d4: NOKEY Preparing... ################################# [100%] Updating / installing... 1:mongodb-org-mongos-4.0.19-1.el7 ################################# [100%]
验证是否登录成功,验证mongo版本是否对
systemctl start mongod.service
systemctl status mongod.service
[root@localhost mongo4.0.19]# systemctl status mongod.service ● mongod.service - MongoDB Database Server Loaded: loaded (/usr/lib/systemd/system/mongod.service; enabled; vendor preset: disabled) Active: active (running) since Tue 2020-08-11 23:50:32 PDT; 2s ago Docs: https://docs.mongodb.org/manual Process: 35557 ExecStart=/usr/bin/mongod $OPTIONS (code=exited, status=0/SUCCESS) Process: 35555 ExecStartPre=/usr/bin/chmod 0755 /var/run/mongodb (code=exited, status=0/SUCCESS) Process: 35553 ExecStartPre=/usr/bin/chown mongod:mongod /var/run/mongodb (code=exited, status=0/SUCCESS) Process: 35547 ExecStartPre=/usr/bin/mkdir -p /var/run/mongodb (code=exited, status=0/SUCCESS) Main PID: 35560 (mongod) Tasks: 28 CGroup: /system.slice/mongod.service └─35560 /usr/bin/mongod -f /etc/mongod.conf Aug 11 23:50:32 localhost.localdomain systemd[1]: Starting MongoDB Database Server... Aug 11 23:50:32 localhost.localdomain mongod[35557]: about to fork child process, waiting until server is ready for connections. Aug 11 23:50:32 localhost.localdomain mongod[35557]: forked process: 35560 Aug 11 23:50:32 localhost.localdomain systemd[1]: Started MongoDB Database Server.
[root@localhost mongo4.0.19]# mongo MongoDB shell version v4.0.19 connecting to: mongodb://127.0.0.1:27017/?gssapiServiceName=mongodb Implicit session: session { "id" : UUID("47409e97-0f7f-4401-b0e3-e7228df13824") } MongoDB server version: 4.0.19 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 Server has startup warnings: 2020-08-11T23:50:32.980-0700 I CONTROL [initandlisten] 2020-08-11T23:50:32.980-0700 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database. 2020-08-11T23:50:32.980-0700 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted. 2020-08-11T23:50:32.980-0700 I CONTROL [initandlisten] 2020-08-11T23:50:32.981-0700 I CONTROL [initandlisten] 2020-08-11T23:50:32.981-0700 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'. 2020-08-11T23:50:32.981-0700 I CONTROL [initandlisten] ** We suggest setting it to 'never' 2020-08-11T23:50:32.981-0700 I CONTROL [initandlisten] 2020-08-11T23:50:32.981-0700 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'. 2020-08-11T23:50:32.981-0700 I CONTROL [initandlisten] ** We suggest setting it to 'never' 2020-08-11T23:50:32.981-0700 I CONTROL [initandlisten] --- Enable MongoDB's free cloud-based monitoring service, which will then receive and display metrics about your deployment (disk utilization, CPU, operation statistics, etc). The monitoring data will be available on a MongoDB website with a unique URL accessible to you and anyone you share the URL with. MongoDB may use this information to make product improvements and to suggest MongoDB products and deployment options to you. To enable free monitoring, run the following command: db.enableFreeMonitoring() To permanently disable this reminder, run the following command: db.disableFreeMonitoring() --- >