1

我正在尝试使用操作码食谱中的厨师独奏安装 postgresql 9.3,但出现以下错误:

Chef::Exceptions::Package: No version specified, and no candidate version available for postgresql93-devel 

这是我在 attributes/default.rb 中的代码,但它只安装了 9.1,无法找到 9.3-devel 的包。

default['postgresql']['version'] = '9.3'
default['postgresql']['client']['packages'] = ["postgresql#{node['postgresql']['version'].split('.').join}-devel"]
default['postgresql']['server']['packages'] = ["postgresql#{node['postgresql']['version'].split('.').join}-server"]
default['postgresql']['contrib']['packages'] = ["postgresql#{node['postgresql']['version'].split('.').join}-contrib"]
default['postgresql']['dir'] = "/var/lib/pgsql/#{node['postgresql']['version']}/data"
default['postgresql']['server']['service_name'] = "postgresql-#{node['postgresql']['version']}"

如果我使用此代码来安装 9.2,则它是成功的,但 minitest 抱怨未安装 9.3 版。

default['postgresql']['version'] = '9.2'
default['postgresql']['enable_pgdg_apt'] = true
default['postgresql']['dir'] = "/etc/postgresql/9.2/main"
default['postgresql']['config']['data_directory'] = "/var/lib/postgresql/9.2/main"
default['postgresql']['config']['hba_file'] = "/etc/postgresql/9.2/main/pg_hba.conf"
default['postgresql']['config']['ident_file'] = "/etc/postgresql/9.2/main/pg_ident.conf"
default['postgresql']['config']['external_pid_file'] = "/var/run/postgresql/9.2-main.pid"
default['postgresql']['config']['ssl_key_file']  = "/etc/ssl/private/ssl-cert-snakeoil.key"
default['postgresql']['config']['ssl_cert_file'] = "/etc/ssl/certs/ssl-cert-snakeoil.pem"
default['postgresql']['client']['packages']  = ["postgresql-client-9.2"]
default['postgresql']['server']['packages']  = ["postgresql-9.2"]
default['postgresql']['contrib']['packages'] = ["postgresql-contrib-9.2"]

我现在在 attributes/default.rb 中使用它

default['postgresql']['password']['postgres'] = 'xxx'
default['sportdata-server']['database']['dbname'] = 'myapp_production'
default['postgresql']['pgdg']['release_apt_codename'] = 'precise'
default['postgresql']['version'] = '9.3'
default['postgresql']['config']['ssl']  = false
default['postgresql']['config']['listen_addresses']  = '*'
4

3 回答 3

6

我刚刚用 CentOS 完成了这项工作,但我从未在 Ubuntu 上尝试过。我注意到几件事:

  1. 您没有为 9.3 启用 pgdg 存储库
  2. 您指定了一些无效的包名称。我认为食谱中的默认值应该足够了。

尝试这个

default['postgresql']['version'] = '9.3'
default['postgresql']['enable_pgdg_apt'] = true

您可能还需要确保您的 VM 没有安装默认的 postgresql 版本。我在 CentOS 上遇到了这个问题。

于 2014-04-22T16:48:18.883 回答
0

我终于放弃了 opscode postgresql 烹饪书,并使用了这个:

属性/default.rb

default ['lsb']['codename'] = 'trusty'
default['postgresql']['version'] = '9.3'

在我的 postgresql-server 配方中:

file "remove deprecated Pitti PPA apt repository" do
  action :delete
  path "/etc/apt/sources.list.d/pitti-postgresql-ppa"
end

bash "adding postgresql repo" do
  user "root"
  code <<-EOC
  echo "deb http://apt.postgresql.org/pub/repos/apt/ #{node['lsb']['codename']}-pgdg main" > /etc/apt/sources.list.d/pgdg.list
  wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
  EOC
  action :run
end

execute "run apt-get update" do
  command 'apt-get update'
  action :run
end

packages = %w(
  libpq-dev
  git-core 
  curl 
  zlib1g-dev
  libssl-dev 
  libreadline-dev 
  libyaml-dev 
  libsqlite3-dev 
  sqlite3 
  libxml2-dev 
  libxslt1-dev
  postgresql-contrib
)

packages.each { |name| package name }

package "postgresql-#{node['postgresql']['version']}"
于 2014-04-21T11:12:02.043 回答
0

Opscode 食谱的这个分支为我解决了这个问题https://github.com/jackpine/postgresql/tree/feature/ubuntu1404。它尚未与 master 合并:https ://github.com/hw-cookbooks/postgresql/pull/150 。

于 2014-06-12T12:46:42.790 回答