第一种安装方法: 用命令行 在线安装: 参见wiki: http://wiki.ubuntu.org.cn/PostgreSQL
另外可以参见:
http://blog.sina.com.cn/s/blog_6af33caa0100ypck.html
http://www.cnblogs.com/Yu/archive/2012/04/30/2476656.html
=======================================================================
1. 首先下载安装包: 我用的是这个版本 postgres_9.1.2-1.i386.openscg.deb
从postgresql 官网(http://www.postgresql.org/download/linux/)找到下载地址: http://www.openscg.com/se/oscg_home_download.jsp
2. 安装步骤 我按照的是这个wiki: http://wiki.openscg.com/index.php/Postgres_9.1_DEB
3. 下面是在我机器上面安装的情形:
[administrator@ubuntu postgresql]$sudo dpkg -i postgres_9.1.2-1.i386.openscg.deb
选中了曾被取消选择的软件包 postgres91。
(正在读取数据库 ... 系统当前总共安装有 169371 个文件和目录。)
正在解压缩 postgres91 (从 postgres_9.1.2-1.i386.openscg.deb) ...
正在设置 postgres91 (9.1.2-1) ...
PostgreSQL 9.1 is now installed in /opt/postgres/9.1.
To initialize, sudo /etc/init.d/postgres-9.1-openscg start
[xxx@ubuntu postgresql]$sudo /etc/init.d/postgres-9.1-openscg start
PostgreSQL 9.1 Configuration
---------------------------------
This will initialize PostgreSQL database cluster. The following
questions will determine the database server port, superuser password
and to start server on system boot. Press <ENTER> to accept defaults.
Specify PostgreSQL server port [5432]:
Specify superuser password [password]:
Do you want PostgreSQL server to be started on boot (y/n) [y]: y
useradd:警告:此主目录已经存在。
不从 skel 目录里向其中复制任何文件。
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.
The database cluster will be initialized with locale zh_CN.UTF-8.
initdb: could not find suitable text search configuration for locale zh_CN.UTF-8
The default text search configuration will be set to "simple".
fixing permissions on existing directory /opt/postgres/9.1/data ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 24MB
creating configuration files ... ok
creating template1 database in /opt/postgres/9.1/data/base/1 ... ok
initializing pg_authid ... ok
setting password ... ok
initializing dependencies ... ok
creating system views ... ok
loading system objects' descriptions ... ok
creating collations ... ok
creating conversions ... ok
creating dictionaries ... ok
setting privileges on built-in objects ... ok
creating information schema ... ok
loading PL/pgSQL server-side language ... ok
vacuuming database template1 ... ok
copying template1 to template0 ... ok
copying template1 to postgres ... ok
Success. You can now start the database server using:
/opt/postgres/9.1/bin/postgres -D /opt/postgres/9.1/data
or
/opt/postgres/9.1/bin/pg_ctl -D /opt/postgres/9.1/data -l logfile start
Configuring PostgreSQL server startup scripts
Adding system startup for /etc/init.d/postgres-9.1-openscg ...
/etc/rc0.d/K15postgres-9.1-openscg -> ../init.d/postgres-9.1-openscg
/etc/rc1.d/K15postgres-9.1-openscg -> ../init.d/postgres-9.1-openscg
/etc/rc6.d/K15postgres-9.1-openscg -> ../init.d/postgres-9.1-openscg
/etc/rc2.d/S85postgres-9.1-openscg -> ../init.d/postgres-9.1-openscg
/etc/rc3.d/S85postgres-9.1-openscg -> ../init.d/postgres-9.1-openscg
/etc/rc4.d/S85postgres-9.1-openscg -> ../init.d/postgres-9.1-openscg
/etc/rc5.d/S85postgres-9.1-openscg -> ../init.d/postgres-9.1-openscg
Starting PostgreSQL 9.1:
waiting for server to start.... done
server started
PostgreSQL 9.1 started successfully
To load this postgres into your environment, source the env file:
. /opt/postgres/9.1/pg91-openscg.env
[xxx@ubuntu postgresql]$
参考资料:
http://wiki.openscg.com/index.php/Postgres_9.1_DEB
http://rongjih.blog.163.com/blog/static/33574461201111187949876/