練功房推薦書單

  • 猛虎出柙雙劍合璧版--最新 OCA / OCP Java SE 7 Programmer 專業認證 (電子書)
  • 流浪教師存零股存到3000萬(全新增修版)(書+DVD)
  • 開始在關西自助旅行(京都‧大阪‧神戶‧奈良)(全新增訂版)
  • 不敗教主的300張股票存股術

Upgrade PostgreSQL 8.1 to PostgreSQL 8.4 on CentOS 5.5 RSS feed
討論區首頁 » PostgreSQL
發表人 內容
andowson

七段學員
[Avatar]

註冊時間: 2007/1/2
文章: 711
來自: 台北
離線
CentOS 5.5支援到PostgreSQL 8.4資料庫,先前的資料庫版本是8.1,由於只能有一版存在,必須移除舊版才行,整個升級過程大致如下:

1.建立備份用的目錄
# mkdir /pgbak

# chown postgres:postgres /pgbak/

2.備份舊的資料
# su - postgres

$ pg_dumpall --globals-only > /pgbak/globals.sql
$ psql -l
$ pg_dump --create --oids --format=c --verbose --file=/pgbak/dbX dbX
$ exit

dbX就是您資料庫的名稱(用psql -l指令可以找出有哪些資料庫)

3.停止PostgreSQL資料庫服務
# /etc/init.d/postgresql stop

4.將舊的目錄備份起來
# mv /var/lib/pgsql/data /pgbak

5.移除舊的postgresql 8.1套件
# yum remove postgresql*

( smilie 注意相關性會移除httpd, mod_ssl等)
6.安裝新的postgresql84套件
# yum install postgresql84-server

7.初始資料庫
service postgresql initdb

8.啟動資料庫
# chkconfig postgresql on

# service postgresql start

9.復原資料
# su - postgres

$ psql -f /pgbak/globals.sql
$ pg_restore --create -d postgres /pgbak/dbX
$ exit

10.參考/pgbak/data目錄下的檔案,修改/var/lib/pgsql/data/postgresql.conf和pg_hba.conf等設定檔
再重新啟動一次postgresql
#service postgresql restart


11.安裝回被移除的套件
# yum install httpd mod_ssl

12.使用備份的設定檔
# mv /etc/httpd/conf/httpd.conf /tmp/.

# mv /etc/httpd/conf/httpd.conf.rpmsave /etc/httpd/conf/httpd.conf
# mv /etc/httpd/conf.d/proxy_ajp.conf /tmp/.
# mv /etc/httpd/conf.d/proxy_ajp.conf.rpmsave /etc/httpd/conf.d/proxy_ajp.conf
# mv /etc/httpd/conf.d/ssl.conf /tmp/.
# mv /etc/httpd/conf.d/ssl.conf.rpmsave /etc/httpd/conf.d/ssl.conf


參考資料:
http://blog.lystor.org.ua/2010/05/upgrading-postgresql-81-to-84-centos-55.html

http://www.postgresonline.com/journal/archives/144-An-almost-idiots-guide-to-Install-and-Upgrade-to-PostgreSQL-8.4-with-Yum.html

分享經驗 累積智慧
[WWW]
 
討論區首頁 » PostgreSQL
前往:   
行動版