提交 1f5c1bfd 编写于 作者: 羽飞's avatar 羽飞 提交者: wangzelin.wzl

do not force to make sure there is enough disk space for observer in docker any more

上级 f327de39
FROM oceanbase/centos7:latest
ARG GIT_SOURCE=github
RUN yum-config-manager --add-repo https://mirrors.aliyun.com/oceanbase/OceanBase.repo && yum install -y ob-deploy-1.2.1 obclient ob-sysbench wget rpm* cpio make glibc-devel glibc-headers m4 git obclient && mkdir /root/pkg && cd /root/pkg && rm -rf /usr/obd/mirror/remote/* && yumdownloader oceanbase-ce oceanbase-ce-libs && obd mirror clone *rpm && obd mirror list local && rm -rf * && yum clean all
WORKDIR /root/.obd/plugins/oceanbase/3.1.0
RUN sed -i 's/system_memory = max(4 << 30, system_memory)/system_memory = max(3 << 30, system_memory)/g' generate_config.py || echo 'system_memory changed'
RUN sed -i 's/if memory_limit < MIN_MEMORY:/if False and (memory_limit < MIN_MEMORY):/g' generate_config.py || echo 'memory_limit changed'
RUN sed -i '/_start_check(plugin_context, strict_check)/a\ success = True' start_check.py || echo 'check changed'
# clone code
RUN mkdir -p /root/source \
&& cd /root/source \
&& git clone https://${GIT_SOURCE}.com/oceanbase/oceanbase
WORKDIR /root/source/oceanbase
RUN sed -i 's/const int64_t ObRunningModeConfig::MINI_MEM_LOWER = 8L << 30;/const int64_t ObRunningModeConfig::MINI_MEM_LOWER = 4L << 30;/g' deps/oblib/src/lib/ob_running_mode.cpp || echo "ob_running_mode.cpp no need patched"
RUN sh build.sh debug --init \
&& sh build.sh --make -j4 \
&& cd build_debug \
&& make DESTDIR=. install \
&& obd mirror create -n oceanbase-ce -V 100.0.0 -p ./usr/local -t test -f
COPY boot /root/boot/
ENV PATH /root/boot:$PATH
WORKDIR /root
CMD _boot
**当前镜像已不在维护,相关能力由 [standalone](../standalone/README-CN.md#启动-oceanbase-实例) 提供**
# 如何使用这个镜像
部署 OceanBase 数据库的方式有很多,使用 Docker 是其中较方便的一种。本仓库提供了 OceanBase 数据库的 Docker 镜像 obce-mini。obce-mini 是 OceanBase 数据库社区版的小规格单机体验镜像,仅供研究、学习和评估使用,不适用于生产环境或性能测试场景。
## 前提条件
在部署 obce-mini 镜像之前,您需要确认以下信息:
- 确保您的机器至少提供 2 核 10GB 以上的资源。
- 您的机器已经安装以下程序:
应用程序 | 推荐版本 | 参考文档
--- | ------ | -----
Docker | 最新版 | [Docker 文档](https://docs.docker.com/get-docker/)
- 您的机器已经启动 Docker 服务。
## 启动 OceanBase 实例
运行以下命令,启动 OceanBase 的实例:
```bash
docker run -p 2881:2881 --name some-obce -d oceanbase/obce-mini
```
启动预计需要 2-5 分钟。执行以下命令,如果返回 `boot success!`,则启动成功。
```bash
$ docker logs some-obce | tail -1
boot success!
```
## 连接 OceanBase 实例
obce-mini 镜像安装了 OceanBase 数据库客户端 obclient,并提供了默认连接脚本 ob-mysql。
```bash
docker exec -it some-obce ob-mysql sys # 连接 sys 租户
docker exec -it some-obce ob-mysql root # 连接用户租户的 root 账户
docker exec -it some-obce ob-mysql test # 连接用户租户的 test 账户
```
您也可以运行以下命令,使用您本机的 obclient 或者 MySQL 客户端连接实例。
```bash
$mysql -uroot -h127.1 -P2881
```
连接成功后,终端将显示如下内容:
```mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 167310
Server version: 5.7.25 OceanBase 3.1.0 (r-00672c3c730c3df6eef3b359eae548d8c2db5ea2) (Built Jun 22 2021 12:46:28)
Copyright (c) 2000, 2021, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
```
## 支持的环境变量
下表列出了当前版本的 obce-mini 镜像支持的环境变量:
变量名称 | 默认值 | 描述
------- | ----- | ---
OB_HOME_PATH | /root/ob | OceanBase 数据库实例的部署路径。
OB_MYSQL_PORT | 2881 | OceanBase 数据库实例的 MySQL 协议端口。
OB_RPC_PORT | 2882 | OceanBase 数据库实例的 RPC 通信端口。
OB_ROOT_PASSWORD | empty | OceanBase 数据库实例 sys 租户的密码。
OB_CLUSTER_NAME | mini-ce | OceanBase 数据库实例名称,OBD 将使用这个名称作为集群名。
OB_TENANT_NAME | test | OceanBase 数据库实例默认初始化的用户租户的名称。
## 运行 Sysbench 脚本
obce-mini 镜像默认安装了 Sysbench 工具,并进行了简单配置。您可以依次执行以下命令,使用默认配置运行 Sysbench 脚本。
```bash
docker exec -it some-obce sysbench cleanup # 清理数据
docker exec -it some-obce sysbench prepare # 准备数据
docker exec -it some-obce sysbench run # 进行测试
docker exec -it some-obce sysbench # 依次执行上述三条命令
```
**This image is no longer maintained, and related capabilities are provided by [standalone](../standalone/README.md##start-an-oceanbase-instance)**
# How to use this image
You can deploy OceanBase databases by using many methods. But Docker is the easiest method. This repository gives you an obce-mini image for deploying OceanBase database by using Docker. obce-mini is a mini standalone test image for OceanBase Database Community Edition. You can use it only for research/study/evaluation. DO NOT use it for production or performance testing.
## Prerequisite
Before you deploy obce-mini image, do a check of these:
- Make sure that your machine has at least 2 physical core and 8GB memory.
- Your machine has installed these applications:
Application | Recommended version | Documentation
--- | ------ | -----
Docker | Latest | [Docker Documentation](https://docs.docker.com/get-docker/)
- You have started the Docker service on your machine.
## Start an OceanBase instance
To start an OceanBase instance, run this command:
```bash
docker run -p 2881:2881 --name some-obce -d oceanbase/obce-mini
```
Two to five minutes are necessary for the boot procedure. To make sure that the boot procedure is successful, run this command:
```bash
$ docker logs some-obce | tail -1
boot success!
```
## Connect to an OceanBase instance
obce-mini image contains obclient (OceanBase Database client) and the default connection script `ob-mysql`.
```bash
docker exec -it some-obce ob-mysql sys # Connect to sys tenant
docker exec -it some-obce ob-mysql root # Connect to the root account of a general tenant
docker exec -it some-obce ob-mysql test # Connect to the test account of a general tenant
```
Or you can run this command to connect to an OceanBase instance with your local obclient or MySQL client.
```bash
$mysql -uroot -h127.1 -P2881
```
When you connect to an OceanBase instance successfully, the terminal returns this message:
```mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 167310
Server version: 5.7.25 OceanBase 3.1.0 (r-00672c3c730c3df6eef3b359eae548d8c2db5ea2) (Built Jun 22 2021 12:46:28)
Copyright (c) 2000, 2021, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
```
## Supported environment variables
This table shows the supported environment variables of the current obce-mini mirror version:
Variable name | Default value | Description
------- | ----- | ---
OB_HOME_PATH | /root/ob | Home path for an OceanBase Database instance.
OB_MYSQL_PORT | 2881 | The MySQL protocol port for an OceanBase Database instance.
OB_RPC_PORT | 2882 | The RPC communication port for an OceanBase Database instance.
OB_ROOT_PASSWORD | empty | The password for the system tenant in an OceanBase Database instance.
OB_CLUSTER_NAME | mini-ce | Instance name for OceanBase Database instance. OBD uses this value as its cluster name.
OB_TENANT_NAME | test | The default initialized general tenant name for an OceanBase Database instance.
## Run the Sysbench script
obce-mini image installs the Sysbench tool by default. And the Sysbench tool is configured. You can run these commands in sequence to run the Sysbench script with the default configurations.
```bash
docker exec -it some-obce sysbench cleanup # Clean the data
docker exec -it some-obce sysbench prepare # Prepare the data
docker exec -it some-obce sysbench run # Do the test
docker exec -it some-obce sysbench # Run the preceding three commands in order
```
#!/bin/bash
CWD=$(cd `dirname $0`;pwd)
cd "${CWD}"
source _env
STAMP="$(date +%s)"
[[ -f boot.yaml ]] && echo "find boot.yaml, skip configuring..." || {
echo "generate boot.yaml ..."
TMPFILE="boot.${STAMP}.yaml"
cp -f boot-tmp.yaml $TMPFILE
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_ROOT_PASSWORD@|${OB_ROOT_PASSWORD}|g" $TMPFILE
echo "create boot dirs and deploy ob cluster ..."
mkdir -p $OB_HOME_PATH && obd cluster deploy "${OB_CLUSTER_NAME}" -c $TMPFILE && mv -f $TMPFILE boot.yaml
}
[[ -f boot.yaml ]] && {
echo "start ob cluster ..."
obd cluster restart $OB_CLUSTER_NAME
}
[[ -f init_tenant.sql ]] || {
echo "generate init_tenant.sql ..."
TMPSQL="init_tenant.${STAMP}.sql"
cp -f init_tenant-tmp.sql $TMPSQL
sed -i "s|@OB_TENANT_NAME@|${OB_TENANT_NAME}|g" $TMPSQL
if [[ "${OB_ROOT_PASSWORD}x" != "x" ]]; then
PASSCMD=-p${OB_ROOT_PASSWORD}
fi
echo "init tenant and sysbench database ..."
obclient -h127.1 -uroot@sys -A -Doceanbase -P${OB_MYSQL_PORT} ${PASSCMD} < $TMPSQL &&
obclient -h127.1 -uroot@${OB_TENANT_NAME} -A -P${OB_MYSQL_PORT} < init_tenant_user.sql &&
mv -f ${TMPSQL} init_tenant.sql
} && echo "boot success!" && exec /sbin/init
OB_HOME_PATH=${OB_HOME_PATH:-"/root/ob"}
OB_MYSQL_PORT=${OB_MYSQL_PORT:-"2881"}
OB_RPC_PORT=${OB_RPC_PORT:-"2882"}
OB_ROOT_PASSWORD=${OB_ROOT_PASSWORD:-""}
OB_CLUSTER_NAME=${OB_CLUSTER_NAME:-"mini-ce"}
OB_TENANT_NAME=${OB_TENANT_NAME:-"test"}
#FROM https://gitee.com/oceanbase/obdeploy/blob/master/example/mini-local-example.yaml
oceanbase-ce:
tags: test
servers:
- 127.0.0.1
global:
home_path: @OB_HOME_PATH@ # default: /root/ob
devname: lo
mysql_port: @OB_MYSQL_PORT@ # default: 2881
rpc_port: @OB_RPC_PORT@ # default: 2882
zone: zone1
cluster_id: 1
memory_limit: 6G
system_memory: 3G
stack_size: 512K
cpu_count: 16
cache_wash_threshold: 1G
__min_full_resource_pool_memory: 268435456
workers_per_cpu_quota: 10
schema_history_expire_time: 1d
net_thread_count: 4
sys_bkgd_migration_retry_num: 3
minor_freeze_times: 100
enable_separate_sys_clog: 0
enable_merge_by_turn: FALSE
enable_auto_leader_switch: FALSE
enable_one_phase_commit: FALSE
weak_read_version_refresh_interval: 5s
balancer_idle_time: 10m
trace_log_slow_query_watermark: 1s
large_query_threshold: 1s
clog_sync_time_warn_threshold: 1s
syslog_io_bandwidth_limit: 10M
_cache_wash_interval: 1m
enable_sql_audit: FALSE
enable_perf_event: FALSE
clog_max_unconfirmed_log_count: 5000
autoinc_cache_refresh_interval: 86400s
cpu_quota_concurrency: 2
datafile_size: 5G
syslog_level: WARN
enable_syslog_recycle: TRUE
max_syslog_file_count: 2
enable_early_lock_release: false tenant=all
default_compress_func: lz4_1.0
root_password: @OB_ROOT_PASSWORD@ # default: null
CREATE RESOURCE UNIT IF NOT EXISTS @OB_TENANT_NAME@ max_cpu = 9, max_memory = 2147483648, min_memory = 2147483648, max_iops = 10000, min_iops = 1280, max_session_num = 3000, max_disk_size = 5153960755;
CREATE RESOURCE POOL IF NOT EXISTS @OB_TENANT_NAME@ UNIT = '@OB_TENANT_NAME@', UNIT_NUM = 1, ZONE_LIST = ('zone1');
CREATE TENANT IF NOT EXISTS @OB_TENANT_NAME@ charset='utf8mb4', replica_num=1, zone_list=('zone1'), primary_zone='RANDOM', resource_pool_list=('@OB_TENANT_NAME@');
ALTER SYSTEM SET _clog_aggregation_buffer_amount = 4;
ALTER SYSTEM SET _flush_clog_aggregation_buffer_timeout = '1ms';
ALTER TENANT @OB_TENANT_NAME@ SET VARIABLES ob_timestamp_service = 'GTS';
ALTER TENANT @OB_TENANT_NAME@ SET VARIABLES autocommit = ON;
ALTER TENANT @OB_TENANT_NAME@ SET VARIABLES ob_query_timeout = 36000000000;
ALTER TENANT @OB_TENANT_NAME@ SET VARIABLES ob_trx_timeout = 36000000000;
ALTER TENANT @OB_TENANT_NAME@ SET VARIABLES max_allowed_packet = 67108864;
ALTER TENANT @OB_TENANT_NAME@ SET VARIABLES ob_sql_work_area_percentage = 100;
ALTER TENANT @OB_TENANT_NAME@ SET VARIABLES parallel_max_servers = 20;
ALTER TENANT @OB_TENANT_NAME@ SET VARIABLES parallel_servers_target = 48;
ALTER TENANT @OB_TENANT_NAME@ SET VARIABLES ob_tcp_invited_nodes='%'
CREATE USER 'test'@'%';
GRANT ALL ON test.* TO 'test'@'%';
#!/bin/bash
CWD=$(cd `dirname $0`;pwd)
cd "${CWD}"
source _env
PASSCMD=""
case "$1" in
sys)
LOGIN_USER="root@sys"
DB="oceanbase"
if [[ "${OB_ROOT_PASSWORD}x" != "x" ]]; then
PASSCMD=-p${OB_ROOT_PASSWORD}
fi
;;
root)
DB="oceanbase"
LOGIN_USER="root@${OB_TENANT_NAME}"
;;
*)
DB="test"
LOGIN_USER="test@${OB_TENANT_NAME}"
;;
esac
echo "login as ${LOGIN_USER}"
CMD="obclient -h127.1 -u${LOGIN_USER} -A -D${DB} -P${OB_MYSQL_PORT} ${PASSCMD}"
echo "Command is: ${CMD}"
${CMD}
#!/bin/bash
CWD=$(cd `dirname $0`;pwd)
cd "${CWD}"
source _env
cd /usr/sysbench/share/sysbench
export LD_LIBRARY_PATH=/u01/mysql/lib/
SYSBENCH=/usr/sysbench/bin/sysbench
SYSBENCH_SCRIPT=${SYSBENCH_SCRIPT:-"/usr/sysbench/share/sysbench/oltp_point_select.lua"}
SYSBENCH_TABLE_SIZE=${SYSBENCH_TABLE_SIZE:-20000}
SYSBENCH_TABLE_NUM=${SYSBENCH_TABLE_NUM:-32}
SYSBENCH_THREADS=${SYSBENCH_THREADS:-32}
SYSBENCH_REPORT_INTERVAL=${SYSBENCH_REPORT_INTERVAL:-2}
SYSBENCH_TIME=${SYSBENCH_TIME:-120}
SYSBENCH_CMD="${SYSBENCH} ${SYSBENCH_SCRIPT} --mysql-host=127.0.0.1 --mysql-port=${OB_MYSQL_PORT} --mysql-db=test --mysql-user=test@${OB_TENANT_NAME} --table_size=${SYSBENCH_TABLE_SIZE} --tables=${SYSBENCH_TABLE_NUM} --threads=${SYSBENCH_THREADS} --report-interval=${SYSBENCH_REPORT_INTERVAL} --time=${SYSBENCH_TIME}"
case "$1" in
cleanup)
set -x
${SYSBENCH_CMD} cleanup
;;
prepare)
set -x
${SYSBENCH_CMD} prepare
;;
run)
set -x
${SYSBENCH_CMD} --db-ps-mode=disable run
;;
*)
set -x
${SYSBENCH_CMD} cleanup
${SYSBENCH_CMD} prepare
${SYSBENCH_CMD} --db-ps-mode=disable run
;;
esac
FROM oceanbase/centos7:latest
ARG VERSION=3.1.3-10100032022041510
RUN yum-config-manager --add-repo https://mirrors.aliyun.com/oceanbase/OceanBase.repo && \
yum install -y ob-deploy obclient ob-sysbench wget libaio && \
mkdir /root/pkg && \
rm -rf /usr/obd/mirror/remote/* && \
rm -rf /u01/mysql /u01/obclient/bin/mysqld* /u01/obclient/bin/aria* /u01/obclient/bin/maria* && \
yum clean all
RUN mkdir /root/pkg && \
cd /root/pkg && \
wget https://mirrors.aliyun.com/oceanbase/community/stable/el/7/x86_64/oceanbase-ce-3.1.2-10000392021123010.el7.x86_64.rpm -q && \
wget https://mirrors.aliyun.com/oceanbase/community/stable/el/7/x86_64/oceanbase-ce-libs-3.1.2-10000392021123010.el7.x86_64.rpm -q && \
wget https://mirrors.aliyun.com/oceanbase/community/stable/el/7/x86_64/oceanbase-ce-${VERSION}.el7.x86_64.rpm -q && \
wget https://mirrors.aliyun.com/oceanbase/community/stable/el/7/x86_64/oceanbase-ce-libs-${VERSION}.el7.x86_64.rpm -q && \
rm -rf /usr/obd/mirror/remote/* && \
obd mirror clone *.rpm && \
obd mirror list local && \
rm -rf /root/base /root/pkg && \
yum clean all
COPY boot /root/boot/
ENV PATH /root/boot:$PATH
WORKDIR /root
CMD _boot
......@@ -5,29 +5,57 @@ source _env
STAMP="$(date +%s)"
# 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}
then
return 1
fi
# convert MINI_MODE to upper case string(can work in bash 4.x)
mini_mode=${MINI_MODE^^}
if [ "x${mini_mode}" == "xNO" ] || [ "x${mini_mode}" == "xFALSE" ] || [ "x${mini_mode}" == "x0" ]; then
return 1
fi
return 0
}
function remove_disk_check_logic_in_obd() {
# make sure obd copy the plugin code
obd cluster list
start_check_file='/root/.obd/plugins/oceanbase/3.1.0/start_check.py'
sed -i "s/critical('(%s) %s not enough disk space\. (Avail/alert('(%s) %s not enough disk space\. (Avail/g" $start_check_file
sed -i "s/critical(EC_OBSERVER_NOT_ENOUGH_DISK_4_CLOG/alert(EC_OBSERVER_NOT_ENOUGH_DISK_4_CLOG/g" $start_check_file
}
[[ -f boot.yaml ]] && echo "find boot.yaml, skip configuring..." || {
echo "generate boot.yaml ..."
TMPFILE="boot.${STAMP}.yaml"
if [[ $MINI_MODE == 1 ]]
if is_mini_mode
then
cp -f boot-mini-tmp.yaml $TMPFILE
echo "oceanbase-ce docker in mini mode"
cp -f boot-mini-tmp.yaml $TMPFILE
else
cp -f boot-tmp.yaml $TMPFILE
cp -f boot-tmp.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_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
echo "create boot dirs and deploy ob cluster ..."
mkdir -p $OB_HOME_PATH
if [[ $MINI_MODE == 1 ]]
then
obd cluster deploy "${OB_CLUSTER_NAME}" -c $TMPFILE && obd cluster tenant create "${OB_CLUSTER_NAME}" -n ${OB_TENANT_NAME} && obd cluster start "${OB_CLUSTER_NAME}" && obclient -h127.1 -uroot@${OB_TENANT_NAME} -A -P${OB_MYSQL_PORT} < init_tenant_user.sql && mv -f $TMPFILE boot.yaml
else
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 boot.yaml
fi
remove_disk_check_logic_in_obd
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 boot.yaml
}
[[ -f boot.yaml ]] && {
......
......@@ -8,8 +8,8 @@ oceanbase-ce:
rpc_port: @OB_RPC_PORT@ # default: 2882
zone: zone1
cluster_id: 1
memory_limit: 8G
system_memory: 4G
memory_limit: 6G
system_memory: 3G
stack_size: 512K
cpu_count: 16
cache_wash_threshold: 1G
......
......@@ -7,3 +7,5 @@ oceanbase-ce:
mysql_port: @OB_MYSQL_PORT@ # default: 2881
rpc_port: @OB_RPC_PORT@ # default: 2882
root_password: @OB_ROOT_PASSWORD@ # default: null
datafile_size: 10G
clog_disk_usage_limit_percentage: 98 # default: 80
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册