【问题标题】:chef-solo + postgres result in invalid pg_hba.confchef-solo + postgres 导致无效的 pg_hba.conf
【发布时间】:2013-11-11 00:39:41
【问题描述】:

我正在尝试用 vagrant + chef solo 设置 postgres。

我使用的是正式收据:http://community.opscode.com/cookbooks/postgresql

我的Berksfile 包含:

site :opscode

cookbook "postgresql"

而我的Vagrantfile 块是:

config.berkshelf.enabled = true

config.vm.provision "chef_solo" do |chef|

chef.add_recipe "postgresql::server"

  chef.json = {

  "postgresql" => {
      "version" => "9.2",
      "password" => { "postgres" => "123" },
      config: { 
      "ssl" => "false" 
  },
      pg_hba: [  
          { type: 'local', db: 'all', user: 'all', addr: '', method: 'trust' },
          { type: 'local', db: 'all', user: 'all', addr: '127.0.0.1/32', method: 'trust' },
          { type: 'local', db: 'all', user: 'all', addr: '::1/128 ', method: 'trust' } 
  ]
  }
end

/etc/postgresql/9.2/main/pg_hba.conf的生成内容如下:

# This file was automatically generated and dropped off by Chef!

# PostgreSQL Client Authentication Configuration File
# ===================================================
#
# Refer to the "Client Authentication" section in the PostgreSQL
# documentation for a complete description of this file.

# TYPE  DATABASE        USER            ADDRESS                 METHOD

###########
# Other authentication configurations taken from chef node defaults:
###########

local   all             all                                     trust

local   all             all             127.0.0.1/32            trust

local   all             all             ::1/128                 trust

# "local" is for Unix domain socket connections only
local   all             all                                     peer

但是,如果我运行 sudo service postgresql restart,它会失败并出现错误:

The PostgreSQL server failed to start. Please check the log output:
2013-11-10 08:12:05 GMT LOG:  invalid authentication method "127.0.0.1/32"
2013-11-10 08:12:05 GMT CONTEXT:  line 17 of configuration file "/etc/postgresql/9.2/main/pg_hba.conf"
2013-11-10 08:12:05 GMT LOG:  invalid authentication method "::1/128"
2013-11-10 08:12:05 GMT CONTEXT:  line 19 of configuration file "/etc/postgresql/9.2/main/pg_hba.conf"
2013-11-10 08:12:05 GMT FATAL:  could not load pg_hba.conf

有问题的条目是那些持有地址的条目。知道我的用例有什么问题吗?

【问题讨论】:

  • 我不完全确定,但我认为您不能像在第一行中那样将地址留空。尝试删除该行。
  • 第一行没问题,实际上只有一行没问题。提到地址的应该是“主机”,而不是“本地”。而目前最后一个是没用的。
  • @MilenA.Radev 感谢您的点击,成功了。随意添加它作为答案,我很乐意将其标记为正确的。

标签: postgresql vagrant chef-solo


【解决方案1】:

第一行没问题,实际上它是唯一没问题的行。提到地址的应该是“主机”,而不是“本地”。而且目前最后一个没用。

Postgres 文档中的更多信息 - "Client Authentication", "The pg_hba.conf File"

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-03-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多