-
Notifications
You must be signed in to change notification settings - Fork 24
/
DingoControl
executable file
·842 lines (729 loc) · 25 KB
/
DingoControl
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
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
#!/bin/bash
# auto read INSTALLER_PATH and USER
INSTALLER_PATH=$(grep "^installer_root_path:" group_vars/all/_shared.yml | cut -d "=" -f 2 | awk '{print $2}')
USER=$(grep "^dingo_user" group_vars/all/_shared.yml | cut -d "=" -f 2 | awk '{print $2}')
echo "INSTALLER_PATH: ${INSTALLER_PATH}"
echo "USER: ${USER}"
function help() {
echo "Usage: Dingocontrol.sh [OPTION]..."
echo "Options:"
echo " --help display this help and exit"
echo " deploy deploy the application"
echo " show show all process for user"
echo " stop stop server"
echo " clean clean server"
echo " start start server"
echo " cleanstart stop clean deploy and start server"
echo " install install playbook"
echo ""
echo ""
echo "For help on specific deploy or run options, run:"
echo " Dingocontrol.sh show --help"
echo " Dingocontrol.sh deploy --help"
echo " Dingocontrol.sh stop --help"
echo " Dingocontrol.sh clean --help"
echo " Dingocontrol.sh start --help"
echo " Dingocontrol.sh cleanstart --help"
echo " Dingocontrol.sh install --help"
}
function show_help() {
echo "Usage: Dingocontrol.sh show [OPTION]..."
echo "Options:"
echo " --help show info help"
echo " process show all process"
echo " file show all file not user"
}
function show_process() {
ansible all_nodes,scaling_in_dingo -m shell -a "ps -fu ${USER}"
}
function show_file() {
ansible all_nodes -m shell -a "find ${INSTALLER_PATH} -not -user ${USER}"
}
function show() {
if [ "$1" == "--help" ]; then
show_help
elif [ "$1" == "process" ]; then
show_process
elif [ "$1" == "file" ]; then
show_file
else
show_help
fi
}
function deploy_help() {
echo "Usage: Dingocontrol.sh clean [OPTION]..."
echo "Options:"
echo " --help deploy info help"
echo " all stop/clean/deploy store/coordinator"
echo " store stop/clean/deploy store"
echo " coordinator stop/clean/deploy coordinator"
echo " index stop/clean/deploy index"
}
function deploy() {
if [ "$1" == "--help" ]; then
deploy_help
elif [ "$1" == "all" ]; then
deploy_all
elif [ "$1" == "store" ]; then
deploy_store
elif [ "$1" == "coordinator" ]; then
deploy_coordinator
elif [ "$1" == "document" ]; then
deploy_document
elif [ "$1" == "diskann" ]; then
deploy_diskann
elif [ "$1" == "index" ]; then
deploy_index
else
deploy_help
fi
}
function deploy_all() {
deploy_coordinator
deploy_store
deploy_index
}
function deploy_store() {
ansible store -m shell -a "${INSTALLER_PATH}/dingo-store/scripts/start-store.sh clean" --become --become-user ${USER}
ansible store -m shell -a "${INSTALLER_PATH}/dingo-store/scripts/start-store.sh deploy" --become --become-user ${USER}
}
function deploy_document() {
ansible document -m shell -a "${INSTALLER_PATH}/dingo-store/scripts/start-document.sh clean" --become --become-user ${USER}
ansible document -m shell -a "${INSTALLER_PATH}/dingo-store/scripts/start-document.sh deploy" --become --become-user ${USER}
}
function deploy_diskann() {
ansible diskann -m shell -a "${INSTALLER_PATH}/dingo-store/scripts/start-diskann.sh clean" --become --become-user ${USER}
ansible diskann -m shell -a "${INSTALLER_PATH}/dingo-store/scripts/start-diskann.sh deploy" --become --become-user ${USER}
}
function deploy_index() {
ansible index -m shell -a "${INSTALLER_PATH}/dingo-store/scripts/start-index.sh clean" --become --become-user ${USER}
ansible index -m shell -a "${INSTALLER_PATH}/dingo-store/scripts/start-index.sh deploy" --become --become-user ${USER}
}
function deploy_coordinator() {
ansible coordinator -m shell -a "${INSTALLER_PATH}/dingo-store/scripts/start-coordinator.sh clean" --become --become-user ${USER}
ansible coordinator -m shell -a "${INSTALLER_PATH}/dingo-store/scripts/start-coordinator.sh deploy" --become --become-user ${USER}
}
function clean_help() {
echo "Usage: Dingocontrol.sh clean [OPTION]..."
echo "Options:"
echo " --help clean info help"
echo " all stop all server and clean all file, if want del completely"
echo " dingo-store stop/clean store/coordinator and clean dingo-store, deprecated"
echo " store stop/clean store"
echo " coordinator stop/clean coordinator"
echo " document stop/clean document"
echo " diskann stop/clean diskann"
echo " index stop/clean index"
echo " node-exporter stop/clean node-exporter"
echo " process-exporter stop/clean process-exporter"
echo " prometheus stop/clean prometheus"
echo " grafana stop/clean grafana"
}
function clean() {
if [ "$1" == "--help" ]; then
clean_help
elif [ "$1" == "all" ]; then
clean_all
elif [ "$1" == "store" ]; then
clean_store
elif [ "$1" == "coordinator" ]; then
clean_coordinator
elif [ "$1" == "document" ]; then
clean_document
elif [ "$1" == "diskann" ]; then
clean_diskann
elif [ "$1" == "index" ]; then
clean_index
elif [ "$1" == "node-exporter" ]; then
clean_node
elif [ "$1" == "process-exporter" ]; then
clean_process
elif [ "$1" == "prometheus" ]; then
clean_prometheus
elif [ "$1" == "grafana" ]; then
clean_grafana
else
clean_help
fi
}
function clean_all() {
clean_store
clean_document
clean_diskann
clean_index
clean_coordinator
stop_executor
clean_node
clean_process
clean_prometheus
clean_grafana
ansible all_nodes,scaling_in_dingo -m shell -a "rm -rf ${INSTALLER_PATH}/*"
}
function clean_store() {
ansible store,add_store -m shell -a "${INSTALLER_PATH}/dingo-store/scripts/start-store.sh clean" --become --become-user ${USER}
}
function clean_document() {
ansible document -m shell -a "${INSTALLER_PATH}/dingo-store/scripts/start-document.sh clean" --become --become-user ${USER}
}
function clean_diskann() {
ansible diskann -m shell -a "${INSTALLER_PATH}/dingo-store/scripts/start-diskann.sh clean" --become --become-user ${USER}
}
function clean_index() {
ansible index -m shell -a "${INSTALLER_PATH}/dingo-store/scripts/start-index.sh clean" --become --become-user ${USER}
}
function clean_coordinator() {
ansible coordinator,add_coordinator -m shell -a "${INSTALLER_PATH}/dingo-store/scripts/start-coordinator.sh clean" --become --become-user ${USER}
}
function clean_node() {
stop_node
ansible node_exporter -m shell -a "rm -f /etc/systemd/system/dingo-node-exporter.service"
}
function clean_process() {
stop_process
ansible process_exporter -m shell -a "rm -f /etc/systemd/system/dingo-process-exporter.service"
}
function clean_prometheus() {
stop_prometheus
ansible prometheus -m shell -a "rm -f /etc/systemd/system/dingo-prometheus.service"
}
function clean_grafana() {
stop_grafana
ansible grafana -m shell -a "rm -f /etc/systemd/system/dingo-grafana.service"
}
function start_help() {
echo "Usage: Dingocontrol.sh start[OPTION]..."
echo "Options:"
echo " all start all process"
echo " dingodb start all dingodb process except monitor"
echo " monitor start all monitor process"
echo " monitor_web start monitor_web"
echo " store start store"
echo " coordinator start coordinator"
echo " document start document"
echo " diskann start diskann"
echo " index start index"
echo " one_executor start one executor need param3=ip"
echo " one_store start one store need param3=ip"
echo " one_document start one document need param3=ip"
echo " one_diskann start one diskann need param3=ip"
echo " one_index start one index need param3=ip"
echo " one_coordinator start one coordinator need param3=ip"
echo " executor start executor"
echo " proxy start proxy"
echo " web start web"
echo " node-exporter start node-exporter"
echo " process-exporter start process-exporter"
echo " prometheus start prometheus"
echo " grafana start grafana"
}
function start() {
if [ "$1" == "--help" ]; then
start_help
elif [ "$1" == "all" ]; then
start_all
elif [ "$1" == "dingodb" ]; then
start_dingodb
elif [ "$1" == "monitor" ]; then
start_monitor
elif [ "$1" == "store" ]; then
start_store
elif [ "$1" == "document" ]; then
start_document
elif [ "$1" == "diskann" ]; then
start_diskann
elif [ "$1" == "index" ]; then
start_index
elif [ "$1" == "coordinator" ]; then
start_coordinator
elif [ "$1" == "one_executor" ]; then
start_one_executor $2
elif [ "$1" == "one_store" ]; then
start_one_store $2
elif [ "$1" == "one_document" ]; then
start_one_document $2
elif [ "$1" == "one_diskann" ]; then
start_one_diskann $2
elif [ "$1" == "one_index" ]; then
start_one_index $2
elif [ "$1" == "one_coordinator" ]; then
start_one_coordinator $2
elif [ "$1" == "executor" ]; then
start_executor
elif [ "$1" == "monitor_web" ]; then
start_monitor_web
elif [ "$1" == "proxy" ]; then
start_proxy
elif [ "$1" == "web" ]; then
start_web
elif [ "$1" == "node-exporter" ]; then
start_node
elif [ "$1" == "process-exporter" ]; then
start_process
elif [ "$1" == "prometheus" ]; then
start_prometheus
elif [ "$1" == "grafana" ]; then
start_grafana
else
start_help
fi
}
function start_all() {
start_coordinator
sleep 10
start_store
start_document
start_diskann
start_index
start_executor
start_proxy
start_web
start_node
start_process
start_prometheus
start_grafana
}
function start_dingodb() {
start_coordinator
sleep 10
start_store
start_document
start_diskann
start_index
start_executor
start_proxy
start_web
}
function start_monitor() {
start_node
start_process
start_prometheus
start_grafana
start_monitor_web
}
function start_one_executor() {
ip=$1
echo "ip: ${ip}"
ansible ${ip} -m shell -a "${INSTALLER_PATH}/dingo-store/bin/start-executor.sh start" --become --become-user ${USER}
}
function start_one_store() {
ip=$1
echo "ip: ${ip}"
ansible ${ip} -m shell -a "${INSTALLER_PATH}/dingo-store/scripts/start-store.sh start" --become --become-user ${USER}
}
function start_one_document() {
ip=$1
echo "ip: ${ip}"
ansible ${ip} -m shell -a "${INSTALLER_PATH}/dingo-store/scripts/start-document.sh start" --become --become-user ${USER}
}
function start_one_diskann() {
ip=$1
echo "ip: ${ip}"
ansible ${ip} -m shell -a "${INSTALLER_PATH}/dingo-store/scripts/start-diskann.sh start" --become --become-user ${USER}
}
function start_one_index() {
ip=$1
echo "ip: ${ip}"
ansible ${ip} -m shell -a "${INSTALLER_PATH}/dingo-store/scripts/start-index.sh start" --become --become-user ${USER}
}
function start_one_coordinator() {
ip=$1
echo "ip: ${ip}"
ansible ${ip} -m shell -a "${INSTALLER_PATH}/dingo-store/scripts/start-coordinator.sh start" --become --become-user ${USER}
# add coor_list
}
function start_store() {
ansible store,add_store -m shell -a "${INSTALLER_PATH}/dingo-store/scripts/start-store.sh start" --become --become-user ${USER}
ansible store --list-hosts | grep -oP '(\d{1,3}\.){3}\d{1,3}' | head -n 1 | xargs ansible store -m shell -a "${INSTALLER_PATH}/dingo-store/scripts/mysql_init.sh" --limit
}
function start_document() {
ansible document -m shell -a "${INSTALLER_PATH}/dingo-store/scripts/start-document.sh start" --become --become-user ${USER}
}
function start_diskann() {
ansible diskann -m shell -a "${INSTALLER_PATH}/dingo-store/scripts/start-diskann.sh start" --become --become-user ${USER}
}
function start_index() {
ansible index -m shell -a "${INSTALLER_PATH}/dingo-store/scripts/start-index.sh start" --become --become-user ${USER}
}
function start_coordinator() {
ansible coordinator,add_coordinator -m shell -a "${INSTALLER_PATH}/dingo-store/scripts/start-coordinator.sh start" --become --become-user ${USER}
sleep 10
}
function start_executor() {
ansible executor -m shell -a "${INSTALLER_PATH}/dingo-store/bin/start-executor.sh" --become --become-user ${USER}
}
function start_web() {
ansible web -m shell -a "${INSTALLER_PATH}/dingo-store/bin/start-web.sh" --become --become-user ${USER}
}
function start_proxy() {
ansible proxy -m shell -a "${INSTALLER_PATH}/dingo-store/bin/start-proxy.sh" --become --become-user ${USER}
}
function start_node() {
ansible node_exporter -m shell -a "systemctl start dingo-node-exporter.service"
}
function start_process() {
ansible process_exporter -m shell -a "systemctl start dingo-process-exporter.service"
}
function start_prometheus() {
ansible prometheus -m shell -a "systemctl start dingo-prometheus.service"
}
function start_grafana() {
ansible grafana -m shell -a "systemctl start dingo-grafana.service"
}
function start_monitor_web() {
ansible executor -m shell -a "${INSTALLER_PATH}/dingo-store/bin/start-web.sh" --become --become-user ${USER}
ansible web -m shell -a "systemctl start nginx.service"
}
function stop_help() {
echo "Usage: Dingocontrol.sh stop [OPTION]..."
echo "Options:"
echo " all stop all process"
echo " dingodb stop all dingodb process except monitor"
echo " monitor stop all monitor process"
echo " store stop store"
echo " document stop document"
echo " diskann stop diskann"
echo " index stop index"
echo " coordinator stop coordinator"
echo " one_executor stop one executor need param3=ip"
echo " one_web stop one web need param3=ip"
echo " one_store stop one store need param3=ip"
echo " one_document stop one document need param3=ip"
echo " one_diskann stop one diskann need param3=ip"
echo " one_index stop one index need param3=ip"
echo " one_coordinator stop one coordinator need param3=ip"
echo " executor stop executor and proxy"
echo " web stop web"
echo " node-exporter stop node-exporter"
echo " process-exporter stop process-exporter"
echo " prometheus stop prometheus"
echo " grafana stop grafana"
echo " monitor_web stop monitor web"
}
function stop() {
if [ "$1" == "--help" ]; then
stop_help
elif [ "$1" == "all" ]; then
stop_all
elif [ "$1" == "dingodb" ]; then
stop_dingodb
elif [ "$1" == "monitor" ]; then
stop_monitor
elif [ "$1" == "store" ]; then
stop_store
elif [ "$1" == "document" ]; then
stop_document
elif [ "$1" == "diskann" ]; then
stop_diskann
elif [ "$1" == "index" ]; then
stop_index
elif [ "$1" == "coordinator" ]; then
stop_coordinator
elif [ "$1" == "one_executor" ]; then
stop_one_executor $2
elif [ "$1" == "one_web" ]; then
stop_one_web $2
elif [ "$1" == "one_store" ]; then
stop_one_store $2
elif [ "$1" == "one_document" ]; then
stop_one_document $2
elif [ "$1" == "one_diskann" ]; then
stop_one_diskann $2
elif [ "$1" == "one_index" ]; then
stop_one_index $2
elif [ "$1" == "one_coordinator" ]; then
stop_one_coordinator $2
elif [ "$1" == "executor" ]; then
stop_executor
elif [ "$1" == "web" ]; then
stop_web
elif [ "$1" == "node-exporter" ]; then
stop_node
elif [ "$1" == "process-exporter" ]; then
stop_process
elif [ "$1" == "prometheus" ]; then
stop_prometheus
elif [ "$1" == "grafana" ]; then
stop_grafana
elif [ "$1" == "monitor_web" ]; then
stop_monitor_web
else
stop_help
fi
}
function stop_all() {
stop_store
stop_document
stop_diskann
stop_index
stop_coordinator
stop_executor
stop_web
stop_node
stop_process
stop_prometheus
stop_grafana
stop_monitor_web
}
function stop_dingodb() {
stop_store
stop_document
stop_diskann
stop_index
stop_coordinator
stop_executor
stop_web
}
function stop_monitor() {
stop_node
stop_process
stop_prometheus
stop_grafana
stop_monitor_web
}
function stop_one_executor() {
ip=$1
echo "ip: ${ip}"
ansible ${ip} -m shell -a "${INSTALLER_PATH}/dingo-store/bin/stop-executor-proxy.sh stop" --become --become-user ${USER}
}
function stop_one_web() {
ip=$1
echo "ip: ${ip}"
ansible ${ip} -m shell -a "${INSTALLER_PATH}/dingo-store/bin/stop-dingo-web.sh stop" --become --become-user ${USER}
}
function stop_one_store() {
ip=$1
echo "ip: ${ip}"
ansible ${ip} -m shell -a "${INSTALLER_PATH}/dingo-store/scripts/start-store.sh stop" --become --become-user ${USER}
}
function stop_one_document() {
ip=$1
echo "ip: ${ip}"
ansible ${ip} -m shell -a "${INSTALLER_PATH}/dingo-store/scripts/start-document.sh stop" --become --become-user ${USER}
}
function stop_one_diskann() {
ip=$1
echo "ip: ${ip}"
ansible ${ip} -m shell -a "${INSTALLER_PATH}/dingo-store/scripts/start-diskann.sh stop" --become --become-user ${USER}
}
function stop_one_index() {
ip=$1
echo "ip: ${ip}"
ansible ${ip} -m shell -a "${INSTALLER_PATH}/dingo-store/scripts/start-index.sh stop" --become --become-user ${USER}
}
function stop_one_coordinator() {
ip=$1
echo "ip: ${ip}"
ansible ${ip} -m shell -a "${INSTALLER_PATH}/dingo-store/scripts/start-coordinator.sh stop" --become --become-user ${USER}
}
function stop_store() {
ansible store,add_store -m shell -a "${INSTALLER_PATH}/dingo-store/scripts/start-store.sh stop" --become --become-user ${USER}
}
function stop_document() {
ansible document -m shell -a "${INSTALLER_PATH}/dingo-store/scripts/start-document.sh stop" --become --become-user ${USER}
}
function stop_diskann() {
ansible diskann -m shell -a "${INSTALLER_PATH}/dingo-store/scripts/start-diskann.sh stop" --become --become-user ${USER}
}
function stop_index() {
ansible index -m shell -a "${INSTALLER_PATH}/dingo-store/scripts/start-index.sh stop" --become --become-user ${USER}
}
function stop_coordinator() {
ansible coordinator,add_coordinator -m shell -a "${INSTALLER_PATH}/dingo-store/scripts/start-coordinator.sh stop" --become --become-user ${USER}
}
function stop_executor() {
ansible executor -m shell -a "${INSTALLER_PATH}/dingo-store/bin/stop-executor-proxy.sh" --become --become-user ${USER}
}
function stop_web() {
ansible web -m shell -a "${INSTALLER_PATH}/dingo-store/bin/stop-dingo-web.sh" --become --become-user ${USER}
}
function stop_node() {
ansible node_exporter -m shell -a "systemctl stop dingo-node-exporter.service"
}
function stop_process() {
ansible process_exporter -m shell -a "systemctl stop dingo-process-exporter.service"
}
function stop_prometheus() {
ansible prometheus -m shell -a "systemctl stop dingo-prometheus.service"
}
function stop_grafana() {
ansible grafana -m shell -a "systemctl stop dingo-grafana.service"
}
function stop_monitor_web() {
ansible executor -m shell -a "${INSTALLER_PATH}/dingo-store/bin/stop-dingo-web.sh" --become --become-user ${USER}
ansible web -m shell -a "systemctl stop nginx.service"
}
function cleanstart_help() {
echo "Usage: Dingocontrol.sh cleanstart [OPTION]..."
echo "Options:"
echo " all stop-clean-deploy store/coordinator/index and restart executor/proxy web"
}
function cleanstart() {
if [ "$1" == "--help" ]; then
cleanstart_help
elif [ "$1" == "all" ]; then
cleanstart_all
else
cleanstart_help
fi
}
function cleanstart_all(){
clean_store
clean_index
clean_coordinator
stop_executor
deploy_coordinator
deploy_store
deploy_index
start_coordinator
sleep 20
start_store
start_index
start_executor
start_proxy
start_web
}
function install_help() {
echo "Usage: Dingocontrol.sh install [OPTION]..."
echo "Options:"
echo " playbook playbook.yml"
echo " system install system"
echo " jdk install jdk"
echo " check-ports check port conflicts"
echo " dingo install dingo"
echo " dingo-store install dingo-store"
echo " dingodb install dingo and dingo-store"
echo " scaling_in_dingodb add node coordinator or store"
echo " coor_list gen_coor_list,use after scaling_in_dingodb"
echo " addpeer addpeer after gen_coor_list, defaults dingo_store_coordinator_exchange_port and dingo_store_coordinator_raft_port"
echo " scaling_out_dingodb scaling coordinator, defaults dingo_store_coordinator_exchange_port and dingo_store_coordinator_raft_port"
echo " prometheus install prometheus"
echo " grafana install grafana"
echo " monitor_web install monitor_web"
echo " node install node_exporter"
echo " process install process_exporter"
echo " monitor install prometheus grafana node_exporter process_exporter monitor_web"
}
function install() {
if [ "$1" == "--help" ]; then
install_help
elif [ "$1" == "playbook" ]; then
install_playbook
elif [ "$1" == "system" ]; then
install_system
elif [ "$1" == "jdk" ]; then
install_jdk
elif [ "$1" == "check-ports" ]; then
install_check_ports
elif [ "$1" == "dingo" ]; then
install_dingo
elif [ "$1" == "dingo-store" ]; then
install_dingo-store
elif [ "$1" == "dingodb" ]; then
install_dingodb
elif [ "$1" == "scaling_in_dingodb" ]; then
install_scaling_in_dingodb
elif [ "$1" == "coor_list" ]; then
install_coor_list $2
elif [ "$1" == "addpeer" ]; then
install_addpeer $2
elif [ "$1" == "scaling_out_dingodb" ]; then
install_scaling_out_dingodb $2
elif [ "$1" == "prometheus" ]; then
install_prometheus
elif [ "$1" == "grafana" ]; then
install_grafana
elif [ "$1" == "node" ]; then
install_node
elif [ "$1" == "process" ]; then
install_process
elif [ "$1" == "monitor" ]; then
install_monitor
elif [ "$1" == "monitor_web" ]; then
install_monitor_web
else
install_help
fi
}
function install_playbook(){
ansible-playbook playbook.yml
}
function install_system(){
ansible-playbook playbooks/01_system.yml -e "install_system=true"
}
function install_jdk(){
ansible-playbook playbooks/02_jdk.yml -e "install_java_sdk=true"
}
function install_check_ports(){
ansible-playbook playbooks/02_1_check_ports.yml -e "check_port_conflicts=true"
}
function install_dingo(){
ansible-playbook playbooks/04_dingo.yml -e "install_dingo=true"
}
function install_dingo-store(){
ansible-playbook playbooks/03_dingo-store.yml -e "install_dingo_store=true"
}
function install_dingodb(){
install_dingo-store
install_dingo
}
function install_scaling_in_dingodb(){
ansible-playbook playbooks/031_scaling_in_dingo.yml -e "install_dingo_store=true"
}
function install_coor_list(){
coor_list=$1
ansible coordinator,add_coordinator -m shell -a "${INSTALLER_PATH}/dingo-store/scripts/gen_coor_list.sh ${coor_list}" --become --become-user ${USER}
}
function install_addpeer(){
peer_ip=$1
ansible coordinator,add_coordinator -m shell -a "cd ${INSTALLER_PATH}/dingo-store/build/bin;./dingodb_client_coordinator --method=RaftAddPeer --addr={{ inventory_hostname }}:{{ dingo_store_coordinator_exchange_port }} --peer=${peer_ip}:{{ dingo_store_coordinator_raft_port }} --index=0" --become --become-user ${USER}
ansible coordinator,add_coordinator -m shell -a "cd ${INSTALLER_PATH}/dingo-store/build/bin;./dingodb_client_coordinator --method=RaftAddPeer --addr={{ inventory_hostname }}:{{ dingo_store_coordinator_exchange_port }} --peer=${peer_ip}:{{ dingo_store_coordinator_raft_port }} --index=1" --become --become-user ${USER}
}
function install_scaling_out_dingodb(){
peer_ip=$1
stop_one_coordinator ${peer_ip}
ansible coordinator,add_coordinator -m shell -a "cd ${INSTALLER_PATH}/dingo-store/build/bin;./dingodb_client_coordinator --method=RaftRemovePeer --addr={{ inventory_hostname }}:{{ dingo_store_coordinator_exchange_port }} --peer=${peer_ip}:{{ dingo_store_coordinator_raft_port }} --index=0" --become --become-user ${USER}
ansible coordinator,add_coordinator -m shell -a "cd ${INSTALLER_PATH}/dingo-store/build/bin;./dingodb_client_coordinator --method=RaftRemovePeer --addr={{ inventory_hostname }}:{{ dingo_store_coordinator_exchange_port }} --peer=${peer_ip}:{{ dingo_store_coordinator_raft_port }} --index=1" --become --become-user ${USER}
}
function install_prometheus(){
ansible-playbook playbooks/05_prometheus.yml -e "install_prometheus=true"
}
function install_grafana(){
ansible-playbook playbooks/08_grafana.yml -e "install_grafana=true"
}
function install_monitor_web(){
ansible-playbook playbooks/09_monitor_web.yml -e "install_monitor_web=true"
}
function install_node(){
ansible-playbook playbooks/06_node_exporter.yml -e "install_node_exporter=true"
}
function install_process(){
ansible-playbook playbooks/07_process_exporter.yml -e "install_process_exporter=true"
}
function install_monitor(){
install_prometheus
install_node
install_process
install_grafana
install_monitor_web
}
if [ $# -eq 0 ] || [ "$1" == "--help" ]; then
help
elif [ "$1" == "show" ]; then
show "${@:2}"
elif [ "$1" == "deploy" ]; then
deploy "${@:2}"
elif [ "$1" == "clean" ]; then
clean "${@:2}"
elif [ "$1" == "start" ]; then
start "${@:2}"
elif [ "$1" == "stop" ]; then
stop "${@:2}"
elif [ "$1" == "cleanstart" ]; then
cleanstart "${@:2}"
elif [ "$1" == "install" ]; then
install "${@:2}"
else
echo "Invalid option: $1"
echo ""
help
fi