http://down.chinaz.com/server/201104/244_1.htm
1、下載postgresql最新版:
- 軟件大小:32.70MB
- 軟件類別:國外軟件 | 數(shù)據(jù)服務(wù)器
- 軟件語言:英文
- 運(yùn)行環(huán)境:Linux
- 軟件授權(quán):免費(fèi)版
- 更新時(shí)間:2012-9-25 9:38:18
- 相關(guān)鏈接:Home Page
2、解壓文件:
tar zxvf postgresql-8.3.7.tar.gz cd postgresql-8.3.7
3、配置:
./configure --prefix=/usr/local/pgsql
4、編譯:
make
5、安裝:
make install
6、創(chuàng)建用戶組和用戶:
groupadd postgres useradd -g postgres postgres
7、創(chuàng)建數(shù)據(jù)庫庫文件存儲目錄、給postgres賦予權(quán)限:
mkdir /usr/local/pgsql/data cd /usr/local/pgsql chown postgres.postgres data
8、初始化數(shù)據(jù)庫目錄:
切換用戶
su - postgresql
初始化數(shù)據(jù)
/usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data
啟動數(shù)據(jù)庫
/usr/local/pgsql/bin/postmaster -D /usr/local/pgsql/data
9、配置監(jiān)聽地址和端口:
vi /usr/local/pgsql/data/postgresql.conf
取消以下兩行的注釋
listen_addresses = '*' port = 5432
10、允許遠(yuǎn)程連接:
vi /usr/local/pgsql/data/pg_hba.conf
添加
host all all 192.168.1.0/24 trust
每項(xiàng)的具體意思在配置文件中有詳細(xì)說明
配置iptables讓遠(yuǎn)程主機(jī)能訪問:
vi /etc/sysconfig
添加
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 5432 -j ACCEPT service iptables restart
11、讓postgresql數(shù)據(jù)庫隨系統(tǒng)啟動而啟動:
將啟動腳本拷貝到/etc/init.d/目錄下,具體執(zhí)行如下命令:
cd /etc/rc.d/init.d cp (第一步解壓的安裝文件目錄)/postgresql-8.3.7/contrib/start-scripts/linux postgresql chmod +x postgresql vi postgresql prefix=/usr/local/pgsql PGDATA="/usr/local/pgsql/data" PGUSER=postgres PGLOG="/var/log/pgsql.log" chkconfig --add postgresql
啟動數(shù)據(jù)庫:
service postgresql start