-
Notifications
You must be signed in to change notification settings - Fork 0
/
ops_manager_install.sh
executable file
·200 lines (135 loc) · 4.78 KB
/
ops_manager_install.sh
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
#!/bin/bash
# Baisc pkg
sudo yum install -y wget
# Install Mongo for appDB
cat <<EOF | sudo tee /etc/yum.repos.d/mongodb-org-6.0.repo
[mongodb-org-6.0]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/amazon/2/mongodb-org/6.0/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-6.0.asc
EOF
sudo yum install -y mongodb-org mongodb-mongosh
# Configure appDB
sudo mkdir -p /data/appdb/node{1,2,3}/{conf,logs,db}
cat <<ENDCONF | sudo tee /data/appdb/node1/conf/mongod.conf
# mongod.conf
# for documentation of all options, see:
# http://docs.mongodb.org/manual/reference/configuration-options/
systemLog:
destination: file
logAppend: true
path: /data/appdb/node1/logs/mongod.log
# Where and how to store data.
storage:
dbPath: /data/appdb/node1/db/
journal:
enabled: true
processManagement:
fork: true # fork and run in background
pidFilePath: /data/appdb/node1/mongod.pid # location of pidfile
timeZoneInfo: /usr/share/zoneinfo
net:
port: 27017
bindIp: 0.0.0.0
bindIpAll: true
replication:
replSetName: mgappdb
ENDCONF
cat <<ENDCONF | sudo tee /data/appdb/node2/conf/mongod.conf
# mongod.conf
# for documentation of all options, see:
# http://docs.mongodb.org/manual/reference/configuration-options/
systemLog:
destination: file
logAppend: true
path: /data/appdb/node2/logs/mongod.log
# Where and how to store data.
storage:
dbPath: /data/appdb/node2/db/
journal:
enabled: true
processManagement:
fork: true # fork and run in background
pidFilePath: /data/appdb/node2/mongod.pid # location of pidfile
timeZoneInfo: /usr/share/zoneinfo
net:
port: 27018
bindIp: 0.0.0.0
bindIpAll: true
replication:
replSetName: mgappdb
ENDCONF
cat <<ENDCONF | sudo tee /data/appdb/node3/conf/mongod.conf
# mongod.conf
# for documentation of all options, see:
# http://docs.mongodb.org/manual/reference/configuration-options/
systemLog:
destination: file
logAppend: true
path: /data/appdb/node3/logs/mongod.log
# Where and how to store data.
storage:
dbPath: /data/appdb/node3/db/
journal:
enabled: true
processManagement:
fork: true # fork and run in background
pidFilePath: /data/appdb/node3/mongod.pid # location of pidfile
timeZoneInfo: /usr/share/zoneinfo
net:
port: 27019
bindIp: 0.0.0.0
bindIpAll: true
replication:
replSetName: mgappdb
ENDCONF
sudo useradd mongod
#sudo groupadd mongod
#sudo usermod -aG mongod mongod
sudo chown -R mongod:mongod /data
sudo -u mongod mongod -f /data/appdb/node1/conf/mongod.conf
sudo -u mongod mongod -f /data/appdb/node2/conf/mongod.conf
sudo -u mongod mongod -f /data/appdb/node3/conf/mongod.conf
sleep 10
mongosh --quiet --eval "rs.initiate({_id: \"mgappdb\", version: 1, members: [{ _id: 0, host : \"localhost:27017\" },{ _id: 1, host : \"localhost:27018\" },{ _id: 2, host : \"localhost:27019\" }]})"
sleep 15
mongosh "mongodb://127.0.0.1:27017/admin" --quiet --eval "db.createUser({user:'root', pwd:'opsmanager', roles:[{db:'admin',role:'root'}]})"
# mongosh "mongodb://root:opsmanager@127.0.0.1:27017/admin"
mongosh -u root -p opsmanager --eval "db.createUser({ user: 'opsManager', pwd: 'passwordone', roles: [ { role: 'readWriteAnyDatabase', db: 'admin' }, { role: 'dbAdminAnyDatabase', db: 'admin' }, { role: 'clusterAdmin', db: 'admin' }, { role: 'clusterMonitor', db: 'admin' } ]})" admin
# install opsmanager
wget https://downloads.mongodb.com/on-prem-mms/rpm/mongodb-mms-6.0.7.100.20221129T1435Z.x86_64.rpm
sudo rpm -ivh mongodb-mms-6.0.7.100.20221129T1435Z.x86_64.rpm
cat << ENDCONF | sudo tee /opt/mongodb/mms/conf/conf-mms.properties
mongo.mongoUri=mongodb://opsManager:passwordone@127.0.0.1:27017,127.0.0.1:27018,127.0.0.1:27019/?maxPoolSize=150&retryWrites=false&retryReads=false
mongo.encryptedCredentials=false
mongo.ssl=false
ENDCONF
sudo setenforce 0
sudo systemctl stop firewalld
sudo systemctl start mongodb-mms.service
# 定义待查找的文本
SEARCH_TEXT1="Successfully finished pre-flight checks"
SEARCH_TEXT2="Started mms"
while true; do
if sudo grep -q "$SEARCH_TEXT1" /var/log/messages; then
echo "Found '$SEARCH_TEXT1' in /var/log/messages"
break
fi
echo "Wait '$SEARCH_TEXT1' in /var/log/messages"
sleep 5
done
while true; do
if sudo grep -q "$SEARCH_TEXT2" /opt/mongodb/mms/logs/mms0.log; then
echo "Found '$SEARCH_TEXT2' in /opt/mongodb/mms/logs/mms0.log"
break
fi
echo "Wait '$SEARCH_TEXT2' in /opt/mongodb/mms/logs/mms0.log"
sleep 5
done
echo "app-mms started ok!"
echo "1. need to configure AWS EC2 Security to add network permission to 8080"
echo "2. use ip to configure ops manager in chrome"
echo "3. install agent & active monitor and backup"
echo "4. install rpm depency, https://www.mongodb.com/docs/ops-manager/current/tutorial/provisioning-prep/index.html#installing-mongodb-enterprise-dependencies"