postgresql源码编译安装

基本环境

安装方式:编译安装
操作系统:rokeylinux
用户:postgres
安装位置:/usr/local/postgres
data位置:/home/postgres/data

创建用户建路径赋权

useradd postgres
mkdir /usr/local/postgres
mkdir /home/postgres/data
chown postgres:postgres -R /usr/local/postgres
chown postgres:postgres -R /home/postgres/data

添加依赖包

yum install -y gcc
yum install -y gcc-c++
yum install -y libicu-devel
yum install -y perl-ExtUtils-Embed.noarch
yum install -y readline
yum install -y readline-devel
yum install -y zlib
yum install -y zlib-devel
yum install -y openssl
yum install -y openssl-devel
yum install -y pam-devel
yum install -y libxml2-devel
yum install -y libxslt-devel
yum install -y openldap-devel
yum install -y systemd-devel
yum install -y tcl-devel
yum install -y python-devel

配置编译参数

./configure --prefix=/usr/local/postgres --with-pgport=5432 --with-perl --with-openssl --with-tcl --with-python --with-pam --with-ldap --enable-thread-safety --with-blocksize=16 --with-wal-blocksize=16 --enable-debug --with-systemd

编译安装

make && make install
/usr/local/postgres/bin/initdb -D /home/postgres/data

配置服务

vim /usr/lib/systemd/system/psql.service
[Unit]
Description=The PostgreSQL Database Server
After=network.target

[Service]
Type=forking
User=postgres
Group=postgres

ExecStart=/usr/local/postgres/bin/pg_ctl start -D /home/postgres/data
ExecStop=/usr/local/postgres/bin/pg_ctl stop
ExecReload=/usr/local/postgres/bin/pg_ctl reload -D /home/postgres/data
TimeoutSec=300

[Install]
WantedBy=multi-user.target

启动服务

systemctl daemon-reload
systemctl start psql

你可能感兴趣的:(数据库,postgresql,数据库)