安装 Postgresql 时 AWS Opsworks Chef 配方失败
Posted
技术标签:
【中文标题】安装 Postgresql 时 AWS Opsworks Chef 配方失败【英文标题】:AWS Opsworks Chef recipe fails when installing Postgresql 【发布时间】:2021-10-22 12:30:50 【问题描述】:我正在 AWS Opsworks 中运行此脚本。它以前工作过,但现在它失败并在脚本下方显示错误消息。 该脚本创建 linux-2 服务器实例,然后立即运行该脚本。 有些人建议设置 pgpcheck=0,但我不知道在哪里添加它。我也不知道是不是这样。
template '/etc/sysconfig/clock' do
source "timezone.erb"
owner 'root'
group 'root'
end
link '/etc/localtime' do
to '/usr/share/zoneinfo/Australia/Sydney'
end
# execute 'enable epel' do
# command 'yum-config-manager --enable epel'
# sensitive true
# end
# package "barman" do
# action :install
# end
packages = %wtmux wget curl htop deltarpm vim-enhanced perl-Switch perl-DateTime perl-Sys-Syslog perl-LWP-Protocol-https perl-Digest-SHA.x86_64
for p in packages do
package p do
action :install
end
end
remote_file "/root/postgres.rpm" do
source "https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm"
action :create_if_missing
end
remote_file "/tmp/wal-g.tar.gz" do
source "https://github.com/wal-g/wal-g/releases/download/v0.2.14/wal-g.linux-amd64.tar.gz"
action :create_if_missing
end
execute 'extract wal-g' do
command 'tar xzvf /tmp/wal-g.tar.gz'
cwd '/usr/local/sbin'
creates '/usr/local/sbin/wal-g'
end
rpm_package "pgdg-redhat12" do
source "/root/postgres.rpm"
action :install
options " --nodeps "
end
ruby_block "fix repo release path" do
block do
fe = Chef::Util::FileEdit.new("/etc/yum.repos.d/pgdg-redhat-all.repo")
fe.search_file_replace(/rhel-\$releasever-\$basearch/,
"rhel-7.5-x86_64")
fe.write_file
end
end
package "postgresql12-server" do
action :install
end
package "postgresql12-contrib" do
action :install
end
为简洁起见,删除了脚本的其余部分。
================================================================================
Error executing action `install` on resource 'yum_package[postgresql12-server]'
================================================================================
Mixlib::ShellOut::ShellCommandFailed
------------------------------------
Expected process to exit with [0], but received '1'
---- Begin output of /usr/bin/python /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/provider/package/yum/yum-dump.py --options --all-provides --yum-lock-timeout 30 ----
STDOUT: [option installonlypkgs] kernel kernel-bigmem installonlypkg(kernel) installonlypkg(kernel-module) installonlypkg(vm) kernel-enterprise kernel-smp kernel-debug kernel-unsupported kernel-source kernel-devel kernel-PAE kernel-PAE-debug
STDERR: yum-dump Repository Error: failure: repodata/repomd.xml from pgdg-common: [Errno 256] No more mirrors to try.
https://download.postgresql.org/pub/repos/yum/common/redhat/rhel-7.5-x86_64/repodata/repomd.xml: [Errno -1] repomd.xml signature could not be verified for pgdg-common
---- End output of /usr/bin/python /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/provider/package/yum/yum-dump.py --options --all-provides --yum-lock-timeout 30 ----
Ran /usr/bin/python /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/provider/package/yum/yum-dump.py --options --all-provides --yum-lock-timeout 30 returned 1
Resource Declaration:
---------------------
# In /var/chef/runs/4af4db66-94d5-43ff-89ca-1002521b8d4a/local-mode-cache/cache/cookbooks/pw_hosting/recipes/db_setup_al.rb
59: package "postgresql12-server" do
60: action :install
61: end
62:
Compiled Resource:
------------------
# Declared in /var/chef/runs/4af4db66-94d5-43ff-89ca-1002521b8d4a/local-mode-cache/cache/cookbooks/pw_hosting/recipes/db_setup_al.rb:59:in `from_file'
yum_package("postgresql12-server") do
package_name "postgresql12-server"
action [:install]
retries 0
retry_delay 2
default_guard_interpreter :default
declared_type :package
cookbook_name "pw_hosting"
recipe_name "db_setup_al"
flush_cache :before=>false, :after=>false
end
Platform:
---------
x86_64-linux
[2021-08-21T15:38:39+10:00] INFO: Running queued delayed notifications before re-raising exception
[2021-08-21T15:38:39+10:00] ERROR: Running exception handlers
[2021-08-21T15:38:39+10:00] ERROR: Exception handlers complete
[2021-08-21T15:38:39+10:00] FATAL: Stacktrace dumped to /var/chef/runs/4af4db66-94d5-43ff-89ca-1002521b8d4a/local-mode-cache/cache/chef-stacktrace.out
[2021-08-21T15:38:39+10:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
[2021-08-21T15:38:39+10:00] ERROR: yum_package[postgresql12-server] (pw_hosting::db_setup_al line 59) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'
---- Begin output of /usr/bin/python /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/provider/package/yum/yum-dump.py --options --all-provides --yum-lock-timeout 30 ----
STDOUT: [option installonlypkgs] kernel kernel-bigmem installonlypkg(kernel) installonlypkg(kernel-module) installonlypkg(vm) kernel-enterprise kernel-smp kernel-debug kernel-unsupported kernel-source kernel-devel kernel-PAE kernel-PAE-debug
STDERR: yum-dump Repository Error: failure: repodata/repomd.xml from pgdg-common: [Errno 256] No more mirrors to try.
https://download.postgresql.org/pub/repos/yum/common/redhat/rhel-7.5-x86_64/repodata/repomd.xml: [Errno -1] repomd.xml signature could not be verified for pgdg-common
---- End output of /usr/bin/python /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/provider/package/yum/yum-dump.py --options --all-provides --yum-lock-timeout 30 ----
Ran /usr/bin/python /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/provider/package/yum/yum-dump.py --options --all-provides --yum-lock-timeout 30 returned 1
[2021-08-21T15:38:39+10:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
Feedback
【问题讨论】:
这可能是一个临时问题,由许多讨论它的线程来处理。您可以尝试在/etc/yum.repos.d/pgdg-redhat-all.repo
中设置gpgcheck=0
。该错误涉及该文件中的[pgdg-common]
部分。
这导致了一个解决方案。在脚本中,我编写了一些代码将任何 gpgcheck 替换为 0,并将 repo_gpgcheck 替换为 0,并且脚本有效。您能否发布答案,我会接受。谢谢。
很高兴知道这会导致解决方案!
【参考方案1】:
根据搜索此问题的结果,它可能是暂时的。但是暂时您可以更改禁用 /etc/yum.repos.d/pgdg-redhat-all.repo
中存储库的 GPG 检查。
该错误表明 [pgdg-common]
存储库的 GPG 验证问题,但这可能是 pgdg-redhat-all.repo
文件中的其他存储库的问题。这通常通过gpgcheck=1
启用。
同时,对于所有使用类似Chef::Util::FileEdit
的内容将其更改为gpgcheck=0
应该可以工作。
【讨论】:
以上是关于安装 Postgresql 时 AWS Opsworks Chef 配方失败的主要内容,如果未能解决你的问题,请参考以下文章
如何使用 AWS Glue Crawler 读取 PostgreSQL 表分区?
如何在 Kubernetes 中使用 Aws EBS 挂载 postgresql 卷
Angular、Spring Boot 和 PostgreSQL 项目需要哪些 AWS 服务? [关闭]
使用 Ngrok 从 AWS Lambda 连接到本地 PostgreSQL