Upgrade single-node ODC

2024-11-11 10:40:33  Updated

Stop ODC of the earlier version

To upgrade single-node OceanBase Developer Center (ODC), you must stop ODC of the earlier version after you update the MetaDB.

  1. Run the docker ps -a command in the command-line tool of the host to view the running containers.

    You can find the container ID of the earlier image in the CONTAINER ID column based on the image name in the IMAGE column. The result is as follows:

    C:\Users\ob>docker ps -a
    CONTAINER ID        IMAGE                                      COMMAND                  CREATED             STATUS              PORTS                                      NAMES
    8bfecbc1cd03        acs-reg.alipay.com/oceanbase/obodc:2.0.1   "/bin/sh -c '/usr/bi..."   13 days ago         Up 13 days          80/tcp, 8080/tcp, x.x.x.x:8989->8989/tcp   obodc
    
  2. After you obtain the container ID, run the docker stop <CONTAINER ID>; command in the command-line tool to stop the ODC container of the earlier version.

    The result is as follows:

    C:\Users\ob>docker stop 8bfecbc1cd03
    8bfecbc1cd03
    
  3. Run the docker rm <CONTAINER ID>; command in the command-line tool to delete the ODC image of the earlier version and release the port occupied.

    The result is as follows:

    C:\Users\ob>docker rm 8bfecbc1cd03
    8bfecbc1cd03
    

Back up the MetaDB

Notice

Before you upgrade ODC, back up the MetaDB. When the upgrade fails, you can roll back ODC by using the backup of MetaDB.

Example: Create ~/odcmetadb_backup as the backup path for the MetaDB and back up the MetaDB of ODC.

#create backup directory
mkdir -p ~/odcmetadb_backup

#backup odc metadb
./obdumper --thread 1 -h <host> -P <port> -u <username> -c <cluster_name> -t <tenant_name> -D <database_name> --ddl --csv --no-sys --all -f ~/odcmetadb_backup

Note

For information about backup options, see Command-line options of OBDUMPER.

Load and run an ODC image

When you upgrade ODC deployed in single-node mode, you need to load and run the ODC image again after you update the MetaDB and stop the ODC container of the earlier version.

Load the image

Notice

  • Images of ODC V4.2.0 and later have been released in Docker Hub. If the server where ODC runs can access Docker Hub, you do not need to download an image and can directly start ODC Docker. For more information, see the "Run the image" section in this topic.
  • If the server where ODC runs cannot access Docker Hub, you need to download and load the image file.
  1. To obtain the ODC image on the host, select the required image from the Maintenance Tools of the OceanBase Download Center.

  2. After you obtain the image, run the following command in the command-line tool to load it:

    gunzip -c obodc-{$version}.tar.gz | docker load
    

Run the image

Run a command in the command-line tool on the host to run the obtained ODC image. The sample command is as follows:

#!/usr/bin/env bash
docker run -v /var/log/odc:/opt/odc/log -v /var/data/odc:/opt/odc/data \
-d -i --net host --cpu-period 100000 --cpu-quota 400000 --memory 8G --name "obodc" \
-e "DATABASE_HOST=xxx.xx.xx.xx" \
-e "DATABASE_PORT=60805" \
-e "DATABASE_USERNAME=[username]@[tenant name]#[cluster name]" \
-e "DATABASE_PASSWORD=******" \
-e "DATABASE_NAME=odc_metadb" \
-e "ODC_PROFILE_MODE=alipay" \
-e "ODC_ADMIN_INITIAL_PASSWORD=******" \
oceanbase/odc:4.2.2

Notice

In the Shell environment, you must enclose a string that contains special characters such as ! and $ with single quotation marks ('), for example, DATABASE_PASSWORD='11111!'.

The following table describes the parameters.

Parameter Description
-v
  • Maps the /var/log/odc directory of the host to the /opt/odc/log directory in the ODC container. If the /var/log/odc directory does not exist on the host, run the mkdir -p /var/log/odc command to create one.
  • Maps the /var/data/odc directory of the host to the /opt/odc/data directory in the ODC container. If the /var/data/odc directory does not exist on the host, run the mkdir -p /var/data/odc command to create one.
--net The network configuration of the Docker container. If you set this parameter to host, the host network is directly used. You can also use the --publish (-p) parameter to configure port mapping. However, the Docker container may fail to start in some environments due to internal DNS resolution errors. In this case, specify --net host in the command to start the Docker container.
--cpu-period --cpu-quota
  • The ---cpu-period parameter specifies the interval at which the CPU cores of the Docker container are reallocated. Unit: μs.
  • The ---cpu-quota parameter specifies the maximum time for running the current Docker container in this interval. Unit: μs.
  • You can use these two parameters in combination to specify the number of CPU cores that the Docker container uses. The value is calculated by dividing cpu-quota by cpu-period. In the preceding sample statement, the values of cpu-quota and cpu-period are respectively 400000 and 100000. Therefore, the resulting value is 4, indicating that the Docker container can use at most four CPU cores.
    --memory The maximum memory size for the Docker container.
    --name The name of the container.
    DATABASE_HOST The IP address of the MetaDB.
    DATABASE_PORT The port number of the MetaDB.
    DATABASE_USERNAME The username of the MetaDB. In OceanBase Database, the username is in the format of db_user@tenant_name#cluster_name.
    DATABASE_PASSWORD The password used to connect to the database.
    DATABASE_NAME The name of the MetaDB.
    ODC_PROFILE_MODE The profile mode. Default value: alipay.
    ODC_ADMIN_INITIAL_PASSWORD The initial password of the administrator account of ODC.

    Notice

    The initial password must meet the following requirements:

    • Contains at least two digits.
    • Contains at least two uppercase letters.
    • Contains at least two lowercase letters.
    • Contains at least two special characters, which can be . _ + @ # $ %
    • Contains 8 to 32 characters without spaces or other special characters.

    In addition to the preceding parameters, you can also use the following parameters when running the image.

    Parameter Description
    ODC_LOG_DIR The log directory. Default value: /opt/odc/log.
    ODC_JVM_HEAP_OPTIONS The JVM heap size configurations. Default value: -XX:MaxRAMPercentage=60.0 -XX:InitialRAMPercentage=60.0, indicating that the JVM heap size is 60% of the total memory. You can also directly specify the JVM heap size by setting the ODC_JVM_HEAP_OPTIONS parameter. For example, -Xmx2048m -Xms2048m indicates that the heap size is 2 GB.
    ODC_JVM_GC_OPTIONS The garbage collection strategy for JVM. Default value: -XX:+UseG1GC -XX:+PrintAdaptiveSizePolicy -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+PrintGCDateStamps -Xloggc:/opt/odc/log/gc.log -XX:+UseGCLogFileRotation -XX:GCLogFileSize=50M -XX:NumberOfGCLogFiles=5.
    ODC_JVM_OOM_OPTIONS The OutOfMemory strategy for JVM. Default value: -XX:+ExitOnOutOfMemoryError.
    ODC_JVM_EXTRA_OPTIONS Other JVM parameters. By default, no other parameter is specified.
    ODC_SERVER_PORT The HTTP listening port for ODC-Server. Default value: 8989.
    ODC_HOST The IP address of ODC, which can be used as the destination IP address for remote procedure calls in high-availability deployment scenarios.
    ODC_MAPPING_PORT The port number of ODC, which is specified to avoid port unavailability due to the deployment environment. This parameter is applicable to port mapping when ODC is deployed in Docker.
    ODC_APP_EXTRA_ARGS Other app parameters.
    For example, --server.servlet.session.timeout=10m indicates that the session timeout period is 10 minutes. By default, no other parameter is specified.

    Contact Us