安装PostgreSQL单机版

推荐安装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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值