zl程序教程

您现在的位置是:首页 >  数据库

当前栏目

2.3 安装技巧介绍

2023-03-09 22:22:40 时间

2.3 安装技巧介绍

2.3.1 在Redhat、CentOS下使用二进制包安装较新版本的方法

如果认为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  ]

[root@localhost ~]# service postgresql-9.2 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 | =c/postgres         

+

           |          |          |             |             |

postgres=CTc/postgres

(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目录下。

2.3.2 如何使用较大的数据块提高I/O性能

在数据仓库中使用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程序启动。