# wget https://ftp.postgresql.org/pub/source/v13.0/postgresql-13.0.tar.gzwget https://mirror.tuna.tsinghua.edu.cn/postgresql/source/v13.0/postgresql-13.0.tar.gz
tar -zxf postgresql-13.0.tar.gz
cd postgresql-13.0
1.3 安装
1
2
3
4
5
6
7
8
./configure \
--prefix=/usr/local/pgsql \
--with-openssl \
--with-pam \
--with-systemd \
--with-uuid=e2fs
make && make install
cat > /usr/lib/systemd/system/postgresql.service << 'EOF'
[Unit]
Description=PostgreSQL database server
After=network.target
[Service]
Type=forking
User=postgres
Group=postgres
# Port number for server to listen on
#Environment=PGPORT=5432
# Location of database directory
Environment=PGDATA=/data/pgsql/data
# Where to send early-startup messages from the server (before the logging
# options of postgresql.conf take effect)
# This is normally controlled by the global default set by systemd
# StandardOutput=syslog
# Disable OOM kill on the postmaster
OOMScoreAdjust=-1000
#ExecStartPre=/usr/local/pgsql/bin/postgresql-check-db-dir ${PGDATA}
ExecStart=/usr/local/pgsql/bin/pg_ctl start -D ${PGDATA}
ExecStop=/usr/local/pgsql/bin/pg_ctl stop -D ${PGDATA}
ExecReload=/usr/local/pgsql/bin/pg_ctl reload -D ${PGDATA}
# Give a reasonable amount of time for the server to start up/shut down
TimeoutSec=300
[Install]
WantedBy=multi-user.target
EOF