【docker】使用容器安装部署OceanBase社区版数据库

本文涉及的产品
容器服务 Serverless 版 ACK Serverless,317元额度 多规格
容器服务 Serverless 版 ACK Serverless,952元额度 多规格
容器镜像服务 ACR,镜像仓库100个 不限时长
简介: 【docker】使用容器安装部署OceanBase社区版数据库

1、OceanBase企业级开源分布式数据库介绍


学习链接:OceanBase 社区版


OceanBase 社区版是一款开源分布式 HTAP(Hybrid Transactional/Analytical Processing)数据库管理系统,具有原生分布式架构,支持金融级高可用、透明水平扩展、分布式事务、多租户和语法兼容等企业级特性。OceanBase 内核通过大规模商用场景的考验,已服务众多行业客户,现面向未来持续构建内核技术竞争力。


2、OceanBase数据库亮点


高可用——单服务器故障能够自愈,支持跨城多机房容灾,数据零丢失,可满足金融行业6级容灾标准(RPO=0,RTO<=30秒)。


线性扩展——透明扩展,自动负载均衡,应用透明的水平扩展,集群规模可超过1500节点,数据量可达 PB 级,单表记录万亿行。


MySQL 高度兼容——兼容 MySQL 协议、语法和使用习惯,MySQL客户端工具可以直接访问OceanBase。


高性能——准内存级数据变更操作、独创的编码压缩技术,结合线性水平扩展,TPC-C 测试达到7.07亿 tpmC。


低成本——使用 PC 服务器和低端 SSD,高存储压缩率降低存储成本,高性能降低计算成本,多租户混部充分利用系统资源。


多租户——原生支持多租户构架,同一套数据库集群可以为多个独立业务提供服务,租户间数据隔离,降低部署和运维成本。


3、OceanBase镜像下载


下载链接🔗:obpilot/oceanbase-ce - Docker Image | Docker Hub


# 搜索镜像
[root@docker OceanBase]# docker search oceanbase
NAME                             DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
oceanbase/oceanbase-xe           OceanBase Database 2.2 Express Edition          4                    
oceanbase/oceanbase-ce           OceanBase is open source now. This is the do…   4                    
oceanbase/obce-mini              obce-mini is a mini standalone test image fo…   3                    
obpilot/oceanbase-ce             3 steps to run an OceanBase-CE docker in you…   3                    
oceanbase/obce-operator          obce-operator                                   1                    
oceanbase/miniob                 miniob database competition                     1                    
zibuyu886/oceanbase-ce-cluster   OceanBase ce cluster                            1                    
huweijie/oceanbase-ce-deploy                                                     0                    
superbigfu/oceanbase                                                             0                    
oceanbase/centos7                                                                0                    
20220121/oceanbase                                                               0                    
jimmyzhou623/oceanbase                                                           0                    
hongweiqin/anolisos-oceanbase    A tentative deploy of oceanbase.                0                    
stutiredboy/centos_ob            Build environment for OceanBase 3.1 CE. Crea…   0                    
ggzzzzzzz/obce-mini              oceanbase community edition 3.1.3 mini image    0                    
[root@docker OceanBase]# 
# 下载镜像
[root@docker-oceanbase ~]# docker pull obpilot/oceanbase-ce: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
[root@docker-oceanbase ~]#
# 查看下载的镜像
[root@docker-oceanbase ~]# docker images
REPOSITORY               TAG       IMAGE ID       CREATED        SIZE
oceanbase/oceanbase-ce   latest    66c986c2d478   3 weeks ago    783MB
obpilot/oceanbase-ce     latest    943379e0b05b   4 months ago   2.25GB
# 查看镜像详细信息
[root@docker-oceanbase ~]# docker inspect obpilot/oceanbase-ce
[
    {
        "Id": "sha256:943379e0b05b2d875575e60b925e62a0c1c406e159712bb3da878ba94c6aa927",
        "RepoTags": [
            "obpilot/oceanbase-ce:latest"
        ],
        "RepoDigests": [
            "obpilot/oceanbase-ce@sha256:7ac28415cf27ba19cb47acb67a55ebf9848ad73a63d80b7e2e85d653233dbaeb"
        ],
        "Parent": "",
        "Comment": "buildkit.dockerfile.v0",
        "Created": "2021-12-02T09:38:08.564951155Z",
        "Container": "",
        "ContainerConfig": {
            "Hostname": "",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "Tty": false,
            "OpenStdin": false,
            "StdinOnce": false,
            "Env": null,
            "Cmd": null,
            "Image": "",
            "Volumes": null,
            "WorkingDir": "",
            "Entrypoint": null,
            "OnBuild": null,
            "Labels": null
        },
        "DockerVersion": "",
        "Author": "obpilot",
        "Config": {
            "Hostname": "",
            "Domainname": "",
            "User": "admin",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "ExposedPorts": {
                "2881/tcp": {},
                "2883/tcp": {}
            },
            "Tty": false,
            "OpenStdin": false,
            "StdinOnce": false,
            "Env": [
                "PATH=/u01/obclient/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
            ],
            "Cmd": [
                "/bin/bash"
            ],
            "Image": "",
            "Volumes": {
                "/data": {}
            },
            "WorkingDir": "/home/admin",
            "Entrypoint": null,
            "OnBuild": null,
            "Labels": {
                "org.label-schema.build-date": "20201204",
                "org.label-schema.license": "GPLv2",
                "org.label-schema.name": "CentOS Base Image",
                "org.label-schema.schema-version": "1.0",
                "org.label-schema.vendor": "CentOS"
            }
        },
        "Architecture": "amd64",
        "Os": "linux",
        "Size": 2254284106,
        "VirtualSize": 2254284106,
        "GraphDriver": {
            "Data": {
                "LowerDir": "/var/lib/docker/overlay2/88a0a85b2ae6f6b056dada96a0b6889438626edfcffb03da8bc34621d259cc98/diff:/var/lib/docker/overlay2/239971ea80af766b33512aea7c9a83aea7c7f190e680df1d415afec43fd25c12/diff:/var/lib/docker/overlay2/978489e5754f335b1c72cad3b9a4d194c822cea9d4cae27c89892ce0a613b1d4/diff:/var/lib/docker/overlay2/0166aaeb275e7347185f4f1d4894ed70e05e266ae919a12f46a2503f1d758515/diff:/var/lib/docker/overlay2/cea7a365c3d7e95b1a70f7f19e32762a2c8f2cc2f7d50926709a6fef14d6fb6e/diff",
                "MergedDir": "/var/lib/docker/overlay2/13930efda2c20ba05bb73e8751398b128e7fe0800b4fced2ff520de4e6fa48e7/merged",
                "UpperDir": "/var/lib/docker/overlay2/13930efda2c20ba05bb73e8751398b128e7fe0800b4fced2ff520de4e6fa48e7/diff",
                "WorkDir": "/var/lib/docker/overlay2/13930efda2c20ba05bb73e8751398b128e7fe0800b4fced2ff520de4e6fa48e7/work"
            },
            "Name": "overlay2"
        },
        "RootFS": {
            "Type": "layers",
            "Layers": [
                "sha256:2653d992f4ef2bfd27f94db643815aa567240c37732cae1405ad1c1309ee9859",
                "sha256:20d9ae45c7f222f404db69d67bbdf73ad526e9a05037ca6854a903dd7cc032b7",
                "sha256:200fd68be2b9a309595774e457c4b5947f425268207f6b1b23ce60d8ca218d44",
                "sha256:5f70bf18a086007016e948b04aed3b82103a36bea41755b6cddfaf10ace3c6ef",
                "sha256:ade784765441d76d839dad73c00fa1e85dac157d6047d362a8a7ac2b0932731a",
                "sha256:aa8e13edce9d58db6c35d13e4f440e87efab3e4831cfa16e9bdbc1afd05bb4a2"
            ]
        },
        "Metadata": {
            "LastTagTime": "0001-01-01T00:00:00Z"
        }
    }
]


4、启动OceanBase实例


先决条件:1、确保您的计算机至少有 2 个物理内核和 10GB 内存。2、确保已经安装最新的Docker并启动运行。


# 启动镜像
[root@docker-oceanbase ~]# docker run -itd --memory 8G --name xybdiy obpilot/oceanbase-ce:latest
6ffe9b5d09d9a8bd4bbae50bd46a243d588d618395f804ce0eb3abf1a736ebcd
# 查看容器是否正常启动
[root@docker-oceanbase ~]# docker ps -s
CONTAINER ID   IMAGE                         COMMAND       CREATED       STATUS       PORTS                NAMES     SIZE
6ffe9b5d09d9   obpilot/oceanbase-ce:latest   "/bin/bash"   2 hours ago   Up 2 hours   2881/tcp, 2883/tcp   xybdiy    5.37GB (virtual 7.62GB)
[root@docker-oceanbase ~]#
# 查看容器详细信息
[root@docker-oceanbase ~]# docker inspect 6ffe9b5d09d9
[
    {
        "Id": "6ffe9b5d09d9a8bd4bbae50bd46a243d588d618395f804ce0eb3abf1a736ebcd",
        "Created": "2022-04-30T14:57:52.762520182Z",
        "Path": "/bin/bash",
        "Args": [],
        "State": {
            "Status": "running",
            "Running": true,
            "Paused": false,
            "Restarting": false,
            "OOMKilled": false,
            "Dead": false,
            "Pid": 1575,
            "ExitCode": 0,
            "Error": "",
            "StartedAt": "2022-04-30T14:57:53.520103874Z",
            "FinishedAt": "0001-01-01T00:00:00Z"
        },
        "Image": "sha256:943379e0b05b2d875575e60b925e62a0c1c406e159712bb3da878ba94c6aa927",
        "ResolvConfPath": "/var/lib/docker/containers/6ffe9b5d09d9a8bd4bbae50bd46a243d588d618395f804ce0eb3abf1a736ebcd/resolv.conf",
        "HostnamePath": "/var/lib/docker/containers/6ffe9b5d09d9a8bd4bbae50bd46a243d588d618395f804ce0eb3abf1a736ebcd/hostname",
        "HostsPath": "/var/lib/docker/containers/6ffe9b5d09d9a8bd4bbae50bd46a243d588d618395f804ce0eb3abf1a736ebcd/hosts",
        "LogPath": "/var/lib/docker/containers/6ffe9b5d09d9a8bd4bbae50bd46a243d588d618395f804ce0eb3abf1a736ebcd/6ffe9b5d09d9a8bd4bbae50bd46a243d588d618395f804ce0eb3abf1a736ebcd-json.log",
        "Name": "/xybdiy",
        "RestartCount": 0,
        "Driver": "overlay2",
        "Platform": "linux",
        "MountLabel": "",
        "ProcessLabel": "",
        "AppArmorProfile": "",
        "ExecIDs": null,
        "HostConfig": {
            "Binds": null,
            "ContainerIDFile": "",
            "LogConfig": {
                "Type": "json-file",
                "Config": {}
            },
            "NetworkMode": "default",
            "PortBindings": {},
            "RestartPolicy": {
                "Name": "no",
                "MaximumRetryCount": 0
            },
            "AutoRemove": false,
            "VolumeDriver": "",
            "VolumesFrom": null,
            "CapAdd": null,
            "CapDrop": null,
            "CgroupnsMode": "host",
            "Dns": [],
            "DnsOptions": [],
            "DnsSearch": [],
            "ExtraHosts": null,
            "GroupAdd": null,
            "IpcMode": "private",
            "Cgroup": "",
            "Links": null,
            "OomScoreAdj": 0,
            "PidMode": "",
            "Privileged": false,
            "PublishAllPorts": false,
            "ReadonlyRootfs": false,
            "SecurityOpt": null,
            "UTSMode": "",
            "UsernsMode": "",
            "ShmSize": 67108864,
            "Runtime": "runc",
            "ConsoleSize": [
                0,
                0
            ],
            "Isolation": "",
            "CpuShares": 0,
            "Memory": 8589934592,
            "NanoCpus": 0,
            "CgroupParent": "",
            "BlkioWeight": 0,
            "BlkioWeightDevice": [],
            "BlkioDeviceReadBps": null,
            "BlkioDeviceWriteBps": null,
            "BlkioDeviceReadIOps": null,
            "BlkioDeviceWriteIOps": null,
            "CpuPeriod": 0,
            "CpuQuota": 0,
            "CpuRealtimePeriod": 0,
            "CpuRealtimeRuntime": 0,
            "CpusetCpus": "",
            "CpusetMems": "",
            "Devices": [],
            "DeviceCgroupRules": null,
            "DeviceRequests": null,
            "KernelMemory": 0,
            "KernelMemoryTCP": 0,
            "MemoryReservation": 0,
            "MemorySwap": 17179869184,
            "MemorySwappiness": null,
            "OomKillDisable": false,
            "PidsLimit": null,
            "Ulimits": null,
            "CpuCount": 0,
            "CpuPercent": 0,
            "IOMaximumIOps": 0,
            "IOMaximumBandwidth": 0,
            "MaskedPaths": [
                "/proc/asound",
                "/proc/acpi",
                "/proc/kcore",
                "/proc/keys",
                "/proc/latency_stats",
                "/proc/timer_list",
                "/proc/timer_stats",
                "/proc/sched_debug",
                "/proc/scsi",
                "/sys/firmware"
            ],
            "ReadonlyPaths": [
                "/proc/bus",
                "/proc/fs",
                "/proc/irq",
                "/proc/sys",
                "/proc/sysrq-trigger"
            ]
        },
        "GraphDriver": {
            "Data": {
                "LowerDir": "/var/lib/docker/overlay2/92e49cc234e06dbbc2f7bece13baa075c194356ac0faddd57c408298fb0fb5a5-init/diff:/var/lib/docker/overlay2/13930efda2c20ba05bb73e8751398b128e7fe0800b4fced2ff520de4e6fa48e7/diff:/var/lib/docker/overlay2/88a0a85b2ae6f6b056dada96a0b6889438626edfcffb03da8bc34621d259cc98/diff:/var/lib/docker/overlay2/239971ea80af766b33512aea7c9a83aea7c7f190e680df1d415afec43fd25c12/diff:/var/lib/docker/overlay2/978489e5754f335b1c72cad3b9a4d194c822cea9d4cae27c89892ce0a613b1d4/diff:/var/lib/docker/overlay2/0166aaeb275e7347185f4f1d4894ed70e05e266ae919a12f46a2503f1d758515/diff:/var/lib/docker/overlay2/cea7a365c3d7e95b1a70f7f19e32762a2c8f2cc2f7d50926709a6fef14d6fb6e/diff",
                "MergedDir": "/var/lib/docker/overlay2/92e49cc234e06dbbc2f7bece13baa075c194356ac0faddd57c408298fb0fb5a5/merged",
                "UpperDir": "/var/lib/docker/overlay2/92e49cc234e06dbbc2f7bece13baa075c194356ac0faddd57c408298fb0fb5a5/diff",
                "WorkDir": "/var/lib/docker/overlay2/92e49cc234e06dbbc2f7bece13baa075c194356ac0faddd57c408298fb0fb5a5/work"
            },
            "Name": "overlay2"
        },
        "Mounts": [
            {
                "Type": "volume",
                "Name": "992249ee3465559f8e7d4f0b3cf51f3f4f9b133c96e77e236c2c2c012fde006f",
                "Source": "/var/lib/docker/volumes/992249ee3465559f8e7d4f0b3cf51f3f4f9b133c96e77e236c2c2c012fde006f/_data",
                "Destination": "/data",
                "Driver": "local",
                "Mode": "",
                "RW": true,
                "Propagation": ""
            }
        ],
        "Config": {
            "Hostname": "6ffe9b5d09d9",
            "Domainname": "",
            "User": "admin",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "ExposedPorts": {
                "2881/tcp": {},
                "2883/tcp": {}
            },
            "Tty": true,
            "OpenStdin": true,
            "StdinOnce": false,
            "Env": [
                "PATH=/u01/obclient/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
            ],
            "Cmd": [
                "/bin/bash"
            ],
            "Image": "obpilot/oceanbase-ce:latest",
            "Volumes": {
                "/data": {}
            },
            "WorkingDir": "/home/admin",
            "Entrypoint": null,
            "OnBuild": null,
            "Labels": {
                "org.label-schema.build-date": "20201204",
                "org.label-schema.license": "GPLv2",
                "org.label-schema.name": "CentOS Base Image",
                "org.label-schema.schema-version": "1.0",
                "org.label-schema.vendor": "CentOS"
            }
        },
        "NetworkSettings": {
            "Bridge": "",
            "SandboxID": "b30d959abafdf14ac0b99af5636ea41562d102e14ef7f6f0c92d2f6d116929ae",
            "HairpinMode": false,
            "LinkLocalIPv6Address": "",
            "LinkLocalIPv6PrefixLen": 0,
            "Ports": {
                "2881/tcp": null,
                "2883/tcp": null
            },
            "SandboxKey": "/var/run/docker/netns/b30d959abafd",
            "SecondaryIPAddresses": null,
            "SecondaryIPv6Addresses": null,
            "EndpointID": "1215f74443f84217d8253a117e20de0ef8693ef9fab7f4f7e1492257a02e293e",
            "Gateway": "172.17.0.1",
            "GlobalIPv6Address": "",
            "GlobalIPv6PrefixLen": 0,
            "IPAddress": "172.17.0.2",
            "IPPrefixLen": 16,
            "IPv6Gateway": "",
            "MacAddress": "02:42:ac:11:00:02",
            "Networks": {
                "bridge": {
                    "IPAMConfig": null,
                    "Links": null,
                    "Aliases": null,
                    "NetworkID": "c4eba9ce2fdd7d0cfb793e91feb5503a5f60f603be4ddef0bcaa66ba2d93b3d9",
                    "EndpointID": "1215f74443f84217d8253a117e20de0ef8693ef9fab7f4f7e1492257a02e293e",
                    "Gateway": "172.17.0.1",
                    "IPAddress": "172.17.0.2",
                    "IPPrefixLen": 16,
                    "IPv6Gateway": "",
                    "GlobalIPv6Address": "",
                    "GlobalIPv6PrefixLen": 0,
                    "MacAddress": "02:42:ac:11:00:02",
                    "DriverOpts": null
                }
            }
        }
    }
]


5、登录xybdiy容器,启动 OB 集群


5.1 登录xybdiy容器


# 进入当前正在运行的容器实例
[root@docker-oceanbase ~]# docker exec -it 6ffe9b5d09d9 bash
[admin@96661d198a15 ~]$ ob
obclient  obd       objcopy   objdump
# 查看集群详细信息
[admin@6ffe9b5d09d9 ~]$ obd cluster list
+------------------------------------------------------------+
|                        Cluster List                        |
+--------+---------------------------------+-----------------+
| Name   | Configuration Path              | Status (Cached) |
+--------+---------------------------------+-----------------+
| obdemo | /home/admin/.obd/cluster/obdemo | deployed        |
+--------+---------------------------------+-----------------+
[admin@6ffe9b5d09d9 ~]$


5.2 启动 OB 集群


💥报错:启动obdemo数据库报错,提示可用内存大小小于8GB,需要扩大内存。



# 启动集群
[admin@6ffe9b5d09d9 ~]$ 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
# 查看集群状态
[admin@6ffe9b5d09d9 ~]$ obd cluster list
+------------------------------------------------------------+
|                        Cluster List                        |
+--------+---------------------------------+-----------------+
| Name   | Configuration Path              | Status (Cached) |
+--------+---------------------------------+-----------------+
| obdemo | /home/admin/.obd/cluster/obdemo | running         |
+--------+---------------------------------+-----------------+
[admin@6ffe9b5d09d9 ~]$


至此,OB集群启动完成。


6、创建 OB 实例(租户)


# 获取OB集群名称,ROOT密码等相关配置信息
[admin@6ffe9b5d09d9 ~]$ cat /home/admin/.obd/cluster/obdemo/config.yaml
[admin@6ffe9b5d09d9 ~]$ grep -E "root_password|appname|cluster_name" /home/admin/.obd/cluster/obdemo/config.yaml
    # observer cluster name, consistent with obproxy's cluster_name
    appname: obce-single
    root_password: rootPWD123 # root user password, can be empty
    # observer cluster name, consistent with oceanbase-ce's appname
    cluster_name: obce-single
[admin@6ffe9b5d09d9 ~]$
# 登录OB集群后台
[admin@6ffe9b5d09d9 ~]$ obclient -h 127.0.0.1 -u root@sys#obce-single -P2883 -prootPWD123 -c -A oceanbase
Welcome to the OceanBase.  Commands end with ; or \g.
Your MySQL connection id is 3
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 [oceanbase]> show databases;
+--------------------+
| Database           |
+--------------------+
| oceanbase          |
| information_schema |
| mysql              |
| SYS                |
| LBACSYS            |
| ORAAUDITOR         |
| test               |
+--------------------+
7 rows in set (0.003 sec)
MySQL [oceanbase]>
# 参考链接:
https://help.aliyun.com/apsara/enterprise/v_3_14_0_20210519/oceanbase/enterprise-user-guide/alter-resource-unit-1.html
# 修改资源单元配置,最低配置为2个CPU
MySQL [oceanbase]> alter resource unit sys_unit_config min_cpu=2;
Query OK, 0 rows affected (0.009 sec)
# 创建资源单元
MySQL [oceanbase]> CREATE resource unit S4C1G max_cpu=4, min_cpu=4, max_memory='1G', min_memory='1G', max_iops=10000, min_iops=1000, max_session_num=1000000, max_disk_size='1024G';
Query OK, 0 rows affected (0.016 sec)
# 创建资源池
MySQL [oceanbase]> CREATE resource pool my_pool unit = 'S4C1G', unit_num = 1;
Query OK, 0 rows affected (0.019 sec)
# 创建租户xybdiysql
MySQL [oceanbase]> create tenant xybdiysql 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.139 sec)
MySQL [oceanbase]> exit
Bye


7、登录OB 实例


# 使用新创建的租户xybdiysql登陆
[admin@6ffe9b5d09d9 ~]$ obclient -h 127.0.0.1 -uroot@xybdiysql#obce-single -P2883 -c -A test
Welcome to the OceanBase.  Commands end with ; or \g.
Your MySQL connection id is 7
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 [test]> show tenant;
+---------------------+
| Current_tenant_name |
+---------------------+
| xybdiysql           |
+---------------------+
1 row in set (0.002 sec)
MySQL [test]>


8、创建数据库、数据表


# 创建数据库OBS
MySQL [test]> create database OBS;
Query OK, 1 row affected (0.024 sec)
# 查看数据库列表
MySQL [test]> show databases;
+--------------------+
| Database           |
+--------------------+
| oceanbase          |
| information_schema |
| mysql              |
| test               |
| obs                |
+--------------------+
5 rows in set (0.004 sec)
# 进入obs数据库
MySQL [test]> use obs;
Database changed
MySQL [obs]>
# 创建student数据表
MySQL [obs]> create table student
    -> (sno char(9) primary key,
    ->  sname char (20) unique,
    ->  ssex char(2),
    ->  sage smallint,
    ->  sdept char(20)
    -> );
Query OK, 0 rows affected (0.060 sec)
# 查表
MySQL [obs]> show tables;
+---------------+
| Tables_in_obs |
+---------------+
| company       |
| student       |
+---------------+
2 rows in set (0.003 sec)
# 插入数据样例
MySQL [obs]> insert into student(sno,sname,ssex,sage,sdept) values('201215121','李勇','男','20','CS');
Query OK, 1 row affected (0.007 sec)
MySQL [obs]> insert into student(sno,sname,ssex,sage,sdept) values('201215122','刘晨','女','19','CS');
Query OK, 1 row affected (0.007 sec)
MySQL [obs]> insert into student(sno,sname,ssex,sage,sdept) values('201215123','王敏','女','18','MA');
Query OK, 1 row affected (0.003 sec)
MySQL [obs]> insert into student(sno,sname,ssex,sage,sdept) values('201215125','张立','男','19','IS');
Query OK, 1 row affected (0.002 sec)
MySQL [obs]> insert into student(sno,sname,ssex,sage,sdept) values('201215128','王阳','男','22','CS');
Query OK, 1 row affected (0.002 sec)
MySQL [obs]> insert into student(sno,sname,ssex,sage,sdept) values('201215129','张力','男','20','CS');
Query OK, 1 row affected (0.005 sec)
# 查看student表信息
MySQL [obs]> select * from student;
+-----------+--------+------+------+-------+
| sno       | sname  | ssex | sage | sdept |
+-----------+--------+------+------+-------+
| 201215121 | 李勇   | 男   |   20 | CS    |
| 201215122 | 刘晨   | 女   |   19 | CS    |
| 201215123 | 王敏   | 女   |   18 | MA    |
| 201215125 | 张立   | 男   |   19 | IS    |
| 201215128 | 王阳   | 男   |   22 | CS    |
| 201215129 | 张力   | 男   |   20 | CS    |
+-----------+--------+------+------+-------+
6 rows in set (0.006 sec)
# 查看student表结构
MySQL [obs]> describe student;
+-------+-------------+------+-----+---------+-------+
| Field | Type        | Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+-------+
| sno   | char(9)     | NO   | PRI | NULL    |       |
| sname | char(20)    | YES  | UNI | NULL    |       |
| ssex  | char(2)     | YES  |     | NULL    |       |
| sage  | smallint(6) | YES  |     | NULL    |       |
| sdept | char(20)    | YES  |     | NULL    |       |
+-------+-------------+------+-----+---------+-------+
5 rows in set (0.003 sec)
MySQL [obs]>
# 查看创建student表的结构
MySQL [obs]> show create table student;
+---------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table   | Create Table                                                                                                                                                                                                                                                                                                                                                                                                                                     |
+---------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| student | CREATE TABLE `student` (
  `sno` char(9) NOT NULL,
  `sname` char(20) DEFAULT NULL,
  `ssex` char(2) DEFAULT NULL,
  `sage` smallint(6) DEFAULT NULL,
  `sdept` char(20) DEFAULT NULL,
  PRIMARY KEY (`sno`),
  UNIQUE KEY `sname` (`sname`) BLOCK_SIZE 16384 GLOBAL
) DEFAULT CHARSET = utf8mb4 ROW_FORMAT = COMPACT COMPRESSION = 'zstd_1.3.8' REPLICA_NUM = 1 BLOCK_SIZE = 16384 USE_BLOOM_FILTER = FALSE TABLET_SIZE = 134217728 PCTFREE = 0 |
+---------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.007 sec)
MySQL [obs]>



本实验采用OBD工具部署单节点OB集群(一个 observer + 一个 obproxy)


9、参考链接


https://open.oceanbase.com/docs/tutorials/quickstart/V1.0.0/2-2-how-to-quickly-experience-oceanbase


https://open.oceanbase.com/answer/detail?id=508


相关实践学习
如何在云端创建MySQL数据库
开始实验后,系统会自动创建一台自建MySQL的 源数据库 ECS 实例和一台 目标数据库 RDS。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助 &nbsp; &nbsp; 相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
相关文章
|
1月前
|
运维 网络安全 持续交付
IDEA+Docker 远程一键部署项目:技术干货分享
【10月更文挑战第4天】在现代软件开发中,快速、可靠、自动化的部署流程是提升开发效率和运维质量的关键。IDEA(IntelliJ IDEA)作为Java开发者首选的IDE,结合Docker这一轻量级容器化技术,能够实现远程一键部署项目,极大地简化了开发到生产的流程。今天,我将和大家分享这一组合在工作学习中的实际应用和技术干货。
216 3
|
6天前
|
人工智能 API 数据安全/隐私保护
使用 Docker 一键免费部署 63.8k 的私人 ChatGPT 网页应用
NextChat 是一个可以在 GitHub 上一键免费部署的私人 ChatGPT 网页应用,支持 GPT3、GPT4 和 Gemini Pro 模型。该项目在 GitHub 上获得了 63.8k 的 star 数。部署简单,只需拉取 Docker 镜像并运行容器,设置 API Key 后即可使用。此外,NextChat 还提供了预设角色的面具功能,方便用户快速创建对话。
54 22
使用 Docker 一键免费部署 63.8k 的私人 ChatGPT 网页应用
|
17天前
|
SQL 关系型数据库 数据库
国产数据实战之docker部署MyWebSQL数据库管理工具
【10月更文挑战第23天】国产数据实战之docker部署MyWebSQL数据库管理工具
56 4
国产数据实战之docker部署MyWebSQL数据库管理工具
|
7天前
|
运维 开发者 Docker
Docker Compose:简化容器化应用的部署与管理
Docker Compose:简化容器化应用的部署与管理
|
7天前
|
Docker 微服务 容器
使用Docker Compose实现微服务架构的快速部署
使用Docker Compose实现微服务架构的快速部署
17 1
|
1月前
|
Web App开发 前端开发 测试技术
【Docker项目实战】使用docker部署tabler后台模版
【10月更文挑战第10天】使用docker部署tabler后台模版
35 1
【Docker项目实战】使用docker部署tabler后台模版
|
1月前
|
JSON JavaScript 测试技术
【Docker项目实战】使用Docker部署PPTist在线演示文稿应用
【10月更文挑战第9天】使用Docker部署PPTist在线演示文稿应用
36 1
【Docker项目实战】使用Docker部署PPTist在线演示文稿应用
|
1月前
|
消息中间件 编解码 Docker
【Docker项目实战】Docker部署RabbitMQ消息中间件
【10月更文挑战第8天】Docker部署RabbitMQ消息中间件
83 1
【Docker项目实战】Docker部署RabbitMQ消息中间件
|
1月前
|
存储 前端开发 测试技术
【Docker项目实战】使用Docker部署Calcium网页计算器
【10月更文挑战第7天】使用Docker部署Calcium网页计算器
30 1
【Docker项目实战】使用Docker部署Calcium网页计算器
|
1月前
|
存储 测试技术 Linux
【Docker项目实战】使用Docker部署Radicale日历和联系人应用
【10月更文挑战第4天】使用Docker部署Radicale日历和联系人应用
131 2
【Docker项目实战】使用Docker部署Radicale日历和联系人应用