zoukankan      html  css  js  c++  java
  • postgresql数据库的yum安装方法

    实验环境>>>>>>>>>>>>>>>>>>
    操作系统:CentOS release 6.3 (Final)
    数据库版本:PostgreSQL-9.3.5

    一、安装postgresql数据库,先到官网下载Yum-Repository的rpm包安装到系统,然后直接yum安装postgresql即可。

          安装postgresql只需要安装postgresql-server即可,yum安装过程中会自己解决所需的make、postgresqlpostgresql-libs等依赖包。

    [root@5201351 ~]# wget http://yum.postgresql.org/9.3/redhat/rhel-6-x86_64/pgdg-centos93-9.3-1.noarch.rpm
    [root@5201351 ~]# rpm -ivh pgdg-centos93-9.3-1.noarch.rpm
    [root@5201351 ~]# yum install postgresql93-server.x86_64 -y              //需开启网官yum仓库

    在安装过程中我们可以发现安装9.3.5版本的postgresql数据库需要的依赖和依赖更新,如下图所示:

    二、接下来是初始化数据库,先得修改postgres用户的环境变量。可以依次执行如下命令:

    [root@5201351 ~]# su - postgres
    -bash-4.1$ echo -e 'PATH=$PATH:/usr/pgsql-9.3/bin
    export PATH' >> .bash_profile
    -bash-4.1$ source .bash_profile              //使配置立即生效
    -bash-4.1$ initdb                            //初始化数据库

    三、配置postgresql数据库

    1、修改postgresql配置文件/var/lib/pgsql/9.3/data/postgresql.conf

         postgresql默认监听localhost,即127.0.0.1。我们可以修改监听地址为指定ip或者用星号(*)表示本机所有网卡地址。

    2、修改postgresql客户端认证配置文件/var/lib/pgsql/9.3/data/pg_hba.conf 以后修改此配置文件

         只需要执行pg_ctl reload命令即可使其生效而不用重启服务。对于远端主机、建议使用md5密码认证方式。如下图所示:

     

    四、使用root用户启动postgresql服务,然后将postgresql服务加入到开机启动列表。

    [root@5201351 ~]# /etc/init.d/postgresql-9.3 start
    [root@5201351 ~]# chkconfig --level 35 postgresql-9.3 on

     当我们安装完postgresql、刚初始化数据库之后的postgresql.conf的内容一般如下:

    #listen_addresses = 'localhost'         # what IP address(es) to listen on;
    #port = 5432                            # (change requires restart)
    max_connections = 100                   # (change requires restart)
    shared_buffers = 128MB                  # min 128kB
    log_destination = 'stderr'              # Valid values are combinations of
    logging_collector = on                  # Enable capturing of stderr and csvlog
    log_directory = 'pg_log'                # directory where log files are written,
    log_filename = 'postgresql-%a.log'      # log file name pattern,
    log_truncate_on_rotation = on           # If on, an existing log file with the
    log_rotation_age = 1d                   # Automatic rotation of logfiles will
    log_rotation_size = 0                   # Automatic rotation of logfiles will
    log_line_prefix = '< %m >'                      # special values:
    log_timezone = 'PRC'
    datestyle = 'iso, mdy'
    timezone = 'PRC'
    lc_messages = 'en_US.UTF-8'                     # locale for system error message
    lc_monetary = 'en_US.UTF-8'                     # locale for monetary formatting
    lc_numeric = 'en_US.UTF-8'                      # locale for number formatting
    lc_time = 'en_US.UTF-8'                         # locale for time formatting
    default_text_search_config = 'pg_catalog.english'
  • 相关阅读:
    bzoj1615 [Usaco2008 Mar]The Loathesome Hay Baler麻烦的干草打包机
    bzoj3402 [Usaco2009 Open]Hide and Seek 捉迷藏
    CF B. Planning The Expedition
    Codeforces ~ 1009C ~ Annoying Present (贪心)
    Codeforces Round#498(Div.3)D. Two Strings Swaps
    牛客Another Distinct Values
    牛客多校第四场 G Maximum Mode
    可持化永久树 的 STL ( rope )
    KMP算法 (字符串的匹配)
    求(3+开根5) N次方的整数部分最后3位
  • 原文地址:https://www.cnblogs.com/5201351/p/4225991.html
Copyright © 2011-2022 走看看