<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程序启动。