Skip to content

Commit

Permalink
[#2651] feat(docker): optimize start.sh in Doris container (#2652)
Browse files Browse the repository at this point in the history
### What changes were proposed in this pull request?

- Optimize`startup.sh`, cat log to stdout
- Add disk space check before starting Doris
- Exit when FE or BE start failed


### Why are the changes needed?


Fix: #2651 

### Does this PR introduce _any_ user-facing change?

N/A

### How was this patch tested?

UT
  • Loading branch information
zhoukangcn authored Mar 27, 2024
1 parent 7f1f218 commit ce50754
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 4 deletions.
2 changes: 1 addition & 1 deletion dev/docker/doris/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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/*

################################################################################
Expand Down
35 changes: 32 additions & 3 deletions dev/docker/doris/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -28,21 +43,35 @@ ${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
url="http://localhost:8030/api/bootstrap"
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
tail -f ${DORIS_FE_HOME}/log/fe.log ${DORIS_BE_HOME}/log/be.log
3 changes: 3 additions & 0 deletions docs/docker-image-details.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ce50754

Please sign in to comment.