Rate This Document
Findability
Accuracy
Completeness
Readability

(Optional) Installing PostgreSQL

To migrate the PostgreSQL database from an x86 server to a Kunpeng server, install and run PostgreSQL on both of the servers. If the PostgreSQL primary/secondary deployment environment has been prepared, skip this section.

Installing PostgreSQL

  1. Install the dependencies.
    yum -y install gcc gcc-c++
    yum -y install automake zlib  bzip2-libs readline bison ncurses gmp mpfr mpfr-devel libmpc
    yum -y install zlib-devel bzip2 bzip2-devel  readline-devel libaio-devel ncurses-devel gmp-devel
  2. Download the PostgreSQL source code.
    mkdir -p /data/pg-13.2
    cd /data/pg-13.2
    wget https://ftp.postgresql.org/pub/source/v13.2/postgresql-13.2.tar.gz --no-check-certificate
    tar -zxvf postgresql-13.2.tar.gz
    cd /data/pg-13.2/postgresql-13.2
    ./configure -prefix=/usr/local/pgsql-13.2
  3. Configure compilation options related to the Arm architecture.

    Skip this step for the x86 architecture.

    1. Open the file.
      vi /data/pg-13.2/postgresql-13.2/src/Makefile.global
    2. Press i to enter the insert mode. Find CFLAGS and CXXFLAGS in the file and add the compilation option to them as follows:
      -march=armv8-a+crc+lse

    3. Press Esc, type :wq!, and press Enter to save the file and exit.
  4. Compile PostgreSQL.
    make -j20
    make -j20 install

    The -j20 parameter can fully utilize the multi-core feature of the CPUs to accelerate the compilation. The number following -j indicates the number of CPU cores. Run cat /proc/cpuinfo | grep processor | wc -l to query the number of CPU cores. The number specified must be less than or equal to the actual number of CPU cores.

  5. Verify the installation.
    1. Check the installation directory and ensure that the binary file is compiled and installed successfully.
      ls /usr/local/pgsql-13.2
      /usr/local/pgsql-13.2/bin/postgres --version

    2. Create the postgres user and user group, and create the data and archive directories.
      groupadd postgres
      useradd -g postgres postgres
      mkdir -p /data/pg-13.2/data
      chown -R postgres:postgres /data/pg-13.2/data
      mkdir -p /data/pg-13.2/archive
      chown -R postgres:postgres /data/pg-13.2/archive