PostgreSQL can be installed using RPMs (binary) or SRPMs (source) managed by YUM. This is available for the following Linux distributions (both 32- and 64-bit platforms; for the current release and prior release or two):

  • Fedora
  • Red Hat Enterprise Linux
  • CentOS
  • Scientific Linux
  • Oracle Enterprise Linux

See links from the main repository, http://yum.postgresql.org:

Contents

[hide]

Instructions

Configure your YUM repository

Locate and edit your distributions .repo file, located:

  • On Fedora: /etc/yum.repos.d/fedora.repo and /etc/yum.repos.d/fedora-updates.repo, [fedora] sections
  • On CentOS: /etc/yum.repos.d/CentOS-Base.repo, [base] and [updates] sections
  • On Red Hat: /etc/yum/pluginconf.d/rhnplugin.conf [main] section

To the section(s) identified above, you need to append a line (otherwise dependencies might resolve to the postgresql supplied by the base repository):

exclude=postgresql*

Install PGDG RPM file

A PGDG file is available for each distribution/architecture/database version combination. Browse http://yum.postgresql.org and find your correct RPM. For example, to install PostgreSQL 9.4 on CentOS 6 64-bit:

yum localinstall http://yum.postgresql.org/9.4/redhat/rhel-6-x86_64/pgdg-centos94-9.4-1.noarch.rpm

Install PostgreSQL

To list available packages:

yum list postgres*

For example, to install a basic PostgreSQL 9.4 server:

yum install postgresql94-server

Other packages can be installed according to your needs.

Post-installation commands

After installing the packages, a database needs to be initialized and configured.

In the commands below, the value of <name> will vary depending on the version of PostgreSQL used.

For PostgreSQL version 9.0 and above, the <name> includes the major.minor version of PostgreSQL, e.g., postgresql-9.4

For versions 8.x, the <name> is always postgresql (without the version signifier).

Data Directory

The PostgreSQL data directory contains all of the data files for the database. The variable PGDATA is used to reference this directory.

For PostgreSQL version 9.0 and above, the default data directory is:

/var/lib/pgsql/<name>/data

For example:

/var/lib/pgsql/9.4/data

For versions 7.x and 8.x, default data directory is:

/var/lib/pgsql/data/

Initialize

The first command (only needed once) is to initialize the database in PGDATA.

service <name> initdb

E.g. for version 9.4:

service postgresql-9.4 initdb

If the previous command did not work, try directly calling the setup binary, located in a similar naming scheme:

/usr/pgsql-y.x/bin/postgresqlyx-setup initdb

E.g. for version 9.4:

/usr/pgsql-9.4/bin/postgresql94-setup initdb

Startup

If you want PostgreSQL to start automatically when the OS starts:

chkconfig <name> on

E.g. for version 9.4:

chkconfig postgresql-9.4 on

In RHEL 7+, try:

systemctl enable postgresql

Control service

To control the database service, use:

service <name> <command>

where <command> can be:

  • start : start the database
  • stop : stop the database
  • restart : stop/start the database; used to read changes to core configuration files
  • reload : reload pg_hba.conf file while keeping database running

E.g. to start version 9.4:

service postgresql-9.4 start

With RHEL 7.1+ and CentOS 7.1+, Systemd is introduced. Use this instead:

systemctl enable postgresql-9.4.service
systemctl start postgresql-9.4.service

Removing

To remove everything:

yum erase postgresql94*

Or remove individual packages as desired.

YUM Installation PostgreSQL的更多相关文章

  1. 与你相遇好幸运,CentOS 7 x86_64使用Yum安装PostgreSQL

    访问http://yum.pgrpms.org/reporpms/repoview/letter_p.group.html,下载并安装和当前系统对应的rpm文件. wget https://downl ...

  2. CentOS下yum安装PostgreSQL

    关键词:centos install PostgreSQL Configure YUM repository vim /etc/yum.repos.d/CentOS-Base.repo [base] ...

  3. Centos7 yum安装postgresql 9.5

    添加RPM yum install https://download.postgresql.org/pub/repos/yum/9.5/redhat/rhel-7-x86_64/pgdg-centos ...

  4. yum安装PostgreSQL 在6和7

    一.安装PostgreSQL 复制代码// 安装EPEL源# wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.n ...

  5. CentOS7使用yum安装PostgreSQL和PostGIS

    更新yum源 CentOS7默认yum源的PostgreSQL版本过低,不适合在本版本上使用.在https://yum.postgresql.org/repopackages.php上找到适合Cent ...

  6. centos使用Yum安装postgresql 13

    rpm源安装 yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat ...

  7. yum安装postgresql

    https://wiki.postgresql.org/wiki/YUM_Installation

  8. postgresql数据库的yum安装方法

    实验环境>>>>>>>>>>>>>>>>>>操作系统:CentOS release 6.3 ...

  9. postgresql安装部署

    一.下载安装: 1.下载: 官网下载地址:https://www.postgresql.org/download/linux/redhat/ 也可以用这个:https://www.enterprise ...

随机推荐

  1. The number of divisors(约数) about Humble Numbers[HDU1492]

    The number of divisors(约数) about Humble Numbers Time Limit: 2000/1000 MS (Java/Others)    Memory Lim ...

  2. BZOJ1769 : [Ceoi2009]tri

    将所有点极角排序,建立线段树,线段树每个节点维护该区间内所有点组成的上下凸壳. 对于一个查询,二分查找出相应区间的左右端点,在线段树上得到$O(\log n)$个节点,在相应凸壳上三分查找出与斜边叉积 ...

  3. js中等性操作符(==)、关系操作符(<,>)和布尔操作符(!)比较规则

    最近一直在笔试面试,经常碰到例如 123=='123'.'abc'==true等问题,其中有答对的,也有答错的,主要原因还是对ECMAScript的规范没有理解清楚,很多题目没有具体分析所导致.现查阅 ...

  4. wp7 HubTile

    在最新的Windows Phone Toolkit中我们可以看到HubTile这个控件,首先先了解下什么是HubTile,简单来说,就是允许你给你的应用程序添加些生动或富有意义的瓦片(Tile).Hu ...

  5. USACO 5.4 Character Recognition(DP)

    非常恶心的一题,卡了三个月,没什么动力做了,代码直接抄的别人的... 这题主要思路就是预处理出几个数组,再预处理出几个数组,最后DP,输出一下路径... 写起来挺非常麻烦,代码不贴了,丢人... 把U ...

  6. BZOJ4129: Haruna’s Breakfast

    Description Haruna每天都会给提督做早餐! 这天她发现早饭的食材被调皮的 Shimakaze放到了一棵 树上,每个结点都有一样食材,Shimakaze要考验一下她. 每个食材都有一个美 ...

  7. C#中使用JQueryUI中Autocomplete插件

    服务器端后台代码: 1 private string GetModelNames() { 2 return @"[ 3 { 4 'value': 'jquery', 5 'label': ' ...

  8. 产生一个int数组,长度为100,并向其中随机插入1-100,并且不能重复

    产生一个int数组,长度为100,并向其中随机插入1-100,并且不能重复 用一个ArrayList存储1到100然后随机产生0到arraylist.size()之间的数字作为下标然后从arrayli ...

  9. CSS3选择器(三)之伪类选择器

    伪类选择器对于大家来说最熟悉的莫过于:link,:focus,:hover之类的了,因为这些在平时中是常用到的伪类选择器,那么先和大家一起简单总 结一下CSS中常用的伪类选择器的使用方法,最后把重心放 ...

  10. SecureCRT的相关问题

    1. 中文显示乱码的解决方法 2. 显示Linux中的颜色信息 3. 解决终端长时间无输入导致SSH连接中断的问题 4. 以公钥方式代替密码方式登录服务器 在SecureCRT中创建Public Ke ...