CentOS安裝postgresql9.1

來源:互聯網
上載者:User

以下是在CentOS5.5上安裝postgresql9.1的相關記錄

(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檔案,根據需要配置相關的存取原則

參考資料:
(1)http://www.davidghedini.com/pg/entry/install_postgresql_9_on_centos
(2)http://www.linuxfly.org/post/88/
(3)



相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.