【问题标题】:Migrate Postgres DB when the source Postgres server is offline在源 Postgres 服务器离线时迁移 Postgres DB
【发布时间】:2013-03-03 00:40:18
【问题描述】:

所以是的,标题说明了一切,我需要以某种方式将数据库从源服务器转移到新服务器,但关键是旧服务器正在分崩离析:P 有没有办法可以将它全部移动到新服务器并导入它?

旧服务器只是拒绝再运行 Postgres,我几乎可以肯定旧服务器上运行的版本是 8.4,而新服务器运行的是 9.2,这会导致问题吗?

这是我尝试在旧服务器上启动 Postgres 时得到的结果,

/etc/init.d/postgresql-8.4 start
* Use of the opts variable is deprecated and will be
* removed in the future.
* Please use extra_commands, extra_started_commands or extra_stopped_commands.
* Starting PostgreSQL ...
could not start server   [ !! ]
* ERROR: postgresql-8.4 failed to start

我也在运行 gentoo :)

提前感谢您的帮助!

【问题讨论】:

  • 所以我安装了 8.4 迁移了新服务器上的数据文件夹,现在 8.4 postgresql 将无法启动不知道发生了什么。为了使用pg_upgrade,服务器必须是可运行的。我得到的错误是DATA_DIR not set,我检查了/etc/conf.d/postgresql-8.4 文件并且设置了pgdata 变量# PostgreSQL's Database Directory PGDATA="/var/lib/postgresql/8.4/data"

标签: postgresql migrate gentoo


【解决方案1】:

注意!在 Gentoo 上,如果您的配置文件(postgresql.conf + pg_hba.conf)NOT 位于 /var/lib/postgresql//data/,pg_upgrade 将失败。新安装正在将配置文件存储在 /etc/postgresql- 中。

在迁移之前,请确保将文件从 /etc/postgresql-/ 复制到 pg_upgrade 的这个目录会失败。

【讨论】:

    【解决方案2】:

    您可以直接复制数据文件,但您必须在目标服务器上使用相同的major版本的PG(例如8.4.x - “8.4”是major)。检查版本的最简单方法是通过psql -V

    如果您想升级到 9.x 版本,这种情况下的升级过程并不难。您需要在新服务器上安装 8.4(通过软件包或手动),然后您需要使用 pg_upgrade 工具进行升级。 pg_upgrade 附带最新版本的 PG,因此预计在此期间在服务器上安装两个。

    您可以找到文档here

    【讨论】:

      猜你喜欢
      • 2018-01-27
      • 2016-01-01
      • 2020-07-02
      • 2022-11-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-08-24
      • 1970-01-01
      相关资源
      最近更新 更多