PostgreSQL安装

PostgreSQL简单安装

1. 系统软件更新(根据具体需要更新)**
yum -y install lrzsz sysstat e4fsprogs ntp readline-devel zlib zlib-devel openssl openssl-devel pam-devel libxml2-devel libxslt-devel python-devel tcl-devel gcc make flex bison perl perl-devel perl-ExtUtils* OpenIPMI-tools systemtap-sdt-devel smartmontools

2. 下载源码包编译安装

cd /opt/soft
wget https://ftp.postgresql.org/pub/source/v9.5.1/postgresql-9.6.2.tar.gz

3. 编译安装

tar -zxvf postgresql-9.6.2.tar.gz
cd /opt/soft/postgresql-9.6.2
./configure --prefix=/usr/local/pgsql --with-pgport=5432 --with-perl --with-tcl --with-python --with-openssl --with-pam --without-ldap --with-libxml --with-libxslt --with-wal-blocksize=8 --with-blocksize=8 --enable-dtrace --enable-debug 
make && make install

>如果需要调试则按照以下方式编译

CFLAGS="-g -ggdb -fno-omit-frame-pointer" ./configure --prefix=/usr/local/pgsql --with-pgport=5432 -enable-debug
CFLAGS="-g -ggdb -fno-omit-frame-pointer" make   
CFLAGS="-g -ggdb -fno-omit-frame-pointer" make install

安装contrib目录下的一些工具,是第三方组织的一些工具代码,建议安装

cd /opt/soft/postgresql-9.6.2/contrib/
make && make install

4. 创建用户和组

groupadd postgres
useradd -g postgres postgres

5.创建数据库数据目录和审计日志目录

mkdir -p /home/postgres/pgdata
mkdir -p /home/postgres/pg_log
chown postgres:postgres /home/postgres/*
chown postgres:postgres /usr/local/pgsql/*
chmod -R 775 /home/postgres/*
*注意数据库data目录权限需是0700*

6.设置环境变量

vi /home/postgres/.bash_profile
export PGHOME=/usr/local/pgsql
export PGPORT=5432
export PGDATA=/home/postgres/pgdata
export DATE=`date +"%Y%m%d%H%M"`
export PGUSER=postgres
export PGHOST=localhost
export PGDATABASE=postgres
export PATH=$PGHOME/bin:$PATH:.
export MANPATH=$PGHOME/share/man:$MANPATH
export LD_LIBRARY_PATH=$PGHOME/lib:$LD_LIBRARY_PATH
export LANG=en_US.utf8
export PG_OOM_ADJUST_FILE=/proc/self/oom_score_adj
export PG_OOM_ADJUST_VALUE=0

7.初始化数据库

su - postgres
initdb -D /home/postgres/pgdata -E UTF8 --locale=C -U postgres 

8.启动数据库

pg_ctl -mf start
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值