greening install

postgresql 9.2

以下安裝若遇到版本不正確或不包含時,請加裝其他套件

加裝方式請參考 common 文中的新增套件

  • 安裝postgresql

    • 可參考:https://wiki.postgresql.org/wiki/YUM_Installation

      #CentOS
      #編輯 CentOS-Base.repo 檔
      vim /etc/yum.repos.d/CentOS-Base.repo
      # [base] and [updates] sections, you need to append a line
      exclude=postgresql*
      
      #Install PGDG RPM file
      yum localinstall http://yum.postgresql.org/9.4/redhat/rhel-6-x86_64/pgdg-centos94-9.4-1.noarch.rpm
      #Install PostgreSQL
      yum install postgresql94-server
      #Initialize
      service postgresql-9.4 initdb
      #Startup (If you want PostgreSQL to start automatically when the OS starts)
      chkconfig postgresql-9.4 on
      #Start the database
      service postgresql-9.4 start
      
      #其他
      yum install postgresql postgresql-server
      service postgresql initdb (or postgresql-setup initdb)
      sudo service postgresql start
      
  • 安裝extension

      yum install postgresql-contrib
    
      [ischool@xxx ~]$ sudo su - postgres
      Last login: Thu Jan 29 04:53:01 UTC 2015 on pts/0
      -bash-4.1$ psql
      psql (9.2.9)
      Type "help" for help.
    
      postgres=# CREATE EXTENSION "adminpack";
      CREATE EXTENSION
      postgres=# CREATE EXTENSION "xml2";
      CREATE EXTENSION
      postgres=# CREATE EXTENSION "uuid-ossp";
      CREATE EXTENSION
    
      postgres=# \q
      -bash-4.1$ exit
      logout
    
  • 外部連線設定

      #搜尋postgresql.conf的路徑
      sudo find / -name postgresql.conf
      #編輯postgresql.conf(依搜尋路徑為主)
      vim /var/lib/pgsql9/data/postgresql.conf
      或
      vim /var/lib/pgsql/9.4/data/postgresql.conf
    
      #修改 localhost 成 *
      listen_addresses = '*'
    
      #編輯pg_hba.conf
      vim /var/lib/pgsql9/data/pg_hba.conf
      或
      vim /var/lib/pgsql/9.4/data/pg_hba.conf
    
      #修改下列資訊
      # IPv4 local connections:
      host    all             all             127.0.0.1/32            md5(or trust)
      # IPv6 local connections:
      host    all             all             ::1/128                 md5(or trust)
      #add this line
      host    all             all             youripaddress/32        md5
    
  • 重啟postgresql
      service postgresql-9.4 restart
      或
      service postgresql start