Centos7 yum installation mongodb implementation steps detail
- 2021-01-19 22:31:26
- OfStack
Introduction to the
MongoDB characteristics
Packages package
The MongoDB official source contains the following dependency packages:
mongodb-org: MongoDB Metadata Package, which automatically installs the following 4 components:
1.mongodb-org-server: Contains the MongoDB daemon and associated configuration and initialization scripts. 2. mongodb-org-mongos: daemon containing mongos 3.mongodb-org-shell: Includes mongo shell. 4.mongodb-org-tools: Tools including MongoDB: mongoimport, bsondump, mongodump, mongoexport, mongofiles, mongooplog, mongoperf, mongorestore, mongostat, and mongotop.
Installation steps
1. Configure yum source for MongoDB
vim /etc/yum.repos.d/mongodb-org-3.4.repo
# Add the following:
[mongodb-org-3.4]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.4/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-3.4.asc
# I can change it here gpgcheck=0, save gpg validation [root@localhost ~]# yum makecache
2. Install MongoDB
Installation command:
yum -y install mongodb-org
Upon completion of installation
Installed:
mongodb-org.x86_64 0:3.4.14-1.el7
Installed as a dependency:
mongodb-org-mongos.x86_64 0:3.4.14-1.el7 mongodb-org-server.x86_64 0:3.4.14-1.el7
mongodb-org-shell.x86_64 0:3.4.14-1.el7 mongodb-org-tools.x86_64 0:3.4.14-1.el7
Finished!
[root@adminset yum.repos.d]#
View the mongo installation location:
whereis mongod
To view the modified configuration file:
vim /etc/mongod.conf
3. Start MongoDB
Start the mongodb:
systemctl start mongod.service
Stop mongodb:
systemctl stop mongod.service
Status of mongodb found:
systemctl status mongod.service
4. To access the external network, you need to close the firewall:
Close the firewall:
[
systemctl stop firewalld.service # Stop firewall
systemctl disable firewalld.service # Disallow firewall boot startup
5. Start Mongo shell
Command:
mongo
View the database:
show dbs
6. Set mongodb remote access:
Edit mongod.conf comment bindIp and restart mongodb.
vim /etc/mongod.conf
Restart mongodb for the changes to take effect:
mongodb-org.x86_64 0:3.4.14-1.el7
0