• centos 6.8 + postgresql 9.6 + pgagent


    pgagent 是 pgsql 的一个job调度的功能扩展存在,个人对pgagent有点困惑,感觉这个东西应该作为数据库系统必备一部分,而不应该让开发人员或者dba再去安装个 pgagent。

    编译安装

    pgAgent 依赖 cmake 和 wxGTK,所以要先配置好 cmake 和wxGTK

    cmake

    centos 6.8 安装是自带了 cmake

    ls -l /usr/bin/cmake
    -rwxr-xr-x 1 root root 4168936 Oct 15  2014 /usr/bin/cmake
    cmake --version
    cmake version 2.8.12.2

    wxGTK

    Latest Stable Release: 3.0.3
    Previous Stable Release: 2.8.12
    本次采用 2.8.12

    root用户下

    vi ~/.bash_profile
    
    export PATH=/usr/local/wxGTK-2.8.12/bin:$PATH
    export LD_LIBRARY_PATH=/usr/local/wxGTK-2.8.12/lib:$LD_LIBRARY_PATH
    
    source .bash_profile

    编译、安装
    root用户下

    ./configure --enable-shared=no --enable-unicode=yes --prefix=/usr/local/wxGTK-2.8.12
    make 
    make install

    pgagent

    下载 pgAgent v3.4.0

    pgagent安装
    这里需要先指定postgresql环境变量
    root用户下

    export PGDATA=/var/lib/pgsql/9.6/data
    export PGHOME=/usr/pgsql-9.6
    export PATH=$PGHOME/bin:$PATH
    export LD_LIBRARY_PATH=/lib:/lib64:/usr/lib:/usr/lib64:$PGHOME/lib:$LD_LIBRARY_PATH
    
    cmake ./
    -- ================================================================================
    -- Configuration summary:
    --  
    --   Project                     : pgagent
    --   Description                 : pgAgent is a job scheduling engine for PostgreSQL
    --   Version                     : 3.4.0
    --  
    --   PostgreSQL version string   : PostgreSQL 9.6.4
    --   PostgreSQL version parts    : 9.6.4
    --   PostgreSQL path             : /usr/pgsql-9.6
    --   PostgreSQL config binary    : /usr/pgsql-9.6/bin/pg_config
    --   PostgreSQL include path     : /usr/pgsql-9.6/include
    --   PostgreSQL library path     : /usr/pgsql-9.6/lib
    --   PostgreSQL share path       : /usr/pgsql-9.6/share
    --  
    --   wxWidgets version           : 2.8.12
    --   wxWidgets path              : /usr/local/wxGTK-2.8.12
    --   wxWidgets config binary     : /usr/local/wxGTK-2.8.12/bin/wx-config
    --   wxWidgets Static linking    : YES
    --   wxWidgets Debug?            : NO
    -- ================================================================================

    make
    make install
    如果没有报错,就可以 到 psql下创建了
    create extension pgagent;

    postgres=# create extension pgagent ;
    CREATE EXTENSION

    rpm 安装

    或者直接 pgagent rpm
    yum list |grep pgagent
    yum install pgagent_96.x86_64

    /usr/share/pgagent_96-3.4.0
    /usr/share/pgagent_96-3.4.0/pgagent_upgrade.sql
    /usr/share/pgagent_96-3.4.0/pgagent.sql

    /usr/pgsql-9.6/share/extension/pgagent–3.4.sql
    /usr/pgsql-9.6/share/extension/pgagent.control
    /usr/pgsql-9.6/share/extension/pgagent–unpackaged–3.4.sql

    查看 pgagent_96
    cat /etc/init.d/pgagent_96

    关键是这一行

     $SU pgagent -c "/usr/bin/pgagent_96 -s $LOGFILE hostaddr=$DBHOST dbname=$DBNAME user=$DBUSER  port=$DBPORT"

    需要使用~/.pgpass来保存密码,在pgagent用户的主目录下新建.pgpass文件

    #hostname:port:database:username:password
    *:*:*:postgres:xxxxx
    将.pgpass的访问权限设置为0600

    $ chmod 0600 .pgpass

    service pgagent_96 status
    service pgagent_96 start

    碰到如下错误
    WARNING: Couldn’t create the primary connection (attempt 3): FATAL: Ident authentication failed for user “postgres”

    开启 pgslq 的 log_connections = ‘on’ ,发现使用的是 ipv6 登录的。关闭操作系统的 ipv6
    lsmod | grep ipv6

    在/etc/modprobe.d/dist.conf结尾添加
    alias net-pf-10 off
    alias ipv6 off

    vi /etc/sysconfig/network
    NETWORKING_IPV6=no

    vi /etc/hosts

    #::1

    17:16:24: Error: Cannot get the official hostname (error 0: Success)
    这个问题是在/etc/hosts 没有添加主机名

    vi /etc/hosts
    x.x.x.x DB_monitor

    chkconfig –level 3 pgagent_96 on
    chkconfig –level 5 pgagent_96 on

    pgagent 使用

    create extension pgagent
    ;

    会在数据库下新建了一个 pgagent 的 schema

    使用 pgAdmin 4 来创建

    参考:https://www.pgadmin.org/download/pgagent-source-code/
    https://www.pgadmin.org/docs/pgadmin3/1.22/pgagent-install.html
    http://cmake.org/download/
    http://www.wxwidgets.org/downloads/

  • 相关阅读:
    JDBC MySQL 实例之 用户管理系统
    利用JDBC连接数据库(MySQL)
    CSS01
    HTML01
    GUI编程02
    GUI编程01
    名词解释
    Navicat MySQL安装
    Eclipse安装Web/JavaEE插件、Eclipse编写HTML代码
    Pascal输出星星
  • 原文地址:https://www.cnblogs.com/ctypyb2002/p/9793132.html
Copyright © 2020-2023  润新知