如何在Linux和BSD上安装PostgreSQL 10

时间:2020-03-05 15:28:07  来源:igfitidea点击:

在前面的文章中,我们介绍了Centos7上的phpPgAdmin配置。

在本文中,我将展示如何在Linux和BSD发行版上安装最新的PostgreSQL 10数据库。
PostgreSQL是一个与对象相关的数据库管理系统.PostgreSQL 10的最新稳定版本包括使用发布/订阅进行逻辑复制,声明性表分区,改进的查询并行性,显着的常规性能改进,更强的密码身份验证以及改进的监视和控制等功能。

RedHat/CentOS安装

对于RHEL/CentOS 6

安装RPM存储库

# yum install https://download.postgresql.org/pub/repos/yum/10/redhat/rhel-6-x86_64/pgdg-redhat10-10-1.noarch.rpm

安装服务器软件包

# yum install postgresql10-server

安装客户端软件包

# yum install postgresql10

初始化数据库并自动启动

# service postgresql-10 initdb
# chkconfig postgresql-10 on
# service postgresql-10 start

对于RHEL/CentOS 7

安装RPM存储库

# yum install https://download.postgresql.org/pub/repos/yum/10/redhat/rhel-7-x86_64/pgdg-redhat10-10-1.noarch.rpm

安装服务器软件包

# yum install postgresql10-server

安装客户端软件包

# yum install postgresql10

初始化数据库并自动启动

# /usr/pgsql-10/bin/postgresql10-setup initdb
# systemctl enable postgresql-10
# systemctl start postgresql-10

Debian安装

我们将需要创建文件/etc/apt/sources.list.d/pgdg.list并根据Debian发行版为PostgreSQL存储库添加一行

Wheezy 7.x

deb http://apt.postgresql.org/pub/repos/apt/wheezy-pgdg main

杰西8.x

deb http://apt.postgresql.org/pub/repos/apt/jessie-pgdg main

拉伸9.x

deb http://apt.postgresql.org/pub/repos/apt/stretch-pgdg main

导入密钥并更新软件包列表

$wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add 
$sudo apt-get update

安装PostgreSQL

$sudo apt-get install postgresql-10

笔记
我们可能需要以root用户身份安装sudo软件包

$su 
# apt install sudo

并将非root用户添加到sudo组

# usermod -a -G sudo username

Ubuntu安装

之前我们写过一篇关于安装Postgresql 9.6的文章,并在Ubuntu 16.04上访问PHPpgAdmin。

我们将需要创建文件/etc/apt/sources.list.d/pgdg.list并根据Ubuntu发行版为PostgreSQL存储库添加一行

Trusty 14.04

deb http://apt.postgresql.org/pub/repos/apt/trusty-pgdg main

Xenial 16.04

deb http://apt.postgresql.org/pub/repos/apt/xenial-pgdg main

Zesty 17.04

deb http://apt.postgresql.org/pub/repos/apt/zesty-pgdg main

导入密钥并更新软件包列表

$wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add 
$sudo apt-get update

安装PostgreSQL

$sudo apt-get install postgresql-10

FreeBSD 11安装

搜索PostgreSQL包

# pkg search postgresql10

安装

# pkg install postgresql10

要在启动时运行数据库,请在/etc/rc.conf中添加postgresql_enable =“ YES”

# sysrc postgresql_enable="YES"

在开始使用之前启用集群

# service postgresql initdb

启动PostgreSQL

# service postgresql start