(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.
- For details about how to install PostgreSQL on an x86 server, see the PostgreSQL 13 Installation Guide or PostgreSQL 15 Installation Guide.
- For details about how to install PostgreSQL on a Kunpeng server, see Installing PostgreSQL in this document.
Installing PostgreSQL
- 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
- 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
- Configure compilation options related to the Arm architecture.
Skip this step for the x86 architecture.
- Open the file.
vi /data/pg-13.2/postgresql-13.2/src/Makefile.global
- 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

- Press Esc, type :wq!, and press Enter to save the file and exit.
- Open the file.
- Compile PostgreSQL.
make -j20 make -j20 install
- Verify the installation.
- 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

- 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
- Check the installation directory and ensure that the binary file is compiled and installed successfully.
Parent topic: Deployment Environment