1.安装编译所需要的rpm包
- yum install -y readline readline-devel openssl openssl-devel zlib zlib-devel gcc*
2.编译安装
- /configure —prefix=/opt/postgres/soft
- make & make install
3.创建用户,修改环境变量3.创建用户,修改环境变量
- groupadd postgres
- useradd -g postgres postgres
- cat .bash_profile
export PGHOME=/opt/postgres/soft
export PGDATA=/opt/postgres/data
export PATH=$PGHOME/bin:$PATH
4. 创建postgres数据库目录
- mkdir -p /opt/postgres/data
- chown -R postgres:postgres /opt/postgres
5.调整linux内核参数
- vi /etc/sysctl.conf
- kernel.shmmax = 68719476736 (默认)
- kernel.shmall = 4294967296 (默认)
- kernel.shmmni = 4096
- kernel.sem = 50100 64128000 50100 1280
- fs.file-max = 7672460
- net.ipv4.ip_local_port_range = 9000 65000
- net.core.rmem_default = 1048576
- net.core.rmem_max = 4194304
- net.core.wmem_default = 262144
net.core.wmem_max = 1048576
vi /etc/security/limits.conf
-
- soft nofile 131072
-
- hard nofile 131072
-
- soft nproc 131072
-
- hard nproc 131072
-
- soft core unlimited
-
- hard core unlimited
-
- soft memlock 50000000
-
- hard memlock 50000000
6.初始化数据库
- initdb -D $PGDATA -E UTF8 —locale=C -U postgres -W
7.据库的启停
- pg_ctl start -D $PGDATA
- pg_ctl stop -m fast|smart|immediate -D $PGDATA
版权声明:本文为博主原创文章,未经博主允许不得转载。
简易安装postgresql