推荐安装9.6以上的版本,多了空闲事务超时参数idle_in_transaction_session_timeout
yum -y update gcc
yum -y install g==
yum -y install g++
yum -y install gcc+
yum install -y libxml2-devel.x86_64
yum search libxml2-devel
yum search gcc
yum -y install libtool
yum -y install gcc-c++.x86_64
yum search readline
yum install -y readline-devel.x86_64
yum install -y zlib-devel.x86_86
useradd postgres
cd /usr/local/
tar zxvf /root/postgresql-9.6.12.tar.gz
cd /usr/local/postgresql-9.6.12
./configure --prefix=/usr/local/pgsql --with-libxml
make
make install
mkdir /data/postgres/data -p
mkdir /data/postgres/log -p
chown -R postgres.postgres /data/postgres/
ln -s /usr/local/pgsql/bin/psql /usr/bin/
ln -s /usr/local/pgsql/bin/pg_ctl /usr/bin/
cat>/root/.bash_profile<<EOF
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
EOF
echo ‘PATH=
P
A
T
H
:
PATH:
PATH:HOME/.local/bin:$HOME/bin:/usr/local/pgsql/bin’>>/root/.bash_profile
echo ‘export PATH’>>/root/.bash_profile
sudo su postgres
cd /usr/local/pgsql/
bin/initdb -D /data/postgres/data
sed -i “86s/127.0.0.1/0.0.0.0/” /data/postgres/data/pg_hba.conf
sed -i “86s/32/0/” /data/postgres/data/pg_hba.conf
sed -i “59s/#l/l/” /data/postgres/data/postgresql.conf
sed -i “59s/localhost/*/” /data/postgres/data/postgresql.conf
bin/pg_ctl -D /data/postgres/data -l /data/postgres/log/pg_server.log start &
cat > /tmp/pg_sec_script<<EOF
alter user postgres with password ‘Postgres123@’
EOF
psql< /tmp/pg_sec_script
rm -f /tmp/pg_sec_script
sed -i “86s/trust/md5/” /data/postgres/data/pg_hba.conf