-
Notifications
You must be signed in to change notification settings - Fork 1
/
centos8.txt
71 lines (46 loc) · 1.22 KB
/
centos8.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
dnf install openssl
sudo nano /etc/yum.repos.d/mongodb-org-4.2.repo
[mongodb-org-4.4]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/4.4/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-4.4.asc
Save the file (Ctrl+o) and exit (Ctrl+x).
sudo yum install -y mongodb-org
sudo yum install checkpolicy
sudo systemctl start mongod
sudo systemctl daemon-reload
sudo systemctl restart mongod
sudo systemctl enable mongod
sudo systemctl status mongod
=============================
mongo
use admin
db.createUser(
{
user: "vnapnic",
pwd: "123456",
roles: [ { role: "userAdminAnyDatabase", db: "admin" } ]
}
)
show users
quit()
===============================
sudo nano /lib/systemd/system/mongod.service
Find the following line:
Environment="OPTIONS=--f /etc/mongod.conf"
Add the --auth option as follows:
Environment="OPTIONS= --auth -f /etc/mongod.conf"
Save the file (Ctrl+o) and exit (Ctrl+x).
===================================
sudo systemctl daemon-reload
sudo systemctl restart mongod
=================================
mongo
use admin
show users
db.auth("vnapnic", "123456")
show users
================================
sudo netstat -plunt | grep mongo