How to Install MongoDB 4.0 on CentOS/RHEL 7/6
MongoDB has released new stable version 4.0 with lots of major enhancements. This tutorial will help you to install MongoDB 4.0 on CentOS 7/6 and Red Hat 7/6 systems.
Step 1 – Add MongoDB Yum Repository
Add following content in yum repository configuration file mongodb.repo as per your required MongoDB version and system architecture. For this article, we are using MongoDB 4.0 repository.CentOS and RedHat systems Only
vi /etc/yum.repos.d/mongodb.repo
[MongoDB] name=MongoDB Repository baseurl=http://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/4.0/x86_64/ gpgcheck=0 enabled=1Fedora users can install it directory from its official yum repositories.
Step 2 – Install MongoDB Server
Let’s use the yum package manager to install mongodb-org package, it will automatically install all its dependencies. To install any specific revision of MongoDB specify package name with version like mongodb-org-4.0.0. The following command will install latest stable version available.yum install mongodb-org
Step 3 – Start MongoDB Service
Package mongodb-org-server provided MongoDB init script, Use that script to start service./etc/init.d/mongod restartConfigure MongoDB to autostart on system boot.
chkconfig mongod on
Step 4 – Check MongoDB Version
Use the following command to check installed MongoDB version[root@tecadmin ~]# mongod --version db version v4.0.0 git version: 3b07af3d4f471ae89e8186d33bbb1d5259597d51 OpenSSL version: OpenSSL 1.0.0-fips 29 Mar 2010 allocator: tcmalloc modules: none build environment: distmod: amazon distarch: x86_64 target_arch: x86_64Connect MongoDB using the command line and execute some test commands for checking proper working.
[root@tecadmin ~]# mongo > use mydb; > db.test.save( { a: 1 } ) > db.test.find() { "_id" : ObjectId("54fc2a4c71b56443ced99ba2"), "a" : 1 }Congratulation’s You have successfully installed mongodb server on your system. For practice only you may use MongoDB browser shell.
References:
http://docs.mongodb.org/manual/installation/
Comentários
Postar um comentário