集群创建
本文介绍通过 ob-operator 创建 OceanBase 集群。
部署前准备
部署之前,您需要在 K8s 集群中部署好 ob-operator,请参考 部署 ob-operator, 并确保 K8s 集群有可用的 storage-class,推荐使用 local-path-provisioner
部署 OceanBase 数据库
创建 Namespace
创建部署 OceanBase 集群使用的 namespace。
kubectl create namespace oceanbase
创建默认用户的 Secret
创建 OceanBase 集群之前,您需要先创建好若干 secret 来存储 OceanBase 中的特定用户
kubectl create secret -n oceanbase generic root-password --from-literal=password='root_password'
定义 OceanBase 集群
OceanBase 集群可以通过 yaml 配置文件进行定义,您可参考如下配置文件作为基础按照实际进行需求进行修改。
apiVersion: oceanbase.oceanbase.com/v1alpha1
kind: OBCluster
metadata:
name: test
namespace: oceanbase
annotations:
"oceanbase.oceanbase.com/independent-pvc-lifecycle": "true"
# "oceanbase.oceanbase.com/mode": "standalone" 或 "service"
# "oceanbase.oceanbase.com/single-pvc": "true"
spec:
clusterName: obcluster
clusterId: 1
userSecrets:
root: root-password
topology:
- zone: zone1
replica: 1
# nodeSelector:
# k1: v1
# affinity:
# nodeAffinity:
# podAffinity:
# podAntiAffinity:
# tolerations:
# - key: "obtopo"
# value: "zone"
# effect: "NoSchedule"
- zone: zone2
replica: 1
- zone: zone3
replica: 1
observer:
image: oceanbase/oceanbase-cloud-native:4.2.0.0-101000032023091319
resource:
cpu: 2
memory: 10Gi
storage:
dataStorage:
storageClass: local-path
size: 50Gi
redoLogStorage:
storageClass: local-path
size: 50Gi
logStorage:
storageClass: local-path
size: 20Gi
monitor:
image: oceanbase/obagent:4.2.0-100000062023080210
resource:
cpu: 1
memory: 1Gi
# parameters:
# - name: system_memory
# value: 2G
# backupVolume:
# volume:
# name: backup
# nfs:
# server: 1.1.1.1
# path: /opt/nfs
# readOnly: false