暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

OceanBase 快速上手

前提条件

在安装 OceanBase 数据库之前,确保您的机器可以连接公网。并且您的软硬件环境满足以下要求:

项目

描述

系统

  • Anolis OS 8.X 版本(内核 Linux 3.10.0 版本及以上) -- 推荐

  • Red Hat Enterprise Linux Server 7.X 版本(内核 Linux 3.10.0 版本及以上) -- 推荐

  • CentOS Linux 7.X 版本及以上版本(内核 Linux 3.10.0 版本及以上) -- 推荐

  • Debian 9.X 版本及以上版本 (内核 Linux 3.10.0 版本及以上)

  • Ubuntu 20.X 版本及以上版本(内核 Linux 3.10.0 版本及以上)

CPU

  • 企业用户最低要求 16 核,推荐 32 核及以上

  • 个人用户最低要求 2 核,推荐 8 核及以上

内存

  • 企业用户最低要求 64G,推荐 256 G 及以上

  • 个人用户最低要求 8G,推荐 64 G 及以上

磁盘类型

推荐使用 SSD

磁盘存储空间

内存大小的 4 倍及以上

文件系统

EXT4 戓 XFS,当数据超过 16T 时,使用 XFS

网卡

千兆互联及以上

说明


以下内容以 x86 架构的 CentOS Linux 7.2 镜像作为环境,其他环境可能略有不同。

步骤 1:下载安装 OBD

获取 OceanBase 数据库最快的方式是使用数据库部署工具 OceanBase Deployer(简称 OBD),因此推荐您使用此方式体验 OceanBase 数据库。按照以下步骤下载并安装 OBD。

方案1:通过 YUM 软件源安装 OBD

如您的机器可以访问公网,并能够添加三方 YUM 软件源,您可以运行以下命令,使用 OceanBase 的官方软件源安装 OBD:

sudo yum install -y yum-utils
sudo yum-config-manager --add-repo https://mirrors.aliyun.com/oceanbase/OceanBase.repo
sudo yum install -y ob-deploy

方案2:离线安装 OBD

  1. 下载 OBD 离线 RPM 安装包。

  2. 运行以下命令安装 OBD。

    yum install -y ob-deploy-1.0.0-1.el7.x86_64.rpm
    source /etc/profile.d/obd.sh

步骤 2:部署 OceanBase 数据库

本节介绍如何使用 OBD 部署 OceanBase 数据库。按照以下步骤部署 OceanBase 数据库:

  1. 从 Github 上下载对应的配置文件模板。

  1. 在配置文件顶部添加用户密码信息。

    user:
      username: <您的账号名>
      password: <您的登录密码>
      key_file: <您的私钥路径>

    其中,username 为登录到目标机器的用户名,确保您的用户名有 home_path 权限。

    注意


    通常情况下,您只能使用登录密码或者私钥登录中的一种方式登录目标机器,如果同时填写,password 将被认为是您私钥的密码。

  2. 修改配置文件中的 IP 地址(可选)。

    oceanbase-ce:
      servers:
        - name: z1
        # Please don't use hostname, only IP can be supported
        ip: 11.166.80.01
  3. 修改配置文件中的 home_path

    oceanbase-ce:
      servers:
        # Please don't use hostname, only IP can be supported
        - 192.168.1.3
      global:
        # The working directory for OceanBase Database. OceanBase Database is started under this directory. This is a required field.
        home_path: /root/observer
        # The directory for data storage. The default value is $home_path/store.
        # data_dir: /data
        # The directory for clog, ilog, and slog. The default value is the same as the data_dir value.
        # redo_dir: /redo

步骤 3:启动 OceanBase 数据库

按照以下步骤部署并启动 OceanBase 数据库实例:

  1. 运行以下命令部署集群:

    obd cluster autodeploy <deploy_name> -c <deploy_config_file> -A

    其中,deploy_name 为集群名称,一个集群只能有一个名称,且集群名称不能重复。增加 -A 参数后,将自动用系统剩余资源创建 test 租户。

  2. 运行以下命令查看集群状态:

    obd cluster display <deploy_name>

步骤 4:连接 OceanBase 数据库

按照以下步骤连接 OceanBase 数据库:

  1. 安装 OceanBase 数据库客户端 OBClient:

    如您的机器已添加 OceanBase 官方 YUM 源作为软件源,使用以下命令直接安装:

    sudo yum install -y obclient

    否则您需要在机器上准备好离线安装包,并执行以下命令安装:

    sudo yum install -y libobclient-2.0.0-2.el7.x86_64.rpm
    sudo yum install -y obclient-2.0.0-2.el7.x86_64.rpm
  2. 运行以下命令,使用 OBClient 客户端连接 OceanBase 数据库:

    obclient -h<your_ip> -P<observer_mysql_port> -uroot

    其中,your_ip 为您 OceanBase 实例所在的机器 IP 地址。observer 默认使用端口 2883 连接 OBClient。如果您对端口做了更改,此处使用您实际的端口号。

    检查 test 租户拥有多少资源, 返回以下信息:

    Welcome to the MariaDB monitor.  Commands end with ; or \g.
    Your MySQL connection id is 3221546072
    Server version: 5.7.25 OceanBase 3.1.0 (r1-) (Built Apr  7 2021 08:14:49)
    
    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)]> use oceanbase;
    Reading table information for completion of table and column names
    You can turn off this feature to get a quicker startup with -A
    
    Database changed
    MySQL [oceanbase]> select * from gv$tenant;
最后修改时间:2022-02-21 03:19:39
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论