嗨,我在一台centos 7机器上运行,我正在将一个旧的postgres数据库迁移到新服务器,它有10 to的数据,所以我正在用pg_basebackup尝试它。新服务器有一个独立的磁盘,具有足够的存储空间来处理操作,但它不是主磁盘。我想将PGDATA设置为这个大数据磁盘。
我遵循了以下步骤:
/usr/bin/pg_basebackup -h IP_OF_OLD_MACHINE -D /mnt/disks/data-disk/pgdata -P -U USERNAME --wal-method=stream我认为pg_basebackup成功地结束了,数据花了几个小时才完成,但是没有引起任何错误。
total 132K
-rw-------. 1 postgres postgres 230 Mar 18 12:36 backup_label
drwx------. 7 postgres postgres 4.0K Mar 18 12:43 base
-rw-------. 1 postgres postgres 30 Mar 19 00:13 current_logfiles
drwx------. 2 postgres postgres 4.0K Mar 19 00:13 global
drwx------. 2 postgres postgres 4.0K Mar 18 12:36 log
drwx------. 2 postgres postgres 4.0K Mar 18 12:36 pg_commit_ts
drwx------. 2 postgres postgres 4.0K Mar 18 12:36 pg_dynshmem
-rw-------. 1 postgres postgres 4.8K Mar 18 12:36 pg_hba.conf
-rw-------. 1 postgres postgres 4.7K Mar 18 12:36 pg_hba.conf~
-rw-------. 1 postgres postgres 1.6K Mar 19 00:13 pg_ident.conf
drwx------. 4 postgres postgres 4.0K Mar 18 12:36 pg_logical
drwx------. 4 postgres postgres 4.0K Mar 18 12:36 pg_multixact
drwx------. 2 postgres postgres 4.0K Mar 18 12:36 pg_notify
drwx------. 2 postgres postgres 4.0K Mar 18 12:36 pg_replslot
drwx------. 2 postgres postgres 4.0K Mar 18 12:36 pg_serial
drwx------. 2 postgres postgres 4.0K Mar 18 12:36 pg_snapshots
drwx------. 2 postgres postgres 4.0K Mar 18 12:36 pg_stat
drwx------. 2 postgres postgres 4.0K Mar 18 12:36 pg_stat_tmp
drwx------. 2 postgres postgres 4.0K Mar 18 12:36 pg_subtrans
drwx------. 2 postgres postgres 4.0K Mar 18 12:36 pg_tblspc
drwx------. 2 postgres postgres 4.0K Mar 18 12:36 pg_twophase
-rw-------. 1 postgres postgres 3 Mar 19 08:27 PG_VERSION
drwx------. 3 postgres postgres 4.0K Mar 18 12:36 pg_wal
drwx------. 2 postgres postgres 4.0K Mar 18 12:36 pg_xact
-rw-------. 1 postgres postgres 88 Mar 18 12:36 postgresql.auto.conf
-rw-------. 1 postgres postgres 24K Mar 19 08:39 postgresql.conf好的,现在我试图用这些数据初始化postgres服务器,我刚刚带来了一个。
这是我的尝试,查看文档:
/usr/pgsql-12/bin/postgresql-12-setup initdb -D /mnt/disks/data-disk/pgdata
systemctl: invalid option -- 'D'
failed to find PGDATA setting in -D.service
/usr/pgsql-12/bin/postgresql-12-setup initdb --pgdata=/mnt/disks/data-disk/pgdata
systemctl: unrecognized option '--pgdata=/mnt/disks/data-disk/pgdata.service'
failed to find PGDATA setting in --pgdata=/mnt/disks/data-disk/pgdata.service在这个过程中有什么错误吗?
更新:正如@pifor告诉我的那样,我向postgres bash_profile添加了路径,然后开始识别PG_DATA。现在的问题是,initdb的目标是查找一个空文件夹,而由于pg_basebackup,它不是空文件夹。
发布于 2020-03-19 15:47:42
物理备份(如pg_basebackup)导致已经初始化的目录。你不运行initdb。您只需启动它,可能在以适合您的情况的任何方式更改配置文件之后。
您可能应该使用指定的插槽将其配置为流,否则在进行备份时会落后,但这将是另一个问题。
为什么不直接将驱动器数组从一个服务器移动到另一个服务器?改变存储硬件和服务器硬件的愿望是吗?
https://dba.stackexchange.com/questions/262271
复制相似问题