PostgreSQL 更新在中国失败

无法重建数据

./launcher rebuild data
检测到 x86_64 架构。
确保启动器是最新的
启动器是最新的
2.0.20250129-0720:正在从 docker-hub-china/discourse-base 拉取
摘要:sha256:d798a945ca4d31c29e5d263cdaf807bafab9b5f6737be0b1b852bea0063a3b91
状态:镜像已最新,来自 registry.cn-wulanchabu.aliyuncs.com/docker-hub-china/discourse-base:2.0.20250129-0720
registry.cn-wulanchabu.aliyuncs.com/docker-hub-china/discourse-base:2.0.20250129-0720
/usr/local/lib/ruby/gems/3.3.0/gems/pups-1.2.1/lib/pups.rb
/usr/local/bin/pups --stdin
I, [2025-02-06T04:49:43.809493 #1]  INFO -- : 从标准输入读取
I, [2025-02-06T04:49:43.812252 #1]  INFO -- : 跳过缺失的 before_code 钩子
I, [2025-02-06T04:49:43.812294 #1]  INFO -- : 跳过缺失的 before_db_migrate 钩子
I, [2025-02-06T04:49:43.812309 #1]  INFO -- : 跳过缺失的 after_code 钩子
I, [2025-02-06T04:49:43.816721 #1]  INFO -- : 文件 > /etc/service/postgres/run  chmod: +x  chown:
I, [2025-02-06T04:49:43.820580 #1]  INFO -- : 文件 > /etc/service/postgres/log/run  chmod: +x  chown:
I, [2025-02-06T04:49:43.824283 #1]  INFO -- : 文件 > /etc/runit/3.d/99-postgres  chmod: +x  chown:
I, [2025-02-06T04:49:43.827979 #1]  INFO -- : 文件 > /root/install_postgres  chmod: +x  chown:
I, [2025-02-06T04:49:43.832007 #1]  INFO -- : 文件 > /root/upgrade_postgres  chmod: +x  chown:
I, [2025-02-06T04:49:43.832273 #1]  INFO -- : 在 /etc/postgresql/15/main/postgresql.conf 中将 data_directory = '/var/lib/postgresql/15/main' 替换为 data_directory = '/shared/postgres_data'
I, [2025-02-06T04:49:43.832904 #1]  INFO -- : 在 /etc/postgresql/15/main/postgresql.conf 中将 (?-mix:#?listen_addresses *=.*) 替换为 listen_addresses = '*'
I, [2025-02-06T04:49:43.833313 #1]  INFO -- : 在 /etc/postgresql/15/main/postgresql.conf 中将 (?-mix:#?synchronous_commit *=.*) 替换为 synchronous_commit = $db_synchronous_commit
I, [2025-02-06T04:49:43.843122 #1]  INFO -- : 在 /etc/postgresql/15/main/postgresql.conf 中将 (?-mix:#?shared_buffers *=.*) 替换为 shared_buffers = $db_shared_buffers
I, [2025-02-06T04:49:43.843548 #1]  INFO -- : 在 /etc/postgresql/15/main/postgresql.conf 中将 (?-mix:#?work_mem *=.*) 替换为 work_mem = $db_work_mem
I, [2025-02-06T04:49:43.843885 #1]  INFO -- : 在 /etc/postgresql/15/main/postgresql.conf 中将 (?-mix:#?default_text_search_config *=.*) 替换为 default_text_search_config = '$db_default_text_search_config'
I, [2025-02-06T04:49:43.844162 #1]  INFO -- : 在 /etc/postgresql/15/main/postgresql.conf 中将 (?-mix:#?checkpoint_segments *=.*) 替换为 checkpoint_segments = $db_checkpoint_segments
I, [2025-02-06T04:49:43.844439 #1]  INFO -- : 在 /etc/postgresql/15/main/postgresql.conf 中将 (?-mix:#?logging_collector *=.*) 替换为 logging_collector = $db_logging_collector
I, [2025-02-06T04:49:43.844732 #1]  INFO -- : 在 /etc/postgresql/15/main/postgresql.conf 中将 (?-mix:#?log_min_duration_statement *=.*) 替换为 log_min_duration_statement = $db_log_min_duration_statement
I, [2025-02-06T04:49:43.845050 #1]  INFO -- : 在 /etc/postgresql/15/main/pg_hba.conf 中将 (?-mix:^#local +replication +postgres +peer$) 替换为 local replication postgres  peer
I, [2025-02-06T04:49:43.845283 #1]  INFO -- : 在 /etc/postgresql/15/main/pg_hba.conf 中将 (?-mix:^host.*all.*all.*127.*$) 替换为 host all all 0.0.0.0/0 md5
I, [2025-02-06T04:49:43.845505 #1]  INFO -- : 在 /etc/postgresql/15/main/pg_hba.conf 中将 (?-mix:^host.*all.*all.*::1\\/128.*$) 替换为 host all all ::/0 md5
I, [2025-02-06T04:49:43.845723 #1]  INFO -- : > if [ -f /root/install_postgres ]; then
  /root/install_postgres & && rm -f /root/install_postgres
elif [ -e /shared/postgres_run/.s.PGSQL.5432 ]; then
  socat /dev/null UNIX-CONNECT:/shared/postgres_run/.s.PGSQL.5432 || exit 0 && echo postgres already running stop container ; exit 1
fi

2025/02/06 04:49:45 socat[33] E connect(, AF=1 "/shared/postgres_run/.s.PGSQL.5432", 36): 连接被拒绝
initdb: 警告:为本地连接启用“trust”身份验证
initdb: 提示:下次运行 initdb 时,可以通过编辑 pg_hba.conf 或使用选项 -A、--auth-local 和 --auth-host 来更改此设置。

您的日志似乎不完整,但下面的代码片段可以提供一些线索。

socat[33] E connect(, AF=1 “/shared/postgres_run/.s.PGSQL.5432”, 36): Connection refused

您是否也在日志输出的靠后部分看到了以下错误?

The source cluster was not shut down cleanly

如果是这样,您可以尝试遵循这些说明

没有正在运行的容器

您在第一步中看到任何错误吗?

我使用了 data.yml 和 web_only.yml 方法

您仍然可以遵循相同的指示,但将任何出现的 appstandalone 替换为 data

仍未连接

$ ./launcher enter data
检测到 x86_64 架构。
root@sober-data:/# export SVWAIT=300
sv stop nginx
sv stop unicorn
sv stop postgres
exit
fail: nginx: 无法更改到服务目录:文件不存在
fail: unicorn: 无法更改到服务目录:文件不存在
ok: down: postgres: 0s, 通常为 up
logout

这表示您已连接到容器。(只需确保在重建 data 容器期间 web_only 容器保持停止状态。)

ok: down: postgres: 0s, normally up

这是重要的输出。它表示 postgres 已干净关闭,您可以继续执行后续步骤。

 ./launcher enter  data
检测到 x86_64 架构。
root@sober-data:/# sv stop postgres
ok: 关闭: postgres: 0秒,通常运行中
root@sober-data:/# exit
logout
root@sober:/var/discourse$ ./launcher rebuild  data
检测到 x86_64 架构。
确保 launcher 已更新
Launcher 已是最新
停止旧容器
+ /usr/bin/docker stop -t 600 data
data
2.0.20250129-0720:从 docker-hub-china/discourse-base 拉取
Digest: sha256:d798a945ca4d31c29e5d263cdaf807bafab9b5f6737be0b1b852bea0063a3b91
状态:镜像已是最新的,用于 registry.cn-wulanchabu.aliyuncs.com/docker-hub-china/discourse-base:2.0.20250129-0720
registry.cn-wulanchabu.aliyuncs.com/docker-hub-china/discourse-base:2.0.20250129-0720
/usr/local/lib/ruby/gems/3.3.0/gems/pups-1.2.1/lib/pups.rb
/usr/local/bin/pups --stdin
I, [2025-02-06T06:19:20.379635 #1]  INFO -- : 从标准输入读取
I, [2025-02-06T06:19:20.380959 #1]  INFO -- : 跳过缺少的 before_code hook
I, [2025-02-06T06:19:20.380976 #1]  INFO -- : 跳过缺少的 before_db_migrate hook
I, [2025-02-06T06:19:20.380983 #1]  INFO -- : 跳过缺少的 after_code hook
I, [2025-02-06T06:19:20.383923 #1]  INFO -- : 文件 > /etc/service/postgres/run  chmod: +x  chown: 
I, [2025-02-06T06:19:20.386435 #1]  INFO -- : 文件 > /etc/service/postgres/log/run  chmod: +x  chown: 
I, [2025-02-06T06:19:20.389343 #1]  INFO -- : 文件 > /etc/runit/3.d/99-postgres  chmod: +x  chown: 
I, [2025-02-06T06:19:20.391719 #1]  INFO -- : 文件 > /root/install_postgres  chmod: +x  chown: 
I, [2025-02-06T06:19:20.394375 #1]  INFO -- : 文件 > /root/upgrade_postgres  chmod: +x  chown: 
I, [2025-02-06T06:19:20.394471 #1]  INFO -- : 在 /etc/postgresql/15/main/postgresql.conf 中,将 data_directory = '/var/lib/postgresql/15/main' 替换为 data_directory = '/shared/postgres_data'
I, [2025-02-06T06:19:20.394742 #1]  INFO -- : 在 /etc/postgresql/15/main/postgresql.conf 中,将 (?-mix:#?listen_addresses *=.*) 替换为 listen_addresses = '*' 
I, [2025-02-06T06:19:20.394972 #1]  INFO -- : 在 /etc/postgresql/15/main/postgresql.conf 中,将 (?-mix:#?synchronous_commit *=.*) 替换为 synchronous_commit = $db_synchronous_commit
I, [2025-02-06T06:19:20.395126 #1]  INFO -- : 在 /etc/postgresql/15/main/postgresql.conf 中,将 (?-mix:#?shared_buffers *=.*) 替换为 shared_buffers = $db_shared_buffers
I, [2025-02-06T06:19:20.395261 #1]  INFO -- : 在 /etc/postgresql/15/main/postgresql.conf 中,将 (?-mix:#?work_mem *=.*) 替换为 work_mem = $db_work_mem
I, [2025-02-06T06:19:20.395400 #1]  INFO -- : 在 /etc/postgresql/15/main/postgresql.conf 中,将 (?-mix:#?default_text_search_config *=.*) 替换为 default_text_search_config = '$db_default_text_search_config'
I, [2025-02-06T06:19:20.395510 #1]  INFO -- : 在 /etc/postgresql/15/main/postgresql.conf 中,将 (?-mix:#?checkpoint_segments *=.*) 替换为 checkpoint_segments = $db_checkpoint_segments
I, [2025-02-06T06:19:20.395622 #1]  INFO -- : 在 /etc/postgresql/15/main/postgresql.conf中,将 (?-mix:#?logging_collector *=.*) 替换为 logging_collector = $db_logging_collector
I, [2025-02-06T06:19:20.395723 #1]  INFO -- : 在 /etc/postgresql/15/main/postgresql.conf中,将 (?-mix:#?log_min_duration_statement *=.*) 替换为 log_min_duration_statement = $db_log_min_duration_statement
I, [2025-02-06T06:19:20.395845 #1]  INFO -- : 在 /etc/postgresql/15/main/pg_hba.conf中,将 #local +replication +postgres +peer 替换为 local replication postgres  peer 
I, [2025-02-06T06:19:20.395930 #1]  INFO -- : 在 /etc/postgresql/15/main/pg_hba.conf中,将 ^host.*all.*all.*127.*$ 替换为 host all all 0.0.0.0/0 md5
I, [2025-02-06T06:19:20.396007 #1]  INFO -- : 在 /etc/postgresql/15/main/pg_hba.conf中,将 ^host.*all.*all.*::1\/128.*$ 替换为 host all all ::/0 md5
I, [2025-02-06T06:19:20.396096 #1]  INFO -- : > if [ -f /root/install_postgres ]; then
  /root/install_postgres && rm -f /root/install_postgres
elif [ -e /shared/postgres_run/.s.PGSQL.5432 ]; then
  socat /dev/null UNIX-CONNECT:/shared/postgres_run/.s.PGSQL.5432 || exit 0 && echo postgres already running stop container ; exit 1
fi

initdb: 警告:为本地连接启用 "trust" 认证
initdb: 提示:你可以通过编辑 pg_hba.conf 或使用 -A 选项或 --auth-local 和 --auth-host 进行更改,下一次运行 initdb 时。

重建是否卡在了这一点?如果是,请取消它并改用这个,然后发布结果。

./launcher start data
./launcher enter data
psql --version
apt-get update

非常感谢。让我返回到docker版本和postgres.template.yml

./launcher rebuild data
检测到x86_64架构。
确保启动器是最新的
启动器已是最新
停止旧容器
+ /usr/bin/docker stop -t 600 data
data
2.0.20250129-0720: 正在从docker-hub-china/discourse-base拉取
Digest: sha256:d798a945ca4d31c29e5d263cdaf807bafab9b5f6737be0b1b852bea0063a3b91
状态:镜像已是最新,来自 registry.cn-wulanchabu.aliyuncs.com/docker-hub-china/discourse-base:2.0.20250129-0720
registry.cn-wulanchabu.aliyuncs.com/docker-hub-china/discourse-base:2.0.20250129-0720
/usr/local/lib/ruby/gems/3.3.0/gems/pups-1.2.1/lib/pups.rb
/usr/local/bin/pups --stdin
我,[2025-02-06T07:02:42.768651 #1]  信息 -- : 正在从标准输入读取
我,[2025-02-06T07:02:42.769907 #1]  信息 -- : 跳过缺失的 before_code hook
我,[2025-02-06T07:02:42.769923 #1]  信息 -- : 跳过缺失的 before_db_migrate hook
我,[2025-02-06T07:02:42.769933 #1]  信息 -- : 跳过缺失的 after_code hook
我,[2025-02-06T07:02:42.772767 #1]  信息 -- : 文件 > /etc/service/postgres/run  chmod: +x  chown: 
我,[2025-02-06T07:02:42.775230 #1]  信息 -- : 文件 > /etc/service/postgres/log/run  chmod: +x  chown: 
我,[2025-02-06T07:02:42.777690 #1]  信息 -- : 文件 > /etc/runit/3.d/99-postgres  chmod: +x  chown: 
我,[2025-02-06T07:02:42.779645 #1]  信息 -- : 文件 > /root/install_postgres  chmod: +x  chown: 
我,[2025-02-06T07:02:42.781825 #1]  信息 -- : 文件 > /root/upgrade_postgres  chmod: +x  chown: 
我,[2025-02-06T07:02:42.781974 #1]  信息 -- : 替换 data_directory = '/var/lib/postgresql/15/main' 为 data_directory = '/shared/postgres_data',在 /etc/postgresql/15/main/postgresql.conf
我,[2025-02-06T07:02:42.782261 #1]  信息 -- : 替换 (?-mix:#?listen_addresses *=.*) 为 listen_addresses = '*' 在 /etc/postgresql/15/main/postgresql.conf
我,[2025-02-06T07:02:42.782427 #1]  信息 -- : 替换 (?-mix:#?synchronous_commit *=.*) 为 synchronous_commit = $db_synchronous_commit 在 /etc/postgresql/15/main/postgresql.conf
我,[2025-02-06T07:02:42.782551 #1]  信息 -- : 替换 (?-mix:#?shared_buffers *=.*) 为 shared_buffers = $db_shared_buffers 在 /etc/postgresql/15/main/postgresql.conf
我,[2025-02-06T07:02:42.782661 #1]  信息 -- : 替换 (?-mix:#?work_mem *=.*) 为 work_mem = $db_work_mem 在 /etc/postgresql/15/main/postgresql.conf
我,[2025-02-06T07:02:42.782762 #1]  信息 -- : 替换 (?-mix:#?default_text_search_config *=.*) 为 default_text_search_config = '$db_default_text_search_config' 在 /etc/postgresql/15/main/postgresql.conf
我,[2025-02-06T07:02:42.782877 #1]  信息 -- : 替换 (?-mix:#?checkpoint_segments *=.*) 为 checkpoint_segments = $db_checkpoint_segments 在 /etc/postgresql/15/main/postgresql.conf
我,[2025-02-06T07:02:42.782974 #1]  信息 -- : 替换 (?-mix:#?logging_collector *=.*) 为 logging_collector = $db_logging_collector 在 /etc/postgresql/15/main/postgresql.conf
我,[2025-02-06T07:02:42.783076 #1]  信息 -- : 替换 (?-mix:#?log_min_duration_statement *=.*) 为 log_min_duration_statement = $db_log_min_duration_statement 在 /etc/postgresql/15/main/postgresql.conf
我,[2025-02-06T07:02:42.783180 #1]  信息 -- : 替换 (?-mix:#?local +replication +postgres +peer$) 为 local replication postgres  peer 在 /etc/postgresql/15/main/pg_hba.conf
我,[2025-02-06T07:02:42.783258 #1]  信息 -- : 替换 (?-mix:#?host.*all.*all.*127.*$) 为 host all all 0.0.0.0/0 md5 在 /etc/postgresql/15/main/pg_hba.conf
我,[2025-02-06T07:02:42.783334 #1]  信息 -- : 替换 (?-mix:#?host.*all.*all.*::1\/128.*$) 为 host all all ::/0 md5 在 /etc/postgresql/15/main/pg_hba.conf
我,[2025-02-06T07:02:42.783416 #1]  信息 -- : > if [ -f /root/install_postgres ]; then
  /root/install_postgres && rm -f /root/install_postgres
elif [ -e /shared/postgres_run/.s.PGSQL.5432 ]; then
  socat /dev/null UNIX-CONNECT:/shared/postgres_run/.s.PGSQL.5432 || exit 0 && echo postgres已在运行,停止容器;退出 1
fi

initdb: 警告: 为本地连接启用了"trust"认证
initdb: 提示: 你可以通过编辑 pg_hba.conf 或使用 -A 选项,或者 --auth-local 和 --auth-host,来更改此设置,下次运行 initdb 时生效。

e 2.0.20250129-0720: 正在从 docker-hub-china/discourse-base 拉取

你能确认你的服务器是否在中国吗?

镜像没问题,这是中国镜像网络加速方法,否则镜像没有网络速度

我将您的查询转移到了一个新话题。我相信这与从中国运行更新有关。

根据您的日志输出,重建似乎在 apt-get update 时失败。我建议使用VPN将您的服务器连接到 apt 仓库。

我也为 apt-get update 做了一个中国的网络加速过程。我想知道 apt-get update 主要更新了哪些软件?

我宁愿知道 /shared/postgres_run/.s.PGSQL.5432 无法连接的根本原因是什么。

您的服务器能够访问下面的存储库吗?

curl -v https://apt.postgresql.org/pub/repos/apt/

更新期间需要该存储库来安装旧的 PostgreSQL 软件包。

这通常是由于数据库未正确关闭引起的。我们之前在您启动和停止 data 容器时已修复了此问题。在您最新的日志输出中未看到此错误。

1 个赞

您的意思是 PostgreSQL 版本太旧,导致了问题。这次升级可以集成到镜像的 Discourse/base 处理中。我使用的是镜像的 Discourse/base: 2.0.20250129-0720。

我的理解有任何问题吗?哪个 PostgreSQL 版本运行正常,哪个 PostgreSQL 版本有问题?

或者,问题可能出在我使用的镜像太新,导致数据构建出现问题。我需要使用镜像 Discourse/base: 2.0.20250114-0014 来构建数据,以适应 PostgreSQL 的升级。

I got the upgrade PostgreSQL15

Templates need to be used in sequence

postgres.13.template.yml
postgres.15.template.yml
postgres.template.yml

postgres.13.template.yml、postgres.15.template.yml file China network acceleration configuration

run:
  - exec: cat /etc/os-release && psql --version
  - exec: |
      if [ -f /etc/apt/sources.list ]; then
        sudo sed -i 's/deb.debian.org/mirrors.ustc.edu.cn/g' /etc/apt/sources.list
      else
        echo "deb http://mirrors.ustc.edu.cn/debian bookworm main contrib non-free non-free-firmware" | sudo tee /etc/apt/sources.list
        echo "deb http://mirrors.ustc.edu.cn/debian bookworm-updates main contrib non-free non-free-firmware" | sudo tee -a /etc/apt/sources.list
      fi
  - exec: |
      if [ -f /etc/apt/sources.list.d/debian.sources ]; then
        sudo sed -i 's/deb.debian.org/mirrors.ustc.edu.cn/g' /etc/apt/sources.list.d/debian.sources
      else
        sudo bash -c 'cat > /etc/apt/sources.list.d/debian.sources <<EOF
        URIs: http://mirrors.ustc.edu.cn/debian
        Suites: bookworm bookworm-updates
        Components: main contrib non-free non-free-firmware
        Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg

        Types: deb
        URIs: http://mirrors.ustc.edu.cn/debian-security
        Suites: bookworm-security
        Components: main contrib non-free non-free-firmware
        Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg
        EOF'
      fi
  - exec: cat /etc/apt/sources.list && cat /etc/apt/sources.list.d/debian.sources
2 个赞

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.