Deploy MyBase

更新时间:
复制 MD 格式

This topic describes how to deploy MyBase for the first time in an offline environment.

Prerequisites

Procedure

Get and decompress the package

  1. Download the deployment package to any management host and decompress it into the /apsara/v1.0.0-xxx directory.

    Warning

    Do not decompress the deployment package directly into the /apsara directory. In the path, v1.0.0-xxx represents the package version number. You must create a subdirectory that corresponds to the package version.

  2. Run the following command to decompress the deployment package.

    tar -xvf mybase-one-v1.0.0-xxx.tar.gz

    mybase-one-v1.0.0-xxx.tar.gz is an example package name. Replace it with the actual name of your deployment package. After decompression, you can run the ls command to view the package contents. The following is an example of the output:

    # ls .
    # mybase-stack.v1.0.0.tar.gz
    # mybase-product-images.v1.0.0.tar.gz
    # mybase-product-baseline.v1.0.0.tar.gz
    # mybase
    # sealer
  3. Run the initialization command.

    ./mybase setup 

    The following output indicates that the initialization was successful.image

For more information about MyBase command-line interface (CLI) commands, see CLI reference.

View package information

This command displays information about the current package, such as the supported products, chip architectures, and OS versions. Before installation, run this command to confirm that the package meets your requirements.

 mybase package-info

image

The output shows that the current package supports three products: PolarDB-X, DAS, and DTS. The supported operating systems are Kylin V10, RHEL 8.10, CentOS Stream 8, and Alinux3.

Dry run

This command checks multiple items, such as the disk, hostname, and host time, to ensure that they meet the installation requirements. The following is an example:

mybase check --phase pre -m 192.xxx.xxx.171 -m 192.xxx.xxx.172 -n 192.xxx.xxx.173 --port 22 --user root --sshPasswd ***** (Password mode)
mybase check --phase pre -m 192.xxx.xxx.171 -m 192.xxx.xxx.172 -n 192.xxx.xxx.173 --port 22 --user root (Passwordless mode)

The following table describes the parameters.

  • -m: The IP addresses of all management plane hosts.

  • -n: The IP addresses of all data plane hosts.

Note

In the current version, some errors can be ignored. If an error occurs, contact the owner.

The following output is returned:

image

Cluster configuration

  1. Run the following command to load the software version to be installed.

    mybase load v1.0.0-2024xxx
    Note

    The version number, such as v1.0.0-2024xxx, must match the version of the package that you decompressed. For example, for the version shown in the following figure, use the following command:image

    mybase load v1.0.0-20241127150353
    Note

    This step decompresses the cluster image package and copies it to the default installation directory. The load command takes about 30 minutes to complete. After the command is executed, the system displays "success".

    image.png

  2. Run the following command to view the current deployment configuration, including the pod CIDR block and default domain name.

    mybase config list
    Important

    Before you install the cluster, confirm the cluster configuration. An incorrect configuration can cause installation failure or unexpected behavior and will require you to uninstall and reinstall the cluster.

    The cluster configurations are described as follows:

    Configuration Name

    Description

    Default Value

    Can be modified

    MYBASE_USER_DOMAIN

    The cluster endpoint.

    test-dbstack.com

    Yes

    MYBASE_SERVICE_CIDR

    The Kubernetes Service CIDR block.

    172.21.0.0/16

    Yes

    MYBASE_IPVS_CIDR

    The IPVS CIDR block.

    172.22.0.0/16

    Yes

    MYBASE_POD_CIDR

    The pod CIDR block.

    172.20.0.0/16

    Yes

    MYBASE_DOCKER_CIDR

    The Docker CIDR block.

    172.19.0.0/16

    Yes

    MYBASE_POD_CNI

    The pod CNI plugin.

    calico

    Yes

    Note
    • CIDR blocks: Make sure that the CIDR block of the host network does not overlap with the four CIDR blocks listed in the configuration. If an overlap exists, modify the CIDR blocks to avoid conflicts.

    • Domain name: Set a primary domain name for the cluster. This domain name must be resolvable by your DNS server. For example, if the primary domain name is set to test-dbstack.example.com, your DNS must be configured to resolve test-dbstack.example.com to the cluster's IP address. This ensures that all services, including database instances and management services, can be accessed through this domain name and its subdomains.

    • CNI plugin: If the Calico installation fails, uninstall the cluster, set the CNI plugin parameter to Flannel, and then reinstall the cluster.

  3. Run the following command to view the configurations that can be modified.

    mybase config help

    image

  4. Run the following command to modify a configuration.

    If the default pod CIDR block (podCidr) or Service CIDR block (serviceCidr) conflicts with the host CIDR block of the current environment, run the following command to modify the pod CIDR block.

    mybase config --podCidr 172.20.0.0/16 (The destination CIDR block to be modified)
    mybase config --serviceCidr 172.21.0.0/16 (The destination CIDR block to be modified, which must be different from podCidr)

    After the modification, run the mybase config list command again. The output shows that the pod CIDR block is changed to 192.168.0.0/16.image

    The default domain name of MyBase is test-dbstack.com. When you deploy in a production environment, you must modify the domain name configuration. Use the following command:

    mybase config --userDomain ****.com

Install the cluster

  1. Configure the region and zone information for the first zone.

    Note

    Configure these settings for both single-data center and multi-data center deployments. Do not use the default values. Set the parameters according to your requirements.

    mybase config --region "cn-beijing" --zone "i" (Set the zone name as needed)

    The following output shows that the zone was configured successfully.

    image

  2. Install the MyBase cluster. This step installs Kubernetes and takes about 20 minutes.

    mybase cluster install -m xxxxip  -m xxxip -m xxxxip (Passwordless SSH is configured)
    mybase cluster install -m xxxxip  -m xxxip -m xxxxip --sshPasswd xxpwd (Passwordless SSH is not configured. The SSH passwords of all hosts must be the same.)

    The following describes the parameters:

    • -m: The IP addresses of the management plane hosts. You can specify one to three hosts. High availability (HA) is supported only when three hosts are specified. The current host must be included in the list.

    After the installation is successful, you can run the kubectl get node -A command to view the host status. The following output indicates a successful installation.

  3. Scale out data nodes.

    1. The following is an example for PolarDB-X.

      Run the following command.

      mybase cluster scale-up -n xxxip -n xxxip -n xxxip --product PolarDB-X (Passwordless SSH is configured)
      mybase cluster scale-up -n xxxip -n xxxip -n xxxip --product PolarDB-X --sshPasswd xxpwd (Passwordless SSH is not configured. The SSH passwords of all hosts must be the same.)

      The following table describes the parameters.

      • -n: The IP addresses of the data plane hosts. You can specify one or more hosts.

      • --product: The database product to which the host belongs.

      After the scale-out is successful, you can run the kubectl get node -A command to view the host status. The following output indicates a successful scale-out.

    2. PolarDB for PostgreSQL is a special case. You need to scale out nodes for PolarDB for PostgreSQL and PolarDB for PostgreSQL Maxscale separately.

      Note

      In a production environment, deploy the data nodes of these two products separately.

      Scale out PolarDB for PostgreSQL.

      mybase cluster scale-up -n xxxip -n xxxip -n xxxip --product PolarDB-PG (Passwordless SSH is configured)
      mybase cluster scale-up -n xxxip -n xxxip -n xxxip --product PolarDB-PG --sshPasswd xxpwd (Passwordless SSH is not configured. The SSH passwords of all hosts must be the same.)

      You can scale out MaxScale for PolarDB for PostgreSQL.

      mybase cluster scale-up -n xxxip -n xxxip -n xxxip --product PolarDB-PG-Maxscale (Passwordless SSH is configured)
      mybase cluster scale-up -n xxxip -n xxxip -n xxxip --product PolarDB-PG-Maxscale --sshPasswd xxpwd (Passwordless SSH is not configured. The SSH passwords of all hosts must be the same.)

      After the scale-out is complete, you can run the kubectl get node -A command to view the host checklist.

Deploy multi-data center management

Single-data center deployment

  1. You can skip this step.

Two-data center deployment

The following is an example for PolarDB-X.

  1. Switch to the second zone and scale out nodes.

    mybase config --region "cn-beijing" --zone "j"
    mybase cluster scale-up  -m xxxip  -m xxxip  -m xxxip --sshPasswd xxpwd
    mybase cluster scale-up  -n xxxip  -n xxxip  -n xxxip --product PolarDB-X --sshPasswd xxpwd
  2. Run the following command to apply the topology.

    mybase topology apply -t 1R2Z

Three-data center deployment

The following is an example for PolarDB-X.

  1. Switch to the second zone and scale out nodes.

    mybase config --region "cn-beijing" --zone "j"
    mybase cluster scale-up  -m xxxip  -m xxxip  -m xxxip --sshPasswd xxpwd
    mybase cluster scale-up  -n xxxip  -n xxxip  -n xxxip --product PolarDB-X --sshPasswd xxpwd
  2. Switch to the third zone and scale out nodes.

    Note

    The third zone requires only one management host. Therefore, the command line includes only one -m parameter.

    The management service in the third data center is a lightweight version. It only deploys services related to disaster recovery and arbitration and does not include services such as monitoring, alerting, logging, or auditing.

    mybase config --region "cn-beijing" --zone "k"
    mybase cluster scale-up  -m xxxip  --sshPasswd xxpwd
    mybase cluster scale-up  -n xxxip  -n xxxip  -n xxxip --product PolarDB-X --sshPasswd xxpwd
  3. Run the following command to apply the topology.

    mybase topology apply -t 1R3Z

Production recommendations

Number of managed machines:

Architecture

Zone 1

Zone 2

Zone 3

Single-data center

3 units

N/A

N/A

Two-data center

3 units

3 units

N/A

Three data centers

2 units

2 units

1 unit

Install products

  1. Run the following command to query the products that can be installed.

    mybase product help

    image

  2. Install the products.

    The following example shows how to install PolarDB-X.

    mybase product install PolarDB-X

    PolarDB for PostgreSQL is a special case. You need to install both PG and MaxScale.

    mybase product install PolarDB-PG PolarDB-PG-Maxscale

    This step imports the product images into the MyBase private image repository and pulls all required images based on their dependencies.

  3. Wait for the command to complete.

Verify the installation

The MyBase installation is asynchronous and can take more than an hour to complete. You can run the following command to check the installation progress.

kubectl get app -A

The installation is complete when the HEALTHY status for all components is true.

image

Additional information

During the installation, the management host that runs the deployment command transfers the deployment package to other hosts. This process generates network traffic. The estimated traffic is as follows:

  • About 30 GB for the deployment package sent to management hosts in the first and second zones.

  • About 5 GB for the deployment package sent to the management host in the third zone.

  • About 5 GB for the deployment package sent to data hosts in any zone.