linux - 有没有办法在没有 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"?
似乎服务器没有打开。我该如何解决?
或者有没有其他方法可以在不启动原始机器的情况下获取数据库?
解决方案
我发现了问题,
- data_directory 的权限应该是 700 ,但我设置为 777
sudo chmod -R <data_dir> 700
- data_directory 的所有者应该是 postgres
sudo chown -R postgres:postgres <data_dir>
推荐阅读
- javascript - 如何在javascript中动态添加asp-for
- c++ - 为什么编译器不能推断返回类型?
- python - 从插入 SQLLite3 中获取操作错误
- bash - 为什么在将其设置为变量后只运行一次而不是两次?重击
- java - 如何在 Java 中为 google cloud delpoyment manager deployments.insert() api 设置预览标志
- c# - 如何创建具有调用生命周期范围的 AWS Lambda 依赖注入服务?
- javascript - Vuejs如何在#app之前在HTML中声明一个组件
- arduino - ESP32 + 深度睡眠 + I2C - 中断问题
- node.js - 如何检测计算机是否锁定在 Node.js 中?
- javascript - 在 AG Grid 列标题中呈现 HTML (Community v20.0.0 +)