使用docker快速体验oceanbase

本文涉及的产品
云数据库 RDS MySQL,集群系列 2核4GB
推荐场景:
搭建个人博客
RDS MySQL Serverless 基础系列,0.5-2RCU 50GB
云数据库 RDS MySQL,高可用系列 2核4GB
简介: 在Windows上使用dockers快速体验oceanbase


1 资源要求

     
     所用笔记本电脑内存为16GB, 处理器Intel i5-8250U,操作系统为Windows 10 Home版,符合Ocean对Docker资源的要求。
23 安装Docker软件
从官网上下载Docker 安装包,地址如下图所示:

这台笔记本上已经安装配置号了WSL2,所以这里选择的是WSL2 backend,下载安装包后双击下载的安装包按照提示安装即可,安装的最后一步,需要退出当前windows 用户重新登陆。

打开Docker 桌面,手动调整一下默认容器资源限制,点击Docker桌面 右上角setting后,Resources菜单,看到下图提示:

        由于Docker后端使用的是WSL 2,要通过WSL2 来配置内存,cpu, 和交换区大小,查看微软官网关于WSL2 资源配置,发现下面的内容:

 windows 内存超过8G之后,默认每个容器的内存限制是总内存的80%,这台笔记本电脑内存为16G,容器内存限制为16GB*80%, 超过了Ocean要求的10GB限制,所以这里使用默认的限制即可。

3 下载并启动镜像
打开命令提示符窗口,搜索Ocean Base映像

C:\Users\lichengxu>docker search oceanbase
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
oceanbase/oceanbase-xe OceanBase Database 2.2 Express Edition 3
oceanbase/obce-mini obce-mini is a mini standalone test image fo… 2
obpilot/oceanbase-ce 3 steps to run an OceanBase-CE docker in you… 2
zibuyu886/oceanbase-ce-cluster OceanBase ce cluster 1
oceanbase/oceanbase-ce OceanBase is open source now. This is the do… 1
huweijie/oceanbase-ce-deploy 0
oceanbase/centos7 0
superbigfu/oceanbase 0
hongweiqin/anolisos-oceanbase A tentative deploy of oceanbase. 0
stutiredboy/centos_ob Build environment for OceanBase 3.1 CE. Crea… 0

下载映像obpilot/oceanbase-ce,

C:\Users\lichengxu>docker pull obpilot/oceanbase-ce
Using default tag: latest
latest: Pulling from obpilot/oceanbase-ce
7a0437f04f83: Pull complete
615dc48ac9f1: Pull complete
b10c1cdae3af: Pull complete
4f4fb700ef54: Pull complete
c0f6c94a6a6a: Pull complete
792630f35e24: Pull complete
Digest: sha256:7ac28415cf27ba19cb47acb67a55ebf9848ad73a63d80b7e2e85d653233dbaeb
Status: Downloaded newer image for obpilot/oceanbase-ce:latest
docker.io/obpilot/oceanbase-ce:latest
运行下载的映像

C:\Users\lichengxu>docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
obpilot/oceanbase-ce latest 943379e0b05b 4 weeks ago 2.25GB

C:\Users\lichengxu>docker run -itd -m 10G --name oceanbase-ce 943379e0b05b
9b435a0284d5f45fca8d0c8a82f1d3635d483ce11f930c78b253cd220274f8fc

C:\Users\lichengxu>docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
9b435a0284d5 943379e0b05b "/bin/bash" 8 seconds ago Up 9 seconds 2881/tcp, 2883/tcp oceanbase-ce

检查容器oceanbase-ce状态为up。

4 OceanBase集群部署
登陆到运行容器内检查集群状态,集群obdemo状态为deployed

C:\Users\lichengxu>docker exec -it oceanbase-ce bash

[admin@9b435a0284d5 ~]$ obd cluster list
Cluster List
Name Configuration Path Status (Cached)
obdemo /home/admin/.obd/cluster/obdemo deployed

启动集群

[admin@9b435a0284d5 ~]$ obd cluster start obdemo
Get local repositories and plugins ok
Open ssh connection ok
Cluster param config check ok
Check before start observer ok
[WARN] (127.0.0.1) The recommended value of fs.aio-max-nr is 1048576 (Current value: 65536)

Check before start obproxy ok
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.1 2881 zone1 active

Start obproxy ok
obproxy program health check ok
Connect to obproxy ok

Initialize cluster
obproxy
ip port prometheus_port status
127.0.0.1 2883 2884 active

obdemo running

启动时,可以从屏幕上看到oceanbase的启动过程,集群先启动observer,后启动obproxy,然后初始化集群,启动成功后,显示odemo状态为running。

[admin@9b435a0284d5 ~]$ obd cluster list
Cluster List
Name Configuration Path Status (Cached)
obdemo /home/admin/.obd/cluster/obdemo running

检查现在集群状态为running,表名集群正在运行。

管理员admin的密码是adminPWD123,运行下面命令连接集群,2881为oceanbase observer监听的端口

[admin@40ba977baa4e obdemo]$ obclient -h127.1 -uroot@sys -P2881 -prootPWD123 -c -A oceanbase
Welcome to the OceanBase. Commands end with ; or \g.
Your MySQL connection id is 3221487883
Server version: 5.7.25 OceanBase 3.1.1 (r4-8c615943cbd25a6f7b8bdfd8677a13a21709a05e) (Built Oct 21 2021 10:52:05)

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

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

也可以通过obproxy连接

[admin@40ba977baa4e obdemo]$ obclient -h127.1 -uroot@sys -P2883 -prootPWD123 -c -A oceanbase
Welcome to the OceanBase. Commands end with ; or \g.
Your MySQL connection id is 12
Server version: 5.6.25 OceanBase 3.1.1 (r4-8c615943cbd25a6f7b8bdfd8677a13a21709a05e) (Built Oct 21 2021 10:52:05)

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

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

5 创建一个业务租户、一个业务数据库,表
创建资源单元,名称为s1c1c
MySQL [oceanbase]> create resource unit s1c1c max_cpu=1, min_cpu=1, max_memory='1G', min_memory='1G',m
ax_iops=1000, max_session_num=10000, max_disk_size='6G';
Query OK, 0 rows affected (0.014 sec)
创建资源池my_pool
MySQL [oceanbase]> create resource pool my_pool unit='s1c1c', unit_num=1;
Query OK, 0 rows affected (0.014 sec)
创建租户obmysql
MySQL [oceanbase]> create tenant obmysql resource_pool_list=('my_pool'), primary_zone='RANDOM',comment 'mysql tenant/instance', charset='utf8' set ob_tcp_invited_nodes='%', ob_compatibility_mode='mysql';
Query OK, 0 rows affected (1.943 sec)
退出当前会话,重新登陆,切换当前数据库至test

[admin@40ba977baa4e obdemo]$ obclient -h127.1 -uroot@obmysql -P2883
Welcome to the OceanBase. Commands end with ; or \g.
Your MySQL connection id is 13
Server version: 5.6.25 OceanBase 3.1.1 (r4-8c615943cbd25a6f7b8bdfd8677a13a21709a05e) (Built Oct 21 2021 10:52:05)

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)]> show databases;
Database
oceanbase
information_schema
mysql
test

4 rows in set (0.003 sec)

MySQL [(none)]> use test;
Database changed

创建表,插入一下数据

MySQL [test]> create table student(

->     sno int not null auto_increment primary key,
->     sname varchar(10) not null,
->     sex char(1) not null,
->     sage tinyint(100) not null,
->     sdept char(4) not null)comment = '学生表';

Query OK, 0 rows affected (0.101 sec)

MySQL [test]> insert into student (sname, sex, sage, sdept) values ('liyong', 'm', 20, 'CS');
Query OK, 1 row affected (0.021 sec)

MySQL [test]> insert into student (sname, sex, sage, sdept) values ('liuchen', 'f', 19, 'CS');
Query OK, 1 row affected (0.006 sec)

MySQL [test]> insert into student (sname, sex, sage, sdept) values ('wangmin', 'f', 18, 'MA');
Query OK, 1 row affected (0.006 sec)

MySQL [test]> insert into student (sname, sex, sage, sdept) values ('zhangli', 'f', 19, 'IS');
Query OK, 1 row affected (0.006 sec)

MySQL [test]>
MySQL [test]> insert into student (sname, sex, sage, sdept) values ('wangyong', 'm', 20, 'CS');
Query OK, 1 row affected (0.004 sec)

MySQL [test]> insert into student (sname, sex, sage, sdept) values ('zhangchen', 'f', 19, 'CS');
Query OK, 1 row affected (0.006 sec)

MySQL [test]> insert into student (sname, sex, sage, sdept) values ('xiemin', 'f', 18, 'MA');
Query OK, 1 row affected (0.006 sec)

MySQL [test]> insert into student (sname, sex, sage, sdept) values ('duli', 'm', 19, 'IS');
Query OK, 1 row affected (0.004 sec)

检查表中的数据,表中已有数据。

MySQL [test]> select * from student;
sno sname sex sage sdept
1 liyong m 20 CS
2 liuchen f 19 CS
3 wangmin f 18 MA
4 zhangli f 19 IS
5 wangyong m 20 CS
6 zhangchen f 19 CS
7 xiemin f 18 MA
8 duli m 19 IS

8 rows in set (0.002 sec)

相关实践学习
如何在云端创建MySQL数据库
开始实验后,系统会自动创建一台自建MySQL的 源数据库 ECS 实例和一台 目标数据库 RDS。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助     相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
相关文章
|
5月前
|
SQL 数据库 Docker
OBCP实践 - OceanBase Docker 体验
开发者和技术爱好者可以在无需复杂安装配置的情况下迅速搭建OceanBase数据库环境,从而方便地进行功能测试、性能评估或者开发调试等实践活动。同时,由于Docker的便捷性,此方法也支持跨平台部署,使得OceanBase数据库能够在不同的操作系统(如Linux、Windows、macOS)上轻松体验。
250 2
|
存储 弹性计算 关系型数据库
5 分钟玩转 OceanBase 社区版 Docker 部署
## 简介 本文是个人把 OceanBase 社区版 3.1 做了一个 Docker 镜像,仅用于学习研究。只要你有一个 4C10G的笔记本可以联公网,你就可以在5分钟内将 OceanBase 社区版跑起来。 OceanBase 社区版是今年 6月1日开源的,只兼容 MySQL,可以理解为分布式的MySQL。其核心功能跟内部业务在用的OceanBase 企业版基本一致。核心功能包含:**多副
3431 0
5 分钟玩转 OceanBase 社区版 Docker 部署
|
存储 容灾 固态存储
【docker】使用容器安装部署OceanBase社区版数据库
【docker】使用容器安装部署OceanBase社区版数据库
1403 0
【docker】使用容器安装部署OceanBase社区版数据库
|
Oracle 关系型数据库 MySQL
arm服务器OceanBase初始化安装体验
OceanBase初始化安装体验
473 0
|
SQL 缓存 算法
首届OceanBase数据库大赛冠军!被北京青年报点赞的人大队伍谈参赛体验
首届OceanBase数据库大赛冠军!被北京青年报点赞的人大队伍谈参赛体验
467 0
首届OceanBase数据库大赛冠军!被北京青年报点赞的人大队伍谈参赛体验
|
存储 Oracle 关系型数据库
OceanBase Docker 体验
OceanBase Docker 体验
|
SQL Oracle 关系型数据库
OceanBase 2.2 体验:用JMeter测试OceanBase性能
本文介绍使用JMeter测试OceanBase性能的方法。 这个方法适用于所有关系数据库(包括分布式的)。
2327 0
|
2月前
|
存储 SQL 分布式数据库
OceanBase 入门:分布式数据库的基础概念
【8月更文第31天】在当今的大数据时代,随着业务规模的不断扩大,传统的单机数据库已经难以满足高并发、大数据量的应用需求。分布式数据库应运而生,成为解决这一问题的有效方案之一。本文将介绍一款由阿里巴巴集团自主研发的分布式数据库——OceanBase,并通过一些基础概念和实际代码示例来帮助读者理解其工作原理。
118 0
|
2月前
|
Oracle 架构师 分布式数据库
OceanBase数据库的发展历程是什么?
【8月更文挑战第11天】OceanBase数据库的发展历程是什么?
146 63
|
2月前
|
Oracle 关系型数据库 MySQL
OceanBase数据库简介
【8月更文挑战第9天】OceanBase数据库简介
275 60
下一篇
无影云桌面