概述
pgagent 作为postgresql的一个任务调度代理,在postgresql 9.0 以前 是附带在pgadmin 包下面的,只是默认不安装,9.0之后作为了一个单独是的安装包。所以要使用pgagent定时任务调度的话还得单独安装。
因为某些系统的yum源中不含有pgaent包,或者版本不适配。可以进行编译安装
需要下载
这里我选择的软件版本分别是:
postgresql 10.3pgagent-3.4.0下载地址:https://www.pgadmin.org/download/pgagent.phpcmake-3.12.2 下载地址:http://cmake.org/download/wxWidgets-3.1.1 下载地址:http://www.wxwidgets.org/downloads/
安装步骤
postgresql的安装
(略)
cmake安装
将安装包上传至服务器并解压,解压后进入解压后生成的cmake-3.12.2目录,执行以下命令。
[root@lsrac97 ~]# tar zxvf cmake-3.12.2.tar.gz[root@lsrac97 ~]# cd cmake-3.12.2[root@lsrac97 cmake-2.8.5]# ./bootstrap && gmake && gmake install
wxWidgets的安装
先配置.bash_profile文件
[root@lsrac97 ~]#vi .bash_profile#加入以下内容:PATH=$PATH:$HOME/bin:/usr/local/wxWidgets-3.1.1/binexport LD_LIBRARY_PATH=/usr/local/wxWidgets-3.1.1/lib:$LD_LIBRARY_PATH#并生效参数文件,命令如下:[root@lsrac97 ~]#source .bash_profile
接着解压该安装包并进入其目录,然后编译和安装
[root@lsrac97 wxGTK-2.8.12 ]# ./configure --enable-shared=no --enable-unicode=yes --prefix=/usr/local/wxWidgets-3.1.1[root@lsrac97 wxGTK-2.8.12 ]# make && make install
可能会报错
configure: error:The development files for GTK+ were not found. For GTK+ 2, pleaseensure that pkg-config is in the path and that gtk+-2.0.pc isinstalled. For GTK+ 1.2 please check that gtk-config is in the path,and that the version is 1.2.3 or above. Also check that thelibraries returned by 'pkg-config gtk+-2.0 --libs' or 'gtk-config--libs' are in the LD_LIBRARY_PATH or equivalent.
解决方法
yum install gtk*
显示以下内容表示编译安装完成
/usr/bin/install -c -m 644 ./include/$f /usr/local/wxWidgets-3.1.1/include/wx-3.1/$f; \done------------------------------------------------------The installation of wxWidgets is finished. On certainplatforms (e.g. Linux) you'll now have to run ldconfigif you installed a shared library and also modify theLD_LIBRARY_PATH (or equivalent) environment variable.wxWidgets comes with no guarantees and doesn't claimto be suitable for any purpose.Read the wxWindows Licence on licencing conditions.------------------------------------------------------[root@stephen wxWidgets-3.1.1]#
pgagent的安装
上传安装包至服务器并解压,进入目录执行如下命令:
[root@lsrac97 pgAgent-4.0.0-Source]# cmake ./
可能会报错:
-- Found Threads: TRUECMake Error at cmake/FindBoost.cmake:2044 (message):Unable to find the requested Boost libraries.Unable to find the Boost header files. Please set BOOST_ROOT to the rootdirectory containing Boost or BOOST_INCLUDEDIR to the directory containingBoost's headers.Call Stack (most recent call first):CMakeLists.txt:112 (FIND_PACKAGE)CMake Error at CMakeLists.txt:118 (MESSAGE):Boost library not found.-- Configuring incomplete, errors occurred!See also "/tmp/pgAgent-4.0.0-Source/CMakeFiles/CMakeOutput.log".See also "/tmp/pgAgent-4.0.0-Source/CMakeFiles/CMakeError.log".
解决方法
yum install boost*
再次执行cmake ./
[root@stephen pgAgent-4.0.0-Source]# cmake ./-- Boost version: 1.53.0-- Found the following Boost libraries:-- filesystem-- regex-- date_time-- thread-- system-- chrono-- atomic---- ================================================================================-- Configuration summary:---- Project : pgagent-- Description : pgAgent is a job scheduling engine for PostgreSQL-- Version : 4.0.0---- PostgreSQL version string : PostgreSQL 9.6.0-- PostgreSQL version parts : 9.6-- PostgreSQL path : /usr/local/pgsql-9-- PostgreSQL config binary : /usr/local/pgsql-9/bin/pg_config-- PostgreSQL include path : /usr/local/pgsql-9.6/include-- PostgreSQL library path : /usr/local/pgsql-9.6/lib-- PostgreSQL share path : /usr/local/pgsql-9.6/share---- Boost version : 1.53.0-- Boost path : /usr/include-- Boost include directory : /usr/include-- Boost library directory : /usr/lib64-- Boost Static linking : NO-- ================================================================================---- Configuring done-- Generating done-- Build files have been written to: /tmp/pgAgent-4.0.0-Source
编译完成
然后编译安装 make && make install即可
[root@stephen pgAgent-4.0.0-Source]# makeScanning dependencies of target run[ 11%] Generating pgagent--4.0.sql, pgagent.control[ 11%] Built target runScanning dependencies of target pgagent[ 22%] Building CXX object CMakeFiles/pgagent.dir/connection.cpp.o[ 33%] Building CXX object CMakeFiles/pgagent.dir/job.cpp.o[ 44%] Building CXX object CMakeFiles/pgagent.dir/misc.cpp.o[ 55%] Building CXX object CMakeFiles/pgagent.dir/pgAgent.cpp.o[ 66%] Building CXX object CMakeFiles/pgagent.dir/precomp.cpp.o[ 77%] Building CXX object CMakeFiles/pgagent.dir/unix.cpp.o[ 88%] Building CXX object CMakeFiles/pgagent.dir/win32.cpp.o[100%] Linking CXX executable pgagent[100%] Built target pgagent[root@stephen pgAgent-4.0.0-Source]# make install[ 11%] Built target run[100%] Built target pgagentInstall the project...-- Install configuration: ""-- Installing: /usr/local/bin/pgagent-- Set runtime path of "/usr/local/bin/pgagent" to ""-- Installing: /usr/local/share/pgagent.sql-- Installing: /usr/local/./README-- Installing: /usr/local/./LICENSE-- Installing: /usr/local/pgsql-9.6/share/extension/pgagent--4.0.sql-- Installing: /usr/local/pgsql-9.6/share/extension/pgagent.control-- Installing: /usr/local/pgsql-9.6/share/extension/pgagent--3.4--4.0.sql-- Installing: /usr/local/pgsql-9.6/share/extension/pgagent--unpackaged--4.0.sql
配置pgagent
创建拓展
postgres=# create extension pgagent ;CREATE EXTENSION
启动pgagent进程
postgres@stephen ~]$ pgagent hostaddr=127.0.0.1 dbname=postgres user=postgres password=postgres[postgres@stephen ~]$
配置定时任务
连接pgadmin
用你的账号信息连接
如果正确安装了pgagent,就会有个pgagent任务
创建任务
步骤里主要写好基础设置,和需要执行的代码
时间表的信息就可以设置时间的重复。
本站文章,未经作者同意,请勿转载,如需转载,请邮件customer@csudata.com.
添加一条新评论
评论加一
评论