support github action

This commit is contained in:
LINxiansheng
2023-09-18 12:14:17 +00:00
committed by ob-robot
parent d762f213e8
commit 69a2ee9689
7 changed files with 109 additions and 28 deletions

View File

@ -16,17 +16,15 @@ function is_true() {
return 0
}
# return 0 if mini_mode is nil or 'no'/'false'/0
# 0 means true and 1 for false in bash
function is_mini_mode() {
if test -z ${MINI_MODE}
function get_mode() {
if test -z ${MODE}
then
return 1
MODE="MINI"
fi
return `is_true ${MINI_MODE}`
MODE=${MODE^^}
}
function exit_while_error() {
if test -z ${EXIT_WHILE_ERROR}
then
@ -47,6 +45,32 @@ function remove_disk_check_logic_in_obd() {
done
}
function run_custom_scripts {
INIT_SCRIPTS_ROOT="${1}";
# Check whether parameter has been passed on
if [ -z "${INIT_SCRIPTS_ROOT}" ]; then
echo "No INIT_SCRIPTS_ROOT passed on, no scripts will be run.";
return;
fi;
# Execute custom provided files (only if directory exists and has files in it)
if [ -d "${INIT_SCRIPTS_ROOT}" ] && [ -n "$(ls -A "${INIT_SCRIPTS_ROOT}")" ]; then
echo -e "Executing user defined scripts..."
run_custom_scripts_recursive ${INIT_SCRIPTS_ROOT}
echo -e "DONE: Executing user defined scripts.\n"
fi;
}
function run_custom_scripts_recursive {
local f
for f in "${1}"/*; do
echo -e "running ${f} ...";
obclient -h127.1 -uroot@${OB_TENANT_NAME} -A -P${OB_MYSQL_PORT} < ${f}
echo "DONE: running ${f}";
done
}
# We should decide whether the observer's data exists and
# whether the obd has the information of the cluster
@ -60,20 +84,29 @@ else # nothing here, bootstrap
echo "generate boot.yaml ..."
TMPFILE="boot.${STAMP}.yaml"
if is_mini_mode
then
get_mode
if [ "x${MODE}" == "xMINI" ]; then
echo "oceanbase-ce docker in mini mode"
cp -f boot-mini-tmp.yaml $TMPFILE
elif [ "x${MODE}" == "xSLIM" ]; then
echo "oceanbase-ce docker in slim mode"
cp -f boot-mini-tmp.yaml $TMPFILE
else
cp -f boot-tmp.yaml $TMPFILE
fi
cat obagent.yaml >> $TMPFILE
if [ "x${MODE}" != "xSLIM" ]; then
cat obagent.yaml >> $TMPFILE
fi
sed -i "s|@OB_HOME_PATH@|${OB_HOME_PATH}|g" $TMPFILE
sed -i "s|@OB_MYSQL_PORT@|${OB_MYSQL_PORT}|g" $TMPFILE
sed -i "s|@OB_RPC_PORT@|${OB_RPC_PORT}|g" $TMPFILE
sed -i "s|@OB_CLUSTER_NAME@|${OB_CLUSTER_NAME}|g" $TMPFILE
sed -i "s|@OB_MEMORY_LIMIT@|${OB_MEMORY_LIMIT}|g" $TMPFILE
sed -i "s|@OB_DATAFILE_SIZE@|${OB_DATAFILE_SIZE}|g" $TMPFILE
sed -i "s|@OB_LOG_DISK_SIZE@|${OB_LOG_DISK_SIZE}|g" $TMPFILE
sed -i "s|@OB_ROOT_PASSWORD@|${OB_ROOT_PASSWORD}|g" $TMPFILE
[ "${OB_DATA_DIR}" ] && echo " data_dir: ${OB_DATA_DIR}" >> $TMPFILE
[ "${OB_REDO_DIR}" ] && echo " redo_dir: ${OB_REDO_DIR}" >> $TMPFILE
@ -84,12 +117,27 @@ else # nothing here, bootstrap
&& obd mirror list local
remove_disk_check_logic_in_obd
obd devmode enable \
&& obd cluster autodeploy "${OB_CLUSTER_NAME}" -c $TMPFILE \
&& obd cluster tenant create "${OB_CLUSTER_NAME}" -n ${OB_TENANT_NAME} \
&& obclient -h127.1 -uroot@${OB_TENANT_NAME} -A -P${OB_MYSQL_PORT} < init_tenant_user.sql \
&& mv -f $TMPFILE ${OB_HOME_PATH}/boot.yaml \
&& echo "deploy success!"
obd devmode enable && obd cluster autodeploy "${OB_CLUSTER_NAME}" -c $TMPFILE;
create_tenant_cmd="obd cluster tenant create ${OB_CLUSTER_NAME} -n ${OB_TENANT_NAME}"
if ! [ -z "${OB_TENANT_MINI_CPU}" ]; then
create_tenant_cmd="${create_tenant_cmd} --min-cpu=${OB_TENANT_MINI_CPU}"
fi;
if ! [ -z "${OB_TENANT_MEMORY_SIZE}" ]; then
create_tenant_cmd="${create_tenant_cmd} --memory-size=${OB_TENANT_MEMORY_SIZE}"
fi;
if ! [ -z "${OB_TENANT_LOG_DISK_SIZE}" ]; then
create_tenant_cmd="${create_tenant_cmd} --log-disk-size=${OB_TENANT_LOG_DISK_SIZE}"
fi;
eval ${create_tenant_cmd}
if [ "x${MODE}" != "xSLIM" ]; then
obclient -h127.1 -uroot@${OB_TENANT_NAME} -A -P${OB_MYSQL_PORT} < init_tenant_user.sql
else
run_custom_scripts /root/boot/init.d
fi
mv -f $TMPFILE ${OB_HOME_PATH}/boot.yaml && echo "deploy success!"
fi
if [ $? -eq 0 ]; then

View File

@ -1,7 +1,12 @@
MINI_MODE=${MINI_MODE:-true}
MINI_MODE=${MINI_MODE:-MINI}
EXIT_WHILE_ERROR=${EXIT_WHILE_ERROR:-true}
OB_HOME_PATH="/root/ob"
OB_MYSQL_PORT="2881"
OB_RPC_PORT="2882"
OB_CLUSTER_NAME="obcluster"
OB_TENANT_NAME="test"
OB_CLUSTER_NAME=${OB_CLUSTER_NAME:-obcluster}
OB_TENANT_NAME=${OB_TENANT_NAME:-test}
OB_MEMORY_LIMIT=${OB_MEMORY_LIMIT:-6G}
OB_DATAFILE_SIZE=${OB_DATAFILE_SIZE:-5G}
OB_LOG_DISK_SIZE=${OB_LOG_DISK_SIZE:-5G}
OB_ROOT_PASSWORD=${OB_ROOT_PASSWORD:-}
OB_SYSTEM_MEMORY=${OB_SYSTEM_MEMORY:-1G}

View File

@ -11,10 +11,10 @@ oceanbase-ce:
zone: zone1
cluster_id: 1
# please set memory limit to a suitable value which is matching resource.
memory_limit: 6G # The maximum running memory for an observer
system_memory: 1G # The reserved system memory. system_memory is reserved for general tenants. The default value is 30G.
datafile_size: 5G # Size of the data file.
log_disk_size: 5G # The size of disk space used by the clog files.
memory_limit: @OB_MEMORY_LIMIT@ # The maximum running memory for an observer
system_memory: @OB_SYSTEM_MEMORY@ # The reserved system memory. system_memory is reserved for general tenants. The default value is 30G.
datafile_size: @OB_DATAFILE_SIZE@ # Size of the data file.
log_disk_size: @OB_LOG_DISK_SIZE@ # The size of disk space used by the clog files.
cpu_count: 16
production_mode: true
syslog_level: INFO # System log level. The default value is INFO.
@ -22,3 +22,4 @@ oceanbase-ce:
enable_syslog_recycle: true # Enable auto system log recycling or not. The default value is false.
max_syslog_file_count: 4 # The maximum number of reserved log files before enabling auto recycling. The default value is 0.
appname: @OB_CLUSTER_NAME@
root_password: @OB_ROOT_PASSWORD@

View File

@ -9,3 +9,4 @@ oceanbase-ce:
datafile_size: 20G
log_disk_size: 20G
appname: @OB_CLUSTER_NAME@
root_password: @OB_ROOT_PASSWORD@