/
install_deps.sh
executable file
·995 lines (884 loc) · 29.9 KB
/
install_deps.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
#!/usr/bin/env bash
#
# A script to install dependencies of GraphScope.
# TODO: check dependencies revise
# TODO: install depedencies faster
set -e
set -o pipefail
# color
readonly RED="\033[0;31m"
readonly YELLOW="\033[1;33m"
readonly GREEN="\033[0;32m"
readonly NC="\033[0m" # No Color
readonly GRAPE_BRANCH="master" # libgrape-lite branch
readonly V6D_VERSION="0.5.0" # vineyard version
readonly V6D_BRANCH="v0.5.0" # vineyard branch
readonly OUTPUT_ENV_FILE="${HOME}/.graphscope_env"
IS_IN_WSL=false && [[ ! -z "${IS_WSL}" || ! -z "${WSL_DISTRO_NAME}" ]] && IS_IN_WSL=true
readonly IS_IN_WSL
DEPS_PREFIX="/usr/local"
BASIC_PACKGES_TO_INSTALL=
PLATFORM=
OS_VERSION=
VERBOSE=false
CN_MIRROR=false
packages_to_install=()
err() {
echo -e "${RED}[$(date +'%Y-%m-%dT%H:%M:%S%z')]: [ERROR] $*${NC}" >&2
}
warning() {
echo -e "${YELLOW}[$(date +'%Y-%m-%dT%H:%M:%S%z')]: [WARNING] $*${NC}" >&1
}
log() {
echo -e "[$(date +'%Y-%m-%dT%H:%M:%S%z')]: $*" >&1
}
succ() {
echo -e "${GREEN}[$(date +'%Y-%m-%dT%H:%M:%S%z')]: $*${NC}" >&1
}
##########################
# Output useage information.
# Globals:
# None
# Arguments:
# None
##########################
usage() {
cat <<END
A script to install dependencies of GraphScope.
Usage: install_deps options
Options:
-h, --help Print help information
--verbose Print the debug logging information
--k8s Install the dependencies for running GraphScope on k8s locally
--dev Install the dependencies for build GraphScope on local
--cn Use tsinghua mirror for brew when install dependencies on macOS
END
}
##########################
# Check dir exists and remove it.
##########################
check_and_remove_dir() {
if [[ -d $1 ]]; then
log "Found $1 exists, remove it."
rm -fr $1
fi
}
##########################
# Get OS platform and version
# Globals:
# PLATFORM
# OS_VERSION
# Reference:
# https://unix.stackexchange.com/questions/6345/how-can-i-get-distribution-name-and-version-number-in-a-simple-shell-script
##########################
get_os_version() {
if [ -f /etc/os-release ]; then
# freedesktop.org and systemd
. /etc/os-release
PLATFORM="${NAME}"
OS_VERSION="${VERSION_ID}"
elif type lsb_release >/dev/null 2>&1; then
# linuxbase.org
PLATFORM=$(lsb_release -si)
OS_VERSION=$(lsb_release -sr)
elif [ -f /etc/lsb-release ]; then
# For some versions of Debian/Ubuntu without lsb_release command
. /etc/lsb-release
PLATFORM="${DISTRIB_ID}"
OS_VERSION="${DISTRIB_RELEASE}"
elif [ -f /etc/debian_version ]; then
# Older Debian/Ubuntu/etc.
PLATFORM=Debian
OS_VERSION=$(cat /etc/debian_version)
elif [ -f /etc/centos-release ]; then
# Older Red Hat, CentOS, etc.
PLATFORM=CentOS
OS_VERSION=$(sed 's/.* \([0-9]\).*/\1/' < /etc/centos-release)
else
# Fall back to uname, e.g. "Linux <version>", also works for BSD, Darwin, etc.
PLATFORM=$(uname -s)
OS_VERSION=$(uname -r)
fi
readonly PLATFORM
readonly OS_VERSION
}
##########################
# Check the compatibility of platform and script.
##########################
check_os_compatibility() {
if [[ "${is_in_wsl}" == true && -z "${WSL_INTEROP}" ]]; then
err "GraphScope does not support to run on WSL1, please use WSL2."
exit 1
fi
if [[ "${PLATFORM}" != *"Ubuntu"* && "${PLATFORM}" != *"CentOS"* && "${PLATFORM}" != *"Darwin"* ]]; then
err "The script is only support platforms of Ubuntu/CentOS/macOS"
exit 1
fi
if [[ "${PLATFORM}" == *"Ubuntu"* && "$(echo ${OS_VERSION} | sed 's/\([0-9]\)\([0-9]\).*/\1\2/')" -lt "20" ]]; then
err "The version of Ubuntu is ${OS_VERSION}. This script requires Ubuntu 20 or greater."
exit 1
fi
if [[ "${PLATFORM}" == *"CentOS"* && "${OS_VERSION}" -lt "8" ]]; then
err "The version of CentOS is ${OS_VERSION}. This script requires CentOS 8 or greater."
exit 1
fi
log "Runing on ${PLATFORM} ${OS_VERSION}"
}
init_basic_packages() {
if [[ "${PLATFORM}" == *"Ubuntu"* ]]; then
BASIC_PACKGES_TO_INSTALL=(
build-essential
wget
curl
lsb-release
libbrotli-dev
libbz2-dev
libclang-dev
libcurl4-openssl-dev
protobuf-compiler-grpc
libevent-dev
libgflags-dev
libgoogle-glog-dev
libgrpc-dev
libgrpc++-dev
libgtest-dev
libgsasl7-dev
libtinfo5
libkrb5-dev
liblz4-dev
libprotobuf-dev
librdkafka-dev
libre2-dev
libsnappy-dev
libssl-dev
libunwind-dev
libutf8proc-dev
libxml2-dev
libz-dev
libzstd-dev
lsb-release
zlib1g-dev
uuid-dev
zip
perl
python3-pip
git
rapidjson-dev
libmsgpack-dev
golang-go
)
elif [[ "${PLATFORM}" == *"CentOS"* ]]; then
BASIC_PACKGES_TO_INSTALL=(
autoconf
automake
clang-devel
git
zlib-devel
libcurl-devel
libevent-devel
libgsasl-devel
librdkafka-devel
libunwind-devel
libuuid-devel
libxml2-devel
libzip
libzip-devel
m4
minizip
minizip-devel
net-tools
openssl-devel
unzip
which
zip
bind-utils
perl
libarchive
gflags-devel
glog-devel
gtest-devel
gcc
gcc-c++
make
wget
curl
rapidjson-devel
msgpack-devel
golang
)
else
BASIC_PACKGES_TO_INSTALL=(
coreutils
protobuf
glog
gflags
grpc
zstd
snappy
lz4
openssl
libevent
librdkafka
autoconf
wget
libomp
rapidjson
msgpack-cxx
go
)
fi
readonly BASIC_PACKGES_TO_INSTALL
}
##########################
# Check the dependencies of deploy command.
##########################
check_dependencies() {
log "Checking dependencies for building GraphScope."
# check python3 >= 3.7
if ! command -v python3 &> /dev/null ||
[[ "$(python3 -V 2>&1 | sed 's/.* \([0-9]\).\([0-9]\).*/\1\2/')" -lt "37" ]]; then
if [[ "${PLATFORM}" == *"CentOS"* ]]; then
packages_to_install+=(python3-devel)
else
packages_to_install+=(python3)
fi
fi
# check cmake >= 3.1
if $(! command -v cmake &> /dev/null) || \
[[ "$(cmake --version 2>&1 | awk -F ' ' '/version/ {print $3}')" < "3.1" ]]; then
packages_to_install+=(cmake)
fi
# check java
if [[ "${PLATFORM}" == *"Darwin"* ]]; then
if [[ ! -z "${JAVA_HOME}" ]]; then
declare -r java_version=$(${JAVA_HOME}/bin/javac -version 2>&1 | awk -F ' ' '{print $2}' | awk -F '.' '{print $1}')
if [[ "${java_version}" -lt "8" ]] || [[ "${java_version}" -gt "15" ]]; then
warning "Found the java version is ${java_version}, do not meet the requirement of GraphScope."
warning "Would install jdk 11 instead and reset the JAVA_HOME"
JAVA_HOME="" # reset JAVA_HOME to jdk11
packages_to_install+=(openjdk@11)
fi
else
if [[ ! -f "/usr/libexec/java_home" ]] || \
! /usr/libexec/java_home -v11 &> /dev/null; then
packages_to_install+=(openjdk@11)
fi
fi
else
if $(! command -v javac &> /dev/null) || \
[[ "$(javac -version 2>&1 | awk -F ' ' '{print $2}' | awk -F '.' '{print $1}')" -lt "7" ]]; then
if [[ "${PLATFORM}" == *"Ubuntu"* ]]; then
packages_to_install+=(default-jdk)
else
packages_to_install+=(java-11-openjdk-devel) # CentOS
fi
fi
fi
# check boost >= 1.66
if [[ ( ! -f "/usr/include/boost/version.hpp" || \
"$(grep "#define BOOST_VERSION" /usr/include/boost/version.hpp | cut -d' ' -f3)" -lt "106600" ) && \
( ! -f "/usr/local/include/boost/version.hpp" || \
"$(grep "#define BOOST_VERSION" /usr/local/include/boost/version.hpp | cut -d' ' -f3)" -lt "106600" ) && \
( ! -f "/opt/homebrew/include/boost/version.hpp" || \
"$(grep "#define BOOST_VERSION" /opt/homebrew/include/boost/version.hpp | cut -d' ' -f3)" -lt "106600" ) ]]; then
case "${PLATFORM}" in
*"Ubuntu"*)
packages_to_install+=(libboost-all-dev)
;;
*"CentOS"*)
packages_to_install+=(boost-devel)
;;
*)
packages_to_install+=(boost)
;;
esac
fi
# check apache-arrow
if [[ ! -f "/usr/local/include/arrow/api.h" && ! -f "/usr/include/arrow/api.h" &&
! -f "/opt/homebrew/include/arrow/api.h" ]]; then
packages_to_install+=(apache-arrow)
fi
# check maven
if ! command -v mvn &> /dev/null; then
packages_to_install+=(maven)
fi
# check rust > 1.52.0
if ( ! command -v rustup &> /dev/null || \
[[ "$(rustc --V | awk -F ' ' '{print $2}')" < "1.52.0" ]] ) && \
( ! command -v ${HOME}/.cargo/bin/rustup &> /dev/null || \
[[ "$(${HOME}/.cargo/bin/rustc --V | awk -F ' ' '{print $2}')" < "1.52.0" ]] ); then
packages_to_install+=(rust)
fi
# check etcd
if ! command -v etcd &> /dev/null; then
packages_to_install+=(etcd)
fi
# check mpi
if ! command -v mpiexec &> /dev/null; then
if [[ "${PLATFORM}" == *"Ubuntu"* ]]; then
packages_to_install+=(libopenmpi-dev)
else
packages_to_install+=(openmpi)
fi
fi
# check c++ compiler
if [[ "${PLATFORM}" == *"Darwin"* ]]; then
if [[ ! -z "$(brew info llvm 2>&1 | grep 'Not installed')" ]];then
packages_to_install+=("llvm")
fi
else
if ! command -v g++ &> /dev/null; then
if [[ "${PLATFORM}" == *"Ubuntu"* ]]; then
packages_to_install+=(build-essential)
else
packages_to_install+=(gcc gcc-c++)
fi
fi
fi
}
##########################
# Write out the related environment export statements to file.
# Globals:
# PLATFORM
# Arguments:
# None
# Outputs:
# output environment export statements to file.
##########################
write_envs_config() {
if [ -f "${OUTPUT_ENV_FILE}" ]; then
warning "Found ${OUTPUT_ENV_FILE} exists, remove the environmen config file and generate a new one."
rm -fr ${OUTPUT_ENV_FILE}
fi
if [[ "${PLATFORM}" == *"Darwin"* ]]; then
if [[ "$(uname -m)" == *"x86_64"* ]]; then
declare -r homebrew_prefix=/usr/local
else
# Apple Silicon: packages are installed under /opt/homebrew by default
declare -r homebrew_prefix=/opt/homebrew
fi
{
echo "export CC=${homebrew_prefix}/opt/llvm/bin/clang"
echo "export CXX=${homebrew_prefix}/opt/llvm/bin/clang++"
if [ -z "${JAVA_HOME}" ]; then
echo "export JAVA_HOME=\$(/usr/libexec/java_home -v11)"
fi
echo "export PATH=\$HOME/.cargo/bin:\${JAVA_HOME}/bin:/usr/local/go/bin:\$PATH"
echo "export PATH=\$(go env GOPATH)/bin:\$PATH"
echo "export OPENSSL_ROOT_DIR=${homebrew_prefix}/opt/openssl"
echo "export OPENSSL_LIBRARIES=${homebrew_prefix}/opt/openssl/lib"
echo "export OPENSSL_SSL_LIBRARY=${homebrew_prefix}/opt/openssl/lib/libssl.dylib"
} >> ${OUTPUT_ENV_FILE}
elif [[ "${PLATFORM}" == *"Ubuntu"* ]]; then
{
echo "export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/lib:/usr/local/lib64"
if [ -z "${JAVA_HOME}" ]; then
echo "export JAVA_HOME=/usr/lib/jvm/default-java"
fi
echo "export PATH=\${JAVA_HOME}/bin:\$HOME/.cargo/bin:/usr/local/go/bin:\$PATH"
echo "export PATH=\$(go env GOPATH)/bin:\$PATH"
} >> ${OUTPUT_ENV_FILE}
else
{
echo "export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/lib:/usr/local/lib64"
if [ -z "${JAVA_HOME}" ]; then
echo "export JAVA_HOME=/usr/lib/jvm/java"
fi
echo "export PATH=\${JAVA_HOME}/bin:\$HOME/.cargo/bin:\$PATH:/usr/local/go/bin"
echo "export PATH=\$(go env GOPATH)/bin:\$PATH"
} >> ${OUTPUT_ENV_FILE}
fi
}
##########################
# Install libgrape-lite.
# Globals:
# NUM_PROC
# Arguments:
# None
# Outputs:
# output log to stdout, output error to stderr.
##########################
install_libgrape-lite() {
log "Building and installing libgrape-lite."
if [[ -f "/usr/local/include/grape/grape.h" ]]; then
log "libgrape-lite already installed, skip."
return 0
fi
check_and_remove_dir "/tmp/libgrape-lite"
git clone -b ${GRAPE_BRANCH} --single-branch --depth=1 \
https://github.com/alibaba/libgrape-lite.git /tmp/libgrape-lite
pushd /tmp/libgrape-lite
mkdir -p build && cd build
cmake ..
make -j$(nproc)
sudo make install
popd
rm -fr /tmp/libgrape-lite
}
##########################
# Install vineyard.
# Globals:
# PLATFORM
# NUM_PROC
# Arguments:
# None
# Outputs:
# output log to stdout, output error to stderr.
##########################
install_vineyard() {
log "Building and installing vineyard."
if command -v /usr/local/bin/vineyardd &> /dev/null && \
[[ "$(/usr/local/bin/vineyardd --version 2>&1 | awk -F ' ' '{print $3}')" == "${V6D_VERSION}" ]]; then
log "vineyard ${V6D_VERSION} already installed, skip."
return 0
fi
check_and_remove_dir "/tmp/v6d"
git clone -b ${V6D_BRANCH} --single-branch --depth=1 \
https://github.com/v6d-io/v6d.git /tmp/v6d
pushd /tmp/v6d
git submodule update --init
mkdir -p build && pushd build
cmake .. -DCMAKE_INSTALL_PREFIX=${DEPS_PREFIX} \
-DBUILD_SHARED_LIBS=ON \
-DBUILD_VINEYARD_TESTS=OFF
make -j$(nproc)
sudo make install && popd
popd
rm -fr /tmp/v6d
}
##########################
# Install cppkafka.
# Globals:
# PLATFORM
# NUM_PROC
# Arguments:
# None
# Outputs:
# output log to stdout, output error to stderr.
##########################
install_cppkafka() {
log "Building and installing cppkafka."
if [[ -f "/usr/local/include/cppkafka/cppkafka.h" ]]; then
log "cppkafka already installed, skip."
return 0
fi
if [[ "${PLATFORM}" == *"Darwin"* ]]; then
export LDFLAGS="-L/usr/local/opt/openssl@3/lib"
export CPPFLAGS="-I/usr/local/opt/openssl@3/include"
fi
check_and_remove_dir "/tmp/cppkafka"
git clone -b 0.4.0 --single-branch --depth=1 \
https://github.com/mfontanini/cppkafka.git /tmp/cppkafka
pushd /tmp/cppkafka
git submodule update --init
mkdir -p build && pushd build
cmake .. && make -j$(nproc)
sudo make install && popd
popd
rm -fr /tmp/cppkafka
}
##########################
# Install denpendencies of GraphScope.
# Globals:
# PLATFORM
# Arguments:
# None
# Outputs:
# output log to stdout, output error to stderr.
##########################
install_dependencies() {
# install dependencies for specific platforms.
if [[ "${PLATFORM}" == *"Ubuntu"* ]]; then
sudo apt-get update -y
log "Installing packages ${BASIC_PACKGES_TO_INSTALL[*]}"
sudo apt-get install -y ${BASIC_PACKGES_TO_INSTALL[*]}
if [[ "${packages_to_install[*]}" =~ "rust" ]]; then
# packages_to_install contains rust
log "Installing rust."
curl -sf -L https://static.rust-lang.org/rustup.sh | sh -s -- -y --profile minimal --default-toolchain 1.54.0
# remove rust from packages_to_install
packages_to_install=("${packages_to_install[@]/rust}")
fi
if [[ "${packages_to_install[*]}" =~ "apache-arrow" ]]; then
log "Installing apache-arrow."
wget -c https://apache.jfrog.io/artifactory/arrow/$(lsb_release --id --short | tr 'A-Z' 'a-z')/apache-arrow-apt-source-latest-$(lsb_release --codename --short).deb \
-P /tmp/
sudo apt install -y -V /tmp/apache-arrow-apt-source-latest-$(lsb_release --codename --short).deb
sudo apt update -y
sudo apt install -y libarrow-dev=3.0.0-1 libarrow-python-dev=3.0.0-1
# remove apache-arrow from packages_to_install
packages_to_install=("${packages_to_install[@]/apache-arrow}")
fi
if [[ ! -z "${packages_to_install}" ]]; then
log "Installing packages ${packages_to_install[*]}"
sudo apt install -y ${packages_to_install[*]}
fi
elif [[ "${PLATFORM}" == *"CentOS"* ]]; then
sudo dnf install -y dnf-plugins-core \
https://download-ib01.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
sudo dnf config-manager --set-enabled epel
sudo dnf config-manager --set-enabled powertools
log "Instralling packages ${BASIC_PACKGES_TO_INSTALL[*]}"
sudo dnf install -y ${BASIC_PACKGES_TO_INSTALL[*]}
if [[ "${packages_to_install[*]}" =~ "apache-arrow" ]]; then
log "Installing apache-arrow."
sudo dnf install -y epel-release || sudo dnf install -y \
https://dl.fedoraproject.org/pub/epel/epel-release-latest-$(cut -d: -f5 /etc/system-release-cpe | cut -d. -f1).noarch.rpm
sudo dnf install -y https://apache.jfrog.io/artifactory/arrow/centos/$(cut -d: -f5 /etc/system-release-cpe | cut -d. -f1)/apache-arrow-release-latest.rpm
sudo dnf install -y arrow-devel
# remove apache-arrow from packages_to_install
packages_to_install=("${packages_to_install[@]/apache-arrow}")
fi
if [[ "${packages_to_install[*]}" =~ "openmpi" ]]; then
log "Installing openmpi v4.0.5"
wget -c https://download.open-mpi.org/release/open-mpi/v4.0/openmpi-4.0.5.tar.gz -P /tmp
check_and_remove_dir "/tmp/openmpi-4.0.5"
tar zxvf /tmp/openmpi-4.0.5.tar.gz -C /tmp
pushd /tmp/openmpi-4.0.5 && ./configure --enable-mpi-cxx
make -j$(nproc)
sudo make install
popd
rm -fr /tmp/openmpi-4.0.5 /tmp/openmpi-4.0.5.tar.gz
packages_to_install=("${packages_to_install[@]/openmpi}")
fi
if [[ "${packages_to_install[*]}" =~ "etcd" ]]; then
log "Installing etcd v3.4.13"
check_and_remove_dir "/tmp/etcd-download-test"
mkdir -p /tmp/etcd-download-test
export ETCD_VER=v3.4.13 && \
export DOWNLOAD_URL=https://github.com/etcd-io/etcd/releases/download && \
curl -L ${DOWNLOAD_URL}/${ETCD_VER}/etcd-${ETCD_VER}-linux-amd64.tar.gz \
-o /tmp/etcd-${ETCD_VER}-linux-amd64.tar.gz
tar xzvf /tmp/etcd-${ETCD_VER}-linux-amd64.tar.gz \
-C /tmp/etcd-download-test --strip-components=1
sudo mv /tmp/etcd-download-test/etcd /usr/local/bin/
sudo mv /tmp/etcd-download-test/etcdctl /usr/local/bin/
rm -fr /tmp/etcd-${ETCD_VER}-linux-amd64.tar.gz /tmp/etcd-download-test
packages_to_install=("${packages_to_install[@]/etcd}")
fi
if [[ "${packages_to_install[*]}" =~ "rust" ]]; then
# packages_to_install contains rust
log "Installing rust."
curl -sf -L https://static.rust-lang.org/rustup.sh | sh -s -- -y --profile minimal --default-toolchain 1.54.0
# remove rust from packages_to_install
packages_to_install=("${packages_to_install[@]/rust}")
fi
if [[ ! -z "${packages_to_install}" ]]; then
log "Installing packages ${packages_to_install[*]}"
sudo dnf -y install ${packages_to_install[*]}
fi
log "Installing protobuf v.3.13.0"
wget -c https://github.com/protocolbuffers/protobuf/releases/download/v3.13.0/protobuf-all-3.13.0.tar.gz -P /tmp
check_and_remove_dir "/tmp/protobuf-3.13.0"
tar zxvf /tmp/protobuf-all-3.13.0.tar.gz -C /tmp/
pushd /tmp/protobuf-3.13.0
./configure --enable-shared --disable-static
make -j$(nproc)
sudo make install && ldconfig
popd
rm -fr /tmp/protobuf-all-3.13.0.tar.gz /tmp/protobuf-3.13.0
log "Installing grpc v1.33.1"
if [[ -d "/tmp/grpc" ]]; then
sudo rm -fr /tmp/grpc
fi
git clone --depth 1 --branch v1.33.1 https://github.com/grpc/grpc.git /tmp/grpc
pushd /tmp/grpc
git submodule update --init
mkdir -p build && cd build
cmake .. -DBUILD_SHARED_LIBS=ON \
-DgRPC_INSTALL=ON \
-DgRPC_BUILD_TESTS=OFF \
-DgRPC_BUILD_CSHARP_EXT=OFF \
-DgRPC_BUILD_GRPC_CSHARP_PLUGIN=OFF \
-DgRPC_BUILD_GRPC_NODE_PLUGIN=OFF \
-DgRPC_BUILD_GRPC_OBJECTIVE_C_PLUGIN=OFF \
-DgRPC_BUILD_GRPC_PHP_PLUGIN=OFF \
-DgRPC_BUILD_GRPC_PYTHON_PLUGIN=OFF \
-DgRPC_BUILD_GRPC_RUBY_PLUGIN=OFF \
-DgRPC_BACKWARDS_COMPATIBILITY_MODE=ON \
-DgRPC_PROTOBUF_PROVIDER=package \
-DgRPC_ZLIB_PROVIDER=package \
-DgRPC_SSL_PROVIDER=package
make -j$(nproc)
sudo make install
popd
rm -fr /tmp/grpc
elif [[ "${PLATFORM}" == *"Darwin"* ]]; then
if [[ ${CN_MIRROR} == true ]]; then
# set brew to tsinghua mirror
export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git"
export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git"
export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles"
fi
log "Installing packages ${BASIC_PACKGES_TO_INSTALL[*]}"
export HOMEBREW_NO_INSTALL_CLEANUP=1
export HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1
brew install ${BASIC_PACKGES_TO_INSTALL[*]} || true
if [[ ${CN_MIRROR} == true && "${packages_to_install[*]}" =~ "openjdk@11" ]]; then
# packages_to_install contains jdk
log "Installing openjdk11."
wget -c https://graphscope.oss-cn-beijing.aliyuncs.com/dependencies/OpenJDK11U-jdk_x64_mac_hotspot_11.0.13_8.tar.gz \
-P /tmp
sudo tar xf /tmp/OpenJDK11U-jdk_x64_mac_hotspot_11.0.13_8.tar.gz -C /Library/Java/JavaVirtualMachines/
rm -fr /tmp/OpenJDK11U-jdk_x64_mac_hotspot_11.0.13_8.tar.gz
# remove jdk from packages_to_install
packages_to_install=("${packages_to_install[@]/openjdk@11}")
fi
if [[ "${packages_to_install[*]}" =~ "rust" ]]; then
# packages_to_install contains rust
log "Installing rust."
curl -sf -L https://static.rust-lang.org/rustup.sh | sh -s -- -y --profile minimal --default-toolchain 1.54.0
# remove rust from packages_to_install
packages_to_install=("${packages_to_install[@]/rust}")
fi
if [[ "${packages_to_install[*]}" =~ "maven" ]]; then
# install maven ignore openjdk dependencies
brew install --ignore-dependencies maven
packages_to_install=("${packages_to_install[@]/maven}")
fi
if [[ ! -z "${packages_to_install}" ]]; then
log "Installing packages ${packages_to_install[*]}"
brew install ${packages_to_install[*]} || true
fi
if [[ "$(uname -m)" == "x86_64" ]]; then
declare -r homebrew_prefix="/usr/local"
else
declare -r homebrew_prefix="/opt/homebrew"
fi
export OPENSSL_ROOT_DIR=${homebrew_prefix}/opt/openssl
export OPENSSL_LIBRARIES=${homebrew_prefix}/opt/openssl/lib
export OPENSSL_SSL_LIBRARY=${homebrew_prefix}/opt/openssl/lib/libssl.dylib
export CC=${homebrew_prefix}/opt/llvm/bin/clang
export CXX=${homebrew_prefix}/opt/llvm/bin/clang++
export CPPFLAGS=-I${homebrew_prefix}/opt/llvm/include
fi
log "Installing zetcd."
GO111MODULE="auto" go get github.com/etcd-io/zetcd/cmd/zetcd
sudo cp ${HOME}/go/bin/zetcd /usr/local/bin/zetcd
log "Installing python packages for vineyard codegen."
pip3 install -U pip --user
pip3 install grpcio-tools libclang parsec setuptools wheel twine --user
install_libgrape-lite
install_vineyard
install_cppkafka
log "Output environments config file ${OUTPUT_ENV_FILE}"
write_envs_config
}
# Functions to install dependencies of k8s evironment.
check_os_compatibility_k8s() {
if [[ "${IS_IN_WSL}" == true && -z "${WSL_INTEROP}" ]]; then
err "The platform is WSL1. GraphScope not support to run on WSL1, please use WSL2."
exit 1
fi
if [[ "${PLATFORM}" != *"Ubuntu"* && "${PLATFORM}" != *"CentOS"* ]]; then
err "The platform is not Ubuntu or CentOs. This script is only available on Ubuntu/CentOS"
exit 1
fi
if [[ "${PLATFORM}" == *"Ubuntu"* && "$(echo ${OS_VERSION} | sed 's/\([0-9]\)\([0-9]\).*/\1\2/')" -lt "18" ]]; then
err "The version of Ubuntu is ${OS_VERSION}. this script requires Ubuntu 18 or greater."
exit 1
fi
if [[ "${PLATFORM}" == *"CentOS"* && "${OS_VERSION}" -lt "7" ]]; then
err "The version of CentOS is ${OS_VERSION}. this script requires CentOS 7 or greater."
exit 1
fi
log "Preparing environment on ${PLATFORM} ${OS_VERSION}"
}
check_dependencies_version_k8s() {
# python
if ! hash python3; then
err "Python3 is not installed"
exit 1
fi
ver=$(python3 -V 2>&1 | sed 's/.* \([0-9]\).\([0-9]\).*/\1\2/')
if [ "$ver" -lt "37" ]; then
err "GraphScope requires python 3.7 or greater. Current version is ${python3 -V}"
exit 1
fi
}
install_dependencies_k8s() {
log "Install dependencies."
if [[ "${PLATFORM}" == *"Ubuntu"* ]]; then
sudo apt-get update -y
sudo apt-get install -y git
sudo apt-get install -y docker.io
sudo apt-get install -y conntrack curl lsof
sudo apt-get install -y python3-pip
sudo apt-get clean
elif [[ "${PLATFORM}" == *"CentOS"* ]]; then
sudo yum install -y git
sudo yum install -y python3-pip
sudo yum install -y yum-utils curl conntrack-tools lsof
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
sudo yum install -y docker-ce docker-ce-cli containerd.io
sudo yum clean all
fi
check_dependencies_version_k8s
pip3 install -U pip --user
pip3 install graphscope-client wheel --user
log "Install kubectl."
K8S_VERSION=$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)
curl -Lo kubectl https://storage.googleapis.com/kubernetes-release/release/"${K8S_VERSION}"/bin/linux/amd64/kubectl && \
chmod +x kubectl && sudo mv kubectl /usr/local/bin/ && sudo ln /usr/local/bin/kubectl /usr/bin/kubectl || true
log "Install kind."
curl -Lo ./kind https://github.com/kubernetes-sigs/kind/releases/download/v0.10.0/kind-linux-amd64
chmod +x kind && sudo mv kind /usr/local/bin/ && sudo ln /usr/local/bin/kind /usr/bin/kind || true
}
##########################
# Start docker daemon.
# Globals:
# None
# Arguments:
# None
# Returns:
# 0 if start successfully, non-zero on error.
##########################
start_docker() {
log "Starting doker daemon."
# start docker daemon if docker not running.
if ! sudo docker info >/dev/null 2>&1; then
if [[ "${IS_IN_WSL}" = false ]]; then
sudo systemctl start docker
else
sudo dockerd > /dev/null&
fi
fi
log "Docker started successfully."
}
##########################
# Launch kubenetes cluster with kind.
# Globals:
# None
# Arguments:
# None
# Returns:
# 0 if launched successfully, non-zero on error.
##########################
launch_k8s_cluster() {
log "Launching k8s cluster"
curl -Lo config-with-mounts.yaml https://kind.sigs.k8s.io/examples/config-with-mounts.yaml
# mount $HOME dir to cluster container, which is kind-control-plane
sed -i 's@/path/to/my/files/@'"${HOME}"'@g; s@/files@'"${HOME}"'@g' ./config-with-mounts.yaml || true
sudo kind create cluster --config config-with-mounts.yaml
sudo chown -R "$(id -u)":"$(id -g)" "${HOME}"/.kube || true
log "Cluster is launched successfully."
}
##########################
# Pull and load the GraphScope images to kind cluster.
# Globals:
# None
# Arguments:
# None
# Returns:
# 0 if successful, non-zero on error.
##########################
pull_images() {
log "Pulling GraphScope images."
image_tag=
# image_tag need to consistent with graphscope client version
if [ -z "${image_tag}" ]; then
image_tag=$(python3 -c "import graphscope; print(graphscope.__version__)")
fi
readonly image_tag
sudo docker pull registry.cn-hongkong.aliyuncs.com/graphscope/graphscope:${image_tag} || true
sudo docker pull quay.io/coreos/etcd:v3.4.13 || true
log "GraphScope images pulled successfully."
log "Loading images into kind cluster."
sudo kind load docker-image registry.cn-hongkong.aliyuncs.com/graphscope/graphscope:${image_tag} || true
sudo kind load docker-image quay.io/coreos/etcd:v3.4.13 || true
log "GraphScope images loaded into kind cluster successfully."
}
##########################
# Main function for installing dependencies of development.
# Globals:
# VERBOSE
# Arguments:
# None
# Outputs:
# output log to stdout, output error to stderr.
##########################
install_deps_dev() {
# parse args for install_deps_dev
while test $# -ne 0; do
arg=$1; shift
case ${arg} in
--verbose) VERBOSE=true; readonly VERBOSE; ;;
--cn) CN_MIRROR=true; readonly CN_MIRROR; ;;
--vineyard_prefix) DEPS_PREFIX=$1; readonly DEPS_PREFIX; shift ;;
*)
echo "unrecognized option '${arg}'"
usage; exit;;
esac
done
if [[ ${VERBOSE} == true ]]; then
set -x
fi
get_os_version
check_os_compatibility
init_basic_packages
check_dependencies
install_dependencies
succ_msg="The script has installed all dependencies for builing GraphScope, use commands:\n
$ source ${OUTPUT_ENV_FILE}
$ make graphscope\n
to build and develop GraphScope."
succ "${succ_msg}"
}
##########################
# Main function for installing dependencies of k8s environment.
# Globals:
# VERBOSE
# Arguments:
# None
# Outputs:
# output log to stdout, output error to stderr.
##########################
install_deps_k8s() {
OVERWRITE=false
while test $# -ne 0; do
arg=$1; shift
case ${arg} in
--verbose) VERBOSE=true; readonly VERBOSE; ;;
--overwrite) OVERWRITE=true; readonly OVERWRITE; ;;
*)
echo "unrecognized option '${arg}'"
usage; exit;;
esac
done
if [[ ${VERBOSE} == true ]]; then
set -x
fi
if [[ ${OVERWRITE} = false && -f "${HOME}/.kube/config" ]]; then
warning_msg="We found existing kubernetes config, seems that you already
have a ready kubernetes cluster. If you do want to reset the kubernetes
environment, please retry with '--overwrite' option."
warning "${warning_msg}"
exit 0
fi
get_os_version
check_os_compatibility_k8s
install_dependencies_k8s
start_docker
launch_k8s_cluster
pull_images
succ_msg="The script has prepared a local k8s cluster with kind to run GraphScope in distributed mode,
Now you are ready to have fun with GraphScope."
succ ${succ_msg}
}
if test $# -eq 0; then
usage; exit 1;
fi
# parse argv
while test $# -ne 0; do
arg=$1; shift
case ${arg} in
-h|--help) usage; exit ;;
--verbose) VERBOSE=true; readonly VERBOSE; ;;
--cn) CN_MIRROR=true; readonly CN_MIRROR; ;;
--dev) install_deps_dev "$@"; exit;;
--k8s) install_deps_k8s "$@"; exit;;
*)
echo "unrecognized option '${arg}'"
usage; exit 1;;
esac
done