This topic describes how to deploy OceanBase Cloud Platform (OCP) Community Edition by using Docker.
Prerequisites
You have created two connections to OceanBase Database in MySQL mode. We recommend that you use two tenants to store metadata and monitoring data respectively.
For more information about how to create an OceanBase cluster, see Deploy a cluster. For more information about how to create an OceanBase Database tenant, see Create a tenant.
You have installed Docker on the host where OCP is deployed, and docker commands can be found in the PATH system variable. OCP is not compatible with podman-docker. For more information about how to install Docker, see Install Docker.
The deployment user has permissions to run docker commands.
Pull an OCP image
Before you deploy OCP, you need to pull an OCP image to your local environment.
Online environment If your deployment environment can access Docker Hub, you can run the following command to pull the OCP image:
docker pull oceanbase/ocp-ce:4.2.2Offline environment If your deployment environment cannot access Docker Hub, you need to pull the image to a host that can, and then import the image to your deployment environment. Here is sample code:
# execute at a host being able to access dockerhub docker pull oceanbase/ocp-ce:4.2.2 docker save -o ocp-ce.tar oceanbase/ocp-ce:4.2.2 scp ocp-ce.tar ${user}@${target}:/tmp/ # execute at target host docker load < /tmp/ocp-ce.tar
Run the following command to check whether the image has been pulled or imported to your deployment environment. The result shown in the following figure indicates a successful pull or import.
docker images | grep ocp-ce

Start the OCP container
Run the following commands to start the OCP container:
## set environment parameters
export OCP_CPU_COUNT=4
export OCP_MEMORY_GB=8
export OCP_METADB_HOST=xxx.xxx.xxx.xxx # do not use 127.0.0.1 or localhsot
export OCP_METADB_PORT=2881
export OCP_METADB_USER=root@ocp_meta
export OCP_METADB_PASSWORD=ocp_meta_password
export OCP_METADB_DBNAME=ocp_meta
export OCP_MONITORDB_USER=root@ocp_monitor
export OCP_MONITORDB_PASSWORD=ocp_monitor_password
export OCP_MONITORDB_DBNAME=ocp_monitor
export OCP_INITIAL_ADMIN_PASSWORD=****** #should match ocp's password validation
export OCP_CONFIG_PROPERTIES=`cat << EOF
server.port:8080
ocp.site.url:http://xxx.xxx.xxx.xxx:8080
obsdk.ob.connection.mode:direct
EOF
`
# start ocp container
docker run -d --name ocp-421 \
--network host \
--cpu-period 100000 --cpu-quota ${OCP_CPU_COUNT}00000 --memory=${OCP_MEMORY_GB}G \
-e OCP_METADB_HOST="${OCP_METADB_HOST}" \
-e OCP_METADB_PORT="${OCP_METADB_PORT}" \
-e OCP_METADB_DBNAME="${OCP_METADB_DBNAME}" \
-e OCP_METADB_USER="${OCP_METADB_USER}" \
-e OCP_METADB_PASSWORD="${OCP_METADB_PASSWORD}" \
-e OCP_MONITORDB_DBNAME="${OCP_MONITORDB_DBNAME}" \
-e OCP_MONITORDB_USER="${OCP_MONITORDB_USER}" \
-e OCP_MONITORDB_PASSWORD="${OCP_MONITORDB_PASSWORD}" \
-e OCP_INITIAL_ADMIN_PASSWORD="${OCP_INITIAL_ADMIN_PASSWORD}" \
-e OCP_CONFIG_PROPERTIES="${OCP_CONFIG_PROPERTIES}" \
oceanbase/ocp-ce:4.2.1
The following table describes the environment variables:
| Variable | Description |
|---|---|
| OCP_CPU_COUNT | The number of CPU cores allocated to the OCP container. For more information, see Host planning. |
| OCP_MEMORY_GB | The size of memory, in GiB, allocated to the OCP container. For more information, see Host planning. |
| OCP_METADB_HOST | The IP address of OCP MetaDB. |
| OCP_METADB_PORT | The port number of OCP MetaDB. |
| OCP_METADB_DBNAME | The name of OCP MetaDB. |
| OCP_METADB_USER | The username of the OCP MetaDB user. If the OBServer node is directly connected, you can specify the username in the user@tenant format. If the OBServer node is connected through OBProxy, you can specify the username in the user@tenant#cluster format. |
| OCP_METADB_PASSWORD | The password of the OCP MetaDB user. |
| OCP_MONITORDB_DBNAME | The name of OCP MonitorDB. |
| OCP_MONITORDB_USER | The username of the OCP MonitorDB user. If the OBServer node is directly connected, you can specify the username in the user@tenant format. If the OBServer node is connected through OBProxy, you can specify the username in the user@tenant#cluster format. |
| OCP_MONITORDB_PASSWORD | The password of the OCP MonitorDB user. |
| OCP_INITIAL_ADMIN_PASSWORD | The logon password of the OCP admin user. The password must meet the following requirements:~!@#%^&*_-+=|(){}[]:;,.?/$`'"<>\). |
| OCP_CONFIG_PROPERTIES | The system parameters of OCP. Specify one parameter in each row and separate the name and value of a parameter with a colon (:). |
Check the OCP deployment result
After the OCP container is started, you need to wait about 2 minutes for OCP to initialize MetaDB and start the service. If the logon page appears after you visit the URL of the OCP console in a browser, the service is started.
If the OCP service fails to be started after a long time, you can view the logs to check the status of OCP.
# use the following command to log into ocp container
docker exec -it ocp-421 bash
# check ocp bootstrap log
less /home/admin/logs/ocp/bootstrap.log
# check ocp runtime log
less /home/admin/logs/ocp/ocp.log