茫茫網海中的冷日
         
茫茫網海中的冷日
發生過的事,不可能遺忘,只是想不起來而已!
 恭喜您是本站第 1671623 位訪客!  登入  | 註冊
主選單

Google 自訂搜尋

Goole 廣告

隨機相片
IMG_60D_00030.jpg

授權條款

使用者登入
使用者名稱:

密碼:


忘了密碼?

現在就註冊!

DB研討會 : [分享]Postgresql 資料庫軟體簡介

發表者 討論內容
冷日
(冷日)
Webmaster
  • 註冊日: 2008/2/19
  • 來自:
  • 發表數: 15771
[分享]Postgresql 資料庫軟體簡介

Postgresql 資料庫軟體簡介

PostgreSQL 與 MySQL 同為廣泛使用且著名的免費 SQL資料庫軟體,前者由 Michael Stonebraker 領導研發的 Berkeley Postgres 資料庫管理系統延伸而來,兼具商業版資料庫的強大功能,支援 SQL92/SQL99 的 SQL 語法,乃一基於 Postgres 而產生之相當完整堅穩的物件關聯(非指物件導向)資料庫管理系統軟體 (ORDBMS),後者 MySQL 的優點則在於執行速度較快,雙方支持者各半,攻防論點亦有所不同。

Postgres 開發的許多物件關聯關念早廣為各個資料庫廣為採用;過去關聯資料庫管理系統 (RDBMS) 僅支援關聯名稱及特定型態屬性的資料模組,觀之目前的商業系統,現有的型態起碼包含整數、浮點數、字元字串、金錢和日期等,過去RDBMS對未來資料的處理已不敷使用,過去關聯模組以其簡樸的語法替代更早的模組,不過此一過於簡樸的語法常造成現今執行的困難,而 PostgreSQL 則以其附加的 inheritance、data types、functions、constraints、triggers、rules 及transaction integrity 等關念帶來實體的功能。

PostgreSQL 最新的版本為 7.1.3 , 至於 7.1.*以上的版本下載站台僅提供 Redhat、Mandrake、Debian(僅提供 7.1 版 , 7.1.1至 7.1.3 則無)的 binary 檔, 7.0(含)之前的版本尚含 OpenLinux、SuSE、TurboLinux、LinuxPPC。在 RedHat 7.1 內含套件則為 7.0.3-8 版 ,包含下述套件:

  • Postgresql 7.0.3-8
  • Postgresql python-7.0.3-8
  • Postgresql tcl-7.0.3-8
  • Postgresql tk-7.0.3-8
  • Postgresql perl-7.0.3-8
  • Postgresql server-7.0.3-8
  • Postgresql devel-7.0.3-8
  • Postgresql jdbc-7.0.3-8
  • Postgresql odbc-7.0.3-8

相關套件下載網址: ftp://ftp.ccu.edu.tw/pub/packages/database/postgresql/

ftp://ftp.ccit.edu.tw/packages/postgresql/

PostgreSQL 7.1.* 版本的主要變格,可從釋出紀要一窺得知,茲摘錄如後 :

Write-ahead Log (WAL)

To maintain database consistency in case of an operating system crash, previous releases of PostgreSQL have forced all data modifications to disk before each transaction commit. With WAL, only one log file must be flushed to disk, greatly improving performance. If you have been using -F in previous releases to disable disk flushes, you may want to consider discontinuing its use.

TOAST

TOAST - Previous releases had a compiled-in row length limit, typically 8k - 32k. This limit made storage of long text fields difficult. With TOAST, long rows of any length can be stored with good performance.

Outer Joins

We now support outer joins. The UNION/NOT IN workaround for outer joins is no longer required. We use the SQL92 outer join syntax.

Function Manager

The previous C function manager did not handle NULLs properly, nor did it support 64-bit CPU's (Alpha). The new function manager does. You can continue using your old custom functions, but you may want to rewrite them in the future to use the new function manager call interface.

Complex Queries

A large number of complex queries that were unsupported in previous releases now work. Many combinations of views, aggregates, UNION, LIMIT, cursors, subqueries, and inherited tables now work properly. Inherited tables are now accessed by default. Subqueries in FROM are now supported.


在 phpbuilder 網站有一篇專欄作家Kevin Kemp 針對 Redhat7.0 上使用 PostgreSQL 的簡介,簡潔實用,值得一讀。筆者特將之作一整理,俾供各位讀者參考;作者試著從頭介紹包含 PostgreSQL 資料庫最常遇到的起動和設定在內的相關執行問題。安裝前系統預設環境為:

(1)已安裝 Redhat7.0
(2)PostgreSQL 尚未安裝
(3)桌面環境(例如 Gnome )已安裝
(4)linuxconf 已安裝
(5)擁有 root 權限

接著從四個項目逐一介紹如后:

其一: PostgreSQL 伺服器和客戶端的安裝
其二: Postmaster 的設定和選項描述
其三:本機使用者與資料庫的建置
其四:從它端電腦的存取問題

步驟一:從 Redhat 安裝光碟片或 Redhat (鏡射)站台下載下述檔案:

1)必要檔案:
A) postgresql-server-7.0.2-17.i386.rpm
B) postgresql-7.0.2-17.i386.rpm
C) php-pgsql-4.0.1pl2-9.i386.rpm

2)可選擇檔案:
A) postgresql-devel-7.0.2-17.i386.rpm
B) postgresql-jdbc-7.0.2-17.i386.rpm
C) postgresql-odbc-7.0.2-17.i386.rpm
D) postgresql-perl-7.0.2-17.i386.rpm
E) postgresql-python-7.0.2-17.i386.rpm
F) postgresql-tcl-7.0.2-17.i386.rpm (作者高度推薦)
G) postgresql-tk-7.0.2-17.i386.rpm (此為上述的一部份)
H) phpPgAdmin_2-2-1-pl1.tar.gz (可從greatbridge.org下載)

步驟二:安裝檔案

1)使用GnoRPM或命列列下輸入 rpm -i 安裝所有.rpm檔案
2)將phpPgAmin搬移到特定目錄下(例如: /Programming/phpprogs下)
3)命列列下輸入 tar -xzf phpPgAdmin_2-2-1-pl1.tar.gz

步驟三: Postmaster 的設定和選項

1)-B 指設定分享記憶體磁碟緩衝數目,最少為伺服器行程的二倍,每一個緩衝佔8k記憶體
2)-D 指指定資料庫目錄
3)-N 指設定Postgres伺服器行程
4)-S 指postmaster 以無除錯資訊的靜默型態啟動
5)-d 指除錯等級
6)-i 指針對遠端連結開一個 TCP/IP port
7)-l 指使用SSL作為安全連線
8)-o 指給伺服器行程的選項
9)-p 指使用-I 選項時打開特定TCP/IP port

步驟四:啟動 PostgreSQL

1.使用 Linuxconf 管理工具啟動 PostgreSQL
2.將 /var/lib/pgsql/data 目錄下的 postmaster.opts 檔案內容
/usr/bin/postmaster
-p 5432
-D /var/lib/pgsql/data
-B 64
-b /usr/bin/postgres
-i
-N 32
改為
/usr/bin/postmaster
-p 5432
-D /var/lib/pgsql/data
-B 512
-b /usr/bin/postgres
-I
-N 128
(變更部份為 -B 512 -i -N 128,需重新啟動 PostgreSQL)

步驟五:開機時啟動 PostgreSQL

使用 Linuxconf 管理工具設定開機時之 runlevel 將 PostgreSQL 加入,使 PostgreSQL 於開機時自動載入啟動。

步驟六:建立使用者和資料庫

1)於命令提示符號輸入su postgres
2)使用 createuser 命令建立使用者,例如 createuser irving;之後會進一步詢問使用者 irving 是否有權建立資料庫和使用者,請回答yes
3)使用 createdb 命令建立資料庫,例如 createdb software
4)然後輸入 exit 離開 postgres 使用者命令提示符號輸入
5)輸入 psql software (資料庫名稱) -U irving (使用者名稱),以登入新建的資料庫。
6)輸入 \q 可登出資料庫

步驟七:允許遠端連線電腦的存取設定

例如欲允許來自 192.168.0.1 來源電腦上的所有使用者存取所有的資料庫,需編輯 /var/lib/pgsql/data 目錄下的 pg_hba.conf 設定檔,在該檔的最後加入一行:
host all 192.168.0.1 255.255.255.0 trust
此外,高度建議為所有使用者和資料庫的存取設定密碼

前一個主題 | 下一個主題 | 頁首 | | |



Powered by XOOPS 2.0 © 2001-2008 The XOOPS Project|