Skip to content

Commit 26c8fb1

Browse files
rootglutenperfbot
authored andcommitted
Add setup script for cent7 (oap 408)
1 parent 7ecda9b commit 26c8fb1

File tree

1 file changed

+276
-0
lines changed

1 file changed

+276
-0
lines changed

scripts/setup-centos7.sh

Lines changed: 276 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,276 @@
1+
#!/bin/bash
2+
# Copyright (c) Facebook, Inc. and its affiliates.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
set -efx -o pipefail
17+
# Some of the packages must be build with the same compiler flags
18+
# so that some low level types are the same size. Also, disable warnings.
19+
SCRIPTDIR=$(dirname "${BASH_SOURCE[0]}")
20+
source $SCRIPTDIR/setup-helper-functions.sh
21+
DEPENDENCY_DIR=${DEPENDENCY_DIR:-/tmp/velox-deps}
22+
CPU_TARGET="${CPU_TARGET:-avx}"
23+
NPROC=$(getconf _NPROCESSORS_ONLN)
24+
FMT_VERSION=10.1.1
25+
export CFLAGS=$(get_cxx_flags $CPU_TARGET) # Used by LZO.
26+
export CXXFLAGS=$CFLAGS # Used by boost.
27+
export CPPFLAGS=$CFLAGS # Used by LZO.
28+
export PKG_CONFIG_PATH=/usr/local/lib64/pkgconfig:/usr/local/lib/pkgconfig:/usr/lib64/pkgconfig:/usr/lib/pkgconfig:$PKG_CONFIG_PATH
29+
FB_OS_VERSION=v2023.12.04.00
30+
31+
# shellcheck disable=SC2037
32+
SUDO="sudo -E"
33+
34+
function run_and_time {
35+
time "$@"
36+
{ echo "+ Finished running $*"; } 2> /dev/null
37+
}
38+
39+
function dnf_install {
40+
$SUDO dnf install -y -q --setopt=install_weak_deps=False "$@"
41+
}
42+
43+
function yum_install {
44+
$SUDO yum install -y "$@"
45+
}
46+
47+
function cmake_install_deps {
48+
cmake -B"$1-build" -GNinja -DCMAKE_CXX_STANDARD=17 \
49+
-DCMAKE_CXX_FLAGS="${CFLAGS}" -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCMAKE_BUILD_TYPE=Release -Wno-dev "$@"
50+
ninja -C "$1-build"
51+
$SUDO ninja -C "$1-build" install
52+
}
53+
54+
function wget_and_untar {
55+
local URL=$1
56+
local DIR=$2
57+
mkdir -p "${DIR}"
58+
wget -q --max-redirect 3 -O - "${URL}" | tar -xz -C "${DIR}" --strip-components=1
59+
}
60+
61+
function install_cmake {
62+
cd "${DEPENDENCY_DIR}"
63+
wget_and_untar https://cmake.org/files/v3.25/cmake-3.25.1.tar.gz cmake-3
64+
cd cmake-3
65+
./bootstrap --prefix=/usr/local
66+
make -j$(nproc)
67+
$SUDO make install
68+
cmake --version
69+
}
70+
71+
function install_ninja {
72+
cd "${DEPENDENCY_DIR}"
73+
github_checkout ninja-build/ninja v1.11.1
74+
./configure.py --bootstrap
75+
cmake -Bbuild-cmake
76+
cmake --build build-cmake
77+
$SUDO cp ninja /usr/local/bin/
78+
}
79+
80+
function install_folly {
81+
cd "${DEPENDENCY_DIR}"
82+
github_checkout facebook/folly "${FB_OS_VERSION}"
83+
cmake_install -DBUILD_TESTS=OFF -DFOLLY_HAVE_INT128_T=ON
84+
}
85+
86+
function install_conda {
87+
cd "${DEPENDENCY_DIR}"
88+
mkdir -p conda && cd conda
89+
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
90+
MINICONDA_PATH=/opt/miniconda-for-velox
91+
bash Miniconda3-latest-Linux-x86_64.sh -b -u $MINICONDA_PATH
92+
}
93+
94+
function install_openssl {
95+
cd "${DEPENDENCY_DIR}"
96+
wget_and_untar https://github.com/openssl/openssl/archive/refs/tags/OpenSSL_1_1_1s.tar.gz openssl
97+
cd openssl
98+
./config no-shared
99+
make depend
100+
make
101+
$SUDO make install
102+
}
103+
104+
function install_gflags {
105+
cd "${DEPENDENCY_DIR}"
106+
wget_and_untar https://github.com/gflags/gflags/archive/v2.2.2.tar.gz gflags
107+
cd gflags
108+
cmake_install -DBUILD_SHARED_LIBS=ON -DBUILD_STATIC_LIBS=ON -DBUILD_gflags_LIB=ON -DLIB_SUFFIX=64 -DCMAKE_INSTALL_PREFIX:PATH=/usr/local
109+
}
110+
111+
function install_glog {
112+
cd "${DEPENDENCY_DIR}"
113+
wget_and_untar https://github.com/google/glog/archive/v0.5.0.tar.gz glog
114+
cd glog
115+
cmake_install -DBUILD_SHARED_LIBS=ON -DBUILD_STATIC_LIBS=ON -DCMAKE_INSTALL_PREFIX:PATH=/usr/local
116+
}
117+
118+
function install_snappy {
119+
cd "${DEPENDENCY_DIR}"
120+
wget_and_untar https://github.com/google/snappy/archive/1.1.8.tar.gz snappy
121+
cd snappy
122+
cmake_install -DSNAPPY_BUILD_TESTS=OFF
123+
}
124+
125+
function install_dwarf {
126+
cd "${DEPENDENCY_DIR}"
127+
wget_and_untar https://github.com/davea42/libdwarf-code/archive/refs/tags/20210528.tar.gz dwarf
128+
cd dwarf
129+
#local URL=https://github.com/davea42/libdwarf-code/releases/download/v0.5.0/libdwarf-0.5.0.tar.xz
130+
#local DIR=dwarf
131+
#mkdir -p "${DIR}"
132+
#wget -q --max-redirect 3 "${URL}"
133+
#tar -xf libdwarf-0.5.0.tar.xz -C "${DIR}"
134+
#cd dwarf/libdwarf-0.5.0
135+
./configure --enable-shared=no
136+
make
137+
make check
138+
$SUDO make install
139+
}
140+
141+
function install_re2 {
142+
cd "${DEPENDENCY_DIR}"
143+
wget_and_untar https://github.com/google/re2/archive/refs/tags/2023-03-01.tar.gz re2
144+
cd re2
145+
$SUDO make install
146+
}
147+
148+
function install_flex {
149+
cd "${DEPENDENCY_DIR}"
150+
wget_and_untar https://github.com/westes/flex/releases/download/v2.6.4/flex-2.6.4.tar.gz flex
151+
cd flex
152+
./autogen.sh
153+
./configure
154+
$SUDO make install
155+
}
156+
157+
function install_lzo {
158+
cd "${DEPENDENCY_DIR}"
159+
wget_and_untar http://www.oberhumer.com/opensource/lzo/download/lzo-2.10.tar.gz lzo
160+
cd lzo
161+
./configure --prefix=/usr/local --enable-shared --disable-static --docdir=/usr/local/share/doc/lzo-2.10
162+
make "-j$(nproc)"
163+
$SUDO make install
164+
}
165+
166+
function install_boost {
167+
cd "${DEPENDENCY_DIR}"
168+
wget_and_untar https://boostorg.jfrog.io/artifactory/main/release/1.72.0/source/boost_1_72_0.tar.gz boost
169+
cd boost
170+
./bootstrap.sh --prefix=/usr/local --with-python=/usr/bin/python3 --with-python-root=/usr/lib/python3.6 --without-libraries=python
171+
$SUDO ./b2 "-j$(nproc)" -d0 install threading=multi
172+
}
173+
174+
function install_libhdfs3 {
175+
cd "${DEPENDENCY_DIR}"
176+
github_checkout apache/hawq master
177+
cd depends/libhdfs3
178+
sed -i "/FIND_PACKAGE(GoogleTest REQUIRED)/d" ./CMakeLists.txt
179+
sed -i "s/dumpversion/dumpfullversion/" ./CMake/Platform.cmake
180+
sed -i "s/dfs.domain.socket.path\", \"\"/dfs.domain.socket.path\", \"\/var\/lib\/hadoop-hdfs\/dn_socket\"/g" src/common/SessionConfig.cpp
181+
sed -i "s/pos < endOfCurBlock/pos \< endOfCurBlock \&\& pos \- cursor \<\= 128 \* 1024/g" src/client/InputStreamImpl.cpp
182+
cmake_install
183+
}
184+
185+
function install_protobuf {
186+
cd "${DEPENDENCY_DIR}"
187+
wget https://github.com/protocolbuffers/protobuf/releases/download/v21.4/protobuf-all-21.4.tar.gz
188+
tar -xzf protobuf-all-21.4.tar.gz
189+
cd protobuf-21.4
190+
./configure CXXFLAGS="-fPIC" --prefix=/usr/local
191+
make "-j$(nproc)"
192+
$SUDO make install
193+
}
194+
195+
function install_awssdk {
196+
cd "${DEPENDENCY_DIR}"
197+
github_checkout aws/aws-sdk-cpp 1.9.379 --depth 1 --recurse-submodules
198+
cmake_install -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS:BOOL=OFF -DMINIMIZE_SIZE:BOOL=ON -DENABLE_TESTING:BOOL=OFF -DBUILD_ONLY:STRING="s3;identity-management"
199+
}
200+
201+
function install_gtest {
202+
cd "${DEPENDENCY_DIR}"
203+
wget https://github.com/google/googletest/archive/refs/tags/release-1.12.1.tar.gz
204+
tar -xzf release-1.12.1.tar.gz
205+
cd googletest-release-1.12.1
206+
mkdir -p build && cd build && cmake -DBUILD_GTEST=ON -DBUILD_GMOCK=ON -DINSTALL_GTEST=ON -DINSTALL_GMOCK=ON -DBUILD_SHARED_LIBS=ON ..
207+
make "-j$(nproc)"
208+
$SUDO make install
209+
}
210+
211+
function install_fmt {
212+
rm -rf /usr/local/lib64/libfmt.a
213+
rm -rf /usr/local/lib64/cmake/fmt
214+
rm -rf /usr/local/include/fmt
215+
rm -rf fmt
216+
wget_and_untar https://github.com/fmtlib/fmt/archive/10.1.1.tar.gz fmt
217+
cmake_install fmt -DFMT_TEST=OFF
218+
}
219+
220+
function install_prerequisites {
221+
run_and_time install_lzo
222+
run_and_time install_boost
223+
run_and_time install_re2
224+
run_and_time install_flex
225+
run_and_time install_openssl
226+
run_and_time install_gflags
227+
run_and_time install_glog
228+
run_and_time install_snappy
229+
run_and_time install_dwarf
230+
}
231+
232+
function install_velox_deps {
233+
run_and_time install_fmt
234+
run_and_time install_folly
235+
run_and_time install_conda
236+
}
237+
238+
$SUDO dnf makecache
239+
240+
# dnf install dependency libraries
241+
dnf_install epel-release dnf-plugins-core # For ccache, ninja
242+
# PowerTools only works on CentOS8
243+
# dnf config-manager --set-enabled powertools
244+
dnf_install ccache git wget which libevent-devel \
245+
openssl-devel libzstd-devel lz4-devel double-conversion-devel \
246+
curl-devel cmake libxml2-devel libgsasl-devel libuuid-devel patch
247+
248+
$SUDO dnf remove -y gflags
249+
250+
# Required for Thrift
251+
dnf_install autoconf automake libtool bison python3 python3-devel
252+
253+
# Required for build flex
254+
dnf_install gettext-devel texinfo help2man
255+
256+
# dnf_install conda
257+
258+
# Activate gcc9; enable errors on unset variables afterwards.
259+
# GCC9 install via yum and devtoolset
260+
# dnf install gcc-toolset-9 only works on CentOS8
261+
262+
$SUDO yum makecache
263+
yum_install centos-release-scl
264+
yum_install devtoolset-9
265+
source /opt/rh/devtoolset-9/enable || exit 1
266+
gcc --version
267+
set -u
268+
269+
# Build from source
270+
[ -d "$DEPENDENCY_DIR" ] || mkdir -p "$DEPENDENCY_DIR"
271+
272+
run_and_time install_cmake
273+
run_and_time install_ninja
274+
275+
install_prerequisites
276+
install_velox_deps

0 commit comments

Comments
 (0)