- About PTK
- Quick Start
- Guidance
- Preparing Configuration File
- Checking the System
- Deploy Database Cluster
- Manage Clusters
- Show Cluster List
- Show Cluster Status
- Start Database
- Stop Database
- Restart Database
- Rebuild Database
- Switchover
- Failover
- Show Plugin Information
- Install Plugins
- Upgrade Database
- Scale-out Cluster
- Scale-in Cluster
- Show Database HBA
- Set Database HBA
- Show Database Parameters
- Set Database Parameters
- Show Cluster Topology Configuration
- Show Cluster Meta Information
- Update Cluster Comment
- Update Database IP
- Role Management
- Install CM
- Uninstall CM
- Manage Cluster VIP
- Install MogHA Service
- Uninstall MogHA Service
- Rename Cluster
- Create Empty Cluster
- Throw Out A Node
- Takeover A Node
- Manage Cluster
- Uninstall Database Cluster
- Collect OS Information
- Download MogDB Installer
- Encrypt Sensitive Information
- Upgrade PTK
- PTKC
- Compatible With Higher Versions of MogDB
- Reference
- Samples of Configuration Files
- Commands
- ptk
- ptk completion
- ptk view-static-config
- 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 createdb
- ptk cluster uninstall-compat-tools
- ptk cluster install-compat-tools
- ptk cluster install-mogila
- 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 Notes
- Community
- Appendix: YAML Syntax
Scale-in Cluster
Through a series of operations, reduce database nodes in the original cluster.
Purpose
PTK provides users with the function of cluster scale-in to meet their needs for business, cost, resource allocation, risk and other factors.
Scale-in Command
ptk cluster -n <CLUSTER_NAME> scale-in [-H|--host HOST] [-i|--id ID] [--skip-clear-user] [--skip-clear-db] [--force]
Sample Topology Before And After Scale-in
One primary N standby and M cascade
The original cluster topology is as follows:
standby1 -- cascade_standby1, cascade_standby2
/
primary
\
standby2 -- cascade_standby3
After deleting standy2
with the scale-in command, the structure changes to:
standby1 -- cascade_standby1, cascade_standby2
/ \
primary \
\
standby2 cascade_standby3
At this point, standby2
is not in the cluster, and the upstream of the downstream node of standby2
is changed to standby1
.
PTK implementation: If the target node role is standby
, if the node has downstream nodes and there are other standby
nodes, then all the downstream nodes of the node to be scaled-in will point to the rest of the standby
nodes in the upstream.
One primary one standby and one cascade
The original cluster topology is as follows:
primary -- standby -- cascade_standby
After deleting standy
with the scale-in command, the structure changes to:
primary standby cascade_standby
At this point the 3 nodes are directly unrelated and are all independent.
QA
Can I scale-out a cluster?
Yes. Please refer to Cluster Scale-out.
Can a cluster be scaled out to empty by performing a scale-out all the time?
No, you cannot. After a scale-out, the cluster will have at least one available data node.
To get an empty cluster, see Create Empty Cluster, or refer to Throwout Node.
Can I directly scale-in the primary node?
No. There will be at least one node surviving after scaling-in, and that node will be the primary node.
What should I do if I want to scale-in the node where the primary node is located?
Consider using the following steps:
- Use the
switchover
command to switch primary and standby nodes. - Scale-in the node on which the primary node used to reside (the node where the standby node now resides).
Can I scale-in a cluster with CM? If yes, is there a restriction?
Yes.
Restrictions: The database nodes of the scaled-in cluster should be at least 2 nodes, and the CM nodes should be at least 2 nodes, because the arbitration mechanism of CM needs to guarantee at least 2 nodes. ADDITIONAL: When scaling-in a cluster with CM, PTK will scale-in the database node and CM node on the target node.
What does --skip-clear-db
do? When should it be used?
Usage: When scaling-in a target node, PTK by default kills the database processes on that node, clears the database related files, and rewrites the replication stream information in the postgresql.conf
file for the remaining nodes. The purpose of --skip-clear-db
is to skip the step of clearing database related files.
When to use: When you want to keep information about the data node.
What does --skip-clear-user
do? When should it be used?
Usage: When PTK scales-in a target node, it normally removes the database user under that node.
When to use: When you don't want to delete database user on the target node.
What does --force
do? When should it be used?
Usage: There may be situations where the node to be scaled-in cannot be linked properly due to special reasons, and some of the checks performed during the scaling-in process cannot be passed, resulting in an error being thrown if the node cannot be scaled-in. The role of --force
is to skip these checks.
When to use it: Continue to perform scale-in tasks when some nodes cannot be linked.
If CM is currently deployed in the cluster and VIPs are configured, will scale-in affect VIPs?
No. PTK refreshes CM-VIP after scale-in for clusters that have VIPs configured to ensure that the basic CM-VIP information is correct.