Skip to content

Commit 0c1c5f0

Browse files
author
bingtao.yin
committed
update ide files
1 parent 7e0919d commit 0c1c5f0

File tree

4 files changed

+305
-2
lines changed

4 files changed

+305
-2
lines changed

.devcontainer/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ RUN \
3434
apt-get install -y ${PKGS} && \
3535
add-apt-repository -y ppa:ubuntu-toolchain-r/ppa && \
3636
apt-get update -y && \
37-
PKGS="vim sudo locales git curl unzip wget zip iputils-ping iproute2 tzdata tree" && \
38-
PKGS="${PKGS} gdb net-tools telnet ccache" && \
37+
PKGS="vim sudo locales git curl unzip wget zip iputils-ping iproute2 tzdata tree jq" && \
38+
PKGS="${PKGS} gdb net-tools telnet ccache linux-tools-common linux-tools-generic" && \
3939
apt-get install -y ${PKGS} && \
4040
locale-gen en_US.UTF-8 && \
4141
echo ${TZ} > /etc/timezone && \
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"cluster": [
3+
{
4+
"fe": 1,
5+
"be": 1
6+
},
7+
{
8+
"fe": 1,
9+
"be": 3
10+
}
11+
]
12+
}
Lines changed: 290 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,290 @@
1+
#!/bin/bash
2+
3+
project_dir=/opt/transwarp/doris
4+
be_output_dir=${project_dir}/output/be
5+
fe_output_dir=${project_dir}/output/fe
6+
cluster_config_file=/opt/transwarp/doris/.devcontainer/devtools/local_cluster.json
7+
cluster_base_path=/opt/doris_local_cluster/cluster
8+
9+
be_port=9060
10+
be_webserver_port=8040
11+
be_heartbeat_service_port=9050
12+
be_brpc_port=8060
13+
14+
fe_http_port=8030
15+
fe_rpc_port=9020
16+
fe_query_port=9030
17+
fe_edit_log_port=9010
18+
19+
function get_cluster_config {
20+
local cluster_id=${1:-0}
21+
22+
len=$(jq '.cluster | length' ${cluster_config_file})
23+
24+
if [ "${cluster_id}" -lt 0 ] || [ "${cluster_id}" -ge "${len}" ]; then
25+
echo "cluster id ${cluster_id} is out of range! (length=${len})"
26+
exit 1
27+
fi
28+
29+
fe_count=$(jq ".cluster[${cluster_id}].fe" ${cluster_config_file})
30+
be_count=$(jq ".cluster[${cluster_id}].be" ${cluster_config_file})
31+
echo "${fe_count} ${be_count}"
32+
}
33+
34+
function prepare_single_be {
35+
local cluster_id=$1
36+
local be_id=$2
37+
local be_path=${cluster_base_path}${cluster_id}/be${be_id}
38+
local target_be_port=$((be_port + be_id))
39+
local target_webserver_port=$((be_webserver_port + be_id))
40+
local target_heartbeat_service_port=$((be_heartbeat_service_port + be_id))
41+
local target_brpc_port=$((be_brpc_port + be_id))
42+
43+
mkdir -p ${be_path}
44+
45+
if [ ! -e "${be_path}/bin" ]; then
46+
cp -r -p ${be_output_dir}/bin ${be_path}/bin
47+
fi
48+
49+
if [ ! -e "${be_path}/conf" ]; then
50+
mkdir -p ${be_path}/conf
51+
cp -r -p ${project_dir}/conf/be.conf ${be_path}/conf/
52+
cp -r -p ${project_dir}/conf/lsan_suppr.conf ${be_path}/conf/
53+
cp -r -p ${project_dir}/conf/asan_suppr.conf ${be_path}/conf/
54+
cp -r -p ${project_dir}/conf/odbcinst.ini ${be_path}/conf/
55+
56+
# update be conf
57+
sed -i '/# priority_networks/a priority_networks = 127.0.0.1' ${be_path}/conf/be.conf
58+
sed -i 's/^be_port = .*/be_port = '"${target_be_port}"'/' ${be_path}/conf/be.conf
59+
sed -i 's/^webserver_port = .*/webserver_port = '"${target_webserver_port}"'/' ${be_path}/conf/be.conf
60+
sed -i 's/^heartbeat_service_port = .*/heartbeat_service_port = '"${target_heartbeat_service_port}"'/' ${be_path}/conf/be.conf
61+
sed -i 's/^brpc_port = .*/brpc_port = '"${target_brpc_port}"'/' ${be_path}/conf/be.conf
62+
fi
63+
64+
mkdir -p ${be_path}/connectors
65+
mkdir -p ${be_path}/jdbc_drivers
66+
mkdir -p ${be_path}/log
67+
mkdir -p ${be_path}/storage
68+
69+
if [ -d "${be_output_dir}/dict" ] && [ ! -e "${be_path}/dict" ]; then
70+
ln -s "${be_output_dir}/dict" "${be_path}/dict"
71+
fi
72+
73+
if [ -d "${be_output_dir}/lib" ] && [ ! -e "${be_path}/lib" ]; then
74+
ln -s "${be_output_dir}/lib" "${be_path}/lib"
75+
fi
76+
77+
if [ -d "${be_output_dir}/tools" ] && [ ! -e "${be_path}/tools" ]; then
78+
ln -s "${be_output_dir}/tools" "${be_path}/tools"
79+
fi
80+
81+
if [ -d "${be_output_dir}/www" ] && [ ! -e "${be_path}/www" ]; then
82+
ln -s "${be_output_dir}/www" "${be_path}/www"
83+
fi
84+
}
85+
86+
function prepare_single_fe {
87+
local cluster_id=$1
88+
local fe_id=$2
89+
local fe_path=${cluster_base_path}${cluster_id}/fe${fe_id}
90+
local target_fe_http_port=$((fe_http_port + fe_id))
91+
local target_fe_rpc_port=$((fe_rpc_port + fe_id))
92+
local target_fe_query_port=$((fe_query_port + fe_id))
93+
local target_fe_edit_log_port=$((fe_edit_log_port + fe_id))
94+
95+
mkdir -p ${fe_path}
96+
97+
if [ ! -e "${fe_path}/bin" ]; then
98+
cp -r -p ${fe_output_dir}/bin ${fe_path}/bin
99+
fi
100+
101+
if [ ! -e "${fe_path}/conf" ]; then
102+
mkdir -p ${fe_path}/conf
103+
mkdir -p ${fe_path}/ssl
104+
cp -r -p ${project_dir}/conf/fe.conf ${fe_path}/conf/
105+
cp -r -p ${project_dir}/conf/ldap.conf ${fe_path}/conf/
106+
107+
# update fe conf
108+
sed -i '/# priority_networks/a priority_networks = 127.0.0.1' ${fe_path}/conf/fe.conf
109+
sed -i 's/^http_port = .*/http_port = '"${target_fe_http_port}"'/' ${fe_path}/conf/fe.conf
110+
sed -i 's/^rpc_port = .*/rpc_port = '"${target_fe_rpc_port}"'/' ${fe_path}/conf/fe.conf
111+
sed -i 's/^query_port = .*/query_port = '"${target_fe_query_port}"'/' ${fe_path}/conf/fe.conf
112+
sed -i 's/^edit_log_port = .*/edit_log_port = '"${target_fe_edit_log_port}"'/' ${fe_path}/conf/fe.conf
113+
fi
114+
115+
mkdir -p ${fe_path}/connectors
116+
mkdir -p ${fe_path}/jdbc_drivers
117+
mkdir -p ${fe_path}/doris-meta
118+
mkdir -p ${fe_path}/log
119+
mkdir -p ${fe_path}/minidump
120+
mkdir -p ${fe_path}/temp_dir
121+
122+
if [ -d "${fe_output_dir}/lib" ] && [ ! -e "${fe_path}/lib" ]; then
123+
ln -s "${fe_output_dir}/lib" "${fe_path}/lib"
124+
fi
125+
126+
if [ -d "${fe_output_dir}/mysql_ssl_default_certificate" ] && [ ! -e "${fe_path}/mysql_ssl_default_certificate" ]; then
127+
ln -s "${fe_output_dir}/mysql_ssl_default_certificate" "${fe_path}/mysql_ssl_default_certificate"
128+
fi
129+
130+
if [ -d "${fe_output_dir}/plugins" ] && [ ! -e "${fe_path}/plugins" ]; then
131+
ln -s "${fe_output_dir}/plugins" "${fe_path}/plugins"
132+
fi
133+
134+
if [ -d "${fe_output_dir}/spark-dpp" ] && [ ! -e "${fe_path}/spark-dpp" ]; then
135+
ln -s "${fe_output_dir}/spark-dpp" "${fe_path}/spark-dpp"
136+
fi
137+
138+
if [ -d "${fe_output_dir}/webroot" ] && [ ! -e "${fe_path}/webroot" ]; then
139+
ln -s "${fe_output_dir}/webroot" "${fe_path}/webroot"
140+
fi
141+
}
142+
143+
function prepare_be {
144+
local cluster_id=$1
145+
local fe_count=0
146+
local be_count=0
147+
read fe_count be_count <<< $(get_cluster_config ${cluster_id})
148+
149+
local i
150+
for((i=0; i<$be_count; i++)); do
151+
prepare_single_be ${cluster_id} ${i}
152+
done
153+
}
154+
155+
function prepare_fe {
156+
local cluster_id=$1
157+
local fe_count=0
158+
local be_count=0
159+
read fe_count be_count <<< $(get_cluster_config ${cluster_id})
160+
161+
local i=0
162+
for((i=0; i<$fe_count; i++)); do
163+
prepare_single_fe ${cluster_id} ${i}
164+
done
165+
}
166+
167+
function prepare_conf {
168+
len=$(jq '.cluster | length' ${cluster_config_file})
169+
170+
local i=0
171+
for((i=0; i<$len; i++)); do
172+
prepare_fe ${i}
173+
prepare_be ${i}
174+
done
175+
}
176+
177+
function start_single_be {
178+
local cluster_id=$1
179+
local be_id=$2
180+
local be_path=${cluster_base_path}${cluster_id}/be${be_id}
181+
export DORIS_HOME=${be_path}
182+
bash ${DORIS_HOME}/bin/start_be.sh --daemon
183+
}
184+
185+
function stop_single_be {
186+
local cluster_id=$1
187+
local be_id=$2
188+
local be_path=${cluster_base_path}${cluster_id}/be${be_id}
189+
export DORIS_HOME=${be_path}
190+
bash ${DORIS_HOME}/bin/stop_be.sh
191+
}
192+
193+
function start_single_fe {
194+
local cluster_id=$1
195+
local fe_id=$2
196+
local fe_path=${cluster_base_path}${cluster_id}/fe${fe_id}
197+
export DORIS_HOME=${fe_path}
198+
bash ${DORIS_HOME}/bin/start_fe.sh --daemon
199+
}
200+
201+
function stop_single_fe {
202+
local cluster_id=$1
203+
local fe_id=$2
204+
local fe_path=${cluster_base_path}${cluster_id}/fe${fe_id}
205+
export DORIS_HOME=${fe_path}
206+
bash ${DORIS_HOME}/bin/stop_fe.sh
207+
}
208+
209+
function start_fe {
210+
local cluster_id=${1:-0}
211+
local fe_count=0
212+
local be_count=0
213+
read fe_count be_count <<< $(get_cluster_config ${cluster_id})
214+
215+
local i=0
216+
for((i=0; i<$fe_count; i++)); do
217+
start_single_fe ${cluster_id} ${i}
218+
done
219+
}
220+
221+
function stop_fe {
222+
local cluster_id=${1:-0}
223+
local fe_count=0
224+
local be_count=0
225+
read fe_count be_count <<< $(get_cluster_config ${cluster_id})
226+
227+
local i
228+
for((i=0; i<$fe_count; i++)); do
229+
stop_single_fe ${cluster_id} ${i}
230+
done
231+
}
232+
233+
function restart_fe {
234+
local cluster_id=${1:-0}
235+
236+
stop_fe ${cluster_id}
237+
start_fe ${cluster_id}
238+
}
239+
240+
function start_be {
241+
local cluster_id=${1:-0}
242+
local fe_count=0
243+
local be_count=0
244+
read fe_count be_count <<< $(get_cluster_config ${cluster_id})
245+
246+
local i
247+
for((i=0; i<$be_count; i++)); do
248+
start_single_be ${cluster_id} ${i}
249+
done
250+
}
251+
252+
function stop_be {
253+
local cluster_id=${1:-0}
254+
local fe_count=0
255+
local be_count=0
256+
read fe_count be_count <<< $(get_cluster_config ${cluster_id})
257+
258+
local i
259+
for((i=0; i<$be_count; i++)); do
260+
stop_single_be ${cluster_id} ${i}
261+
done
262+
}
263+
264+
function restart_be {
265+
local cluster_id=${1:-0}
266+
267+
stop_be ${cluster_id}
268+
start_be ${cluster_id}
269+
}
270+
271+
function start_cluster {
272+
local cluster_id=${1:-0}
273+
274+
start_fe ${cluster_id}
275+
start_be ${cluster_id}
276+
}
277+
278+
function stop_cluster {
279+
local cluster_id=${1:-0}
280+
281+
stop_fe ${cluster_id}
282+
stop_be ${cluster_id}
283+
}
284+
285+
function restart_cluster {
286+
local cluster_id=${1:-0}
287+
288+
stop_cluster ${cluster_id}
289+
start_cluster ${cluster_id}
290+
}

.devcontainer/docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ services:
2222
- /var/run/docker.sock:/var/run/docker.sock
2323
- ${LOCAL_MVN_REPO}:/home/dev/.m2:cached
2424
- ${LOCAL_CCACHE}:/opt/ccache:cached
25+
- ${LOCAL_DORIS_CLUSTER}:/opt/doris_local_cluster:cached
2526
working_dir: /opt/transwarp/doris
2627
network_mode: host
2728
tty: true

0 commit comments

Comments
 (0)