[root@sentos yum.repos.d]# touch /etc/yum.repos.d/mongodb-org-4.2.repo[root@sentos yum.repos.d]# vi /etc/yum.repos.d/mongodb-org-4.2.repo[root@sentos yum.repos.d]# cat /etc/yum.repos.d/mongodb-org-4.2.repo[mongodb-org-4.2]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/4.2/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-4.2.asc
[root@sentos ~]# sudo yum install -y mongodb-org-4.2.5 mongodb-org-server-4.2.5 mongodb-org-shell-4.2.5 mongodb-org-mongos-4.2.5 mongodb-org-tools-4.2.5
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
http://mirrors.njupt.edu.cn/centos/7.7.1908/os/x86_64/repodata/repomd.xml: [Errno 14] curl#56 - "Recv failure: Connection reset by peer"
Trying other mirror.
base | 3.6 kB 00:00:00
extras | 2.9 kB 00:00:00
mongodb-org-4.2 | 2.5 kB 00:00:00
updates | 2.9 kB 00:00:00
Resolving Dependencies
--> Running transaction check
---> Package mongodb-org.x86_64 0:4.2.5-1.el7 will be installed
---> Package mongodb-org-mongos.x86_64 0:4.2.5-1.el7 will be installed
---> Package mongodb-org-server.x86_64 0:4.2.5-1.el7 will be installed
---> Package mongodb-org-shell.x86_64 0:4.2.5-1.el7 will be installed
---> Package mongodb-org-tools.x86_64 0:4.2.5-1.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
=============================================================================================================================================================================================
Package Arch Version Repository Size
=============================================================================================================================================================================================
Installing:
mongodb-org x86_64 4.2.5-1.el7 mongodb-org-4.2 5.8 k
mongodb-org-mongos x86_64 4.2.5-1.el7 mongodb-org-4.2 14 M
mongodb-org-server x86_64 4.2.5-1.el7 mongodb-org-4.2 25 M
mongodb-org-shell x86_64 4.2.5-1.el7 mongodb-org-4.2 17 M
mongodb-org-tools x86_64 4.2.5-1.el7 mongodb-org-4.2 62 M
Transaction Summary
=============================================================================================================================================================================================
Install 5 Packages
Total size: 119 M
Total download size: 119 M
Installed size: 283 M
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
warning: /var/cache/yum/x86_64/7/mongodb-org-4.2/packages/mongodb-org-mongos-4.2.5-1.el7.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID 058f8b6b: NOKEY ] 2.5 MB/s | 26 MB 00:00:37 ETA
Public key for mongodb-org-mongos-4.2.5-1.el7.x86_64.rpm is not installed
(1/4): mongodb-org-mongos-4.2.5-1.el7.x86_64.rpm | 14 MB 00:00:01
(2/4): mongodb-org-shell-4.2.5-1.el7.x86_64.rpm | 17 MB 00:00:01
(3/4): mongodb-org-server-4.2.5-1.el7.x86_64.rpm | 25 MB 00:01:51
(4/4): mongodb-org-tools-4.2.5-1.el7.x86_64.rpm | 62 MB 00:02:31
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 788 kB/s | 119 MB 00:02:34
Retrieving key from https://www.mongodb.org/static/pgp/server-4.2.asc
Importing GPG key 0x058F8B6B:
Userid : "MongoDB 4.2 Release Signing Key <packaging@mongodb.com>"
Fingerprint: e162 f504 a20c df15 827f 718d 4b7c 549a 058f 8b6b
From : https://www.mongodb.org/static/pgp/server-4.2.asc
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : mongodb-org-tools-4.2.5-1.el7.x86_64 1/5
Installing : mongodb-org-mongos-4.2.5-1.el7.x86_64 2/5
Installing : mongodb-org-shell-4.2.5-1.el7.x86_64 3/5
Installing : mongodb-org-server-4.2.5-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.
Installing : mongodb-org-4.2.5-1.el7.x86_64 5/5
Verifying : mongodb-org-server-4.2.5-1.el7.x86_64 1/5
Verifying : mongodb-org-4.2.5-1.el7.x86_64 2/5
Verifying : mongodb-org-shell-4.2.5-1.el7.x86_64 3/5
Verifying : mongodb-org-mongos-4.2.5-1.el7.x86_64 4/5
Verifying : mongodb-org-tools-4.2.5-1.el7.x86_64 5/5
Installed:
mongodb-org.x86_64 0:4.2.5-1.el7 mongodb-org-mongos.x86_64 0:4.2.5-1.el7 mongodb-org-server.x86_64 0:4.2.5-1.el7 mongodb-org-shell.x86_64 0:4.2.5-1.el7
mongodb-org-tools.x86_64 0:4.2.5-1.el7
Complete![root@sentos mongodb]# vi /etc/yum.conf[root@sentos mongodb]# cat /etc/yum.conf[main]
cachedir=/var/cache/yum/$basearch/$releasever
keepcache=0
debuglevel=2
logfile=/var/log/yum.log
exactarch=1
obsoletes=1
gpgcheck=1
plugins=1
installonly_limit=5
bugtracker_url=http://bugs.centos.org/set_project.php?project_id=23&ref=http://bugs.centos.org/bug_report_page.php?category=yum
distroverpkg=centos-release
exclude=mongodb-org,mongodb-org-server,mongodb-org-shell,mongodb-org-mongos,mongodb-org-tools
# This is the default, if you make this bigger yum won't see if the metadata# is newer on the remote and so you'll "gain" the bandwidth of not having to# download the new metadata and "pay" for it by yum not having correct# information.# It is esp. important, to have correct metadata, for distributions like# Fedora which don't keep old packages around. If you don't like this checking# interupting your command line usage, it's much better to have something# manually check the metadata once an hour (yum-updatesd will do this).# metadata_expire=90m# PUT YOUR REPOS HERE OR IN separate files named file.repo# in /etc/yum.repos.d[root@sentos mongodb]# ps -ef|grep mongod
root 45654 43886 0 07:18 pts/0 00:00:00 grep --color=auto mongodb
[root@sentos mongodb]# whereis mongod.conf
mongod: /usr/bin/mongod /etc/mongod.conf /usr/share/man/man1/mongod.1
[root@sentos mongodb]# vi /etc/mongod.conf[root@sentos mongodb]# cat /etc/mongod.conf# mongod.conf# for documentation of all options, see:# http://docs.mongodb.org/manual/reference/configuration-options/# where to write logging data.
systemLog:
destination: file
logAppend: true
path: /var/log/mongodb/mongod.log
# Where and how to store data.
storage:
dbPath: /var/lib/mongo
journal:
enabled: true
# engine:# wiredTiger:# how the process runs
processManagement:
fork: true # fork and run in background
pidFilePath: /var/run/mongodb/mongod.pid # location of pidfile
timeZoneInfo: /usr/share/zoneinfo
# network interfaces
net:
port: 27017
bindIp: 0.0.0.0 # Enter 0.0.0.0,:: to bind to all IPv4 and IPv6 addresses or, alternatively, use the net.bindIpAll setting.#security:#operationProfiling:#replication:#sharding:## Enterprise-Only Options#auditLog:#snmp:[root@sentos mongodb]# sudo service mongod restart
Redirecting to /bin/systemctl restart mongod.service
[root@sentos mongodb]# sudo chkconfig mongod on
Note: Forwarding request to 'systemctl enable mongod.service'.[root@sentos mongodb]# ps -ef|grep mongod
mongod 46611 1 2 07:37 ? 00:00:01 /usr/bin/mongod -f /etc/mongod.conf
root 46703 43886 0 07:37 pts/0 00:00:00 grep --color=auto mongod
[root@sentos mongodb]# mongo
MongoDB shell version v4.2.5
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
Implicit session: session {"id" : UUID("e5462537-5730-4414-b60d-41dfa112f062")}
MongoDB server version: 4.2.5
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-04-19T07:37:08.395+0800 I CONTROL [initandlisten]
2020-04-19T07:37:08.395+0800 I CONTROL [initandlisten]** WARNING: Access control is not enabled for the database.
2020-04-19T07:37:08.395+0800 I CONTROL [initandlisten]** Read and write access to data and configuration is unrestricted.
2020-04-19T07:37:08.395+0800 I CONTROL [initandlisten]
2020-04-19T07:37:08.395+0800 I CONTROL [initandlisten]
2020-04-19T07:37:08.395+0800 I CONTROL [initandlisten]** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
2020-04-19T07:37:08.395+0800 I CONTROL [initandlisten]** We suggest setting it to 'never'
2020-04-19T07:37:08.405+0800 I CONTROL [initandlisten]
2020-04-19T07:37:08.405+0800 I CONTROL [initandlisten]** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2020-04-19T07:37:08.405+0800 I CONTROL [initandlisten]** We suggest setting it to 'never'
2020-04-19T07:37:08.405+0800 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()---
> ^C
bye
[root@sentos mongodb]# firewall-cmd --list-ports
8080/tcp 3306/tcp 80/tcp 6379/tcp 8081/tcp
[root@sentos mongodb]# firewall-cmd --zone=public --add-port=27017/tcp --permanent
success
[root@sentos mongodb]# firewall-cmd --reload
success
[root@sentos mongodb]# firewall-cmd --list-ports
8080/tcp 3306/tcp 80/tcp 6379/tcp 8081/tcp 27017/tcp