support github action
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
FROM openanolis/anolisos:8.8
|
||||
FROM openanolis/anolisos
|
||||
|
||||
# docker build --build-arg VERSION={VERSION} .
|
||||
ARG VERSION
|
||||
|
||||
@ -34,8 +34,11 @@ OceanBase 提供了一个独立部署的测试镜像[oceanbase-ce](https://hub.d
|
||||
# 部署最小规格实例
|
||||
docker run -p 2881:2881 --name oceanbase-ce -d oceanbase/oceanbase-ce
|
||||
|
||||
# 根据当前容器情况部署最小规格的实例
|
||||
docker run -p 2881:2881 --name oceanbase-ce -e MODE=slim -e OB_MEMORY_LIMIT=5G -v {init_sql_folder_path}:/root/boot/init.d -d oceanbase/oceanbase-ce
|
||||
|
||||
# 根据当前容器情况部署最大规格的实例
|
||||
docker run -p 2881:2881 --name oceanbase-ce -e MINI_MODE=0 -d oceanbase/oceanbase-ce
|
||||
docker run -p 2881:2881 --name oceanbase-ce -e MODE=normal -d oceanbase/oceanbase-ce
|
||||
```
|
||||
|
||||
启动预计需要 2-5 分钟。执行以下命令,如果返回 `boot success!`,则启动成功。
|
||||
@ -71,8 +74,18 @@ mysql -uroot -h127.1 -P2881
|
||||
|
||||
| 变量名称 | 默认值 | 描述 |
|
||||
| ---------------- | ------------- | ------------------------------------------------------------ |
|
||||
| MINI_MODE | true | true表示使用mini 模式部署OceanBase数据库实例,仅用来研究学习使用。不适合用于生产或性能测试。 |
|
||||
| MODE | {mini, slim, normal} | mini或者不赋值变量表示使用mini模式部署OceanBase数据库实例,仅用来研究学习使用。不适合用于生产或性能测试。slim适用于更小的自定义配置,移除obagent,支持自定义的初始化脚本在绑定目录/root/boot/init.d,如果不绑定该目录,docker不会执行该租户的初始化sql。|
|
||||
| EXIT_WHILE_ERROR | true | OceanBase 如果启动失败,是否退出容器。比如初次run镜像失败,或start容器失败,可以将此参数设置为false,那么OB启动失败,也可以进入容器,查看OceanBase的运行日志,然后进行排查。 |
|
||||
| OB_CLUSTER_NAME | obcluster | oceanbase集群名 |
|
||||
| OB_TENANT_NAME | test | oceanbase mysql租户名|
|
||||
| OB_MEMORY_LIMIT | 6G | oceanbase启动memory_limit参数配置 |
|
||||
| OB_DATAFILE_SIZE | 5G | oceanbase启动datafile_size参数配置 |
|
||||
| OB_LOG_DISK_SIZE | 5G | oceanbase启动log_disk_size参数配置 |
|
||||
| OB_ROOT_PASSWORD | | oceanbase启动sys租户的root用户密码配置 |
|
||||
| OB_SYSTEM_MEMORY | 1G | oceanbase启动system_memory参数配置 |
|
||||
| OB_TENANT_MINI_CPU | | oceanbase租户mini_cpu参数配置 |
|
||||
| OB_TENANT_MEMORY_SIZE | | oceanbase租户memory_size参数配置 |
|
||||
| OB_TENANT_LOG_DISK_SIZE | | oceanbase租户log_disk_size参数配置 |
|
||||
|
||||
## 运行 Sysbench 脚本
|
||||
|
||||
|
||||
@ -34,8 +34,11 @@ To start an OceanBase instance, run this command:
|
||||
# deploy mini instance
|
||||
docker run -p 2881:2881 --name oceanbase-ce -d oceanbase/oceanbase-ce
|
||||
|
||||
# deploy an instance of the slim size according to the current container
|
||||
docker run -p 2881:2881 --name oceanbase-ce -e MODE=slim -e OB_MEMORY_LIMIT=5G -v {init_sql_folder_path}:/root/boot/init.d -d oceanbase/oceanbase-ce
|
||||
|
||||
# deploy an instance of the largest size according to the current container
|
||||
docker run -p 2881:2881 --name oceanbase-ce -e MINI_MODE=0 -d oceanbase/oceanbase-ce
|
||||
docker run -p 2881:2881 --name oceanbase-ce -e MODE=normal -d oceanbase/oceanbase-ce
|
||||
```
|
||||
|
||||
Two to five minutes are necessary for the boot procedure. To make sure that the boot procedure is successful, run this command:
|
||||
@ -69,8 +72,18 @@ This table shows the supported environment variables of the current oceanbase-ce
|
||||
|
||||
| Variable name | Default value | Description |
|
||||
| ---------------- | ------------- | ------------------------------------------------------------ |
|
||||
| MINI_MODE | false | If ture, will use mini mode to deploy OceanBase Database instance, it should be used only for research/study/evaluation. DO NOT use it for production or performance testing. |
|
||||
| MODE | {mini, slim, normal} | If it is mini, then the docker use mini mode to deploy OceanBase Database instance, it should be used only for research/study/evaluation. DO NOT use it for production or performance testing. If it is slim, then the docker can run in a smaller instance. It remove the obagent and can run a self tenant initial sql by yourself in the mount volume /root/boot/init.d. If you do not mount the volume path the docker does not init the tenant sql. |
|
||||
| EXIT_WHILE_ERROR | true | Whether quit the container while start observer failed. If start observer failed, you can not explore the logs as the container will exit. But if you set the EXIT_WHILE_ERROR=false, the container will not exit while observer starting fail and you can use docker exec to debug. |
|
||||
| OB_CLUSTER_NAME | obcluster | The oceanbase cluster name |
|
||||
| OB_TENANT_NAME | test | The oceanbase mysql tenant name |
|
||||
| OB_MEMORY_LIMIT | 6G | The oceanbase cluster memory_limit configuration |
|
||||
| OB_DATAFILE_SIZE | 5G | The oceanbase cluster datafile_size configuration |
|
||||
| OB_LOG_DISK_SIZE | 5G | The oceanbase cluster log_disk_size configuration |
|
||||
| OB_ROOT_PASSWORD | | The oceanbase root user password of sys tenant |
|
||||
| OB_SYSTEM_MEMORY | 1G | The oceanbase cluster system_memory configuration |
|
||||
| OB_TENANT_MINI_CPU | | The oceanbase tenant mini_cpu configuration |
|
||||
| OB_TENANT_MEMORY_SIZE | | The oceanbase tenant memory_size configuration |
|
||||
| OB_TENANT_LOG_DISK_SIZE | | The oceanbase tenant log_disk_size configuration |
|
||||
|
||||
## Run the Sysbench script
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
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
|
||||
|
||||
@ -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}
|
||||
@ -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@
|
||||
|
||||
@ -9,3 +9,4 @@ oceanbase-ce:
|
||||
datafile_size: 20G
|
||||
log_disk_size: 20G
|
||||
appname: @OB_CLUSTER_NAME@
|
||||
root_password: @OB_ROOT_PASSWORD@
|
||||
|
||||
Reference in New Issue
Block a user