一、参考资料
Oracle Linux 7 RPM方式安装PG12数据库...
链接:http://note.youdao.com/noteshare?id=d4f82fd6b4d4cbd44f52221f25173f00&sub=36E4C4E7CFC44E4EB827B49861D5F71A
Oracle Linux 7 源码方式安装PG12数据库
参考
http://note.youdao.com/noteshare?id=f98cb215687871773b50329b266e2714&sub=2F59C7CB8B6E425EBBC0677F7DCBCDCF
二、下载链接
https://www.postgresql.org/ftp/source/v12.0/
三、安装(源码)
1、安装oracle linux系统
2、上传安装包到/usr/local/
3、部署命令(可直接放入脚本执行)
#!/bin/bash
#设置主机名
echo "设置主机名"
hostnamectl set-hostname pg01
hostname
#设置hosts
echo "设置hosts"
echo "192.168.18.9 pg01" >> /etc/hosts
cat /etc/hosts
#设置英文环境
echo "设置英文环境"
echo "export LANG=en_US" >> ~/.bash_profile
cat ~/.bash_profile
#修改资源限制参数
echo "修改资源限制参数"
cp /etc/security/limits.conf{,.bak}
cat >> /etc/security/limits.conf << "EOF"
* soft nproc 65535
* hard nproc 65535
* soft nofile 65535
* hard nofile 65535
* soft stack 65535
* hard stack 65535
EOF
cat /etc/security/limits.conf
#查看资源限制
echo "查看资源限制"
tmp1=`ls /etc/security/limits.d/*-nproc.conf`
cp tmp1{,.bak}
cat $tmp1
echo "* - nproc 65535" > $tmp1
cat $tmp1
#ssh资源配置
echo "ssh资源配置"
echo "session include postlogin" >> /etc/pam.d/login
cat /etc/pam.d/login
#关闭SElinux
echo "关闭SElinux"
sed -i "s#SELINUX=enforcing#SELINUX=disabled#g" /etc/selinux/config
setenforce 0
#关闭防火墙
echo "关闭防火墙"
systemctl disable firewalld.service
systemctl stop firewalld.service
systemctl status firewalld.service
#设置sysctl.conf参数
echo "设置sysctl.conf参数"
cat >> /etc/sysctl.conf << "EOF"
vm.swappiness=10
vm.min_free_kbytes=512000
fs.aio-max-nr = 1048576
fs.file-max = 6815744
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048586
kernel.shmmax = 13743895347
kernel.shmall = 3355443
kernel.shmmni = 4096
kernel.sem = 4096 2147483647 2147483646 512000
EOF
cat /etc/sysctl.conf
#解压安装包
tar -zxvf /usr/local/postgresql-12.0.tar.gz
cd /usr/local/postgresql-12.0
#安装依赖
yum install -y gcc
yum install -y bison
yum install -y ncurses
yum install -y ncurses-devel
yum install -y zlib
yum install -y zlib-devel
yum install -y readline-devel
yum install -y libxml2
yum install -y openssl
yum install -y libstdc++-devel
yum install -y gcc-c++
#设置安装路径
mkdir /etc/postgresql12
./configure --prefix=/etc/postgresql12
cd /usr/local/postgresql-12.0
make
make install
#初始化设置
/etc/postgresql12/data/
mkdir /etc/postgresql12/data
chown postgres /etc/postgresql12/data/
chgrp postgres /etc/postgresql12/data/
/etc/postgresql12/data/
#设置数据目录
su - postgres
/etc/postgresql12/bin/initdb -D /etc/postgresql12/data/
#修改配置文件
su - root
#放开访问
echo "host all postgres 0.0.0.0/0 trust" >> /etc/postgresql12/data/pg_hba.conf
#设置监听ip和端口
echo "listen_addresses = '*'" >> /etc/postgresql12/data/postgresql.conf
echo "port = 5432" >> /etc/postgresql12/data/postgresql.conf
cat /etc/postgresql12/data/postgresql.conf | grep "^[a-z]"
#启动postgresql
su - postgres
/etc/postgresql12/bin/pg_ctl -D /etc/postgresql12/data/ -l /etc/postgresql12/logs/pg.log start
网友评论