- Overview
- Quick Start
- Install PTK
- Usage
- Configuration
- Config Samples
- Commands
- ptk
- ptk completion
- ptk register
- ptk init-cluster
- ptk collect
- ptk rec-guc
- ptk cache
- ptk gen-ptkc
- ptk manage
- ptk demo
- ptk meta
- ptk version
- ptk self
- ptk gen-om-xml
- ptk env
- ptk gen-static-config
- ptk cluster
- ptk cluster rename
- ptk cluster throwout
- ptk cluster takeover
- ptk cluster uninstall-cm
- ptk cluster install-cm
- ptk cluster gen-cert-files
- ptk cluster load-cm-vip
- ptk cluster del-kerberos-auth
- ptk cluster add-kerberos-auth
- ptk cluster uninstall-kerberos-server
- ptk cluster install-kerberos-server
- ptk cluster is-in-upgrade
- ptk cluster upgrade-rollback
- ptk cluster upgrade-commit
- ptk cluster upgrade
- ptk cluster demote
- ptk cluster promote
- ptk cluster refresh
- ptk cluster shell
- ptk cluster modify-comment
- ptk cluster show-config
- ptk cluster set-guc
- ptk cluster show-guc
- ptk cluster set-hba
- ptk cluster show-hba
- ptk cluster scale-out
- ptk cluster scale-in
- ptk cluster uninstall-mogha
- ptk cluster install-mogha
- ptk cluster list-plugins
- ptk cluster install-plugin
- ptk cluster inspect
- ptk cluster failover
- ptk cluster switchover
- ptk cluster build
- ptk cluster status
- ptk cluster restart
- ptk cluster stop
- ptk cluster start
- ptk uninstall
- ptk ls
- ptk install
- ptk exec
- ptk template
- ptk encrypt
- ptk checkos
- ptk download
- ptk candidate
- Troubleshooting
- FAQ
- Release Note
- GPTK - Graphical Deployment Tool
- Community
- Appendix: YAML Syntax
Scale-In/Out
What Is Scale-In/Out?
Scale-in/out indicates that you can add database nodes to or delete database nodes from the existing database cluster to meet different service requirements.
Terms:
- Scale-out: Adds database nodes to the existing database cluster.
- Scale-in: Deletes database nodes from the existing database cluster.
Prerequisites
Assume that you have a MogDB database cluster which can include a node or multiple nodes, and the cluster name is CLUSTER_NAME
.
During scale-out, make sure that the database version and configuration is consistent with the system environment, avoiding the incompatibility problem.
For details about how to install a database cluster, see Database Installation.
Scale-Out
Scale-Out Parameters
# ptk cluster scale-out -h
Perform scale-out for a MogDB cluster.
Usage:
ptk cluster scale-out [flags]
Examples:
ptk cluster -n <cluster_name> scale-out -c scale-out.yaml
Flags:
-y, --assumeyes Replies yes to all questions automatically.
-c, --config string Specifies the scale-in and scale-out configuration file path.
--cpu string Specifies the CPU model.
'ptk candidate cpu' can be used for querying the supported CPU models.
--default-guc Specifies that GUC parameters are not automatically optimized. The default database parameters are used.
-h, --help help for scale-out
--skip-check-distro Skips the system release check.
--skip-check-os Skips the system check.
--skip-create-user Skips user creation.
--skip-rollback Skips rollback for installation failures.
Scale-Out Principle
During scale-out, PTK randomly chooses a node in a cluster, packages static files such as the application and tool directories of the node, copies the package to the target machine, and then decompress it to a directory.
PTK then uses a kernel tool to initiate a new data directory, and refreshes the cluster configuration file based on the topology of the new cluster.
Note that nodes are scaled out one by one. When a node fails scale-out, scale-out is stopped, and the cluster configuration is refreshed for only cluster nodes that finish scale-out.
Create a Configuration File for Scale-Out
The ptk template
subcommand includes scale-out, and it can generate a basic scale-out configuration file template.
ptk template scale-out > scale-out.yaml
In this case, a scale-out configuration file named scale-out.yaml is created. You need to modify it as needed.
The following introduces the scale-out configuration file template.
# The newly added database server list is the same as that during installation.
db_servers:
- host: "replace host ip here"
# The role can be "standby" (default) or "cascade_standby".
role: standby
ssh_option:
port: 22
user: root
password: "encrypted ssh password by ptk"
# CM component server list
# If a CM component is installed in a cluster before scale-out,, the CM server list needs to be specified.
# Typically, the CM server list is the same as that of the database.
# If only database or CM component on the new server is scaled out, the two server lists can be inconsistent.
cm_servers:
- host: "replace host ip here"
Scale-Out Support Description
Original Cluster | Scale-Out Condition | Supported or Not | Solution |
---|---|---|---|
db1, db2 | db3 | Supported | |
db1, db2 | cm1, cm2 | Not Supported | Uninstall the cluster and specify the --install-cm parameter to install the cluster again. |
db1+cm1, db2+cm2, db3+cm3 | db4+cm4 | Supported | |
db1+cm1, db2+cm2, db3+cm3 | db4 | Supported | |
db1+cm1, db2+cm2, db3+cm3 | cm4 | Supported | |
db1+cm1, db2+cm2, db3 | cm3 | Not Supported | Perform scale-in for db3 and perform scale-out for db3+cm3. |
db1+cm1, db2+cm2, cm3 | db3 | Not Supported | Perform scale-in for cm3 and perform scale-out for db3+cm3. |
Scale-Out Command
ptk cluster -n CLUSTER_NAME scale-out -c scale-out.yaml
Scale-Out Demonstration
Scale-In
View the Help Information
# ptk cluster scale-in -h
Perform scale-in for a MogDB cluster
Usage:
ptk cluster scale-in [flags]
Examples:
ptk cluster -n <cluster_name> scale-in -H <IP1> -H <IP2>
Flags:
-y, --assumeyes Replies yes to all questions automatically.
--force If the target host cannot be connected using SSH, forcibly delete the target instance from the configuration of the upgraded cluster node.
-h, --help help for scale-in
-H, --host stringArray Specifies the target IP address to be deleted.
--skip-clear-db Skips deletion of the directory of the target database.
--skip-clear-user Skips deletion of the system user of the target database.
Scale-In Command
ptk cluster -n CLUSTER_NAME scale-in -H IP1 -H IP2
The above command can remove database nodes whose IP addresses are IP1
and IP2
from a cluster.
Scale-in description
- Scale-in for one primary server, multiple standby servers, and multiple cascaded servers
Assume that the cluster topology is as follows:
standby1 —— cascade_standby1
/
primary
\
standby2 —— cascade_standby2
After deleting standby1, the topology is changed to the following one:
standby1 cascade_standby1
/
primary /
\ /
standby2 —— cascade_standby2
At this time, standby1 is not in the cluster but is independent of the cluster.
That is to say, if a standby node is to be deleted, there is a cascaded standby node under the standby node, and there are multiple standby nodes, PTK will randomly choose a standby node to connect the cascaded standby node.
- Scale-in for one primary server, one standby servers, and one cascaded servers
Assume that the cluster topology is as follows:
primary —— standby1 —— cascade_standby1
After deleting standby1, the topology is changed to the following one:
primary standby1 cascade_standby1
At this time, three nodes are independent of each other.
Scale-In Support Description
Note: Scale-In supports only deletion of a node based on the node level of the IP address.
Original Cluster | Scale-In Condition | Supported or Not | Solution |
---|---|---|---|
db1, db2, db3 | db3 | Supported | |
db1+cm1, db2+cm2, db3+cm3 | db3+cm3 (same IP address) | Supported | |
db1+cm1, db2+cm2, db3+cm3 | db3 | Not Supported | Perform scale-in for db3+cm3 and perform scale-out for cm3. |
db1+cm1, db2+cm2, db3+cm3 | cm3 | Not Supported | Perform scale-in for db3+cm3 and perform scale-out for db3. |
db1+cm1, db2+cm2, db3 | db3 | Supported | |
db1+cm1, db2+cm2, cm3 | cm3 | Supported |