Ubuntu上编译安装PostgreSQL

来源:互联网 发布:生命公式1.0软件 编辑:程序博客网 时间:2024/05/16 10:43
0. 安装postgresql需要的 Bison 和 Flex,以及 版本控制工具 git:
    $ sudo apt-get install bison flex git

1. 新建用户组 postgres 和用户 postgres ,gid 和 uid 都是 88 。
    $ sudo groupadd -g 88 postgres
    $ sudo useradd -c "PostgreSQL USER" -g 88 -G postgres -s /bin/bash -u 88 postgres
    $ sudo mkdir /home/postgres
    $ sudo chown /home/postgres postgres
    $ sudo chgrp /home/postgres postgres
    (经提醒,以下为正确的使用方式)
    $ sudo chown postgres /home/postgres
    $ sudo chgrp postgres /home/postgres
    $ sudo passwd postgres

2. 下载postgresql源代码。
    postgres@ubuntu:~$ git clone http://git.oschina.net/pythonshell/postgresql

3. 迁出9.3.5版本的代码
    postgres@ubuntu:~$ cd postgresql/
    postgres@ubuntu:!/postgresql$ git checkout REL9_3_5

4. 准备编译的目录( /home/postgres/postgres_9_3_5_build )
    postgres@ubuntu:~/postgressql$ cd ..
    postgres@ubuntu:~$ mkdir postgres_9.3.5_build

5. 准备安装程序的目录 ( /home/pgsql/ )
    postgres@ubuntu:~$ mkdir pgsql

6. 运行configure,为编译做准备
    postgres@ubuntu:~$ cd postgres_9.3.5_build
    postgres@ubuntu:~/postgres_9.3.5_build$ /home/postgres/postgresql/configure --prefix=/home/postgres/pgsql/ --without-readline --without-zlib
    其中,如果你安装了readline,可以去掉 --without-readline。
    如果你安装了zlib,可以去掉--without-zlib。

7. 开始编译
    postgres@ubuntu:~/postgres_9.3.5_build$ make
    All of PostgreSQL successfully made. Ready to install.

8. 检查
    postgres@ubuntu:~/postgres_9.3.5_build$ make check
    =======================
    All 136 tests passed.
    =======================

9. 安装到 /home/postgresql/pgsql 下
    postgres@ubuntu:~/postgres_9.3.5_build$ make install
    PostgreSQL installation complete.

10. 指定数据存放位置 ( /home/postgres/pgsql/data/ )
    postgres@ubuntu:~/postgres_9.3.5_build$ cd ../pgsql
    postgres@ubuntu:~/pgsql$ mkdir data

11. 运行postgresql数据库,以及postgresql的命令行交互软件psql
    postgres@ubuntu:~/pgsql$ bin/postgres -D data/ >logfile 2>&1 &
    postgres@ubuntu:~/pgsql$ bin/createdb test
    postgres@ubuntu:~/pgsql$ bin/psql test

0 0
原创粉丝点击