Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: linkis service distributed deployment. #4730

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions linkis-dist/bin/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ source ${workDir}/bin/common.sh
##load config
echo "======= Step 1: Load deploy-config/* =========="
export LINKIS_CONFIG_PATH=${LINKIS_CONFIG_PATH:-"${workDir}/deploy-config/linkis-env.sh"}
export LINKIS_DISTRIBUTION_CONFIG_PATH=${LINKIS_CONFIG_PATH:-"${workDir}/deploy-config/linkis-distribution-env.sh"}
export LINKIS_DB_CONFIG_PATH=${LINKIS_DB_CONFIG_PATH:-"${workDir}/deploy-config/db.sh"}

source ${LINKIS_CONFIG_PATH}
Expand Down Expand Up @@ -112,6 +113,7 @@ else
fi

cp ${LINKIS_CONFIG_PATH} $LINKIS_HOME/conf
cp ${LINKIS_DISTRIBUTION_CONFIG_PATH} $LINKIS_HOME/conf
cp ${LINKIS_DB_CONFIG_PATH} $LINKIS_HOME/conf

common_conf=$LINKIS_HOME/conf/linkis.properties
Expand Down
42 changes: 42 additions & 0 deletions linkis-dist/deploy-config/linkis-distribution-env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/usr/bin/env 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.
#

# description: Stop all Server
#
# Modified for Linkis 1.0.0
#Actively load user env

#Configure the ip addresses of each service cluster. Multiple ip addresses are separated by commas (,)
#eureka cluster,
EUREKA_SERVER_IPS=127.0.0.1

#gateway cluster
GATEWAY_SERVER_IPS=127.0.0.1

#publicservice server cluster
PUBLICSERVICE_SERVER_IPS=127.0.0.1

#linkis manager server cluster
MANAGER_SERVER_IPS=127.0.0.1

#entrance cluster
ENTRANCE_SERVER_IPS=127.0.0.1

#ecm cluster
ENGINECONNMANAGER_SERVER_IPS=127.0.0.1

#ssh port
SSH_PORT=22
5 changes: 4 additions & 1 deletion linkis-dist/package/sbin/linkis
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,12 @@ function checkServer() {
echo -e "<-------------- ${YELLOW}Linkis-$1 ${NC} ------------------>"
echo "Begin to check $1"
sh $LINKIS_HOME/sbin/linkis-daemon.sh status $1
if [ "$LINKIS_LOG_DIR" = "" ]; then
export LINKIS_LOG_DIR=$LINKIS_HOME/logs
fi
if [ $? -ne 0 ]; then
ALL_SERVER_NAME=linkis-$1
LOG_PATH=$LINKIS_HOME/logs/$ALL_SERVER_NAME.log
LOG_PATH=$LINKIS_LOG_DIR/$ALL_SERVER_NAME.log
echo "ERROR: your $ALL_SERVER_NAME microservice does not start successful !!! ERROR logs as follows :"
echo "Please check detail log, log path :$LOG_PATH"
else
Expand Down
294 changes: 294 additions & 0 deletions linkis-dist/package/sbin/linkis-distribution
Original file line number Diff line number Diff line change
@@ -0,0 +1,294 @@
#!/bin/sh
#
# 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.
#

source /etc/profile
source ~/.bash_profile

cd `dirname $0`
cd ..
INSTALL_HOME=`pwd`

# set LINKIS_HOME
if [ "$LINKIS_HOME" = "" ]; then
export LINKIS_HOME=$INSTALL_HOME
fi

source ${LINKIS_HOME}/sbin/common.sh

# set LINKIS_CONF_DIR
if [ "$LINKIS_CONF_DIR" = "" ]; then
export LINKIS_CONF_DIR=$LINKIS_HOME/conf
fi
source $LINKIS_CONF_DIR/linkis-env.sh
source $LINKIS_CONF_DIR/linkis-distribution-env.sh

export ENGINE_MANAGER=cg-engineconnmanager
export ENTRANCE=cg-entrance
export LINKISMANAGER=cg-linkismanager
export GATEWAY=mg-gateway
export EUREKA=mg-eureka
export PUBLICSERVICE=ps-publicservice

YELLOW='\033[0;33m'

help() {
echo "<----------------------------------------------------------->"
echo "NAME"
echo " linkis-distribution manage the distributed linkis service"
echo "SYNOPSIS"
echo " linkis-distribution [OPTION] [SERVICE-NAME | ALIAS]"
echo "DESCRIPTION"
echo ""
echo " help, display this help and exit"
echo ""
echo " start, start all service"
echo ""
echo " start [service-name], start [service-name] service"
echo ""
echo " stop, stop all service"
echo ""
echo " stop [service-name], stop [service-name] service"
echo ""
echo " status, show all service status"
echo ""
echo " status [service-name], show [service-name] service status"
echo ""
echo " restart, restart all service"
echo ""
echo " restart [service-name], restart [service-name] service"
echo ""
echo "SERVICE-NAME"
echo " cg-engineconnmanager alias 1"
echo " cg-entrance alias 2"
echo " cg-linkismanager alias 3"
echo " mg-eureka alias 4"
echo " mg-gateway alias 5"
echo " ps-publicservice alias 6"
echo "<----------------------------------------------------------->"
exit 1
}

status(){
echo -e "<-------------- ${YELLOW}Linkis-$1 ${NC} ------------------>"
SERVER_CMD="sh $LINKIS_HOME/sbin/linkis-daemon.sh status $1"
ip_arr=(`echo $2 | tr ',' ' '`)
for current_ip in ${ip_arr[*]}
do
echo "[$current_ip]"
executeCMD $current_ip "$SERVER_CMD"
if [ "$LINKIS_LOG_DIR" = "" ]; then
export LINKIS_LOG_DIR=$LINKIS_HOME/logs
fi
if [ $? -ne 0 ]; then
ALL_SERVER_NAME=linkis-$1
LOG_PATH=$LINKIS_LOG_DIR/$ALL_SERVER_NAME.log
echo "ERROR: your $ALL_SERVER_NAME microservice does not start successful !!! ERROR logs as follows :"
echo "Please check detail log, log path :$LOG_PATH"
else
echo [OK]
echo ""
echo ""
fi
done
echo "<-------------------------------->"
#sleep 1
}

status_all(){
status $ENGINE_MANAGER $ENGINECONNMANAGER_SERVER_IPS
status $ENTRANCE $ENTRANCE_SERVER_IPS
status $LINKISMANAGER $MANAGER_SERVER_IPS
status $EUREKA $EUREKA_SERVER_IPS
status $GATEWAY $GATEWAY_SERVER_IPS
status $PUBLICSERVICE $PUBLICSERVICE_SERVER_IPS
}

stop(){
SERVER_CMD="sh $LINKIS_HOME/sbin/linkis-daemon.sh stop $1"
ip_arr=(`echo $2 | tr ',' ' '`)
for current_ip in ${ip_arr[*]}
do
echo "[$current_ip]"
executeCMD $current_ip "$SERVER_CMD"
done
}

stop_all(){
stop $ENGINE_MANAGER $ENGINECONNMANAGER_SERVER_IPS
stop $ENTRANCE $ENTRANCE_SERVER_IPS
stop $LINKISMANAGER $MANAGER_SERVER_IPS
stop $EUREKA $EUREKA_SERVER_IPS
stop $GATEWAY $GATEWAY_SERVER_IPS
stop $PUBLICSERVICE $PUBLICSERVICE_SERVER_IPS
}

start(){
SERVER_CMD="sh $LINKIS_HOME/sbin/linkis-daemon.sh start $1"
ip_arr=(`echo $2 | tr ',' ' '`)
for current_ip in ${ip_arr[*]}
do
echo "[$current_ip]"
executeCMD $current_ip "$SERVER_CMD"
done
}

start_all(){
start $EUREKA $EUREKA_SERVER_IPS
start $GATEWAY $GATEWAY_SERVER_IPS
start $PUBLICSERVICE $PUBLICSERVICE_SERVER_IPS
start $LINKISMANAGER $MANAGER_SERVER_IPS
start $ENTRANCE $ENTRANCE_SERVER_IPS
start $ENGINE_MANAGER $ENGINECONNMANAGER_SERVER_IPS
}

restart(){
stop $1 $2
start $1 $2
}

restart_all(){
stop_all
start_all
}


#Select an execution method based on the input parameters. If you do not enter this parameter, follow the instructions
case "$1" in
"start")
case "$2" in
"$ENGINE_MANAGER" | 1)
start $ENGINE_MANAGER $ENGINECONNMANAGER_SERVER_IPS
;;
"$ENTRANCE" | 2)
start $ENTRANCE $ENTRANCE_SERVER_IPS
;;
"$LINKISMANAGER" | 3)
start $LINKISMANAGER $MANAGER_SERVER_IPS
;;
"$EUREKA" | 4)
start $EUREKA $EUREKA_SERVER_IPS
;;
"$GATEWAY" | 5)
start $GATEWAY $GATEWAY_SERVER_IPS
;;
"$PUBLICSERVICE" | 6)
start $PUBLICSERVICE $PUBLICSERVICE_SERVER_IPS
;;
*)
if [ "$2" = "" ]; then
start_all
else
echo "Please enter the correct service name"
echo "Run help to view the service name"
fi
;;
esac
;;
"stop")
case "$2" in
"$ENGINE_MANAGER" | 1)
stop $ENGINE_MANAGER $ENGINECONNMANAGER_SERVER_IPS
;;
"$ENTRANCE" | 2)
stop $ENTRANCE $ENTRANCE_SERVER_IPS
;;
"$LINKISMANAGER" | 3)
stop $LINKISMANAGER $MANAGER_SERVER_IPS
;;
"$EUREKA" | 4)
stop $EUREKA $EUREKA_SERVER_IPS
;;
"$GATEWAY" | 5)
stop $GATEWAY $GATEWAY_SERVER_IPS
;;
"$PUBLICSERVICE" | 6)
stop $PUBLICSERVICE $PUBLICSERVICE_SERVER_IPS
;;
*)
if [ "$2" = "" ]; then
stop_all
else
echo "Please enter the correct service name"
echo "Run help to view the service name"
fi
;;
esac
;;
"status")
case "$2" in
"$ENGINE_MANAGER" | 1)
status $ENGINE_MANAGER $ENGINECONNMANAGER_SERVER_IPS
;;
"$ENTRANCE" | 2)
status $ENTRANCE $ENTRANCE_SERVER_IPS
;;
"$LINKISMANAGER" | 3)
status $LINKISMANAGER $MANAGER_SERVER_IPS
;;
"$EUREKA" | 4)
status $EUREKA $EUREKA_SERVER_IPS
;;
"$GATEWAY" | 5)
status $GATEWAY $GATEWAY_SERVER_IPS
;;
"$PUBLICSERVICE" | 6)
status $PUBLICSERVICE $PUBLICSERVICE_SERVER_IPS
;;
*)
if [ "$2" = "" ]; then
status_all
else
echo "Please enter the correct service name"
echo "Run help to view the service name"
fi
;;
esac
;;
"restart")
case "$2" in
"$ENGINE_MANAGER" | 1)
restart $ENGINE_MANAGER $ENGINECONNMANAGER_SERVER_IPS
;;
"$ENTRANCE" | 2)
restart $ENTRANCE $ENTRANCE_SERVER_IPS
;;
"$LINKISMANAGER" | 3)
restart $LINKISMANAGER $MANAGER_SERVER_IPS
;;
"$EUREKA" | 4)
restart $EUREKA $EUREKA_SERVER_IPS
;;
"$GATEWAY" | 5)
restart $GATEWAY $GATEWAY_SERVER_IPS
;;
"$PUBLICSERVICE" | 6)
restart $PUBLICSERVICE $PUBLICSERVICE_SERVER_IPS
;;
*)
if [ "$2" = "" ]; then
stop_all
restart_all
else
echo "Please enter the correct service name"
echo "Run help to view the service name"
fi
;;
esac
;;
*)
help
;;
esac
Loading