当前位置: 首页 > 工具软件 > Docs-base > 使用案例 >

OceanBase数据库Docker部署文档

华子航
2023-12-01

OceanBase数据库Docker****部署文档
OceanBase数据库Docker****部署文档

本文主要是使用docker容器使用oceanbase镜像部署一个单节点集群,供学习使用。其中也有一些再部署过程中出现的一些问题报错,我也给出了一些问题分析和解决办法。

一、部署准备

1、主机版本信息及配置:
Windows 10, 64-bit, 8C,16G
2、VMware版本信息:
VMware® Workstation 12 Pro 12.0.0 build-2985596
3、CentOS-7版本信息及配置:CentOS-7-x86_64-DVD-2009
虚拟机配置 Cpu 8核,内存16G,硬盘 20G
注:docker安装简单切勿用于生产

二、部署过程

1、配置一下yum

wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo

yum makecache 

2、安装一下docker

yum -y install docker

3 、查看docker安装列表

yum list installed | grep docker 

[root@localhost yum.repos.d]# yum list installed | grep docker 
docker.x86_64                           2:1.13.1-208.git7d71120.el7_9  @extras  
docker-client.x86_64                    2:1.13.1-208.git7d71120.el7_9  @extras  
docker-common.x86_64                    2:1.13.1-208.git7d71120.el7_9  @extras  安装成功

4、 启动docker容器

service docker start

5、查看docker是否启动(active为启动状态)

service docker status 
[root@localhost yum.repos.d]# service docker status 
Redirecting to /bin/systemctl status docker.service
● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
   Active: active (running) since 六 2021-12-11 10:08:13 CST; 7s ago
     Docs: http://docs.docker.com
 Main PID: 20796 (dockerd-current)
    Tasks: 28
   CGroup: /system.slice/docker.service
           ├─20796 /usr/bin/dockerd-current --add-runtime docker-runc=/usr/libex...
           └─20807 /usr/bin/docker-containerd-current -l unix:///var/run/docker/.

6、搜索oceanbase镜像

docker search oceanbase 

[root@localhost yum.repos.d]# docker search oceanbase 
INDEX       NAME                                       DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
docker.io   docker.io/oceanbase/oceanbase-xe           OceanBase Database 2.2 Express Edition                        
docker.io   docker.io/obpilot/oceanbase-ce             3 steps to run an OceanBase-CE docker in                  
docker.io   docker.io/oceanbase/obce-mini              obce-mini is a mini standalone test image                
docker.io   docker.io/oceanbase/oceanbase-ce           OceanBase is open source now. This is the                 
docker.io   docker.io/zibuyu886/oceanbase-ce-cluster   OceanBase ce cluster                            
docker.io   docker.io/hongweiqin/anolisos-oceanbase    A tentative deploy of oceanbase.                0                    
docker.io   docker.io/huweijie/oceanbase-ce-deploy                                                     0                    
docker.io   docker.io/oceanbase/centos7                                                                0                    
docker.io   docker.io/stutiredboy/centos_ob            Build environment for OceanBase 3.1 CE. Cr...   0                    
docker.io   docker.io/superbigfu/oceanbase                                                             0                    

7、安装 docker

docker pull oceanbase/obce-mini 

8、运行docker

docker run -p 2881:2881 --name oceanbase-mini -d -e OB_HOME_PATH="/root/obce/" -e OB_TENANT_NAME="obmysql" oceanbase/obce-mini

9、查看运行日志

[root@localhost yum.repos.d]# docker logs oceanbase-mini
generate boot.yaml ...
create boot dirs and deploy ob cluster ...
Package oceanbase-ce-3.1.0 is available.
install oceanbase-ce-3.1.0 for local ok
+-----------------------------------------------------------------------------+
|                                   Packages                                  |
+--------------+---------+---------+------------------------------------------+
| Repository   | Version | Release | Md5                                      |
+--------------+---------+---------+------------------------------------------+
| oceanbase-ce | 3.1.0   | 2.el7   | afd11d52f83eef4b456d77969fde620c4bfba85e |
+--------------+---------+---------+------------------------------------------+
Open ssh connection ok**

10、进入oceanbase,并启动集群:

[root@localhost yum.repos.d]# docker exec -it oceanbase-mini bash 
[root@92a08310b8f3 /]# obd cluster start mini-ce 
Get local repositories and plugins ok
Open ssh connection ok
Cluster status check ok
Deploy "mini-ce" is running

11、进入数据库(初次完成不需要输入密码)

obclient -h 127.0.0.1 -P 2881 -uroot -p -c -A

12、查看当前资源规格及资源池配置(默认是有一个obmysql)

select unit_config_id, name from __all_unit_config;
select resource_pool_id, name from __all_resource_pool;
MySQL [oceanbase]>  select tenant_id,tenant_name,max_cpu,min_cpu,max_memory/1024/1024/1024 from v$unit;
+-----------+-------------+---------+---------+---------------------------+
| tenant_id | tenant_name | max_cpu | min_cpu | max_memory/1024/1024/1024 |
+-----------+-------------+---------+---------+---------------------------+
|         1 | sys         |       5 |     2.5 |            1.199999999255 |
|      1001 | obmysql     |       9 |       9 |            2.500000000000 |

13、利用系统默认的用户登录(系统给的没有密码)

obclient -h 127.0.0.1 -P 2881 -uroot@obmysql  -p -c -A
obclient -h 127.0.0.1 -P 2883 -u root@obmysql -p -c -A oceanbase

14、创建一个单元资源(可选)可跳过

create resource unit my_unit1 max_cpu=1, max_memory='1g', max_iops=128, max_disk_size='5g', max_session_num=64, min_cpu=1, min_memory='1g', min_iops=128;

15、资源池配置(可选)可跳过

create resource pool my_pool1 unit='my_unit1', unit_num=1, zone_list=('zone1');

16、创建一个租户

create tenant my_tenant1 resource_pool_list=('obmysql');

17、创建数据表

create table user1(id int(4) primary key, name varchar(20));

18、创建内容

insert into user1(id, name) values(1, '张三');
insert into user1(id, name) values(2, '李四');

MySQL [test]> select * from user1;
+----+--------+
| id | name   |
+----+--------+
|  1 | 张三 |
|  2 | 李四 |
+----+--------+
2 rows in set (0.002 sec)
 类似资料: