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

Optimize the packaged deployment module of dss1.0.0 #388

Merged
merged 1 commit into from
Aug 23, 2021
Merged
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
112 changes: 112 additions & 0 deletions assembly/bin/appconn-install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
#!/bin/sh
#Actively load user env
source ~/.bashrc
shellDir=`dirname $0`
workDir=`cd ${shellDir}/..;pwd`

SOURCE_ROOT=${workDir}

#load config
source ${SOURCE_ROOT}/conf/config.sh
source ${SOURCE_ROOT}/conf/db.sh

APPCONN_NAME=''
APPCONN_INSTALL_IP=127.0.0.1
APPCONN_INSTALL_PORT=8088

#echo "Current path of init sql is ${DB_DML_PATH}"
LOCAL_IP="`ifconfig | grep 'inet' | grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $2}'`"

function isSuccess(){
if [ $? -ne 0 ]; then
echo "Failed to " + $1
exit 1
else
echo "Succeed to" + $1
fi
}

PROC_NAME=DSSProjectServerApplication
ProcNumber=`ps -ef |grep -w $PROC_NAME|grep -v grep|wc -l`
if [ $ProcNumber -le 0 ];then
echo "${PROC_NAME} is not running,Please check whether DSS is installed"
exit 1000
else
echo "Begine to install appconn"
fi

##choose install mysql mode
function initInstallAppConn() {
echo "Please select the type of installation component?"
echo " 1: schedulis"
echo " 2: visualis"
echo " 3:Your AppConn Name"
echo " 4:exit"
read -p "Please input the choice:" idx
if [[ '1' = "$idx" ]];then
APPCONN_NAME="schedulis"
elif [[ '2' = "$idx" ]];then
APPCONN_NAME="visualis"
elif [[ '4' = "$idx" ]];then
echo "no choice,exit!"
exit 1
else
APPCONN_NAME=$idx
fi
echo "Current installation component is ${APPCONN_NAME}"

echo ""
echo "If this machine(127.0.0.1) is installed, enter 1"
echo "For others, you need to enter a complete IP address."
read -p "Please enter the ip of appconn: " ip
APPCONN_INSTALL_IP=$ip
if [[ '1' = "$ip" ]];then
APPCONN_INSTALL_IP="127.0.0.1"
fi
echo "You input ip is ${APPCONN_INSTALL_IP}"

echo ""
read -p "Please enter the port of appconn:" port
APPCONN_INSTALL_PORT=$port
echo "You input ip is ${APPCONN_INSTALL_PORT}"
}

function replaceCommonIp() {
if [[ $APPCONN_INSTALL_IP == "127.0.0.1" ]] || [[ $APPCONN_INSTALL_IP == "0.0.0.0" ]];then
echo "APPCONN_INSTALL_IP is equals $APPCONN_INSTALL_IP, we will change it to ip address"
APPCONN_INSTALL_IP=$LOCAL_IP
fi
}

##choose execute mysql mode
function executeSQL() {
TEMP_DB_DML_PATH=${SOURCE_ROOT}/dss-appconns/${APPCONN_NAME}/db
DB_DML_PATH=$TEMP_DB_DML_PATH/init_real.sql
cp -rf $TEMP_DB_DML_PATH/init.sql $DB_DML_PATH
sed -i "s/APPCONN_INSTALL_IP/$APPCONN_INSTALL_IP/g" $DB_DML_PATH
sed -i "s/APPCONN_INSTALL_PORT/$APPCONN_INSTALL_PORT/g" $DB_DML_PATH
sed -i "s#DSS_INSTALL_HOME_VAL#$DSS_INSTALL_HOME#g" $DB_DML_PATH
mysql -h$MYSQL_HOST -P$MYSQL_PORT -u$MYSQL_USER -p$MYSQL_PASSWORD -D$MYSQL_DB --default-character-set=utf8 -e "source $DB_DML_PATH"
isSuccess "source $DB_DML_PATH"
echo "the table update finished"
}

echo ""
echo "step1:Initialize installation settings"
initInstallAppConn
echo ""

echo "step2:replaceIp"
replaceCommonIp
echo ""

echo "step3:update database"
executeSQL
echo ""

echo "step4:refresh appconn load"
curl -H "Token-Code:BML-AUTH" -H "Token-User:hadoop" -X GET http://${GATEWAY_INSTALL_IP}:${GATEWAY_PORT}/api/rest_j/v1/dss/framework/project/appconn/${APPCONN_NAME}/load
echo ""

echo "Please restart services of DSS's and Linkis's"

43 changes: 43 additions & 0 deletions assembly/bin/checkEnv.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/sh
#
# Copyright 2019 WeBank
#
# Licensed 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.
#
say() {
printf 'check command fail \n %s\n' "$1"
}

err() {
say "$1" >&2
exit 1
}

check_cmd() {
command -v "$1" > /dev/null 2>&1
}

need_cmd() {
if ! check_cmd "$1"; then
err "need '$1' (your linux command not found)"
fi
}
echo "<-----start to check used cmd---->"
need_cmd yum
need_cmd java
need_cmd mysql
need_cmd telnet
need_cmd tar
need_cmd sed
need_cmd dos2unix
echo "<-----end to check used cmd---->"
102 changes: 102 additions & 0 deletions assembly/bin/excecuteSQL.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
#!/bin/sh

function checkExternalServer(){
echo "telnet check for your $SERVER_NAME, if you wait for a long time,may be your $SERVER_NAME does not prepared"
result=`echo -e "\n" | telnet $EXTERNAL_SERVER_IP $EXTERNAL_SERVER_PORT 2>/dev/null | grep Connected | wc -l`
if [ $result -eq 1 ]; then
echo "$SERVER_NAME is OK."
else
echo "$SERVER_NAME is Bad. You need to prepare the' $SERVER_NAME ' environment in advance"
exit 1
fi
}

## choose install mode
function chooseInstallMode() {
echo "Simple installation mode"
#check for Java
checkJava
#check for mysql
SERVER_NAME=MYSQL
EXTERNAL_SERVER_IP=$MYSQL_HOST
EXTERNAL_SERVER_PORT=$MYSQL_PORT
checkExternalServer
}

##choose install mysql mode
function chooseInstallMySQLMode() {
echo "Do you want to clear Dss table information in the database?"
echo " 1: Do not execute table-building statements"
echo " 2: Dangerous! Clear all data and rebuild the tables."
echo ""
MYSQL_INSTALL_MODE=1
read -p "Please input the choice:" idx
if [[ '2' = "$idx" ]];then
MYSQL_INSTALL_MODE=2
echo "You chose Rebuild the table"
elif [[ '1' = "$idx" ]];then
MYSQL_INSTALL_MODE=1
echo "You chose not execute table-building statements"
else
echo "no choice,exit!"
exit 1
fi

##init db
if [[ '2' = "$MYSQL_INSTALL_MODE" ]];then
ENV_FLAG="dev"
DB_CONF_PATH=${workDir}/db
DB_DML_PATH=$DB_CONF_PATH/dss_dml_real.sql
replaceAppConnInstanceSQL
executeSQL
fi
}

##choose execute mysql mode
function executeSQL() {
chooseInstallMode

sed -i "s/GATEWAY_INSTALL_IP/$GATEWAY_INSTALL_IP/g" $DB_DML_PATH
sed -i "s/GATEWAY_PORT/$GATEWAY_PORT/g" $DB_DML_PATH

sed -i "s#DSS_INSTALL_HOME_VAL#$DSS_INSTALL_HOME#g" $DB_DML_PATH

mysql -h$MYSQL_HOST -P$MYSQL_PORT -u$MYSQL_USER -p$MYSQL_PASSWORD -D$MYSQL_DB --default-character-set=utf8 -e "source $DB_CONF_PATH/dss_ddl.sql"
isSuccess "source dss_ddl.sql"
mysql -h$MYSQL_HOST -P$MYSQL_PORT -u$MYSQL_USER -p$MYSQL_PASSWORD -D$MYSQL_DB --default-character-set=utf8 -e "source $DB_DML_PATH"
isSuccess "source dss_dml_real.sql"
echo "Rebuild the table"
}

function replaceAppConnInstanceSQL() {
DB_DML_PATH=$DB_CONF_PATH/dss_dml_real.sql
cp -rf $DB_CONF_PATH/dss_dml.sql $DB_DML_PATH
sed -i "s#ORCHESTRATOR_IP#$DSS_FRAMEWORK_ORCHESTRATOR_SERVER_INSTALL_IP#g" $DB_DML_PATH
sed -i "s#ORCHESTRATOR_PORT#$DSS_FRAMEWORK_ORCHESTRATOR_SERVER_PORT#g" $DB_DML_PATH

sed -i "s#WORKFLOW_IP#$DSS_WORKFLOW_SERVER_INSTALL_IP#g" $DB_DML_PATH
sed -i "s#WORKFLOW_PORT#$DSS_WORKFLOW_SERVER_PORT#g" $DB_DML_PATH

sed -i "s#EVENTCHECKER_JDBC_URL#$EVENTCHECKER_JDBC_URL#g" $DB_DML_PATH
sed -i "s#EVENTCHECKER_JDBC_USERNAME#$EVENTCHECKER_JDBC_USERNAME#g" $DB_DML_PATH
sed -i "s#EVENTCHECKER_JDBC_PASSWORD#$EVENTCHECKER_JDBC_PASSWORD#g" $DB_DML_PATH

sed -i "s#DATACHECKER_JOB_JDBC_URL#$DATACHECKER_JOB_JDBC_URL#g" $DB_DML_PATH
sed -i "s#DATACHECKER_JOB_JDBC_USERNAME#$DATACHECKER_JOB_JDBC_USERNAME#g" $DB_DML_PATH
sed -i "s#DATACHECKER_JOB_JDBC_PASSWORD#$DATACHECKER_JOB_JDBC_PASSWORD#g" $DB_DML_PATH

sed -i "s#DATACHECKER_BDP_JDBC_URL#$DATACHECKER_BDP_JDBC_URL#g" $DB_DML_PATH
sed -i "s#DATACHECKER_BDP_JDBC_USERNAME#$DATACHECKER_BDP_JDBC_USERNAME#g" $DB_DML_PATH
sed -i "s#DATACHECKER_BDP_JDBC_PASSWORD#$DATACHECKER_BDP_JDBC_PASSWORD#g" $DB_DML_PATH

sed -i "s#BDP_MASK_IP#127.0.0.1#g" $DB_DML_PATH
sed -i "s#BDP_MASK_PORT#8087#g" $DB_DML_PATH

sed -i "s#EMAIL_HOST#${EMAIL_HOST}#g" $DB_DML_PATH
sed -i "s#EMAIL_PORT#${EMAIL_PORT}#g" $DB_DML_PATH
sed -i "s#EMAIL_USERNAME#${EMAIL_USERNAME}#g" $DB_DML_PATH
sed -i "s#EMAIL_PASSWORD#${EMAIL_PASSWORD}#g" $DB_DML_PATH
sed -i "s#EMAIL_PROTOCOL#${EMAIL_PROTOCOL}#g" $DB_DML_PATH
}

chooseInstallMySQLMode
Loading