In Part 1 I got OB running in Docker and poked around the sys tenant — enough to say “it boots.” But sys is the system tenant, not where your business data belongs. To actually use this thing you have to understand OB’s multi-tenancy and resource model, which is where it diverges most from the standalone databases I knew. So this post covers: how to create a real tenant, how clients connect, and how data actually gets spread across nodes.

Still learning notes, not an official manual. The tenant-creation commands are marked “check against your own environment,” because in a MINI_MODE single-node setup the zone names and available resources may differ from mine — run SHOW ZONES; before copying anything.


1. The three-layer model: tenant / resource pool / Unit

I assumed “connect to the database, create a schema, start working.” Reality corrected me — resources in OB are managed in layers:

  • Unit (resource unit): describes “how much resource this tenant gets on one OBServer” — CPU, memory, log disk size. Think of it as a lightweight virtual container.
  • Resource Pool: made of one or more Units of the same spec, bound to specified Zones, then handed to a tenant as a whole.
  • Tenant: the standalone database instance your application actually uses, in either MySQL or Oracle mode, drawing resources from the pools it owns.

So the chain is Cluster → Tenant → Database → Table, with Unit / Pool being the vehicle for “how resources get sliced up and handed out.” The correct order for creating a tenant is Unit first, then Pool, then Tenant — skipping the first two and going straight to CREATE TENANT fails. That was my first stumble, and it’s not just my experience: the docs state that RESOURCE_POOL_LIST is mandatory when creating a tenant, so resource planning has to happen first.

Drawing the layers out — together with OBProxy routing below — made it click much faster:

Multi-tenancy and OBProxy routing

Tenants are isolated from each other; the app only talks to OBProxy, which routes each SQL to the right leader replica.


2. Hands-on: creating a MySQL tenant

Below is a local single-node (MINI_MODE) example. Start by confirming your zone names and resource usage — don’t copy my zone1 blindly:

SHOW ZONES;
-- or for more detail
SELECT * FROM oceanbase.DBA_OB_ZONES;
SELECT * FROM oceanbase.DBA_OB_UNITS;

Step one, define a Unit spec (MINI_MODE has limited memory, so keep it small):

CREATE RESOURCE UNIT unit_s1
  MAX_CPU 1,
  MEMORY_SIZE '1G',
  MAX_IOPS 1000,
  MIN_IOPS 1000,
  LOG_DISK_SIZE '2G';

Step two, build a Resource Pool from that Unit, saying which zone it lands in:

CREATE RESOURCE POOL pool_mysql
  UNIT='unit_s1',
  UNIT_NUM=1,
  ZONE_LIST=('zone1');   -- use the actual zone name from SHOW ZONES

Step three, create the tenant, attach the pool, and declare the compatibility mode plus allowed client IPs:

CREATE TENANT mysql_tenant
  RESOURCE_POOL_LIST=('pool_mysql'),
  PRIMARY_ZONE='zone1',
  LOCALITY='F@zone1'
  SET OB_COMPATIBILITY_MODE='MYSQL',
      OB_TCP_INVITED_NODES='%';

PRIMARY_ZONE and LOCALITY get their own section in Part 3; for now just fill in your zone name. OB_TCP_INVITED_NODES='%' opens up the connection allowlist — leave it out and external clients simply cannot connect. That was my second stumble. (If you don’t specify it at all, the default is that only the local machine’s IP may connect.)

Once it exists, connect as that tenant using the user@tenant form:

obclient -h127.0.0.1 -P2881 -uroot@mysql_tenant -A

The initial root has no password — change it. After that you can create databases and tables and write data much like ordinary MySQL:

CREATE DATABASE shop;
USE shop;
CREATE TABLE item (id BIGINT PRIMARY KEY, name VARCHAR(64));
INSERT INTO item VALUES (1, 'keyboard');

3. How clients connect: direct vs OBProxy

For a single-node playground, connecting straight to the observer’s 2881 is easiest. In production you should put OBProxy (also called ODP, OceanBase Database Proxy) in front.

OBProxy is a separate access-layer process that speaks the MySQL protocol. Its job: discover data distribution automatically and route each SQL to the OBServer holding the relevant leader replica, while handling connection management and load balancing. From the application’s point of view there is exactly one address to connect to, and it never has to know which node holds the data.

Why do you need it in a distributed setup? Because the data is scattered across machines. Connect directly to one observer and any SQL touching data that lives elsewhere has to be served by a remote or distributed plan that reaches out to other nodes — OBProxy spares you that by routing and reusing connections up front.

If you want to try OBProxy locally, there’s a community image (check the version and port of whatever you pull; the default proxy port is usually 2883):

docker run -p 2883:2883 -d oceanbase/obproxy-ce
# then point your app at 2883; the user@tenant form is unchanged
obclient -h127.0.0.1 -P2883 -uroot@mysql_tenant -A

In production you run several OBProxy instances with a load balancer in front, so the proxy itself isn’t a single point of failure.


4. Partitioned tables: how data gets “spread out”

This is the entry point to distributed SQL. In a standalone database a table is basically one object; in OB a table is split into partitions, each partition maps to a Tablet, and the Tablet is the smallest unit of distribution, replication and balancing.

Common partitioning styles are Range, Hash, List and Key, and they can be combined. It matters for two reasons:

  • Horizontal scale: even a huge table can be split and spread across OBServers in different Zones instead of hitting a single machine’s ceiling.
  • Partition pruning: a query can scan only the relevant Tablets instead of the whole table.

For example, hash-partition by user id into 8 partitions:

CREATE TABLE orders (
  id BIGINT,
  user_id BIGINT,
  amount DECIMAL(10,2),
  PRIMARY KEY(id)
) PARTITION BY HASH(user_id) PARTITIONS 8;

I used to think “just write the CREATE TABLE like MySQL and move on.” What I missed: the partitioning strategy decides how data is distributed, how hot spots get spread, and whether queries can prune. Pick badly and “distributed” ends up slower than a single box. This deserves its own study session.


5. Wrap-up & what’s next

  • OB’s resource model is Cluster → Tenant → Database → Table, with Unit / Pool as the resource vehicle; creating a tenant is a Unit → Pool → Tenant sequence, and it won’t work without a pool.
  • In production, connect through OBProxy and let the app know just one address.
  • Partitioned tables are the basis of data distribution; the strategy directly shapes performance and scalability.

Next: high availability and elasticity — Paxos majority and the lease that prevents split-brain, how locality / primary_zone decide replica placement and where leaders live, what happens when you scale out, and what actually happens when a Zone dies. That maps directly onto the disaster-recovery logic I care about most on our K8s setup.

References: