简体   繁体   English

PostgreSQL pgAgent的工作无法正常工作

[英]PostgreSQL pgAgent's job can't work

When I use postgres, the job works, but when I use ydz2, the job doesn't work: 当我使用postgres时,该工作正常,但是当我使用ydz2时,该工作不正常:

Couldn't get a connection to the database 无法连接到数据库

Both of them are my local database. 他们两个都是我的本地数据库。

Job Step 工作步骤

在此处输入图片说明

Job Step Statistics 作业步骤统计

在此处输入图片说明

Where should I configure it? 我应该在哪里配置它?

Thank you. 谢谢。

It seems pgagent cannot connect to the database, which might be because you didn't provide the required credentials. 似乎pgagent无法连接到数据库,这可能是因为您没有提供所需的凭据。 Make sure your .pgpass file is properly configured. 确保正确配置了.pgpass文件。

Assuming you're using the user postgres for pgAgent and that you have installed the extension in the database postgres : 假设您正在使用pgAgent用户postgres ,并且已在数据库postgres安装了扩展名:

$ sudo su - postgres
$ cd ~
$ nano .pgpass

Insert the following text and save the document: 插入以下文本并保存文档:

localhost:5432:*:postgres:[postgres_password]

This line basically tells the database connection to use the given password for the user postgres to connect to any ( * ) database on the server localhost listening on the port 5432 . 该行基本上告诉数据库连接使用给定的密码,以便用户postgres连接到侦听端口5432的服务器localhost上的任何( * )数据库。

Once you're done with the .pgpass, give the file the proper permissions: 一旦完成.pgpass,请为文件赋予适当的权限:

$ chmod 0600 .pgpass

You might need to restart pgAgent (not sure if it's necessary): 您可能需要重新启动pgAgent(不确定是否有必要):

$ pgagent hostaddr=localhost dbname=postgres user=postgres

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM