完善酒店網(wǎng)站建設(shè)線上推廣策劃方案
本文作者:馬順華
引言
OceanBase 4.3 是一個(gè)專為實(shí)時(shí)分析 AP 業(yè)務(wù)設(shè)計(jì)的重大更新版本。它基于LSM-Tree架構(gòu),引入了列存引擎,實(shí)現(xiàn)了行存與列存數(shù)據(jù)存儲(chǔ)的無(wú)縫整合。這一版本不僅顯著提升了AP場(chǎng)景的查詢性能,同時(shí)也確保了TP業(yè)務(wù)場(chǎng)景的高效運(yùn)行,使其適用于包括復(fù)雜分析、實(shí)時(shí)報(bào)表、實(shí)時(shí)數(shù)倉(cāng)以及聯(lián)機(jī)交易等在內(nèi)的混合負(fù)載場(chǎng)景。
- TP & AP一體化產(chǎn)品形態(tài):OceanBase 4.3 實(shí)現(xiàn)了行存和列存數(shù)據(jù)的完美共存,使得TP(聯(lián)機(jī)交易)和AP(實(shí)時(shí)分析)業(yè)務(wù)能夠同時(shí)在一個(gè)系統(tǒng)中運(yùn)行,大大提高了系統(tǒng)的靈活性和效率。
- 全面增強(qiáng)的內(nèi)核特性:該版本引入了列存引擎、新版向量化引擎和基于列存的代價(jià)模型,這些技術(shù)的引入使得OceanBase在處理大寬表等復(fù)雜場(chǎng)景時(shí)具有更高的性能。
- 顯著增強(qiáng)的計(jì)算性能:OceanBase 4.3 在同等硬件環(huán)境下,大寬表場(chǎng)景下的查詢性能達(dá)到了業(yè)內(nèi)主流列存大寬表數(shù)據(jù)庫(kù)的水平。
- 持續(xù)提升的易用性:新版本內(nèi)核擴(kuò)展了 Online DDL、支持了租戶克隆等功能,優(yōu)化性能和資源使用,提升了系統(tǒng)易用性。
背景信息
OceanBase 數(shù)據(jù)庫(kù)自 V4.0.0 版本起,提供了一站式的 all-in-one 安裝包。這個(gè)安裝包包含了 OBD、OceanBase 數(shù)據(jù)庫(kù)、ODP、OBAgent、Grafana、Prometheus 等組件,自 V4.1.0 版本起,還新增支持了 OCP Express 的安裝。您可以根據(jù)實(shí)際需求選擇安裝所需組件。想要快速上手體驗(yàn) OceanBase 社區(qū)版嗎?本文將指導(dǎo)您通過(guò)三種部署方案——演示環(huán)境、集群環(huán)境和容器環(huán)境,輕松體驗(yàn) OceanBase 的強(qiáng)大功能。請(qǐng)注意,以下部署方案僅適用于測(cè)試環(huán)境,不適用于生產(chǎn)環(huán)境。
前提條件
在開(kāi)始部署之前,請(qǐng)確保您的軟硬件環(huán)境滿足 OceanBase 的基本要求。以下指南以 x86 架構(gòu)的 CentOS Linux 7.4 為例,其他環(huán)境請(qǐng)參照官方文檔進(jìn)行相應(yīng)調(diào)整。
項(xiàng)目 | 描述 |
---|---|
系統(tǒng) | CentOS Linux 7.X 版本 |
CPU | 最低要求 2 核,推薦 4 核及以上。 |
內(nèi)存 | 最低要求 8 GB,推薦設(shè)置在 16 GB 至 1024 GB 范圍內(nèi)。 |
磁盤類型 | 使用 SSD 存儲(chǔ)。 |
磁盤存儲(chǔ)空間 | 最低要求 19 GB。 |
文件系統(tǒng) | EXT4 戓 XFS,當(dāng)數(shù)據(jù)超過(guò) 16T 時(shí),使用 XFS。 |
all-in-one 安裝包 | all-in-one 安裝包需選擇 V4.1.0 及以上版本。 |
Docker | 使用 Docker 部署 OceanBase 數(shù)據(jù)庫(kù)時(shí)需提前安裝 Docker 并啟動(dòng) Docker 服務(wù),詳細(xì)操作請(qǐng)參考?Docker 文檔。 |
以下內(nèi)容以 x86 架構(gòu)的 CentOS Linux 7.4 鏡像作為環(huán)境,其他環(huán)境可能略有不同。
[root@worker2 ~]# cat /etc/redhat-release
CentOS Linux release 7.4.1708 (Core)
[root@worker2 ~]# free -htotal used free shared buff/cache available
Mem: 27G 3.5G 552M 15G 23G 8.3G
Swap: 8.0G 0B 8.0G
[root@worker2 ~]# df -Th
Filesystem Type Size Used Avail Use% Mounted on
/dev/mapper/centos-root ext4 91G 49G 38G 57% /
devtmpfs devtmpfs 14G 0 14G 0% /dev
tmpfs tmpfs 14G 0 14G 0% /dev/shm
tmpfs tmpfs 14G 1.4G 13G 11% /run
tmpfs tmpfs 14G 0 14G 0% /sys/fs/cgroup
/dev/sda2 ext4 190M 141M 35M 81% /boot
/dev/sdb1 xfs 200G 10G 190G 5% /data
一、準(zhǔn)備 OceanBase 部署環(huán)境
當(dāng)您僅擁有一臺(tái)可用機(jī)器時(shí),您可參考本節(jié)內(nèi)容使用 obd demo 命令快速部署單機(jī) OceanBase 數(shù)據(jù)庫(kù)。
1、下載并安裝 all-in-one 安裝包
請(qǐng)從 OceanBase 軟件下載中心 下載最新版本 all-in-one 安裝包,并將其上傳到機(jī)器任一目錄下。
https://www.oceanbase.com/softwarecenter
2、上傳安裝包
[root@worker2 ob4-3]# ls
oceanbase-all-in-one-4.3.1.0-100000032024051615.el7.x86_64.tar.gz
[root@worker2 ob4-3]#
3、解壓安裝包
在安裝包所在目錄下執(zhí)行如下命令解壓安裝包并安裝。
[root@worker2 ob4-3]# ls
oceanbase-all-in-one-4.3.1.0-100000032024051615.el7.x86_64.tar.gz
[root@worker2 ob4-3]# tar -xzf oceanbase-all-in-one-4.3.1.0-100000032024051615.el7.x86_64.tar.gz
[root@worker2 ob4-3]# ls
oceanbase-all-in-one oceanbase-all-in-one-4.3.1.0-100000032024051615.el7.x86_64.tar.gz
[root@worker2 ob4-3]# cd oceanbase-all-in-one/
[root@worker2 oceanbase-all-in-one]# ls
bin obclient obd README.md rpms VERSION
[root@worker2 oceanbase-all-in-one]#
4、安裝 all-in-one
[root@worker2 oceanbase-all-in-one]# ls
bin obclient obd README.md rpms VERSION
[root@worker2 oceanbase-all-in-one]# cd bin/
[root@worker2 bin]# ls
env.sh install.sh uninstall.sh
[root@worker2 bin]# ./install.sh
name: grafana
version: 7.5.17
release:1
arch: x86_64
md5: 1bf1f338d3a3445d8599dc6902e7aeed4de4e0d6
size: 177766248
add /opt/ob4-3/oceanbase-all-in-one/rpms/grafana-7.5.17-1.el7.x86_64.rpm to local mirror
name: obagent
version: 4.2.2
release:100000042024011120.el7
arch: x86_64
md5: 19739a07a12eab736aff86ecf357b1ae660b554e
size: 72919140
add /opt/ob4-3/oceanbase-all-in-one/rpms/obagent-4.2.2-100000042024011120.el7.x86_64.rpm to local mirror
name: ob-configserver
version: 1.0.0
release:2.el7
arch: x86_64
md5: feca6b9c76e26ac49464f34bfa0780b5a8d3f4a0
size: 24259515
add /opt/ob4-3/oceanbase-all-in-one/rpms/ob-configserver-1.0.0-2.el7.x86_64.rpm to local mirror
name: ob-deploy
version: 2.8.0
release:4.el7
arch: x86_64
md5: cd73c47e348ccdb71455b1a671e95f77ef818e0c
size: 154417687
add /opt/ob4-3/oceanbase-all-in-one/rpms/ob-deploy-2.8.0-4.el7.x86_64.rpm to local mirror
name: obproxy-ce
version: 4.2.3.0
release:3.el7
arch: x86_64
md5: 0490ebc04220def8d25cb9cac9ac61a4efa6d639
size: 688373235
add /opt/ob4-3/oceanbase-all-in-one/rpms/obproxy-ce-4.2.3.0-3.el7.x86_64.rpm to local mirror
name: oceanbase-ce
version: 4.3.1.0
release:100000032024051615.el7
arch: x86_64
md5: f3cd399aa780d23fbb60faed68e32a7dbd4e6a3c
size: 589267409
add /opt/ob4-3/oceanbase-all-in-one/rpms/oceanbase-ce-4.3.1.0-100000032024051615.el7.x86_64.rpm to local mirror
name: oceanbase-ce-libs
version: 4.3.1.0
release:100000032024051615.el7
arch: x86_64
md5: 68f0b5f988bd5fb80d44ac29afad0c2b2f2d3763
size: 468528
add /opt/ob4-3/oceanbase-all-in-one/rpms/oceanbase-ce-libs-4.3.1.0-100000032024051615.el7.x86_64.rpm to local mirror
name: oceanbase-diagnostic-tool
version: 2.0.0
release:32024041111.el7
arch: x86_64
md5: 5deeab8e3359ebf933898136090f72ebb3729f8a
size: 36010369
add /opt/ob4-3/oceanbase-all-in-one/rpms/oceanbase-diagnostic-tool-2.0.0-32024041111.el7.x86_64.rpm to local mirror
name: ocp-express
version: 4.2.2
release:100000022024011120.el7
arch: x86_64
md5: 09ffcf156d1df9318a78af52656f499d2315e3f7
size: 78426196
add /opt/ob4-3/oceanbase-all-in-one/rpms/ocp-express-4.2.2-100000022024011120.el7.x86_64.rpm to local mirror
name: openjdk-jre
version: 1.8.0_322
release:b09.el7
arch: x86_64
md5: 051aa69c5abb8697d15c2f0dcb1392b3f815f7ed
size: 69766947
add /opt/ob4-3/oceanbase-all-in-one/rpms/openjdk-jre-1.8.0_322-b09.el7.x86_64.rpm to local mirror
name: prometheus
version: 2.37.1
release:10000102022110211.el7
arch: x86_64
md5: 58913c7606f05feb01bc1c6410346e5fc31cf263
size: 211224073
add /opt/ob4-3/oceanbase-all-in-one/rpms/prometheus-2.37.1-10000102022110211.el7.x86_64.rpm to local mirror
Trace ID: 7cd5ad98-24a7-11ef-b503-005056818c51
If you want to view detailed obd logs, please run: obd display-trace 7cd5ad98-24a7-11ef-b503-005056818c51
Disable remote ok
Trace ID: 7dcb601c-24a7-11ef-a5bd-005056818c51
If you want to view detailed obd logs, please run: obd display-trace 7dcb601c-24a7-11ef-a5bd-005056818c51add auto set env logic to profile: /root/.bash_profile#########################################################################################Install Finished
=========================================================================================
Setup Environment: source ~/.oceanbase-all-in-one/bin/env.sh
Quick Start: obd demo
Use Web Service to install: obd web
Use Web Service to upgrade: obd web upgrade
More Details: obd -h
=========================================================================================
[root@worker2 bin]#
[root@worker2 bin]#
[root@worker2 bin]# source ~/.oceanbase-all-in-one/bin/env.sh
[root@worker2 bin]#
二、單機(jī)部署 OceanBase 數(shù)據(jù)庫(kù)
執(zhí)行 obd demo 命令,OceanBase 將默認(rèn)在當(dāng)前用戶家目錄下以最小規(guī)格部署并啟動(dòng)數(shù)據(jù)庫(kù)及相關(guān)組件,部署名為 demo。如有定制化需求,請(qǐng)參考官方文檔中的快速部署命令。
1、執(zhí)行 obd demo 部署 OceanBase 數(shù)據(jù)庫(kù)
obd demo
[root@worker2 ~]# obd demo
Found a higher version
name: oceanbase-ce
version: 4.3.1.0
release:100000032024051615.el7
arch: x86_64
md5: f3cd399aa780d23fbb60faed68e32a7dbd4e6a3c
size: 589267409
Do you want to use it? [y/n]: y
Package oceanbase-ce-4.3.1.0-100000032024051615.el7 is available.
Found a higher version
name: obproxy-ce
version: 4.2.3.0
release:3.el7
arch: x86_64
md5: 0490ebc04220def8d25cb9cac9ac61a4efa6d639
size: 688373235
Do you want to use it? [y/n]: y
Package obproxy-ce-4.2.3.0-3.el7 is available.
Found a higher version
name: obagent
version: 4.2.2
release:100000042024011120.el7
arch: x86_64
md5: 19739a07a12eab736aff86ecf357b1ae660b554e
size: 72919140
Do you want to use it? [y/n]: y
Package obagent-4.2.2-100000042024011120.el7 is available.
install oceanbase-ce-4.3.1.0 for local ok
install obproxy-ce-4.2.3.0 for local ok
install grafana-7.5.17 for local ok
install prometheus-2.37.1 for local ok
install obagent-4.2.2 for local ok
Cluster param config check ok
Open ssh connection ok
Generate obagent configuration ok
Generate prometheus configuration ok
Generate grafana configuration ok
Generate obproxy configuration ok
Generate observer configuration ok
+--------------------------------------------------------------------------------------------+
| Packages |
+--------------+---------+------------------------+------------------------------------------+
| Repository | Version | Release | Md5 |
+--------------+---------+------------------------+------------------------------------------+
| oceanbase-ce | 4.3.1.0 | 100000032024051615.el7 | f3cd399aa780d23fbb60faed68e32a7dbd4e6a3c |
| obproxy-ce | 4.2.3.0 | 3.el7 | 0490ebc04220def8d25cb9cac9ac61a4efa6d639 |
| grafana | 7.5.17 | 1 | 1bf1f338d3a3445d8599dc6902e7aeed4de4e0d6 |
| prometheus | 2.37.1 | 10000102022110211.el7 | 58913c7606f05feb01bc1c6410346e5fc31cf263 |
| obagent | 4.2.2 | 100000042024011120.el7 | 19739a07a12eab736aff86ecf357b1ae660b554e |
+--------------+---------+------------------------+------------------------------------------+
Repository integrity check ok
Load param plugin ok
Open ssh connection ok
Parameter check ok
Cluster status check ok
Initializes observer work home ok
Initializes obproxy work home ok
Initializes grafana work home ok
Initializes prometheus work home ok
Initializes obagent work home ok
Remote oceanbase-ce-4.3.1.0-100000032024051615.el7-f3cd399aa780d23fbb60faed68e32a7dbd4e6a3c repository install ok
Remote oceanbase-ce-4.3.1.0-100000032024051615.el7-f3cd399aa780d23fbb60faed68e32a7dbd4e6a3c repository lib check !!
Remote obproxy-ce-4.2.3.0-3.el7-0490ebc04220def8d25cb9cac9ac61a4efa6d639 repository install ok
Remote obproxy-ce-4.2.3.0-3.el7-0490ebc04220def8d25cb9cac9ac61a4efa6d639 repository lib check ok
Remote grafana-7.5.17-1-1bf1f338d3a3445d8599dc6902e7aeed4de4e0d6 repository install ok
Remote grafana-7.5.17-1-1bf1f338d3a3445d8599dc6902e7aeed4de4e0d6 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
Remote obagent-4.2.2-100000042024011120.el7-19739a07a12eab736aff86ecf357b1ae660b554e repository install ok
Remote obagent-4.2.2-100000042024011120.el7-19739a07a12eab736aff86ecf357b1ae660b554e repository lib check ok
Try to get lib-repository
Package oceanbase-ce-libs-4.3.1.0-100000032024051615.el7 is available.
install oceanbase-ce-libs-4.3.1.0 for local ok
Remote oceanbase-ce-libs-4.3.1.0-100000032024051615.el7-68f0b5f988bd5fb80d44ac29afad0c2b2f2d3763 repository install ok
Remote oceanbase-ce-4.3.1.0-100000032024051615.el7-f3cd399aa780d23fbb60faed68e32a7dbd4e6a3c repository lib check ok
demo deployed
Get local repositories ok
Search plugins ok
Load cluster param plugin ok
Open ssh connection ok
Check before start observer ok
[WARN] OBD-1007: (127.0.0.1) The recommended number of stack size is unlimited (Current value: 20480)
[WARN] OBD-1017: (127.0.0.1) The value of the "fs.file-max" must be greater than 6573688 (Current value: 655350, Recommended value: 6573688)
[WARN] OBD-2000: (127.0.0.1) not enough memory. (Free: 263M, Need: 6144M)
[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
cluster scenario: express_oltp
Start observer ok
observer program health check ok
Connect to observer 127.0.0.1:2881 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.3.1.0 | 2881 | zone1 | ACTIVE |
+-----------+---------+------+-------+--------+
obclient -h127.0.0.1 -P2881 -uroot -Doceanbase -Acluster unique id: ba0792c2-f3a5-5f3f-a1c5-c969744780fd-18ff2acdab4-00010304+---------------------------------------------+
| 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 | VlxvOiQdfw | active |
+--------------------------------------+-------+------------+--------+
demo running
Trace ID: 3cc9e300-24c9-11ef-9f40-0050568197df
If you want to view detailed obd logs, please run: obd display-trace 3cc9e300-24c9-11ef-9f40-0050568197df
obd demo 命令默認(rèn)在當(dāng)前用戶家目錄下以最小規(guī)格部署并啟動(dòng) OceanBase 數(shù)據(jù)庫(kù)及相關(guān)組件(包括 ODP、OBAgent、Grafana 和 Prometheus),固定部署名為 demo。如需更多定制化的部署形式,參見(jiàn) 快速部署命令。
2、查看部署狀態(tài)
[root@worker2 ~]# obd cluster list
+----------------------------------------------------------+
| Cluster List |
+----------+-----------------------------+-----------------+
| Name | Configuration Path | Status (Cached) |
+----------+-----------------------------+-----------------+
| demo | /root/.obd/cluster/demo | running |
| ob41test | /root/.obd/cluster/ob41test | destroyed |
+----------+-----------------------------+-----------------+
Trace ID: d69691f8-2592-11ef-a9b9-0050568197df
If you want to view detailed obd logs, please run: obd display-trace d69691f8-2592-11ef-a9b9-0050568197df
[root@worker2 ~]#
狀態(tài) running 為運(yùn)行正常您也可以使用 OBD 命令管理該 OceanBase 數(shù)據(jù)庫(kù),詳細(xì)命令介紹請(qǐng)參考 集群命令組。
三、訪問(wèn)與配置
當(dāng)安裝 grafana 或 prometheus 時(shí),會(huì)輸出 grafana 或 prometheus 的訪問(wèn)地址。在阿里云或其他云環(huán)境下,可能出現(xiàn)因無(wú)法獲取公網(wǎng) IP 而輸出內(nèi)網(wǎng)地址的情況,此 IP 非公網(wǎng)地址,您需要使用正確的地址。
部署成功后,根據(jù)輸出信息中的連接命令,使用 OBClient 客戶端連接到 OceanBase 數(shù)據(jù)庫(kù)。執(zhí)行輸出中的連接命令連接數(shù)據(jù)庫(kù)
obd demo 命令成功執(zhí)行后會(huì)輸出通過(guò) OBClient 連接 OceanBase 數(shù)據(jù)庫(kù)的命令,示例如下。
1、通過(guò) 2881 端口直連數(shù)據(jù)庫(kù)
[root@worker2 ~]# obclient -h127.0.0.1 -P2881 -uroot@sys -Doceanbase -A
Welcome to the OceanBase. Commands end with ; or \g.
Your OceanBase connection id is 3221487833
Server version: OceanBase_CE 4.3.1.0 (r100000032024051615-bad90e897a7f0f56b8ce5c43e186aa8f4bab03c4) (Built May 16 2024 17:21:43)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]>
2、通過(guò) ODP 代理訪問(wèn)數(shù)據(jù)庫(kù)
[root@worker2 ~]# obclient -h127.0.0.1 -P2883 -uroot@sys -Doceanbase -A
Welcome to the OceanBase. Commands end with ; or \g.
Your OceanBase connection id is 1251475458
Server version: OceanBase_CE 4.3.1.0 (r100000032024051615-bad90e897a7f0f56b8ce5c43e186aa8f4bab03c4) (Built May 16 2024 17:21:43)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]>
使用 OBClient 客戶端連接 OceanBase 集群的詳細(xì)操作可參見(jiàn) 通過(guò) OBClient 連接 OceanBase 租戶。連接 OceanBase 數(shù)據(jù)庫(kù)更多方法請(qǐng)參見(jiàn) 連接方式概述。
3、(可選)配置密碼
使用 obd demo 命令快速部署 OceanBase 數(shù)據(jù)庫(kù)后,您可參考如下步驟為 demo 集群配置密碼。
修改配置文件obd cluster edit-config demo執(zhí)行上述命令打開(kāi)配置文件后,在配置文件中 oceanbase-ce(社區(qū)版)/oceanbase(企業(yè)版) 組件下添加 root_password: xxxx,添加完成后保存退出。示例如下:
[root@worker2 ~]# obd cluster edit-config demo
Search param plugin and load okoceanbase-ce:servers:- 127.0.0.1global:home_path: /root/oceanbase-ceappname: demoroot_password: ******cluster_id: 1717763299scenario: express_oltpenable_syslog_recycle: trueenable_syslog_wf: falsemax_syslog_file_count: 4memory_limit: 6144Mproduction_mode: false__min_full_resource_pool_memory: 1073741824system_memory: 1024Mcpu_count: 16datafile_size: 2048Mdatafile_maxsize: 8192Mdatafile_next: 2048Mlog_disk_size: 14336M
obproxy-ce:servers:- 127.0.0.1global:home_path: /root/obproxy-ceskip_proxy_sys_private_check: trueenable_strict_kernel_release: falseenable_cluster_checkout: falseproxy_mem_limited: 500M127.0.0.1:proxy_id: 4774client_session_id_version: 2depends:- oceanbase-ce
grafana:servers:- 127.0.0.1global:home_path: /root/grafanalogin_password: VlxvOiQdfwdepends:- prometheus
prometheus:servers:- 127.0.0.1global:home_path: /root/prometheusdepends:- obagent
obagent:servers:- 127.0.0.1global:home_path: /root/obagentob_monitor_status: activedepends:- oceanbase-ce
4、重啟集群
修改并保存配置文件后,OBD 會(huì)輸出待執(zhí)行的重啟命令,直接復(fù)制執(zhí)行即可,示例如下。
[root@worker2 ~]# obd cluster edit-config demo
Search param plugin and load ok
Search param plugin and load ok
Parameter check ok
Save deploy "demo" configuration
Use `obd cluster reload demo` to make changes take effect.
Trace ID: 8cb3948c-24ca-11ef-9f19-0050568197df
If you want to view detailed obd logs, please run: obd display-trace 8cb3948c-24ca-11ef-9f19-0050568197df
[root@worker2 ~]#
從輸出可以看出,修改配置文件中 root@sys 用戶密碼后,需執(zhí)行 obd cluster reload demo 命令重啟 demo 集群。
[root@worker2 ~]# obd cluster reload demo
Get local repositories and plugins ok
Load cluster param plugin ok
Open ssh connection ok
Cluster status check ok
Connect to observer 127.0.0.1:2881 ok
Reload observer ok
Connect to obproxy ok
Connect to Obagent ok
Reload obagent ok
Connect to Prometheus ok
Reload prometheus ok
Connect to grafana ok
Reload Grafana ok
demo reload
Trace ID: 50b9c09a-24cb-11ef-8401-0050568197df
If you want to view detailed obd logs, please run: obd display-trace 50b9c09a-24cb-11ef-8401-0050568197df
[root@worker2 ~]#
說(shuō)明:您也可使用 root 用戶登錄數(shù)據(jù)庫(kù)的 sys 租戶后,通過(guò) ALTER USER 命令修改用戶密碼。詳細(xì)操作可參見(jiàn) ALTER USER。
5、測(cè)試帶密碼登錄
[root@worker2 ~]# obclient -h127.0.0.1 -P2883 -uroot@sys -Doceanbase -A
ERROR 1045 (42000): Access denied for user 'root'@'xxx.xxx.xxx.xxx' (using password: NO)
[root@worker2 ~]# obclient -h127.0.0.1 -P2883 -uroot@sys -Doceanbase -A -p
Enter password:
Welcome to the OceanBase. Commands end with ; or \g.
Your OceanBase connection id is 1251475463
Server version: OceanBase_CE 4.3.1.0 (r100000032024051615-bad90e897a7f0f56b8ce5c43e186aa8f4bab03c4) (Built May 16 2024 17:21:43)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]>
不帶密碼登錄已經(jīng)報(bào)錯(cuò)了,-p加上密碼后正常登錄。
四、SQL基礎(chǔ)操作(MySQL 模式)的增刪改查
本節(jié)主要介紹 OceanBase 數(shù)據(jù)庫(kù) MySQL 模式下的一些 SQL 基本操作。
1、創(chuàng)建數(shù)據(jù)庫(kù)
使用 CREATE DATABASE 語(yǔ)句創(chuàng)建數(shù)據(jù)庫(kù)。示例:創(chuàng)建數(shù)據(jù)庫(kù) obdb1,指定字符集為 utf8mb4,并創(chuàng)建讀寫屬性。
obclient [oceanbase]>
obclient [oceanbase]> CREATE DATABASE obdb1 DEFAULT CHARACTER SET utf8mb4 READ WRITE;
Query OK, 1 row affected (0.060 sec)obclient [oceanbase]>
更多 CREATE DATABASE 語(yǔ)句相關(guān)的語(yǔ)法說(shuō)明,請(qǐng)參見(jiàn) CREATE DATABASE 章節(jié)。
1.1查看數(shù)據(jù)庫(kù)
創(chuàng)建完成后,可以通過(guò) SHOW DATABASES 命令查看當(dāng)前數(shù)據(jù)庫(kù)服務(wù)器中所有的數(shù)據(jù)庫(kù)。
obclient [oceanbase]>
obclient [oceanbase]> SHOW DATABASES;
+--------------------+
| Database |
+--------------------+
| information_schema |
| LBACSYS |
| mysql |
| obdb1 |
| oceanbase |
| ocs |
| ORAAUDITOR |
| SYS |
| test |
+--------------------+
9 rows in set (0.004 sec)obclient [oceanbase]>
2、創(chuàng)建表
使用 CREATE TABLE 語(yǔ)句在數(shù)據(jù)庫(kù)中創(chuàng)建新表。
示例:在數(shù)據(jù)庫(kù) oddb1 中創(chuàng)建表 test。
obclient [oceanbase]>
obclient [oceanbase]> USE obdb1;
Database changed
obclient [obdb1]> CREATE TABLE obtest (c1 INT PRIMARY KEY, c2 VARCHAR(3));
Query OK, 0 rows affected (0.156 sec)obclient [obdb1]>
更多 CREATE TABLE 語(yǔ)句相關(guān)的語(yǔ)法說(shuō)明,請(qǐng)參見(jiàn) CREATE TABLE 章節(jié)。
2.1 查看表
使用 SHOW CREATE TABLE 語(yǔ)句查看建表語(yǔ)句。
示例:
2.2 查看表 obtest 的建表語(yǔ)句。
obclient [obdb1]>
obclient [obdb1]> SHOW CREATE TABLE obtest\G
*************************** 1. row ***************************Table: obtest
Create Table: CREATE TABLE `obtest` (`c1` int(11) NOT NULL,`c2` varchar(3) DEFAULT NULL,PRIMARY KEY (`c1`)
) DEFAULT CHARSET = utf8mb4 ROW_FORMAT = DYNAMIC COMPRESSION = 'zstd_1.3.8' REPLICA_NUM = 1 BLOCK_SIZE = 16384 USE_BLOOM_FILTER = FALSE TABLET_SIZE = 134217728 PCTFREE = 0
1 row in set (0.032 sec)obclient [obdb1]>
2.3 使用 SHOW TABLES 語(yǔ)句查看 db1 數(shù)據(jù)庫(kù)中的所有表。
obclient [obdb1]> SHOW TABLES FROM obdb1;
+-----------------+
| Tables_in_obdb1 |
+-----------------+
| obtest |
+-----------------+
1 row in set (0.005 sec)obclient [obdb1]>
3、修改表
使用 ALTER TABLE 語(yǔ)句來(lái)修改已存在的表的結(jié)構(gòu),包括修改表及表屬性、新增列、修改列及屬性、刪除列等。
示例:
3.1 將表 test 的字段 c2 改名為 c3,并同時(shí)修改其字段類型。
obclient [obdb1]> DESCRIBE obtest;
+-------+------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+------------+------+-----+---------+-------+
| c1 | int(11) | NO | PRI | NULL | |
| c2 | varchar(3) | YES | | NULL | |
+-------+------------+------+-----+---------+-------+
2 rows in set (0.005 sec)obclient [obdb1]> ALTER TABLE obtest CHANGE COLUMN c2 c3 CHAR(10);
Query OK, 0 rows affected (0.681 sec)obclient [obdb1]> DESCRIBE obtest;
+-------+----------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+----------+------+-----+---------+-------+
| c1 | int(11) | NO | PRI | NULL | |
| c3 | char(10) | YES | | NULL | |
+-------+----------+------+-----+---------+-------+
2 rows in set (0.027 sec)obclient [obdb1]>
3.2 在表 obtest 中增加、刪除列。
obclient [obdb1]>
obclient [obdb1]> DESCRIBE obtest;
+-------+----------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+----------+------+-----+---------+-------+
| c1 | int(11) | NO | PRI | NULL | |
| c3 | char(10) | YES | | NULL | |
+-------+----------+------+-----+---------+-------+
2 rows in set (0.004 sec)obclient [obdb1]> ALTER TABLE obtest ADD c4 int;
Query OK, 0 rows affected (0.113 sec)obclient [obdb1]> DESCRIBE obtest;
+-------+----------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+----------+------+-----+---------+-------+
| c1 | int(11) | NO | PRI | NULL | |
| c3 | char(10) | YES | | NULL | |
| c4 | int(11) | YES | | NULL | |
+-------+----------+------+-----+---------+-------+
3 rows in set (0.005 sec)obclient [obdb1]> ALTER TABLE obtest DROP c3;
Query OK, 0 rows affected (0.516 sec)obclient [obdb1]> DESCRIBE obtest;
+-------+---------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+---------+------+-----+---------+-------+
| c1 | int(11) | NO | PRI | NULL | |
| c4 | int(11) | YES | | NULL | |
+-------+---------+------+-----+---------+-------+
2 rows in set (0.027 sec)obclient [obdb1]>
更多 ALTER TABLE 語(yǔ)句相關(guān)的語(yǔ)法說(shuō)明,請(qǐng)參見(jiàn) ALTER TABLE 章節(jié)。
4、刪除表
使用 DROP TABLE 語(yǔ)句刪除表。
示例:刪除表 obtest。
obclient [obdb1]>
obclient [obdb1]> DROP TABLE obtest;
Query OK, 0 rows affected (0.075 sec)obclient [obdb1]>
更多 DROP TABLE 語(yǔ)句相關(guān)的語(yǔ)法說(shuō)明,請(qǐng)參見(jiàn) DROP TABLE 章節(jié)。
5、插入數(shù)據(jù)
使用 INSERT 語(yǔ)句在已經(jīng)存在的表中插入數(shù)據(jù)。
示例:創(chuàng)建表 t1 并插入一行數(shù)據(jù)。
obclient [obdb1]> CREATE TABLE obt1(c1 INT PRIMARY KEY, c2 int) PARTITION BY KEY(c1) PARTITIONS 4;
Query OK, 0 rows affected (0.121 sec)obclient [obdb1]> SELECT * FROM obt1;
Empty set (0.065 sec)obclient [obdb1]> INSERT obt1 VALUES(1,1);
Query OK, 1 row affected (0.007 sec)obclient [obdb1]> SELECT * FROM obt1;
+----+------+
| c1 | c2 |
+----+------+
| 1 | 1 |
+----+------+
1 row in set (0.005 sec)obclient [obdb1]>
6、刪除數(shù)據(jù)
使用 DELETE 語(yǔ)句刪除數(shù)據(jù),支持單表刪除和多表刪除數(shù)據(jù)。
示例:
6.1 通過(guò) CREATE TABLE 創(chuàng)建表 t2 和 t3。刪除 c1=2 的行,其中 c1 列為表 t2 中的 PRIMARY KEY。
/表 t3 為 KEY 分區(qū)表,且分區(qū)名由系統(tǒng)根據(jù)分區(qū)命令規(guī)則自動(dòng)生成,即分區(qū)名為 p0、p1、p2、p3
/
obclient [obdb1]>
obclient [obdb1]> CREATE TABLE obt2(c1 INT PRIMARY KEY, c2 INT);
Query OK, 0 rows affected (0.095 sec)obclient [obdb1]> INSERT obt2 VALUES(1,1),(2,2),(3,3),(5,5);
Query OK, 4 rows affected (0.005 sec)
Records: 4 Duplicates: 0 Warnings: 0obclient [obdb1]> SELECT * FROM obt2;
+----+------+
| c1 | c2 |
+----+------+
| 1 | 1 |
| 2 | 2 |
| 3 | 3 |
| 5 | 5 |
+----+------+
4 rows in set (0.007 sec)obclient [obdb1]> CREATE TABLE obt3(c1 INT PRIMARY KEY, c2 INT) PARTITION BY KEY(c1) PARTITIONS 4;
Query OK, 0 rows affected (0.142 sec)obclient [obdb1]> INSERT INTO obt3 VALUES(5,5),(1,1),(2,2),(3,3);
Query OK, 4 rows affected (0.035 sec)
Records: 4 Duplicates: 0 Warnings: 0obclient [obdb1]> SELECT * FROM obt3;
+----+------+
| c1 | c2 |
+----+------+
| 5 | 5 |
| 1 | 1 |
| 2 | 2 |
| 3 | 3 |
+----+------+
4 rows in set (0.028 sec)obclient [obdb1]> DELETE FROM obt2 WHERE c1 = 2;
Query OK, 1 row affected (0.005 sec)obclient [obdb1]> SELECT * FROM obt2;
+----+------+
| c1 | c2 |
+----+------+
| 1 | 1 |
| 3 | 3 |
| 5 | 5 |
+----+------+
3 rows in set (0.003 sec)obclient [obdb1]>
6.2 刪除表 t2 中按照 c2 列排序之后的第一行數(shù)據(jù)。
obclient [obdb1]> SELECT * FROM obt2;
+----+------+
| c1 | c2 |
+----+------+
| 1 | 1 |
| 3 | 3 |
| 5 | 5 |
+----+------+
3 rows in set (0.003 sec)obclient [obdb1]> DELETE FROM obt2 ORDER BY c2 LIMIT 1;
Query OK, 1 row affected (0.005 sec)obclient [obdb1]> SELECT * FROM obt2;
+----+------+
| c1 | c2 |
+----+------+
| 3 | 3 |
| 5 | 5 |
+----+------+
2 rows in set (0.001 sec)obclient [obdb1]>
7、更新數(shù)據(jù)
使用 UPDATE 語(yǔ)句修改表中的字段值。
示例:通過(guò) CREATE TABLE 創(chuàng)建表 t4 和 t5,將表 t4 中 t4.c1=10 對(duì)應(yīng)的那一行數(shù)據(jù)的 c2 列值修改為 100。
obclient [obdb1]>
obclient [obdb1]> CREATE TABLE obt4(c1 INT PRIMARY KEY, c2 INT);
Query OK, 0 rows affected (0.113 sec)obclient [obdb1]> INSERT obt4 VALUES(10,10),(20,20),(30,30),(40,40);
Query OK, 4 rows affected (0.033 sec)
Records: 4 Duplicates: 0 Warnings: 0obclient [obdb1]> SELECT * FROM obt4;
+----+------+
| c1 | c2 |
+----+------+
| 10 | 10 |
| 20 | 20 |
| 30 | 30 |
| 40 | 40 |
+----+------+
4 rows in set (0.005 sec)obclient [obdb1]> CREATE TABLE obt5(c1 INT PRIMARY KEY, c2 INT) PARTITION BY KEY(c1) PARTITIONS 4;
Query OK, 0 rows affected (0.118 sec)obclient [obdb1]> INSERT obt5 VALUES(50,50),(10,10),(20,20),(30,30);
Query OK, 4 rows affected (0.025 sec)
Records: 4 Duplicates: 0 Warnings: 0obclient [obdb1]> SELECT * FROM obt5;
+----+------+
| c1 | c2 |
+----+------+
| 20 | 20 |
| 10 | 10 |
| 50 | 50 |
| 30 | 30 |
+----+------+
4 rows in set (0.015 sec)obclient [obdb1]> UPDATE obt4 SET obt4.c2 = 100 WHERE obt4.c1 = 10;
Query OK, 1 row affected (0.004 sec)
Rows matched: 1 Changed: 1 Warnings: 0obclient [obdb1]> SELECT * FROM obt4;
+----+------+
| c1 | c2 |
+----+------+
| 10 | 100 |
| 20 | 20 |
| 30 | 30 |
| 40 | 40 |
+----+------+
4 rows in set (0.003 sec)obclient [obdb1]>
8、查詢數(shù)據(jù)
使用 SELECT 語(yǔ)句查詢表中的內(nèi)容。
示例:
8.1 通過(guò) CREATE TABLE 創(chuàng)建表 t6。從表 t6 中讀取 name 的數(shù)據(jù)。
obclient [obdb1]>
obclient [obdb1]> CREATE TABLE obt6 (id INT, name VARCHAR(50), num INT);
Query OK, 0 rows affected (0.205 sec)obclient [obdb1]> INSERT INTO obt6 VALUES(1,'a',100),(2,'b',200),(3,'a',50);
Query OK, 3 rows affected (0.042 sec)
Records: 3 Duplicates: 0 Warnings: 0obclient [obdb1]> SELECT * FROM obt6;
+------+------+------+
| id | name | num |
+------+------+------+
| 1 | a | 100 |
| 2 | b | 200 |
| 3 | a | 50 |
+------+------+------+
3 rows in set (0.007 sec)obclient [obdb1]> SELECT name FROM obt6;
+------+
| name |
+------+
| a |
| b |
| a |
+------+
3 rows in set (0.003 sec)
9、在查詢結(jié)果中對(duì) name 進(jìn)行去重處理。
obclient [obdb1]> SELECT DISTINCT name FROM obt6;
+------+
| name |
+------+
| a |
| b |
+------+
2 rows in set (0.004 sec)obclient [obdb1]>
五、部署體驗(yàn)建議
熟悉文檔:在開(kāi)始體驗(yàn)之前,建議用戶仔細(xì)閱讀 OceanBase 官方文檔,了解 odb demo 的使用方法和注意事項(xiàng)。
多場(chǎng)景測(cè)試:為了更全面地了解 OceanBase 4.3 的性能和功能,建議用戶在不同的業(yè)務(wù)場(chǎng)景下進(jìn)行測(cè)試,如高并發(fā)讀寫、大數(shù)據(jù)量查詢等。
關(guān)注社區(qū):OceanBase 社區(qū)是一個(gè)活躍的開(kāi)發(fā)者社區(qū),用戶可以在其中交流經(jīng)驗(yàn)、尋求幫助、參與討論等。
總結(jié)
OceanBase 4.3 社區(qū)版以其強(qiáng)大的功能、優(yōu)秀的性能和易用性,為開(kāi)發(fā)者提供了一個(gè)高效的分布式數(shù)據(jù)庫(kù)解決方案。通過(guò) odb demo 命令快速體驗(yàn) OceanBase 4.3 社區(qū)版是一個(gè)便捷的方式,用戶可以在短時(shí)間內(nèi)了解該版本的各項(xiàng)功能和優(yōu)勢(shì)。無(wú)論是對(duì)于數(shù)據(jù)庫(kù)初學(xué)者還是專業(yè)開(kāi)發(fā)人員來(lái)說(shuō),這都是一個(gè)值得嘗試的體驗(yàn)過(guò)程。希望以上部署測(cè)試能對(duì)您有所幫助!