镜像下载、域名解析、时间同步请点击 阿里云开源镜像站

一、OceanBase介绍

OceanBase是由蚂蚁集团完全自主研发的金融级分布式关系数据库,始创于2010年。OceanBase具有数据强一致、高可用、高性能、在线扩展、高度兼容SQL标准和主流关系数据库、低成本等特点。

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

二、OceanBase安装操作

本实验基于CentOS 7.9系统进行演示操作

  1. [root@oceanbase ~]# cat /etc/redhat-release
  2. CentOS Linux release 7.9.2009 (Core)

安装前期准备

本实验采用单机模式 的部署方式,在同一台机器上安装服务端和客户端进行测试。

需要内存大小8GB 以上;(本实验内存大小 10 GB)

磁盘空间大小65GB以上;(本实验磁盘大小 95 GB)

1、通过 YUM 软件源下载并安装 OBD

执行以下三种命令。

  1. # yum install -y yum-utils
  2. # yum-config-manager --add-repo https://mirrors.aliyun.com/oceanbase/OceanBase.repo
  3. # yum install -y ob-deploy
  1. [root@obd ~]# yum install -y yum-utils
  2. Loaded plugins: fastestmirror
  3. Loading mirror speeds from cached hostfile
  4. Package yum-utils-1.1.31-54.el7_8.noarch already installed and latest version
  5. Nothing to do
  6. [root@obd ~]# yum-config-manager --add-repo https://mirrors.aliyun.com/oceanbase/OceanBase.repo
  7. Loaded plugins: fastestmirror
  8. adding repo from: https://mirrors.aliyun.com/oceanbase/OceanBase.repo
  9. grabbing file https://mirrors.aliyun.com/oceanbase/OceanBase.repo to /etc/yum.repos.d/OceanBase.repo
  10. repo saved to /etc/yum.repos.d/OceanBase.repo
  11. [root@obd ~]# yum install -y ob-deploy
  12. Loaded plugins: fastestmirror
  13. Loading mirror speeds from cached hostfile
  14. Package ob-deploy-1.2.1-9.el7.x86_64 already installed and latest version
  15. Nothing to do
  16. [root@obd ~]#

或者

  1. 离线安装 OBD
  2. 1. 下载 OBD 离线 RPM 安装包。
  3. 2. 运行以下命令安装 OBD
  4. # yum install -y ob-deploy-1.0.0-1.el7.x86_64.rpm
  5. # source /etc/profile.d/obd.sh

2、下载 OceanBase 数据库配置文件模板

从 Github 上下载对应的配置文件模板。本实验采用的是mini-local-example.yaml 配置文件

Gitee下载链接:

example/mini-local-example.yaml · OceanBase/obdeploy - Gitee.com

  1. oceanbase-ce:
  2. servers:
  3. # Please don't use hostname, only IP can be supported
  4. - 127.0.0.1
  5. global:
  6. # The working directory for OceanBase Database. OceanBase Database is started under this directory. This is a required field.
  7. home_path: /xyb/observer
  8. # The directory for data storage. The default value is $home_path/store.
  9. # data_dir: /data
  10. # The directory for clog, ilog, and slog. The default value is the same as the data_dir value.
  11. # redo_dir: /redo
  12. # Please set devname as the network adaptor's name whose ip is in the setting of severs.
  13. # if set severs as "127.0.0.1", please set devname as "lo"
  14. # if current ip is 192.168.1.10, and the ip's network adaptor's name is "eth0", please use "eth0"
  15. devname: lo
  16. mysql_port: 2881 # External port for OceanBase Database. The default value is 2881. DO NOT change this value after the cluster is started.
  17. rpc_port: 2882 # Internal port for OceanBase Database. The default value is 2882. DO NOT change this value after the cluster is started.
  18. zone: zone1
  19. cluster_id: 1
  20. # please set memory limit to a suitable value which is matching resource.
  21. memory_limit: 8G # The maximum running memory for an observer
  22. system_memory: 4G # The reserved system memory. system_memory is reserved for general tenants. The default value is 30G.
  23. stack_size: 512K
  24. cpu_count: 16
  25. cache_wash_threshold: 1G
  26. __min_full_resource_pool_memory: 268435456
  27. workers_per_cpu_quota: 10
  28. schema_history_expire_time: 1d
  29. # The value of net_thread_count had better be same as cpu's core number.
  30. net_thread_count: 4
  31. sys_bkgd_migration_retry_num: 3
  32. minor_freeze_times: 10
  33. enable_separate_sys_clog: 0
  34. enable_merge_by_turn: FALSE
  35. datafile_disk_percentage: 20 # The percentage of the data_dir space to the total disk space. This value takes effect only when datafile_size is 0. The default value is 90.
  36. syslog_level: INFO # System log level. The default value is INFO.
  37. enable_syslog_wf: false # Print system logs whose levels are higher than WARNING to a separate log file. The default value is true.
  38. enable_syslog_recycle: true # Enable auto system log recycling or not. The default value is false.
  39. max_syslog_file_count: 4 # The maximum number of reserved log files before enabling auto recycling. The default value is 0.
  40. # root_password: # root user password, can be empty

3、部署 OceanBase 数据库

运行以下命令部署集群

  1. obd cluster deploy <deploy_name> -c <deploy_config_file> -A
  1. [root@obs ~]# obd cluster deploy xybobs -c mini-local-example.yaml
  2. Update OceanBase-community-stable-el7 ok
  3. Update OceanBase-development-kit-el7 ok
  4. Download oceanbase-ce-3.1.2-10000392021123010.el7.x86_64.rpm (46.45 M): 100% [##############] Time: 0:00:08 5.74 MB/s
  5. Package oceanbase-ce-3.1.2 is available.
  6. install oceanbase-ce-3.1.2 for local ok
  7. +-------------------------------------------------------------------------------------------+
  8. | Packages |
  9. +--------------+---------+-----------------------+------------------------------------------+
  10. | Repository | Version | Release | Md5 |
  11. +--------------+---------+-----------------------+------------------------------------------+
  12. | oceanbase-ce | 3.1.2 | 10000392021123010.el7 | 7fafba0fac1e90cbd1b5b7ae5fa129b64dc63aed |
  13. +--------------+---------+-----------------------+------------------------------------------+
  14. Repository integrity check ok
  15. Parameter check ok
  16. Open ssh connection ok
  17. Remote oceanbase-ce-3.1.2-7fafba0fac1e90cbd1b5b7ae5fa129b64dc63aed repository install ok
  18. Remote oceanbase-ce-3.1.2-7fafba0fac1e90cbd1b5b7ae5fa129b64dc63aed repository lib check !!
  19. [WARN] 127.0.0.1 oceanbase-ce-3.1.2-7fafba0fac1e90cbd1b5b7ae5fa129b64dc63aed require: libmariadb.so.3
  20. Try to get lib-repository
  21. Download oceanbase-ce-libs-3.1.2-10000392021123010.el7.x86_64.rpm (155.22 K): 100% [########] Time: 0:00:00 6.76 MB/s
  22. Package oceanbase-ce-libs-3.1.2 is available.
  23. install oceanbase-ce-libs-3.1.2 for local ok
  24. Use oceanbase-ce-libs-3.1.2-94fff0ab31de053051dba66039e3185fa390cad5 for oceanbase-ce-3.1.2-7fafba0fac1e90cbd1b5b7ae5fa129b64dc63aed
  25. Remote oceanbase-ce-libs-3.1.2-94fff0ab31de053051dba66039e3185fa390cad5 repository install ok
  26. Remote oceanbase-ce-3.1.2-7fafba0fac1e90cbd1b5b7ae5fa129b64dc63aed repository lib check ok
  27. Cluster status check ok
  28. Initializes observer work home ok
  29. xybobs deployed
  30. [root@obs ~]#

4、启动 OceanBase 数据库

  1. [root@obs ~]# obd cluster start xybobs
  2. Get local repositories and plugins ok
  3. Open ssh connection ok
  4. Load cluster param plugin ok
  5. Check before start observer ok
  6. [WARN] (127.0.0.1) clog and data use the same disk (/)
  7. Start observer ok
  8. observer program health check ok
  9. Connect to observer ok
  10. Initialize cluster
  11. Cluster bootstrap ok
  12. Wait for observer init ok
  13. +---------------------------------------------+
  14. | observer |
  15. +-----------+---------+------+-------+--------+
  16. | ip | version | port | zone | status |
  17. +-----------+---------+------+-------+--------+
  18. | 127.0.0.1 | 3.1.2 | 2881 | zone1 | active |
  19. +-----------+---------+------+-------+--------+
  20. xybobs running
  21. [root@obs ~]#

5、连接OceanBase数据库

安装OceanBase数据库客户端 OBClient

  1. # yum install -y obclient
  1. [root@obs ~]# yum install -y obclient
  2. Loaded plugins: fastestmirror
  3. Loading mirror speeds from cached hostfile
  4. Resolving Dependencies
  5. --> Running transaction check
  6. ---> Package obclient.x86_64 0:2.0.0-2.el7 will be installed
  7. --> Processing Dependency: libobclient >= 2.0.0 for package: obclient-2.0.0-2.el7.x86_64
  8. --> Running transaction check
  9. ---> Package libobclient.x86_64 0:2.0.0-2.el7 will be installed
  10. --> Finished Dependency Resolution
  11. Dependencies Resolved
  12. ======================================================================================================================================
  13. Package Arch Version Repository Size
  14. ======================================================================================================================================
  15. Installing:
  16. obclient x86_64 2.0.0-2.el7 oceanbase.community.stable 40 M
  17. Installing for dependencies:
  18. libobclient x86_64 2.0.0-2.el7 oceanbase.community.stable 643 k
  19. Transaction Summary
  20. ======================================================================================================================================
  21. Install 1 Package (+1 Dependent package)
  22. Total download size: 41 M
  23. Installed size: 188 M
  24. Downloading packages:
  25. (1/2): libobclient-2.0.0-2.el7.x86_64.rpm | 643 kB 00:00:00
  26. (2/2): obclient-2.0.0-2.el7.x86_64.rpm | 40 MB 00:00:06
  27. --------------------------------------------------------------------------------------------------------------------------------------
  28. Total 6.6 MB/s | 41 MB 00:00:06
  29. Running transaction check
  30. Running transaction test
  31. Transaction test succeeded
  32. Running transaction
  33. Installing : libobclient-2.0.0-2.el7.x86_64 1/2
  34. Installing : obclient-2.0.0-2.el7.x86_64 2/2
  35. Verifying : libobclient-2.0.0-2.el7.x86_64 1/2
  36. Verifying : obclient-2.0.0-2.el7.x86_64 2/2
  37. Installed:
  38. obclient.x86_64 0:2.0.0-2.el7
  39. Dependency Installed:
  40. libobclient.x86_64 0:2.0.0-2.el7
  41. Complete!
  42. [root@obs ~]#

使用Root用户登录 OceanBase 数据库

  1. [root@obs ~]# obclient -h192.168.200.88 -P2881 -uroot
  2. Welcome to the OceanBase. Commands end with ; or \g.
  3. Your MySQL connection id is 3221487658
  4. Server version: 5.7.25 OceanBase 3.1.2 (r10000392021123010-d4ace121deae5b81d8f0b40afbc4c02705b7fc1d) (Built Dec 30 2021 02:47:29)
  5. Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
  6. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  7. MySQL [(none)]> show databases;
  8. +--------------------+
  9. | Database |
  10. +--------------------+
  11. | oceanbase |
  12. | information_schema |
  13. | mysql |
  14. | SYS |
  15. | LBACSYS |
  16. | ORAAUDITOR |
  17. | test |
  18. +--------------------+
  19. 7 rows in set (0.007 sec)
  20. MySQL [(none)]> exit
  21. Bye

切换使用obs用户登录 OceanBase 数据库

  1. [root@obs ~]# su obs
  2. [obs@obs root]$ obclient -h192.168.200.88 -P2881 -uroot
  3. Welcome to the OceanBase. Commands end with ; or \g.
  4. Your MySQL connection id is 3221487837
  5. Server version: 5.7.25 OceanBase 3.1.2 (r10000392021123010-d4ace121deae5b81d8f0b40afbc4c02705b7fc1d) (Built Dec 30 2021 02:47:29)
  6. Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
  7. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  8. # 查看数据库
  9. MySQL [(none)]> show databases;
  10. +--------------------+
  11. | Database |
  12. +--------------------+
  13. | oceanbase |
  14. | information_schema |
  15. | mysql |
  16. | SYS |
  17. | LBACSYS |
  18. | ORAAUDITOR |
  19. | test |
  20. +--------------------+
  21. 7 rows in set (0.002 sec)
  22. MySQL [(none)]>

6、OceanBase 数据库 常用命令

  1. # obs帮助命令
  2. [root@obs ~]# obd -h
  3. Usage: obd <command> [options]
  4. Available commands:
  5. cluster Deploy and manage a cluster.
  6. mirror Manage a component repository for OBD.
  7. repo Manage local repository for OBD.
  8. test Run test for a running deployment.
  9. update Update OBD.
  10. Options:
  11. --version show program's version number and exit
  12. -h, --help Show help and exit.
  13. -v, --verbose Activate verbose output.
  14. # 查看obd管理的集群列表
  15. [root@obs ~]# obd cluster list
  16. +------------------------------------------------------+
  17. | Cluster List |
  18. +--------+---------------------------+-----------------+
  19. | Name | Configuration Path | Status (Cached) |
  20. +--------+---------------------------+-----------------+
  21. | xybobs | /root/.obd/cluster/xybobs | running |
  22. +--------+---------------------------+-----------------+
  23. # 查看集群状态
  24. [root@obs ~]# obd cluster display xybobs
  25. Get local repositories and plugins ok
  26. Open ssh connection ok
  27. Cluster status check ok
  28. Connect to observer ok
  29. Wait for observer init ok
  30. +---------------------------------------------+
  31. | observer |
  32. +-----------+---------+------+-------+--------+
  33. | ip | version | port | zone | status |
  34. +-----------+---------+------+-------+--------+
  35. | 127.0.0.1 | 3.1.2 | 2881 | zone1 | active |
  36. +-----------+---------+------+-------+--------+

三、安装过程中的报错信息

磁盘空间不足,至少所需65G磁盘空间大小。

  1. [root@obs ~]# vim mini-local-example.yaml
  2. [root@obs ~]# obd cluster autodeploy xyb -c mini-local-example.yaml
  3. Update OceanBase-community-stable-el7 ok
  4. Update OceanBase-development-kit-el7 ok
  5. Download oceanbase-ce-3.1.2-10000392021123010.el7.x86_64.rpm (46.45 M): 100% [####] Time: 0:00:06 7.88 MB/s
  6. Package oceanbase-ce-3.1.2 is available.
  7. install oceanbase-ce-3.1.2 for local ok
  8. Cluster param config check ok
  9. Open ssh connection ok
  10. Generate observer configuration x
  11. [ERROR] (127.0.0.1) / not enough disk space. (Avail: 14.9G, Need: 64.1G). Use `redo_dir` to set other disk for clog

网卡名称错误❌,本机安装使用的IP是127.0.0.1,对应的网络名称是lo。销毁集群后重新部署。

  1. [root@obs ~]# obd cluster start xybobs
  2. Get local repositories and plugins ok
  3. Open ssh connection ok
  4. Load cluster param plugin ok
  5. Check before start observer x
  6. [WARN] (127.0.0.1) clog and data use the same disk (/)
  7. [ERROR] 127.0.0.1 ens32 fail to ping 127.0.0.1. Please check configuration `devname`
  8. [root@obs ~]#

提示所需的系统内存不足,需要提升内存大小。(推荐内存大小在16GB以上)

  1. [root@obs ~]# obd cluster start xybobs
  2. Get local repositories and plugins ok
  3. Open ssh connection ok
  4. Load cluster param plugin ok
  5. Check before start observer x
  6. [ERROR] (127.0.0.1) not enough memory. (Free: 7.3G, Need: 8.0G)
  7. [WARN] (127.0.0.1) clog and data use the same disk (/)
  8. [root@obs ~]#

本文转自:https://blog.csdn.net/qq_45392321/article/details/123171408

更多相关文章

  1. Android干坏事——禁止设备休眠
  2. Android(安卓)studio Day01-2&3
  3. 基于linux系统安装Android(安卓)Studio
  4. android数据库编程----SqLiteOpenHelper的使用
  5. 一文教你快速部署OneBlog开源项目
  6. android(2)
  7. Android安装环境搭建
  8. Android短彩信数据库信息整理
  9. Android(安卓)APK应用安装原理(2)-查找APK并自动安装

随机推荐

  1. Android学习札记17:ImageView中的setImage
  2. 2011.10.18——— android 自定义Animati
  3. Android中如何自己制作su
  4. Android休眠唤醒机制简介(二)
  5. JS判断客户端类型(ipad,iphone,android)
  6. Android 简单的账号密码登陆界面(IO流)
  7. Android Studio 环境问题
  8. Android 开发系列 2 Activity
  9. 为Android软件创建快捷方式
  10. Android中OnScrollListener的详解(Listvie