• ubuntu14.04 LTS 源码编译安装postgreSQL


    一、环境

      ubuntu14.04

      postgresql-9.4.3

    二、安装

      1、依赖包安装

    sudo apt-get install libperl-dev  python-dev libreadline-gplv2-dev zlib1g-dev

      2、下载postgreSQL,编译安装

    wger https://ftp.postgresql.org/pub/source/v9.4.3/postgresql-9.4.3.tar.bz2
    tar -jxvf  postgresql-9.4.3.tar.bz2 -C /usr/local/src/
    ./configure --prefix=/usr/local/postgresql-9.4.3 --with-perl --with-python
    sudo make && sudo make install 
    cd /usr/local/
    sudo ln -fs postgresql-9.4.3/ pgsql

      在编译安装路径是加上了版本号,加上版本号的原因是为了以后升级方便;如果postgreSQL9.4.4发布了,自需要在编译postgreSQL9.4.4后,将现有的数据库停掉,然后把链接/usr/local/pgsql指向/usr/local/postgresql-9.4.4。

      3、配置环境变量

      安装完成后,配置postgresql可执行文件的路径和共享库的路径,数据库目录

    export PATH=/usr/local/pgsql/bin:$PATH
    export LD_LIBRARY_PATH=/usr/local/pgsql/lib

      如果想以上配置对所有用户都生效,可以把上面的内容添加到/etc/profile文件中。如果想以上的配置对当前用户生效,在linux下可以把以上内容添加到.bashrc文件中,在其他的unix下可以添加到.profile文件中。

      4、创建数据库簇

    sudo mkdir -p /data/pgdata
    sudo mkdir -p /data/pglog/postgresql.log
    export PGDATA=/data/pgdata #数据目录环境变量
    adduser postgres
    sudo chown -R /data initdb -D /data/pgdata

     显示如下:

    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".
    The default database encoding has accordingly been set to "UTF8".
    initdb: could not find suitable text search configuration for locale "zh_CN.UT                                                                                       F-8"
    The default text search configuration will be set to "simple".
    
    Data page checksums are disabled.
    
    fixing permissions on existing directory /data/pgdata ... ok
    creating subdirectories ... ok
    selecting default max_connections ... 100
    selecting default shared_buffers ... 128MB
    selecting dynamic shared memory implementation ... posix
    creating configuration files ... ok
    creating template1 database in /data/pgdata/base/1 ... ok
    initializing pg_authid ... 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
    syncing data to disk ... ok
    
    WARNING: enabling "trust" authentication for local connections
    You can change this by editing pg_hba.conf or using the option -A, or
    --auth-local and --auth-host, the next time you run initdb.
    
    Success. You can now start the database server using:
    
        postgres -D /data/pgdata/
    or
        pg_ctl -D /data/pgdata/ -l logfile start

     5、 安装contrib目录下的工具

    cd postgresql-9.4.3/contrib
    make
    sudo make install

      6、启动和停止数据库

    pg_ctl start -D /data/pgdata  -l /data/pglog/postgresql.log 
    pg_ctl stop -D /dtat/pgdata

       7、测试

    netstat -nultp | grep 

    tcp        0      0 192.168.45.127:5432     0.0.0.0:*               LISTEN      16015/postgres
  • 相关阅读:
    关于MySQL5.6配置文件my-default.ini不生效问题
    jQuery学习总结(三)
    jQuery学习总结(二)
    jQuery学习总结(一)
    mysql输出到页面MVC模式
    简单的在jsp页面操作mysql
    mysql5.7的基本使用
    mysq5.7l的下载与配置
    jdk环境变量的配置
    SQL SERVER——给已有数据的表增加唯一值
  • 原文地址:https://www.cnblogs.com/chrisDuan/p/4571195.html
Copyright © 2020-2023  润新知