This is an automated email from the ASF dual-hosted git repository. diwu pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push: new e334e407975 [fix](docker)Docker be register bug and add fe new interface recovery (#37335) e334e407975 is described below commit e334e4079750461531c8237ebc79fcf2aa9e3c9d Author: FreeOnePlus <54164178+freeonep...@users.noreply.github.com> AuthorDate: Tue Jul 16 15:42:59 2024 +0800 [fix](docker)Docker be register bug and add fe new interface recovery (#37335) --- docker/runtime/be/resource/entry_point.sh | 2 +- docker/runtime/be/resource/init_be.sh | 68 +++++++-- docker/runtime/fe/resource/init_fe.sh | 238 +++++++++++++++++++++++++----- 3 files changed, 255 insertions(+), 53 deletions(-) diff --git a/docker/runtime/be/resource/entry_point.sh b/docker/runtime/be/resource/entry_point.sh index 1ae418163fa..6e3dfaf3875 100755 --- a/docker/runtime/be/resource/entry_point.sh +++ b/docker/runtime/be/resource/entry_point.sh @@ -167,7 +167,7 @@ check_be_status() { if [[ $1 == true ]]; then docker_process_sql <<<"show frontends" | grep "[[:space:]]${MASTER_FE_IP}[[:space:]]" else - docker_process_sql <<<"show backends" | grep "[[:space:]]${CURRENT_BE_IP}[[:space:]]" | grep "[[:space:]]${CURRENT_BE_PORT}[[:space:]]" | grep "[[:space:]]true[[:space:]]" + docker_process_sql <<<"show backends" | grep "[[:space:]]${CURRENT_BE_IP}[[:space:]]" | grep "[[:space:]]${CURRENT_BE_PORT}[[:space:]]" fi be_join_status=$? if [[ "${be_join_status}" == 0 ]]; then diff --git a/docker/runtime/be/resource/init_be.sh b/docker/runtime/be/resource/init_be.sh index 42afd1f6754..f9269f3ee7e 100644 --- a/docker/runtime/be/resource/init_be.sh +++ b/docker/runtime/be/resource/init_be.sh @@ -72,23 +72,26 @@ show_be_args(){ doris_note "CURRENT_BE_IP " ${CURRENT_BE_IP} doris_note "CURRENT_BE_PORT " ${CURRENT_BE_PORT} doris_note "RUN_TYPE " ${RUN_TYPE} - doris_note "PRIORITY_NETWORKS " ${PRIORITY_NETWORKS} } # Execute sql script, passed via stdin # usage: docker_process_sql sql_script docker_process_sql() { - set +e - mysql -uroot -P9030 -h${MASTER_FE_IP} --comments "$@" 2>/dev/null + set +e + if [[ $RUN_TYPE == "ELECTION" || $RUN_TYPE == "ASSIGN" ]]; then + mysql -uroot -P9030 -h${MASTER_FE_IP} --comments "$@" 2>/dev/null + elif [[ $RUN_TYPE == "FQDN" ]]; then + mysql -uroot -P9030 -h${MASTER_NODE_NAME} --comments "$@" 2>/dev/null + fi } node_role_conf(){ - if [[ ${NODE_ROLE} == 'computation' ]]; then - doris_note "this node role is computation" - echo "be_node_role=computation" >>${DORIS_HOME}/be/conf/be.conf - else - doris_note "this node role is mix" - fi + if [[ ${NODE_ROLE} == 'computation' ]]; then + doris_note "this node role is computation" + echo "be_node_role=computation" >>${DORIS_HOME}/be/conf/be.conf + else + doris_note "this node role is mix" + fi } register_be_to_fe() { @@ -103,12 +106,25 @@ register_be_to_fe() { fi fi for i in {1..300}; do - docker_process_sql <<<"alter system add backend '${CURRENT_BE_IP}:${CURRENT_BE_PORT}'" + if [[ $RUN_TYPE == "ELECTION" || $RUN_TYPE == "ASSIGN" ]]; then + SQL="alter system add backend '${CURRENT_BE_IP}:${CURRENT_BE_PORT}';" + doris_note "Executing SQL: $SQL" + docker_process_sql <<<"$SQL" + elif [[ $RUN_TYPE == "FQDN" ]]; then + SQL="alter system add backend '${CURRENT_NODE_NAME}:${CURRENT_BE_PORT}';" + doris_note "Executing SQL: $SQL" + docker_process_sql <<<"$SQL" + fi register_be_status=$? if [[ $register_be_status == 0 ]]; then doris_note "BE successfully registered to FE!" is_fe_start=true return + else + check_be_status + if [[ $IS_BE_JOIN_STATUS == "true" ]]; then + return + fi fi if [[ $(( $i % 20 )) == 1 ]]; then doris_note "Register BE to FE is failed. retry." @@ -122,16 +138,23 @@ register_be_to_fe() { check_be_status() { set +e - local is_fe_start=false - for i in {1..300}; do + declare -g IS_FE_START_STATUS IS_BE_JOIN_STATUS + IS_FE_START_STATUS=false + IS_BE_JOIN_STATUS=false + for i in {1..100}; do if [[ $(($i % 20)) == 1 ]]; then doris_warn "start check be register status~" fi - docker_process_sql <<<"show backends;" | grep "[[:space:]]${CURRENT_BE_IP}[[:space:]]" | grep "[[:space:]]${CURRENT_BE_PORT}[[:space:]]" + if [[ $RUN_TYPE == "ELECTION" || $RUN_TYPE == "ASSIGN" ]]; then + docker_process_sql <<<"show backends" | grep "[[:space:]]${CURRENT_BE_IP}[[:space:]]" | grep "[[:space:]]${CURRENT_BE_PORT}[[:space:]]" + elif [[ $RUN_TYPE == "FQDN" ]]; then + docker_process_sql <<<"show backends" | grep "[[:space:]]${CURRENT_NODE_NAME}[[:space:]]" | grep "[[:space:]]${CURRENT_BE_PORT}[[:space:]]" + fi be_join_status=$? if [[ "${be_join_status}" == 0 ]]; then doris_note "Verify that BE is registered to FE successfully" - is_fe_start=true + IS_FE_START_STATUS=true + IS_BE_JOIN_STATUS=true return else if [[ $(($i % 20)) == 1 ]]; then @@ -140,11 +163,20 @@ check_be_status() { fi sleep 1 done - if [[ ! $is_fe_start ]]; then + if [[ ! $IS_FE_START_STATUS ]]; then doris_error "Failed to register BE to FE!Tried 30 times!Maybe FE Start Failed!" fi } +add_fqdn_conf() { + doris_note "add 'FE hosts msg' \n${FE_HOSTS_MSG} to /etc/hosts" + echo -e ${FE_HOSTS_MSG} >/etc/hosts + doris_note "add 'BE hosts msg' \n${BE_HOSTS_MSG} to /etc/hosts" + echo -e ${BE_HOSTS_MSG} >>/etc/hosts + doris_note "add 'host_name = ${CURRENT_NODE_NAME}' to /etc/hostname" + echo ${CURRENT_NODE_NAME} >/etc/hostname +} + cleanup() { doris_note "Container stopped, running stop_be script" ${DORIS_HOME}/be/bin/stop_be.sh @@ -154,7 +186,11 @@ _main() { trap 'cleanup' SIGTERM SIGINT docker_setup_env if [ -z "$DATABASE_ALREADY_EXISTS" ]; then - add_priority_networks $PRIORITY_NETWORKS + if [ $RUN_TYPE == "FQDN" ]; then + add_fqdn_conf + else + add_priority_networks $PRIORITY_NETWORKS + fi node_role_conf show_be_args register_be_to_fe diff --git a/docker/runtime/fe/resource/init_fe.sh b/docker/runtime/fe/resource/init_fe.sh index 8cbd80ea237..bfdd6f29487 100644 --- a/docker/runtime/fe/resource/init_fe.sh +++ b/docker/runtime/fe/resource/init_fe.sh @@ -55,10 +55,18 @@ _is_sourced() { } docker_setup_env() { - declare -g DATABASE_ALREADY_EXISTS BUILD_TYPE_K8S + declare -g DATABASE_ALREADY_EXISTS BUILD_TYPE_K8S PRIORITY_NETWORKS_EXISTS if [ -d "${DORIS_HOME}/fe/doris-meta/image" ]; then + doris_note "the image is exsit!" DATABASE_ALREADY_EXISTS='true' fi + if grep -q "$PRIORITY_NETWORKS" "${DORIS_HOME}/fe/conf/fe.conf" ; then + doris_note "the priority_networks is exsit!" + PRIORITY_NETWORKS_EXISTS='true' + else + doris_note "the priority_networks values is $PRIORITY_NETWORKS" + doris_note "the conf file path is ${DORIS_HOME}/fe/conf/fe.conf" + fi } # Check the variables required for startup @@ -74,6 +82,47 @@ docker_required_variables_env() { return fi + if [[ -n "$FE_SERVERS" && -n "$BE_SERVERS" && -n "$FE_ID" && -n "$FQDN" ]]; then + RUN_TYPE="FQDN" + if [[ $FE_SERVERS =~ ^[a-zA-Z].+:[1-2]{0,1}[0-9]{0,1}[0-9]{1}(\.[1-2]{0,1}[0-9]{0,1}[0-9]{1}){3}:[1-6]{0,1}[0-9]{1,4}(,[a-zA-Z]+\w+:[1-2]{0,1}[0-9]{0,1}[0-9]{1}(\.[1-2]{0,1}[0-9]{0,1}[0-9]{1}){3}:[1-6]{0,1}[0-9]{1,4})*$ || $FE_SERVERS =~ ^([0-9a-fA-F]{1,4}:){7,7}([0-9a-fA-F]{1,4}|:)|([0-9a-fA-F]{1,4}:){1,6}(:[0-9a-fA-F]{1,4}|:)|([0-9a-fA-F]{1,4}:){1,5}((:[0-9a-fA-F]{1,4}){1,2}|:)|([0-9a-fA-F]{1,4}:){1,4}((:[0-9a-fA-F]{1,4}){1,3}|:)|([0-9a-fA-F]{1,4}:){1,3}((:[0-9a-fA-F]{1,4}){1,4 [...] + doris_warn "FE_SERVERS " $FE_SERVERS + else + doris_error "FE_SERVERS rule error!example: \$FE_NAME:\$FE_HOST_IP:\$FE_EDIT_LOG_PORT[,\$FE_NAME:\$FE_HOST_IP:\$FE_EDIT_LOG_PORT]... AND FE_NAME Ruler is '[a-zA-Z].+'!" + fi + if [[ $FE_ID =~ ^[1-9]{1}$ ]]; then + doris_warn "FE_ID " $FE_ID + else + doris_error "FE_ID rule error!If FE is the role of Master, please set FE_ID=1, and ensure that all IDs correspond to the IP of the current node, ID start num is 1." + fi + if [[ $BE_SERVERS =~ ^[a-zA-Z].+:[1-2]{0,1}[0-9]{0,1}[0-9]{1}(\.[1-2]{0,1}[0-9]{0,1}[0-9]{1}){3}(,[a-zA-Z]+\w+:[1-2]{0,1}[0-9]{0,1}[0-9]{1}(\.[1-2]{0,1}[0-9]{0,1}[0-9]{1}){3})*$ || $FE_SERVERS =~ ^([0-9a-fA-F]{1,4}:){7,7}([0-9a-fA-F]{1,4}|:)|([0-9a-fA-F]{1,4}:){1,6}(:[0-9a-fA-F]{1,4}|:)|([0-9a-fA-F]{1,4}:){1,5}((:[0-9a-fA-F]{1,4}){1,2}|:)|([0-9a-fA-F]{1,4}:){1,4}((:[0-9a-fA-F]{1,4}){1,3}|:)|([0-9a-fA-F]{1,4}:){1,3}((:[0-9a-fA-F]{1,4}){1,4}|:)|([0-9a-fA-F]{1,4}:){1,2}((:[0-9a-fA-F [...] + doris_warn "BE_SERVERS " $BE_SERVERS + else + doris_error "BE_SERVERS rule error!example: \$BE_NODE_NAME:\$BE_HOST_IP[,\$BE_NODE_NAME:\$BE_HOST_IP:]... AND BE_NODE_NAME Ruler is '[a-zA-Z].+'!" + fi + return + fi + + if [[ -n "$RECOVERY" && -n "$FE_SERVERS" && -n "$FE_ID" ]]; then + RUN_TYPE="RECOVERY" + if [[ $RECOVERY =~ true ]]; then + doris_warn "RECOVERY " $RECOVERY + else + doris_error "RECOVERY value error! Only Support 'true'!" + fi + if [[ $FE_SERVERS =~ ^.+:[1-2]{0,1}[0-9]{0,1}[0-9]{1}(\.[1-2]{0,1}[0-9]{0,1}[0-9]{1}){3}:[1-6]{0,1}[0-9]{1,4}(,.+:[1-2]{0,1}[0-9]{0,1}[0-9]{1}(\.[1-2]{0,1}[0-9]{0,1}[0-9]{1}){3}:[1-6]{0,1}[0-9]{1,4})*$ || $FE_SERVERS =~ ^([0-9a-fA-F]{1,4}:){7,7}([0-9a-fA-F]{1,4}|:)|([0-9a-fA-F]{1,4}:){1,6}(:[0-9a-fA-F]{1,4}|:)|([0-9a-fA-F]{1,4}:){1,5}((:[0-9a-fA-F]{1,4}){1,2}|:)|([0-9a-fA-F]{1,4}:){1,4}((:[0-9a-fA-F]{1,4}){1,3}|:)|([0-9a-fA-F]{1,4}:){1,3}((:[0-9a-fA-F]{1,4}){1,4}|:)|([0-9a-fA-F]{ [...] + doris_warn "FE_SERVERS " $FE_SERVERS + else + doris_error "FE_SERVERS rule error!example: \$FE_NAME:\$FE_HOST_IP:\$FE_EDIT_LOG_PORT[,\$FE_NAME:\$FE_HOST_IP:\$FE_EDIT_LOG_PORT]..." + fi + if [[ $FE_ID =~ ^[1-9]{1}$ ]]; then + doris_warn "FE_ID" $FE_ID + else + doris_error "FE_ID rule error!If FE is the role of Master, please set FE_ID=1, and ensure that all IDs correspond to the IP of the current node." + fi + doris_warn "The Frontend MetaData Will Recovery." + return + fi + if [[ -n "$FE_SERVERS" && -n "$FE_ID" ]]; then RUN_TYPE="ELECTION" if [[ $FE_SERVERS =~ ^.+:[1-2]{0,1}[0-9]{0,1}[0-9]{1}(\.[1-2]{0,1}[0-9]{0,1}[0-9]{1}){3}:[1-6]{0,1}[0-9]{1,4}(,.+:[1-2]{0,1}[0-9]{0,1}[0-9]{1}(\.[1-2]{0,1}[0-9]{0,1}[0-9]{1}){3}:[1-6]{0,1}[0-9]{1,4})*$ || $FE_SERVERS =~ ^([0-9a-fA-F]{1,4}:){7,7}([0-9a-fA-F]{1,4}|:)|([0-9a-fA-F]{1,4}:){1,6}(:[0-9a-fA-F]{1,4}|:)|([0-9a-fA-F]{1,4}:){1,5}((:[0-9a-fA-F]{1,4}){1,2}|:)|([0-9a-fA-F]{1,4}:){1,4}((:[0-9a-fA-F]{1,4}){1,3}|:)|([0-9a-fA-F]{1,4}:){1,3}((:[0-9a-fA-F]{1,4}){1,4}|:)|([0-9a-fA-F]{ [...] @@ -88,7 +137,7 @@ docker_required_variables_env() { fi return fi - doris_note $FE_MASTER_IP " " $FE_MASTER_PORT " " $FE_CURRENT_IP " " $FE_CURRENT_PORT + if [[ -n "$FE_MASTER_IP" && -n "$FE_MASTER_PORT" && -n "$FE_CURRENT_IP" && -n "$FE_CURRENT_PORT" ]]; then RUN_TYPE="ASSIGN" if [[ $FE_MASTER_IP =~ ^[1-2]{0,1}[0-9]{0,1}[0-9]{1}(\.[1-2]{0,1}[0-9]{0,1}[0-9]{1}){3}$ || $FE_MASTER_IP =~ ^([0-9a-fA-F]{1,4}:){7,7}([0-9a-fA-F]{1,4}|:)|([0-9a-fA-F]{1,4}:){1,6}(:[0-9a-fA-F]{1,4}|:)|([0-9a-fA-F]{1,4}:){1,5}((:[0-9a-fA-F]{1,4}){1,2}|:)|([0-9a-fA-F]{1,4}:){1,4}((:[0-9a-fA-F]{1,4}){1,3}|:)|([0-9a-fA-F]{1,4}:){1,3}((:[0-9a-fA-F]{1,4}){1,4}|:)|([0-9a-fA-F]{1,4}:){1,2}((:[0-9a-fA-F]{1,4}){1,5}|:)|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6}|:)|:((:[0-9a-fA-F]{1,4}){1,7 [...] @@ -119,36 +168,40 @@ docker_required_variables_env() { plan 1: BUILD_TYPE plan 2: - FE_SERVERS & FE_ID + RECOVERY & FE_SERVERS & FE_ID plan 3: + FE_SERVERS & FE_ID + plan 4: + FE_SERVERS & FE_ID & BE_SERVERS & FQDN + plan 5: FE_MASTER_IP & FE_MASTER_PORT & FE_CURRENT_IP & FE_CURRENT_PORT" EOF } get_doris_fe_args() { - declare -g MASTER_FE_IP CURRENT_FE_IP MASTER_FE_EDIT_PORT CURRENT_FE_EDIT_PORT PRIORITY_NETWORKS CURRENT_FE_IS_MASTER - if [ $RUN_TYPE == "ELECTION" ]; then + declare -g MASTER_FE_IP CURRENT_FE_IP CURRENT_NODE_NAME MASTER_FE_EDIT_PORT MASTER_NODE_NAME CURRENT_FE_EDIT_PORT PRIORITY_NETWORKS CURRENT_FE_IS_MASTER FE_HOSTS_MSG BE_HOSTS_MSG + if [[ $RUN_TYPE == "ELECTION" || $RUN_TYPE == "RECOVERY" ]]; then local feServerArray=($(echo "${FE_SERVERS}" | awk '{gsub (/,/," "); print $0}')) for i in "${feServerArray[@]}"; do val=${i} val=${val// /} - tmpFeName=$(echo "${val}" | awk -F ':' '{ sub(/fe/, ""); sub(/ /, ""); print$1}') + tmpFeName=$(echo "${val}" | awk -F ':' '{ sub(/ /, ""); print$1}') tmpFeIp=$(echo "${val}" | awk -F ':' '{ sub(/ /, ""); print$2}') tmpFeEditLogPort=$(echo "${val}" | awk -F ':' '{ sub(/ /, ""); print$3}') - check_arg "TMP_FE_NAME" $tmpFeName - feIpArray[$tmpFeName]=${tmpFeIp} + check_arg "TMP_FE_IP" $tmpFeIp + feIpArray+=("$tmpFeIp") check_arg "TMP_FE_EDIT_LOG_PORT" $tmpFeEditLogPort - feEditLogPortArray[$tmpFeName]=${tmpFeEditLogPort} + feEditLogPortArray+=("$tmpFeEditLogPort") done - MASTER_FE_IP=${feIpArray[1]} + MASTER_FE_IP=${feIpArray[0]} check_arg "MASTER_FE_IP" $MASTER_FE_IP - MASTER_FE_EDIT_PORT=${feEditLogPortArray[1]} + MASTER_FE_EDIT_PORT=${feEditLogPortArray[0]} check_arg "MASTER_FE_EDIT_PORT" $MASTER_FE_EDIT_PORT - CURRENT_FE_IP=${feIpArray[FE_ID]} + CURRENT_FE_IP=${feIpArray[$FE_ID-1]} check_arg "CURRENT_FE_IP" $CURRENT_FE_IP - CURRENT_FE_EDIT_PORT=${feEditLogPortArray[FE_ID]} + CURRENT_FE_EDIT_PORT=${feEditLogPortArray[$FE_ID-1]} check_arg "CURRENT_FE_EDIT_PORT" $CURRENT_FE_EDIT_PORT if [ ${MASTER_FE_IP} == ${CURRENT_FE_IP} ]; then @@ -160,13 +213,83 @@ get_doris_fe_args() { PRIORITY_NETWORKS=$(echo "${CURRENT_FE_IP}" | awk -F '.' '{print$1"."$2"."$3".0/24"}') check_arg "PRIORITY_NETWORKS" $PRIORITY_NETWORKS - doris_note "FE_IP_ARRAY = ${feIpArray[*]}" - doris_note "FE_EDIT_LOG_PORT_ARRAY = ${feEditLogPortArray[*]}" - doris_note "MASTER_FE = ${feIpArray[1]}:${feEditLogPortArray[1]}" + doris_note "FE_IP_ARRAY = [${feIpArray[*]}]" + doris_note "FE_EDIT_LOG_PORT_ARRAY = [${feEditLogPortArray[*]}]" + doris_note "MASTER_FE = ${MASTER_FE_IP}:${MASTER_FE_EDIT_PORT}" doris_note "CURRENT_FE = ${CURRENT_FE_IP}:${CURRENT_FE_EDIT_PORT}" doris_note "PRIORITY_NETWORKS = ${PRIORITY_NETWORKS}" - elif [ $RUN_TYPE == "ASSIGN" ]; then + elif [[ $RUN_TYPE == "FQDN" ]]; then + local feServerArray=($(echo "${FE_SERVERS}" | awk '{gsub (/,/," "); print $0}')) + local beServerArray=($(echo "${BE_SERVERS}" | awk '{gsub (/,/," "); print $0}')) + feIpArray=() + feEditLogPortArray=() + feNameArray=() + beIpArray=() + beNameArray=() + for ((i=0; i<${#feServerArray[@]}; i++)); do + val=${feServerArray[i]} + val=${val// /} + tmpFeName=$(echo "${val}" | awk -F ':' '{ sub(/ /, ""); print$1}') + tmpFeIp=$(echo "${val}" | awk -F ':' '{ sub(/ /, ""); print$2}') + tmpFeEditLogPort=$(echo "${val}" | awk -F ':' '{ sub(/ /, ""); print$3}') + check_arg "TMP_FE_NAME" $tmpFeName + feNameArray+=("$tmpFeName") + check_arg "TMP_FE_IP" $tmpFeIp + feIpArray+=("$tmpFeIp") + check_arg "TMP_FE_EDIT_LOG_PORT" $tmpFeEditLogPort + feEditLogPortArray+=("$tmpFeEditLogPort") + FE_HOSTS_MSG+=$(printf "%s\t%s" $tmpFeIp $tmpFeName) + if [ $i -lt $((${#feServerArray[@]}-1)) ]; then + FE_HOSTS_MSG+='\n' + fi + done + for ((i=0; i<${#beServerArray[@]}; i++)); do + val=${beServerArray[i]} + val=${val// /} + tmpBeName=$(echo "${val}" | awk -F ':' '{ sub(/fe/, ""); sub(/ /, ""); print$1}') + tmpBeIp=$(echo "${val}" | awk -F ':' '{ sub(/ /, ""); print$2}') + check_arg "TMP_BE_NAME" $tmpBeName + beNameArray+=("$tmpBeName") + check_arg "TMP_BE_IP" $tmpBeIp + beIpArray+=("$tmpBeIp") + BE_HOSTS_MSG+=$(printf "%s\t%s" $tmpBeIp $tmpBeName) + if [ $i -lt $((${#beServerArray[@]}-1)) ]; then + BE_HOSTS_MSG+='\n' + fi + done + + MASTER_FE_IP=${feIpArray[0]} + check_arg "MASTER_FE_IP" $MASTER_FE_IP + MASTER_FE_EDIT_PORT=${feEditLogPortArray[0]} + check_arg "MASTER_FE_EDIT_PORT" $MASTER_FE_EDIT_PORT + MASTER_NODE_NAME=${feNameArray[0]} + check_arg "MASTER_NODE_NAME" $MASTER_NODE_NAME + CURRENT_NODE_NAME=${feNameArray[$FE_ID-1]} + check_arg "CURRENT_NODE_NAME" $CURRENT_NODE_NAME + CURRENT_FE_IP=${feIpArray[$FE_ID-1]} + check_arg "CURRENT_FE_IP" $CURRENT_FE_IP + CURRENT_FE_EDIT_PORT=${feEditLogPortArray[$FE_ID-1]} + check_arg "CURRENT_FE_EDIT_PORT" $CURRENT_FE_EDIT_PORT + + if [ "${MASTER_FE_IP}" == "${CURRENT_FE_IP}" ]; then + CURRENT_FE_IS_MASTER=true + else + CURRENT_FE_IS_MASTER=false + fi + + # Print arrays with desired format + doris_note "FE_HOSTS_MSG = [\n${FE_HOSTS_MSG}\n]" + doris_note "BE_HOSTS_MSG = [\n${BE_HOSTS_MSG}\n]" + doris_note "FE_NAME_ARRAY = [${feNameArray[*]}]" + doris_note "FE_IP_ARRAY = [${feIpArray[*]}]" + doris_note "FE_EDIT_LOG_PORT_ARRAY = [${feEditLogPortArray[*]}]" + doris_note "MASTER_FE = ${MASTER_FE_IP}:${MASTER_FE_EDIT_PORT}" + doris_note "MASTEMASTER_NODE_NAMER_FE = ${MASTER_NODE_NAME}" + doris_note "CURRENT_NODE_NAME = ${CURRENT_NODE_NAME}" + doris_note "CURRENT_FE = ${CURRENT_FE_IP}:${CURRENT_FE_EDIT_PORT}" + + elif [[ $RUN_TYPE == "ASSIGN" ]]; then MASTER_FE_IP=${FE_MASTER_IP} check_arg "MASTER_FE_IP" $MASTER_FE_IP MASTER_FE_EDIT_PORT=${FE_MASTER_PORT} @@ -187,8 +310,9 @@ get_doris_fe_args() { fi # check fe start - check_fe_status true - + if [[ $RUN_TYPE == "ELECTION" || $RUN_TYPE == "ASSIGN" ]]; then + check_fe_status true + fi } add_priority_networks() { @@ -196,30 +320,51 @@ add_priority_networks() { echo "priority_networks = ${1}" >>${DORIS_HOME}/fe/conf/fe.conf } +add_fqdn_conf() { + doris_note "add ‘enable_fqdn_mode = true’ to ${DORIS_HOME}/fe/conf/fe.conf" + echo "enable_fqdn_mode = true" >>${DORIS_HOME}/fe/conf/fe.conf + doris_note "add 'FE hosts msg' \n${FE_HOSTS_MSG} to /etc/hosts" + echo -e ${FE_HOSTS_MSG} >/etc/hosts + doris_note "add 'BE hosts msg' \n${BE_HOSTS_MSG} to /etc/hosts" + echo -e ${BE_HOSTS_MSG} >>/etc/hosts + doris_note "add 'host_name = ${CURRENT_NODE_NAME}' to /etc/hostname" + echo ${CURRENT_NODE_NAME} >/etc/hostname +} + # Execute sql script, passed via stdin # usage: docker_process_sql sql_script docker_process_sql() { set +e - mysql -uroot -P9030 -h${MASTER_FE_IP} --comments "$@" 2>/dev/null + if [[ $RUN_TYPE == "ELECTION" || $RUN_TYPE == "ASSIGN" ]]; then + mysql -uroot -P9030 -h${MASTER_FE_IP} --comments "$@" 2>/dev/null + elif [[ $RUN_TYPE == "FQDN" ]]; then + mysql -uroot -P9030 -h${MASTER_NODE_NAME} --comments "$@" 2>/dev/null + fi } docker_setup_db() { set +e # check fe status local is_fe_start=false - if [ ${CURRENT_FE_IS_MASTER} == true ]; then + if [[ ${CURRENT_FE_IS_MASTER} == true ]]; then doris_note "Current FE is Master FE! No need to register again!" return fi - for i in {1..300}; do - docker_process_sql <<<"alter system add FOLLOWER '${CURRENT_FE_IP}:${CURRENT_FE_EDIT_PORT}'" + for i in {1..30}; do + if [[ $RUN_TYPE == "ELECTION" || $RUN_TYPE == "ASSIGN" ]]; then + docker_process_sql <<<"alter system add FOLLOWER '${CURRENT_FE_IP}:${CURRENT_FE_EDIT_PORT}'" + elif [[ $RUN_TYPE == "FQDN" ]]; then + docker_process_sql <<<"alter system add FOLLOWER '${CURRENT_NODE_NAME}:${CURRENT_FE_EDIT_PORT}'" + fi register_fe_status=$? if [[ $register_fe_status == 0 ]]; then doris_note "FE successfully registered!" is_fe_start=true break else - check_fe_status + if [[ $RUN_TYPE == "ELECTION" || $RUN_TYPE == "ASSIGN" ]]; then + check_fe_status + fi if [ -n "$CURRENT_FE_ALREADY_EXISTS" ]; then doris_warn "Same frontend already exists! No need to register again!" break @@ -255,11 +400,19 @@ check_fe_status() { doris_note "Current FE is Master FE! No need check fe status!" return fi - for i in {1..300}; do + for i in {1..30}; do if [[ $1 == true ]]; then - docker_process_sql <<<"show frontends" | grep "[[:space:]]${MASTER_FE_IP}[[:space:]]" | grep "[[:space:]]${MASTER_FE_EDIT_PORT}[[:space:]]" + if [[ $RUN_TYPE == "ELECTION" || $RUN_TYPE == "ASSIGN" ]]; then + docker_process_sql <<<"show frontends" | grep "[[:space:]]${MASTER_FE_IP}[[:space:]]" | grep "[[:space:]]${MASTER_FE_EDIT_PORT}[[:space:]]" + elif [[ $RUN_TYPE == "FQDN" ]]; then + docker_process_sql <<<"show frontends" | grep "[[:space:]]${MASTER_NODE_NAME}[[:space:]]" | grep "[[:space:]]${MASTER_FE_EDIT_PORT}[[:space:]]" + fi else - docker_process_sql <<<"show frontends" | grep "[[:space:]]${CURRENT_FE_IP}[[:space:]]" | grep "[[:space:]]${CURRENT_FE_EDIT_PORT}[[:space:]]" + if [[ $RUN_TYPE == "ELECTION" || $RUN_TYPE == "ASSIGN" ]]; then + docker_process_sql <<<"show frontends" | grep "[[:space:]]${CURRENT_FE_IP}[[:space:]]" | grep "[[:space:]]${CURRENT_FE_EDIT_PORT}[[:space:]]" + elif [[ $RUN_TYPE == "FQDN" ]]; then + docker_process_sql <<<"show frontends" | grep "[[:space:]]${CURRENT_NODE_NAME}[[:space:]]" | grep "[[:space:]]${CURRENT_FE_EDIT_PORT}[[:space:]]" + fi fi fe_join_status=$? if [[ "${fe_join_status}" == 0 ]]; then @@ -298,22 +451,35 @@ _main() { ${DORIS_HOME}/fe/bin/start_fe.sh --console & child_pid=$! else - docker_setup_env get_doris_fe_args - - if [ -z "$DATABASE_ALREADY_EXISTS" ]; then - add_priority_networks $PRIORITY_NETWORKS + docker_setup_env + if [[ $DATABASE_ALREADY_EXISTS == "true" && $PRIORITY_NETWORKS_EXISTS != "true" ]]; then + if [[ $RUN_TYPE == "ELECTION" || $RUN_TYPE == "ASSIGN" || $RUN_TYPE == "RECOVERY" ]]; then + doris_note "start add_priority_networks" + add_priority_networks $PRIORITY_NETWORKS + elif [[ $RUN_TYPE == "FQDN" ]]; then + doris_note "start add_fqdn_conf" + add_fqdn_conf + fi fi - docker_setup_db - check_fe_status + if [[ $RUN_TYPE == "ELECTION" || $RUN_TYPE == "ASSIGN" ]]; then + check_fe_status + fi doris_note "Ready to start CURRENT_FE!" - - if [ $CURRENT_FE_IS_MASTER == true ]; then + if [ $RECOVERY == true ]; then + start_fe.sh --console --metadata_failure_recovery & + child_pid=$! + fi + if [[ $CURRENT_FE_IS_MASTER == true ]]; then ${DORIS_HOME}/fe/bin/start_fe.sh --console & child_pid=$! else - ${DORIS_HOME}/fe/bin/start_fe.sh --helper ${MASTER_FE_IP}:${MASTER_FE_EDIT_PORT} --console & + if [[ $RUN_TYPE == "ELECTION" || $RUN_TYPE == "ASSIGN" ]]; then + ${DORIS_HOME}/fe/bin/start_fe.sh --helper ${MASTER_FE_IP}:${MASTER_FE_EDIT_PORT} --console & + elif [[ $RUN_TYPE == "FQDN" ]]; then + ${DORIS_HOME}/fe/bin/start_fe.sh --helper ${MASTER_NODE_NAME}:${MASTER_FE_EDIT_PORT} --console & + fi child_pid=$! fi fi --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org