金融行业实践:OceanBase Docker 体验 OceanBase3.1.1数据库(离线安装)

2024年 5月 7日 58.8k 0

作者简介:张霁:数据库架构师。

环境准备和检查

​ 申请一台物理机,作为宿主机,然后对其进行环境参数检查

  • 操作系统检查
1 [root@localhost ~]# cat /etc/redhat-release
2 CentOS Linux release 7.9.2009 (Core)
3 [root@localhost ~]# 

  • 内存
1 [root@localhost ~]# free -h
2       total    used    free   shared buff/cache available
3 Mem:     251G    15G    215G    86M    19G    234G
4 Swap:     15G     0B    15G
5 

  • CPU
[root@localhost ~]# cat /proc/cpuinfo | grep processor processor   : 0 processor   : 1 processor   : 2 processor   : 3 processor   : 4 processor   : 5 processor   : 6 processor   : 7 processor   : 8 processor   : 9 processor   : 10 processor   : 11 processor   : 12 processor   : 13 processor   : 14 processor   : 15 processor   : 16 processor   : 17 processor   : 18 processor   : 19 processor   : 20 processor   : 21 processor   : 22 processor   : 23 processor   : 24 processor   : 25 processor   : 26 processor   : 27 processor   : 28 processor   : 29 processor   : 30 processor   : 31 processor   : 32 processor   : 33 processor   : 34 processor   : 35 processor   : 36 processor   : 37 processor   : 38 processor   : 39 processor   : 40 processor   : 41 processor   : 42 processor   : 43 processor   : 44 processor   : 45 processor   : 46 processor   : 47 processor   : 48 processor   : 49 processor   : 50 processor   : 51 processor   : 52 processor   : 53 processor   : 54 processor   : 55 processor   : 56 processor   : 57 processor   : 58 processor   : 59 processor   : 60 processor   : 61 processor   : 62 processor   : 63

  • 配置 yum 源,下载软件源配置文件,刷新缓存。

由于我的机器是内网环境,并且有内网固定源地址,所以隐去具体地址。

  

 公网地址可参考社区版教程内容。

1  wget http://xxx/repo/last/<配置文件>
2 yum makecache

安装并启动 Docker

  • 安装 Docker

安装 docker 软件,命令如下,详细可参考 Docker 官网。

1 [root@localhost yum.repos.d]# yum -y install docker
2 Loaded plugins: fastestmirror, langpacks
3 Loading mirror speeds from cached hostfile
4 Resolving Dependencies
5 --> Running transaction check
6 ---> Package docker.x86_64 2:1.13.1-208.git7d71120.el7_9 will be installed
7 --> Processing Dependency: docker-common = 2:1.13.1-208.git7d71120.el7_9 for package: 2:docker-1.13.1-208.git7d71120.el7_9.x86_64
8 --> Processing Dependency: docker-client = 2:1.13.1-208.git7d71120.el7_9 for package: 2:docker-1.13.1-208.git7d71120.el7_9.x86_64
9 --> Processing Dependency: subscription-manager-rhsm-certificates for package: 2:docker-1.13.1-208.git7d71120.el7_9.x86_64
10 --> Running transaction check
11 ---> Package docker-client.x86_64 2:1.13.1-208.git7d71120.el7_9 will be installed
12 ---> Package docker-common.x86_64 2:1.13.1-208.git7d71120.el7_9 will be installed
13 --> Processing Dependency: skopeo-containers >= 1:0.1.26-2 for package: 2:docker-common-1.13.1-208.git7d71120.el7_9.x86_64
14 --> Processing Dependency: oci-umount >= 2:2.3.3-3 for package: 2:docker-common-1.13.1-208.git7d71120.el7_9.x86_64
15 --> Processing Dependency: oci-systemd-hook >= 1:0.1.4-9 for package: 2:docker-common-1.13.1-208.git7d71120.el7_9.x86_64
16 --> Processing Dependency: oci-register-machine >= 1:0-5.13 for package: 2:docker-common-1.13.1-208.git7d71120.el7_9.x86_64
17 --> Processing Dependency: container-storage-setup >= 0.9.0-1 for package: 2:docker-common-1.13.1-208.git7d71120.el7_9.x86_64
18 --> Processing Dependency: container-selinux >= 2:2.51-1 for package: 2:docker-common-1.13.1-208.git7d71120.el7_9.x86_64
19 --> Processing Dependency: atomic-registries for package: 2:docker-common-1.13.1-208.git7d71120.el7_9.x86_64
20 ---> Package subscription-manager-rhsm-certificates.x86_64 0:1.24.50-1.el7.centos will be installed
21 --> Running transaction check
22 ---> Package atomic-registries.x86_64 1:1.22.1-33.gitb507039.el7_8 will be installed
23 --> Processing Dependency: python-pytoml for package: 1:atomic-registries-1.22.1-33.gitb507039.el7_8.x86_64
24 ---> Package container-selinux.noarch 2:2.119.2-1.911c772.el7_8 will be installed
25 ---> Package container-storage-setup.noarch 0:0.11.0-2.git5eaf76c.el7 will be installed
26 ---> Package containers-common.x86_64 1:0.1.40-11.el7_8 will be installed
27 --> Processing Dependency: subscription-manager for package: 1:containers-common-0.1.40-11.el7_8.x86_64
28 --> Processing Dependency: slirp4netns for package: 1:containers-common-0.1.40-11.el7_8.x86_64
29 --> Processing Dependency: fuse-overlayfs for package: 1:containers-common-0.1.40-11.el7_8.x86_64
30 ---> Package oci-register-machine.x86_64 1:0-6.git2b44233.el7 will be installed
31 ---> Package oci-systemd-hook.x86_64 1:0.2.0-1.git05e6923.el7_6 will be installed
32 ---> Package oci-umount.x86_64 2:2.5-3.el7 will be installed
33 --> Running transaction check
34 ---> Package fuse-overlayfs.x86_64 0:0.7.2-6.el7_8 will be installed
35 --> Processing Dependency: libfuse3.so.3(FUSE_3.2)(64bit) for package: fuse-overlayfs-0.7.2-6.el7_8.x86_64
36 --> Processing Dependency: libfuse3.so.3(FUSE_3.0)(64bit) for package: fuse-overlayfs-0.7.2-6.el7_8.x86_64
37 --> Processing Dependency: libfuse3.so.3()(64bit) for package: fuse-overlayfs-0.7.2-6.el7_8.x86_64
38 ---> Package python-pytoml.noarch 0:0.1.14-1.git7dea353.el7 will be installed
39 ---> Package slirp4netns.x86_64 0:0.4.3-4.el7_8 will be installed
40 ---> Package subscription-manager.x86_64 0:1.24.50-1.el7.centos will be installed
41 --> Processing Dependency: subscription-manager-rhsm = 1.24.50 for package: subscription-manager-1.24.50-1.el7.centos.x86_64
42 --> Processing Dependency: python-dmidecode >= 3.12.2-2 for package: subscription-manager-1.24.50-1.el7.centos.x86_64
43 --> Processing Dependency: python-syspurpose for package: subscription-manager-1.24.50-1.el7.centos.x86_64
44 --> Processing Dependency: python-dateutil for package: subscription-manager-1.24.50-1.el7.centos.x86_64
45 --> Running transaction check
46 ---> Package fuse3-libs.x86_64 0:3.6.1-4.el7 will be installed
47 ---> Package python-dateutil.noarch 0:1.5-7.el7 will be installed
48 ---> Package python-dmidecode.x86_64 0:3.12.2-4.el7 will be installed
49 ---> Package python-syspurpose.x86_64 0:1.24.50-1.el7.centos will be installed
50 ---> Package subscription-manager-rhsm.x86_64 0:1.24.50-1.el7.centos will be installed
51 --> Finished Dependency Resolution

Dependencies Resolved

============================================================================================================================================================
 Package                       Arch         Version                    Repository        Size
============================================================================================================================================================
Installing:
 docker                        x86_64        2:1.13.1-208.git7d71120.el7_9         extras7_9         17 M
Installing for dependencies:
 atomic-registries                  x86_64        1:1.22.1-33.gitb507039.el7_8         extras7_9         36 k
 container-selinux                  noarch        2:2.119.2-1.911c772.el7_8           extras7_9         40 k
 container-storage-setup               noarch        0.11.0-2.git5eaf76c.el7            extras7_9         35 k
 containers-common                  x86_64        1:0.1.40-11.el7_8               extras7_9         43 k
 docker-client                    x86_64        2:1.13.1-208.git7d71120.el7_9         extras7_9        3.9 M
 docker-common                    x86_64        2:1.13.1-208.git7d71120.el7_9         extras7_9        101 k
 fuse-overlayfs                    x86_64        0.7.2-6.el7_8                 extras7_9         54 k
 fuse3-libs                      x86_64        3.6.1-4.el7                  extras7_9         82 k
 oci-register-machine                 x86_64        1:0-6.git2b44233.el7             extras7_9        1.1 M
 oci-systemd-hook                   x86_64        1:0.2.0-1.git05e6923.el7_6          extras7_9         34 k
 oci-umount                      x86_64        2:2.5-3.el7                  extras7_9         33 k
 python-dateutil                   noarch        1.5-7.el7                   base7_9          85 k
 python-dmidecode                   x86_64        3.12.2-4.el7                 base7_9          83 k
 python-pytoml                    noarch        0.1.14-1.git7dea353.el7            extras7_9         18 k
 python-syspurpose                  x86_64        1.24.50-1.el7.centos             updates7_9        275 k
 slirp4netns                     x86_64        0.4.3-4.el7_8                 extras7_9         81 k
 subscription-manager                 x86_64        1.24.50-1.el7.centos             updates7_9        1.1 M
 subscription-manager-rhsm              x86_64        1.24.50-1.el7.centos             updates7_9        333 k
 subscription-manager-rhsm-certificates        x86_64        1.24.50-1.el7.centos             updates7_9        237 k

Transaction Summary
============================================================================================================================================================
Install 1 Package (+19 Dependent packages)

Total download size: 25 M
Installed size: 86 M
Downloading packages:
(1/20): container-selinux-2.119.2-1.911c772.el7_8.noarch.rpm                                    | 40 kB 00:00:00   
(2/20): atomic-registries-1.22.1-33.gitb507039.el7_8.x86_64.rpm                                   | 36 kB 00:00:00   
(3/20): containers-common-0.1.40-11.el7_8.x86_64.rpm                                        | 43 kB 00:00:00   
(4/20): container-storage-setup-0.11.0-2.git5eaf76c.el7.noarch.rpm                                 | 35 kB 00:00:00   
(5/20): docker-client-1.13.1-208.git7d71120.el7_9.x86_64.rpm                                    | 3.9 MB 00:00:00   
(6/20): docker-common-1.13.1-208.git7d71120.el7_9.x86_64.rpm                                    | 101 kB 00:00:00   
(7/20): fuse-overlayfs-0.7.2-6.el7_8.x86_64.rpm                                           | 54 kB 00:00:00   
(8/20): fuse3-libs-3.6.1-4.el7.x86_64.rpm                                              | 82 kB 00:00:00   
(9/20): oci-register-machine-0-6.git2b44233.el7.x86_64.rpm                                     | 1.1 MB 00:00:00   
(10/20): oci-systemd-hook-0.2.0-1.git05e6923.el7_6.x86_64.rpm                                    | 34 kB 00:00:00   
(11/20): oci-umount-2.5-3.el7.x86_64.rpm                                              | 33 kB 00:00:00   
(12/20): python-pytoml-0.1.14-1.git7dea353.el7.noarch.rpm                                      | 18 kB 00:00:00   
(13/20): slirp4netns-0.4.3-4.el7_8.x86_64.rpm                                            | 81 kB 00:00:00   
(14/20): docker-1.13.1-208.git7d71120.el7_9.x86_64.rpm                                       | 17 MB 00:00:00   
(15/20): subscription-manager-1.24.50-1.el7.centos.x86_64.rpm                                    | 1.1 MB 00:00:00   
(16/20): python-dmidecode-3.12.2-4.el7.x86_64.rpm                                          | 83 kB 00:00:00   
(17/20): python-dateutil-1.5-7.el7.noarch.rpm                                            | 85 kB 00:00:00   
(18/20): python-syspurpose-1.24.50-1.el7.centos.x86_64.rpm                                     | 275 kB 00:00:00   
(19/20): subscription-manager-rhsm-1.24.50-1.el7.centos.x86_64.rpm                                 | 333 kB 00:00:00   
(20/20): subscription-manager-rhsm-certificates-1.24.50-1.el7.centos.x86_64.rpm                           | 237 kB 00:00:00   
------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                            55 MB/s | 25 MB 00:00:00   
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Warning: RPMDB altered outside of yum.
** Found 11 pre-existing rpmdb problem(s), 'yum check' output follows:
LoadGenerator-11.00.000-1.i386 has missing requires of libX11.so.6
LoadGenerator-11.00.000-1.i386 has missing requires of libicudata.so
LoadGenerator-11.00.000-1.i386 has missing requires of libicudata.so.36
LoadGenerator-11.00.000-1.i386 has missing requires of libicui18n.so.36
LoadGenerator-11.00.000-1.i386 has missing requires of libicutu.so.36
LoadGenerator-11.00.000-1.i386 has missing requires of libicuuc.so.36
LoadGenerator-11.00.000-1.i386 has missing requires of libncurses.so.5
LoadGenerator-11.00.000-1.i386 has missing requires of libstdc++.so.6
LoadGenerator-11.00.000-1.i386 has missing requires of libstdc++.so.6(CXXABI_1.3)
LoadGenerator-11.00.000-1.i386 has missing requires of libstdc++.so.6(GLIBCXX_3.4)
LoadGenerator-11.00.000-1.i386 has missing requires of libz.so.1
 Installing : python-dateutil-1.5-7.el7.noarch                                                    1/20 
 Installing : subscription-manager-rhsm-certificates-1.24.50-1.el7.centos.x86_64                                   2/20 
 Installing : subscription-manager-rhsm-1.24.50-1.el7.centos.x86_64                                         3/20 
 Installing : slirp4netns-0.4.3-4.el7_8.x86_64                                                    4/20 
 Installing : python-dmidecode-3.12.2-4.el7.x86_64                                                  5/20 
 Installing : python-pytoml-0.1.14-1.git7dea353.el7.noarch                                              6/20 
 Installing : 1:atomic-registries-1.22.1-33.gitb507039.el7_8.x86_64                                         7/20 
 Installing : 1:oci-register-machine-0-6.git2b44233.el7.x86_64                                            8/20 
 Installing : container-storage-setup-0.11.0-2.git5eaf76c.el7.noarch                                         9/20 
 Installing : 2:oci-umount-2.5-3.el7.x86_64                                                     10/20 
 Installing : 2:container-selinux-2.119.2-1.911c772.el7_8.noarch                                          11/20 
 Installing : 1:oci-systemd-hook-0.2.0-1.git05e6923.el7_6.x86_64                                          12/20 
 Installing : python-syspurpose-1.24.50-1.el7.centos.x86_64                                             13/20 
 Installing : subscription-manager-1.24.50-1.el7.centos.x86_64                                           14/20 
 Installing : fuse3-libs-3.6.1-4.el7.x86_64                                                     15/20 
 Installing : fuse-overlayfs-0.7.2-6.el7_8.x86_64                                                  16/20 
 Installing : 1:containers-common-0.1.40-11.el7_8.x86_64                                              17/20 
 Installing : 2:docker-common-1.13.1-208.git7d71120.el7_9.x86_64                                          18/20 
 Installing : 2:docker-client-1.13.1-208.git7d71120.el7_9.x86_64                                          19/20 
 Installing : 2:docker-1.13.1-208.git7d71120.el7_9.x86_64                                              20/20 
 Verifying : 2:docker-common-1.13.1-208.git7d71120.el7_9.x86_64                                           1/20 
 Verifying : 2:docker-1.13.1-208.git7d71120.el7_9.x86_64                                              2/20 
 Verifying : subscription-manager-rhsm-certificates-1.24.50-1.el7.centos.x86_64                                   3/20 
 Verifying : 1:atomic-registries-1.22.1-33.gitb507039.el7_8.x86_64                                         4/20 
 Verifying : fuse3-libs-3.6.1-4.el7.x86_64                                                     5/20 
 Verifying : fuse-overlayfs-0.7.2-6.el7_8.x86_64                                                  6/20 
 Verifying : python-syspurpose-1.24.50-1.el7.centos.x86_64                                             7/20 
 Verifying : 1:oci-systemd-hook-0.2.0-1.git05e6923.el7_6.x86_64                                           8/20 
 Verifying : subscription-manager-1.24.50-1.el7.centos.x86_64                                            9/20 
 Verifying : 2:docker-client-1.13.1-208.git7d71120.el7_9.x86_64                                          10/20 
 Verifying : 2:container-selinux-2.119.2-1.911c772.el7_8.noarch                                          11/20 
 Verifying : 2:oci-umount-2.5-3.el7.x86_64                                                     12/20 
 Verifying : container-storage-setup-0.11.0-2.git5eaf76c.el7.noarch                                        13/20 
 Verifying : 1:oci-register-machine-0-6.git2b44233.el7.x86_64                                           14/20 
 Verifying : python-pytoml-0.1.14-1.git7dea353.el7.noarch                                             15/20 
 Verifying : 1:containers-common-0.1.40-11.el7_8.x86_64                                              16/20 
 Verifying : python-dmidecode-3.12.2-4.el7.x86_64                                                 17/20 
 Verifying : slirp4netns-0.4.3-4.el7_8.x86_64                                                   18/20 
 Verifying : subscription-manager-rhsm-1.24.50-1.el7.centos.x86_64                                         19/20 
 Verifying : python-dateutil-1.5-7.el7.noarch                                                   20/20 

Installed:
 docker.x86_64 2:1.13.1-208.git7d71120.el7_9                                                        

Dependency Installed:
 atomic-registries.x86_64 1:1.22.1-33.gitb507039.el7_8               container-selinux.noarch 2:2.119.2-1.911c772.el7_8          
 container-storage-setup.noarch 0:0.11.0-2.git5eaf76c.el7              containers-common.x86_64 1:0.1.40-11.el7_8              
 docker-client.x86_64 2:1.13.1-208.git7d71120.el7_9                 docker-common.x86_64 2:1.13.1-208.git7d71120.el7_9          
 fuse-overlayfs.x86_64 0:0.7.2-6.el7_8                       fuse3-libs.x86_64 0:3.6.1-4.el7                    
 oci-register-machine.x86_64 1:0-6.git2b44233.el7                  oci-systemd-hook.x86_64 1:0.2.0-1.git05e6923.el7_6          
 oci-umount.x86_64 2:2.5-3.el7                           python-dateutil.noarch 0:1.5-7.el7                  
 python-dmidecode.x86_64 0:3.12.2-4.el7                       python-pytoml.noarch 0:0.1.14-1.git7dea353.el7            
 python-syspurpose.x86_64 0:1.24.50-1.el7.centos                  slirp4netns.x86_64 0:0.4.3-4.el7_8                  
 subscription-manager.x86_64 0:1.24.50-1.el7.centos                 subscription-manager-rhsm.x86_64 0:1.24.50-1.el7.centos        
 subscription-manager-rhsm-certificates.x86_64 0:1.24.50-1.el7.centos        

Complete!



  • 查看docker安装列表
[root@localhost yum.repos.d]# yum list installed | grep docker docker.x86_64              2:1.13.1-208.git7d71120.el7_9 docker-client.x86_64           2:1.13.1-208.git7d71120.el7_9 docker-common.x86_64           2:1.13.1-208.git7d71120.el7_9

  • 启动docker容器

1 [root@localhost yum.repos.d]# service docker start
2 Redirecting to /bin/systemctl start docker.service

  • 查看docker是否启动(active为启动状态)
1 [root@localhost yum.repos.d]# service docker status
2 Redirecting to /bin/systemctl status docker.service
3  docker.service - Docker Application Container Engine
4   Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
5   Active: active (running) since Wed 2022-01-05 01:49:34 CST; 1min 14s ago
6    Docs: http://docs.docker.com
7  Main PID: 34137 (dockerd-current)
8   Tasks: 59
9   CGroup: /system.slice/docker.service
10      ├─34137 /usr/bin/dockerd-current --add-runtime docker-runc=/usr/libexec/docker/docker-runc-current --default-runtime=docker-runc --exec-opt na...
11      └─34155 /usr/bin/docker-containerd-current -l unix:///var/run/docker/libcontainerd/docker-containerd.sock --metrics-interval=0 --start-timeout...

Jan 05 01:49:33 localhost.localdomain dockerd-current[34137]: time="2022-01-05T01:49:33.449038142+08:00" level=info msg="libcontainerd: new contai... 34155"
Jan 05 01:49:34 localhost.localdomain dockerd-current[34137]: time="2022-01-05T01:49:34.523347225+08:00" level=info msg="Graph migration to conten...econds"
Jan 05 01:49:34 localhost.localdomain dockerd-current[34137]: time="2022-01-05T01:49:34.524270388+08:00" level=info msg="Loading containers: start."
Jan 05 01:49:34 localhost.localdomain dockerd-current[34137]: time="2022-01-05T01:49:34.537891563+08:00" level=info msg="Firewalld running: false"
Jan 05 01:49:34 localhost.localdomain dockerd-current[34137]: time="2022-01-05T01:49:34.579153497+08:00" level=info msg="Default bridge (docker0) ...ddress"
Jan 05 01:49:34 localhost.localdomain dockerd-current[34137]: time="2022-01-05T01:49:34.605121866+08:00" level=info msg="Loading containers: done."
Jan 05 01:49:34 localhost.localdomain dockerd-current[34137]: time="2022-01-05T01:49:34.624145990+08:00" level=info msg="Daemon has completed init...zation"
Jan 05 01:49:34 localhost.localdomain dockerd-current[34137]: time="2022-01-05T01:49:34.624174900+08:00" level=info msg="Docker daemon" commit="7d...=1.13.1
Jan 05 01:49:34 localhost.localdomain dockerd-current[34137]: time="2022-01-05T01:49:34.631729974+08:00" level=info msg="API listen on /var/run/docker.sock"
Jan 05 01:49:34 localhost.localdomain systemd[1]: Started Docker Application Container Engine.
Hint: Some lines were ellipsized, use -l to show in full.

安装并运行 oceanbase 集群

下载 OcenaBase 镜像

由于是内网环境,无法连接互联网下载,需要提前下载好 oceanbase-ce 的镜像。

我使用的是社区其他人提供的镜像文件,通过百度网盘里下载。

地址如下:

链接: https://pan.baidu.com/s/1qAcAB17OpAVlDpIjzJ2bfA

提取码: wzc8

原文地址:https://open.oceanbase.com/blog/8600168

下载后,传到内网服务器上。

解压镜像:

[root@localhost 3.1.1]# docker load -i oceanbase-ce.gz 2653d992f4ef: Loading layer [==================================================>] 216.5 MB/216.5 MB 20d9ae45c7f2: Loading layer [==================================================>] 6.144 kB/6.144 kB 200fd68be2b9: Loading layer [==================================================>] 2.048 GB/2.048 GB 5f70bf18a086: Loading layer [==================================================>] 1.024 kB/1.024 kB ade784765441: Loading layer [==================================================>] 7.168 kB/7.168 kB 30e19cf8784f: Loading layer [==================================================>] 5.12 kB/5.12 kB Loaded image: docker.io/obpilot/oceanbase-ce:latest

查看镜像:

[root@localhost 3.1.1]# docker images REPOSITORY           TAG        IMAGE ID      CREATED      SIZE docker.io/obpilot/oceanbase-ce latest       67eaef2b40a4    7 weeks ago    2.25 GB

运行容器:

[root@localhost 3.1.1]# docker run -itd -m 40G -p 2881:2881 -p 2883:2883 --name oceanbase-ce obpilot/oceanbase-ce:latest 20f5808b3f10ad1df38a56462c37fc3e75ba1b5366185b5896ba8a5239868655

查看容器是否运行:

[root@localhost 3.1.1]# docker ps CONTAINER ID    IMAGE            COMMAND      CREATED      STATUS       PORTS                      NAMES 20f5808b3f10    obpilot/oceanbase-ce:latest "/bin/bash"    22 seconds ago   Up 22 seconds   0.0.0.0:2881->2881/tcp, 0.0.0.0:2883->2883/tcp oceanbase-ce

连入 oceanbase-ce 容器:

[root@localhost 3.1.1]# docker exec -it oceanbase-ce bash  [admin@20f5808b3f10 ~]$

获取集群信息

[admin@20f5808b3f10 ~]$ obd cluster list +------------------------------------------------------------+ |            Cluster List            | +--------+---------------------------------+-----------------+ | Name | Configuration Path       | Status (Cached) | +--------+---------------------------------+-----------------+ | obdemo | /home/admin/.obd/cluster/obdemo | deployed    | +--------+---------------------------------+-----------------+

启动集群

[admin@20f5808b3f10 ~]$ obd cluster start obdemo Get local repositories and plugins ok Open ssh connection ok Cluster param config check ok Check before start observer ok 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@20f5808b3f10 ~]$ obd cluster display obdemo Get local repositories and plugins ok Open ssh connection ok Cluster status check ok Connect to observer ok Wait for observer init ok +---------------------------------------------+ |         observer         | +-----------+---------+------+-------+--------+ | ip    | version | port | zone | status | +-----------+---------+------+-------+--------+ | 127.0.0.1 | 3.1.1 | 2881 | zone1 | active | +-----------+---------+------+-------+--------+   Connect to obproxy ok +---------------------------------------------+ |         obproxy         | +-----------+------+-----------------+--------+ | ip    | port | prometheus_port | status | +-----------+------+-----------------+--------+ | 127.0.0.1 | 2883 | 2884      | active | +-----------+------+-----------------+--------+

连接 OceanBase

  • 使用 observer 2881 端口登录

[admin@20f5808b3f10 ~]$ obclient -h127.1 -uroot@sys -P2881 -prootPWD123 -c -A  Welcome to the OceanBase. Commands end with ; or \g. Your MySQL connection id is 3221487645 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.   MySQL [(none)]> show parameters like 'cluster'; +-------+----------+-----------+----------+---------+-----------+-------------+---------------------+----------+---------+---------+-------------------+ | zone | svr_type | svr_ip  | svr_port | name  | data_type | value   | info        | section | scope | source | edit_level    | +-------+----------+-----------+----------+---------+-----------+-------------+---------------------+----------+---------+---------+-------------------+ | zone1 | observer | 127.0.0.1 |  2882 | cluster | NULL   | obce-single | Name of the cluster | OBSERVER | CLUSTER | DEFAULT | DYNAMIC_EFFECTIVE | +-------+----------+-----------+----------+---------+-----------+-------------+---------------------+----------+---------+---------+-------------------+ 1 row in set (0.006 sec)

使用 obproxy 2883 端口登录

 [admin@20f5808b3f10 ~]$ obclient -h127.1 -uroot@sys#obce-single -P2883 -prootPWD1
 Welcome to the OceanBase. Commands end with ; or \g.
 Your MySQL connection id is 9
 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 parameters like 'cluster';
+-------+----------+-----------+----------+---------+-----------+-------------+---------------------+----------+---------+---------+-------------------+
 | zone | svr_type | svr_ip  | svr_port | name  | data_type | value   | info        | section | scope | source | edit_level    |
 +-------+----------+-----------+----------+---------+-----------+-------------+---------------------+----------+---------+---------+-------------------+
 | zone1 | observer | 127.0.0.1 |  2882 | cluster | NULL   | obce-single | Name of the cluster | OBSERVER | CLUSTER | DEFAULT | DYNAMIC_EFFECTIVE |
 +-------+----------+-----------+----------+---------+-----------+-------------+---------------------+----------+---------+---------+-------------------+
 1 row in set (0.002 sec)

创建 MySQL 租户

创建租户

创建资源规格

MySQL [oceanbase]> CREATE resource unit u1 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='100G'; 
Query OK, 0 rows affected (0.006 sec)

创建资源池

MySQL [oceanbase]> CREATE resource pool my_pool unit = 'u1', unit_num = 1;
Query OK, 0 rows affected (0.009 sec)

创建租户

MySQL [oceanbase]> create tenant obmysql resource_pool_list=('my_pool'), primary_zone='zone1',comment 'mysql tenant/instance', charset='utf8' set ob_tcp_invited_nodes='%', ob_compatibility_mode='mysql'; 
Query OK, 0 rows affected (0.430 sec)

创建业务数据库

MySQL [oceanbase]> create database testdb1 ;
Query OK, 1 row affected (0.016 sec)

创建业务用户

MySQL [oceanbase]> create user testuser1@'%' identified by 'testuser1' ;
Query OK, 0 rows affected (0.012 sec)
MySQL [oceanbase]> grant all privileges on *.* to testuser1@'%';
Query OK, 0 rows affected (0.017 sec)

创建业务表

MySQL [oceanbase]> use testdb1;
Database changed
MySQL [testdb1]> CREATE TABLE A (
  -> INTERNAL_KEY BIGINT NOT NULL ,
  -> BASE_ACCT_NO VARCHAR(50) DEFAULT NULL ,
  -> CCY VARCHAR(3) DEFAULT NULL ,
  -> ACCT_SEQ_NO VARCHAR(8) DEFAULT NULL ,
  -> CARD_NO VARCHAR(50) DEFAULT NULL ,
  -> CLIENT_NO VARCHAR(20) DEFAULT NULL ,
  -> ACCT_STATUS VARCHAR(1) DEFAULT NULL ,
  -> BAL_TYPE VARCHAR(2) DEFAULT NULL ,
  -> TERM_TYPE VARCHAR(1) DEFAULT NULL ,
  -> AUTO_RENEW_ROLLOVER VARCHAR(1) DEFAULT NULL ,
  -> LAST_CHANGE_USER_ID VARCHAR(30) DEFAULT NULL ,
  -> LAST_CHANGE_DATE VARCHAR(8) DEFAULT NULL ,
  -> CMISLOAN_NO VARCHAR(50) DEFAULT NULL ,
  -> ACCT_TYPE VARCHAR(2) DEFAULT NULL,
  -> PRIMARY KEY (INTERNAL_KEY)
  -> );
Query OK, 0 rows affected (0.045 sec)

操作业务表

MySQL [testdb1]>insert into a values (1,'1','CNY','1','1','1','A','T','Q','W','1','20210104','1','I');
Query OK, 1 row affected (0.007 sec)

退出

MySQL [testdb1]> exit
Bye

————————————————

附录:

练习题:

实践练习一(必选):OceanBase Docker 体验 

实践练习二(必选):手动部署 OceanBase 集群 

实践练习三(可选):使用OBD 部署一个 三副本OceanBase 集群 

实践练习四(必选):迁移 MySQL 数据到 OceanBase 集群 

实践练习五(可选):对 OceanBase 做性能测试 

实践练习六(必选):查看 OceanBase 执行计划 

还没交作业的小伙伴要抓紧啦!

可以免费带走 OBCP 考试券喔~~

方法一:完成四道必选练习

方法二:任意一道练习题 ➕ 结业考试超过80分

已经有很多同学抢先答题了,

加入钉钉群(群号3582 5151),和大家一起学习、交流~~

进群二维码:

金融行业实践:OceanBase Docker 体验 OceanBase3.1.1数据库(离线安装)-1

相关文章

Oracle如何使用授予和撤销权限的语法和示例
Awesome Project: 探索 MatrixOrigin 云原生分布式数据库
下载丨66页PDF,云和恩墨技术通讯(2024年7月刊)
社区版oceanbase安装
Oracle 导出CSV工具-sqluldr2
ETL数据集成丨快速将MySQL数据迁移至Doris数据库

发布评论