Rate This Document
Findability
Accuracy
Completeness
Readability

Compiling and Installing PostgreSQL

Build the PostgreSQL database from the source code.

  1. Download the PostgreSQL 11.3 source package postgresql-11.3.tar.gz.

    For the download URL, see Environment Requirements.

  2. Upload the source package to the /home directory on the server, go to the /home directory, and decompress the source package.
    1
    2
    cd /home
    tar -xvf postgresql-11.3.tar.gz
    

  3. Go to the decompressed PostgreSQL directory and compile PostgreSQL.
    1
    2
    cd /home/postgresql-11.3
    ./configure -prefix=/usr/local/pgsql
    

  4. Configure performance tuning options.
    1. Open the Makefile.global file.
      1
      vim /home/postgresql-11.3/src/Makefile.global
      
    2. Press i to enter the insert mode and add the following content to the end of line 261 to enable LSE performance optimization:
      -march=armv8-a+crc+lse

      The target file content:

    3. Press Esc, type :wq!, and press Enter to save the file and exit.
  5. Install PostgreSQL.
    1
    make -j 64
    

    1
    make -j 64 install
    

    In the command, -j 64 can make full use of the multi-core feature of the CPUs to accelerate the compilation. The number following -j indicates the number of CPU cores. You can run the cat /proc/cpuinfo | grep processor | wc -l command to query the number of CPU cores. The value specified must be less than or equal to the actual number of CPU cores.

  6. View the PostgreSQL installation directory.
    1
    ls /usr/local/pgsql
    
  7. View the PostgreSQL version.
    1
    /usr/local/pgsql/bin/postgres --version