This document describes the steps to delete a cluster, uninstall and reinstall MatrixDB 4. Taking three nodes as an example, the main node is mdw, and the two data nodes are sdw1 and sdw2 respectively.
Before performing the operation, be sure to read this prompt carefully:
Notes!
1, 2, and 3 The parts in the serial numbers are independent of each other. Just select one of them according to the above prompts, and do not execute them all!
Notes!
· This part of the operation will delete all data in the * database and cannot be restored. Be careful to think about it before the operation. · The gpdeletesysystem tool can only be used in cluster startup state.
You can use the following statement to query the master node data directory of your cluster.
postgres=# SELECT * FROM gp_segment_configuration ORDER BY 1 ASC;
In our example, we get the following results. It can be seen that the data storage directory of the master node mdw is "/home/mxdata_20220729105027/master/mxseg-1".
dbid | content | role | preferred_role | mode | status | port | hostname | address | datadir
-----+-----------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------
1 | -1 | p | p | n | u | 5433 | mdw | mdw | /home/mxdata_20220729105027/mast
er/mxseg-1
2 | 0 | p | p | s | u | 6000 | sdw1 | sdw1 | /home/mxdata_20220729105027/prim
ary/mxseg0
3 | 1 | p | p | s | u | 6001 | sdw1 | sdw1 | /home/mxdata_20220729105027/prim
ary/mxseg1
4 | 2 | p | p | s | u | 6000 | sdw2 | sdw2 | /home/mxdata_20220729105027/prim
ary/mxseg2
5 | 3 | p | p | s | u | 6001 | sdw2 | sdw2 | /home/mxdata_20220729105027/prim
ary/mxseg3
6 | 0 | m | m | s | u | 6002 | sdw2 | sdw2 | /home/mxdata_20220729105027/mirr
or/mxseg0
7 | 1 | m | m | s | u | 6003 | sdw2 | sdw2 | /home/mxdata_20220729105027/mirr
or/mxseg1
8 | 2 | m | m | s | u | 6003 | sdw1 | sdw1 | /home/mxdata_20220729105027/mirr
or/mxseg2
9 | 3 | m | m | s | u | 6002 | sdw1 | sdw1 | /home/mxdata_20220729105027/mirr
or/mxseg3
(9 rows)
Then exit the terminal opened by psql through the meta command \q.
postgres=# \q
Under the mxadmin user, use the gpdeletesysystem command to clean up the data and delete the cluster.
[mxadmin@mdw ~]$ gpdeletesystem -d /home/mxdata_20220729105027/master/mxseg-1
Before re-initializing the graphic interface, you need to clean up two configuration files to reset the initialization environment.
.matrixdb.env is the environment variable configuration file for MatrixDB. It contains the environment variables PGPORT, MASTER_DATA_DIRECTORY, and PGDATABASE. PGPORT specifies the port of the database server for the client application, MASTER_DATA_DIRECTORY refers to a directory created by gpinsystem in the master node data directory location, and PGDATABASE specifies the database name, which is the same as the user name by default. Execute the following command on the Master:
[mxadmin@mdw ~]$ rm ~/.matrixdb.env
Notes!
The cluster.conf file contains the deployed cluster information and modification is prohibited.
Use root permissions to delete the cluster.conf file on the Master under normal users.
[<username>@mdw ~]$ sudo rm /etc/matrixdb/cluster.conf
Restart the service with root permissions under ordinary users. After completion, you can re-enter the graphic interface to initialize the cluster.
[<username>@mdw ~]$ sudo systemctl restart matrixdb.supervisor.service
Notes!
All the following commands need to be executed under root permissions. You will use this step to completely uninstall the MatrixDB software and completely delete the original cluster.
You need to perform the above "1.1 Query the master node data directory" and "1.2 Delete the cluster". This step completely deletes all cluster data and is not recoverable.
You need to perform the above "1.3.1 Delete the .matrixdb.env file" and "1.3.2 Delete the cluster.conf file". This step will manually clean up the cluster environment variable configuration file and the deployed cluster information file.
This step will completely uninstall the MatrixDB software. Under normal users, run with root permissions on all nodes.
[<username>@mdw ~]$ sudo yum remove -y matrixdb.x86_64
#or
[<username>@mdw ~]$ sudo yum erase -y matrixdb.x86_64
Where "matrixdb.x86_64" is the program name after the cluster is installed, and can be queried through the following command.
[<username>@mdw ~]$ yum list installed | grep matrixdb
If you use this part, you can rest assured that if you uninstall and reinstall another (or the same) version in the large version of MatrixDB 4, you will not lose cluster data. For example, MatrixDB 4.5 upgrades to MatrixDB 4.6; MatrixDB 4.6 downgrades to MatrixDB 4.5; uninstalls MatrixDB 4.5 and reinstalls MatrixDB 4.5.
Notes!
The upgrade of MatrixDB 4 small version can also be directly upgraded to the rpm package. For details, please refer to [MatrixDB 4 small version upgrade] (/doc/latest/install/mx4_upgrade "MatrixDB 4 small version upgrade").
First, you need to be prepared before upgrading, downgrading, or reinstalling. This step is necessary, otherwise it will hinder the uninstall operation. On the master node, exit the terminal opened by psql through the meta command \q.
postgres=# \q
In the example, you can use fast mode to stop the cluster process. If you need it, you can also choose smart or immediate mode to stop the cluster. The table below illustrates their differences.
[mxadmin@mdw ~]$ gpstop -a -M fast
gpstop mode | parameters | disable new connection | wait for the process to complete | Is it the default mode |
---|---|---|---|---|
smart | -M smart | Yes | Yes | |
fast | -M fast | Yes | No, interrupted connection, transaction rollback | No |
immediate | -M immediate | Yes | No, kill the process directly | No |
You need to perform the "2.3 MatrixDB Uninstall" above. This step will completely uninstall the original version of MatrixDB software.
Notes!
This step needs to be performed on all nodes.
Reinstall the rpm package you need. This operation is performed under normal users.
[<username>@mdw ~]$ yum install matrixdb-4.6.0.enterprise-1.el7.x86_64.rpm
Notes!
This step needs to be performed on all nodes.
First, connect to the mxadmin user using root permissions on the master node.
[<username>@mdw ~]$ sudo su - mxadmin
Then, use the gpstart tool to start the cluster.
[mxadmin@mdw ~]$ gpstart -a