热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

CentOS系统中安装postgresql数据库

(1)从http://yum.pgrpms.org/repopackages.php下载postgresql9.1rpm安装包[root@server1~]#wgethttp://yum.pgrpms.org/9.1/redhat/rhel-5-i386/pgdg-centos91-9.1-4.noarch.rpm(2
(1) 从http://yum.pgrpms.org/repopackages.php 下载postgresql9.1 rpm安装包
  [root@server1 ~]# wget http://yum.pgrpms.org/9.1/redhat/rhel-5-i386/pgdg-centos91-9.1-4.noarch.rpm

(2)安装pgdg-centos91-9.1-4.noarch.rpm
  [root@server1 ~]# rpm -i pgdg-centos91-9.1-4.noarch.rpm 

(3)更改CentOS-Base.repo
  为方便通过yum安装postgresql9.1的相关软件,所以需要更改CentOS-Base.repo,以便于yum list postgresql* 能找到postgresql9.1的相关软件包
  只需要在 CentOS-Base.repo的[base] and [updates]中增加'exclude=postgresql*'即可
  具体操作如下:
    [root@server1 ~]# cd /etc/yum.repos.d 
    [root@server1 yum.repos.d]# vi CentOS-Base.repo  
      [base]
      name=CentOS-$releasever - Base
      mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
      #baseurl=http://ftp.sjtu.edu.cn/centos/$releasever/os/$basearch/
      gpgcheck=1
      gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
      exclude=postgresql*
      #released updates
      [updates]
      name=CentOS-$releasever - Updates
      mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
      #baseurl=http://ftp.sjtu.edu.cn/centos/$releasever/updates/$basearch/
      gpgcheck=1
      gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
      exclude=postgfesql*
      #packages used/produced in the build but not released

(4)通过yum list postgres*来检测相关的安装包
  [root@server1 yum.repos.d]# yum list postgres*
    Available Packages 
    postgresql91.x86_64                         9.1.1-1PGDG.rhel6             pgdg91 
    postgresql91-contrib.x86_64                 9.1.1-1PGDG.rhel6             pgdg91 
    postgresql91-debuginfo.x86_64               9.1.1-1PGDG.rhel6             pgdg91 
    postgresql91-devel.i686                     9.1.1-1PGDG.rhel6             pgdg91 
    postgresql91-devel.x86_64                   9.1.1-1PGDG.rhel6             pgdg91 
    postgresql91-docs.x86_64                    9.1.1-1PGDG.rhel6             pgdg91 
    postgresql91-jdbc.x86_64                    9.1.901-1PGDG.rhel6           pgdg91 
    postgresql91-jdbc-debuginfo.x86_64          9.1.901-1PGDG.rhel6           pgdg91 
    postgresql91-libs.i686                      9.1.1-1PGDG.rhel6             pgdg91 
    postgresql91-libs.x86_64                    9.1.1-1PGDG.rhel6             pgdg91 
    postgresql91-odbc.x86_64                    09.00.0200-1PGDG.rhel6        pgdg91 
    postgresql91-odbc-debuginfo.x86_64          09.00.0200-1PGDG.rhel6        pgdg91 
    postgresql91-plperl.x86_64                  9.1.1-1PGDG.rhel6             pgdg91 
    postgresql91-plpython.x86_64                9.1.1-1PGDG.rhel6             pgdg91 
    postgresql91-pltcl.x86_64                   9.1.1-1PGDG.rhel6             pgdg91 
    postgresql91-python.x86_64                  4.0-2PGDG.rhel6               pgdg91 
    postgresql91-python-debuginfo.x86_64        4.0-2PGDG.rhel6               pgdg91 
    postgresql91-server.x86_64                  9.1.1-1PGDG.rhel6             pgdg91 
    postgresql91-tcl.x86_64                     1.9.0-1.rhel6                 pgdg91 
    postgresql91-tcl-debuginfo.x86_64           1.9.0-1.rhel6                 pgdg91 
    postgresql91-test.x86_64                    9.1.1-1PGDG.rhel6             pgdg91 
    postgresql_autodoc.noarch                   1.40-1.rhel6                  pgdg91 
    [root@server1 yum.repos.d]# 

(6)使用yum安装postgresql9.1以及相关软件包
  [root@server1 yum.repos.d]# yum install postgresql91 postgresql91-devel postgresql91-server postgresql91-libs postgresql91-contrib 

(7)初始化并启动postgresql
  [root@server1 yum.repos.d]# service postgresql-9.1 initdb 
  Initializing database:                                     [  OK  ] 
  [root@server1 yum.repos.d]# 
  [root@server1 yum.repos.d]# service postgresql-9.1 initdb 
  Initializing database:                                     [  OK  ] 
  [root@server1 yum.repos.d]# 

安装postgresql注意事项:
(1)如果在initdb时失败,则很有可能是因为系统默认字符编码和postgresql所认可的不一致所导致的,这时可以通过/var/lib/pgsql/9.1/pgstartup.log的相关出错信息来确认
  如果确定是编码的问题导致initdb失败,则可以通过在initdb时指定--no-locale来解决,具体方法如下
  1.1 [root@GJZ bin]# su - postgres
  1.2 -bash-3.2$ /usr/local/pgsql/bin/initdb --no-locale
    The files belonging to this database system will be owned by user "postgres".
    This user must also own the server process.
    The database cluster will be initialized with locale C.
    The default database encoding has accordingly been set to SQL_ASCII.
    The default text search configuration will be set to "english".
    fixing permissions on existing directory /var/lib/pgsql/9.1/data ... ok
(2) 注意修改/var/lib/pgsql/9.1/data中的postgresql.conf和pg_hba.conf文件,根据需要配置相关的访问策略 。

推荐阅读
  • 本文介绍了在CentOS上安装Python2.7.2的详细步骤,包括下载、解压、编译和安装等操作。同时提供了一些注意事项,以及测试安装是否成功的方法。 ... [详细]
  • 如何实现织梦DedeCms全站伪静态
    本文介绍了如何通过修改织梦DedeCms源代码来实现全站伪静态,以提高管理和SEO效果。全站伪静态可以避免重复URL的问题,同时通过使用mod_rewrite伪静态模块和.htaccess正则表达式,可以更好地适应搜索引擎的需求。文章还提到了一些相关的技术和工具,如Ubuntu、qt编程、tomcat端口、爬虫、php request根目录等。 ... [详细]
  • 本文介绍了在开发Android新闻App时,搭建本地服务器的步骤。通过使用XAMPP软件,可以一键式搭建起开发环境,包括Apache、MySQL、PHP、PERL。在本地服务器上新建数据库和表,并设置相应的属性。最后,给出了创建new表的SQL语句。这个教程适合初学者参考。 ... [详细]
  • 本文介绍了Oracle数据库中tnsnames.ora文件的作用和配置方法。tnsnames.ora文件在数据库启动过程中会被读取,用于解析LOCAL_LISTENER,并且与侦听无关。文章还提供了配置LOCAL_LISTENER和1522端口的示例,并展示了listener.ora文件的内容。 ... [详细]
  • 腾讯安全平台部招聘安全工程师和数据分析工程师
    腾讯安全平台部正在招聘安全工程师和数据分析工程师。安全工程师负责安全问题和安全事件的跟踪和分析,提供安全测试技术支持;数据分析工程师负责安全产品相关系统数据统计和分析挖掘,通过用户行为数据建模为业务决策提供参考。招聘要求包括熟悉渗透测试和常见安全工具原理,精通Web漏洞,熟练使用多门编程语言等。有相关工作经验和在安全站点发表作品的候选人优先考虑。 ... [详细]
  • Python项目实战10.2:MySQL读写分离性能优化
    本文介绍了在Python项目实战中进行MySQL读写分离的性能优化,包括主从同步的配置和Django实现,以及在两台centos 7系统上安装和配置MySQL的步骤。同时还介绍了创建从数据库的用户和权限的方法。摘要长度为176字。 ... [详细]
  • PHP组合工具以及开发所需的工具
    本文介绍了PHP开发中常用的组合工具和开发所需的工具。对于数据分析软件,包括Excel、hihidata、SPSS、SAS、MARLAB、Eview以及各种BI与报表工具等。同时还介绍了PHP开发所需的PHP MySQL Apache集成环境,包括推荐的AppServ等版本。 ... [详细]
  • docker容器的数据管理一:数据卷实现数据的永久化,完全独立于容 ... [详细]
  • 导读:在编程的世界里,语言纷繁多样,而大部分真正广泛流行的语言并不是那些学术界的产物,而是在通过自由发挥设计出来的。和那些 ... [详细]
  • 安装mysqlclient失败解决办法
    本文介绍了在MAC系统中,使用django使用mysql数据库报错的解决办法。通过源码安装mysqlclient或将mysql_config添加到系统环境变量中,可以解决安装mysqlclient失败的问题。同时,还介绍了查看mysql安装路径和使配置文件生效的方法。 ... [详细]
  • Centos7.6安装Gitlab教程及注意事项
    本文介绍了在Centos7.6系统下安装Gitlab的详细教程,并提供了一些注意事项。教程包括查看系统版本、安装必要的软件包、配置防火墙等步骤。同时,还强调了使用阿里云服务器时的特殊配置需求,以及建议至少4GB的可用RAM来运行GitLab。 ... [详细]
  • Python如何调用类里面的方法
    本文介绍了在Python中调用同一个类中的方法需要加上self参数,并且规范写法要求每个函数的第一个参数都为self。同时还介绍了如何调用另一个类中的方法。详细内容请阅读剩余部分。 ... [详细]
  • Python语法上的区别及注意事项
    本文介绍了Python2x和Python3x在语法上的区别,包括print语句的变化、除法运算结果的不同、raw_input函数的替代、class写法的变化等。同时还介绍了Python脚本的解释程序的指定方法,以及在不同版本的Python中如何执行脚本。对于想要学习Python的人来说,本文提供了一些注意事项和技巧。 ... [详细]
  • 如何在php中将mysql查询结果赋值给变量
    本文介绍了在php中将mysql查询结果赋值给变量的方法,包括从mysql表中查询count(学号)并赋值给一个变量,以及如何将sql中查询单条结果赋值给php页面的一个变量。同时还讨论了php调用mysql查询结果到变量的方法,并提供了示例代码。 ... [详细]
  • 在使用dedecms过程中,添加自定义字段变量很有用,但删除并不容易。本文介绍了两种常用的删除方法:执行SQL语句和手动SQL删除。 ... [详细]
author-avatar
YW1232602897663_231
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有