This is an automated email from the ASF dual-hosted git repository.

dataroaring pushed a commit to branch branch-3.0
in repository https://gitbox.apache.org/repos/asf/doris.git

commit 9288c8fafb81ddf8a1f0e0f8c362c84ce2bcee3c
Author: catpineapple <1391869...@qq.com>
AuthorDate: Fri Aug 9 12:02:50 2024 +0800

    [feature](docker) add disaggregated doris docker image content (#39093)
    
    1. Added corresponding scripts for the doris image(fe,be) of 
storage-computing separation deployment
    2. Added a new metaservice image module
    3. Added binary package storage paths and prompt files for different 
architectures to facilitate clearer construction of your own image
---
 .../runtime/be/resource/amd64/x64_package_is_here  |  23 +++
 .../be/resource/arm64/arm64_package_is_here        |  23 +++
 .../be/resource/be_disaggregated_entrypoint.sh     | 185 ++++++++++++++++++
 .../be/resource/be_disaggregated_prestop.sh        |  23 +++
 .../runtime/be/resource/be_disaggregated_probe.sh  |  64 +++++++
 .../broker/resource/amd64/x64_package_is_here      |  23 +++
 .../broker/resource/arm64/arm64_package_is_here    |  23 +++
 .../runtime/fe/resource/amd64/x64_package_is_here  |  23 +++
 .../fe/resource/arm64/arm64_package_is_here        |  23 +++
 .../fe/resource/fe_disaggregated_entrypoint.sh     | 207 +++++++++++++++++++++
 .../fe/resource/fe_disaggregated_prestop.sh        |  23 +++
 .../runtime/fe/resource/fe_disaggregated_probe.sh  |  64 +++++++
 docker/runtime/ms/Dockerfile                       |  57 ++++++
 .../runtime/ms/resource/amd64/x64_package_is_here  |  23 +++
 .../ms/resource/arm64/arm64_package_is_here        |  23 +++
 .../ms/resource/ms_disaggregated_entrypoint.sh     |  44 +++++
 .../ms/resource/ms_disaggregated_prestop.sh        |  24 +++
 .../runtime/ms/resource/ms_disaggregated_probe.sh  |  62 ++++++
 18 files changed, 937 insertions(+)

diff --git a/docker/runtime/be/resource/amd64/x64_package_is_here 
b/docker/runtime/be/resource/amd64/x64_package_is_here
new file mode 100644
index 00000000000..c92bb295a23
--- /dev/null
+++ b/docker/runtime/be/resource/amd64/x64_package_is_here
@@ -0,0 +1,23 @@
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+
+This file is not required for building an image.
+It is just a reminder for you: If you build a docker image yourself,
+please place the installation package (already unzipped) corresponding to the 
CPU architecture at the same level as this file.
diff --git a/docker/runtime/be/resource/arm64/arm64_package_is_here 
b/docker/runtime/be/resource/arm64/arm64_package_is_here
new file mode 100644
index 00000000000..c92bb295a23
--- /dev/null
+++ b/docker/runtime/be/resource/arm64/arm64_package_is_here
@@ -0,0 +1,23 @@
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+
+This file is not required for building an image.
+It is just a reminder for you: If you build a docker image yourself,
+please place the installation package (already unzipped) corresponding to the 
CPU architecture at the same level as this file.
diff --git a/docker/runtime/be/resource/be_disaggregated_entrypoint.sh 
b/docker/runtime/be/resource/be_disaggregated_entrypoint.sh
new file mode 100755
index 00000000000..f2dc6f6e223
--- /dev/null
+++ b/docker/runtime/be/resource/be_disaggregated_entrypoint.sh
@@ -0,0 +1,185 @@
+#!/bin/bash
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+#TODO: convert to "_"
+MS_ENDPOINT=${MS_ENDPOINT}
+MS_TOKEN=${MS_TOKEN:="greedisgood9999"}
+DORIS_HOME=${DORIS_HOME:="/opt/apache-doris"}
+CONFIGMAP_PATH=${CONFIGMAP_PATH:="/etc/doris"}
+INSTANCE_ID=${INSTANCE_ID}
+INSTANCE_NAME=${INSTANCE_NAME}
+HEARTBEAT_PORT=9050
+CLUSTER_NMAE=${CLUSTER_NAME}
+#option:IP,FQDN
+HOST_TYPE=${HOST_TYPE:="FQDN"}
+STATEFULSET_NAME=${STATEFULSET_NAME}
+POD_NAMESPACE=$POD_NAMESPACE
+DEFAULT_CLUSTER_ID=${POD_NAMESPACE}"_"${STATEFULSET_NAME}
+CLUSTER_ID=${CLUSTER_ID:="$DEFAULT_CLUSTER_ID"}
+POD_NAME=${POD_NAME}
+CLOUD_UNIQUE_ID_PRE=${CLOUD_UNIQUE_ID_PRE:="1:$INSTANCE_ID"}
+CLOUD_UNIQUE_ID="$CLOUD_UNIQUE_ID_PRE:$POD_NAME"
+# replace "-" with "_" in CLUSTER_ID and CLOUD_UNIQUE_ID
+CLUSTER_ID=$(sed 's/-/_/g' <<<$CLUSTER_ID)
+
+CONFIG_FILE="$DORIS_HOME/be/conf/be.conf"
+MY_SELF=
+
+DEFAULT_CLUSTER_NAME=$(awk -F $INSTANCE_NAME"-" '{print $NF}' 
<<<$STATEFULSET_NAME)
+CLUSTER_NAME=${CLUSTER_NAME:="$DEFAULT_CLUSTER_NAME"}
+
+#TODO: check config or not, add default
+echo 'file_cache_path = 
[{"path":"/opt/apache-doris/be/storage","total_size":107374182400,"query_limit":107374182400}]'
 >> $DORIS_HOME/be/conf/be.conf
+
+function log_stderr()
+{
+    echo "[`date`] $@" >& 1
+}
+
+function add_cluster_info_to_conf()
+{
+    echo "meta_service_endpoint=$MS_ENDPOINT" >> $DORIS_HOME/be/conf/be.conf
+    echo "cloud_unique_id=$CLOUD_UNIQUE_ID" >> $DORIS_HOME/be/conf/be.conf
+    echo "meta_service_use_load_balancer = false" >> 
$DORIS_HOME/be/conf/be.conf
+    echo "enable_file_cache = true" >> $DORIS_HOME/be/conf/be.conf
+}
+
+function link_config_files()
+{
+    if [[ -d $CONFIGMAP_PATH ]]; then
+        for file in `ls $CONFIGMAP_PATH`;
+        do
+            if [[ -f $DORIS_HOME/be/conf/$file ]]; then
+                mv $DORIS_HOME/be/conf/$file $DORIS_HOME/be/conf/$file.bak
+            fi
+        done
+    fi
+
+    for file in `ls $CONFIGMAP_PATH`;
+    do
+        if [[ "$file" == "be.conf" ]]; then
+            cp $CONFIGMAP_PATH/$file $DORIS_HOME/be/conf/$file
+            add_cluster_info_to_conf
+            continue
+        fi
+
+        ln -sfT $CONFIGMAP_PATH/$file $DORIS_HOME/be/conf/$file 
+    done
+}
+
+function parse_config_file_with_key()
+{
+    local key=$1
+    local value=`grep "^\s*$key\s*=" $CONFIG_FILE | sed 
"s|^\s*$key\s*=\s*\(.*\)\s*$|\1|g"`
+}
+
+function parse_my_self_address()
+{
+    local my_ip=`hostname -i | awk '{print $1}'`
+    local my_fqdn=`hostname -f`
+    if [[ $HOST_TYPE == "IP" ]]; then
+        MY_SELF=$my_ip
+    else
+        MY_SELF=$my_fqdn
+    fi
+}
+
+function variables_initial()
+{
+    parse_my_self_address
+    local heartbeat_port=$(parse_config_file_with_key "heartbeat_service_port")
+    if [[ "x$heartbeat_port" != "x" ]]; then
+        HEARTBEAT_PORT=$heartbeat_port
+    fi
+}
+
+function check_or_register_in_ms()
+{
+    interval=5
+    start=$(date +%s)
+    timeout=60
+    while true;
+    do
+        local 
find_address="http://$MS_ENDPOINT/MetaService/http/get_cluster?token=$MS_TOKEN";
+        local output=$(curl -s $find_address \
+              -d 
'{"cloud_unique_id":"'$CLOUD_UNIQUE_ID'","cluster_id":"'$CLUSTER_ID'"}')
+        if grep -q -w "$MY_SELF" <<< $output &>/dev/null; then
+            log_stderr "[INFO] $MY_SELF have register in instance id 
$INSTANCE_ID cluser id $CLUSTER_ID!"
+            return
+        fi
+
+        local code=$(jq -r ".code" <<< $output)
+        if [[ "$code" == "NOT_FOUND" ]]; then
+           # if grep -q -w "$CLUSTER_ID" <<< $output &>/dev/null; then
+           #     log_stderr "[INFO] cluster id $CLUSTER_ID have exists, only 
register self.!"
+           #     add_my_self
+           # else
+           log_stderr "[INFO] register cluster id $CLUSTER_ID with myself 
$MY_SELF into instance id $INSTANCE_ID."
+           add_my_self_with_cluster
+           # fi
+        else
+            log_stderr "[INFO] register $MY_SELF into cluster id $CLUSTER_ID!"
+            add_my_self
+        fi
+
+        local now=$(date +%s)
+        let "expire=start+timeout"
+        if [[ $expire -le $now ]]; then
+            log_stderr "[ERROR] Timeout for register myself to ms, abort!"
+            exit 1
+        fi
+        sleep $interval
+    done
+}
+
+function add_my_self()
+{
+    local 
register_address="http://$MS_ENDPOINT/MetaService/http/add_node?token=$MS_TOKEN";
+    local output=$(curl -s $register_address \
+              -d '{"instance_id":"'$INSTANCE_ID'",
+              "cluster":{"type":"COMPUTE","cluster_id":"'$CLUSTER_ID'",
+              
"nodes":[{"cloud_unique_id":"'$CLOUD_UNIQUE_ID'","ip":"'$MY_SELF'","host":"'$MY_SELF'","heartbeat_port":'$HEARTBEAT_PORT'}]}}')
+    local code=$(jq -r ".code" <<< $output)
+    if [[ "$code" == "OK" ]]; then
+        log_stderr "[INFO] my_self $MY_SELF register to ms $MS_ENDPOINT 
instance_id $INSTANCE_ID be cluster $CLUSTER_ID success."
+    else
+        log_stderr "[ERROR] my_self $MY_SELF register ms $MS_ENDPOINT 
instance_id $INSTANCE_ID be cluster $CLUSTER_ID failed,err=$output!"
+    fi
+}
+
+function add_my_self_with_cluster()
+{
+    local 
register_address="http://$MS_ENDPOINT/MetaService/http/add_cluster?token=$MS_TOKEN";
+    local output=$(curl -s $register_address \
+              -d '{"instance_id":"'$INSTANCE_ID'",
+              
"cluster":{"type":"COMPUTE","cluster_name":"'$CLUSTER_NAME'","cluster_id":"'$CLUSTER_ID'",
+              
"nodes":[{"cloud_unique_id":"'$CLOUD_UNIQUE_ID'","ip":"'$MY_SELF'","host":"'$MY_SELF'","heartbeat_port":'$HEARTBEAT_PORT'}]}}')
+    local code=$(jq -r ".code" <<< $output)
+    if [[ "$code" == "OK" ]]; then
+        log_stderr "[INFO] cluster $CLUSTER_ID contains $MY_SELF register to 
ms $MS_ENDPOINT instance_id $INSTANCE_ID success."
+    else
+        log_stderr "[ERROR] cluster $CLUSTER_ID contains $MY_SELF register to 
ms $MS_ENDPOINT instance_id $INSTANCE_ID failed,err=$output!"
+    fi
+}
+
+add_cluster_info_to_conf
+link_config_files
+variables_initial
+check_or_register_in_ms
+
+$DORIS_HOME/be/bin/start_be.sh --console
diff --git a/docker/runtime/be/resource/be_disaggregated_prestop.sh 
b/docker/runtime/be/resource/be_disaggregated_prestop.sh
new file mode 100755
index 00000000000..06808b72206
--- /dev/null
+++ b/docker/runtime/be/resource/be_disaggregated_prestop.sh
@@ -0,0 +1,23 @@
+#!/bin/bash
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+#
+
+DORIS_HOME=${DORIS_HOME:="/opt/apache-doris"}
+
+$DORIS_HOME/be/bin/stop_be.sh --grace
diff --git a/docker/runtime/be/resource/be_disaggregated_probe.sh 
b/docker/runtime/be/resource/be_disaggregated_probe.sh
new file mode 100755
index 00000000000..741d78c750f
--- /dev/null
+++ b/docker/runtime/be/resource/be_disaggregated_probe.sh
@@ -0,0 +1,64 @@
+#!/bin/bash
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+#
+
+PROBE_TYPE=$1
+DORIS_HOME=${DORIS_HOME:="/opt/apache-doris"}
+CONFIG_FILE="$DORIS_HOME/be/conf/be.conf"
+DEFAULT_HEARTBEAT_SERVICE_PORT=9050
+DEFAULT_WEBSERVER_PORT=8040
+
+function parse_config_file_with_key()
+{
+    local key=$1
+    local value=`grep "^\s*$key\s*=" $CONFIG_FILE | sed 
"s|^\s*$key\s*=\s*\(.*\)\s*$|\1|g"`
+    echo $value
+}
+
+function alive_probe()
+{
+    local heartbeat_service_port=$(parse_config_file_with_key 
"heartbeat_service_port")
+    
heartbeat_service_port=${heartbeat_service_port:=$DEFAULT_HEARTBEAT_SERVICE_PORT}
+    if netstat -lntp | grep ":$heartbeat_service_port" > /dev/null ; then
+        exit 0
+    else
+        exit 1
+    fi
+}
+
+function ready_probe()
+{
+    local webserver_port=$(parse_config_file_with_key "webserver_port")
+    webserver_port=${webserver_port:=$DEFAULT_WEBSERVER_PORT}
+    local ip=`hostname -i | awk '{print $1}'`
+    local url="http://${ip}:${webserver_port}/api/health";
+    local res=$(curl -s $url)
+    local status=$(jq -r ".status" <<< $res)
+    if [[ "x$status" == "xOK" ]]; then
+        exit 0
+    else
+        exit 1
+    fi
+}
+
+if [[ "$PROBE_TYPE" == "ready" ]]; then
+    ready_probe
+else
+    alive_probe
+fi
diff --git a/docker/runtime/broker/resource/amd64/x64_package_is_here 
b/docker/runtime/broker/resource/amd64/x64_package_is_here
new file mode 100644
index 00000000000..c92bb295a23
--- /dev/null
+++ b/docker/runtime/broker/resource/amd64/x64_package_is_here
@@ -0,0 +1,23 @@
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+
+This file is not required for building an image.
+It is just a reminder for you: If you build a docker image yourself,
+please place the installation package (already unzipped) corresponding to the 
CPU architecture at the same level as this file.
diff --git a/docker/runtime/broker/resource/arm64/arm64_package_is_here 
b/docker/runtime/broker/resource/arm64/arm64_package_is_here
new file mode 100644
index 00000000000..c92bb295a23
--- /dev/null
+++ b/docker/runtime/broker/resource/arm64/arm64_package_is_here
@@ -0,0 +1,23 @@
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+
+This file is not required for building an image.
+It is just a reminder for you: If you build a docker image yourself,
+please place the installation package (already unzipped) corresponding to the 
CPU architecture at the same level as this file.
diff --git a/docker/runtime/fe/resource/amd64/x64_package_is_here 
b/docker/runtime/fe/resource/amd64/x64_package_is_here
new file mode 100644
index 00000000000..c92bb295a23
--- /dev/null
+++ b/docker/runtime/fe/resource/amd64/x64_package_is_here
@@ -0,0 +1,23 @@
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+
+This file is not required for building an image.
+It is just a reminder for you: If you build a docker image yourself,
+please place the installation package (already unzipped) corresponding to the 
CPU architecture at the same level as this file.
diff --git a/docker/runtime/fe/resource/arm64/arm64_package_is_here 
b/docker/runtime/fe/resource/arm64/arm64_package_is_here
new file mode 100644
index 00000000000..c92bb295a23
--- /dev/null
+++ b/docker/runtime/fe/resource/arm64/arm64_package_is_here
@@ -0,0 +1,23 @@
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+
+This file is not required for building an image.
+It is just a reminder for you: If you build a docker image yourself,
+please place the installation package (already unzipped) corresponding to the 
CPU architecture at the same level as this file.
diff --git a/docker/runtime/fe/resource/fe_disaggregated_entrypoint.sh 
b/docker/runtime/fe/resource/fe_disaggregated_entrypoint.sh
new file mode 100755
index 00000000000..d9af8ab612a
--- /dev/null
+++ b/docker/runtime/fe/resource/fe_disaggregated_entrypoint.sh
@@ -0,0 +1,207 @@
+#!/bin/bash
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+
+# ms address, fe pod's address should register in it.
+MS_ENDPOINT=${MS_ENDPOINT}
+MS_TOKEN=${MS_TOKEN:="greedisgood9999"}
+ELECT_NUMBER=${ELECT_NUMBER:=1}
+FE_EDIT_PORT=${FE_EDIT_PORT:=9010}
+# cloud_id is default.
+CLUSTER_ID=${CLUSTER_ID:="RESERVED_CLUSTER_ID_FOR_SQL_SERVER"}
+# cloud_name is default.
+CLUSTER_NAME=${CLUSTER_NAME:="RESERVED_CLUSTER_NAME_FOR_SQL_SERVER"}
+#the instance id, pod's address should register in instance->cluster.
+INSTANCE_ID=${INSTANCE_ID}
+MY_SELF=
+HOSTNAME=`hostname`
+STATEFULSET_NAME=${STATEFULSET_NAME}
+POD_NAME=${POD_NAME}
+CLOUD_UNIQUE_ID_PRE=${CLOUD_UNIQUE_ID_PRE:="1:$INSTANCE_ID"}
+CLOUD_UNIQUE_ID="$CLOUD_UNIQUE_ID_PRE:$POD_NAME"
+
+CONFIGMAP_PATH=${CONFIGMAP_MOUNT_PATH:="/etc/doris"}
+DORIS_HOME=${DORIS_HOME:="/opt/apache-doris"}
+CONFIG_FILE="$DORIS_HOME/fe/conf/fe.conf"
+
+SEQUENCE_NUMBER=$(hostname | awk -F '-' '{print $NF}')
+NODE_TYPE="FE_MASTER"
+
+if [ "$SEQUENCE_NUMBER" -ge "$ELECT_NUMBER" ]; then
+    NODE_TYPE="FE_OBSERVER"
+fi
+
+# 1. add default config in config file or link config files.
+# 2. assign global variables.
+# 3. register myself.
+
+
+function log_stderr()
+{
+    echo "[`date`] $@" >& 1
+}
+
+function add_cluster_info_to_conf()
+{
+    echo "meta_service_endpoint=$MS_ENDPOINT" >> $DORIS_HOME/fe/conf/fe.conf
+    echo "cloud_unique_id=$CLOUD_UNIQUE_ID" >> $DORIS_HOME/fe/conf/fe.conf
+}
+
+function link_config_files()
+{
+    if [[ -d $CONFIGMAP_PATH ]]; then
+        #backup files want to replace
+        for file in `ls $CONFIGMAP_PATH`;
+        do
+            if [[ -f $DORIS_HOME/fe/conf/$file ]]; then
+                mv $DORIS_HOME/fe/conf/$file $DORIS_HOME/fe/conf/$file.bak
+            fi
+        done
+
+        for file in `ls $CONFIGMAP_PATH`;
+        do
+            if [[ "$file" == "fe.conf" ]]; then
+                cp $CONFIGMAP_PATH/$file $DORIS_HOME/fe/conf/$file
+                add_cluster_info_to_conf
+                continue
+            fi
+
+            ln -sfT $CONFIGMAP_PATH/$file $DORIS_HOME/fe/conf/$file
+        done
+    fi
+}
+
+parse_config_file_with_key()
+{
+    local key=$1
+    local value=`grep "^\s*$key\s*=" $CONFIG_FILE | sed 
"s|^\s*$key\s*=\s*\(.*\)\s*$|\1|g"`
+    echo $value
+}
+
+# confirm the register address, if config `enable_fqdn_mode=true` use fqdn 
start or use ip.
+function parse_my_self_address()
+{
+    local value=`parse_config_file_with_key "enable_fqdn_mode"`
+
+    local my_ip=`hostname -i | awk '{print $1}'`
+    local my_fqdn=`hostname -f`
+    if [[ $value == "true" ]]; then
+        MY_SELF=$my_fqdn
+    else
+        MY_SELF=$my_ip
+    fi
+}
+
+function variables_inital()
+{
+    parse_my_self_address
+    local edit_port=$(parse_config_file_with_key "edit_log_port")
+    if [[ "x$edit_port" != "x" ]]; then
+        FE_EDIT_PORT=${edit_port:=$FE_EDIT_PORT}
+    fi
+    
+}
+
+function check_or_register_in_ms()
+{
+    interval=5
+    start=$(date +%s)
+    timeout=60
+    while true;
+    do
+        local 
find_address="http://$MS_ENDPOINT/MetaService/http/get_cluster?token=$MS_TOKEN";
+        local output=$(curl -s $find_address \
+                  -d '{"cloud_unique_id": "'$CLOUD_UNIQUE_ID'",
+                  "cluster_id": "RESERVED_CLUSTER_ID_FOR_SQL_SERVER"}')
+        if grep -q -w $MY_SELF <<< $output &>/dev/null ; then
+            log_stderr "[INFO] $MY_SELF have registerd in metaservice!"
+            return
+        fi
+
+        local code=$(jq -r ".code" <<< $output)
+        if [[ "$code" == "NOT_FOUND" ]]; then
+        #    if grep -q -w "RESERVED_CLUSTER_NAME_FOR_SQL_SERVER" <<< $output 
&>/dev/null; then
+        #        log_stderr "[INFO] RESERVED_CLUSTER_NAME_FOR_SQL_SERVER fe 
cluster have exist, register node $MY_SELF."
+        #        add_my_self
+        #    else
+             log_stderr "[INFO] RESERVED_CLUSTER_NAME_FOR_SQL_SERVER fe 
cluster not exist, register fe clsuter."
+             add_my_self_with_cluster
+        #    fi
+        else
+            log_stderr "[INFO] register myself $MY_SELF into fe cluster 
cloud_unique_id $CLOUD_UNIQUE_ID."
+            add_my_self 
+        fi
+
+        local now=$(date +%s)
+        let "expire=start+timeout"
+        if [[ $expire -le $now ]]; then
+            log_stderr "[ERROR] Timeout for register myself to ms, abort!"
+            exit 1
+        fi
+        sleep $interval
+    done
+}
+
+function add_my_self()
+{
+    local 
register_address="http://$MS_ENDPOINT/MetaService/http/add_node?token=$MS_TOKEN";
+    local curl_cmd="curl -s $register_address -d 
'{\"instance_id\":\"$INSTANCE_ID\",\"cluster\":{\"type\":\"SQL\",\"cluster_name\":\"RESERVED_CLUSTER_NAME_FOR_SQL_SERVER\",\"cluster_id\":\"RESERVED_CLUSTER_ID_FOR_SQL_SERVER\",\"nodes\":[{\"cloud_unique_id\":\"$CLOUD_UNIQUE_ID\",\"ip\":\"$MY_SELF\",\"host\":\"$MY_SELF\",\"edit_log_port\":9010,\"node_type\":\"$NODE_TYPE\"}]}}'"
+    # echo "add_my_self: $curl_cmd"
+    local output=$(eval "$curl_cmd")
+    # echo "add_my_self response:$output"
+    local code=$(jq -r ".code" <<< $output)
+    if [[ "$code" == "OK" ]]; then
+        log_stderr "[INFO] my_self $MY_SELF register to ms $MS_ENDPOINT 
instance_id $INSTANCE_ID fe cluster RESERVED_CLUSTER_NAME_FOR_SQL_SERVER 
success!"
+    else
+        log_stderr "[ERROR] my_self register ms $MS_ENDPOINT instance_id 
$INSTANCE_ID fe cluster failed, response $output!"
+    fi
+}
+
+function add_my_self_with_cluster()
+{
+    local 
register_address="http://$MS_ENDPOINT/MetaService/http/add_cluster?token=$MS_TOKEN";
+    local 
curl_data="{\"instance_id\":\"$INSTANCE_ID\",\"cluster\":{\"type\":\"SQL\",\"cluster_name\":\"RESERVED_CLUSTER_NAME_FOR_SQL_SERVER\",\"cluster_id\":\"RESERVED_CLUSTER_ID_FOR_SQL_SERVER\",\"nodes\":[{\"cloud_unique_id\":\"$CLOUD_UNIQUE_ID\",\"ip\":\"$MY_SELF\",\"host\":\"$MY_SELF\",\"node_type\":\"$NODE_TYPE\",\"edit_log_port\":$FE_EDIT_PORT}]}}"
+    local curl_cmd="curl -s $register_address -d '$curl_data'"
+    # echo "add_my_self_with_cluster: $curl_cmd"
+    local output=$(eval "$curl_cmd")
+    # echo "add_my_self_with_cluster response: $output"
+    code=$(jq -r ".code" <<< $output)
+    if [[ "$code" == "OK" ]]; then
+        log_stderr "[INFO] fe cluster contains $MY_SELF node_type $NODE_TYPE 
register to ms $MS_ENDPOINT instance_id $INSTANCE_ID success."
+    else
+        log_stderr "[ERROR] fe cluster contains $MY_SELF node_type $NODE_TYPE 
register to ms $MS_ENDPOINT instance_id $INSTANCE_ID faied, $output!"
+    fi
+}
+
+function check_and_modify_fqdn_config()
+{
+    local enable_fqdn=`parse_config_file_with_key "enable_fqdn_mode"`
+    log_stderr "enable_fqdn is : $enable_fqdn"
+    if [[ "x$enable_fqdn" != "xtrue" ]] ; then
+        log_stderr "add enable_fqdn_mode = true to $CONFIG_FILE"
+        echo "enable_fqdn_mode = true" >> $CONFIG_FILE
+    fi
+}
+
+add_cluster_info_to_conf
+check_and_modify_fqdn_config
+link_config_files
+variables_inital
+check_or_register_in_ms
+/opt/apache-doris/fe/bin/start_fe.sh --console
+
diff --git a/docker/runtime/fe/resource/fe_disaggregated_prestop.sh 
b/docker/runtime/fe/resource/fe_disaggregated_prestop.sh
new file mode 100755
index 00000000000..5a101954c91
--- /dev/null
+++ b/docker/runtime/fe/resource/fe_disaggregated_prestop.sh
@@ -0,0 +1,23 @@
+#!/bin/bash
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+#
+
+DORIS_HOME=${DORIS_HOME:="/opt/apache-doris"}
+
+$DORIS_HOME/fe/bin/stop_fe.sh --grace
diff --git a/docker/runtime/fe/resource/fe_disaggregated_probe.sh 
b/docker/runtime/fe/resource/fe_disaggregated_probe.sh
new file mode 100755
index 00000000000..31d96d32d6d
--- /dev/null
+++ b/docker/runtime/fe/resource/fe_disaggregated_probe.sh
@@ -0,0 +1,64 @@
+#!/bin/bash
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+#
+
+DORIS_HOEM=${DORIS_HOME:="/opt/apache-doris"}
+CONFIG_FILE="$DORIS_HOME/fe/conf/fe.conf"
+DEFAULT_HTTP_PORT=8030
+DEFAULT_QUERY_PORT=9030
+PROBE_TYPE=$1
+
+function parse_config_file_with_key()
+{
+    local key=$1
+    local value=`grep "^\s*$key\s*=" $CONFIG_FILE | sed 
"s|^\s*$key\s*=\s*\(.*\)\s*$|\1|g"`
+    echo $value
+}
+
+function alive_probe()
+{
+    local query_port=$(parse_config_file_with_key "query_port")
+    query_port=${query_port:=$DEFAULT_QUERY_PORT}
+    if netstat -lntp | grep ":$query_port" > /dev/null ; then
+        exit 0
+    else
+        exit 1
+    fi
+}
+
+function ready_probe()
+{
+    local http_port=$(parse_config_file_with_key "http_port")
+    http_port=${http_port:=$DEFAULT_HTTP_PORT}
+    local ip=`hostname -i | awk '{print $1}'`
+    local url="http://${ip}:${http_port}/api/health";
+    local res=$(curl -s $url)
+    local code=$(jq -r ".code" <<< $res)
+    if [[ "x$code" == "x0" ]]; then
+        exit 0
+    else
+        exit 1
+    fi
+}
+
+if [[ "$PROBE_TYPE" == "ready" ]]; then
+    ready_probe
+else
+    alive_probe
+fi
diff --git a/docker/runtime/ms/Dockerfile b/docker/runtime/ms/Dockerfile
new file mode 100644
index 00000000000..d50f3ec05ff
--- /dev/null
+++ b/docker/runtime/ms/Dockerfile
@@ -0,0 +1,57 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# how to use Dockerfile.
+# this is dockerfile for build doris ms image
+# when build youself image.
+# 1. pull binary from official website and decompress into resource directory 
that the level equals with this Dockerfile.
+# 2. untar xxxx.tar.gz in resource/{arch} directory, makesure your doris 
package real version and target arch.
+# 3. run commad docker build -t xxx.doris.ms:xx -f Dockerfile --build-arg 
DORIS_VERSION=3.0.0
+
+# we have support buildx for amd64 and arm64 architecture image build.
+# get the binary from doris github and utar into resource, update the 
directory as apache-`version(example:3.0.0)`-bin-`architecture(amd64/arm64)` 
mode.
+
+# choose a base image
+FROM selectdb/base:latest
+
+ARG TARGETARCH
+
+ARG DORIS_VERSION="x.x.x"
+
+
+RUN if echo $DORIS_VERSION | grep -E 
'^([3-9]|([1-9]([0-9])))|^branch\-([3-9]|([1-9]([0-9])))|master.*' >>/dev/null 
; then \
+        ln -s /usr/lib/jvm/jdk-17 /usr/lib/jvm/java && \
+        rm -rf /usr/lib/jvm/jdk-8; \
+    else \
+        ln -s /usr/lib/jvm/jdk-8 /usr/lib/jvm/java && \
+        rm -rf /usr/lib/jvm/jdk-17; \
+    fi;
+
+# set environment variables
+ENV JAVA_HOME=/usr/lib/jvm/java
+ENV PATH=$PATH:$JAVA_HOME/bin:/opt/apache-doris/ms/bin
+
+COPY resource/${TARGETARCH:-amd64}/apache-doris-${DORIS_VERSION}-bin-*/ms 
/opt/apache-doris/ms
+
+COPY resource/ms_*.sh /opt/apache-doris/
+
+#RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
+
+WORKDIR /opt/apache-doris
+
+#ENTRYPOINT ["bash","entry_point.sh"]
+ENTRYPOINT ["bash","ms_disaggregated_entrypoint.sh"]
diff --git a/docker/runtime/ms/resource/amd64/x64_package_is_here 
b/docker/runtime/ms/resource/amd64/x64_package_is_here
new file mode 100644
index 00000000000..c92bb295a23
--- /dev/null
+++ b/docker/runtime/ms/resource/amd64/x64_package_is_here
@@ -0,0 +1,23 @@
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+
+This file is not required for building an image.
+It is just a reminder for you: If you build a docker image yourself,
+please place the installation package (already unzipped) corresponding to the 
CPU architecture at the same level as this file.
diff --git a/docker/runtime/ms/resource/arm64/arm64_package_is_here 
b/docker/runtime/ms/resource/arm64/arm64_package_is_here
new file mode 100644
index 00000000000..c92bb295a23
--- /dev/null
+++ b/docker/runtime/ms/resource/arm64/arm64_package_is_here
@@ -0,0 +1,23 @@
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+
+This file is not required for building an image.
+It is just a reminder for you: If you build a docker image yourself,
+please place the installation package (already unzipped) corresponding to the 
CPU architecture at the same level as this file.
diff --git a/docker/runtime/ms/resource/ms_disaggregated_entrypoint.sh 
b/docker/runtime/ms/resource/ms_disaggregated_entrypoint.sh
new file mode 100755
index 00000000000..e3415b1d0c4
--- /dev/null
+++ b/docker/runtime/ms/resource/ms_disaggregated_entrypoint.sh
@@ -0,0 +1,44 @@
+#!/bin/bash
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+#
+
+#get from env
+FDB_ENDPOINT=${FDB_ENDPOINT}
+CONFIGMAP_PATH=${CONFIGMAP_PATH:="/etc/doris"}
+DORIS_HOME=${DORIS_HOME:="/opt/apache-doris"}
+
+echo "fdb_cluster=$FDB_ENDPOINT" >> $DORIS_HOME/ms/conf/doris_cloud.conf
+if [[ -d $CONFIGMAP_PATH ]]; then
+    for file in `ls $CONFIGMAP_PATH`
+        do
+            if [[ "$file" == "doris_cloud.conf" ]] ; then
+                mv -f $DORIS_HOME/ms/conf/$file $DORIS_HOME/ms/conf/$file.bak
+                cp $CONFIGMAP_PATH/$file $DORIS_HOME/ms/conf/$file
+                echo "fdb_cluster=$FDB_ENDPOINT" >> 
$DORIS_HOME/ms/conf/doris_cloud.conf
+                continue
+            fi
+
+            if test -e $DORIS_HOME/ms/conf/$file ; then
+                mv -f $DORIS_HOME/ms/conf/$file $DORIS_HOME/ms/conf/$file.bak
+            fi
+            ln -sfT $CONFIGMAP_PATH/$file $DORIS_HOME/ms/conf/$file
+       done
+fi
+
+$DORIS_HOME/ms/bin/start.sh --$1
diff --git a/docker/runtime/ms/resource/ms_disaggregated_prestop.sh 
b/docker/runtime/ms/resource/ms_disaggregated_prestop.sh
new file mode 100755
index 00000000000..f92acad40a8
--- /dev/null
+++ b/docker/runtime/ms/resource/ms_disaggregated_prestop.sh
@@ -0,0 +1,24 @@
+#!/bin/bash
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+
+#get from env
+DORIS_HOME=${DORIS_HOME:="/opt/apache-doris"}
+
+$DORIS_HOME/ms/bin/stop.sh --$1
+
diff --git a/docker/runtime/ms/resource/ms_disaggregated_probe.sh 
b/docker/runtime/ms/resource/ms_disaggregated_probe.sh
new file mode 100755
index 00000000000..87bb316375f
--- /dev/null
+++ b/docker/runtime/ms/resource/ms_disaggregated_probe.sh
@@ -0,0 +1,62 @@
+#!/bin/bash
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+DORIS_HOME=${DORIS_HOME:="/opt/apache-doris"}
+CONFIG_FILE="$DORIS_HOME/ms/conf/doris_cloud.conf"
+DEFAULT_BRPC_LISTEN_PORT=5000
+PROBE_TYPE=$1
+
+log_stderr()
+{
+    echo "[`date`] $@" >&2
+}
+
+function parse_config_file_with_key()
+{
+    local key=$1
+    local value=`grep "^\s*$key\s*=" $CONFIG_FILE | sed 
"s|^\s*$key\s*=\s*\(.*\)\s*$|\1|g"`
+    echo $value
+}
+
+function alive_probe()
+{
+    local brpc_listen_port=$(parse_config_file_with_key "brpc_listen_port")
+    brpc_listen_port=${brpc_listen_port:=$DEFAULT_BRPC_LISTEN_PORT}
+    if netstat -lntp | grep ":$brpc_listen_port" > /dev/null ; then
+        exit 0
+    else
+        exit 1
+    fi
+}
+
+function ready_probe()
+{
+    local brpc_listen_port=$(parse_config_file_with_key "brpc_listen_port")
+    brpc_listen_port=${brpc_listen_port:=$DEFAULT_BRPC_LISTEN_PORT}
+    if netstat -lntp | grep ":$brpc_listen_port" > /dev/null ; then
+        exit 0
+    else
+        exit 1
+    fi
+}
+
+if [[ "$PROBE_TYPE" == "ready" ]]; then
+    ready_probe
+else
+    alive_probe
+fi


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org


Reply via email to