1.依賴包安裝
yum groupinstall "Development tools" ##開發(fā)包
yum install -y bison ##語法分析器
yum install -y flex ##詞法分析器
yum install -y readline-devel ##psql客戶端的命令歷史
yum install -y zlib-devel ##pg_dump/pg_restore的壓縮功能支持
yum install docbook-dtds
yum install docbook-style-dsssl
yum install docbook-style-xsl
yum install libxslt
yum install bxslt-devel
2.創(chuàng)建用戶、目錄
useradd postgres
echo postgres | passwd --stdin postgres
mkdir -p /u07
mkdir -p /u07/pgsql
mkdir -p /u07/pg_data
chown -R postgres:postgres /u07
chmod -R 755 /u07
3.編譯安裝
./configure --prefix=/u07/pgsql \
--enable-cassert \
--enable-debug \
--enable-depend CFLAGS=-O0
make world&& make install-world
編譯選項
重要
--prefix= PREFIX 安裝路徑
--with-blocksize=BLOCKSIZE 數(shù)據(jù)庫blocksize ,缺省8KB
--with-segsize=SEGSIZE 表文件的段尺寸,缺省1GB
-with-llvm 使用基于JIT的lIvm編譯
存儲過程語言支持
--with-tcl
--with-tclconfig = DIR
--with-perl
--with-python
安全選項
--with-gssapi
--with-krb-srvnam = NAME
--with-pam
--with-bsd-auth
--with-ldap
---with-bonjour
--with-openssl
--with-selinux
其他
--enable-debug
4.修改環(huán)境變量
vi ~/.bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin
export PATH
export PGDATA=/u07/pg_data
export PGHOME=/u07/pgsql
export PGDATABASE=postgres
export PGPORT=5432
export LD_LIBRARY_PATH=$PGHOME/lib
export PATH=$PGHOME/bin:$PATH
source .bash_profile
5.初始數(shù)據(jù)庫
initdb -D $PGDATA -E utf8 --wal-segsize=8
pg_ctl start