技术头条 - 一个快速在微博传播文章的方式     搜索本站
您现在的位置首页 --> MySQL --> PostgreSQL安装

PostgreSQL安装

浏览:2218次  出处信息

PostgreSQL8.x版本的安装已经非常的简单了。EnterpriseDB制作了一键安装的版本,包括FreeBSD/Linux/Mac OS X/Solaris/Windows平台都有。不过即使使用源码编译,也非常的简单。各个版本的源码可以点这里下载

创建os用户

#useradd -g dba postgres
#su - postgres

编译

$tar -zxvf postgresql-8.4.2.tar.gz
$cd postgresql-8.4.2
$./configure --prefix=/OPT/postgresql --enable-profiling --with-blocksize=8 --with-wal-blocksize=8
$make && make install

其中with-blocksize指定数据块大小,默认8k,with-wal-blocksize指定日志块大小,默认也是8k。更多编译配置选项,可以通过./configure -help查看。

初始化database,注意PostgreSQL在服务端不支持GBK编码。

$cd /opt/postgresql/bin
$ ./initdb --encoding=utf8 -D /opt/postgresql/data
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 en_US.UTF-8.
The default text search configuration will be set to "english".

creating directory /opt/postgresql/data ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 32MB
creating configuration files ... ok
creating template1 database in /opt/postgresql/data/base/1 ... ok
initializing pg_authid ... ok
initializing dependencies ... ok
creating system views ... ok
loading system objects' descriptions ... ok
creating conversions ... ok
creating dictionaries ... ok
setting privileges on built-in objects ... ok
creating information schema ... ok
vacuuming database template1 ... ok
copying template1 to template0 ... ok
copying template1 to postgres ... ok

WARNING: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the -A option the
next time you run initdb.

Success. You can now start the database server using:

    ./postgres -D /opt/postgresql/data
or
    ./pg_ctl -D /opt/postgresql/data -l logfile start

初始化完成后,会在 /opt/postgresql/data目录生成数据库的文件,至此,软件安装完毕,数据库创建完毕。

启动数据库

./pg_ctl -D /opt/postgresql/data/ -l /opt/postgresql/log/alert.log start

启动后,可以发现PostgreSQL实例一共运行了5个进程

$ ps -ef | grep postgres
postgres 17572     1  0 16:41 pts/2    00:00:00 /opt/postgresql/bin/postgres
-D /opt/postgresql/data
postgres 17574 17572  0 16:41 ?        00:00:00 postgres: writer process
postgres 17575 17572  0 16:41 ?        00:00:00 postgres: wal writer process
postgres 17576 17572  0 16:41 ?        00:00:00 postgres: autovacuum launcher process
postgres 17577 17572  0 16:41 ?        00:00:00 postgres: stats collector process
postgres 18679 20791  0 16:47 pts/2    00:00:00 grep postgres

其中wal writer process是日志写进程。

建议继续学习:

  1. 也谈PostgreSQL的同步配置(Slony)    (阅读:4489)
  2. 多版本并发控制:PostgreSQL vs InnoDB    (阅读:3514)
  3. Ubuntu下Postgresql-8.4安装及配置    (阅读:3292)
  4. PostgreSQL与MySQL的区别    (阅读:2905)
  5. Ubuntu下PostgreSQL数据库集群(PL/Proxy)配置方法    (阅读:2922)
  6. PostgreSQL 9.1的新特性    (阅读:2466)
  7. PostgreSQL    (阅读:2367)
  8. PostgreSQL从菜鸟到专家 PostgreSQL介绍    (阅读:2346)
  9. 在Linux上编译安装PostgreSQL8.3.X    (阅读:2233)
  10. PostgreSQL从菜鸟到专家 数据库的数据存取设计    (阅读:2049)
QQ技术交流群:445447336,欢迎加入!
扫一扫订阅我的微信号:IT技术博客大学习
© 2009 - 2024 by blogread.cn 微博:@IT技术博客大学习

京ICP备15002552号-1