Updated on 2024-11-29 GMT+08:00

Importing and Exporting MOTService Metadata and Service Data

Scenario

To ensure MOTService data security routinely or before a major operation on MOTService (such as upgrade or migration), you need to back up or export MOTService data. The backup data can be used to recover the system if an exception occurs or the operation has not achieved the expected result, minimizing the adverse impacts on services.

You can run scripts to import and export MOTService data, or create MOTService backup and restoration tasks on FusionInsight Manager. This section describes how to use MOTImportTool.sh and MOTExportTool.sh to import and export MOTService metadata and service data.

Prerequisites

  • MOTService has been installed in the cluster and all components in the cluster are running properly.
  • You have obtained the floating IP address of MOTService.

    Log in to FusionInsight Manager, choose Cluster > Services > MOTService, click Configurations then All Configurations, search for the motservice.floatip parameter, and obtain its value, which is the floating IP address of MOTService.

  • The size of the data file to be imported does not exceed 200 MB.

Exporting Data

  1. Log in to FusionInsight Manager, choose Cluster > Services > MOTService, click Instance, and view and record the service IP address of the MOTServer(Active) instance.
  2. Log in to the active MOTService node as user omm.
  3. Configure the data export scenario (perform this step only for initial configuration or when new configuration is added). Configure the file based on site requirements and save it.

    vim ${BIGDATA_HOME}/FusionInsight_FARMER_RTD_8.1.0.1/install/FusionInsight-MOTService-2.7.0/setup/conf/mot_import_export/mot_export_and_import.cfg

    #eg:Scenario-dbID-floatIp-port-username-databaseName-exportFilepath-importFilepath
    Retail-db1-192.168.43.192-20105-dttest-db_tpcc-/opt/mot_test-/opt/mot_test
    Credit card-db2-192.168.43.192-20105-dttest-db_tpcc-/opt/mot_test-/opt/mot_test
    Payment 1-db3-192.168.43.192-20105-dttest-db_tpcc-/opt/mot_test-/opt/mot_test
    Payment 2-db4-192.168.43.192-20105-dttest-db_tpcc-/opt/mot_test-/opt/mot_test

    Configuration format:

    Scenario name-dbID-Floating IP address of the MOTService database-MOTService service port (20105 by default)-MOTService database username-MOTService database name-Storage path of the file to be exported-Storage path of the file to be imported

    • dbID: database ID. The value must contain letters and numbers, for example, db1.
    • Storage path of the file to be exported and Storage path of the file to be imported: Enter user-defined absolute paths. Ensure that the user omm has operation permissions on the paths.

  4. To export table-level data, create a record file for the table to be exported in the export file storage path, for example, /opt/mot_test/exporttable.txt. Skip this step if you want to export database-level data.

    The exporttable.txt file contains the names of the tables to be exported. You can export one or more tables. Enter one table name in each line. The following is an example:

    mottest1
    t_tansaction

  5. Run the following command to go to the directory where the export tool is located:

    cd ${BIGDATA_HOME}/FusionInsight_FARMER_RTD_8.1.0.1/install/FusionInsight-MOTService-2.7.0/tools

  6. Run the following command to start the MOTExportTool.sh export tool:

    sh MOTExportTool.sh Export format parameter

    For example, to export table-level metadata and service data in text format, run the sh MOTExportTool.sh metaanddata-table-text command.

    Currently, data can be exported in only one format at a time. If you enter multiple formats, the help information will be printed. The supported formats are as follows:

    Table 1 Data export formats

    Parameter

    Description

    metaanddata-table-text

    Exports table-level metadata and service data in text format.

    metaanddata-table-binary

    Exports table-level metadata and service data in binary format.

    metaanddata-database-text

    Exports database-level metadata and service data in text format.

    metaanddata-database-binary

    Exports database-level metadata and service data in binary format.

    dataonly-table-text

    Exports table-level service data in text format.

    dataonly-table-binary

    Exports table-level service data in binary format.

    dataonly-database-text

    Exports database-level service data in text format.

    dataonly-database-binary

    Exports database-level service data in binary format.

    metaonly-table-text

    Exports table-level metadata in text format.

    metaonly-table-binary

    Exports table-level metadata in binary format.

    metaonly-database-text

    Exports database-level metadata in text format.

    metaonly-database-binary

    Exports database-level metadata in binary format.

  7. View the read configuration column and enter dbID corresponding to the scenario data to be exported. For example, to export retail data, enter db1.

    To prevent incorrect input, the message "Are you sure you want to select the type : xxx" is displayed to remind you to confirm the scenario name corresponding to the scenario ID.

    • If the input is correct, enter y or any other key except n.
    • If the input is incorrect, enter n to stop the script. Then, execute the script again.

    Enter y and press Enter.

  8. Enter the password of the MOTService database.
  9. To export table-level data, enter the path and name of the file to be exported that are configured in 3, for example, /opt/mot_test/exporttable.txt. Skip this step if you want to export database-level data.
  10. Check the export result. If the following information is displayed, the export is successful.

    dump database Database name successfully
    total time: 1792 ms
    export data successfully! Filepath is:xxx/export_xxx.sql 

Importing Data

  1. Log in to FusionInsight Manager, choose Cluster > Services > MOTService, click Instance, and view and record the service IP address of the MOTServer(Active) instance.
  2. Log in to the active MOTService node as user omm.
  3. Configure the data import scenario (perform this step only for initial configuration or when new configuration is added). Configure the file based on site requirements.

    vim ${BIGDATA_HOME}/FusionInsight_FARMER_RTD_8.1.0.1/install/FusionInsight-MOTService-2.7.0/setup/conf/mot_import_export/mot_export_and_import.cfg

    #eg:Scenario-dbID-floatIp-port-username-databaseName-exportFilepath-importFilepath
    Retail-db1-192.168.43.192-20105-dttest-db_tpcc-/opt/mot_test-/opt/mot_test
    Credit card-db2-192.168.43.192-20105-dttest-db_tpcc-/opt/mot_test-/opt/mot_test
    Payment 1-db3-192.168.43.192-20105-dttest-db_tpcc-/opt/mot_test-/opt/mot_test
    Payment 2-db4-192.168.43.192-20105-dttest-db_tpcc-/opt/mot_test-/opt/mot_test

    Configuration format:

    Scenario name-dbID-Floating IP address of the MOTService database-MOTService service port (20105 by default)-MOTService database username-MOTService database name-Storage path of the file to be exported-Storage path of the file to be imported

    • dbID: database ID. The value must contain letters and numbers, for example, db1.
    • Storage path of the file to be exported and Storage path of the file to be imported: Enter user-defined absolute paths. Ensure that the user omm has operation permissions on the paths.

  4. Run the following command to go to the directory where the export tool is located:

    cd ${BIGDATA_HOME}/FusionInsight_FARMER_RTD_8.1.0.1/install/FusionInsight-MOTService-2.7.0/tools

  5. Run the following command to start the MOTImportTool.sh import tool:

    sh MOTImportTool.sh Import format

    For example, to import table-level metadata and service data in binary format, run the sh MOTImportTool.sh binary command.

    Currently, data can be imported in only one format at a time. If you enter multiple formats, the help information will be printed. The supported formats are as follows:

    Table 2 Data import formats

    Parameter

    Description

    text

    Imports data in text format.

    binary

    Imports data in binary format.

  6. View the read configuration column and enter dbID corresponding to the scenario data to be imported. For example, to import retail data, enter db1.

    To prevent incorrect input, the message "Are you sure you want to select the type : xxx" is displayed to remind you to confirm the scenario name corresponding to the scenario ID.

    • If the input is correct, enter y or any other key except n.
    • If the input is incorrect, enter n to stop the script. Then, execute the script again.

    Enter y and press Enter.

  7. Enter the database password.
  8. Enter the name of the file to be imported that is configured in 3, for example, test05Dmp. (The binary format is used as an example. The file to be imported must be in .dmp format. So, you only need to enter the file name.)
  9. Check the import result. If the following information is displayed, the import is successful.

    restore operation successfully
    total time: 82 ms