CentOS 7下用yum快速安装MongoDB的方法教程
程序员文章站
2022-06-25 09:47:00
前言
mongodb 是一个介于关系数据库和非关系数据库之间的产品,是非关系数据库当中功能最丰富,最像关系数据库的。mongodb是深受广大开源爱好者支持和研究的nosq...
前言
mongodb 是一个介于关系数据库和非关系数据库之间的产品,是非关系数据库当中功能最丰富,最像关系数据库的。mongodb是深受广大开源爱好者支持和研究的nosql数据库之一,它基于灵活的json文档方式,非常适合敏捷开发,其高可用功能强大,支持水平扩展等众多关键特性。一如其简约而不简单的mysql一样,安装起来也非常方便,支持源码编译安装,rpm安装以及yum安装等众多方式。本文主要讲述在centos 7下用yum方式快速安装mongodb的方法,下面来一起看看吧。
一、安装环境及配置yum
# more /etc/redhat-release centos linux release 7.2.1511 (core) # 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 -y install mongodb-org loaded plugins: fastestmirror, langpacks base | 3.6 kb 00:00:00 epel/x86_64/metalink | 5.2 kb 00:00:00 extras | 3.4 kb 00:00:00 mongodb-org-3.2 | 2.5 kb 00:00:00 updates | 3.4 kb 00:00:00 mongodb-org-3.2/7/primary_db | 50 kb 00:00:03 loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * epel: mirrors.tuna.tsinghua.edu.cn * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com resolving dependencies --> running transaction check ---> package mongodb-org.x86_64 0:3.2.10-1.el7 will be installed --> processing dependency: mongodb-org-tools = 3.2.10 for package: mongodb-org-3.2.10-1.el7.x86_64 --> processing dependency: mongodb-org-shell = 3.2.10 for package: mongodb-org-3.2.10-1.el7.x86_64 --> processing dependency: mongodb-org-server = 3.2.10 for package: mongodb-org-3.2.10-1.el7.x86_64 --> processing dependency: mongodb-org-mongos = 3.2.10 for package: mongodb-org-3.2.10-1.el7.x86_64 --> running transaction check ---> package mongodb-org-mongos.x86_64 0:3.2.10-1.el7 will be installed ---> package mongodb-org-server.x86_64 0:3.2.10-1.el7 will be installed ---> package mongodb-org-shell.x86_64 0:3.2.10-1.el7 will be installed ---> package mongodb-org-tools.x86_64 0:3.2.10-1.el7 will be installed --> finished dependency resolution dependencies resolved =================================================================================================== package arch version repository size =================================================================================================== installing: mongodb-org x86_64 3.2.10-1.el7 mongodb-org-3.2 5.8 k installing for dependencies: mongodb-org-mongos x86_64 3.2.10-1.el7 mongodb-org-3.2 5.6 m mongodb-org-server x86_64 3.2.10-1.el7 mongodb-org-3.2 12 m mongodb-org-shell x86_64 3.2.10-1.el7 mongodb-org-3.2 6.7 m mongodb-org-tools x86_64 3.2.10-1.el7 mongodb-org-3.2 41 m transaction summary =================================================================================================== install 1 package (+4 dependent packages) total download size: 65 m installed size: 201 m downloading packages: warning: /var/cache/yum/x86_64/7/mongodb-org-3.2/packages/mongodb-org-3.2.10-1.el7.x86_64.rpm: header v3 rsa/sha1 signature, key id ea312927: nokey ] public key for mongodb-org-3.2.10-1.el7.x86_64.rpm is not installed (1/5): mongodb-org-3.2.10-1.el7.x86_64.rpm | 5.8 kb 00:00:04 (2/5): mongodb-org-server-3.2.10-1.el7.x86_64.rpm | 12 mb 00:00:11 (3/5): mongodb-org-shell-3.2.10-1.el7.x86_64.rpm | 6.7 mb 00:00:06 (4/5): mongodb-org-tools-3.2.10-1.el7.x86_64.rpm | 41 mb 00:00:36 (5/5): mongodb-org-mongos-3.2.10-1.el7.x86_64.rpm | 5.6 mb 00:03:28 --------------------------------------------------------------------------------------------------- total 322 kb/s | 65 mb 00:03:28 retrieving key from https://www.mongodb.org/static/pgp/server-3.2.asc importing gpg key 0xea312927: userid : "mongodb 3.2 release signing key <packaging@mongodb.com>" fingerprint: 42f3 e95a 2c4f 0827 9c49 60ad d68f a50f ea31 2927 from : https://www.mongodb.org/static/pgp/server-3.2.asc running transaction check running transaction test transaction test succeeded running transaction installing : mongodb-org-tools-3.2.10-1.el7.x86_64 1/5 installing : mongodb-org-mongos-3.2.10-1.el7.x86_64 2/5 installing : mongodb-org-shell-3.2.10-1.el7.x86_64 3/5 installing : mongodb-org-server-3.2.10-1.el7.x86_64 4/5 installing : mongodb-org-3.2.10-1.el7.x86_64 5/5 verifying : mongodb-org-server-3.2.10-1.el7.x86_64 1/5 verifying : mongodb-org-3.2.10-1.el7.x86_64 2/5 verifying : mongodb-org-shell-3.2.10-1.el7.x86_64 3/5 verifying : mongodb-org-mongos-3.2.10-1.el7.x86_64 4/5 verifying : mongodb-org-tools-3.2.10-1.el7.x86_64 5/5 installed: mongodb-org.x86_64 0:3.2.10-1.el7 dependency installed: mongodb-org-mongos.x86_64 0:3.2.10-1.el7 #author : leshami mongodb-org-server.x86_64 0:3.2.10-1.el7 #blog : http://blog.csdn.net/leshami mongodb-org-shell.x86_64 0:3.2.10-1.el7 mongodb-org-tools.x86_64 0:3.2.10-1.el7 complete!
三、验证安装结果
# rpm -qa |grep mongodb mongodb-org-3.2.10-1.el7.x86_64 mongodb-org-mongos-3.2.10-1.el7.x86_64 mongodb-org-shell-3.2.10-1.el7.x86_64 mongodb-org-server-3.2.10-1.el7.x86_64 mongodb-org-tools-3.2.10-1.el7.x86_64 # rpm -ql mongodb-org-server /etc/init.d/mongod /etc/mongod.conf /etc/sysconfig/mongod /usr/bin/mongod /usr/share/doc/mongodb-org-server-3.2.10 /usr/share/doc/mongodb-org-server-3.2.10/gnu-agpl-3.0 /usr/share/doc/mongodb-org-server-3.2.10/mpl-2 /usr/share/doc/mongodb-org-server-3.2.10/readme /usr/share/doc/mongodb-org-server-3.2.10/third-party-notices /usr/share/man/man1/mongod.1 /var/lib/mongo /var/log/mongodb /var/log/mongodb/mongod.log /var/run/mongodb [root@localhost ~]# /etc/init.d/mongod start starting mongod (via systemctl): [ ok ] [root@localhost ~]# netstat -nltp|grep mongo tcp 0 0 127.0.0.1:27017 0.0.0.0:* listen 89958/mongod # mongo mongodb shell version: 3.2.10 connecting to: 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 > db.version() 3.2.10
总结
以上就是关于在centos 7系统下利用yum方式快速安装mongodb的方法,希望本文的内容对大家的学习或者工作能带来一定的帮助,如果有疑问大家可以留言交流。