gpt4 book ai didi

linux - 在新的 Linux 服务器上恢复 postgresql 安装

转载 作者:太空宇宙 更新时间:2023-11-04 05:09:25 26 4
gpt4 key购买 nike

我不知道如何在新的 ubuntu 18.04 服务器上恢复 postgres 安装。我的旧 postgres 位于 mnt 分区中。

我刚刚使用 postgresqp 11 全新安装配置了新的 ubuntu 18.04 服务器。现在,我想用我的旧 postgres(也是 11)指向 mnt 分区。我尝试使用路径 "/mnt/postgresql/11/main" 更改默认目录的 data_directory 但没有成功。有什么想法吗?

mnt 分区包含我所有的数据库和旧信息:

/mnt/postgresql/11/main$ ls -a

. base pg_dynshmem pg_notify pg_snapshots pg_subtrans pg_wal postmaster.opts
.. global pg_logical pg_replslot pg_stat pg_tblspc pg_xact
PG_VERSION pg_commit_ts pg_multixact pg_serial pg_stat_tmp pg_twophase postgresql.auto.conf

我的默认路径是:

/etc/postgresql/11/main$ ls
conf.d pg_ctl.conf pg_ident.conf postgresql.conf.save start.conf
environment pg_hba.conf postgresql.conf postgresql.conf.save.1

我实际的/etc/postgresql/11/main/postgresql.conf是:

#------------------------------------------------------------------------------
# FILE LOCATIONS
#------------------------------------------------------------------------------

# The default values of these variables are driven from the -D command-line
# option or PGDATA environment variable, represented here as ConfigDir.

#data_directory = '/mnt/postgresql/11/main' '/var/lib/postgresql/11/main'
data_directory = '/mnt/postgresql/11/main' # use data in another directory
# (change requires restart)
hba_file = '/etc/postgresql/11/main/pg_hba.conf' # host-based authentication file
# (change requires restart)
ident_file = '/etc/postgresql/11/main/pg_ident.conf' # ident configuration file
# (change requires restart)

# If external_pid_file is not explicitly set, no extra PID file is written.
external_pid_file = '/var/run/postgresql/11-main.pid' # write an extra PID file
# (change requires restart)


#------------------------------------------------------------------------------
# CONNECTIONS AND AUTHENTICATION
#------------------------------------------------------------------------------

# - Connection Settings -

listen_addresses = '*' # what IP address(es) to listen on;
# comma-separated list of addresses;
# defaults to 'localhost'; use '*' for all
# (change requires restart)
port = 5432 # (change requires restart)

我需要恢复所有 mnt 分区数据,但我不知道该怎么做。有帮助吗??

当我重新启动 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"?

最佳答案

psql 是一个客户端实用程序,它不会启动 postgresql 服务。要在 Ubuntu 中启动 PostgreSQL,请使用 service 命令(必须是 root 或 sudo):

sudo service postgresql start

关于linux - 在新的 Linux 服务器上恢复 postgresql 安装,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57308610/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com