Rate This Document
Findability
Accuracy
Completeness
Readability

(Optional) Importing Data

Import data to the PostgreSQL database through sysbench to verify the correctness and consistency of the migrated data. If the required data is available in the actual environment, skip this section.

Assume that PostgreSQL requires data to be preset, which includes 10 tables and each table contains one million rows.

  1. Install sysbench.
    1. Obtain and decompress the sysbench 1.0.20 source package. For details, see section Obtaining the Source Code in the sysbench 0.5 & 1.0 Test Guide.
    2. In the decompressed source code directory, install the dependencies required by sysbench.
      yum install -y mariadb-devel postgresql-devel
    3. Generate an automatic configuration script.
      ./autogen.sh
    4. To enable sysbench to support PostgreSQL tests, specify the include and lib directories of PostgreSQL.
      ./configure --with-mysql --with-pgsql --with-pgsql-includes=/usr/local/pgsql-13.2/include --with-pgsql-libs=/usr/local/pgsql-13.2/lib
      • --with-pgsql-includes=/usr/local/pgsql-13.2/include:specifies the PostgreSQL header file path during compilation.
      • --with-pgsql-libs=/usr/local/pgsql-13.2/lib: specifies the PostgreSQL library file path during compilation.
    5. Compile and install sysbench.
      make clean && make -j96 && make -j96 install
    6. Verify that the installed sysbench supports PostgreSQL.
      sysbench --db-driver --help

      In the command output, if the parameters related to pgsql - PostgreSQL driver and pgsql options are displayed, PostgreSQL is supported.

  2. Use sysbench to import data to the PostgreSQL database.
    1. Switch to user postgres.
      su - postgres
    2. Create a database named sysbench for storing test data.
      /usr/local/pgsql-13.2/bin/createdb sysbench
    3. Import data.
      sysbench \
      --db-driver=pgsql \
      --pgsql-host=127.0.0.1 \
      --pgsql-port=5432 \
      --pgsql-user=postgres \
      --pgsql-password=123456 \
      --pgsql-db=sysbench \
      --table_size=1000000 \
      --tables=10 \
      --time=180 \
      --threads=96 \
      --report-interval=10 oltp_read_write prepare

      The preceding commands import data to the sysbench database and creates 10 tables, with each table containing one million rows of data.