-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmongoDb-Vps_config.txt
100 lines (54 loc) · 1.79 KB
/
mongoDb-Vps_config.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
MONGOURI=mongodb://admin:[email protected]:27017/qavahdb
vim /etc/yum.repos.d/mongodb-org-7.0.repo
[mongodb-org-7.0]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/9/mongodb-org/7.0/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://pgp.mongodb.com/server-7.0.asc
yum update -y
sudo yum install -y mongodb-org
sudo yum install -y mongodb-org-7.0.14 mongodb-org-database-7.0.14 mongodb-org-server-7.0.14 mongodb-mongosh-7.0.14 mongodb-org-mongos-7.0.14 mongodb-org-tools-7.0.14
systemctl start mongod
systemctl enable mongod
vim /etc/mongod.conf
bindIp: 0.0.0.0
systemctl restart mongod
firewall-cmd --add-port=27017/tcp --permanent
firewall-cmd --reload
mongosh
use admin
db.createUser({
user: "admin",
pwd: "12345",
roles: [{ role: "userAdminAnyDatabase", db: "admin" }, "readWriteAnyDatabase"]
})
db.auth("admin", "12345")
use qavahdb
db.createUser({
user: "admin",
pwd: "12345",
roles: ["readWrite"]
})
db.getUsers()
sudo firewall-cmd --get-active-zones
sudo firewall-cmd --zone=public --list-all
db.createUser({
user: "admin_qavah",
pwd: "0)9(8*7&6^5%4$3#2@1!",
roles: [{ role: "readWrite", db: "qavah_db" }],
mechanisms: [ "SCRAM-SHA-1", "SCRAM-SHA-256" ]
})
db.createUser({
user: "admin",
pwd: "1!2@3#4$5%6^7&8*9(0)",
roles: [
{ role: "userAdminAnyDatabase", db: "admin" },
{ role: "readWriteAnyDatabase", db: "admin" }
],
mechanisms: [ "SCRAM-SHA-1", "SCRAM-SHA-256" ]
})
MONGOURI=mongodb://admin_qavah:0)9(8*7%266%5E5%254%243%232%[email protected]:27017/qavah_db?authSource=qavah_db&authMechanism=SCRAM-SHA-1
mongosh --port 27017 --authenticationDatabase "admin" -u "qavah_user" -p
security:
authorization: enabled