移动数据库文件后无法连接到postgresql服务器

时间:2017-03-16 20:10:02

标签: postgresql debian postgresql-9.4

我想将postgresql数据库移动到外部硬盘驱动器(HDD 2TB USB 3.0)。我复制了整个目录:

/var/lib/postgresql/9.4/main/

到外部驱动器,保留权限,使用命令(由用户postgres运行):

$ rsync -aHAX /var/lib/postgresql/9.4/main/* new_dir_path

此命令的第一次运行被中断,但在第二次尝试中我复制了所有内容(基本上是一个大小为800 GB的数据库)。在文件

/etc/postgresql/9.4/main/postgresql.conf

我改变了行

data_directory = '/var/lib/postgresql/9.4/main'

指向新位置。我重新启动了postgresql服务,当我从用户postgres运行命令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"?

我没有更改任何其他设置。没有pidfile' postmaster.pid'在新的位置(或在旧的位置)。当我运行命令时

$ /usr/lib/postgresql/9.4/bin/postgres --single -D /etc/postgresql/9.4/main -P -d 1

我得到了

2017-03-16 20:47:39 CET [2314-1] DEBUG:  mmap with MAP_HUGETLB failed, huge pages disabled: Cannot allocate memory
2017-03-16 20:47:39 CET [2314-2] NOTICE:  database system was shut down at 2017-03-16 20:01:23 CET
2017-03-16 20:47:39 CET [2314-3] DEBUG:  checkpoint record is at 647/4041B3A0
2017-03-16 20:47:39 CET [2314-4] DEBUG:  redo record is at 647/4041B3A0; shutdown TRUE
2017-03-16 20:47:39 CET [2314-5] DEBUG:  next transaction ID: 1/414989450; next OID: 112553
2017-03-16 20:47:39 CET [2314-6] DEBUG:  next MultiXactId: 485048384; next MultiXactOffset: 1214064579
2017-03-16 20:47:39 CET [2314-7] DEBUG:  oldest unfrozen transaction ID: 259446705, in database 12141
2017-03-16 20:47:39 CET [2314-8] DEBUG:  oldest MultiXactId: 476142442, in database 12141
2017-03-16 20:47:39 CET [2314-9] DEBUG:  transaction ID wrap limit is 2406930352, limited by database with OID 12141
2017-03-16 20:47:39 CET [2314-10] DEBUG:  MultiXactId wrap limit is 2623626089, limited by database with OID 12141
2017-03-16 20:47:39 CET [2314-11] DEBUG:  starting up replication slots
2017-03-16 20:47:39 CET [2314-12] DEBUG:  oldest MultiXactId member is at offset 1191132700
2017-03-16 20:47:39 CET [2314-13] DEBUG:  MultiXact member stop limit is now 1191060352 based on MultiXact 476142442

PostgreSQL stand-alone backend 9.4.9
backend> 

但我现在不知道如何理解这个输出。当我还原postgresql.conf文件中的更改时,一切正常。有趣的是,几个月前我以相同的方式移动了数据库,但是移动到了本地目录,它运行起来了。 我使用postgresql-9.4和debian-jessie。

感谢您的帮助!

更新

日志文件的内容:

$ cat /var/log/postgresql/postgresql-9.4-main.log
2017-03-14 17:07:16 CET [13822-2] LOG:  received fast shutdown request
2017-03-14 17:07:16 CET [13822-3] LOG:  aborting any active transactions
2017-03-14 17:07:16 CET [13827-3] LOG:  autovacuum launcher shutting down
2017-03-14 17:07:16 CET [13824-1] LOG:  shutting down
2017-03-14 17:07:16 CET [13824-2] LOG:  database system is shut down

0 个答案:

没有答案
相关问题