mxmoveseg

This document describes the mirror segment instance (Mirror) migration tool mxmoveseg.

Note!
mxmoveseg is used only to migrate segment instances in the gp_segment_configuration table where the role (current role) is m (mirror). It does not depend on the preferred_role (preferred role) column.

1 Description

  • Functionality
    • The mxmoveseg tool supports migrating any database segment instance currently serving as Mirror/Standby to another server.
  • Use Cases
    • The current cluster is operational, but workload imbalance affects performance and stability. Migrate Mirror/Standby segments across machines to rebalance load.
    • A server has gone offline. Migrate the Mirror/Standby segment to a healthy new server to maintain cluster availability.

Note!
Before using this tool, you must assess the health of all servers in the system. If any servers are unhealthy, identify them explicitly to ensure that mxmoveseg can collect information only from healthy hosts.

2 Command-Line Options

The following table lists the available command-line options:

Option Description
--config Create a configuration file for the Mirror segment to be migrated
--plan Generate a migration plan based on the configuration
--setup Execute the migration plan
-h / --help Display help information

3 Examples

3.1 Migrate an Existing Segment to a New Server

Note!
The new server must have the same version of YMatrix RPM/DEB package installed as per YMatrix deployment documentation, but do not initialize a new cluster through the graphical interface.

Note!
The new server may host a YMatrix cluster with a different major version (e.g., YMatrix 4.8 on the old server and YMatrix 5.1 on the new server).

Collect information about the existing database cluster. Use more /etc/matrixdb5/cluster.conf to view the cluster ID.

[<username>@<master_hostname> ~]$ sudo /opt/ymatrix/matrixdb5/bin/mxctl expand init --cluster-id <clusterid> --unrestrict > /tmp/init

Add the new server.

[<username>@<master_hostname> ~]$ cat /tmp/init | sudo /opt/ymatrix/matrixdb5/bin/mxctl expand add --unrestrict --host <newhost> > /tmp/initadd

Check network connectivity between the discovered servers.

[<username>@<master_hostname> ~]$ cat /tmp/initadd | sudo /opt/ymatrix/matrixdb5/bin/mxctl expand netcheck > /tmp/netcheck

Switch to the mxadmin user.

[<username>@<master_hostname> ~]$ sudo su - mxadmin

Create a migration configuration file. Edit the required segment instances according to the instructions in the generated file.

$ mxmoveseg config --db-cluster-id <clusterid> --filename /tmp/migrate.cfg

# After creating the configuration file, manually edit the dbid (obtained by running SELECT * FROM gp_segment_configuration; after connecting to the database), hostname, etc., of the segment to be migrated. SPEC: If there is a port conflict between the new and old servers, specify a new port in the configuration file.
$ vim /tmp/migrate.cfg

Generate the migration plan.

$ mxmoveseg plan --init-file /tmp/netcheck --config-file /tmp/migrate.cfg > /tmp/plan

Execute the migration.

$ mxmoveseg setup --plan-file /tmp/plan --mode cli

After successful migration, verify the status of the migrated Mirror using the GUI: "Cluster Management" → "Cluster Overview" → "Instance View", or use the SELECT * FROM gp_segment_configuration SQL statement.

3.2 Migrate an Existing Segment to an Old Server

Collect information about the existing database cluster. Use more /etc/matrixdb5/cluster.conf to view the cluster ID.

[<username>@<master_hostname> ~]$ sudo /opt/ymatrix/matrixdb5/bin/mxctl expand init --cluster-id <clusterid> --unrestrict > /tmp/init

Check network connectivity between the discovered servers.

[<username>@<master_hostname> ~]$ cat /tmp/init | sudo /opt/ymatrix/matrixdb5/bin/mxctl expand netcheck > /tmp/netcheck

Switch to the mxadmin user.

[<username>@<master_hostname> ~]$ sudo su - mxadmin

Create a migration configuration file. Edit the required segment instances according to the instructions in the generated file.

$ mxmoveseg config --db-cluster-id <clusterid> --filename /tmp/migrate.cfg

# After creating the configuration file, manually edit the dbid (obtained by running SELECT * FROM gp_segment_configuration; after connecting to the database), hostname, etc., of the Mirror to be migrated. SPEC: If there is a port conflict between the target and original servers, specify a new port in the configuration file.
$ vim /tmp/migrate.cfg

Generate the migration plan.

$ mxmoveseg plan --init-file /tmp/netcheck --config-file /tmp/migrate.cfg > /tmp/plan

Execute the migration.

$ mxmoveseg setup --plan-file /tmp/plan --mode cli

After successful migration, verify the status of the migrated Mirror using the GUI: "Cluster Management" → "Cluster Overview" → "Instance View", or use the SELECT * FROM gp_segment_configuration SQL statement.