- 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
四、上传代码
- 代码仓库地址 https://gitee.com/lee1002/oceanbase-docker
- 依赖包仓库地址 https://gitee.com/lee1002/oceanbase-depend
- 有任何使用上或者功能上的问题可以提issue,评论或者留言给我。
- git push
[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