前言:在尝试过用简便的rpm包来安装的过程中,总会遇到一些莫名的错误,本次是在生产中需要部署一套pgagent,使用了源码编译安装,记录一下。
环境信息
centos7.4
postgres 10.6
需要的依赖包
cmake-3.15.3.tar.gz
wxGTK-2.8.12.tar.gz
pgAgent-4.0.0-Source.tar.gz
下载链接:https://pan.baidu.com/s/1BTlZM2OwuT8wuWgpKXWZyg
提取码:ajaf
也可以直接选择各插件的官网进行下载。
安装步骤
上传三个文件包到服务器对应路径下。
编译安装cmake
tar -xvf cmake-3.15.3.tar.gz
cd cmake-3.15.3/
./bootstrap && gmake && gmake install
可能存在以下错误
[root@hmc_fire cmake-3.15.3]# ./bootstrap && gmake && gmake install
---------------------------------------------
CMake 3.15.3, Copyright 2000-2019 Kitware, Inc. and Contributors
C compiler on this system is: cc
---------------------------------------------
Error when bootstrapping CMake:
Cannot find a C++ compiler that supports both C++11 and the specified C++ flags.
Please specify one using environment variable CXX.
The C++ flags are "".
They can be changed using the environment variable CXXFLAGS.
See cmake_bootstrap.log for compilers attempted.
---------------------------------------------
Log of errors: /root/cmake-3.15.3/Bootstrap.cmk/cmake_bootstrap.log
---------------------------------------------
需要安装gcc,笔者这里通过yum search gcc查找后安装
yum install gcc-c++.x86_64
然后再次执行上面的安装命令即可。
编译安装wxGTK
# 添加环境变量
# 根目录下执行 (需要看pg_config命令在root环境下是否生效了,可能存在环境依赖)
vi .bash_profile #将下面两行内容添加到末尾
export PATH=$PATH:$PGHOME/bin:/usr/local/wxGTK-2.8.12/bin
export LD_LIBRARY_PATH=/usr/local/wxGTK-2.8.12/lib:$PGHOME/lib:$LD_LIBRARY_PATH
# 然后加载环境
source .bash_profile
tar -xvf wxGTK-2.8.12.tar.gz
cd wxGTK-2.8.12/
./configure --enable-shared=no --enable-unicode=yes --prefix=/usr/local/wxGTK-2.8.12
# 此处可能存在报错,确实gtk相关依赖
# yum install gtk* 解决
make && make install
编译安装pgagent
tar -xvf pgAgent-4.0.0-Source.tar.gz
cd pgAgent-4.0.0-Source/
cmake ./
# 可能会报错提示有依赖没有安装,执行命令安装
# yum install boost*
make && make install
最后切换到postgres用户下,进入 "对应" 数据库命令行, 创建扩展
create extension pgagent;
使用postgres用户,启动pgagent服务
pgagent_10 hostaddr=127.0.0.1 dbname=postgres user=postgres
# pgagent_10有可能是pgagent,名称可能不一样。如果不是以postgres用户启动的,需要添加password
结束
至此,安装工作结束,使用pgadmin连接数据库,可以发现有pgAgent jobs选项。
网友评论