會員註冊 / 登入  |  電腦版  |  Jump to bottom of page

PostgreSQL » Upgrade PostgreSQL 8.1 to PostgreSQL 8.4 on CentOS 5.5

發表人: andowson, 七段學員
2011-04-02 21:50:02
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




會員註冊 / 登入  |  電腦版  |  Jump to top of page