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

本文涉及的产品
容器服务 Serverless 版 ACK Serverless,952元额度 多规格
容器镜像服务 ACR,镜像仓库100个 不限时长
容器服务 Serverless 版 ACK Serverless,317元额度 多规格
简介: 「更易用的OceanBase」| 制作自定义OceanBase容器——逆向思维
  • 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
  • 阿里云镜像大小
    网络异常,图片无法展示
    |

    网络异常,图片无法展示
    |

  • 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镜像大小
    网络异常,图片无法展示
    |

  • 对比官方镜像
    网络异常,图片无法展示
    |

六、下载测试

  • 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
相关实践学习
如何在云端创建MySQL数据库
开始实验后,系统会自动创建一台自建MySQL的 源数据库 ECS 实例和一台 目标数据库 RDS。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助     相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
目录
相关文章
|
6月前
|
存储 算法 C语言
【C++ 迭代器实现 终篇】深入理解C++自定义容器和迭代器的实现与应用
【C++ 迭代器实现 终篇】深入理解C++自定义容器和迭代器的实现与应用
223 0
|
5月前
|
监控 Serverless 文件存储
函数计算产品使用问题之如何确保新建的实例拉取的是最新的自定义容器镜像
函数计算产品作为一种事件驱动的全托管计算服务,让用户能够专注于业务逻辑的编写,而无需关心底层服务器的管理与运维。你可以有效地利用函数计算产品来支撑各类应用场景,从简单的数据处理到复杂的业务逻辑,实现快速、高效、低成本的云上部署与运维。以下是一些关于使用函数计算产品的合集和要点,帮助你更好地理解和应用这一服务。
|
3月前
|
C++ 容器
C++中自定义结构体或类作为关联容器的键
C++中自定义结构体或类作为关联容器的键
40 0
|
6月前
|
存储 弹性计算 运维
Docker数据集与自定义镜像:构建高效容器的关键要素
Docker数据集与自定义镜像:构建高效容器的关键要素
135 8
|
6月前
|
运维 安全 Linux
深入理解Docker自定义网络:构建高效的容器网络环境
深入理解Docker自定义网络:构建高效的容器网络环境
286 6
|
6月前
|
存储 C++ 容器
set容器一自定义数据类型指定排序规则讲解
set容器一自定义数据类型指定排序规则讲解
186 1
|
6月前
|
算法 程序员 C语言
【C++ 迭代器】深入探讨 C++ 迭代器:标准与自定义容器中的 begin() 和 cbegin()
【C++ 迭代器】深入探讨 C++ 迭代器:标准与自定义容器中的 begin() 和 cbegin()
178 0
|
9天前
|
Kubernetes Cloud Native Docker
云原生时代的容器化实践:Docker和Kubernetes入门
【10月更文挑战第37天】在数字化转型的浪潮中,云原生技术成为企业提升敏捷性和效率的关键。本篇文章将引导读者了解如何利用Docker进行容器化打包及部署,以及Kubernetes集群管理的基础操作,帮助初学者快速入门云原生的世界。通过实际案例分析,我们将深入探讨这些技术在现代IT架构中的应用与影响。
41 2
|
15天前
|
关系型数据库 MySQL API
|
6天前
|
机器学习/深度学习 数据采集 Docker
Docker容器化实战:构建并部署一个简单的Web应用
Docker容器化实战:构建并部署一个简单的Web应用
下一篇
无影云桌面