一、规划
192.168.4.225 h1主库
192.168.4.226 h2备库
二、编译安装
在h1和h2都要执行以下操作:
(1)下载源码:
cd /home/wslu/work/pg/postgresql
git clone https://github.com/postgres/postgres .
(2)编译、安装
./configure --prefix=/home/wslu/work/pg/pgsql
make
make install
三、初始化环境变量
在h1和h2都要执行:
export PGDATA=/home/wslu/work/pg/pgsql/dataexport PATH=/home/wslu/work/pg/pgsql/bin:$PATH
export LD_LIBRARY_PATH=/home/wslu/work/pg/pgsql/lib
四、初始化主库
在h1执行:
wslu@h1:~/work/pg/pgsql$ initdb The files belonging to this database system will be owned by user "wslu". This user must also own the server process. The database cluster will be initialized with locale "zh_CN.UTF-8". The default database encoding has accordingly been set to "UTF8". initdb: could not find suitable text search configuration for locale "zh_CN.UTF-8" The default text search configuration will be set to "simple". Data page checksums are disabled. creating directory /home/wslu/work/pg/pgsql/data ... ok creating subdirectories ... ok selecting default max_connections ... 100 selecting default shared_buffers ... 128MB selecting dynamic shared memory implementation ... posix creating configuration files ... ok creating template1 database in /home/wslu/work/pg/pgsql/data/base/1 |