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

「OceanBase 4.1 体验」快速体验 OceanBase 4.1 数据库 部署演示环境

原创 shunwah 2023-04-22
502

作者:马顺华

从事运维管理工作多年,目前就职于某科技有限公司,熟悉运维自动化、OceanBase部署运维、MySQL 运维以及各种云平台技术和产品。并已获得OceanBase认证OBCA、OBCP 证书、OpenGauss社区认证结业证书。OceanBase & 墨天轮第二、三、四、五、六届技术征文大赛,多次获得 一、二、三 等奖,时常在墨天轮发布原创技术文章,并多次被首页推荐。

image.png

本文以部署 OceanBase 演示环境、部署 OceanBase 集群环境和部署 OceanBase 容器环境三种部署方案为例指导您如何快速使用 OceanBase 数据库。

注意

本文中的方法仅适用于 OceanBase 数据库快速上手体验,不适用生产环境,如需在生产环境中部署 OceanBase 数据库,请参考 OceanBase 数据库文档中 部署数据库 章节。

本文提供的三种方案中,部署演示环境 和 部署集群环境 同时适用于企业版和社区版部署;部署容器环境 仅适用于社区版部署。

背景信息

OceanBase 数据库自 V4.0.0 开始提供统一的安装包 all-in-one package。您可以通过这个统一的安装包一次性完成 OBD、OceanBase 数据库、ODP、OBAgent、Grafana、Prometheus 的安装,自 V4.1.0 起,all-in-one package 新增支持安装 OCP Express。您可以根据实际需求选择部分或全部组件安装。

方案介绍

为了助力您快速上手体验 OceanBase 数据库,我们提供了如下三种不同的方案实现快速部署 Oceanbase 数据,您可以根据自身环境情况灵活选择。

一、部署 OceanBase 演示环境

此方案适用于仅有一台机器时,快速搭建一个可用的 OceanBase 数据库环境。部署的 OceanBase 数据库环境具备数据库的基本功能,可以有效地帮助您了解 OceanBase 数据库;但是该环境不具备任何分布式能力及高可用特性,不建议长期使用。具体操作步骤请参考 方案一:部署 OceanBase 演示环境。

1:部署 OceanBase 演示环境

当您仅拥有一台可用机器时,您可参考本节内容使用 obd demo 命令快速部署单机 OceanBase 数据库。

2:下载并安装 all-in-one 安装包

下载 all-in-one 安装包,并将其上传到机器任一目录下。

企业版:请联系技术支持获取 all-in-one 安装包。

社区版:请从 OceanBase 软件下载中心 下载 all-in-one 安装包,建议下载最新版本。

在安装包所在目录下执行如下命令解压安装包并安装,本次测试使用社区版:

[admin@test001 ~]$ tar -xzf oceanbase-all-in-one-*.tar.gz
[admin@test001 ~]$ cd oceanbase-all-in-one/bin/
[admin@test001 bin]$ ./install.sh
[admin@test001 bin]$ source ~/.oceanbase-all-in-one/bin/env.sh

3. 从 OceanBase 社区下载中心 下载最新的

官方下载地址:https://www.oceanbase.com/softwarecenter
image.png
2. all-in-one package,oceanbase-all-in-one-4.xx.xx-xxx.tar.gz。
image.png

4. 执行以下命令解压安装包并安装。

[root@CAIP131 soft]# ls
obce-3zones.yaml  obce-3zones.yamlbak  oceanbase-all-in-one-4.1.0.0-100120230323143519.el7.x86_64.tar.gz  Python-3.9.5  tsar
[root@CAIP131 soft]# tar -xzf oceanbase-all-in-one-4.1.0.0-100120230323143519.el7.x86_64.tar.gz 
[root@CAIP131 soft]# 

image.png

5. 安装 all-in-one

[root@CAIP131 soft]# cd oceanbase-all-in-one/bin/
[root@CAIP131 bin]# ls
env.sh  install.sh  uninstall.sh
[root@CAIP131 bin]# ./install.sh
name: grafana
version: 7.5.17
release:1
arch: x86_64
md5: 1bf1f338d3a3445d8599dc6902e7aeed4de4e0d6
add /root/soft/oceanbase-all-in-one/rpms/grafana-7.5.17-1.el7.x86_64.rpm to local mirror
name: obagent
version: 1.3.0
release:22.el7
arch: x86_64
md5: d57fbb4962b2fbecb6282358c59295fdfba4d6ac
add /root/soft/oceanbase-all-in-one/rpms/obagent-1.3.0-22.el7.x86_64.rpm to local mirror
name: obproxy-ce
version: 4.1.0.0
release:7.el7
arch: x86_64
md5: 2a9d9bf67f179dcca2a8c9e7c77373d94e7e2abe
add /root/soft/oceanbase-all-in-one/rpms/obproxy-ce-4.1.0.0-7.el7.x86_64.rpm to local mirror
name: oceanbase-ce
version: 4.1.0.0
release:100000192023032010.el7
arch: x86_64
md5: 8439ecf8db5e0649bd49671b41ea9e8c85756b63
add /root/soft/oceanbase-all-in-one/rpms/oceanbase-ce-4.1.0.0-100000192023032010.el7.x86_64.rpm to local mirror
name: oceanbase-ce-libs
version: 4.1.0.0
release:100000192023032010.el7
arch: x86_64
md5: a83b1dd1cab44d3f610d439931322be7a08555f2
add /root/soft/oceanbase-all-in-one/rpms/oceanbase-ce-libs-4.1.0.0-100000192023032010.el7.x86_64.rpm to local mirror
name: ocp-express
version: 1.0.0
release:100000432023032015.el7
arch: x86_64
md5: 42c6fc921063f24f9e1072d75bfa7f21f42146e3
add /root/soft/oceanbase-all-in-one/rpms/ocp-express-1.0.0-100000432023032015.el7.x86_64.rpm to local mirror
name: prometheus
version: 2.37.1
release:10000102022110211.el7
arch: x86_64
md5: 58913c7606f05feb01bc1c6410346e5fc31cf263
add /root/soft/oceanbase-all-in-one/rpms/prometheus-2.37.1-10000102022110211.el7.x86_64.rpm to local mirror
Trace ID: 2828d740-e0ef-11ed-87dd-0050568197df
If you want to view detailed obd logs, please run: obd display-trace 2828d740-e0ef-11ed-87dd-0050568197df
Disable remote ok
Trace ID: 28bb5502-e0ef-11ed-bec9-0050568197df
If you want to view detailed obd logs, please run: obd display-trace 28bb5502-e0ef-11ed-bec9-0050568197df

add auto set env logic to profile: /root/.bash_profile

#####################################################################
 Install Finished 
=====================================================================
Setup Environment:     source ~/.oceanbase-all-in-one/bin/env.sh 
Start Web Service:     obd web 
Quick Start:           obd demo 
More Details:          obd -h 
=====================================================================
[root@CAIP131 bin]# 

image.png

6. 执行 which obd 和 which obclient 检测是否安装成功

如果可以找到 oceanbase-all-in-one 下的 obd 和 obclient 路径,则表示安装成功。

[root@CAIP131 bin]# which obd
/root/.oceanbase-all-in-one/obd/usr/bin/obd
[root@CAIP131 bin]# which obclient
/root/.oceanbase-all-in-one/obclient/u01/obclient/bin/obclient
[root@CAIP131 bin]# 

image.png

二、单机部署 OceanBase 数据库

1.执行 obd demo 命令,快速部署 OceanBase 数据库

obd demo 命令默认在当前家目录下以最小规格部署并启动 OceanBase 数据库及相关组件(包括 ODP、OBAgent、Grafana 和 Prometheus),固定部署名为 demo。如需更多定制化的部署形式,参见 快速部署命令。

您也可以使用 OBD 命令管理该 OceanBase 数据库,详细命令介绍请参考 集群命令组。

[root@CAIP131 oceanbase-all-in-one]# obd demo
Found a higher version
name: oceanbase-ce
version: 4.1.0.0
release:100000192023032010.el7
arch: x86_64
md5: 8439ecf8db5e0649bd49671b41ea9e8c85756b63
Do you want to use it? [y/n]: y
Package oceanbase-ce-4.1.0.0-100000192023032010.el7 is available.
Found a higher version
name: obproxy-ce
version: 4.1.0.0
release:7.el7
arch: x86_64
md5: 2a9d9bf67f179dcca2a8c9e7c77373d94e7e2abe
Do you want to use it? [y/n]: y
Package obproxy-ce-4.1.0.0-7.el7 is available.
Found a higher version
name: obagent
version: 1.3.0
release:22.el7
arch: x86_64
md5: d57fbb4962b2fbecb6282358c59295fdfba4d6ac
Do you want to use it? [y/n]: y
Package obagent-1.3.0-22.el7 is available.
install grafana-7.5.17 for local ok
install oceanbase-ce-4.1.0.0 for local ok
install obproxy-ce-4.1.0.0 for local ok
install obagent-1.3.0 for local ok
install prometheus-2.37.1 for local ok
Cluster param config check ok
Open ssh connection ok
Generate grafana configuration ok
Generate observer configuration ok
Generate obproxy configuration ok
Generate obagent configuration ok
Generate prometheus configuration ok
+--------------------------------------------------------------------------------------------+
|                                          Packages                                          |
+--------------+---------+------------------------+------------------------------------------+
| Repository   | Version | Release                | Md5                                      |
+--------------+---------+------------------------+------------------------------------------+
| grafana      | 7.5.17  | 1                      | 1bf1f338d3a3445d8599dc6902e7aeed4de4e0d6 |
| oceanbase-ce | 4.1.0.0 | 100000192023032010.el7 | 8439ecf8db5e0649bd49671b41ea9e8c85756b63 |
| obproxy-ce   | 4.1.0.0 | 7.el7                  | 2a9d9bf67f179dcca2a8c9e7c77373d94e7e2abe |
| obagent      | 1.3.0   | 22.el7                 | d57fbb4962b2fbecb6282358c59295fdfba4d6ac |
| prometheus   | 2.37.1  | 10000102022110211.el7  | 58913c7606f05feb01bc1c6410346e5fc31cf263 |
+--------------+---------+------------------------+------------------------------------------+
Repository integrity check ok
Parameter check ok
Open ssh connection ok
Cluster status check ok
Initializes grafana work home ok
Initializes observer work home ok
Initializes obproxy work home ok
Initializes obagent work home ok
Initializes prometheus work home ok
Remote grafana-7.5.17-1-1bf1f338d3a3445d8599dc6902e7aeed4de4e0d6 repository install ok
Remote grafana-7.5.17-1-1bf1f338d3a3445d8599dc6902e7aeed4de4e0d6 repository lib check ok
Remote oceanbase-ce-4.1.0.0-100000192023032010.el7-8439ecf8db5e0649bd49671b41ea9e8c85756b63 repository install ok
Remote oceanbase-ce-4.1.0.0-100000192023032010.el7-8439ecf8db5e0649bd49671b41ea9e8c85756b63 repository lib check !!
Remote obproxy-ce-4.1.0.0-7.el7-2a9d9bf67f179dcca2a8c9e7c77373d94e7e2abe repository install ok
Remote obproxy-ce-4.1.0.0-7.el7-2a9d9bf67f179dcca2a8c9e7c77373d94e7e2abe repository lib check ok
Remote obagent-1.3.0-22.el7-d57fbb4962b2fbecb6282358c59295fdfba4d6ac repository install ok
Remote obagent-1.3.0-22.el7-d57fbb4962b2fbecb6282358c59295fdfba4d6ac repository lib check ok
Remote prometheus-2.37.1-10000102022110211.el7-58913c7606f05feb01bc1c6410346e5fc31cf263 repository install ok
Remote prometheus-2.37.1-10000102022110211.el7-58913c7606f05feb01bc1c6410346e5fc31cf263 repository lib check ok
Try to get lib-repository
Found a higher version
name: oceanbase-ce-libs
version: 4.1.0.0
release:100000192023032010.el7
arch: x86_64
md5: a83b1dd1cab44d3f610d439931322be7a08555f2
Do you want to use it? [y/n]: y
Package oceanbase-ce-libs-4.1.0.0-100000192023032010.el7 is available.
install oceanbase-ce-libs-4.1.0.0 for local ok
Remote oceanbase-ce-libs-4.1.0.0-100000192023032010.el7-a83b1dd1cab44d3f610d439931322be7a08555f2 repository install ok
Remote oceanbase-ce-4.1.0.0-100000192023032010.el7-8439ecf8db5e0649bd49671b41ea9e8c85756b63 repository lib check ok
demo deployed
Get local repositories ok
Search plugins ok
Open ssh connection ok
Load cluster param plugin ok
Check before start observer ok
[WARN] OBD-1007: (127.0.0.1) The recommended number of open files is 655350 (Current value: 65535)
[WARN] OBD-1012: (127.0.0.1) clog and data use the same disk (/)

Check before start obproxy ok
Check before start obagent ok
Check before start prometheus ok
Check before start grafana ok
Start observer ok
observer program health check ok
Connect to observer ok
Initialize oceanbase-ce ok
Start obproxy ok
obproxy program health check ok
Connect to obproxy ok
Initialize obproxy-ce ok
Start obagent ok
obagent program health check ok
Connect to Obagent ok
Start promethues ok
prometheus program health check ok
Connect to Prometheus ok
Initialize prometheus ok
Start grafana ok
grafana program health check ok
Connect to grafana ok
Initialize grafana ok
Wait for observer init ok
+---------------------------------------------+
|                   observer                  |
+-----------+---------+------+-------+--------+
| ip        | version | port | zone  | status |
+-----------+---------+------+-------+--------+
| 127.0.0.1 | 4.1.0.0 | 2881 | zone1 | ACTIVE |
+-----------+---------+------+-------+--------+
obclient -h127.0.0.1 -P2881 -uroot -Doceanbase -A

+---------------------------------------------+
|                   obproxy                   |
+-----------+------+-----------------+--------+
| ip        | port | prometheus_port | status |
+-----------+------+-----------------+--------+
| 127.0.0.1 | 2883 | 2884            | active |
+-----------+------+-----------------+--------+
obclient -h127.0.0.1 -P2883 -uroot -Doceanbase -A
+-----------------------------------------------------------------+
|                             obagent                             |
+--------------+--------------------+--------------------+--------+
| ip           | mgragent_http_port | monagent_http_port | status |
+--------------+--------------------+--------------------+--------+
| 127.0.0.1 | 8089               | 8088               | active |
+--------------+--------------------+--------------------+--------+
+-----------------------------------------------------+
|                      prometheus                     |
+--------------------------+------+----------+--------+
| url                      | user | password | status |
+--------------------------+------+----------+--------+
| http://127.0.0.1:9090 |      |          | active |
+--------------------------+------+----------+--------+
+-------------------------------------------------------------------+
|                              grafana                              |
+--------------------------------------+-------+-----------+--------+
| url                                  | user  | password  | status |
+--------------------------------------+-------+-----------+--------+
| http://127.0.0.1:3000/d/oceanbase | admin | oceanbase | active |
+--------------------------------------+-------+-----------+--------+
demo running
Trace ID: 8ed734c8-e0ef-11ed-84db-0050568197df
If you want to view detailed obd logs, please run: obd display-trace 8ed734c8-e0ef-11ed-84db-0050568197df

image.png

说明
当安装 grafana 或 prometheus 时,会输出 grafana 或 prometheus 的访问地址。在阿里云或其他云环境下,可能出现因无法获取公网 IP 而输出内网地址的情况,此 IP 非公网地址,您需要使用正确的地址。
image.png

三、连接 OceanBase 数据库

使用 OBClient 客户端连接 OceanBase 数据库

1.通过 2881 端口直连数据库

[root@CAIP131 oceanbase-all-in-one]# obclient -h127.0.0.1 -P2881 -uroot@sys -Doceanbase -A
Welcome to the OceanBase.  Commands end with ; or \g.
Your OceanBase connection id is 3221487698
Server version: OceanBase_CE 4.1.0.0 (r100000192023032010-0265dfc6d00ff4f0ff4ad2710504a18962abaef6) (Built Mar 20 2023 10:12:57)

Copyright (c) 2000, 2018, OceanBase and/or its affiliates. All rights reserved.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

obclient [oceanbase]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| LBACSYS            |
| mysql              |
| oceanbase          |
| ORAAUDITOR         |
| SYS                |
| test               |
+--------------------+
7 rows in set (0.014 sec)

obclient [oceanbase]> 

image.png

2.通过 ODP 代理访问数据库

[root@CAIP131 oceanbase-all-in-one]# 
[root@CAIP131 oceanbase-all-in-one]# obclient -h127.0.0.1 -P2883 -uroot@sys -Doceanbase -A --proxy-mode
Welcome to the OceanBase.  Commands end with ; or \g.
Your OceanBase connection id is 2
Server version: 

Copyright (c) 2000, 2018, OceanBase and/or its affiliates. All rights reserved.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

obclient [oceanbase]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| LBACSYS            |
| mysql              |
| oceanbase          |
| ORAAUDITOR         |
| SYS                |
| test               |
+--------------------+
7 rows in set (0.009 sec)

obclient [oceanbase]> 

image.png

「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论