首页 > 解决方案 > 有没有办法在没有 pg_dump 的情况下迁移 postgresql db?

问题描述

原来的 postgres 服务器是在 ubuntu 上运行的,但是机器崩溃无法启动。

我尝试在安装了 postgres 的 Ubuntu 上实时挂载磁盘,然后将其更改为data_directory我挂载的原始 data_directoty 的路径,但失败了。运行时没有错误消息systemctl start postgresql,但是当我尝试使用 psql 登录时,它显示

psql: 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"?

似乎服务器没有打开。我该如何解决?

或者有没有其他方法可以在不启动原始机器的情况下获取数据库?

标签: linuxpostgresqlcrashdatabase-backups

解决方案


我发现了问题,

  1. data_directory 的权限应该是 700 ,但我设置为 777
    sudo chmod -R <data_dir> 700
  2. data_directory 的所有者应该是 postgres
    sudo chown -R postgres:postgres <data_dir>

推荐阅读