安装方式:
RPM包安装
安装步骤:
一.下载RPM包
下图是需要注意的事项。其一选择MongoDB的社区版本,默认是企业版本。其二,选中版本后,在下方会出现下载地址,直接复制下载即可
二.安装并查看是否安装成功
[root@localhost ~]# rpm -ivh https://repo.mongodb.org/yum/redhat/7/mongodb-org/4.2/x86_64/RPMS/mongodb-org-server-4.2.1-1.el7.x86_64.rpm Retrieving https://repo.mongodb.org/yum/redhat/7/mongodb-org/4.2/x86_64/RPMS/mongodb-org-server-4.2.1-1.el7.x86_64.rpm #正常来说,会出现两个百分号才是正常的 warning: /var/tmp/rpm-tmp.dkH44i: Header V3 RSA/SHA1 Signature, key ID 058f8b6b: NOKEY Preparing... ################################# [100%] Updating / installing... 1:mongodb-org-server-4.2.1-1.el7 ################################# [100%] Created symlink from /etc/systemd/system/multi-user.target.wants/mongod.service to /usr/lib/systemd/system/mongod.service. [root@localhost ~]# systemctl status mongod #能够在systemctl中识别到这个服务,即安装成功 ● mongod.service - MongoDB Database Server Loaded: loaded (/usr/lib/systemd/system/mongod.service; enabled; vendor preset: disabled) Active: inactive (dead) Docs: https://docs.mongodb.org/manual Nov 10 21:15:19 localhost.localdomain systemd[1]: [/usr/lib/systemd/system/mongod.service:31] Unknown lvalue 'TasksMax' in section 'Service' Nov 10 21:15:19 localhost.localdomain systemd[1]: [/usr/lib/systemd/system/mongod.service:32] Unknown lvalue 'TasksAccounting' in s...ervice' Nov 10 21:15:19 localhost.localdomain systemd[1]: [/usr/lib/systemd/system/mongod.service:31] Unknown lvalue 'TasksMax' in section 'Service' Nov 10 21:15:19 localhost.localdomain systemd[1]: [/usr/lib/systemd/system/mongod.service:32] Unknown lvalue 'TasksAccounting' in s...ervice' Hint: Some lines were ellipsized, use -l to show in full. [root@localhost ~]#
三.启动MongoDB
[root@localhost ~]# systemctl start mongod [root@localhost ~]# systemctl status mongod ● mongod.service - MongoDB Database Server Loaded: loaded (/usr/lib/systemd/system/mongod.service; enabled; vendor preset: disabled) Active: active (running) since Sun 2019-11-10 21:17:24 EST; 24s ago Docs: https://docs.mongodb.org/manual Process: 21989 ExecStart=/usr/bin/mongod $OPTIONS (code=exited, status=0/SUCCESS) Process: 21986 ExecStartPre=/usr/bin/chmod 0755 /var/run/mongodb (code=exited, status=0/SUCCESS) Process: 21983 ExecStartPre=/usr/bin/chown mongod:mongod /var/run/mongodb (code=exited, status=0/SUCCESS) Process: 21981 ExecStartPre=/usr/bin/mkdir -p /var/run/mongodb (code=exited, status=0/SUCCESS) Main PID: 21992 (mongod) CGroup: /system.slice/mongod.service └─21992 /usr/bin/mongod -f /etc/mongod.conf Nov 10 21:17:22 localhost.localdomain systemd[1]: Starting MongoDB Database Server... Nov 10 21:17:22 localhost.localdomain mongod[21989]: about to fork child process, waiting until server is ready for connections. Nov 10 21:17:22 localhost.localdomain mongod[21989]: forked process: 21992 Nov 10 21:17:24 localhost.localdomain systemd[1]: Started MongoDB Database Server.
建议shell和tools也一块安装