6
6
7
7
set -eo pipefail
8
8
9
+
10
+ fe_mysql_port="9030"
11
+ if [ -n "${FE_MASTER_PORT}" ]; then
12
+ fe_mysql_port="${FE_MASTER_PORT}"
13
+ fi
14
+
9
15
if grep -q -i "stand" <<< "${RUN_MODE}"; then
10
16
11
17
@@ -17,11 +23,11 @@ if grep -q -i "stand" <<< "${RUN_MODE}"; then
17
23
fi
18
24
19
25
20
- wait4x --timeout 86400s mysql "root@tcp(127.0.0.1:9030 )/" && \
26
+ wait4x --timeout 86400s mysql "root@tcp(127.0.0.1:${fe_mysql_port} )/" && \
21
27
(
22
28
## check if the backend is already added
23
- if ! mysql -uroot -P9030 -h127.0.0.1 -e "show backends" | grep -q -E "${join_backend}.*9050"; then
24
- mysql -uroot -P9030 -h127.0.0.1 -e "ALTER SYSTEM ADD BACKEND '${join_backend}:9050'"
29
+ if ! mysql -uroot -P${fe_mysql_port} -h127.0.0.1 -e "show backends" | grep -q -E "${join_backend}.*9050"; then
30
+ mysql -uroot -P${fe_mysql_port} -h127.0.0.1 -e "ALTER SYSTEM ADD BACKEND '${join_backend}:9050'"
25
31
fi
26
32
)
27
33
fi
30
36
## //TODO
31
37
## will ignore BE_SERVERS
32
38
## will ignore FQDN
33
- ## will ignore FE_MASTER_PORT //TODO
39
+
34
40
35
41
36
42
if grep -q -i "fe" <<< "${RUN_MODE}"; then
@@ -50,6 +56,7 @@ if [ -n "${FE_SERVERS}" ]; then
50
56
51
57
# specific for k8s sts pod, because the FE_ID cant set var ENV
52
58
# so we need to get the index from hostname
59
+ # TODO need make sure it is indeed in k8s environment
53
60
if [ -z "${FE_ID}" ]; then
54
61
HOSTNAME="$(hostname -s)"
55
62
if [[ $HOSTNAME =~ (.*)-([0-9]+)$ ]]; then
@@ -82,7 +89,7 @@ if [ -n "${FE_SERVERS}" ]; then
82
89
done
83
90
fi
84
91
85
- wait4x --timeout 86400s mysql "root@tcp(${fe_master}:9030 )/" && \
92
+ wait4x --timeout 86400s mysql "root@tcp(${fe_master}:${fe_mysql_port} )/" && \
86
93
(
87
94
for k in "${!fe_join[@]}"; do
88
95
val="${fe_join[$k]}";
@@ -92,15 +99,13 @@ wait4x --timeout 86400s mysql "root@tcp(${fe_master}:9030)/" && \
92
99
# echo "${val_grep}"
93
100
# echo "###########################################"
94
101
## check if the frontend is already added
95
- if ! mysql -uroot -P9030 -h${fe_master} -e "show frontends;" | grep -q -E "${val_grep}"; then
96
- mysql -uroot -P9030 -h${fe_master} -e "ALTER SYSTEM ADD FOLLOWER '${val}'"
102
+ if ! mysql -uroot -P${fe_mysql_port} -h${fe_master} -e "show frontends;" | grep -q -E "${val_grep}"; then
103
+ mysql -uroot -P${fe_mysql_port} -h${fe_master} -e "ALTER SYSTEM ADD FOLLOWER '${val}'"
97
104
fi
98
105
done
99
106
)
100
107
101
- # mysql -uroot -P9030 -hfe-01 -e "ALTER SYSTEM ADD FOLLOWER 'fe-02:9010'"
102
- # mysql -uroot -P9030 -hfe-01 -e "ALTER SYSTEM ADD FOLLOWER 'fe-03:9010'"
103
- # mysql -uroot -P9030 -hfe-01 -e "ALTER SYSTEM DROP FOLLOWER 'fe-04:9010'"
108
+
104
109
105
110
106
111
fi
@@ -132,7 +137,7 @@ if [ -n "${FE_SERVERS}" ]; then
132
137
done
133
138
fi
134
139
135
- wait4x --timeout 86400s mysql "root@tcp(${fe_master}:9030 )/" && \
140
+ wait4x --timeout 86400s mysql "root@tcp(${fe_master}:${fe_mysql_port} )/" && \
136
141
(
137
142
val="";
138
143
@@ -143,8 +148,8 @@ wait4x --timeout 86400s mysql "root@tcp(${fe_master}:9030)/" && \
143
148
fi
144
149
145
150
val_grep=${val//:/.*}
146
- if ! mysql -uroot -P9030 -h${fe_master} -e "show backends;" | grep -q -E "${val_grep}"; then
147
- mysql -uroot -P9030 -h${fe_master} -e "ALTER SYSTEM ADD BACKEND '${val}'"
151
+ if ! mysql -uroot -P${fe_mysql_port} -h${fe_master} -e "show backends;" | grep -q -E "${val_grep}"; then
152
+ mysql -uroot -P${fe_mysql_port} -h${fe_master} -e "ALTER SYSTEM ADD BACKEND '${val}'"
148
153
fi
149
154
)
150
155
0 commit comments