-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupgrade-clickhouse.sh
45 lines (39 loc) · 1.48 KB
/
upgrade-clickhouse.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
echo "${_group}Upgrading Clickhouse ..."
# .env 파일에서 환경변수 불러오기
ENV_FILE_PATH=".env"
if [ -f "$ENV_FILE_PATH" ]; then
export $(grep -v '^#' "$ENV_FILE_PATH" | xargs)
else
echo "$ENV_FILE_PATH 파일을 찾을 수 없습니다."
exit 1
fi
function wait_for_clickhouse() {
# Wait for clickhouse
RETRIES=30
until $dc ps clickhouse | grep 'healthy' || [ $RETRIES -eq 0 ]; do
echo "Waiting for clickhouse server, $((RETRIES--)) remaining attempts..."
sleep 1
done
}
# First check to see if user is upgrading by checking for existing clickhouse volume
if [[ -n "$(docker volume ls -q --filter name=sentry-$UNIQUE_KEY-clickhouse)" ]]; then
# Start clickhouse if it is not already running
$dc up -d clickhouse
# Wait for clickhouse
wait_for_clickhouse
# In order to get to 23.8, we need to first upgrade go from 21.8 -> 22.8 -> 23.3 -> 23.8
version=$($dc exec clickhouse clickhouse-client -q 'SELECT version()')
if [[ "$version" == "21.8.13.1.altinitystable" || "$version" == "21.8.12.29.altinitydev.arm" ]]; then
$dc down clickhouse
$dcb --build-arg BASE_IMAGE=altinity/clickhouse-server:22.8.15.25.altinitystable clickhouse
$dc up -d clickhouse
wait_for_clickhouse
$dc down clickhouse
$dcb --build-arg BASE_IMAGE=altinity/clickhouse-server:23.3.19.33.altinitystable clickhouse
$dc up -d clickhouse
wait_for_clickhouse
else
echo "Detected clickhouse version $version. Skipping upgrades!"
fi
fi
echo "${_endgroup}"