-
Notifications
You must be signed in to change notification settings - Fork 38
/
hopsworks-installer.sh
executable file
·1659 lines (1498 loc) · 50.6 KB
/
hopsworks-installer.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
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
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/bash
###################################################################################################
# #
# This code is released under the GNU General Public License, Version 3, see for details: #
# http://www.gnu.org/licenses/gpl-3.0.txt #
# #
# #
# Copyright (c) Hopsworks AB, 2020/2021/2022. #
# All Rights Reserved. #
# #
###################################################################################################
###################################################################################################
# #
# #
# | | | | | | #
# | |__| | ___ _ __ _____ _____ _ __| | _____ #
# | __ |/ _ \| '_ \/ __\ \ /\ / / _ \| '__| |/ / __| #
# | | | | (_) | |_) \__ \\ V V / (_) | | | <\__ \ #
# |_|__|_|\___/| .__/|___/ \_/\_/ \___/|_| |_|\_\___/ #
# |_ _| | || | | | | #
# | | _ __ |_|| |_ __ _| | | ___ _ __ #
# | | | '_ \/ __| __/ _` | | |/ _ \ '__| #
# _| |_| | | \__ \ || (_| | | | __/ | #
# |_____|_| |_|___/\__\__,_|_|_|\___|_| #
# #
###################################################################################################
HOPSWORKS_REPO=logicalclocks/hopsworks-chef
HOPSWORKS_BRANCH=master
CLUSTER_DEFINITION_BRANCH=https://raw.githubusercontent.com/logicalclocks/karamel-chef/$HOPSWORKS_BRANCH
KARAMEL_VERSION=0.10-SNAPSHOT
ENTERPRISE_DOWNLOAD_URL=https://nexus.hops.works/repository
INSTALL_ACTION=
NON_INTERACT=0
SCRIPTNAME=`basename $0`
AVAILABLE_MEMORY=$(free -g | grep Mem | awk '{ print $2 }')
AVAILABLE_DISK=$(df -h | grep '/$' | awk '{ print $4 }')
AVAILABLE_DISK=${AVAILABLE_DISK%.*}
# Azure mounts /mnt/resource - AWS/GCP mount /mnt
AVAILABLE_MNT=$(df -h | grep '/mnt' | awk '{ print $4 }')
AVAILABLE_MNT=${AVAILABLE_MNT%.*}
AVAILABLE_CPUS=$(cat /proc/cpuinfo | grep '^processor' | wc -l)
FILE_SYSTEM=$(df -Th | grep '/$' | awk '{ print $2 }')
IP=$(hostname -I | awk '{ print $1 }')
HOSTNAME=$(hostname -f)
DISTRO=
WORKER_ID=0
DRY_RUN=0
CLEAN_INSTALL_DIR=0
SUDO_PWD=
INSTALL_LOCALHOST=1
INSTALL_LOCALHOST_TLS=2
INSTALL_CLUSTER=3
INSTALL_KARAMEL=4
INSTALL_NVIDIA=5
PURGE_HOPSWORKS=7
PURGE_HOPSWORKS_ALL_HOSTS=8
TLS="false"
REVERSE_DNS=1
CLOUD=
NVME=0
NDB_NVME=
YARN="yarn:"
RM_WORKER=
ENTERPRISE=0
KUBERNETES=0
DOWNLOAD=
KUBERNETES_RECIPES=""
INPUT_YML="cluster-defns/hopsworks-head.yml"
WORKER_YML="cluster-defns/hopsworks-worker.yml"
WORKER_GPU_YML="cluster-defns/hopsworks-worker-gpu.yml"
YML_FILE="cluster-defns/hopsworks-installation.yml"
ENTERPRISE_ATTRS=
KUBE="false"
WORKER_LIST=
WORKER_IP=
WORKER_DEFAULTS=
HAS_GPUS=0
AVAILABLE_GPUS=
CUDA=
KARAMEL_HTTP_PROXY_1=
KARAMEL_HTTP_PROXY_2=
KARAMEL_HTTP_PROXY_3=
KARAMEL_HTTP_PROXY_4=
KARAMEL_HTTP_PROXY_5=
KARAMEL_HTTP_PROXY_6=
PROXY=
GEM_SERVER=0
GEM_SERVER_PORT=54321
OS_VERSION=0
KAFKA_PUBLIC_IP=
HOPSWORKS_PUBLIC_IP=
NODE_MANAGER_HEAD=" - hops::nm
"
# $1 = String describing error
exit_error()
{
#CleanUpTempFiles
echo "" $ECHO_OUT
echo "Error number: $1"
echo "Exiting hopsworks-installer.sh."
echo ""
exit 1
}
# $1 = accept phrase (what to accept)
# caller reads $ENTERED_STRING global variable for result
enter_string()
{
echo "$1"
read ENTERED_STRING
}
###################################################################################################
# SCREEN CLEAR FUNCTIONS
###################################################################################################
clear_screen()
{
if [ $NON_INTERACT -eq 0 ] ; then
echo ""
echo "Press ENTER to continue"
read cont < /dev/tty
fi
clear
}
clear_screen_no_skipline()
{
if [ $NON_INTERACT -eq 0 ] ; then
echo "Press ENTER to continue"
read cont < /dev/tty
fi
clear
}
accept_enterprise()
{
echo ""
echo "You are installing a time-limited version of Hopsworks Enterprise."
echo "The license for this version is valid for 60 days from now."
echo "Hopsworks Terms and conditions: https://www.logicalclocks.com/hopsworks-terms-and-conditions "
printf "Do you agree to Hopsworks terms and conditions (y/n)? "
read ACCEPT
case $ACCEPT in
y|yes)
echo "Continuing..."
echo ""
;;
n|no)
;;
*)
echo "Next time, enter 'y' or 'yes' to continue."
echo "Exiting..."
exit 3
;;
esac
}
#######################################################################
# LICENSING
#######################################################################
splash_screen()
{
clear
echo ""
echo "Karamel/Hopsworks Installer, Copyright(C) 2021 Logical Clocks AB. All rights reserved."
echo ""
echo "This program can install Karamel/Chef and/or Hopsworks."
echo ""
echo "To cancel installation at any time, press CONTROL-C"
echo ""
echo "You appear to have following setup on this host:"
echo "* available memory: $AVAILABLE_MEMORY"
echo "* available disk space (on '/' root partition): $AVAILABLE_DISK"
echo "* available disk space (under '/mnt' partition): $AVAILABLE_MNT"
echo "* available CPUs: $AVAILABLE_CPUS"
echo "* available GPUS: $AVAILABLE_GPUS"
echo "* file system: $FILE_SYSTEM"
echo "* your ip is: $IP"
echo "* installation user: $USER"
echo "* linux distro: $DISTRO"
echo "* version: $OS_VERSION"
echo "* cluster defn branch: $CLUSTER_DEFINITION_BRANCH"
echo "* hopsworks-chef branch: $HOPSWORKS_REPO/$HOPSWORKS_BRANCH"
clear_screen
}
strlen=${#HOSTNAME}
if [ $strlen -gt 64 ] ; then
echo ""
echo "WARNING: hostname is longer 64 chars which can cause problems with OpenSSL: $HOSTNAME"
echo ""
fi
if [ $AVAILABLE_MEMORY -lt 29 ] ; then
echo ""
echo "WARNING: We recommend at least 32GB of RAM. Minimum is 16GB of Ram. You have $AVAILABLE_MEMORY GB of RAM"
echo ""
fi
if [[ "$AVAILABLE_DISK" == *"G"* ]]; then
space=${AVAILABLE_DISK::-1}
else
space=${AVAILABLE_DISK}
fi
if [ $space -lt 60 ] && [ "$AVAILABLE_MNT" == "" ]; then
echo ""
echo "WARNING: We recommend at least 60GB of disk space on the root partition. Minimum is 50GB of available disk."
echo "You have $AVAILABLE_DISK space on '/', and no space on '/mnt'."
echo ""
fi
if [ "$AVAILABLE_MNT" != "" ] ; then
if [[ "$AVAILABLE_MNT" == *"G"* ]]; then
mnt=${AVAILABLE_MNT::-1}
else
mnt=${AVAILABLE_MNT}
fi
if [ $space -lt 30 ] || [ $mnt -lt 50 ]; then
echo ""
echo "WARNING: We recommend at least 30GB of disk space on the root partition as well as at least 50GB on the /mnt partition."
echo "You have ${space}G space on '/', and ${mnt}G on '/mnt'."
echo ""
fi
fi
if [ $AVAILABLE_CPUS -lt 4 ] ; then
echo ""
echo "WARNING: Hopsworks needs at least 4 CPUs to be able to run Spark applications."
echo ""
fi
if [ "$FILE_SYSTEM" != "ext4" ] ; then
echo ""
echo "WARNING: Hopsworks installer only supports 'ext4' as a file system."
echo "If you want to install Hopsworks on 'zfs' or 'xfs', contact www.logicalclocks.com for Enterprise support."
echo ""
fi
which dig > /dev/null
if [ $? -ne 0 ] ; then
echo "Installing dig..."
if [ "$DISTRO" == "Ubuntu" ] ; then
sudo apt install dnsutils -y > /dev/null
# elif [ "${DISTRO,,}" == "centos" ] || [ "${DISTRO,,}" == "os" ] ; then
else
sudo yum install bind-utils -y > /dev/null
fi
fi
which perl > /dev/null
if [ $? -ne 0 ] ; then
echo "Installing perl..."
if [ "$DISTRO" == "Ubuntu" ] ; then
sudo apt install perl -y > /dev/null
else
sudo yum install perl -y > /dev/null
fi
fi
# If there are multiple FQDNs for this IP, return the last one (this works on Azure)
reverse_hostname=$(dig +noall +answer -x $IP | awk '{ print $5 }' | sort -r | grep -v 'internal.cloudapp.net')
# stirp off trailing '.' chracter on the hostname returned
reverse_hostname=${reverse_hostname::-1}
if [ "$reverse_hostname" != "$HOSTNAME" ] ; then
REVERSE_DNS=0
echo ""
echo "WARNING: Reverse DNS does not work on this host. If you enable 'TLS', it will not work."
echo "Hostname: $HOSTNAME"
echo "Reverse Hostname: $reverse_hostname"
echo "Azure installation: please continue, we will try and fix this during the installation."
# echo "https://docs.microsoft.com/en-us/azure/dns/private-dns-getstarted-portal"
# echo ""
echo "On-premises: you have to configure your networking to make reverse-DNS work correctly."
echo ""
fi
pgrep mysql > /dev/null
if [ $? -eq 0 ] ; then
echo ""
echo "WARNING: A MySQL service is already running on this host. This could case installation problems."
echo -n "A service is running at this pid: "
pgrep mysql | tail -1
echo ""
fi
pgrep glassfish-domain1 > /dev/null
if [ $? -eq 0 ] ; then
echo ""
echo "WARNING: A Hopsworks server is already running on this host. This could case installation problems."
echo -n "A service is running at this pid: "
pgrep glassfish-domain1 | tail -1
echo ""
fi
pgrep airflow > /dev/null
if [ $? -eq 0 ] ; then
echo ""
echo "WARNING: An Airflow server is already running on this host. This could case installation problems."
echo -n "A service is running at this pid: "
pgrep airflow | tail -1
echo ""
fi
pgrep hadoop > /dev/null
if [ $? -eq 0 ] ; then
echo ""
echo "WARNING: A Hadoop server is already running on this host. This could case installation problems."
echo -n "A service is running at this pid: "
pgrep hadoop | tail -1
echo ""
fi
pgrep ndb > /dev/null
if [ $? -eq 0 ] ; then
echo ""
echo "WARNING: A MySQL Cluster (NDB) instance is already running on this host. This could case installation problems."
echo -n "A service is running at this pid: "
pgrep ndb | tail -1
echo ""
fi
display_license()
{
echo ""
echo "This code is released under the GNU General Public License, Version 3, see:"
echo "http://www.gnu.org/licenses/gpl-3.0.txt"
echo ""
echo "Copyright(C) 2021 Logical Clocks AB. All rights reserved."
echo "Logical Clocks AB is furnishing this item \"as is\". Logical Clocks AB does not provide any"
echo "warranty of the item whatsoever, whether express, implied, or statutory,"
echo "including, but not limited to, any warranty of merchantability or fitness"
echo "for a particular purpose or any warranty that the contents of the item will"
echo "be error-free. In no respect shall Logical Clocks AB incur any liability for any"
echo "damages, including, but limited to, direct, indirect, special, or consequential"
echo "damages arising out of, resulting from, or any way connected to the use of the"
echo "item, whether or not based upon warranty, contract, tort, or otherwise; "
echo "whether or not injury was sustained by persons or property or otherwise;"
echo "and whether or not loss was sustained from, or arose out of, the results of,"
echo "the item, or any services that may be provided by Logical Clocks AB."
echo ""
printf 'Do you accept these terms and conditions? [ yes or no ] '
}
accept_license ()
{
read ACCEPT
case $ACCEPT in
yes | Yes | YES)
;;
no | No | NO)
echo ""
exit 0
;;
*)
echo ""
echo "Please enter either 'yes' or 'no'."
printf 'Do you accept these terms and conditions? [ yes or no ] '
accept_license
;;
esac
}
get_install_option_help()
{
INSTALL_OPTION_HELP="
Install Options Help\n
===========================================================================\n
This program installs Karamel and can also install Hopsworks using Karamel and Chef-Solo.\n
$INSTALL_AS_DAEMON_HELP\n
\n
(1) Setup and start a single-host Hopsworks installation using Karamel. The cluster will run on this machine. \n
\tThe binaries and directories for storing data will all be under /srv/hops.\n
\tHopsworks will run at the end of the installation.\n
(2) Setup and start a multi-host Hopsworks installation using Karamel. The cluster will run on all the machines. \n
\tHopsworks will run at the end of the installation.\n
(3) Setup, install, and run Karamel on this host. \n
\tKaramel can be used to install Hopsworks by opening the URL in your browser: http://${ip}:9090/index.html \n
This installer has a Web UI available on the following port: \n
\t 9090 \n
The following ports should be opened for external Python access to the Hopsworks Feature Store: \n
\t 443, 8020, 9083, 9085, 50010 \n
"
}
install_action()
{
if [ "$INSTALL_ACTION" == "" ] ; then
echo "-------------------- Installation Options --------------------"
echo ""
echo "What would you like to do?"
echo ""
echo "(1) Install a single-host Hopsworks cluster."
echo ""
echo "(2) Install a single-host Hopsworks cluster with TLS enabled."
echo ""
echo "(3) Install a multi-host Hopsworks cluster with TLS enabled."
echo ""
echo "(4) Install an Enterprise Hopsworks cluster."
echo ""
echo "(5) Install an Enterprise Hopsworks cluster with Kubernetes"
echo ""
echo "(6) Install and start Karamel."
echo ""
echo "(7) Install Nvidia drivers and reboot server."
echo ""
echo "(8) Purge (uninstall) Hopsworks from this host."
echo ""
echo "(9) Purge (uninstall) Hopsworks from ALL hosts."
echo ""
printf 'Please enter your choice '1', '2', '3', '4', '5', '6', '7', '8', '9', 'q' \(quit\), or 'h' \(help\) : '
read ACCEPT
case $ACCEPT in
1)
INSTALL_ACTION=$INSTALL_LOCALHOST
;;
2)
INSTALL_ACTION=$INSTALL_LOCALHOST_TLS
;;
3)
INSTALL_ACTION=$INSTALL_CLUSTER
;;
4)
INSTALL_ACTION=$INSTALL_CLUSTER
ENTERPRISE=1
accept_enterprise
;;
5)
INSTALL_ACTION=$INSTALL_CLUSTER
ENTERPRISE=1
KUBERNETES=1
accept_enterprise
;;
6)
INSTALL_ACTION=$INSTALL_KARAMEL
;;
7)
INSTALL_ACTION=$INSTALL_NVIDIA
;;
8)
INSTALL_ACTION=$PURGE_HOPSWORKS
;;
9)
INSTALL_ACTION=$PURGE_HOPSWORKS_ALL_HOSTS
;;
h | H)
clear
get_install_option_help
echo -e $INSTALL_OPTION_HELP
clear_screen_no_skipline
install_action
;;
q | Q)
exit_error
;;
*)
echo ""
echo "Invalid Choice: $ACCEPT"
echo "Please enter your choice '1', '2', '3', '4', 'q', or 'h'."
clear_screen
install_action
;;
esac
clear_screen
fi
}
#
# To test http_proxy support:
# yum install iptables-services
# netstat -plant
# Reference: https://www.thegeekstuff.com/scripts/iptables-rules
#
# Delete all existing rules:
# iptables -F
#
# Allow incoming ssh (and connection response)
# sudo iptables -A INPUT -p tcp --dport 22 -m conntrack --ctstate NEW,ESTABLISHED -j ACCEPT
# sudo iptables -A OUTPUT -p tcp --sport 22 -m conntrack --ctstate ESTABLISHED -j ACCEP
# iptables -A OUTPUT -o eth0 -p tcp --sport 22 -m state --state ESTABLISHED -j ACCEPT
#
# allow related traiff
# sudo iptables -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
# sudo iptables -A OUTPUT -m conntrack --ctstate ESTABLISHED -j ACCEPT
# sudo iptables -A INPUT -p tcp --dport 22 -m conntrack --ctstate NEW,ESTABLISHED -j ACCEPT
# sudo iptables -A OUTPUT -p tcp --sport 22 -m conntrack --ctstate ESTABLISHED -j ACCEPT
# drop other incoming Traffic:
# iptables -A INPUT -j DROP
#
# Allow outgoing ssh connections:
# iptables -A OUTPUT -o eth0 -p tcp --dport 22 -m state --state NEW,ESTABLISHED -j ACCEPT
# iptables -A INPUT -i eth0 -p tcp --sport 22 -m state --state ESTABLISHED -j ACCEPT
#
# Allow outgoing https:
# iptables -A OUTPUT -o eth0 -p tcp -d 192.168.100.0/24 --dport 443 -m state --state NEW,ESTABLISHED -j ACCEPT
# iptables -A INPUT -i eth0 -p tcp -d 192.168.100.0/24 --sport 443 -m state --state ESTABLISHED -j ACCEPT
#
# Allow loopback
# iptables -A INPUT -i lo -j ACCEPT
# iptables -A OUTPUT -o lo -j ACCEPT
parse_proxy()
{
# extract the protocol
proto="$(echo $PROXY | grep :// | sed -e 's,^\(.*://\).*,\1,g')"
# remove the protocol
url="$(echo ${PROXY/$proto/})"
# extract the user (if any)
user="$(echo $url | grep @ | cut -d@ -f1)"
# extract the host and port
hostport="$(echo ${url/$user@/} | cut -d/ -f1)"
# by request host without port
host="$(echo $hostport | sed -e 's,:.*,,g')"
# by request - try to extract the port
port="$(echo $hostport | sed -e 's,^.*:,:,g' -e 's,.*:\([0-9]*\).*,\1,g' -e 's,[^0-9],,g')"
if [ "$port" == "" ] ; then
if [ "$proto" == "http://" ] ; then
port="80"
elif [ "$proto" == "https://" ] ; then
port="443"
else
port=-1
fi
fi
}
set_karamel_http_proxy()
{
parse_proxy
if [ "$proto" == "http://" ] ; then
http_proxy=$PROXY
KARAMEL_HTTP_PROXY_1="export http_proxy=${proto}${host}:${port}"
KARAMEL_HTTP_PROXY_2="export http_proxy_host=$host"
KARAMEL_HTTP_PROXY_3="export http_proxy_port=$port"
if [ "$https_proxy" != "" ] ; then
PROXY=$https_proxy
parse_proxy
fi
KARAMEL_HTTP_PROXY_4="export https_proxy=${proto}${host}:${port}"
KARAMEL_HTTP_PROXY_5="export https_proxy_host=$host"
KARAMEL_HTTP_PROXY_6="export https_proxy_port=$port"
elif [ "$proto" == "https://" ] ; then
https_proxy=$PROXY
KARAMEL_HTTP_PROXY_4="export https_proxy=${proto}${host}:${port}"
KARAMEL_HTTP_PROXY_5="export https_proxy_host=$host"
KARAMEL_HTTP_PROXY_6="export https_proxy_port=$port"
if [ "$http_proxy" != "" ] ; then
PROXY=$http_proxy
parse_proxy
fi
KARAMEL_HTTP_PROXY_1="export http_proxy=${proto}${host}:${port}"
KARAMEL_HTTP_PROXY_2="export http_proxy_host=$host"
KARAMEL_HTTP_PROXY_3="export http_proxy_port=$port"
else
echo "Error. Unrecognized http(s) proxy protocol: $proto is a problem from $PROXY"
exit 15
fi
if [ "$proto" == "http://" ] ; then
export http_proxy="${proto}${host}:${port}"
elif [ "$proto" == "https://" ] ; then
export https_proxy="${proto}${host}:${port}"
fi
rm -f index.html
http_proxy="${proto}${host}:${port}" wget --timeout=10 http://www.google.com/index.html 2>&1 > /dev/null
if [ $? -ne 0 ] ; then
echo "WARNING: There could be a problem with the proxy server setting."
echo "WARNING: wget (with http proxy 'on') could not download this file: http://www.logicalclocks.com/index.html"
echo "http_proxy=$http_proxy"
echo "https_proxy=$https_proxy"
echo "PROXY=$PROXY"
fi
rm -f index.html
echo "http_proxy: $http_proxy"
echo "https_proxy: $https_proxy"
}
check_proxy()
{
echo ""
printf "Is the host running this installer behind a http proxy (y/n)? "
read ACCEPT
case $ACCEPT in
y|yes)
# Just take the first http proxy set - https or http, not both https_proxy and http_proxy
printf "Enter the URL of the HTTP(S) PROXY: "
read PROXY
;;
n|no)
;;
*)
echo ""
echo "Invalid Choice: $ACCEPT"
echo "Please enter your choice 'y' or 'yes' for yes, 'n' or 'no' for no: "
clear_screen
check_proxy
;;
esac
}
enter_cloud()
{
if [ "$CLOUD" == "" ] ; then
echo "-------------------- Where are you installing Hopsworks? --------------------"
echo ""
echo "On what platform are you installing Hopsworks?"
echo ""
echo "(1) On-premises or private cloud."
echo ""
echo "(2) AWS."
echo ""
echo "(3) GCP."
echo ""
echo "(4) Azure."
echo ""
printf 'Please enter your choice '1', '2', '3', '4' : '
read ACCEPT
case $ACCEPT in
1)
CLOUD="none"
;;
2)
CLOUD="aws"
;;
3)
CLOUD="gcp"
;;
4)
CLOUD="azure"
;;
*)
echo ""
echo "Invalid Choice: $ACCEPT"
echo "Please enter your choice '1', '2', '3', '4'."
clear_screen
enter_cloud
;;
esac
clear_screen
fi
}
enter_email()
{
echo "Please enter your email address to continue:"
read email
if [[ $email =~ .*@.* ]]
then
echo "Registering...."
echo "{\"id\": \"$rand\", \"name\":\"$email\"}" > .details
else
echo "Exiting. Invalid email address."
exit 1
fi
curl -H "Content-type:application/json" --data @.details https://www.register.hops.works:443/keyword --connect-timeout 10 > /dev/null 2>&1
}
enter_public_ips()
{
echo "Hopsworks needs to advetise the public IP address of the Hopsworks head node and the Kafka Broker:"
echo "Please enter the public IP address or FQDN of this node:"
read hopsworks_ip
ping -c 1 $hopsworks_ip
if [ $? -ne 0 ]
then
echo "Exiting. Could not ping to the entered address: $hopsworks_ip."
exit 1
fi
HOPSWORKS_PUBLIC_IP=$hopsworks_ip
KAFKA_PUBLIC_IP=$hopsworks_ip
printf "Is the Kafka broker on the same public IP? (y/n)? "
read ACCEPT
case $ACCEPT in
y|yes)
echo "Setting Kafka public IP to $hopsworks_ip."
echo ""
;;
n|no)
echo "Please enter the public IP address or FQDN of the kafka broker:"
read kafka_ip
KAFKA_PUBLIC_IP=$kafka_ip
echo "Setting Kafka public IP to $kafka_ip."
;;
*)
echo "Next time, enter 'y' or 'n' ."
enter_public_ips
;;
esac
}
update_worker_yml()
{
sed -i "s/__WORKER_ID__/$WORKER_ID/" $tmpYml
sed -i "s/__WORKER_IP__/$WORKER_IP/" $tmpYml
sed -i "s/__MBS__/$MBS/" $tmpYml
sed -i "s/__CPUS__/$CPUS/" $tmpYml
cat $tmpYml >> $YML_FILE
}
add_worker()
{
if [ "$WORKER_DEFAULTS" != "true" ] ; then
printf 'Please enter the IP of the worker you want to add: '
read WORKER_IP
fi
ssh -t -o StrictHostKeyChecking=no $WORKER_IP "whoami" > /dev/null
if [ $? -ne 0 ] ; then
echo "Failed to ssh using public into: ${USER}@${WORKER_IP}"
echo "Cannot add worker node, as you need to be able to ssh into it using your public key"
echo ""
echo ""
echo "You can setup passwordless SSH to setup to ${USER}@${WORKER_IP} by entering the password."
echo "Running ssh-copy-id.... "
ssh-copy-id -i ${HOME}/.ssh/id_rsa.pub ${USER}@${WORKER_IP}
if [ $? -ne 0 ] ; then
exit_error "Problem setting up passwordless SSH to ${USER}@${WORKER_IP}"
fi
fi
WORKER_MEM=$(ssh -t -o StrictHostKeyChecking=no $WORKER_IP "free -m | grep Mem | awk '{ print \$2 }'")
WORKER_DISK=$(ssh -t -o StrictHostKeyChecking=no $WORKER_IP "df -h | grep '/\$' | awk '{ print \$4 }'")
WORKER_CPUS=$(ssh -t -o StrictHostKeyChecking=no $WORKER_IP "cat /proc/cpuinfo | grep '^processor' | wc -l")
NUM_GBS=$(expr $WORKER_MEM - 2)
NUM_CPUS=$(expr $WORKER_CPUS - 1)
MBS=$WORKER_MEM
echo "Amount of disk space available on root partition ('/'): $WORKER_DISK"
echo "Amount of memory available on this worker: $WORKER_MEM MBs"
if [ "$WORKER_DEFAULTS" != "true" ] ; then
printf "Please enter the amount of memory in this worker to be used (GBs): "
read GBS
MBS=$(expr $GBS \* 1024)
fi
echo "Amount of CPUs available on worker: $WORKER_CPUS"
CPUS=$WORKER_CPUS
if [ "$WORKER_DEFAULTS" != "true" ] ; then
printf "Please enter the number of CPUs in this worker to be used: "
read CPUS
fi
if [ "${DISTRO,,}" == "centos" ] || [ "${DISTRO,,}" == "os" ] ; then
ssh -t -o StrictHostKeyChecking=no $WORKER_IP "sudo yum install pciutils -y"
fi
WORKER_MNT=$(ssh -t -o StrictHostKeyChecking=no $WORKER_IP "sudo df -h | grep '/mnt' | awk '{ print $4 }'")
re='^[0-9]+$'
if [ "$CLOUD" == "azure" ] ; then
NSLOOKUP=$(ssh -t -o StrictHostKeyChecking=no $WORKER_IP "nslookup $WORKER_IP | grep name | grep -v 'internal.cloudapp.net'")
SUSPECTED_HOSTNAME=$(echo $NSLOOKUP | awk {' print $4 '})
SUSPECTED_HOSTNAME=${SUSPECTED_HOSTNAME::-1}
echo ""
echo "On Azure, you need to add every worker to the same Private DNS Zone, and note the hostname you set in Azure."
echo "We suspect the private DNS hostname is:"
echo " $SUSPECTED_HOSTNAME"
echo ""
if [ "$WORKER_DEFAULTS" != "true" ] ; then
printf "Please enter the private DNS hostname for this worker (default: $SUSPECTED_HOSTNAME): "
read PRIVATE_HOSTNAME
if [ "$PRIVATE_HOSTNAME" == "" ] ; then
PRIVATE_HOSTNAME=$SUSPECTED_HOSTNAME
fi
else
PRIVATE_HOSTNAME=$SUSPECTED_HOSTNAME
fi
ssh -t -o StrictHostKeyChecking=no $WORKER_IP "sudo hostname $PRIVATE_HOSTNAME"
if [[ $WORKER_MNT =~ $re ]] ; then
ssh -t -o StrictHostKeyChecking=no $WORKER_IP "sudo rm -rf /srv/hops; sudo mkdir -p /mnt/resource/hops; sudo ln -s /mnt/resource/hops /srv/hops"
fi
else
if [[ $WORKER_MNT =~ $re ]] ; then
ssh -t -o StrictHostKeyChecking=no $WORKER_IP "sudo rm -rf /srv/hops; sudo mkdir -p /mnt/hops; sudo ln -s /mnt/hops /srv/hops"
fi
fi
WORKER_GPUS=$(ssh -t -o StrictHostKeyChecking=no $WORKER_IP "sudo lspci | grep -i nvidia | wc -l")
# strip carriage return '\r' from variable to make it a number
WORKER_GPUS=$(echo $WORKER_GPUS|tr -d '\r')
echo ""
echo "Number of GPUs found on worker: $WORKER_GPUS"
echo ""
if [ "$WORKER_GPUS" -gt "0" ] ; then
HAS_GPUS=1
if [ "$WORKER_DEFAULTS" != "true" ] ; then
printf 'Do you want all of the GPUs to be used by this worker (y/n (default y):'
read ACCEPT
if [ "$ACCEPT" == "y" ] || [ "$ACCEPT" == "yes" ] || [ "$ACCEPT" == "" ] ; then
echo "$WORKER_GPUS will be used on this worker."
else
echo "$The GPUs will not be used on this worker."
WORKER_GPUS=0
fi
# else
# ssh -t -o StrictHostKeyChecking=no $WORKER_IP "sudo yum install \"kernel-devel-uname-r == $(uname -r)\" -y" > /dev/null
fi
else
echo "No worker GPUs available"
fi
tmpYml="cluster-defns/.worker.yml"
if [ "$WORKER_GPUS" -gt "0" ] ; then
echo "GPU Worker YML"
cat $WORKER_GPU_YML > $tmpYml
update_worker_yml
else
echo "CPU Worker YML"
cat $WORKER_YML > $tmpYml
update_worker_yml
fi
if [ $? -ne 0 ] ; then
echo ""
echo "Failure: could not add a worker to the yml file."
exit_error
fi
WORKER_ID=$((WORKER_ID+1))
}
worker_size()
{
# Edit this file: /etc/ssd/sshd_config
#chmod 644 ~/.ssh/authorized_keys
#chmod 700 ~/.ssh
#RSAAuthentication yes
#PubkeyAuthentication yes
#AuthorizedKeysFile .ssh/authorized_keys
#PasswordAuthentication no
printf 'Please enter the number of extra workers you want to add (default: 0): '
read NUM_WORKERS
if [ "$NUM_WORKERS" == "" ] ; then
NUM_WORKERS=0
fi
if [ $NUM_WORKERS -gt 0 ] ; then
# No Nodemanager for Head node
NODE_MANAGER_HEAD=""
fi
i=0
while [ $i -lt $NUM_WORKERS ] ;
do
add_worker
i=$((i+1))
clear_screen
done
}
install_dir()
{
root="${AVAILABLE_DISK//G}"
mnt="${AVAILABLE_MNT//G}"
if [ "$mnt" != "" ] && [ $mnt -gt $root ] ; then
# Azure mounts disks here: /mnt/reosurce
if [ "$CLOUD" == "azure" ] ; then
sudo mkdir -p /mnt/resource/hops
sudo rm -rf /srv/hops
sudo ln -s /mnt/resource/hops /srv/hops
else
# AWS/GCP mount disks here: /mnt
sudo mkdir -p /mnt/hops
sudo rm -rf /srv/hops
sudo ln -s /mnt/hops /srv/hops
fi
fi
}
# called if interrupt signal is handled
TrapBreak()
{
trap "" HUP INT TERM
echo -e "\n\nInstallation cancelled by user!"
exit_error $EXIT_SIGNAL_CAUGHT
}
check_linux()
{
UNAME=$(uname | tr \"[:upper:]\" \"[:lower:]\")
# If Linux, try to determine specific distribution
if [ \"$UNAME\" == \"linux\" ]; then
# If available, use LSB to identify distribution
if [ -f /etc/lsb-release -o -d /etc/lsb-release.d ]; then
DISTRO=$(lsb_release -i | cut -d: -f2 | sed s/'^\t'//)
# Otherwise, use release info file
OS_VERSION=$(lsb_release -d | grep -o -E '[0-9]+' | head -1)
else
DISTRO=$(ls -d /etc/[A-Za-z]*[_-][rv]e[lr]* | grep -v \"lsb\" | cut -d'/' -f3 | cut -d'-' -f1 | cut -d'_' -f1 | head -1)
if [ "$DISTRO" == "Ubuntu" ] || [ "$DISTRO" == "debian" ] ; then
sudo apt install lsb-core -y
OS_VERSION=$(lsb_release -d | grep -o -E '[0-9]+' | head -1)
DISTRO="Ubuntu"
elif [ "${DISTRO,,}" == "centos" ] || [ "${DISTRO,,}" == "os" ] ; then
sudo yum install redhat-lsb-core -y
else
echo "Could not recognize Linux distro: $DISTRO"
echo ""
echo "Please select your Linux OS distribution"
echo ""
echo "(1) Centos/RedHat."
echo ""
echo "(2) Debian/Ubuntu."
echo ""
echo "(3) Other."
echo ""
printf 'Please enter your choice '1', '2', '3': '
read ACCEPT
case $ACCEPT in
1)
DISTRO="centos"
;;
2)
DISTRO="Ubuntu"
;;
*)
echo ""
exit_error "Invalid Linux version. Only Centos or Ubuntu supported."
;;
esac
fi
fi
else
exit_error "This script only works for Linux."
fi
}
check_userid()
{
# Check if user is root
USERID=`id | sed -e 's/).*//; s/^.*(//;'`
if [ "X$USERID" == "Xroot" ]; then
exit_error "This script only works for non-root users."
fi
}
purge_local()
{
echo "Shutting down services..."
if sudo test -f "/srv/hops/kagent/kagent/bin/shutdown-all-local-services.sh" ; then
sudo /srv/hops/kagent/kagent/bin/shutdown-all-local-services.sh -f > /dev/null
fi
echo "Killing karamel..."
pkill java
echo "Removing karamel..."
rm -rf ~/karamel*
echo "Removing cookbooks..."
sudo rm -rf ~/.karamel