暂无图片
暂无图片
5
暂无图片
暂无图片
暂无图片

「更易用的OceanBase」| 制作自定义OceanBase容器——逆向思维

原创 李宏达 2022-11-01
1396

前言


使用容器版本安装部署数据库时,是为了更方便便捷的使用,作者在使用OceanBase容器版本部署的时候并未发现相关的Dockerfile且镜像较大,这就导致不能更好的自定义功能,有些背离了容器版本的初衷。

本文利用docker history命令从镜像层剥离dockerfile的相关命令,然后从运行的容器里反推找到boot,涉及到的安装包依赖环境,最终实现dockerfile的编写,替换基础镜像为Ubuntu,最终镜像大小减少了150MB,文末提供了阿里云和docker hub镜像地址及dockerfile 码云地置,欢迎大家测试使用。

一、安装Docker

1. 安装并启动Docker

[root@oceanbase1 ~]# yum install -y yum-utils   device-mapper-persistent-data   lvm2
[root@oceanbase1 ~]# yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
[root@oceanbase1 ~]# yum install docker-ce docker-ce-cli containerd.io docker-compose-plugin -y
[root@oceanbase1 ~]# systemctl start docker
[root@oceanbase1 ~]# systemctl enable docker

二、解析Dockerfile

1. pull

[root@oceanbase1 ~]# docker pull oceanbase/oceanbase-ce
Using default tag: latest
latest: Pulling from oceanbase/oceanbase-ce
13add961a70d: Pull complete
c8175aff0e18: Pull complete
39c994bcc219: Pull complete
71a870d28c6f: Pull complete
Digest: sha256:6c3f458abc38a017e604af1188726174b6dc81f38c96e2869dc2cb04931a8cd8
Status: Downloaded newer image for oceanbase/oceanbase-ce:latest
docker.io/oceanbase/oceanbase-ce:latest

2. 解析

  • 从create by字段提取部分dockerfile内容
[root@oceanbase1 ~]# docker history 4af946862346 --no-trunc
IMAGE                                                                     CREATED         CREATED BY                                                                                                                                                                                                                                                                                                                                                                                           SIZE      COMMENT
sha256:4af94686234630b4e86297637deefbb6e090f1893545aa803dec03269c3e62ca   3 months ago    /bin/sh -c #(nop)  CMD ["/bin/sh" "-c" "_boot"]                                                                                                                                                                                                                                                                                                                                                      0B
<missing>                                                                 3 months ago    /bin/sh -c #(nop) WORKDIR /root                                                                                                                                                                                                                                                                                                                                                                      0B
<missing>                                                                 3 months ago    /bin/sh -c #(nop)  ENV PATH=/root/boot:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin                                                                                                                                                                                                                                                                                                  0B
<missing>                                                                 3 months ago    /bin/sh -c #(nop) COPY dir:8ca8c9383f9767b320dbc0cab03d57ccb39997339cf90b023c4348232edc46e5 in /root/boot/                                                                                                                                                                                                                                                                                           5.32kB
<missing>                                                                 3 months ago    |1 VERSION=3.1.4-10000092022071511 /bin/sh -c mkdir /root/pkg &&     cd /root/pkg &&     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/* &&     yum clean all   51.5MB
<missing>                                                                 3 months ago    |1 VERSION=3.1.4-10000092022071511 /bin/sh -c yum-config-manager --add-repo https://mirrors.aliyun.com/oceanbase/OceanBase.repo &&     yum install -y ob-deploy obclient ob-sysbench wget libaio &&     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                                     292MB
<missing>                                                                 3 months ago    /bin/sh -c #(nop)  ARG VERSION=3.1.3-10100032022041510                                                                                                                                                                                                                                                                                                                                               0B
<missing>                                                                 15 months ago                                                                                                                                                                                                                                                                                                                                                                                                        214MB
  • 找到基础镜像
[root@oceanbase1 oceanbase-docker]# docker start e6318f6ec467
e6318f6ec467
[root@oceanbase1 oceanbase-docker]# docker exec -it oceanbase-ce bash
[root@e6318f6ec467 ~]#
[root@e6318f6ec467 ~]#
[root@e6318f6ec467 ~]# lsb_release
LSB Version:    :core-4.1-amd64:core-4.1-noarch
[root@e6318f6ec467 ~]# lsb_release -a
LSB Version:    :core-4.1-amd64:core-4.1-noarch
Distributor ID: CentOS
Description:    CentOS Linux release 7.9.2009 (Core)
Release:        7.9.2009
Codename:       Core

  • 初版Dockerfile
[root@oceanbase1 oceanbase-docker]# cat Dockerfile
FROM centos:centos7.9.2009
COPY boot /root/boot/
RUN VERSION=3.1.4-10000092022071511 yum-config-manager --add-repo https://mirrors.aliyun.com/oceanbase/OceanBase.repo && \
    yum install -y ob-deploy obclient ob-sysbench wget libaio &&  \
    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 VERSION=3.1.4-10000092022071511 mkdir /root/pkg && \
    cd /root/pkg && 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/* &&\
    yum clean all
ENV PATH=/root/boot:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
WORKDIR /root
CMD ["/bin/sh" "-c" "_boot"]
  • 从已有的容器里拷贝_boot
[root@oceanbase1 oceanbase-docker]# docker cp e6318f6ec467:/root/_boot .

三、构建与优化

1. 第一次构建

[root@oceanbase1 oceanbase-docker]# pwd
/root/oceanbase-docker
[root@oceanbase1 oceanbase-docker]# ls
boot  Dockerfile
[root@oceanbase1 oceanbase-docker]# docker build -t oceanbase:test .
Sending build context to Docker daemon  188.1MB
Step 1/7 : FROM centos:centos7.9.2009
 ---> eeb6ee3f44bd
Step 2/7 : COPY boot /root/boot/
 ---> Using cache
 ---> 7af2ff5bab30
Step 3/7 : RUN VERSION=3.1.4-10000092022071511 yum-config-manager --add-repo https://mirrors.aliyun.com/oceanbase/OceanBase.repo &&     yum install -y ob-deploy obclient ob-sysbench wget libaio &&      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
 ---> Running in 39431507a097
Loaded plugins: fastestmirror, ovl
adding repo from: https://mirrors.aliyun.com/oceanbase/OceanBase.repo
grabbing file https://mirrors.aliyun.com/oceanbase/OceanBase.repo to /etc/yum.repos.d/OceanBase.repo
repo saved to /etc/yum.repos.d/OceanBase.repo
Loaded plugins: fastestmirror, ovl
Determining fastest mirrors
 * base: mirrors.tuna.tsinghua.edu.cn
 * extras: mirrors.bfsu.edu.cn
 * updates: mirrors.bfsu.edu.cn
Resolving Dependencies
--> Running transaction check
---> Package libaio.x86_64 0:0.3.109-13.el7 will be installed
---> Package ob-deploy.x86_64 0:1.5.0-12.el7 will be installed
---> Package ob-sysbench.x86_64 0:1.0.20-3.el7 will be installed
---> Package obclient.x86_64 0:2.0.2-3.el7 will be installed
--> Processing Dependency: libobclient >= 2.0.0 for package: obclient-2.0.2-3.el7.x86_64
---> Package wget.x86_64 0:1.14-18.el7_6.1 will be installed
--> Running transaction check
---> Package libobclient.x86_64 0:2.0.2-2.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package       Arch     Version              Repository                    Size
================================================================================
Installing:
 libaio        x86_64   0.3.109-13.el7       base                          24 k
 ob-deploy     x86_64   1.5.0-12.el7         oceanbase.community.stable    33 M
 ob-sysbench   x86_64   1.0.20-3.el7         oceanbase.development-kit    346 k
 obclient      x86_64   2.0.2-3.el7          oceanbase.community.stable   173 M
 wget          x86_64   1.14-18.el7_6.1      base                         547 k
Installing for dependencies:
 libobclient   x86_64   2.0.2-2.el7          oceanbase.community.stable   847 k

Transaction Summary
================================================================================
Install  5 Packages (+1 Dependent package)

Total download size: 208 M
Installed size: 802 M
Downloading packages:
warning: /var/cache/yum/x86_64/7/base/packages/libaio-0.3.109-13.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Public key for libaio-0.3.109-13.el7.x86_64.rpm is not installed
warning: /var/cache/yum/x86_64/7/oceanbase.development-kit/packages/ob-sysbench-1.0.20-3.el7.x86_64.rpm: Header V4 RSA/SHA1 Signature, key ID e9b4a7aa: NOKEY
Public key for ob-sysbench-1.0.20-3.el7.x86_64.rpm is not installed
Public key for libobclient-2.0.2-2.el7.x86_64.rpm is not installed
^C

2. 第一次优化

  • 会hang在这里很久(因为rpm下载太慢了),且有些warning。我们来优化一下。
  • 提前下载好rpm
  • yum 加上 --nogpgcheck
[root@oceanbase1 rpm]# yumdownloader ob-deploy obclient ob-sysbench wget libaio
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.tuna.tsinghua.edu.cn
 * extras: mirrors.bupt.edu.cn
 * updates: mirrors.bupt.edu.cn
(1/5): libaio-0.3.109-13.el7.x86_64.rpm                                                                                                               |  24 kB  00:00:00
(2/5): libaio-0.3.109-13.el7.i686.rpm                                                                                                                 |  24 kB  00:00:00
(3/5): ob-sysbench-1.0.20-3.el7.x86_64.rpm                                                                                                            | 346 kB  00:00:01
(4/5): ob-deploy-1.5.0-12.el7.x86_64.rpm                                                                                                              |  33 MB  00:02:54
(5/5): obclient-2.0.2-3.el7.x86_64.rpm                                                                                                                | 173 MB  00:18:35
  • 由于缺少resolve忘记解决依赖,这里再下载一次解决依赖
error: Failed dependencies:
        libobclient >= 2.0.0 is needed by obclient-2.0.2-3.el7.x86_64

[root@oceanbase1 rpm]# yumdownloader ob-deploy obclient ob-sysbench wget libaio --resolve
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.tuna.tsinghua.edu.cn
 * extras: mirrors.bupt.edu.cn
 * updates: mirrors.bupt.edu.cn
--> Running transaction check
---> Package libaio.i686 0:0.3.109-13.el7 will be installed
---> Package libaio.x86_64 0:0.3.109-13.el7 will be reinstalled
---> Package ob-deploy.x86_64 0:1.5.0-12.el7 will be reinstalled
---> Package ob-sysbench.x86_64 0:1.0.20-3.el7 will be installed
---> Package obclient.x86_64 0:2.0.2-3.el7 will be installed
--> Processing Dependency: libobclient >= 2.0.0 for package: obclient-2.0.2-3.el7.x86_64
---> Package wget.x86_64 0:1.14-18.el7_6.1 will be installed
--> Running transaction check
---> Package libobclient.x86_64 0:2.0.2-2.el7 will be installed
--> Finished Dependency Resolution
libobclient-2.0.2-2.el7.x86_64.rpm                                                                                                                    | 847 kB  00:00:07

[root@oceanbase1 oceanbase-docker]# ls
boot  Dockerfile  pkg
[root@oceanbase1 oceanbase-docker]# ls pkg/
libaio-0.3.109-13.el7.i686.rpm      obclient-2.0.2-3.el7.x86_64.rpm      wget-1.14-18.el7_6.1.x86_64.rpm
libaio-0.3.109-13.el7.x86_64.rpm    ob-deploy-1.5.0-12.el7.x86_64.rpm
libobclient-2.0.2-2.el7.x86_64.rpm  ob-sysbench-1.0.20-3.el7.x86_64.rpm
  • Dockerfile
[root@oceanbase1 oceanbase-docker]# cat Dockerfile
FROM centos:centos7.9.2009
COPY boot /root/boot/
COPY pkg /root/pkg/
RUN yum-config-manager --add-repo https://mirrors.aliyun.com/oceanbase/OceanBase.repo && \
    cd /root/pkg/ && \
    rpm -ivh libobclient-2.0.2-2.el7.x86_64.rpm libaio-0.3.109-13.el7.i686.rpm libaio-0.3.109-13.el7.x86_64.rpm wget-1.14-18.el7_6.1.x86_64.rpm ob-sysbench-1.0.20-3.el7.x86_64.rpm obclient-2.0.2-3.el7.x86_64.rpm ob-deploy-1.5.0-12.el7.x86_64.rpm --nosignature && \
    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  cd /root/pkg && \
    rm -rf /usr/obd/mirror/remote/* &&\
    yum clean all
ENV PATH=/root/boot:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
WORKDIR /root
CMD ["_boot"]

3. 第二次构建

[root@oceanbase1 oceanbase-docker]# docker build -t oceanbase:test .
Sending build context to Docker daemon  267.6MB
Step 1/8 : FROM centos:centos7.9.2009
 ---> eeb6ee3f44bd
Step 2/8 : COPY boot /root/boot/
 ---> 24c19ac56e04
Step 3/8 : COPY pkg /root/pkg/
 ---> e38480da210a
Step 4/8 : RUN yum-config-manager --add-repo https://mirrors.aliyun.com/oceanbase/OceanBase.repo &&     cd /root/pkg/ &&    wget-1.14-18.el7_6.1.x86_64.rpm ob-sysbench-1.0.20-3.el7.x86_64.rpm obclient-2.0.2-3.el7.x86_64.rpm ob-deploy-1.5.0-12.el7mysqld* /u01/obclient/bin/aria* /u01/obclient/bin/maria* &&     yum clean all
 ---> Running in 4114dfe9a87d
Loaded plugins: fastestmirror, ovl
adding repo from: https://mirrors.aliyun.com/oceanbase/OceanBase.repo
grabbing file https://mirrors.aliyun.com/oceanbase/OceanBase.repo to /etc/yum.repos.d/OceanBase.repo
repo saved to /etc/yum.repos.d/OceanBase.repo
Preparing...                          ########################################
Updating / installing...
libobclient-2.0.2-2.el7               ########################################
obclient-2.0.2-3.el7                  ########################################
ob-sysbench-1.0.20-3.el7              ########################################
Please execute 'sysbench --help' for more information.
ob-deploy-1.5.0-12.el7                ########################################
Installation of obd finished successfully
Please source /etc/profile.d/obd.sh to enable it
wget-1.14-18.el7_6.1                  ########################################
libaio-0.3.109-13.el7                 ########################################
libaio-0.3.109-13.el7                 ########################################
Loaded plugins: fastestmirror, ovl
Cleaning repos: base extras oceanbase.community.stable oceanbase.development-kit
              : updates
Removing intermediate container 4114dfe9a87d
 ---> b37b0839eee8
Step 5/8 : RUN  cd /root/pkg &&     rm -rf /usr/obd/mirror/remote/* &&    yum clean all
 ---> Running in 60a2414469b0
Loaded plugins: fastestmirror, ovl
Cleaning repos: base extras oceanbase.community.stable oceanbase.development-kit
              : updates
Removing intermediate container 60a2414469b0
 ---> 7af143f83ce7
Step 6/8 : ENV PATH=/root/boot:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
 ---> Running in 72f0ff83e8b7
Removing intermediate container 72f0ff83e8b7
 ---> ede9c5ba9d54
Step 7/8 : WORKDIR /root
 ---> Running in e623e0996d35
Removing intermediate container e623e0996d35
 ---> 0234ff905a4f
Step 8/8 : CMD ["_boot"]
 ---> Running in d580c4e5789a
Removing intermediate container d580c4e5789a
 ---> 25185d7fa0e9
Successfully built 25185d7fa0e9
Successfully tagged oceanbase:test

4. 启动测试

  • run
[root@oceanbase1 oceanbase-docker]# docker run -p 2881:2881 --name oceanbase-test -e MINI_MODE=1 -d oceanbase:test
a45de8f8730fc6bba2acd69792e9cf067e37581bf3a72e5a42a4e563c03904ff
[root@oceanbase1 oceanbase-docker]# docker logs -f oceanbase-test
generate boot.yaml ...
oceanbase-ce docker in mini mode
create boot dirs and deploy ob cluster ...
...
...
name: wget
version: 1.14
release:18.el7_6.1
arch: x86_64
md5: c87f4d3b21d1cb8509fbaadb65eeefc7ca579064
add /root/pkg/wget-1.14-18.el7_6.1.x86_64.rpm to local mirror
+---------------------------------------------------------------------------------------------------------+
|                                            local Package List                                           |
+-------------------+---------+-----------------------+--------+------------------------------------------+
| name              | version | release               | arch   | md5                                      |
+-------------------+---------+-----------------------+--------+------------------------------------------+
| libaio            | 0.3.109 | 13.el7                | i686   | b1f4b46fe5bf353650905a8e7965710f3831e18d |
| libaio            | 0.3.109 | 13.el7                | x86_64 | a6059890e3323e2a5d0a372e4e3d6f1399dc5c76 |
| libobclient       | 2.0.2   | 2.el7                 | x86_64 | 9380b4f5ca295ce75ae56db4f0f09b4effd2e704 |
| ob-deploy         | 1.5.0   | 12.el7                | x86_64 | 5406e26462200de99df15b8f4ef062beb7f6c52a |
| ob-sysbench       | 1.0.20  | 3.el7                 | x86_64 | b611500b4bdaa0dc680ac6b5808a10185b71231b |
| obclient          | 2.0.2   | 3.el7                 | x86_64 | 4b180b2b1ee84f282cf39bf4f585df010f62b9a6 |
| oceanbase-ce      | 3.1.4   | 10000092022071511.el7 | x86_64 | c5cd94f4f190317b6a883c58a26460a506205ce6 |
| oceanbase-ce-libs | 3.1.4   | 10000092022071511.el7 | x86_64 | 6d5437b0cad486b55963f89b8ef3769af7995350 |
| wget              | 1.14    | 18.el7_6.1            | x86_64 | c87f4d3b21d1cb8509fbaadb65eeefc7ca579064 |
+-------------------+---------+-----------------------+--------+------------------------------------------+
Local deploy is empty
Package oceanbase-ce-3.1.4-10000092022071511.el7 is available.
install oceanbase-ce-3.1.4 for local ok
Cluster param config check ok
Open ssh connection ok
Generate observer configuration ok
oceanbase-ce-3.1.4 already installed.
+-------------------------------------------------------------------------------------------+
|                                          Packages                                         |
+--------------+---------+-----------------------+------------------------------------------+
| Repository   | Version | Release               | Md5                                      |
+--------------+---------+-----------------------+------------------------------------------+
| oceanbase-ce | 3.1.4   | 10000092022071511.el7 | c5cd94f4f190317b6a883c58a26460a506205ce6 |
+--------------+---------+-----------------------+------------------------------------------+
Repository integrity check ok
Parameter check ok
Open ssh connection ok
Cluster status check ok
Initializes observer work home ok
Remote oceanbase-ce-3.1.4-10000092022071511.el7-c5cd94f4f190317b6a883c58a26460a506205ce6 repository install ok
Remote oceanbase-ce-3.1.4-10000092022071511.el7-c5cd94f4f190317b6a883c58a26460a506205ce6 repository lib check !!
Try to get lib-repository
Package oceanbase-ce-libs-3.1.4-10000092022071511.el7 is available.
install oceanbase-ce-libs-3.1.4 for local ok
Remote oceanbase-ce-libs-3.1.4-10000092022071511.el7-6d5437b0cad486b55963f89b8ef3769af7995350 repository install ok
Remote oceanbase-ce-3.1.4-10000092022071511.el7-c5cd94f4f190317b6a883c58a26460a506205ce6 repository lib check ok
obcluster deployed
Get local repositories ok
Search plugins ok
Open ssh connection ok
Load cluster param plugin ok
Check before start observer ok
[WARN] OBD-1007: (127.0.0.1) The recommended number of open files is 655350 (Current value: %s)
[WARN] (127.0.0.1) clog and data use the same disk (/)

Start observer ok
observer program health check ok
Connect to observer ok
Initialize cluster
Cluster bootstrap ok
Wait for observer init ok
+---------------------------------------------+
|                   observer                  |
+-----------+---------+------+-------+--------+
| ip        | version | port | zone  | status |
+-----------+---------+------+-------+--------+
| 127.0.0.1 | 3.1.4   | 2881 | zone1 | active |
+-----------+---------+------+-------+--------+

obcluster running
Get local repositories and plugins ok
Open ssh connection ok
Connect to observer ok
Create tenant test ok
deploy success!
boot success!
^C
  • login
[root@oceanbase1 oceanbase-docker]# docker exec -it oceanbase-test ob-mysql sys
login as root@sys
Command is: obclient -h127.1 -uroot@sys -A -Doceanbase -P2881
Welcome to the OceanBase.  Commands end with ; or \g.
Your OceanBase connection id is 3221487634
Server version: 5.7.25 OceanBase 3.1.4 (r10000092022071511-b4bfa011ceaef428782dcb65ae89190c40b78c2f) (Built Jul 15 2022 11:45:14)

Copyright (c) 2000, 2022, OceanBase and/or its affiliates. All rights reserved.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

obclient [oceanbase]> select version();
+--------------------+
| version()          |
+--------------------+
| 3.1.4-OceanBase CE |
+--------------------+
1 row in set (0.007 sec)

obclient [oceanbase]>

5. 第二次优化

  • 容器镜像大了200M,且本地存放文件太多,考虑两阶段构建
  • 考虑托管gitee然后打包tag方式下载rpm包,由于单个文件限制100M大小,放弃。
  • 最终发现OceanBase的官网发现了相关下载链接优化如下。
[root@oceanbase1 oceanbase-docker]# cat Dockerfile
FROM centos:7.9.2009 as builder
RUN set -eux; \
    yum install wget -y && \
    mkdir /root/pkg/ && \
    cd /root/pkg/ && \
    yumdownloader libaio && \
    wget -O /root/pkg/ob-deploy-1.5.0-12.el7.x86_64.rpm https://obbusiness-private.oss-cn-shanghai.aliyuncs.com/download-center/opensource/obdeploy/1.5.0/ob-deploy-1.5.0-12.el7.x86_64.rpm -P /root/pkg && \
    wget -O /root/pkg/libobclient-2.0.2-2.el7.x86_64.rpm https://mdn.alipayobjects.com/ob_portal/afts/file/A*0-XHQZ8iONgAAAAAAAAAAAAADWF2AQ?af_fileName=libobclient-2.0.2-2.el7.x86_64.rpm && \
    wget -O /root/pkg/obclient-2.0.2-3.el7.x86_64.rpm https://mdn.alipayobjects.com/ob_portal/afts/file/A*ycQqT7fFJ38AAAAAAAAAAAAADWF2AQ?af_fileName=obclient-2.0.2-3.el7.x86_64.rpm && \
    wget -O /root/pkg/oceanbase-ce-libs-3.1.4-10000092022071511.el7.x86_64.rpm https://mdn.alipayobjects.com/ob_portal/afts/file/A*yAluQr0F5gsAAAAAAAAAAAAADWF2AQ?af_fileName=oceanbase-ce-libs-3.1.4-10000092022071511.el7.x86_64.rpm && \
    wget -O /root/pkg/oceanbase-ce-3.1.4-10000092022071511.el7.x86_64.rpm https://mdn.alipayobjects.com/ob_portal/afts/file/A*qjwRQ66mcuUAAAAAAAAAAAAADWF2AQ?af_fileName=oceanbase-ce-3.1.4-10000092022071511.el7.x86_64.rpm

FROM centos:7.9.2009

COPY boot /root/boot/
COPY --from=builder /root/pkg/ /root/pkg/

RUN cd /root/pkg/ && \
    rpm -ivh libobclient-2.0.2-2.el7.x86_64.rpm libaio-0.3.109-13.el7.i686.rpm libaio-0.3.109-13.el7.x86_64.rpm obclient-2.0.2-3.el7.x86_64.rpm ob-deploy-1.5.0-12.el7.x86_64.rpm && \
    rm -rf /u01/mysql /u01/obclient/bin/mysqld* /u01/obclient/bin/aria* /u01/obclient/bin/maria* && \
    cd /root/pkg && \
    rm -rf /usr/obd/mirror/remote/* &&\
    rm -f bobclient-2.0.2-2.el7.x86_64.rpm libaio-0.3.109-13.el7.i686.rpm libaio-0.3.109-13.el7.x86_64.rpm obclient-2.0.2-3.el7.x86_64.rpm ob-deploy-1.5.0-12.el7.x86_64.rpm && \
    yum clean all
ENV PATH=/root/boot:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
WORKDIR /root
CMD ["_boot"]

6. 第二次构建

[root@oceanbase1 oceanbase-docker]# docker build -t oceanbase:test .
Sending build context to Docker daemon  68.61kB
Step 1/9 : FROM centos:7.9.2009 as builder
 ---> eeb6ee3f44bd
Step 2/9 : RUN set -eux;     yum install wget -y &&     mkdir /root/pkg/ &&     cd /root/pkg/ &&     yumdownloader libaio &&                                                                                                                wget -O /root/pkg/ob-deploy-1.5.0-12.el7.x86_64.rpm https://obbusiness-private.oss-cn-shanghai.aliyuncs.com/download-cent                                                                                                           er/opensource/obdeploy/1.5.0/ob-deploy-1.5.0-12.el7.x86_64.rpm -P /root/pkg &&     wget -O /root/pkg/libobclient-2.0.2-2.el7.                                                                                                           x86_64.rpm https://mdn.alipayobjects.com/ob_portal/afts/file/A*0-XHQZ8iONgAAAAAAAAAAAAADWF2AQ?af_fileName=libobclient-2.0.2-2                                                                                                           .el7.x86_64.rpm &&     wget -O /root/pkg/obclient-2.0.2-3.el7.x86_64.rpm https://mdn.alipayobjects.com/ob_portal/afts/file/A*                                                                                                           ycQqT7fFJ38AAAAAAAAAAAAADWF2AQ?af_fileName=obclient-2.0.2-3.el7.x86_64.rpm &&     wget -O /root/pkg/oceanbase-ce-libs-3.1.4-1                                                                                                           0000092022071511.el7.x86_64.rpm https://mdn.alipayobjects.com/ob_portal/afts/file/A*yAluQr0F5gsAAAAAAAAAAAAADWF2AQ?af_fileNam                                                                                                           e=oceanbase-ce-libs-3.1.4-10000092022071511.el7.x86_64.rpm &&     wget -O /root/pkg/oceanbase-ce-3.1.4-10000092022071511.el7.                                                                                                           x86_64.rpm https://mdn.alipayobjects.com/ob_portal/afts/file/A*qjwRQ66mcuUAAAAAAAAAAAAADWF2AQ?af_fileName=oceanbase-ce-3.1.4-                                                                                                           10000092022071511.el7.x86_64.rpm
 ---> Running in 63113118c822
+ yum install wget -y
Loaded plugins: fastestmirror, ovl
Determining fastest mirrors
 * base: mirrors.bupt.edu.cn
 * extras: mirrors.bupt.edu.cn
 * updates: mirrors.bfsu.edu.cn
Resolving Dependencies
--> Running transaction check
---> Package wget.x86_64 0:1.14-18.el7_6.1 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package        Arch             Version                   Repository      Size
================================================================================
Installing:
 wget           x86_64           1.14-18.el7_6.1           base           547 k

Transaction Summary
================================================================================
Install  1 Package

Total download size: 547 k
Installed size: 2.0 M
Downloading packages:
warning: /var/cache/yum/x86_64/7/base/packages/wget-1.14-18.el7_6.1.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80e                                                                                                           b5: NOKEY
Public key for wget-1.14-18.el7_6.1.x86_64.rpm is not installed
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Importing GPG key 0xF4A80EB5:
 Userid     : "CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>"
 Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
 Package    : centos-release-7-9.2009.0.el7.centos.x86_64 (@CentOS)
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : wget-1.14-18.el7_6.1.x86_64                                  1/1
install-info: No such file or directory for /usr/share/info/wget.info.gz
  Verifying  : wget-1.14-18.el7_6.1.x86_64                                  1/1

Installed:
  wget.x86_64 0:1.14-18.el7_6.1

Complete!
+ mkdir /root/pkg/
+ cd /root/pkg/
+ yumdownloader libaio
Loaded plugins: fastestmirror, ovl
Loading mirror speeds from cached hostfile
 * base: mirrors.bupt.edu.cn
 * extras: mirrors.bupt.edu.cn
 * updates: mirrors.bfsu.edu.cn
+ wget -O /root/pkg/ob-deploy-1.5.0-12.el7.x86_64.rpm https://obbusiness-private.oss-cn-shanghai.aliyuncs.com/download-center                                                                                                           /opensource/obdeploy/1.5.0/ob-deploy-1.5.0-12.el7.x86_64.rpm -P /root/pkg
--2022-10-31 04:52:04--  https://obbusiness-private.oss-cn-shanghai.aliyuncs.com/download-center/opensource/obdeploy/1.5.0/ob                                                                                                           -deploy-1.5.0-12.el7.x86_64.rpm
Resolving obbusiness-private.oss-cn-shanghai.aliyuncs.com (obbusiness-private.oss-cn-shanghai.aliyuncs.com)... 106.14.229.148
Connecting to obbusiness-private.oss-cn-shanghai.aliyuncs.com (obbusiness-private.oss-cn-shanghai.aliyuncs.com)|106.14.229.14                                                                                                           8|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 34091424 (33M) [application/x-redhat-package-manager]
Saving to: '/root/pkg/ob-deploy-1.5.0-12.el7.x86_64.rpm'

     0K .......... .......... .......... .......... ..........  0%  791K 42s
 ...
 ...
 33150K .......... .......... .......... .......... .......... 99% 11.8M 0s
 33200K .......... .......... .......... .......... .......... 99% 10.5M 0s
 33250K .......... .......... .......... .......... ..        100% 11.5M=3.1s

2022-10-31 04:52:07 (10.5 MB/s) - '/root/pkg/ob-deploy-1.5.0-12.el7.x86_64.rpm' saved [34091424/34091424]

+ wget -O /root/pkg/libobclient-2.0.2-2.el7.x86_64.rpm 'https://mdn.alipayobjects.com/ob_portal/afts/file/A*0-XHQZ8iONgAAAAAA                                                                                                           AAAAAAADWF2AQ?af_fileName=libobclient-2.0.2-2.el7.x86_64.rpm'
Warning: wildcards not supported in HTTP.
--2022-10-31 04:52:07--  https://mdn.alipayobjects.com/ob_portal/afts/file/A*0-XHQZ8iONgAAAAAAAAAAAAADWF2AQ?af_fileName=libob                                                                                                           client-2.0.2-2.el7.x86_64.rpm
Resolving mdn.alipayobjects.com (mdn.alipayobjects.com)... 111.26.147.249, 111.26.147.248, 2409:801a:3000:3:3::3f1, ...
Connecting to mdn.alipayobjects.com (mdn.alipayobjects.com)|111.26.147.249|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 866256 (846K) [audio/x-pn-realaudio-plugin]
Saving to: '/root/pkg/libobclient-2.0.2-2.el7.x86_64.rpm'

     0K .......... .......... .......... .......... ..........  5%  852K 1s
    50K .......... .......... .......... .......... .......... 11% 2.10M 1s
   100K .......... .......... .......... .......... .......... 17% 2.34M 0s
   150K .......... .......... .......... .......... .......... 23% 10.9M 0s
   200K .......... .......... .......... .......... .......... 29% 11.1M 0s
   250K .......... .......... .......... .......... .......... 35% 2.81M 0s
   300K .......... .......... .......... .......... .......... 41% 6.14M 0s
   350K .......... .......... .......... .......... .......... 47% 4.13M 0s
   400K .......... .......... .......... .......... .......... 53% 8.77M 0s
   450K .......... .......... .......... .......... .......... 59% 5.05M 0s
   500K .......... .......... .......... .......... .......... 65% 4.51M 0s
   550K .......... .......... .......... .......... .......... 70% 11.8M 0s
   600K .......... .......... .......... .......... .......... 76% 8.23M 0s
   650K .......... .......... .......... .......... .......... 82% 12.5M 0s
   700K .......... .......... .......... .......... .......... 88% 11.3M 0s
   750K .......... .......... .......... .......... .......... 94% 9.65M 0s
   800K .......... .......... .......... .......... .....     100% 15.4M=0.2s

2022-10-31 04:52:08 (4.11 MB/s) - '/root/pkg/libobclient-2.0.2-2.el7.x86_64.rpm' saved [866256/866256]

+ wget -O /root/pkg/obclient-2.0.2-3.el7.x86_64.rpm 'https://mdn.alipayobjects.com/ob_portal/afts/file/A*ycQqT7fFJ38AAAAAAAAA                                                                                                           AAAADWF2AQ?af_fileName=obclient-2.0.2-3.el7.x86_64.rpm'
Warning: wildcards not supported in HTTP.
--2022-10-31 04:52:08--  https://mdn.alipayobjects.com/ob_portal/afts/file/A*ycQqT7fFJ38AAAAAAAAAAAAADWF2AQ?af_fileName=obcli                                                                                                           ent-2.0.2-3.el7.x86_64.rpm
Resolving mdn.alipayobjects.com (mdn.alipayobjects.com)... 111.26.147.248, 111.26.147.249, 2409:801a:3000:3:3::3f1, ...
Connecting to mdn.alipayobjects.com (mdn.alipayobjects.com)|111.26.147.248|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 181903628 (173M) [audio/x-pn-realaudio-plugin]
Saving to: '/root/pkg/obclient-2.0.2-3.el7.x86_64.rpm'

     0K .......... .......... .......... .......... ..........  0%  804K 3m41s
    50K .......... .......... .......... .......... ..........  0% 2.26M 2m29s

...
...

177550K .......... .......... .......... .......... .......... 99% 8.81M 0s
177600K .......... .......... .......... ..........           100% 18.7M=16s

2022-10-31 04:52:24 (11.1 MB/s) - '/root/pkg/obclient-2.0.2-3.el7.x86_64.rpm' saved [181903628/181903628]

+ wget -O /root/pkg/oceanbase-ce-libs-3.1.4-10000092022071511.el7.x86_64.rpm 'https://mdn.alipayobjects.com/ob_portal/afts/fi                                                                                                           le/A*yAluQr0F5gsAAAAAAAAAAAAADWF2AQ?af_fileName=oceanbase-ce-libs-3.1.4-10000092022071511.el7.x86_64.rpm'
Warning: wildcards not supported in HTTP.
--2022-10-31 04:52:24--  https://mdn.alipayobjects.com/ob_portal/afts/file/A*yAluQr0F5gsAAAAAAAAAAAAADWF2AQ?af_fileName=ocean                                                                                                           base-ce-libs-3.1.4-10000092022071511.el7.x86_64.rpm
Resolving mdn.alipayobjects.com (mdn.alipayobjects.com)... 111.26.147.248, 111.26.147.249, 2409:801a:3000:3:3::3f2, ...
Connecting to mdn.alipayobjects.com (mdn.alipayobjects.com)|111.26.147.248|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 158384 (155K) [audio/x-pn-realaudio-plugin]
Saving to: '/root/pkg/oceanbase-ce-libs-3.1.4-10000092022071511.el7.x86_64.rpm'

     0K .......... .......... .......... .......... .......... 32% 1.14M 0s
    50K .......... .......... .......... .......... .......... 64% 2.33M 0s
   100K .......... .......... .......... .......... .......... 96% 15.6M 0s
   150K ....                                                  100% 8911G=0.07s

2022-10-31 04:52:24 (2.25 MB/s) - '/root/pkg/oceanbase-ce-libs-3.1.4-10000092022071511.el7.x86_64.rpm' saved [158384/158384]

+ wget -O /root/pkg/oceanbase-ce-3.1.4-10000092022071511.el7.x86_64.rpm 'https://mdn.alipayobjects.com/ob_portal/afts/file/A*                                                                                                           qjwRQ66mcuUAAAAAAAAAAAAADWF2AQ?af_fileName=oceanbase-ce-3.1.4-10000092022071511.el7.x86_64.rpm'
Warning: wildcards not supported in HTTP.
--2022-10-31 04:52:24--  https://mdn.alipayobjects.com/ob_portal/afts/file/A*qjwRQ66mcuUAAAAAAAAAAAAADWF2AQ?af_fileName=ocean                                                                                                           base-ce-3.1.4-10000092022071511.el7.x86_64.rpm
Resolving mdn.alipayobjects.com (mdn.alipayobjects.com)... 111.26.147.249, 111.26.147.248, 2409:801a:3000:3:3::3f2, ...
Connecting to mdn.alipayobjects.com (mdn.alipayobjects.com)|111.26.147.249|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 49601860 (47M) [audio/x-pn-realaudio-plugin]
Saving to: '/root/pkg/oceanbase-ce-3.1.4-10000092022071511.el7.x86_64.rpm'

     0K .......... .......... .......... .......... ..........  0% 2.00M 24s
    50K .......... .......... .......... .......... ..........  0% 2.18M 23s

...
...

 48350K .......... .......... .......... .......... .......... 99% 9.32M 0s
 48400K .......... .......... .......... .........            100% 17.2M=4.3s

2022-10-31 04:52:28 (11.1 MB/s) - '/root/pkg/oceanbase-ce-3.1.4-10000092022071511.el7.x86_64.rpm' saved [49601860/49601860]

Removing intermediate container 63113118c822
 ---> b06583d94389
Step 3/9 : FROM centos:7.9.2009
 ---> eeb6ee3f44bd
Step 4/9 : COPY boot /root/boot/
 ---> 0f4a731d7dd2
Step 5/9 : COPY --from=builder /root/pkg/ /root/pkg/
 ---> 61c68a5edc42
Step 6/9 : RUN cd /root/pkg/ &&     rpm -ivh libobclient-2.0.2-2.el7.x86_64.rpm libaio-0.3.109-13.el7.i686.rpm libaio-0.3.109                                                                                                           -13.el7.x86_64.rpm obclient-2.0.2-3.el7.x86_64.rpm ob-deploy-1.5.0-12.el7.x86_64.rpm &&     rm -rf /u01/mysql /u01/obclient/b                                                                                                           in/mysqld* /u01/obclient/bin/aria* /u01/obclient/bin/maria* &&     cd /root/pkg &&     rm -rf /usr/obd/mirror/remote/* &&                                                                                                               rm -f bobclient-2.0.2-2.el7.x86_64.rpm libaio-0.3.109-13.el7.i686.rpm libaio-0.3.109-13.el7.x86_64.rpm obclient-2.0.2-3.el7.x                                                                                                           86_64.rpm ob-deploy-1.5.0-12.el7.x86_64.rpm &&     yum clean all
 ---> Running in 9b19e5cd0d53
warning: libaio-0.3.109-13.el7.i686.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Preparing...                          ########################################
Updating / installing...
libobclient-2.0.2-2.el7               ########################################
obclient-2.0.2-3.el7                  ########################################
ob-deploy-1.5.0-12.el7                ########################################
Installation of obd finished successfully
Please source /etc/profile.d/obd.sh to enable it
libaio-0.3.109-13.el7                 ########################################
libaio-0.3.109-13.el7                 ########################################
Loaded plugins: fastestmirror, ovl
Cleaning repos: base extras updates
Removing intermediate container 9b19e5cd0d53
 ---> 602ecb5fcf73
Step 7/9 : ENV PATH=/root/boot:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
 ---> Running in 380fa45a1746
Removing intermediate container 380fa45a1746
 ---> 2f8dd45b52ee
Step 8/9 : WORKDIR /root
 ---> Running in 16bc47928148
Removing intermediate container 16bc47928148
 ---> 0c2d0a0a6925
Step 9/9 : CMD ["_boot"]
 ---> Running in 31b07786a9ff
Removing intermediate container 31b07786a9ff
 ---> 5b8f291e6ec3
Successfully built 5b8f291e6ec3
Successfully tagged oceanbase:test
  • login
[root@oceanbase1 oceanbase-docker]# docker exec -it oceanbase-test ob-mysql sys
login as root@sys
Command is: obclient -h127.1 -uroot@sys -A -Doceanbase -P2881
Welcome to the OceanBase.  Commands end with ; or \g.
Your OceanBase connection id is 3221487745
Server version: 5.7.25 OceanBase 3.1.4 (r10000092022071511-b4bfa011ceaef428782dcb65ae89190c40b78c2f) (Built Jul 15 2022 11:45:14)

Copyright (c) 2000, 2022, OceanBase and/or its affiliates. All rights reserved.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

obclient [oceanbase]>

7. 第三次优化

  • 由于两阶段构建多了一层COPY层大小,导致增加了200M容器大小,优化为一次构建。
  • 构建时间大致为1分钟,测试启动登录正常。
[root@oceanbase1 oceanbase-docker]# cat Dockerfile
FROM centos:7.9.2009

COPY boot /root/boot/

RUN set -eux; \
    yum install wget -y && \
    mkdir /root/pkg/ && \
    cd /root/pkg/ && \
    yumdownloader libaio && \
    wget -O /root/pkg/ob-deploy-1.5.0-12.el7.x86_64.rpm https://obbusiness-private.oss-cn-shanghai.aliyuncs.com/download-center/opensource/obdeploy/1.5.0/ob-deploy-1.5.0-12.el7.x86_64.rpm -P /root/pkg && \
    wget -O /root/pkg/libobclient-2.0.2-2.el7.x86_64.rpm https://mdn.alipayobjects.com/ob_portal/afts/file/A*0-XHQZ8iONgAAAAAAAAAAAAADWF2AQ?af_fileName=libobclient-2.0.2-2.el7.x86_64.rpm && \
    wget -O /root/pkg/obclient-2.0.2-3.el7.x86_64.rpm https://mdn.alipayobjects.com/ob_portal/afts/file/A*ycQqT7fFJ38AAAAAAAAAAAAADWF2AQ?af_fileName=obclient-2.0.2-3.el7.x86_64.rpm && \
    wget -O /root/pkg/oceanbase-ce-libs-3.1.4-10000092022071511.el7.x86_64.rpm https://mdn.alipayobjects.com/ob_portal/afts/file/A*yAluQr0F5gsAAAAAAAAAAAAADWF2AQ?af_fileName=oceanbase-ce-libs-3.1.4-10000092022071511.el7.x86_64.rpm && \
    wget -O /root/pkg/oceanbase-ce-3.1.4-10000092022071511.el7.x86_64.rpm https://mdn.alipayobjects.com/ob_portal/afts/file/A*qjwRQ66mcuUAAAAAAAAAAAAADWF2AQ?af_fileName=oceanbase-ce-3.1.4-10000092022071511.el7.x86_64.rpm && \
    rpm -ivh libobclient-2.0.2-2.el7.x86_64.rpm libaio-0.3.109-13.el7.i686.rpm libaio-0.3.109-13.el7.x86_64.rpm obclient-2.0.2-3.el7.x86_64.rpm ob-deploy-1.5.0-12.el7.x86_64.rpm && \
    rm -rf /u01/mysql /u01/obclient/bin/mysqld* /u01/obclient/bin/aria* /u01/obclient/bin/maria* && \
    cd /root/pkg && \
    rm -rf /usr/obd/mirror/remote/* &&\
    rm -f libobclient-2.0.2-2.el7.x86_64.rpm libaio-0.3.109-13.el7.i686.rpm libaio-0.3.109-13.el7.x86_64.rpm obclient-2.0.2-3.el7.x86_64.rpm ob-deploy-1.5.0-12.el7.x86_64.rpm && \

ENV PATH=/root/boot:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

WORKDIR /root

CMD ["_boot"]

8. 第四次优化

涉及到的知识点及优化方向

  • 核心思想是在不影响使用的前提下缩小image大小

  • 采用更小的Ubuntu基础镜像,OceanBase支持Ubuntu 20.X 版本及以上版本

  • 把转码后的文件上传的gitee上方便build使用减少本地COPY的镜像层大小

  • obclient大小超过100M不能上传到gitee,把rpm解压删除掉无用的东西并调试最终大小为50M左右,满足上传条件。

  • wget -O (下载文件名) -q(减少进度条输出,优化build输出)

  • observer二进制为后台命令,docker需要保持运行时,使用top -b保持运行

  • DEBIAN_FRONTEND=noninteractive TERM=dumb 解决top报错

  • CMD 传参observer 给ENTRYPOINT _boot(数据库安装脚本) 运行

  • vim和procps暂未安装有需求可以自行安装

  • rm 清理相关cache及处理后的中间文件,最终镜像大小402M 官方558M

  • image

[root@oceanbase1 ~]# docker image ls
REPOSITORY               TAG        IMAGE ID       CREATED             SIZE
oceanbase                test       876fbee4e01c   29 minutes ago      402MB
oceanbase/oceanbase-ce   latest     4af946862346   3 months ago        558MB
ubuntu                   20.04      ba6acccedd29   12 months ago       72.8MB
centos                   7.9.2009   eeb6ee3f44bd   13 months ago       204MB
  • Dockerfile
[root@oceanbase1 oceanbase-docker]# cat Dockerfile
FROM ubuntu:20.04

COPY boot /root/boot/

ENV DEBIAN_FRONTEND=noninteractive \
    PATH=/root/boot:/root/ob/bin:/u01/obclient/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin \
    LD_LIBRARY_PATH=LD_LIBRARY_PATH:/root/ob/lib \
    TERM=dumb


RUN set -eux; \
    apt-get update && apt-get install -y \
    libaio-dev  \
    krb5-locales  \
    libk5crypto3  \
    libkeyutils1  \
    libkrb5-3  \
    libkrb5support0 \
#    vim  \
    wget \
#    procps \
    libssl1.1 && \
    mkdir /root/pkg && cd /root/pkg/ && useradd admin && \
    wget -O /root/pkg/oceanbase-ce-libs-3.1.4-10000092022071511.el7.x86_64.rpm https://mdn.alipayobjects.com/ob_portal/afts/file/A*yAluQr0F5gsAAAAAAAAAAAAADWF2AQ?af_fileName=oceanbase-ce-libs-3.1.4-10000092022071511.el7.x86_64.rpm -q && \
    wget -O /root/pkg/oceanbase-ce-3.1.4-10000092022071511.el7.x86_64.rpm https://mdn.alipayobjects.com/ob_portal/afts/file/A*qjwRQ66mcuUAAAAAAAAAAAAADWF2AQ?af_fileName=oceanbase-ce-3.1.4-10000092022071511.el7.x86_64.rpm  -q  && \
    wget -O /root/pkg/obclient-3.1.4.tar.gz https://gitee.com/lee1002/oceanbase-depend/releases/download/oceanbase-3.1.4_depend_for_ubuntu/obclient-3.1.4.tar.gz -q  && \
    wget -O /root/pkg/oceanbase-ce-libs_3.1.4-10000092022071511.el7_amd64.deb https://gitee.com/lee1002/oceanbase-depend/releases/download/oceanbase-3.1.4_depend_for_ubuntu/oceanbase-ce-libs_3.1.4-10000092022071511.el7_amd64.deb -q && \
    wget -O /root/pkg/libobclient_2.0.2-2.el7_amd64.deb https://gitee.com/lee1002/oceanbase-depend/releases/download/oceanbase-3.1.4_depend_for_ubuntu/libobclient_2.0.2-2.el7_amd64.deb  -q && \
    wget -O /root/pkg/ob-deploy_1.5.0-12.el7_amd64.deb https://gitee.com/lee1002/oceanbase-depend/releases/download/oceanbase-3.1.4_depend_for_ubuntu/ob-deploy_1.5.0-12.el7_amd64.deb  -q && \
    dpkg --no-force-overwrite -i ob-deploy_1.5.0-12.el7_amd64.deb && \
    dpkg --no-force-overwrite -i oceanbase-ce-libs_3.1.4-10000092022071511.el7_amd64.deb && \
    dpkg --no-force-overwrite -i libobclient_2.0.2-2.el7_amd64.deb && \
    tar -xf /root/pkg/obclient-3.1.4.tar.gz -C / && \
    cd /root/pkg && \
    rm -rf /usr/obd/mirror/remote/* &&\
    rm -f obclient-3.1.4.tar.gz ob-deploy_1.5.0-12.el7_amd64.deb libobclient_2.0.2-2.el7_amd64.deb && \
    apt clean -y && \
    rm -rf \
    /var/cache/debconf/* \
    /var/lib/apt/lists/* \
    /var/log/* \
    /var/tmp/* \
    rm -rf /tmp/*


WORKDIR /root

ENTRYPOINT ["/root/boot/_boot"]
CMD ["observer"]
  • Build输出
[root@oceanbase1 oceanbase-docker]# docker build -t oceanbase:test .
Sending build context to Docker daemon  69.12kB
Step 1/7 : FROM ubuntu:20.04
 ---> ba6acccedd29
Step 2/7 : COPY boot /root/boot/
 ---> Using cache
 ---> 10d1472c6960
Step 3/7 : ENV DEBIAN_FRONTEND=noninteractive     PATH=/root/boot:/root/ob/bin:/u01/obclient/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin     LD_LIBRARY_PATH=LD_LIBRARY_PATH:/root/ob/lib     TERM=dumb
 ---> Using cache
 ---> a6734a678470
Step 4/7 : RUN set -eux;     apt-get update && apt-get install -y     libaio-dev      krb5-locales      libk5crypto3      libkeyutils1      libkrb5-3      libkrb5support0     wget     libssl1.1 &&     mkdir /root/pkg && cd /root/pkg/ && useradd admin &&     wget -O /root/pkg/oceanbase-ce-libs-3.1.4-10000092022071511.el7.x86_64.rpm https://mdn.alipayobjects.com/ob_portal/afts/file/A*yAluQr0F5gsAAAAAAAAAAAAADWF2AQ?af_fileName=oceanbase-ce-libs-3.1.4-10000092022071511.el7.x86_64.rpm -q &&     wget -O /root/pkg/oceanbase-ce-3.1.4-10000092022071511.el7.x86_64.rpm https://mdn.alipayobjects.com/ob_portal/afts/file/A*qjwRQ66mcuUAAAAAAAAAAAAADWF2AQ?af_fileName=oceanbase-ce-3.1.4-10000092022071511.el7.x86_64.rpm  -q  &&     wget -O /root/pkg/obclient-3.1.4.tar.gz https://gitee.com/lee1002/oceanbase-depend/releases/download/oceanbase-3.1.4_depend_for_ubuntu/obclient-3.1.4.tar.gz -q  &&     wget -O /root/pkg/oceanbase-ce-libs_3.1.4-10000092022071511.el7_amd64.deb https://gitee.com/lee1002/oceanbase-depend/releases/download/oceanbase-3.1.4_depend_for_ubuntu/oceanbase-ce-libs_3.1.4-10000092022071511.el7_amd64.deb -q &&     wget -O /root/pkg/libobclient_2.0.2-2.el7_amd64.deb https://gitee.com/lee1002/oceanbase-depend/releases/download/oceanbase-3.1.4_depend_for_ubuntu/libobclient_2.0.2-2.el7_amd64.deb  -q &&     wget -O /root/pkg/ob-deploy_1.5.0-12.el7_amd64.deb https://gitee.com/lee1002/oceanbase-depend/releases/download/oceanbase-3.1.4_depend_for_ubuntu/ob-deploy_1.5.0-12.el7_amd64.deb  -q &&     dpkg --no-force-overwrite -i ob-deploy_1.5.0-12.el7_amd64.deb &&     dpkg --no-force-overwrite -i oceanbase-ce-libs_3.1.4-10000092022071511.el7_amd64.deb &&     dpkg --no-force-overwrite -i libobclient_2.0.2-2.el7_amd64.deb &&     tar -xf /root/pkg/obclient-3.1.4.tar.gz -C / &&     cd /root/pkg &&     rm -rf /usr/obd/mirror/remote/* &&    rm -f obclient-3.1.4.tar.gz ob-deploy_1.5.0-12.el7_amd64.deb libobclient_2.0.2-2.el7_amd64.deb &&     apt clean -y &&     rm -rf     /var/cache/debconf/*     /var/lib/apt/lists/*     /var/log/*     /var/tmp/*     rm -rf /tmp/*
 ---> Running in 358472898aeb
+ apt-get update
Get:1 http://archive.ubuntu.com/ubuntu focal InRelease [265 kB]

...
...

Get:18 http://archive.ubuntu.com/ubuntu focal-backports/universe amd64 Packages [27.5 kB]
Fetched 24.2 MB in 1min 35s (255 kB/s)
Reading package lists...
+ apt-get install -y libaio-dev krb5-locales libk5crypto3 libkeyutils1 libkrb5-3 libkrb5support0 wget libssl1.1
Reading package lists...
Building dependency tree...
Reading state information...
The following additional packages will be installed:
  ca-certificates libaio1 libpsl5 openssl publicsuffix
Suggested packages:
  krb5-doc krb5-user
The following NEW packages will be installed:
  ca-certificates krb5-locales libaio-dev libaio1 libk5crypto3 libkeyutils1
  libkrb5-3 libkrb5support0 libpsl5 libssl1.1 openssl publicsuffix wget
0 upgraded, 13 newly installed, 0 to remove and 37 not upgraded.
Need to get 3079 kB of archives.
After this operation, 9126 kB of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libssl1.1 amd64 1.1.1f-1ubuntu2.16 [1321 kB]

...
...

Get:13 http://archive.ubuntu.com/ubuntu focal/main amd64 libaio-dev amd64 0.3.112-5 [13.7 kB]
debconf: delaying package configuration, since apt-utils is not installed
Fetched 3079 kB in 23s (133 kB/s)

...

...
Running hooks in /etc/ca-certificates/update.d...
done.
+ mkdir /root/pkg
+ cd /root/pkg/
+ useradd admin
+ wget -O /root/pkg/oceanbase-ce-libs-3.1.4-10000092022071511.el7.x86_64.rpm https://mdn.alipayobjects.com/ob_portal/afts/file/A*yAluQr0F5gsAAAAAAAAAAAAADWF2AQ?af_fileName=oceanbase-ce-libs-3.1.4-10000092022071511.el7.x86_64.rpm -q
+ wget -O /root/pkg/oceanbase-ce-3.1.4-10000092022071511.el7.x86_64.rpm https://mdn.alipayobjects.com/ob_portal/afts/file/A*qjwRQ66mcuUAAAAAAAAAAAAADWF2AQ?af_fileName=oceanbase-ce-3.1.4-10000092022071511.el7.x86_64.rpm -q
+ wget -O /root/pkg/obclient-3.1.4.tar.gz https://gitee.com/lee1002/oceanbase-depend/releases/download/oceanbase-3.1.4_depend_for_ubuntu/obclient-3.1.4.tar.gz -q
+ wget -O /root/pkg/oceanbase-ce-libs_3.1.4-10000092022071511.el7_amd64.deb https://gitee.com/lee1002/oceanbase-depend/releases/download/oceanbase-3.1.4_depend_for_ubuntu/oceanbase-ce-libs_3.1.4-10000092022071511.el7_amd64.deb -q
+ wget -O /root/pkg/libobclient_2.0.2-2.el7_amd64.deb https://gitee.com/lee1002/oceanbase-depend/releases/download/oceanbase-3.1.4_depend_for_ubuntu/libobclient_2.0.2-2.el7_amd64.deb -q
+ wget -O /root/pkg/ob-deploy_1.5.0-12.el7_amd64.deb https://gitee.com/lee1002/oceanbase-depend/releases/download/oceanbase-3.1.4_depend_for_ubuntu/ob-deploy_1.5.0-12.el7_amd64.deb -q
+ dpkg --no-force-overwrite -i ob-deploy_1.5.0-12.el7_amd64.deb
Selecting previously unselected package ob-deploy.
(Reading database ... 4521 files and directories currently installed.)
Preparing to unpack ob-deploy_1.5.0-12.el7_amd64.deb ...
Unpacking ob-deploy (1.5.0-12.el7) ...
Setting up ob-deploy (1.5.0-12.el7) ...
Installation of obd finished successfully
Please source /etc/profile.d/obd.sh to enable it
Processing triggers for libc-bin (2.31-0ubuntu9.2) ...
+ dpkg --no-force-overwrite -i oceanbase-ce-libs_3.1.4-10000092022071511.el7_amd64.deb
Selecting previously unselected package oceanbase-ce-libs.
(Reading database ... 5543 files and directories currently installed.)
Preparing to unpack oceanbase-ce-libs_3.1.4-10000092022071511.el7_amd64.deb ...
Unpacking oceanbase-ce-libs (3.1.4-10000092022071511.el7) ...
Setting up oceanbase-ce-libs (3.1.4-10000092022071511.el7) ...
Processing triggers for libc-bin (2.31-0ubuntu9.2) ...
+ dpkg --no-force-overwrite -i libobclient_2.0.2-2.el7_amd64.deb
Selecting previously unselected package libobclient.
(Reading database ... 5554 files and directories currently installed.)
Preparing to unpack libobclient_2.0.2-2.el7_amd64.deb ...
Unpacking libobclient (2.0.2-2.el7) ...
Setting up libobclient (2.0.2-2.el7) ...
Processing triggers for libc-bin (2.31-0ubuntu9.2) ...
+ tar -xf /root/pkg/obclient-3.1.4.tar.gz -C /
+ cd /root/pkg
+ rm -rf /usr/obd/mirror/remote/OceanBase.repo
+ rm -f obclient-3.1.4.tar.gz ob-deploy_1.5.0-12.el7_amd64.deb libobclient_2.0.2-2.el7_amd64.deb
+ apt clean -y

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

+ rm -rf /var/cache/debconf/config.dat /var/cache/debconf/config.dat-old /var/cache/debconf/passwords.dat /var/cache/debconf/templates.dat /var/cache/debconf/templates.dat-old /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_focal-backports_InRelease /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_focal-backports_main_binary-amd64_Packages.lz4 /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_focal-backports_universe_binary-amd64_Packages.lz4 /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_focal-updates_InRelease /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_focal-updates_main_binary-amd64_Packages.lz4 /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_focal-updates_multiverse_binary-amd64_Packages.lz4 /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_focal-updates_restricted_binary-amd64_Packages.lz4 /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_focal-updates_universe_binary-amd64_Packages.lz4 /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_focal_InRelease /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_focal_main_binary-amd64_Packages.lz4 /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_focal_multiverse_binary-amd64_Packages.lz4 /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_focal_restricted_binary-amd64_Packages.lz4 /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_focal_universe_binary-amd64_Packages.lz4 /var/lib/apt/lists/auxfiles /var/lib/apt/lists/lock /var/lib/apt/lists/partial /var/lib/apt/lists/security.ubuntu.com_ubuntu_dists_focal-security_InRelease /var/lib/apt/lists/security.ubuntu.com_ubuntu_dists_focal-security_main_binary-amd64_Packages.lz4 /var/lib/apt/lists/security.ubuntu.com_ubuntu_dists_focal-security_multiverse_binary-amd64_Packages.lz4 /var/lib/apt/lists/security.ubuntu.com_ubuntu_dists_focal-security_restricted_binary-amd64_Packages.lz4 /var/lib/apt/lists/security.ubuntu.com_ubuntu_dists_focal-security_universe_binary-amd64_Packages.lz4 /var/log/alternatives.log /var/log/apt /var/log/bootstrap.log /var/log/btmp /var/log/dpkg.log /var/log/faillog /var/log/lastlog /var/log/wtmp /var/tmp/* rm -rf /tmp/*
Removing intermediate container 358472898aeb
 ---> 2d705657e597
Step 5/7 : WORKDIR /root
 ---> Running in ea13ce931bb6
Removing intermediate container ea13ce931bb6
 ---> 0f78b51886a9
Step 6/7 : ENTRYPOINT ["/root/boot/_boot"]
 ---> Running in f01ee0a12677
Removing intermediate container f01ee0a12677
 ---> ae636adc1a90
Step 7/7 : CMD ["observer"]
 ---> Running in ad3ba01022fc
Removing intermediate container ad3ba01022fc
 ---> 876fbee4e01c
Successfully built 876fbee4e01c
Successfully tagged oceanbase:test
  • run log
[root@oceanbase1 oceanbase-docker]# docker run -p 2881:2881 --name oceanbase1 -e MINI_MODE=1 -d oceanbase:test
05f05daac815f62bef460f3199835fd07c7e525d043936159dcdca85a1964f75
[root@oceanbase1 oceanbase-docker]# docker logs -f oceanbase1
generate boot.yaml ...
oceanbase-ce docker in mini mode
create boot dirs and deploy ob cluster ...
name: oceanbase-ce
version: 3.1.4
release:10000092022071511.el7
arch: x86_64
md5: c5cd94f4f190317b6a883c58a26460a506205ce6
add /root/pkg/oceanbase-ce-3.1.4-10000092022071511.el7.x86_64.rpm to local mirror
name: oceanbase-ce-libs
version: 3.1.4
release:10000092022071511.el7
arch: x86_64
md5: 6d5437b0cad486b55963f89b8ef3769af7995350
add /root/pkg/oceanbase-ce-libs-3.1.4-10000092022071511.el7.x86_64.rpm to local mirror
+---------------------------------------------------------------------------------------------------------+
|                                            local Package List                                           |
+-------------------+---------+-----------------------+--------+------------------------------------------+
| name              | version | release               | arch   | md5                                      |
+-------------------+---------+-----------------------+--------+------------------------------------------+
| oceanbase-ce      | 3.1.4   | 10000092022071511.el7 | x86_64 | c5cd94f4f190317b6a883c58a26460a506205ce6 |
| oceanbase-ce-libs | 3.1.4   | 10000092022071511.el7 | x86_64 | 6d5437b0cad486b55963f89b8ef3769af7995350 |
+-------------------+---------+-----------------------+--------+------------------------------------------+
Local deploy is empty
[WARN] Use centos 7 remote mirror repository for ubuntu 20.04
Package oceanbase-ce-3.1.4-10000092022071511.el7 is available.
install oceanbase-ce-3.1.4 for local ok
Cluster param config check ok
Open ssh connection ok
Generate observer configuration ok
[WARN] Use centos 7 remote mirror repository for ubuntu 20.04
oceanbase-ce-3.1.4 already installed.
+-------------------------------------------------------------------------------------------+
|                                          Packages                                         |
+--------------+---------+-----------------------+------------------------------------------+
| Repository   | Version | Release               | Md5                                      |
+--------------+---------+-----------------------+------------------------------------------+
| oceanbase-ce | 3.1.4   | 10000092022071511.el7 | c5cd94f4f190317b6a883c58a26460a506205ce6 |
+--------------+---------+-----------------------+------------------------------------------+
Repository integrity check ok
Parameter check ok
Open ssh connection ok
Cluster status check ok
Initializes observer work home ok
Remote oceanbase-ce-3.1.4-10000092022071511.el7-c5cd94f4f190317b6a883c58a26460a506205ce6 repository install ok
Remote oceanbase-ce-3.1.4-10000092022071511.el7-c5cd94f4f190317b6a883c58a26460a506205ce6 repository lib check !!
Try to get lib-repository
[WARN] Use centos 7 remote mirror repository for ubuntu 20.04
Package oceanbase-ce-libs-3.1.4-10000092022071511.el7 is available.
install oceanbase-ce-libs-3.1.4 for local ok
Remote oceanbase-ce-libs-3.1.4-10000092022071511.el7-6d5437b0cad486b55963f89b8ef3769af7995350 repository install ok
Remote oceanbase-ce-3.1.4-10000092022071511.el7-c5cd94f4f190317b6a883c58a26460a506205ce6 repository lib check ok
obcluster deployed
Get local repositories ok
Search plugins ok
Open ssh connection ok
Load cluster param plugin ok
Check before start observer ok
[WARN] (127.0.0.1) failed to get open files
[WARN] (127.0.0.1) failed to get max user processes
[WARN] (127.0.0.1) clog and data use the same disk (/)

Start observer ok
observer program health check ok
Connect to observer ok
Initialize cluster
Cluster bootstrap ok
Wait for observer init ok
+---------------------------------------------+
|                   observer                  |
+-----------+---------+------+-------+--------+
| ip        | version | port | zone  | status |
+-----------+---------+------+-------+--------+
| 127.0.0.1 | 3.1.4   | 2881 | zone1 | active |
+-----------+---------+------+-------+--------+

obcluster running
Get local repositories and plugins ok
Open ssh connection ok
Connect to observer ok
Create tenant test ok
deploy success!
boot success!
top - 05:24:07 up  4:47,  0 users,  load average: 9.64, 11.31, 10.45
Tasks:   2 total,   1 running,   1 sleeping,   0 stopped,   0 zombie
%Cpu(s):  0.0 us,  0.0 sy,  0.0 ni,100.0 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
MiB Mem :  11835.0 total,   1520.1 free,   5593.0 used,   4721.9 buff/cache
MiB Swap:   3969.0 total,   3967.1 free,      1.9 used.   5814.0 avail Mem

   PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND
   176 root      20   0 6865516   4.1g  52016 S  33.3  35.3   0:21.72 observer
  • login test
[root@oceanbase1 oceanbase-docker]# mysql -h127.1 -uroot -P2881
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MySQL connection id is 3221487625
Server version: 5.7.25 OceanBase 3.1.4 (r10000092022071511-b4bfa011ceaef428782dcb65ae89190c40b78c2f) (Built Jul 15 2022 11:45:14)

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MySQL [(none)]> select now();
+---------------------+
| now()               |
+---------------------+
| 2022-11-01 13:24:19 |
+---------------------+
1 row in set (0.00 sec)

MySQL [(none)]> Bye
[root@oceanbase1 oceanbase-docker]# docker exec -it oceanbase1 bash
root@05f05daac815:~# obclient -h127.1 -uroot -P2881
Welcome to the OceanBase.  Commands end with ; or \g.
Your OceanBase connection id is 3221487630
Server version: 5.7.25 OceanBase 3.1.4 (r10000092022071511-b4bfa011ceaef428782dcb65ae89190c40b78c2f) (Built Jul 15 2022 11:45:14)

Copyright (c) 2000, 2022, OceanBase and/or its affiliates. All rights reserved.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

obclient [(none)]> see le    ;
ERROR: No query specified

obclient [(none)]> select now();
+---------------------+
| now()               |
+---------------------+
| 2022-11-01 13:24:47 |
+---------------------+
1 row in set (0.001 sec)

obclient [(none)]> Bye
root@05f05daac815:~# exit

四、上传代码

[root@oceanbase1 oceanbase-docker]# tree 3.1.4/
3.1.4/
├── boot
│   ├── _boot
│   ├── boot-mini-tmp.yaml
│   ├── boot-tmp.yaml
│   ├── _env
│   ├── init_tenant_user.sql
│   └── ob-mysql
└── Dockerfile

1 directory, 7 files

[root@oceanbase1 oceanbase-docker]# git add .
[root@oceanbase1 oceanbase-docker]# git commit -m "first commit OceanBase Docker 3.1.4 for Ubuntu 20.04"
[master 7e07935] first commit OceanBase Docker 3.1.4 for Ubuntu 20.04
 7 files changed, 250 insertions(+)
 create mode 100644 3.1.4/Dockerfile
 create mode 100755 3.1.4/boot/_boot
 create mode 100755 3.1.4/boot/_env
 create mode 100644 3.1.4/boot/boot-mini-tmp.yaml
 create mode 100644 3.1.4/boot/boot-tmp.yaml
 create mode 100644 3.1.4/boot/init_tenant_user.sql
 create mode 100755 3.1.4/boot/ob-mysql
[root@oceanbase1 oceanbase-docker]# git push origin master
Username for 'https://gitee.com': 15501059069
Password for 'https://15501059069@gitee.com':
Counting objects: 12, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (11/11), done.
Writing objects: 100% (11/11), 3.99 KiB | 0 bytes/s, done.
Total 11 (delta 0), reused 0 (delta 0)
remote: Powered by GITEE.COM [GNK-6.4]
To https://gitee.com/lee1002/oceanbase-docker.git
   f1bbbb9..7e07935  master -> master

五、上传阿里云和docker hub镜像仓库

  • aliyun push
[root@oceanbase1 ~]# docker login --username=lihongda1002 registry.cn-hangzhou.aliyuncs.com
Password:
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store

Login Succeeded
[root@oceanbase1 ~]# docker tag 876fbee4e01c  registry.cn-hangzhou.aliyuncs.com/lihongda/oceanbase:3.1.4
[root@oceanbase1 ~]# docker push registry.cn-hangzhou.aliyuncs.com/lihongda/oceanbase:3.1.4
The push refers to repository [registry.cn-hangzhou.aliyuncs.com/lihongda/oceanbase]
324f607e68b1: Pushed
ccf65c4db96f: Pushed
9f54eef41275: Pushed
3.1.4: digest: sha256:f8d2e174dbe0c2bfa3baa5f0fc08c593aa9a18d6a03c8a9cd53eed5770c3e13d size: 950
  • 阿里云镜像大小
    image.png
    image.png

  • docker hub push

[root@oceanbase1 ~]# docker push 15501059069/oceanbase:3.1.4
The push refers to repository [docker.io/15501059069/oceanbase]
324f607e68b1: Pushed
ccf65c4db96f: Layer already exists
9f54eef41275: Layer already exists
3.1.4: digest: sha256:f8d2e174dbe0c2bfa3baa5f0fc08c593aa9a18d6a03c8a9cd53eed5770c3e13d size: 950

  • docker hub镜像大小
    image.png

  • 对比官方镜像
    image.png

六、下载测试

  • pull
[root@node1 ~]# docker pull registry.cn-hangzhou.aliyuncs.com/lihongda/oceanbase:3.1.4
3.1.4: Pulling from lihongda/oceanbase
7b1a6ab2e44d: Pull complete
d1d2fe4e3cb7: Pull complete
704e71a61af6: Pull complete
Digest: sha256:f8d2e174dbe0c2bfa3baa5f0fc08c593aa9a18d6a03c8a9cd53eed5770c3e13d
Status: Downloaded newer image for registry.cn-hangzhou.aliyuncs.com/lihongda/oceanbase:3.1.4
registry.cn-hangzhou.aliyuncs.com/lihongda/oceanbase:3.1.4
[root@node1 ~]# docker pull 15501059069/oceanbase:3.1.4
3.1.4: Pulling from 15501059069/oceanbase
Digest: sha256:f8d2e174dbe0c2bfa3baa5f0fc08c593aa9a18d6a03c8a9cd53eed5770c3e13d
Status: Downloaded newer image for 15501059069/oceanbase:3.1.4
docker.io/15501059069/oceanbase:3.1.4
[root@node1 ~]# docker image ls |grep oceanbase
15501059069/oceanbase                                                         3.1.4       876fbee4e01c   About an hour ago   402MB
registry.cn-hangzhou.aliyuncs.com/lihongda/oceanbase                          3.1.4       876fbee4e01c   About an hour ago   402MB
  • run
[root@node1 ~]# docker run -p 2881:2881 --name oceanbase -e MINI_MODE=1 -d 876fbee4e01c
ce6f837ad9f4b3f281a93ba1354bee5183825a0e753f62cdd9b39b6039ba3197
  • log
[root@node1 ~]# docker logs -f oceanbase
generate boot.yaml ...
oceanbase-ce docker in mini mode
create boot dirs and deploy ob cluster ...
name: oceanbase-ce
version: 3.1.4
release:10000092022071511.el7
arch: x86_64
md5: c5cd94f4f190317b6a883c58a26460a506205ce6
add /root/pkg/oceanbase-ce-3.1.4-10000092022071511.el7.x86_64.rpm to local mirror
name: oceanbase-ce-libs
version: 3.1.4
release:10000092022071511.el7
arch: x86_64
md5: 6d5437b0cad486b55963f89b8ef3769af7995350
add /root/pkg/oceanbase-ce-libs-3.1.4-10000092022071511.el7.x86_64.rpm to local mirror
+---------------------------------------------------------------------------------------------------------+
|                                            local Package List                                           |
+-------------------+---------+-----------------------+--------+------------------------------------------+
| name              | version | release               | arch   | md5                                      |
+-------------------+---------+-----------------------+--------+------------------------------------------+
| oceanbase-ce      | 3.1.4   | 10000092022071511.el7 | x86_64 | c5cd94f4f190317b6a883c58a26460a506205ce6 |
| oceanbase-ce-libs | 3.1.4   | 10000092022071511.el7 | x86_64 | 6d5437b0cad486b55963f89b8ef3769af7995350 |
+-------------------+---------+-----------------------+--------+------------------------------------------+
Local deploy is empty
[WARN] Use centos 7 remote mirror repository for ubuntu 20.04
Package oceanbase-ce-3.1.4-10000092022071511.el7 is available.
install oceanbase-ce-3.1.4 for local ok
Cluster param config check ok
Open ssh connection ok
Generate observer configuration ok
[WARN] Use centos 7 remote mirror repository for ubuntu 20.04
oceanbase-ce-3.1.4 already installed.
+-------------------------------------------------------------------------------------------+
|                                          Packages                                         |
+--------------+---------+-----------------------+------------------------------------------+
| Repository   | Version | Release               | Md5                                      |
+--------------+---------+-----------------------+------------------------------------------+
| oceanbase-ce | 3.1.4   | 10000092022071511.el7 | c5cd94f4f190317b6a883c58a26460a506205ce6 |
+--------------+---------+-----------------------+------------------------------------------+
Repository integrity check ok
Parameter check ok
Open ssh connection ok
Cluster status check ok
Initializes observer work home ok
Remote oceanbase-ce-3.1.4-10000092022071511.el7-c5cd94f4f190317b6a883c58a26460a506205ce6 repository install ok
Remote oceanbase-ce-3.1.4-10000092022071511.el7-c5cd94f4f190317b6a883c58a26460a506205ce6 repository lib check !!
Try to get lib-repository
[WARN] Use centos 7 remote mirror repository for ubuntu 20.04
Package oceanbase-ce-libs-3.1.4-10000092022071511.el7 is available.
install oceanbase-ce-libs-3.1.4 for local ok
Remote oceanbase-ce-libs-3.1.4-10000092022071511.el7-6d5437b0cad486b55963f89b8ef3769af7995350 repository install ok
Remote oceanbase-ce-3.1.4-10000092022071511.el7-c5cd94f4f190317b6a883c58a26460a506205ce6 repository lib check ok
obcluster deployed
Get local repositories ok
Search plugins ok
Open ssh connection ok
Load cluster param plugin ok
Check before start observer ok
[WARN] (127.0.0.1) failed to get open files
[WARN] (127.0.0.1) failed to get max user processes
[WARN] (127.0.0.1) clog and data use the same disk (/)

Start observer ok
observer program health check ok
Connect to observer ok
Initialize cluster

Cluster bootstrap ok
Wait for observer init ok
+---------------------------------------------+
|                   observer                  |
+-----------+---------+------+-------+--------+
| ip        | version | port | zone  | status |
+-----------+---------+------+-------+--------+
| 127.0.0.1 | 3.1.4   | 2881 | zone1 | active |
+-----------+---------+------+-------+--------+

obcluster running
Get local repositories and plugins ok
Open ssh connection ok
Connect to observer ok
Create tenant test ok
deploy success!
boot success!
top - 06:28:27 up  2:43,  0 users,  load average: 73.30, 29.31, 11.27
Tasks:   2 total,   2 running,   0 sleeping,   0 stopped,   0 zombie
%Cpu(s): 82.3 us, 17.7 sy,  0.0 ni,  0.0 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
MiB Mem :  15995.0 total,   4750.4 free,   6152.4 used,   5092.2 buff/cache
MiB Swap:      0.0 total,      0.0 free,      0.0 used.   6943.8 avail Mem

   PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND
   176 root      20   0 6929004   3.6g  54604 R 353.3  23.1   9:31.52 observer
^C
  • login test
[root@node1 ~]# docker exec -it oceanbase bash
root@ce6f837ad9f4:~# obclient -h127.1 -uroot -P2881
Welcome to the OceanBase.  Commands end with ; or \g.
Your OceanBase connection id is 3221487646
Server version: 5.7.25 OceanBase 3.1.4 (r10000092022071511-b4bfa011ceaef428782dcb65ae89190c40b78c2f) (Built Jul 15 2022 11:45:14)

Copyright (c) 2000, 2022, OceanBase and/or its affiliates. All rights reserved.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

obclient [(none)]> select now();
+---------------------+
| now()               |
+---------------------+
| 2022-11-01 14:29:40 |
+---------------------+
1 row in set (0.002 sec)

obclient [(none)]>

总结


制作数据库的容器版也是一个道阻且长的过程,后续有许多可以添加的功能,比如自定义数据库的各种参数(将变量从_boot引入到config.yaml里),制作默认的创建的数据库用户账号及密码,提供一些demo测试环境,预制一些插件和功能,提供多个container实现分布式功能,Docker-Compose一键部署功能,暂时就想到这么多,下边是一些地址,有需要的可以自行取用。

  • dockerhub
docker pull 15501059069/oceanbase:3.1.4
  • aliyun
docker pull registry.cn-hangzhou.aliyuncs.com/lihongda/oceanbase:3.1.4
  • gitee
git clone https://gitee.com/lee1002/oceanbase-docker.git
最后修改时间:2022-11-04 09:25:47
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论