zoukankan      html  css  js  c++  java
  • Centos源码安装postgresql

    安装基础package

    yum install readline readline-devel zlib zlib-devel gcc-c++ make

    1. 需要GNU make 版本3.80或更高版本 (make -v命令查看)
    2. gcc
    3. tar gzip bzip make
    4. readline推荐使用,它允许psql记住每个您键入的命令,并允许您使用上下键来记起和编辑之前的命令

    源码安装

    1. cd /usr/src/
    2. wget http://ftp.postgresql.org/pub/source/v9.1.4/postgresql-9.1.4.tar.gz
    3. tar -zxvf postgresql-9.1.4.tar.gz
    4. cd postgresql-9.1.4
    5. ./configure
    6. make
    7. make install
    8. adduser postgres
    9. mkdir /usr/local/pgsql/data
    10. chown postgres /usr/local/pgsql/data
    11. su – postgres
    12. /usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data
    13. exit (以root身份操作)
    14. cp /usr/src/postgresql-9.1.4/contrib/start-scripts/linux /etc/init.d/postgresql
    15. chmod 775 /etc/init.d/postgresql <这时候可以通过chkconfig --add,然后就可以service postgresql start, stop, restart,status来控制服务>

    设置环境变量

    1. vim /etc/profile, 在文件末尾添加
    export PATH=/usr/local/pgsql/bin:$PATH
    保存并退出,使环境变量生效,执行以下命令:
    source /etc/profile
    目的:这样就可以在su postgres命令后,输入psql, createdb, 等价于/usr/local/pgsql/bin/createdb

    数据库连接设置

    安装后的文件位于/usr/local/pgsql/,配置文件在/usr/local/pgsql/data目录下
    vim /usr/local/pgsql/data/pg_hba.conf

    错误以及解决方法

    1. 问题 :service postgresql start启动后, 通过命令ps -ef|grep post命令检测到实际DB没有启动。在data目录下的serverlog中日志显示:
    LOG: could not bind IPv4 socket: Cannot assign requested address
    HINT: Is another postmaster already running on port 5432? If not, wait a few seconds and retry.
    WARNING: could not create listen socket for "localhost" 
    FATAL: could not create any TCP/IP sockets
    1.2 原因 :root身份, ping localhost显示127.0.0.1, su postgres去ping localhost, 显示的 64 bytes from 202.102.110.204: icmp_seq=1 ttl=250 time=6.80 ms
    1.3 解决方法 :在data/postgresql.conf目录中, 修改listen_addresses = '127.0.0.1', 默认为"localhost"

    yum安装方法参考文献
    http://www.davidghedini.com/pg/entry/install_postgresql_9_on_centos

  • 相关阅读:
    nginx.conf
    添加分类和标签,级联数据
    使用事物插入数据库
    列表页面常用技巧
    常用TagHelper
    培训指导
    控件数据绑定总结
    快速添加Basic表单
    自动构建表单
    模块制作标准说明
  • 原文地址:https://www.cnblogs.com/tzp_8/p/2762229.html
Copyright © 2011-2022 走看看