-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsetup_machine.bash
executable file
·280 lines (239 loc) · 11.4 KB
/
setup_machine.bash
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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
echo "----------------Load environment variables----------------"
. ./yb/configfile.bash
echo "----------------Prepare data drives--------------------"
for ip in $ALL_NODES; do \
echo =======$ip=======; \
ssh -i $PEM $ADMIN_USER@$ip lsblk; \
done
for ip in $ALL_NODES; do \
echo =======$ip=======; \
ssh -i $PEM $ADMIN_USER@$ip sudo umount /mnt/d0;
ssh -i $PEM $ADMIN_USER@$ip sudo /sbin/mkfs.xfs /dev/nvme1n1 -f; \
done
for ip in $ALL_NODES; do \
echo =======$ip=======; \
ssh -i $PEM $ADMIN_USER@$ip sudo /sbin/blkid -o value -s TYPE -c /dev/null /dev/nvme1n1; \
done
echo "----------------Configure Drives--------------------"
for ip in $ALL_NODES; do \
echo =======$ip=======; \
ssh -i $PEM $ADMIN_USER@$ip \
sudo "echo '/dev/nvme1n1 /mnt/d0 xfs defaults,noatime,nofail,allocsize=4m 0 2' | sudo tee -a /etc/fstab"; \
done
for ip in $ALL_NODES; do \
echo =======$ip=======; \
ssh -i $PEM $ADMIN_USER@$ip cat /etc/fstab | grep xfs; \
done
echo "----------------Mount Drives--------------------"
for ip in $ALL_NODES; do \
echo =======$ip=======; \
ssh -i $PEM $ADMIN_USER@$ip sudo mkdir -p /mnt/d0; \
ssh -i $PEM $ADMIN_USER@$ip sudo mount /mnt/d0; \
ssh -i $PEM $ADMIN_USER@$ip sudo chmod 777 /mnt/d0; \
done
for ip in $ALL_NODES; do \
echo =======$ip=======; \
ssh -i $PEM $ADMIN_USER@$ip df -kh | grep mnt; \
done
echo "----------------Verify system configuration--------------------"
echo "---Install various packages like ntp, iostats, netstat etc---"
for ip in $ALL_NODES; do \
echo =======$ip=======; \
ssh -i $PEM $ADMIN_USER@$ip sudo yum install -y epel-release ntp; \
done
for ip in $ALL_NODES; do \
echo =======$ip=======; \
ssh -i $PEM $ADMIN_USER@$ip sudo yum install -y perf sysstat net-tools links; \
done
echo "----------------Set ulimits--------------------"
for ip in $ALL_NODES; do \
echo =======$ip=======; \
ssh -i $PEM $ADMIN_USER@$ip sudo "echo '* - core unlimited' | sudo tee -a /etc/security/limits.conf"; \
ssh -i $PEM $ADMIN_USER@$ip sudo "echo '* - nofile 1048576' | sudo tee -a /etc/security/limits.conf"; \
ssh -i $PEM $ADMIN_USER@$ip sudo "echo '* - nproc 12000' | sudo tee -a /etc/security/limits.conf"; \
done
for ip in $ALL_NODES; do \
echo =======$ip=======; \
ssh -i $PEM $ADMIN_USER@$ip sudo "echo '* - nproc 12000' | sudo tee -a /etc/security/limits.d/20-nproc.conf"; \
done
for ip in $ALL_NODES; do \
echo =======$ip=======; \
ssh -i $PEM $ADMIN_USER@$ip ulimit -n -u -c; \
done
echo "---------------- Install YugabyteDB --------------------"
for ip in $ALL_NODES; do \
echo =======$ip=======; \
ssh -i $PEM $ADMIN_USER@$ip mkdir -p ~/yb-software; \
ssh -i $PEM $ADMIN_USER@$ip mkdir -p ~/yb-conf; \
done
for ip in $ALL_NODES; do \
echo =======$ip=======; \
ssh -i $PEM $ADMIN_USER@$ip \
"cd ~/yb-software; \
curl -k -o yugabyte-${YB_VERSION}-linux.tar.gz \
https://downloads.yugabyte.com/yugabyte-${YB_VERSION}-linux.tar.gz"; \
ssh -i $PEM $ADMIN_USER@$ip \
"cd ~/yb-software; \
tar xvfz yugabyte-${YB_VERSION}-linux.tar.gz"; \
ssh -i $PEM $ADMIN_USER@$ip \
"cd ~/yb-software/yugabyte-${YB_VERSION}; \
./bin/post_install.sh"; \
done
echo "---------------- Create ~/master & ~/tserver directories as symlinks -----------------"
for ip in $MASTER_NODES; do \
echo =======$ip=======; \
ssh -i $PEM $ADMIN_USER@$ip \
"ln -s ~/yb-software/yugabyte-${YB_VERSION} ~/master"; \
done
for ip in $ALL_NODES; do \
echo =======$ip=======; \
ssh -i $PEM $ADMIN_USER@$ip \
"ln -s ~/yb-software/yugabyte-${YB_VERSION} ~/tserver"; \
done
echo "---------------- Create YB-Master1 configuration file -----------------"
(MASTER=$MASTER1; CLOUD=aws; REGION=ap-south-1; AZ=ap-south-1a; CONFIG_FILE=~/yb-conf/master.conf ;\
ssh -i $PEM $ADMIN_USER@$MASTER "
echo --master_addresses=$MASTER_RPC_ADDRS > $CONFIG_FILE
echo --fs_data_dirs=$DATA_DIRS >> $CONFIG_FILE
echo --rpc_bind_addresses=$MASTER:7100 >> $CONFIG_FILE
echo --webserver_interface=$MASTER >> $CONFIG_FILE
echo --placement_cloud=$CLOUD >> $CONFIG_FILE
echo --placement_region=$REGION >> $CONFIG_FILE
echo --placement_zone=$AZ >> $CONFIG_FILE
"
);
echo "---------------- Create YB-Master2 configuration file -----------------"
(MASTER=$MASTER2; CLOUD=aws; REGION=ap-south-1; AZ=ap-south-1b; CONFIG_FILE=~/yb-conf/master.conf ;\
ssh -i $PEM $ADMIN_USER@$MASTER "
echo --master_addresses=$MASTER_RPC_ADDRS > $CONFIG_FILE
echo --fs_data_dirs=$DATA_DIRS >> $CONFIG_FILE
echo --rpc_bind_addresses=$MASTER:7100 >> $CONFIG_FILE
echo --webserver_interface=$MASTER >> $CONFIG_FILE
echo --placement_cloud=$CLOUD >> $CONFIG_FILE
echo --placement_region=$REGION >> $CONFIG_FILE
echo --placement_zone=$AZ >> $CONFIG_FILE
"
);
echo "---------------- Create YB-Master3 configuration file -----------------"
(MASTER=$MASTER3; CLOUD=aws; REGION=ap-south-1; AZ=ap-south-1b; CONFIG_FILE=~/yb-conf/master.conf ;\
ssh -i $PEM $ADMIN_USER@$MASTER "
echo --master_addresses=$MASTER_RPC_ADDRS > $CONFIG_FILE
echo --fs_data_dirs=$DATA_DIRS >> $CONFIG_FILE
echo --rpc_bind_addresses=$MASTER:7100 >> $CONFIG_FILE
echo --webserver_interface=$MASTER >> $CONFIG_FILE
echo --placement_cloud=$CLOUD >> $CONFIG_FILE
echo --placement_region=$REGION >> $CONFIG_FILE
echo --placement_zone=$AZ >> $CONFIG_FILE
"
);
echo "---------------- Verify Master configuration files -----------------"
for ip in $MASTER_NODES; do \
echo =======$ip=======; \
ssh -i $PEM $ADMIN_USER@$ip cat ~/yb-conf/master.conf; \
done
(CLOUD=aws; REGION=ap-south-1; AZ=ap-south-1a; CONFIG_FILE=~/yb-conf/tserver.conf; \
for ip in $AZ1_NODES; do \
echo =======$ip=======; \
ssh -i $PEM $ADMIN_USER@$ip "
echo --tserver_master_addrs=$MASTER_RPC_ADDRS > $CONFIG_FILE
echo --fs_data_dirs=$DATA_DIRS >> $CONFIG_FILE
echo --rpc_bind_addresses=$ip:9100 >> $CONFIG_FILE
echo --cql_proxy_bind_address=$ip:9042 >> $CONFIG_FILE
echo --redis_proxy_bind_address=$ip:6379 >> $CONFIG_FILE
echo --webserver_interface=$ip >> $CONFIG_FILE
echo --placement_cloud=$CLOUD >> $CONFIG_FILE
echo --placement_region=$REGION >> $CONFIG_FILE
echo --placement_zone=$AZ >> $CONFIG_FILE
echo --pgsql_proxy_bind_address=$ip:5433 >> $CONFIG_FILE
"
done
);
(CLOUD=aws; REGION=ap-south-1; AZ=ap-south-1b; CONFIG_FILE=~/yb-conf/tserver.conf; \
for ip in $AZ2_NODES; do \
echo =======$ip=======; \
ssh -i $PEM $ADMIN_USER@$ip "
echo --tserver_master_addrs=$MASTER_RPC_ADDRS > $CONFIG_FILE
echo --fs_data_dirs=$DATA_DIRS >> $CONFIG_FILE
echo --rpc_bind_addresses=$ip:9100 >> $CONFIG_FILE
echo --cql_proxy_bind_address=$ip:9042 >> $CONFIG_FILE
echo --redis_proxy_bind_address=$ip:6379 >> $CONFIG_FILE
echo --webserver_interface=$ip >> $CONFIG_FILE
echo --placement_cloud=$CLOUD >> $CONFIG_FILE
echo --placement_region=$REGION >> $CONFIG_FILE
echo --placement_zone=$AZ >> $CONFIG_FILE
echo --pgsql_proxy_bind_address=$ip:5433 >> $CONFIG_FILE
"
done
);
(CLOUD=aws; REGION=ap-south-1; AZ=ap-south-1b; CONFIG_FILE=~/yb-conf/tserver.conf; \
for ip in $AZ3_NODES; do \
echo =======$ip=======; \
ssh -i $PEM $ADMIN_USER@$ip "
echo --tserver_master_addrs=$MASTER_RPC_ADDRS > $CONFIG_FILE
echo --fs_data_dirs=$DATA_DIRS >> $CONFIG_FILE
echo --rpc_bind_addresses=$ip:9100 >> $CONFIG_FILE
echo --cql_proxy_bind_address=$ip:9042 >> $CONFIG_FILE
echo --redis_proxy_bind_address=$ip:6379 >> $CONFIG_FILE
echo --webserver_interface=$ip >> $CONFIG_FILE
echo --placement_cloud=$CLOUD >> $CONFIG_FILE
echo --placement_region=$REGION >> $CONFIG_FILE
echo --placement_zone=$AZ >> $CONFIG_FILE
echo --pgsql_proxy_bind_address=$ip:5433 >> $CONFIG_FILE
"
done
);
echo "---------------- Verify TSERVER configuration files -----------------"
for ip in $ALL_NODES; do \
echo =======$ip=======; \
ssh -i $PEM $ADMIN_USER@$ip cat ~/yb-conf/tserver.conf; \
done
echo "---------------- Start masters and verify -----------------"
chmod 777 ./yb/start_master.bash
./yb/start_master.bash
echo "---------------- Start tservers and verify -----------------"
chmod 777 ./yb/start_tserver.bash
./yb/start_tserver.bash
echo "---------------- Configure AZ- and region-aware placement -----------------"
ssh -i $PEM $ADMIN_USER@$MASTER1 \
~/master/bin/yb-admin --master_addresses $MASTER_RPC_ADDRS \
modify_placement_info \
aws.ap-south-1.ap-south-1a,aws.ap-south-1.ap-south-1b 3
echo "---------------- Set zone preference -----------------"
ssh -i $PEM $ADMIN_USER@$MASTER1 \
~/master/bin/yb-admin --master_addresses $MASTER_RPC_ADDRS \
set_preferred_zones \
aws.ap-south-1.ap-south-1b
echo "---------------- Test PostgreSQL-compatible YSQL API -----------------"
chmod 777 ./yb/test-pgsql.bash
./yb/test-pgsql.bash
echo "---------------- Test Cassandra-compatible YCQL API -----------------"
chmod 777 ./yb/test-cassandra.bash
./yb/test-cassandra.bash
echo "---------------- Running sample workload -----------------"
export CIP_ADDR=10.0.0.66:9042
jar=./yb-sample-apps.jar
CassandraKeyValueLog="/home/centos/yb/metrics/CassandraKeyValue-$(date "+%Y%m%d-%H%m").txt"
java -jar $jar --workload CassandraKeyValue --nodes 10.0.0.66:9042 >> $CassandraKeyValueLog &
CassandraBatchTimeseriesLog="/home/centos/yb/metrics/CassandraBatchTimeseries-$(date "+%Y%m%d-%H%m").txt"
java -jar $jar --workload CassandraBatchTimeseries --nodes 10.0.0.66:9042 >> $CassandraBatchTimeseriesLog &
SqlInsertsLog="/home/centos/yb/metrics/SqlInserts-$(date "+%Y%m%d-%H%m").txt"
java -jar $jar --workload SqlInserts --nodes 10.0.0.66:9042 >> $SqlInsertsLog &
wget https://github.com/prometheus/prometheus/releases/download/v2.30.3/prometheus-2.30.3.linux-amd64.tar.gz
tar xvfz prometheus-*
cd prometheus-*
./prometheus-*/prometheus --config.file=/home/centos/yb/yugabytedb.yml &
#link 3.6.95.250:9090
#http://3.6.95.250:9090/graph
#http://3.6.95.250:9090/metrics
for f in Cassandra*.txt; do
parsed="Parsed-$f.log";
search="com.yugabyte.sample.common.metrics.MetricsTracker"
echo "R-ops/s R-ms/ops total-R-ops W-ops/s W-ms/ops total-W-ops Uptime-ms maxWrittenKey maxGeneratedKey"> $parsed
grep $search $f | cut -f8,10,12,19,21,23,30,34,37 -d " " | tr -d "(" >> $parsed
done
for f in cpu_usage*.txt; do
parsed="Parsed-$f.log";
search="all"
echo "datetime,CPU,%user,%nice,%system,%iowait,%steal,%idle" > $parsed
grep $search $f | tr -s " " "," | cut -f1-8 -d "," >> $parsed
done