hbase-exporter/tests/hbase-setup.sh

65 lines
1.5 KiB
Bash
Raw Normal View History

2021-03-03 17:58:43 +00:00
#!/usr/bin/env bash
2021-03-03 18:23:52 +00:00
set -ueo pipefail
2021-03-03 17:58:43 +00:00
HBASE_VERSION="2.4.1"
HBASE_FILE="hbase-${HBASE_VERSION}-bin.tar.gz"
HBASE_URL="https://downloads.apache.org/hbase/${HBASE_VERSION}/${HBASE_FILE}"
HBASE_FILE_CKSUM="5afb643c2391461619516624168e042b42a66e25217a3319552264c6af522e3a21a5212bfcba759b7b976794648ef13ee7b5a415f33cdb89bba43d40162aa685"
HBASE_HOST="127.0.0.1"
2021-03-04 19:59:36 +00:00
HBASE_CONFIG="hbase/conf/hbase-site.xml"
2021-03-03 17:58:43 +00:00
declare -a DEPS=("java")
check_dependencies() {
for i in "${DEPS[@]}"
do
if [[ -z $(which "${i}") ]]; then
error "Could not find ${i}"
exit 1
fi
done
}
download() {
if [ -f "$HBASE_FILE" ]; then
CKSUM="$(sha512 -q ${HBASE_FILE})"
if [ "$CKSUM" = "$HBASE_FILE_CKSUM" ]; then
2021-03-03 21:17:29 +00:00
printf "HBase archive exists\n"
2021-03-03 17:58:43 +00:00
fi
else
2021-03-03 21:17:29 +00:00
printf "Downloading ${1}\n"
2021-03-03 17:58:43 +00:00
curl -LO ${1}
fi
2021-03-04 19:59:36 +00:00
printf "Extracting HBase archive\n"
2021-03-03 17:58:43 +00:00
tar xfz ${HBASE_FILE}
2021-03-04 19:59:36 +00:00
mv hbase-${HBASE_VERSION} hbase/
2021-03-03 17:58:43 +00:00
}
create_config() {
2021-03-04 19:59:36 +00:00
printf "Writing HBase config\n"
2021-03-04 16:45:34 +00:00
cat <<EOF > $2
2021-03-03 17:58:43 +00:00
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
<property>
<name>hbase.rootdir</name>
2021-03-04 16:45:34 +00:00
<value>file:///${1}/hbase</value>
2021-03-03 17:58:43 +00:00
</property>
<property>
<name>hbase.zookeeper.property.dataDir</name>
<value>${1}/zookeeper</value>
</property>
2021-03-04 16:45:34 +00:00
<property>
<name>hbase.unsafe.stream.capability.enforce</name>
<value>false</value>
</property>
2021-03-03 17:58:43 +00:00
</configuration>
EOF
}
check_dependencies
download ${HBASE_URL}
2021-03-04 19:59:36 +00:00
create_config "/tmp" ${HBASE_CONFIG}