<b>2.3 安裝技巧介紹</b>
<b>2.3.1 在redhat、centos下使用二進制包安裝較新版本的方法</b>
如果認為redhat或centos上自帶的postgresql版本太低,想要使用新版本,可以使用下面的方法安裝。
使用postgresql官方的rpm包,将新版本資訊加到版本庫中:
rpm -i
http://yum.postgresql.org/9.2/redhat/rhel-6-x86_64/pgdg-redhat92-9.2-7.noarch.rpm
然後使用yum install 指令安裝新版本:
yum install postgresql92-server.x86_64
再使用1.1.2節介紹的方法安裝新版本的postgresql:
[root@localhost ~]# service postgresql-9.2
status
is
stopped
[root@localhost ~]# service postgresql-9.2
initdb
initializing database: [ ok ]
start
starting postgresql-9.2 service: [ ok ]
登入資料庫:
[root@localhost ~]# su - postgres
-bash-4.1$ psql
psql (9.2.4)
type "help" for help.
postgres=# \l
list of
databases
name | owner
| encoding | collate |
ctype | access
privileges
-----------+----------+----------+-------------+-------------+------------------
postgres
| postgres | utf8 |
en_us.utf-8 | en_us.utf-8 |
template0 | postgres | utf8 | en_us.utf-8 | en_us.utf-8 |
=c/postgres
+
| | | | |
postgres=ctc/postgres
template1 | postgres | utf8 | en_us.utf-8 | en_us.utf-8 |
| | | | |
(3 rows)
postgres=# \q
使用下面指令把相關的第三方貢獻包也安裝上:
yum install postgresql92-contrib.x86_64
新版本的postgresql的資料目錄在/var/lib/pgsql/<version>/data目錄下,“version”代表postgresql的版本,如9.2版本就安裝在/var/lib/pgsql/9.2/data目錄下。
<b>2.3.2 如何使用較大的資料塊提高i/o性能</b>
在資料倉庫中使用postgresql時,若希望使用較大的資料塊提高i/o性能怎麼辦?要解決這類問題,隻能采用從源碼安裝的方法,在執行./configure指令時指定較大的資料塊,一般也需要指定較大的wal日志塊和wal日志檔案的大小。如想指定128kb的資料塊、128kb的wal日志塊、64mb的wal日志檔案,則configure指令如下:
./configure --prefix=/usr/local/pgsql9.2.4
--with-perl --with-python
--with-blocksize=128
--with-wal-blocksize=128 --with-wal-segsize=64
使用此時編譯出來的postgresql程式建立的postgresql資料庫,不能使用其他塊大小的postgresql程式啟動。