PostgreSQL多种方式安装

  PostgreSQL

测试环境

测试环境为CentOS7。x x86_64位系统。

前提:

<李>

安装最小化安装

<李>

安装epel源

获取源码

到官方网站获取源代码:

wget  https://ftp.postgresql.org/pub/source/v9.4.6/postgresql-9.4.6.tar.bz2

编译安装

安装依赖

 yum  install  -y  systemtap-sdt-devel  perl-ExtUtils-Embed  \
  pam-devel  libxml2-devel  libxslt-devel  python-devel 

编译

。/configure ——prefix=/opt/pgsql-9.4.6  \
  ——with-perl  \
  ——with-python  \
  ——with-openssl  \
  ——with-pam  \
  ——without-ldap  \
  ——with-libxml  \
  ——with-libxslt  \
  ——enable-thread-safety  \
  ——with-wal-blocksize=16 \
  ——with-blocksize=16 \
  ——enable-dtrace  \
  ——启用调试
  gmake  world  #,安装了包含文档,所有的普通发布版
  gmake  check-world ——,(需要普通用户执行。可选,耗时较长)
  gmake  install-world 

启动服务

 useradd  postgres
  su 作用;postgres
  vi  ~/. bash_profile
  #,添加
  export  PGDATA=https://www.yisu.com/pgdata/pg_root
  出口LANG=en_US.utf8
  出口PGHOME=/opt/pgsql-9.4.6
  出口LD_LIBRARY_PATH=$ PGHOME/lib:/lib64:/usr/lib64:/usr/地方/lib64:/lib:/usr/lib:/usr/地方/lib: LD_LIBRARY_PATH美元
  导出路径=$ PGHOME/bin: $路径
  出口MANPATH=$ PGHOME/分享/男:MANPATH美元
  出口PGUSER=postgres 

 mkdir  -pv /pgdata/pg_root
  chown  -R  postgres: postgres /pgdata/pg_root
  su 作用;postgres
  #,初始化数据
  #,initdb  -D  PGDATA 美元;-E  UTF8 ——地区=C  -U  postgres  - w
  #,会提示输入两次密码

修改配置文件

 vi /etc/sysctl.conf
  
  kernel.shmmni =4096
  kernel.sem =, 50100, 50100, 1280, 50100
  fs.file-max =7672460
  时间=net.ipv4.ip_local_port_range  9000年,65000年
  net.core.rmem_max =4194304
  net.core.wmem_default =262144
  net.core.wmem_max =, 1048576,
  
  sysctl  p 

 vi /etc/安全/limits.conf
  *,soft  nofile  131072年
  *,hard  nofile  131072年
  *,soft  nproc  131072年
  *,hard  nproc  131072年
  *,soft  core 无限的
  *,hard  core 无限的
  *,soft  memlock  50000000
  *,hard  memlock  50000000 

启动数据库

 #, pg_ctl  start  -D  PGDATA美元
  #,或者使用如下的方式启动
  pg_ctl  -D /var/lib/pgsql/data  -l  logfile 开始
  
  bash - 4.2美元,lsof 日志文件
  COMMAND  PID  USER  FD  TYPE  DEVICE 大?OFF  NODE 名字
  postgres  30772, postgres  1 w  REG  8、3, 0, 34606128,日志文件
  postgres  30772, postgres  2 w  REG  8、3, 0, 34606128,日志文件
  bash - 4.2美元,lsof 我:5432
  COMMAND  PID  USER  FD  TYPE  DEVICE 大?OFF  NODE 名字
  postgres  30771, postgres  3 u  IPv6  37671946, 0 t0  TCP  localhost: postgres (听)
  postgres  30771, postgres  4 u  IPv4  37671947, 0 t0  TCP  localhost: postgres (听)

 echo “host  all  all  0.0.0.0/0  md5”,在祝辞PGDATA/pg_hba美元。参看

停止

 pg_ctl  stop  -m 快速智能| | immediate  -D 美元PGDATA 

CentOS二进制包安装

 rpm  -ivh  https://download.postgresql.org/pub/repos/yum/9.4/redhat/rhel - 7 - x86_64/pgdg centos94 - 9.4 - 3. - noarch.rpm 

 yum  install  -y  postgresql94-server。x86_64 

PostgreSQL多种方式安装