Hitachi

Hitachi Advanced Database Setup and Operation Guide


11.4.16 Reorganizing a multi-chunk table: Reorganization using a sample shell script

HADB provides a sample shell script ($ADBDIR/sample/reorg_column_sample.sh) that performs chunk-based reorganization for the chunks that need to be reorganized in a multi-chunk table. This section describes how to reorganize a table by using this sample shell script and the processing executed by the sample shell script.

Important
  • You can use this sample shell script for only a multi-chunk table that is a column store table. You cannot use this sample shell script for a multi-chunk table that is a row store table.

  • Note that this sample shell script is provided for only demonstration and its operation is not guaranteed. Before you use the sample shell script, always examine its content, and, if necessary, modify the script. Failure to examine the content of the sample shell script might cause an error that damages the database.

  • A table that is being reorganized by using the sample shell script cannot be accessed.

Organization of this subsection

(1) Procedure for table reorganization using a sample shell script

The following shows the procedure for table reorganization using a sample shell script.

Procedure
  1. Check the size of free space in the data DB area.

    To execute the sample shell script, the data DB area that stores the reorganization-target table must have as large a free space as the data stored in the current chunk.

    If the free space is insufficient in the data DB area, secure sufficient free space as explained in 11.10.6 Securing free space in a data DB area.

  2. Prepare a work directory.

    Note that this directory must be empty. This directory will store files that the HADB server will create during table reorganization.

  3. Execute the sample shell script.

    The following shows the command syntax of the sample shell script.

    ■ Command syntax of the sample shell script

    reorg_column_sample.sh user password schema table workdir
    Table 11‒8: Explanation of arguments

    No.

    Argument

    Explanation

    1

    user

    Specify the authorization identifier of the HADB user.

    2

    password

    Specify the password of the HADB user.

    3

    schema

    Specify the schema name of the column store table to be reorganized.

    4

    table

    Specify the table name of the column store table to be reorganized.

    5

    workdir

    Specify the work directory. Make sure that the directory you specify is empty.

    While the sample shell script is being executed, the following files are generated in the work directory. When execution of the sample shell script ends, all of these files are deleted.

    • File containing the execution results of the adbdbstatus command

    • Output data path file

    • Output data file for the chunk being reorganized

    • Input data file for creating an empty chunk

    • Input data path file for creating an empty chunk

Example

The following shows an example of the sample shell script for reorganizing the data in a column store table on a chunk basis. The specified table name and other items are as follows:

  • Authorization identifier and schema name: ADBUSER01

  • Password: ADBPASSWORD

  • Processing-target column store table: T1

  • Work directory: /home/adbmanager/work_dir

■ Example of specifying commands in the sample shell script

reorg_column_sample.sh ADBUSER01 ADBPASSWORD ADBUSER01 T1 /home/adbmanager/work_dir
Important
  • If an error occurs in execution of a command that is called in the sample shell script, always check the details of the error. Troubleshoot the error, if necessary, and then use the sample shell script.

  • In the sample shell script, you cannot specify command arguments (such as the user name and table name) that include spaces.

(2) Processing that is executed by the sample shell script

When the sample shell script is executed, it stops all access to the target table and reorganizes all chunks that need to be reorganized.

The following shows an overview of the processing that is executed by the sample shell script.

■ Overview of processing

  1. The adbchgsrvmode --offline command is executed, and the HADB server operation mode changes to offline mode.

    For details about offline mode, see 10.2.3 HADB server operation modes.

  2. The comment, chunk ID, and status of the current chunk are obtained.

  3. The following adbdbstatus command is executed, and the chunk IDs of the chunks that need to be reorganized are obtained.

    adbdbstatus -d reorginfo -n processing-target-column-store-table -t
  4. The following steps (a to d) are repeated for each of the chunks other than the current chunk, among the chunks determined in step 3.

    1. The comments and statuses of the reorganization-target chunks are obtained.

    2. The data of the reorganization-target chunks is exported.

    3. The data of the reorganization-target chunks is deleted.

    4. The data exported in step b is imported. At this time, import is performed according to the chunk comment and chunk status obtained in step a.

  5. If the current chunk obtained in step 2 is subject to reorganization, steps a to d of step 4 are executed for the current chunk. If the current chunk obtained in step 2 is not subject to reorganization, an empty chunk is created, which is then merged with the current chunk.

  6. The adbchgsrvmode --normal command is executed, and the HADB server operation mode changes to normal mode.