发布于 2015-11-12 14:23:37 | 231 次阅读 | 评论: 0 | 来源: PHPERZ

这里有新鲜出炉的PostgreSQL指南,程序狗速度看过来!

PostgreSQL关系型数据库管理系统

PostgreSQL是以加州大学伯克利分校计算机系开发的 POSTGRES,现在已经更名为PostgreSQL,版本 4.2为基础的对象关系型数据库管理系统(ORDBMS)。


Linux平台下的安装

以下操作环境基于CentOS7-86_64

我们知道在Linux系统下安装软件有两条路可以走,一是下载源代码自行编译,二是使用官方的软件仓库
安装。我个人是非常推荐使用官方的仓库来安装的,使用官方的软件仓库安装软件有如下优点:

  1. 拥有开发者调试过的最佳性能

  2. 自动解决令人头痛的依赖

  3. 提供了通用的系统管理接口

PostgreSQL 现存很多版本,分别是7.3、7.4、8.0、8.1、8.2、8.3、8.4、9.0、9.1、9.2、
9.3、9.4、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版
本来进行下面的练习。

# 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来初始化,必须使用这个命令:

# /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,可以愉快地进行下一步实验了。



最新网友评论  共有(0)条评论 发布评论 返回顶部

Copyright © 2007-2017 PHPERZ.COM All Rights Reserved   冀ICP备14009818号  版权声明  广告服务