No relevant resource is found in the selected language.

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Read our privacy policy>Search

Reminder

To have a better experience, please upgrade your IE browser.

upgrade

HUAWEI CLOUD Stack 6.5.0 Backup and Restoration Guide 03

Rate and give feedback :
Huawei uses machine translation combined with human proofreading to translate this document to different languages in order to help you better understand the content of this document. Note: Even the most advanced machine translation cannot match the quality of professional translators. Huawei shall not bear any responsibility for translation accuracy and it is recommended that you refer to the English document (a link for which has been provided).
Single Service Data Restoration

Single Service Data Restoration

Scenarios

The same GaussdbHA database is deployed for VPC, Combined API, Task Center, SDR, and CCS. GaussdbHA is deployed on the PUB-DB01 and PUB-DB02 nodes. The database backs up the data of all services in one backup package. This section describes how to restore the data of a single service.

Table 2-3 Database names of the combined deployment services

Service Name

Database Name

API Gateway

CONSOLE

SDR

METERTICKET

VPC

VPC

Combined API

TASKMGR

CCS

CCS

Task Center

TASKCENTER

Impact on the System

During the restoration, services related to the database to be restored are unavailable. The restoration takes about 10 minutes.

Prerequisites

  • You have obtained the IP address and password of the database node to be restored.
  • An application, such as PuTTY, which can be used for remote access on various platforms, is available.
    NOTE:

    During the execution, you need to enter the password of the dbadmin user. The default password is Manager@123.

Procedure

Exporting Single Service Data from the Original Database Node

  1. Use PuTTY to log in to the original database node.

    The default account is gaussdb. The default password is Huawei@123.

  2. Run the following command and enter the password of the root user as prompted to switch to the root user (the default password is Cloud12#$):

    sudo su - root

  3. Run the following command to switch to the dbadmin user:

    su - dbadmin

  4. Run the following commands to export data of the database of a service:

    gs_ctl reload

    gs_dump Name of the database of a service -Fp -cC --pg-format -f /home/dbadmin/dump.sql

    For example, to export data from the TaskCenter database, run the following command:

    gs_dump TASKCENTER -Fp -cC --pg-format -f /home/dbadmin/dump.sql

  1. Enter the password of user dbadmin as prompted and press Enter.
  2. Run the following command and enter the password of the root user to switch to the root user:

    sudo su - root

  3. Run the following command to create a backup upload directory:

    mkdir /home/gaussdb/dbbackupfile/

  4. Run the following commands to copy the exported database file to the backup directory created in Step 7 and modify the file permissions.

    cp /home/dbadmin/dump.sql /home/gaussdb/dbbackupfile/

    chmod 777 /home/gaussdb/dbbackupfile/dump.sql

  5. Use a network transmission tool, such as WinSCP, to copy the exported database file to the local PC and upload the file to the /home/gaussdb directory on the active node of the database to be restored.

Restoring Data of the Single Service on the Active Node of the Database to Be Restored

  1. Use PuTTY to log in to the active node of the database to be restored.

    Ensure that user gaussdb and the management IP address of the database are used to establish the connection.

  2. Run the following command and enter the password of the root user to switch to the root user:

    sudo su - root

  3. Run the following commands to modify the permission of the database configuration file:

    cp /home/gaussdb/dump.sql /home/dbadmin

    chmod 777 /home/dbadmin/dump.sql

  4. Run the following command to switch to the database user dbadmin:

    su dbadmin

  5. Run the following commands to prevent the service to be restored from accessing the faulty database:

    cd $GAUSSDATA

    vim pg_hba.conf

  6. Press i to enter the editing mode.
  7. Comment out the permission for the service to access the database. Only the permission for connecting to the database locally is reserved for database restoration. Figure 2-2 shows the details.

    Figure 2-2 Commenting out the permission for TaskCenter to access the database
    NOTE:

    Figure 2-2 uses TaskCenter as an example.

  8. Press Esc, enter :wq, and press Enter.

    The system saves the change and exits the vi editor.

  9. Run the following command to make the results of Step 14 to Step 17 to take effect:

    gs_ctl reload

  10. Run the following command to check whether the database to be restored has service access:

    ps -ef|grep gaussdb|grep Name of the database of the service

    For example, if the name of the database of the service is TASKCENTER, run the following command:

    ps -ef|grep gaussdb|grep TASKCENTER

    Figure 2-3 Accessing TaskCenter
    NOTE:

    Figure 2-3 indicates that TaskCenter has been accessed by two processes whose IDs are 11987 and 11988.

  11. Run the following command to stop the processes that access the database:

    gsql -h 127.0.0.1 -p 5432 -d postgres? -c "select pg_terminate_backend(Process ID)"

    For example, if the process IDs queried in Step 19 are 11987 and 11988, run the following commands:

    gsql -h 127.0.0.1 -p 5432 -d postgres? -c "select pg_terminate_backend(11987)"

    gsql -h 127.0.0.1 -p 5432 -d postgres? -c "select pg_terminate_backend(11988)"

    NOTE:

    If you have queried more than one processes in Step 19, run the command for each of them.

  12. Enter the password of user dbadmin as prompted and press Enter.

    If the following information is displayed, the process is stopped:

     PG_TERMINATE_BACKEND
    ----------------------
     t
    (1 row)

  13. Run the following command to restore the database:

    gsql -h 127.0.0.1 -p Database listening port -d postgres -f/home/dbadmin/dump.sql

    For example, if the database listening port is 5432, run the following command:

    gsql -h 127.0.0.1 -p 5432-d postgres -f /home/dbadmin/dump.sql

    NOTE:

    You can run the lsof -nPi|grep -i listen|grep 127.0.0.1|grep gaussdb command to obtain the listening port number.

  14. Enter the password of user dbadmin as prompted and press Enter.

    Figure 2-4 Restoring the database

  15. Run the following commands to check whether the database is restored, enter the password of user dbadmin as prompted, and press Enter:

    gsql -U dbadmin -d Name of the database corresponding to the service

    set search_path=test_rts

    \d+

    NOTE:

    Replace the value of test_rts with the value of schema for the required service. If the schema does not exist, use public.

    Figure 2-5 TaskCenter service table

    If the command output contains the required service table, the restoration is successful.

  16. Run the following command to switch to user dbadmin:

    \q

  17. Run the following commands to restore the permission for accessing the database of the service:

    cd $GAUSSDATA

    vim pg_hba.conf

  18. Press i to enter the editing mode and restore the permission commented out in Step 16.

    Figure 2-6 Restoring the permission for TaskCenter to access the database

  19. Press Esc, enter :wq, and press Enter.

    The system saves the change and exits the vi editor.

  20. Run the following command to make the results of Step 26 to Step 28 to take effect:

    gs_ctl reload

Translation
Download
Updated: 2019-06-14

Document ID: EDOC1100062366

Views: 752

Downloads: 9

Average rating:
This Document Applies to these Products
Related Documents
Related Version
Share
Previous Next