如下操做环境基于CentOS7-86_64java
咱们知道在Linux系统下安装软件有两条路能够走,一是下载源代码自行编译,二是使用官方的软件仓库
安装。我我的是很是推荐使用官方的仓库来安装的,使用官方的软件仓库安装软件有以下优势:python
拥有开发者调试过的最佳性能sql
自动解决使人头痛的依赖数据库
提供了通用的系统管理接口centos
PostgreSQL 现存不少版本,分别是7.三、7.四、8.0、8.一、8.二、8.三、8.四、9.0、9.一、9.二、
9.三、9.四、9.5,其中,7.3到9.0版本 被标记为上游再也不支持(no longer maintained by upst
ream),
而9.5版本被标记为“BETA TESTING ONLY, NOT FOR PRODUCTION”,即仅供测试,不得用于生产
环境。(本文写于2015--11-12,你读到本文时,极可能状况已经变化,请访问此处 来获取最新的版本状况)。基于当前PostgreSQL的版本情况,我推荐使用9.4版
原本进行下面的练习。post
# yum localinstall http://yum.postgresql.org/9.4/redhat/rhel-7-x86_64/pgdg-cen tos94-9.4-2.noarch.rpm
其中,pgdg-centos94-9.4-2.noarch.rpm是适用于CentOS 7-x86_64的软件包。一样地,也能够访问上一个连接来获取符合你使用的发行版的软件包。若是安装此软件后,会
自动配置PostgreSQL的安装源,如今,咱们来看下源中是否具备postgresql的安装包:性能
# yum list postgresql* Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: centos.ustc.edu.cn * epel: ftp.cuhk.edu.hk * extras: mirrors.pubyun.com * ius: mirrors.tuna.tsinghua.edu.cn * remi-safe: mirrors.neterra.net * updates: mirrors.sina.cn Installed Packages postgresql-libs.x86_64 9.2.13-1.el7_1 @updates ******略去大量无用输出******** postgresql-upgrade.x86_64 9.2.13-1.el7_1 updates postgresql94-contrib.x86_64 9.4.5-1PGDG.rhel7 pgdg94 postgresql94-debuginfo.x86_64 9.4.5-1PGDG.rhel7 pgdg94 postgresql94-devel.x86_64 9.4.5-1PGDG.rhel7 pgdg94 postgresql94-docs.x86_64 9.4.5-1PGDG.rhel7 pgdg94 postgresql94-jdbc.noarch 9.3.1101-2.rhel7 pgdg94 postgresql94-jdbc-javadoc.noarch 9.3.1101-2.rhel7 pgdg94 postgresql94-odbc.x86_64 09.03.0400-1PGDG.rhel7 pgdg94 postgresql94-odbc-debuginfo.x86_64 09.03.0400-1PGDG.rhel7 pgdg94 postgresql94-plperl.x86_64 9.4.5-1PGDG.rhel7 pgdg94 postgresql94-plpython.x86_64 9.4.5-1PGDG.rhel7 pgdg94 postgresql94-pltcl.x86_64 9.4.5-1PGDG.rhel7 pgdg94 postgresql94-python.x86_64 4.1.1-2PGDG.rhel7 pgdg94 postgresql94-python-debuginfo.x86_64 4.1.1-2PGDG.rhel7 pgdg94 postgresql94-test.x86_64
能够看到,实际上是CentOS默认源是包含了PostgreSQL9.2的。不过这个不重要,咱们继续。测试
# yum install postgresql94-server
固然还能够根据需求安装其余的包,针对目前的练习,安装这个包就足够了。操作系统
安装完成后,须要初始化数据库。PostgreSQL对systemd支持并不完整,因此不能像在CentOS6.X中
直接使用系统命令service来初始化,必须使用这个命令:.net
# /usr/pgsql-9.4/bin/postgresql94-setup initdb Initializing database ... OK
此时系统初始化已经完毕,能够启动后台服务了:
# systemctl list-unit-files |grep postgresql postgresql-9.4.service disabled # systemctl start postgresql-9.4 # systemctl enable postgresql-9.4
此刻,你的操做系统中就安装好了PostgreSQL,能够愉快地进行下一步实验了。