一、安装规划
- 安装单实例
- 配置主从
- 安装pgpool -ii
二、单实例安装
2.1 操作系统
os: centos 7.6
cpu: 4 core
memory:32g
disk: 60g
192.168.0.1
192.168.0.2
2.2 postgresql 软件准备
源码: postgresql 11.5
2.3 安装前检查
使用 yum install 安装以下包
make 2.5+
gcc
readline readline-devel
zlib
zlib-devel
perl 5.8.3
perl-devel
python
tcl 8.4
2.4 修改内核参数、增加postgres用户、修改/dev/shm 大小
2.4.1 修改内核参数
net.ipv4.ip_forward = 0
net.ipv4.conf.default.rp_filter = 1
net.ipv4.conf.default.accept_source_route = 0
kernel.sysrq = 0
kernel.core_uses_pid = 1
net.ipv4.tcp_syncookies = 1
kernel.msgmnb = 65536
kernel.msgmax = 65536
kernel.shmmax = 123695058124
kernel.shmall = 30198988
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default = 262144
net.core.rmem_max = 41943040
net.core.wmem_default = 262144
net.core.wmem_max = 1048576
2.4.2 增加用户
useradd postgres
passwd postgres
2.4.3 修改/dev/shm
fuser -km /dev/shm
mount -t tmpfs -o size=10240m tmpfs /dev/shm
vi /etc/fstab
tmpfs /dev/shm tmpfs defaults,size=10240m 0 0
备注:不修改这个,后面在大并发查询时,可能会出现下面大错误
CAUSE BY:could not resize shared memory segment "/PostgreSQL.644318876" to 196864 bytes: 设备上没有空间
2.6 修改limit配置
/etc/security/limits.conf
postgres soft nproc 65536
postgres hard nproc 65536
postgres soft nofile 2048
postgres hard nofile 65536
postgres soft stack 10240
postgres hard stack 10240
2.7 源码安装
scp postgresql-11.5.tar.gz postgres@192.168.0.1:/tmp
postgres login the 192.168.0.1
cd /tmp
tar zxvf postgresql-11.5.tar.gz
./configure
make
su -
make install
mkdir /work/pgsql/data
chown postgres /work/pgsql/data
su - postgres
#初始化数据库
/usr/local/pgsql/bin/initdb -D /work/pgsql/data
|
#启动实例
/usr/local/pgsql/bin/pg_ctl -D /work/pgsql/data -l logfile start
|