简体   繁体   English

PG :: ConnectionBad Postgres群集关闭

[英]PG::ConnectionBad Postgres Cluster down

Digitalocean disabled my droplet's internet access. Digitalocean禁用了我的Droplet的Internet访问。 After fixing the error (rollback to older backup) they restored the internet access. 修复错误(还原到较早的备份)后,他们恢复了Internet访问。 But afterwards I constantly get an error when deploying, I can't seem to get my Postgres database up and running. 但是之后,在部署过程中我经常遇到错误,我似乎无法启动并运行我的Postgres数据库。

I'm getting an error each time I try to deploy my application. 每次尝试部署应用程序时,都会收到错误消息。

PG::ConnectionBad: could not connect to server: No such file or directory
    Is the server running locally and accepting
    connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?

So I used SSH to login to my server and check if my Postgres was actually running with: 因此,我使用SSH登录到我的服务器,并检查我的Postgres是否实际在运行:

pg_lsclusters

Results into: 结果成:

Ver Cluster Port Status Owner Data directory Log file 9.5 main 5432 down postgres /var/lib/postgresql/9.5/main /var/log/postgresql/postgresql-9.5-main.log

Postgres server status Postgres服务器状态

So my Postgres server seems to be down. 因此我的Postgres服务器似乎已关闭。 I tried putting it 'up' again with: 我尝试通过以下方式再次将其“调高”:

pg_ctlcluster 9.5 main start After doing so I got the error: Insecure directory in $ENV{PATH} while running with -T switch at /usr/bin/pg_ctlcluster line 403. pg_ctlcluster 9.5 main start这样做之后,我得到了错误: Insecure directory in $ENV{PATH} while running with -T switch at /usr/bin/pg_ctlcluster line 403.

And /usr/bin/pg_ctlcluster on line 403 says: 403行上的/usr/bin/pg_ctlcluster说:

system 'systemctl', 'is-active', '-q', "postgresql\\@$version-$cluster"; But I'm not to sure what the problem could be here and how I could fix this. 但是我不确定问题可能出在哪里以及如何解决。

Update 更新资料

I also tried updating the permissions on /bin to 755 as mentioned here . 我也尝试更新的权限/bin提到到755 这里 Sadly that did not fix my problem. 不幸的是,这并没有解决我的问题。

Update 2 更新2

I changed the /usr/bin to 755. Now when I try pg_ctlcluster 9.5 main start , I get this: 我将/ usr / bin更改为755。现在,当我尝试pg_ctlcluster 9.5 main start ,我得到了:

Job for postgresql@9.5-main.service failed because the control process exited with error code. postgresql@9.5-main.service的作业失败,因为控制进程退出并显示错误代码。 See "systemctl status postgresql@9.5-main.service" and "journalctl -xe" for details. 有关详细信息,请参见“ systemctl状态postgresql@9.5-main.service”和“ journalctl -xe”。

And inside the systemctl status postgresql@9.5-main.service : systemctl status postgresql@9.5-main.service

postgresql@9.5-main.service - PostgreSQL Cluster 9.5-main
   Loaded: loaded (/lib/systemd/system/postgresql@.service; disabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Sun 2018-01-28 17:32:38 EST; 45s ago
  Process: 22473 ExecStart=postgresql@%i --skip-systemctl-redirect %i start (code=exited, status=1/FAILURE)

Jan 28 17:32:08 *url* systemd[1]: Starting PostgreSQL Cluster 9.5-main...
Jan 28 17:32:38 *url* postgresql@9.5-main[22473]: The PostgreSQL server failed to start.
Jan 28 17:32:38 *url* systemd[1]: postgresql@9.5-main.service: Control process exited, code=exited status=1
Jan 28 17:32:38 *url* systemd[1]: Failed to start PostgreSQL Cluster 9.5-main.
Jan 28 17:32:38 *url* systemd[1]: postgresql@9.5-main.service: Unit entered failed state.
Jan 28 17:32:38 *url* systemd[1]: postgresql@9.5-main.service: Failed with result 'exit-code'.

Thanks! 谢谢!

You better not mix systemctl and pg_ctlcluster . 您最好不要混合使用systemctlpg_ctlcluster Let systemctl makes the calls to pg_ctlcluster with the right user and permissions. systemctl使用正确的用户和权限调用pg_ctlcluster You should start your postgresql instance with 您应该使用以下命令启动postgresql实例

sudo systemctl start postgresql@9.5-main.service

Also, check the errors in the startup log. 另外,检查启动日志中的错误。 You can post them too, to help you figure out what's going on. 您也可以发布它们,以帮助您了解发生了什么。

Your systemctl status also outputs that the service is disable, so, when the server reboots, you will have to start the service manually. 您的systemctl status还输出该服务已禁用,因此,在服务器重新引导时,您将必须手动启动该服务。 To enable it run: 要启用它,请运行:

sudo systemctl enable postgresql@9.5-main.service

I hope it helps 希望对您有所帮助

It is mainly because /etc/hosts file is somehow changed.I have removed extra space inside /etc/hosts file.Use cat /etc/hosts Add these lines into the file 主要是因为/ etc / hosts文件有所更改。我已经删除了/ etc / hosts文件中的多余空间。使用cat / etc / hosts将这些行添加到文件中

  1. 127.0.0.1 localhost 127.0.0.1本地主机
  2. 127.0.1.1 your-host-name 127.0.1.1您的主机名
  3. ::1 ip6-localhost ip6-loopback :: 1 ip6-localhost ip6-loopback

And I have given permission 644 to /etc/hosts file.It is working for me even after the reboot of the system. 而且我已经授予/ etc / hosts文件644的权限。即使重新启动系统,它也对我有用。

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

相关问题 重新启动mac PG :: ConnectionBad后无法连接到postgres - can't connect to postgres after restarting mac PG::ConnectionBad PG::ConnectionBad: FATAL: 生产服务器上用户“postgres”的密码认证失败 - PG::ConnectionBad: FATAL: password authentication failed for user “postgres” on the production server Ruby / Sinatra / Postgres 应用程序“PG::ConnectionBad”的 Heroku 部署 - Heroku deployment for Ruby / Sinatra / Postgres app "PG::ConnectionBad" Ruby on Rails PG :: ConnectionBad - Ruby on Rails PG::ConnectionBad Docker - PG :: ConnectionBad - Docker - PG::ConnectionBad PG :: ConnectionBad错误 - PG::ConnectionBad error 从SQLite迁移到Postgres以便在Heroku上进行部署。 PG :: ConnectionBad。 使用Cloud9 - Migrating from SQLite to Postgres for deployment on Heroku. PG::ConnectionBad. Using Cloud9 Rails在Mac OS X / PG :: ConnectionBad上找不到我的Postgres服务器:无法连接到服务器 - Rails cannot find my Postgres server on Mac OS X / PG::ConnectionBad: could not connect to server Rails,Postgres和Docker有PG :: ConnectionBad“/var/run/postgresql/.s.PGSQL.5432”? - Rails, Postgres and Docker having PG::ConnectionBad “/var/run/postgresql/.s.PGSQL.5432”? 产品中的Rails 5:PG :: ConnectionBad:严重:使用Docker的用户“ postgres”的密码身份验证失败 - Rails 5 in prod: PG::ConnectionBad: FATAL: password authentication failed for user “postgres” with Docker
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM