OceanBase logo

OceanBase

A unified distributed database ready for your transactional, analytical, and AI workloads.

DEPLOY YOUR WAY

OceanBase Cloud

The best way to deploy and scale OceanBase

OceanBase Enterprise

Run and manage OceanBase on your infra

TRY OPEN SOURCE

OceanBase Community Edition

The free, open-source distributed database

OceanBase seekdb

Open source AI native search database

Customer Stories

Real-world success stories from enterprises across diverse industries.

View All
BY USE CASES

Mission-Critical Transactions

Global & Multicloud Application

Elastic Scaling for Peak Traffic

Real-time Analytics

Active Geo-redundancy

Database Consolidation

Resources

Comprehensive knowledge hub for OceanBase.

Blog

Live Demos

Training & Certification

Documentation

Official technical guides, tutorials, API references, and manuals for all OceanBase products.

View All
PRODUCTS

OceanBase Cloud

OceanBase Database

Tools

Connectors and Middleware

QUICK START

OceanBase Cloud

OceanBase Database

BEST PRACTICES

Practical guides for utilizing OceanBase more effectively and conveniently

Company

Learn more about OceanBase – our company, partnerships, and trust and security initiatives.

About OceanBase

Partner

Trust Center

Contact Us

International - English
中国站 - 简体中文
日本 - 日本語
Sign In
Start on Cloud

A unified distributed database ready for your transactional, analytical, and AI workloads.

DEPLOY YOUR WAY

OceanBase Cloud

The best way to deploy and scale OceanBase

OceanBase Enterprise

Run and manage OceanBase on your infra

TRY OPEN SOURCE

OceanBase Community Edition

The free, open-source distributed database

OceanBase seekdb

Open source AI native search database

Customer Stories

Real-world success stories from enterprises across diverse industries.

View All
BY USE CASES

Mission-Critical Transactions

Global & Multicloud Application

Elastic Scaling for Peak Traffic

Real-time Analytics

Active Geo-redundancy

Database Consolidation

Comprehensive knowledge hub for OceanBase.

Blog

Live Demos

Training & Certification

Documentation

Official technical guides, tutorials, API references, and manuals for all OceanBase products.

View All
PRODUCTS
OceanBase CloudOceanBase Database
ToolsConnectors and Middleware
QUICK START
OceanBase CloudOceanBase Database
BEST PRACTICES

Practical guides for utilizing OceanBase more effectively and conveniently

Learn more about OceanBase – our company, partnerships, and trust and security initiatives.

About OceanBase

Partner

Trust Center

Contact Us

Start on Cloud
编组
All Products
    • Databases
    • iconOceanBase Database
    • iconOceanBase Cloud
    • iconOceanBase Tugraph
    • iconInteractive Tutorials
    • iconOceanBase Best Practices
    • Tools
    • iconOceanBase Cloud Platform
    • iconOceanBase Migration Service
    • iconOceanBase Developer Center
    • iconOceanBase Migration Assessment
    • iconOceanBase Admin Tool
    • iconOceanBase Loader and Dumper
    • iconOceanBase Deployer
    • iconKubernetes operator for OceanBase
    • iconOceanBase Diagnostic Tool
    • iconOceanBase Binlog Service
    • Connectors and Middleware
    • iconOceanBase Database Proxy
    • iconEmbedded SQL in C for OceanBase
    • iconOceanBase Call Interface
    • iconOceanBase Connector/C
    • iconOceanBase Connector/J
    • iconOceanBase Connector/ODBC
    • iconOceanBase Connector/NET
icon

OceanBase Database

SQL - V4.0.0

  • Document overview
  • Overview
    • Overview
    • System architecture
    • Compatibility with MySQL
    • Limits
  • Get Started
    • Quick experience
    • Hands on for OceanBase SQL
      • Before you start
      • Basic SQL operations
    • Create a sample application
      • Connect to OceanBase Database by using a Python driver
      • Connect to OceanBase Database by using Go MySQL Driver
      • Connect a Java application to OceanBase Database
      • Connect a C application to OceanBase Database
    • Experience OceanBase advanced features
      • Experience scalable OLTP
        • Run the TPC-C benchmark test on OceanBase Database
        • Experience the hot row update capability of OceanBase Database
      • Experience operational OLAP
      • Experience parallel import and data compression
      • Experience the multitenancy feature
  • Develop
    • Connect to Oceanbase Database with client
      • Overview
      • Connect to OceanBase Database by using a MySQL client
      • Connect to OceanBase Database by using OBClient
      • Connect to OceanBase Database by using ODC
      • Connect Java applications to OceanBase Database
      • Connect to OceanBase Database by using Go MySQL Driver
      • Connect to OceanBase Database by using Unix ODBC
      • C application
        • OceanBase Connector/C
        • C API functions
        • Connect C applications to OceanBase Database
      • Connect Python applications to OceanBase Database
      • SpringBoot connection example
      • SpringBatch connection example
      • SpringJDBC connection example
      • SpringJPA connection example
      • Hibernate connection example
      • MyBatis connection example
      • Example of Database connection pool configuration
        • Overview of database connection pool configuration
        • Example of configuring a Tomcat connection pool
        • Example of configuring a C3P0 connection pool
        • Example of configuring a Proxool connection pool
        • Example of configuring a HiKariCP connection pool
        • Example of configuring a DBCP connection pool
        • CommonPool configuration example
        • Example of configuring a JDBC connection pool
    • Create and manage database objects
      • About DDL statements
      • View the currently connected database
      • Change the password of a user
      • Data type
        • General data types
        • Unsupported data types
      • Create and manage tables
        • About tables
        • Create a table
        • About auto-increment columns
        • About types of column constraints
        • About table structure modification
        • About table clearing
        • About table dropping
        • Flash back a dropped table
        • About table privileges
      • Create and manage partition tables
        • About partitioned tables
        • Create a partitioned table
        • Manage a partitioned table
        • Create a subpartitioned table
        • Manage a subpartitioned table
        • Partition routing
        • Indexes on partitioned tables
        • Suggestions on using partitioned tables
      • Create and manage indexes
        • About indexes
        • Create an index
        • Drop an index
      • Create and manage views
        • About views
        • Create a view
        • Modify a view
        • Delete a view
      • Create and manage sequences
        • About sequences
        • Create a sequence
        • Modify a sequence
        • Delete a sequence
    • Query
      • About queries
      • Single-table queries
      • Conditional queries
      • ORDER BY queries
      • GROUP BY queries
      • Use the LIMIT clause in queries
      • Query data from multiple tables
        • About multi-table join queries
        • INNER JOIN queries
        • OUTER JOIN queries
        • Subqueries
      • Use operators and functions in a query
        • Use arithmetic operators in queries
        • Use numerical functions in queries
        • Use string connectors in queries
        • Use string functions in queries
        • Use datetime functions in queries
        • Use type conversion functions in queries
        • Use aggregate functions in queries
        • Use NULL-related functions in queries
        • Use the CASE conditional operator in queries
        • Use the SELECT FOR UPDATE statement to lock query results
      • Execution plan
        • View an execution plan
        • Understand an execution plan
      • Use SQL hints in queries
      • Variables of query timeout
    • DML statements and transactions
      • DML statement
        • About DML statements
        • About the INSERT statement
        • UPDATE statements
        • About the DELETE statement
        • About the REPLACE INTO statement
      • Transactions
        • About transaction control statements
        • Start a transaction
        • Transaction savepoints
        • Commit a transaction
        • Roll back a transaction
        • About transaction timeout
    • Common errors and solutions
      • About error codes
      • Database connection error
      • About timeout
        • Idle session timeout
        • Transaction timeout errors
      • About user
        • Locked user
        • Incorrect user password
      • About table
        • Table already exists
        • Table does not exist
        • Invalid use of NULL value
      • About constraint
        • Unique key conflict
        • Foreign key conflict
      • About SQL commands
        • Data truncation
  • Deploy
    • Overview
    • On-premises deployment
      • Software and hardware requirements
      • Configuration before deployment
      • Deploy OceanBase Database online
      • Deploy OceanBase Database offline
    • Deploy OceanBase Database in a Kubernetes cluster
    • High availability deployment
      • Use Alibaba Otter to implement remote active-active disaster recovery
  • Migrate
    • Data Migration Overview
    • Migrate data from MySQL Database to OceanBase
      • Use Canal to synchronize MySQL data to OceanBase Database in real time
      • Use DataX to migrate MySQL data to OceanBase Database
      • Use DBCAT to migrate MySQL table schemas to OceanBase Database
      • Migrate MySQL table schemas to OceanBase Database by using mysqldump
      • Migrate MySQL table data to OceanBase Database by using mysqldump
    • Use OBDUMPER to export data from or OBLOADER to import data to OceanBase Database
    • Migrate data from CSV-file to OceanBase
      • Use DataX to load CSV data files to OceanBase Database
      • Use the LOAD DATA statement to load CSV data files to OceanBase Database
    • Migrate data from SQL files to OceanBase Database
    • Migrate data and resource units between tables
    • Migrate data from OceanBase Database to MySQL
      • Use Canal to synchronize OceanBase Database data to MySQL in real time

Download PDF

Document overview Overview System architecture Compatibility with MySQL Limits Quick experience Before you start Basic SQL operations Connect to OceanBase Database by using a Python driver Connect to OceanBase Database by using Go MySQL Driver Connect a Java application to OceanBase Database Connect a C application to OceanBase Database Experience operational OLAP Experience parallel import and data compression Experience the multitenancy feature Overview Connect to OceanBase Database by using a MySQL client Connect to OceanBase Database by using OBClient Connect to OceanBase Database by using ODC Connect Java applications to OceanBase Database Connect to OceanBase Database by using Go MySQL Driver Connect to OceanBase Database by using Unix ODBC Connect Python applications to OceanBase Database SpringBoot connection example SpringBatch connection example SpringJDBC connection example SpringJPA connection example Hibernate connection example MyBatis connection example About DDL statements View the currently connected database Change the password of a user About queries Single-table queries Conditional queries ORDER BY queries GROUP BY queries Use the LIMIT clause in queries Use SQL hints in queries Variables of query timeout About error codes Database connection error Overview Software and hardware requirements Configuration before deployment Deploy OceanBase Database online Deploy OceanBase Database offline Deploy OceanBase Database in a Kubernetes cluster Use Alibaba Otter to implement remote active-active disaster recovery Data Migration Overview Use Canal to synchronize MySQL data to OceanBase Database in real time Use DataX to migrate MySQL data to OceanBase Database Use DBCAT to migrate MySQL table schemas to OceanBase Database Migrate MySQL table schemas to OceanBase Database by using mysqldump Migrate MySQL table data to OceanBase Database by using mysqldump Use OBDUMPER to export data from or OBLOADER to import data to OceanBase Database Use DataX to load CSV data files to OceanBase Database Use the LOAD DATA statement to load CSV data files to OceanBase Database Migrate data from SQL files to OceanBase Database Migrate data and resource units between tables Use Canal to synchronize OceanBase Database data to MySQL in real time
OceanBase logo

The Unified Distributed Database for the AI Era.

Follow Us
Products
OceanBase CloudOceanBase EnterpriseOceanBase Community EditionOceanBase seekdb
Resources
DocsBlogLive DemosTraining & Certification
Company
About OceanBaseTrust CenterLegalPartnerContact Us
Follow Us

© OceanBase 2026. All rights reserved

Cloud Service AgreementPrivacy PolicySecurity
Contact Us
Document Feedback
  1. Documentation Center
  2. OceanBase Database
  3. SQL
  4. V4.0.0
iconOceanBase Database
SQL - V 4.0.0
SQL
KV
  • V 4.4.2
  • V 4.3.5
  • V 4.3.3
  • V 4.3.1
  • V 4.3.0
  • V 4.2.5
  • V 4.2.2
  • V 4.2.1
  • V 4.2.0
  • V 4.1.0
  • V 4.0.0
  • V 3.1.4 and earlier

Deploy OceanBase Database in a Kubernetes cluster

Last Updated:2024-01-30 09:06:13  Updated
share
What is on this page
Deploy ob-operator
Deploy ob-operator with Helm
Deploy ob-operator with configuration files
Deploy OceanBase Database
Preparations
Deploy local-path-provisioner
Deploy OceanBase Database
Deploy OceanBase Database Proxy (ODP)
Connect to OceanBase Database
Monitor OceanBase Database
Deploy Prometheus
Deploy Grafana

folded

share

This topic describes how to deploy OceanBase Database in a Kubernetes environment by using ob-operator. Currently, only Kubernetes version 1.23.6 is tested, and if you encounter any issues while deploying other versions, feel free to contact us.

The topic is divided into three parts:

  1. Deploy ob-operator
  2. Deploy OceanBase Database
  3. Monitor OceanBase Database

Deploy ob-operator

Using ob-operator can simplify the deployment and operation of OceanBase Database in a Kubernetes cluster. The following two ways are available to deploy ob-operator:

Deploy ob-operator with Helm

You can deploy ob-operator by running the following commands:

helm repo add ob-operator https://oceanbase.github.io/ob-operator/
helm install ob-operator ob-operator/ob-operator --namespace=oceanbase-system --create-namespace  --version=1.2.0

Deploy ob-operator with configuration files

You can deploy ob-operator with configuration files by running the following commands:

# deploy CRD
kubectl apply -f https://raw.githubusercontent.com/oceanbase/ob-operator/1.2.0_release/deploy/crd.yaml

# deploy ob-operator
kubectl apply -f https://raw.githubusercontent.com/oceanbase/ob-operator/1.2.0_release/deploy/operator.yaml

Customize ob-operator

If you need to customize ob-operator, download the configuration file by running the following commands:

# download the config file
wget https://raw.githubusercontent.com/oceanbase/ob-operator/1.2.0_release/deploy/crd.yaml
wget https://raw.githubusercontent.com/oceanbase/ob-operator/1.2.0_release/deploy/operator.yaml

After you modify the configuration file, deploy ob-operator by running the following commands:

# after making some modification
kubectl apply -f crd.yaml
kubectl apply -f operator.yaml

Deploy OceanBase Database

Preparations

Configure labels for Kubernetes nodes

ob-operator uses nodeSelector in the obcluster.yaml configuration file of OceanBase Database to determine the distribution of observer nodes. Therefore, you need to configure labels for the Kubernetes nodes first.

You can set the label for a node by running the following command:

kubectl label node <node_name> <label_key>=<label_value>

# for example
kubectl label node node1 ob.zone=zone1

Deploy local-path-provisioner

To deploy OceanBase Database by using ob-operator, create a Persistent Volume Claim (PVC) as storage. For optimal performance, local storage is recommended. This topic uses local-path-provisioner to manage PVC.

Use the following command to deploy local-path-provisioner:

kubectl apply -f https://raw.githubusercontent.com/rancher/local-path-provisioner/v0.0.24/deploy/local-path-storage.yaml

For more information, see local-path-provisioner.

Deploy OceanBase Database

The OceanBase cluster is defined in a YAML configuration file. You can customize the configuration file provided by ob-operator to suit your needs. Use the following command to download the obcluster.yaml configuration file for OceanBase Database:

wget https://raw.githubusercontent.com/oceanbase/ob-operator/1.2.0_release/deploy/obcluster.yaml

The sample content of the configuration file is shown below.

apiVersion: cloud.oceanbase.com/v1
kind: OBCluster
metadata:
  name: ob-test
  namespace: obcluster
spec:
  imageRepo: oceanbase/oceanbase-ce
  tag: 4.0.0.0-100000272022110114
  imageObagent: oceanbase/obagent:1.2.0
  clusterID: 1
  topology:
    - cluster: cn
      zone:
      - name: zone1
        region: region1
        nodeSelector:
          ob.zone: zone1
        replicas: 1
      - name: zone2
        region: region1
        nodeSelector:
          ob.zone: zone2
        replicas: 1
      - name: zone3
        region: region1
        nodeSelector:
          ob.zone: zone3
        replicas: 1
      parameters:
        - name: log_disk_size
          value: "40G"
  resources:
    cpu: 2
    memory: 10Gi
    storage:
      - name: data-file
        storageClassName: "local-path"
        size: 50Gi
      - name: data-log
        storageClassName: "local-path"
        size: 50Gi
      - name: log
        storageClassName: "local-path"
        size: 30Gi
      - name: obagent-conf-file
        storageClassName: "local-path"
        size: 1Gi
    volume:
        name: backup
        nfs:
          server: ${nfs_server_address}
          path: /opt/nfs
          readOnly: false

Parameters in the sample content are described as follows:

  • imageRepo: The image repository of OceanBase Database.

  • tag: The tag of the OceanBase image.

  • imageObagent: The image of OBAgent, which is used to collect monitoring data for the OceanBase cluster.

  • cluster: To deploy an OceanBase cluster in a Kubernetes cluster, set the value of this parameter to the same as that of the startup parameter --cluster-name of ob-operator.

  • parameters: The custom parameters of OceanBase Database. Specify the parameters as needed.

  • cpu: The number of pod CPU cores. We recommend that you set the value to an integer greater than 2. A value smaller than 2 may cause system exceptions.

  • memory: The pod memory size. We recommend that you set the value to an integer greater than 10 GiB. A value smaller than 10 GiB may cause system exceptions.

  • data-file: The data storage configuration of OceanBase Database. You can specify the size and storageClassName to use as the data directory for OceanBase Database. We recommend that you configure a value at least 3 times the size of memory or larger.

  • data-log: The log storage configuration of OceanBase Database. You can specify the size and storageClassName to use as the Clog directory for OceanBase Database. We recommend that you configure a value at least 3 times the size of memory or larger.

  • log: The process log storage configuration of OceanBase Database. You can specify the size and storageClassName to use as the directory for storing process logs for OceanBase Database. We recommend that you configure a value of at least 10Gi or larger.

  • obagent-conf-file: The storage configuration of OBAgent configuration files, which is used to store OBAgent configuration files. A smaller size, generally around 1Gi, is sufficient.

  • volume: The storage for backup data. If no backup requirement exists, this can be left unconfigured. However, once the cluster is created, it cannot be added later, so we recommend that you plan for this before deployment.

After you modify the configuration file, run the following command to deploy the cluster:

kubectl apply -f obcluster.yaml

Deploy OceanBase Database Proxy (ODP)

ODP is defined by using yaml configuration files. You can customize these files by referring to the configuration files of ob-operator. To download the ODP configuration files, run the following command:

wget https://raw.githubusercontent.com/oceanbase/ob-operator/1.2.0_release/deploy/obproxy/deployment.yaml
wget https://raw.githubusercontent.com/oceanbase/ob-operator/1.2.0_release/deploy/obproxy/service.yaml

The sample content of the deployment.yaml file is shown below.

# deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: obproxy
  namespace: obcluster
spec:
  selector:
    matchLabels:
      app: obproxy
  replicas: 2
  template:
    metadata:
      labels:
        app: obproxy
    spec:
      containers:
        - name: obproxy
          image: oceanbase/obproxy-ce:4.0.0-5
          ports:
            - containerPort: 2883
              name: "sql"
            - containerPort: 2884
              name: "prometheus"
          env:
            - name: APP_NAME
              value: helloworld
            - name: OB_CLUSTER
              value: ob-test
            - name: RS_LIST
              value: $RS_LIST
          resources:
            limits:
              memory: 2Gi
              cpu: "1"

Parameters in the sample content are described as follows:

  • APP_NAME: The name of the ODP application.

  • OB_CLUSTER: The name of the OceanBase cluster that the ODP connects to.

  • RS_LIST: The rs_list of the OceanBase cluster, which has the format ${ip1}:${port1};${ip2}:${port2};${ip3}:${port3}. Replace values in this format with actual ones. The following two ways are available to obtain the address of rs_list:

    • Method 1: Connect to the OceanBase cluster and run the s show parameters like 'rootservice_list'; command to view it.

    • Method 2: Use the kubectl get RootService rs-${cluster_name} -n ${namespace} -o yaml command to query all Root Service addresses, and then concatenate them into a complete rs_list. Replace ${cluster_name} and ${namespace} with the actual OceanBase cluster name and namespace.

The service.yaml file opens two ports: one for SQL connection and the other for monitoring data collection. Here is what the service.yaml file contains:

# service.yaml
apiVersion: v1
kind: Service
metadata:
  name: obproxy-service
  namespace: obcluster
spec:
  type: NodePort
  selector:
    app: obproxy
  ports:
    - name: "sql"
      port: 2883
      targetPort: 2883
      nodePort: 30083
    - name: "prometheus"
      port: 2884
      targetPort: 2884
      nodePort: 30084

After you modify the configuration file, run the following commands for deployment:

kubectl apply -f deployment.yaml
kubectl apply -f service.yaml

Connect to OceanBase Database

We recommend that you connect to OceanBase Database through ODP. After you deploy OceanBase Database and ODP, run the following command to obtain the service connection address of ODP:

kubectl get svc ${servicename} -n ${namespace}

# for example
kubectl get svc obproxy-service -n obcluster

# output
NAME              TYPE       CLUSTER-IP      EXTERNAL-IP   PORT(S)                         AGE
obproxy-service   NodePort   xxx.xxx.xxx.xxx   <none>        2883:30083/TCP,2884:30084/TCP   1m

You can make a connection using CLUSTER-IP and PORT. The corresponding connection commands are as follows:

# use clusterip without password
obclient -hxxx.xxx.xxx.xxx -P2883 -uroot@sys oceanbase -A -c

# use clusterip with password
obclient -hxxx.xxx.xxx.xxx -P2883 -uroot@sys -p oceanbase -A -c

# using nodeport without password
obclient -h<node_ip> -P30083 -uroot@sys oceanbase -A -c

# using nodeport with password
obclient -h<node_ip> -P30083 -uroot@sys -p oceanbase -A -c

Monitor OceanBase Database

Deploy Prometheus

Download the Prometheus configuration files by running the following command and customize them by referring to the Prometheus configuration files provided by ob-operator:

wget https://raw.githubusercontent.com/oceanbase/ob-operator/1.2.0_release/deploy/prometheus/cluster-role.yaml
wget https://raw.githubusercontent.com/oceanbase/ob-operator/1.2.0_release/deploy/prometheus/cluster-role-binding.yaml
wget https://raw.githubusercontent.com/oceanbase/ob-operator/1.2.0_release/deploy/prometheus/configmap.yaml
wget https://raw.githubusercontent.com/oceanbase/ob-operator/1.2.0_release/deploy/prometheus/deployment.yaml
wget https://raw.githubusercontent.com/oceanbase/ob-operator/1.2.0_release/deploy/prometheus/service.yaml

Prometheus selects the address for collecting data based on the name and port of the service in Kubernetes. You can configure filtering for data collection using regular expressions, as shown in the configuration in the configmap.yaml file:

# Configurations in configmap.yaml
scrape_configs:
  - job_name: 'obagent-monitor-basic'
    kubernetes_sd_configs:
      - role: endpoints
    metrics_path: '/metrics/ob/basic'
    relabel_configs:
    - source_labels: [__meta_kubernetes_endpoints_name,__meta_kubernetes_endpoint_port_name]
      regex: svc-monitor-ob-test;monagent
      action: keep
  - job_name: 'obagent-monitor-extra'
    kubernetes_sd_configs:
      - role: endpoints
    metrics_path: '/metrics/ob/extra'
    relabel_configs:
    - source_labels: [__meta_kubernetes_service_name, __meta_kubernetes_pod_container_port_name]
      regex: svc-monitor-ob-test;monagent
      action: keep
  - job_name: 'obagent-monitor-host'
    kubernetes_sd_configs:
      - role: endpoints
    metrics_path: '/metrics/node/host'
    relabel_configs:
    - source_labels: [__meta_kubernetes_endpoints_name,__meta_kubernetes_endpoint_port_name]
      regex: svc-monitor-ob-test;monagent
      action: keep
  - job_name: 'proxy-monitor'
    kubernetes_sd_configs:
      - role: endpoints
    metrics_path: '/metrics'
    relabel_configs:
    - source_labels: [__meta_kubernetes_endpoints_name,__meta_kubernetes_endpoint_port_name]
      regex: obproxy-service;prometheus
      action: keep

The configurations are described as follows:

  • Service and port:

    • OceanBase: ob-operator creates a service based on the OceanBase cluster name to obtain the exporter address. The naming rule for the service is svc-monitor-${obcluster_name}, and the port name is monagent. If you customized the cluster name during deployment, modify the relevant configuration according to the actual cluster name.

    • ODP: You need to configure the corresponding ODP service and port name.

  • Request path for monitoring metrics:

    • OceanBase cluster: The request paths are /metrics/ob/basic and /metrics/ob/extra.

    • ODP cluster: ODP supports the ability to expose monitoring metrics using the Prometheus protocol, and the request path is /metrics.

After you modify the configuration file, deploy it by running the following command:

kubectl apply -f cluster-role.yaml
kubectl apply -f cluster-role-binding.yaml
kubectl apply -f configmap.yaml
kubectl apply -f deployment.yaml
kubectl apply -f service.yaml

Verification

Open the Prometheus address in a browser and navigate to Status > Targets to verify that the Endpoint under proxy-monitor, obagent-monitor-host, obagent-monitor-basic, and obagent-monitor-extra are all in the up state.

Click on Graph to enter PromQL expressions and perform queries.

Deploy Grafana

Download the Grafana configuration files by running the following command and customize them by referring to the Prometheus configuration files provided by ob-operator:

wget https://raw.githubusercontent.com/oceanbase/ob-operator/1.2.0_release/deploy/grafana/configmap.yaml
wget https://raw.githubusercontent.com/oceanbase/ob-operator/1.2.0_release/deploy/grafana/pvc.yaml
wget https://raw.githubusercontent.com/oceanbase/ob-operator/1.2.0_release/deploy/grafana/deployment.yaml
wget https://raw.githubusercontent.com/oceanbase/ob-operator/1.2.0_release/deploy/grafana/service.yaml

The configmap.yaml file contains key configuration information about Grafana, including the address of the Prometheus data source. If Prometheus was customized during deployment, you need to configure the actual service address.

# Key configurations in configmap.yaml
apiVersion: v1
kind: ConfigMap
metadata:
  name: grafana-datasources
  namespace: obcluster
data:
  prometheus.yaml: |-
    {
        "apiVersion": 1,
        "datasources": [
            {
               "access":"proxy",
                "editable": true,
                "name": "prometheus",
                "orgId": 1,
                "type": "prometheus",
                "url": "http://svc-prometheus.obcluster.svc:8080",
                "version": 1,
                "isDefault": true
            }
        ]
    }

The Grafana configuration uses the service address of Prometheus as the data source configuration (url field in datasources). You need to fill this in according to the actual deployment of Prometheus.

After you modify the configuration file, deploy it by running the following command:

kubectl apply -f configmap.yaml
kubectl apply -f pvc.yaml
kubectl apply -f deployment.yaml
kubectl apply -f service.yaml

Verification

Open the Grafana address in a browser and log on with the admin user. The default password is also admin, and you will be prompted to change it the first time you log on. The Grafana configuration includes the OceanBase Database dashboard by default, which you can view by opening the following link in a browser:

http://${node_ip}:${node_port}/d/oceanbase

You can view the host metrics and ODP monitoring templates by adding the following dashboard IDs.

  • Host: 15216

  • ODP: 15354

Note

ODP monitoring data will only be displayed after actual requests are sent.

Previous topic

Deploy OceanBase Database offline
Last

Next topic

Use Alibaba Otter to implement remote active-active disaster recovery
Next
What is on this page
Deploy ob-operator
Deploy ob-operator with Helm
Deploy ob-operator with configuration files
Deploy OceanBase Database
Preparations
Deploy local-path-provisioner
Deploy OceanBase Database
Deploy OceanBase Database Proxy (ODP)
Connect to OceanBase Database
Monitor OceanBase Database
Deploy Prometheus
Deploy Grafana