This topic describes how to upgrade OCP using Docker containers.
Prerequisites
Docker is installed on the host where OCP is deployed, and the docker command can be found in the system's PATH. Currently, OCP is not compatible with podman-docker. For instructions on how to install Docker, see Install Docker.
Stop the OCP service
Before upgrading OCP, you must stop the OCP service. The method for stopping the OCP service varies depending on the deployment method.
Stop the OCP container
If the OCP to be upgraded is deployed using a container, you can run the following command to stop the container:
docker kill ${container_name}
Stop the ocp process
If the OCP to be upgraded is deployed using an RPM package, you can run the following command to stop the ocp process:
# find ocp process
ps -ef | grep ocp
# kill ocp process
kill -9 ${pid_of_OCP}
Start the OCP container
Start the new version of OCP container using the original OCP MetaDB to complete the upgrade.
Notice
The container name for OCP after the upgrade cannot be the same as the container name before the upgrade. Otherwise, the container cannot be started.
Run the following command 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_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_CONFIG_PROPERTIES="${OCP_CONFIG_PROPERTIES}" \
oceanbase/ocp-ce:4.2.1
The environment variables in the command are described in the following table.
| Environment 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 allocated to the OCP container (in GiB). For more information, see Host planning. |
| OCP_METADB_HOST | OCP MetaDB connection address. |
| OCP_METADB_PORT | OCP MetaDB connection port. |
| OCP_METADB_DBNAME | OCP MetaDB database name. |
| OCP_METADB_USER | OCP MetaDB username. If the OBServer node is directly connected, use the user@tenant format. If the OBServer node is connected through OBProxy, use the user@tenant#cluster format. |
| OCP_METADB_PASSWORD | OCP MetaDB user password. |
| OCP_MONITORDB_DBNAME | OCP MonitorDB database name. |
| OCP_MONITORDB_USER | OCP MonitorDB username. 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_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 upgrade 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.logCheck the version number of OCP to check whether OCP has been upgraded as expected.