Skip to content

World's most powerful open data catalog for building a high-performance, geo-distributed and federated metadata lake.

[#2651] feat(docker): optimize start.sh in Doris container (#2652)

Kangce5075483ece
diff --git a/dev/docker/doris/Dockerfile b/dev/docker/doris/Dockerfile
index f655d56e59..90016b1110 100644
--- a/dev/docker/doris/Dockerfile
+++ b/dev/docker/doris/Dockerfile
@@ -17,7 +17,7 @@ RUN apt-get update -y && DEBIAN_FRONTEND=noninteractive apt-get install -y --no
curl wget less vim htop iproute2 numactl jq iotop sysstat tzdata xz-utils \
tcpdump iputils-ping dnsutils strace lsof blktrace \
bpfcc-tools linux-headers-realtime linux-tools-realtime silversearcher-ag \
- net-tools openjdk-8-jdk && \
+ net-tools netcat openjdk-8-jdk && \
rm -rf /var/lib/apt/lists/*
################################################################################
diff --git a/dev/docker/doris/start.sh b/dev/docker/doris/start.sh
index 7ed373159f..dec026d866 100644
--- a/dev/docker/doris/start.sh
+++ b/dev/docker/doris/start.sh
@@ -9,6 +9,21 @@ DORIS_HOME="$(cd "${DORIS_HOME}">/dev/null; pwd)"
DORIS_FE_HOME="${DORIS_HOME}/fe/"
DORIS_BE_HOME="${DORIS_HOME}/be/"
+# print the disk usage
+echo "Disk usage:"
+df -h
+
+# check free disk space, if little then 6GB, Doris FE (version < 2.1.0) can not start
+# TODO: change the threshold to 2GB when Doris Version is up to 2.1.0, add bdbje_free_disk_bytes to fe.conf
+THRESHOLD=6
+
+DISK_FREE=`df -BG | grep '/$' | tr -s ' ' | cut -d ' ' -f4 | grep -o '[0-9]*'`
+if [ "$DISK_FREE" -lt "$THRESHOLD" ]
+then
+ echo "ERROR: Doris FE (version < 2.1.0) can not start with less than ${THRESHOLD}G disk space."
+ exit 1
+fi
+
# comment a code snippet about max_map_count, it's not necessary for IT environment
DORIS_BE_SCRIPT="${DORIS_BE_HOME}/bin/start_be.sh"
@@ -28,6 +43,7 @@ ${DORIS_FE_HOME}/bin/start_fe.sh --daemon
${DORIS_BE_HOME}/bin/start_be.sh --daemon
# wait for the fe to start
+fe_started=false
for i in {1..10}; do
sleep 5
# check http://localhost:8030/api/bootstrap return contains content '"msg":"success"' to see if the fe is ready
@@ -35,14 +51,27 @@ for i in {1..10}; do
response=$(curl --silent --request GET $url)
if echo "$response" | grep -q "\"msg\":\"success\""; then
- break
+ fe_started=true
+ break
else
- echo "waiting for the fe to start"
+ echo "waiting for the fe to start"
fi
done
+if [ "$fe_started" = false ]; then
+ echo "Doris fe failed to start"
+
+ cat ${DORIS_FE_HOME}/log/fe.*
+ exit 1
+fi
+
# add the be to the fe
mysql -h127.0.0.1 -P9030 -uroot -e "ALTER SYSTEM ADD BACKEND '${CONTAINER_IP}:9050'"
+if [ $? -ne 0 ]; then
+ echo "Failed to add the BE to the FE"
+ exit 1
+fi
+
# persist the container
-tail -f /dev/null
\ No newline at end of file
+tail -f ${DORIS_FE_HOME}/log/fe.log ${DORIS_BE_HOME}/log/be.log
diff --git a/docs/docker-image-details.md b/docs/docker-image-details.md
index 9c826da483..52ea9b7858 100644
--- a/docs/docker-image-details.md
+++ b/docs/docker-image-details.md
@@ -166,6 +166,9 @@ You can use this image to test Apache Doris.
Changelog
+- gravitino-ci-doris:0.1.1
+ - Optimize `start.sh`, add disk space check before starting Doris, exit when FE or BE start failed, add log to stdout
+
- gravitino-ci-doris:0.1.0
- Docker image `datastrato/gravitino-ci-doris:0.1.0`
- Start Doris BE & FE in one container