实践练习一(必选):OceanBase Docker 体验 OceanBase3.1.1数据库(离线安装)

实践练习一(必选):OceanBase Docker 体验 OceanBase3.1.1数据库(离线安装)

Docker下体验OceanBase3.1.1数据库

环境准备和检查

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

  • 操作系统检查
[root@localhost ~]# cat /etc/redhat-release
CentOS Linux release 7.9.2009 (Core)
[root@localhost ~]# 
  • 内存
[root@localhost ~]# free -h
              total        used        free      shared  buff/cache   available
Mem:           251G         15G        215G         86M         19G        234G
Swap:           15G          0B         15G

  • 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源,下载软件源配置文件,刷新缓存。

由于我的机器是内网环境,并且有内网固定源地址,所以隐去具体地址。
  
  公网地址可参考社区版教程内容。

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

安装并启动Docker

  • 安装Docker

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

[root@localhost yum.repos.d]# yum -y install docker
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package docker.x86_64 2:1.13.1-208.git7d71120.el7_9 will be installed
--> 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
--> 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
--> Processing Dependency: subscription-manager-rhsm-certificates for package: 2:docker-1.13.1-208.git7d71120.el7_9.x86_64
--> Running transaction check
---> Package docker-client.x86_64 2:1.13.1-208.git7d71120.el7_9 will be installed
---> Package docker-common.x86_64 2:1.13.1-208.git7d71120.el7_9 will be installed
--> Processing Dependency: skopeo-containers >= 1:0.1.26-2 for package: 2:docker-common-1.13.1-208.git7d71120.el7_9.x86_64
--> Processing Dependency: oci-umount >= 2:2.3.3-3 for package: 2:docker-common-1.13.1-208.git7d71120.el7_9.x86_64
--> Processing Dependency: oci-systemd-hook >= 1:0.1.4-9 for package: 2:docker-common-1.13.1-208.git7d71120.el7_9.x86_64
--> Processing Dependency: oci-register-machine >= 1:0-5.13 for package: 2:docker-common-1.13.1-208.git7d71120.el7_9.x86_64
--> Processing Dependency: container-storage-setup >= 0.9.0-1 for package: 2:docker-common-1.13.1-208.git7d71120.el7_9.x86_64
--> Processing Dependency: container-selinux >= 2:2.51-1 for package: 2:docker-common-1.13.1-208.git7d71120.el7_9.x86_64
--> Processing Dependency: atomic-registries for package: 2:docker-common-1.13.1-208.git7d71120.el7_9.x86_64
---> Package subscription-manager-rhsm-certificates.x86_64 0:1.24.50-1.el7.centos will be installed
--> Running transaction check
---> Package atomic-registries.x86_64 1:1.22.1-33.gitb507039.el7_8 will be installed
--> Processing Dependency: python-pytoml for package: 1:atomic-registries-1.22.1-33.gitb507039.el7_8.x86_64
---> Package container-selinux.noarch 2:2.119.2-1.911c772.el7_8 will be installed
---> Package container-storage-setup.noarch 0:0.11.0-2.git5eaf76c.el7 will be installed
---> Package containers-common.x86_64 1:0.1.40-11.el7_8 will be installed
--> Processing Dependency: subscription-manager for package: 1:containers-common-0.1.40-11.el7_8.x86_64
--> Processing Dependency: slirp4netns for package: 1:containers-common-0.1.40-11.el7_8.x86_64
--> Processing Dependency: fuse-overlayfs for package: 1:containers-common-0.1.40-11.el7_8.x86_64
---> Package oci-register-machine.x86_64 1:0-6.git2b44233.el7 will be installed
---> Package oci-systemd-hook.x86_64 1:0.2.0-1.git05e6923.el7_6 will be installed
---> Package oci-umount.x86_64 2:2.5-3.el7 will be installed
--> Running transaction check
---> Package fuse-overlayfs.x86_64 0:0.7.2-6.el7_8 will be installed
--> Processing Dependency: libfuse3.so.3(FUSE_3.2)(64bit) for package: fuse-overlayfs-0.7.2-6.el7_8.x86_64
--> Processing Dependency: libfuse3.so.3(FUSE_3.0)(64bit) for package: fuse-overlayfs-0.7.2-6.el7_8.x86_64
--> Processing Dependency: libfuse3.so.3()(64bit) for package: fuse-overlayfs-0.7.2-6.el7_8.x86_64
---> Package python-pytoml.noarch 0:0.1.14-1.git7dea353.el7 will be installed
---> Package slirp4netns.x86_64 0:0.4.3-4.el7_8 will be installed
---> Package subscription-manager.x86_64 0:1.24.50-1.el7.centos will be installed
--> Processing Dependency: subscription-manager-rhsm = 1.24.50 for package: subscription-manager-1.24.50-1.el7.centos.x86_64
--> Processing Dependency: python-dmidecode >= 3.12.2-2 for package: subscription-manager-1.24.50-1.el7.centos.x86_64
--> Processing Dependency: python-syspurpose for package: subscription-manager-1.24.50-1.el7.centos.x86_64
--> Processing Dependency: python-dateutil for package: subscription-manager-1.24.50-1.el7.centos.x86_64
--> Running transaction check
---> Package fuse3-libs.x86_64 0:3.6.1-4.el7 will be installed
---> Package python-dateutil.noarch 0:1.5-7.el7 will be installed
---> Package python-dmidecode.x86_64 0:3.12.2-4.el7 will be installed
---> Package python-syspurpose.x86_64 0:1.24.50-1.el7.centos will be installed
---> Package subscription-manager-rhsm.x86_64 0:1.24.50-1.el7.centos will be installed
--> 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容器
[root@localhost yum.repos.d]# service docker start
Redirecting to /bin/systemctl start docker.service
  • 查看docker是否启动(active为启动状态)
[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 Wed 2022-01-05 01:49:34 CST; 1min 14s ago
     Docs: http://docs.docker.com
 Main PID: 34137 (dockerd-current)
    Tasks: 59
   CGroup: /system.slice/docker.service
           ├─34137 /usr/bin/dockerd-current --add-runtime docker-runc=/usr/libexec/docker/docker-runc-current --default-runtime=docker-runc --exec-opt na...
           └─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
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值