postgresql 基本安装

1.软件下载

官网下载地址12.6版本
本文章是采用二进制安装方式,如果想采用别的方法可以看官网https://www.postgresql.org/download/

https://ftp.postgresql.org/pub/source/v12.6/postgresql-12.6.tar.gz

注意在安装时候保证防火墙、selinux等关闭

2.安装准备


1. 创建用户
 useradd postgres
 passwd  postgres
2. 安装依赖包
yum groupinstall -y "Development Tools" "Legacy UNIX Compatibility" -y
yum install -y bison flex readline* zlib-devel gcc* gmake -y
3. 创建目录并授权
mkdir -p /opt/pg12
mkdir -p /pgdata/data
mkdir -p /archive
chown -R postgres. /pgdata
chown -R postgres. /archive
chown -R postgres. /opt/pg12
chmod 700 /pgdata/data  -R
4. 配置系统参数
# vim   /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

开启生效参数
# sysctl -p
# vim    /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

3. 编译

上传软件到服务器

# tar xf postgresql-12.6.tar.gz
# cd postgresql-12.6
# ./configure --prefix=/usr/local/pg12 --with-pgport=1921
# gmake world
# gmake install-world

4.设置环境变量

su - postgres
$ vim .bash_profile
export PGDATA=/pgdata/data
export LANG=en_US.utf8
export PGHOME=/opt/pg12
export LD_LIBRARY_PATH=$PGHOME/lib:/lib64:/usr/lib64:/usr/local/lib64:/lib:/usr/lib:/usr/local/lib:$LD_LIBRARY_PATH
export DATE=`date +"%Y%m%d%H%M"`
export PATH=$PGHOME/bin:$PATH:.
export MANPATH=$PGHOME/share/man:$MANPATH
export PGUSER=postgres

5.初始化

initdb -A md5 -D $PGDATA -E utf8 --locale=C -W

在这里插入图片描述

6. 启动/关闭

pg_ctl -D /pgdata/12/data/ start/stop/restart -l logfile
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值