7

我正在努力在 Vagrant VM (Ubuntu 12.04) 上使用Opscode postgresql 食谱安装 PostgreSQL 9.2。

这是我的食谱:

node.set['postgresql']['version']             = "9.2"
node.set['postgresql']['enable_pgdg_apt']     = true
node.set['postgresql']['password']            = {postgres: "pwd"}
node.set['postgresql']['server']['packages']  = ["postgresql-9.2"]

include_recipe "postgresql::apt_pgdg_postgresql"
include_recipe "postgresql::server"
include_recipe "database"

运行结果如下:

[2013-05-23T11:00:52+00:00] FATAL: Chef::Exceptions::EnclosingDirectoryDoesNotExist:
template[/etc/postgresql/9.2/main/postgresql.conf] (postgresql::server line 60) had an error: 
Chef::Exceptions::EnclosingDirectoryDoesNotExist: Parent directory /etc/postgresql/9.2/main does not exist.

我正在使用最新的 3.0.0 版本的 postgresql 食谱。

使用干净的 VM(vagrant destroy、up 等)从头开始重新运行所有内容会出现此错误:

[2013-05-23T11:16:37+00:00] FATAL: Chef::Exceptions::EnclosingDirectoryDoesNotExist:
template[/etc/postgresql/9.1/main/postgresql.conf] (postgresql::server line 60) had an error: 
Chef::Exceptions::EnclosingDirectoryDoesNotExist: Parent directory /etc/postgresql/9.1/main does not exist.

突然之间,我们甚至没有正确的版本。

4

2 回答 2

9

这是最终为我解决的问题:

  1. update-alternatives --remove postmaster.1.gz /usr/share/postgresql/9.1/man/man1/postmaster.1.gz

  2. 使用下面的conf。

剪辑:

postgresql: {
    enable_pgdg_apt: true,
    dir: "/etc/postgresql/9.2/main",
    config: {
        data_directory: "/var/lib/postgresql/9.2/main",
        hba_file: "/etc/postgresql/9.2/main/pg_hba.conf",
        ident_file: "/etc/postgresql/9.2/main/pg_ident.conf",
        external_pid_file: "/var/run/postgresql/9.2-main.pid",
        ssl_key_file: "/etc/ssl/private/ssl-cert-snakeoil.key",
        ssl_cert_file: "/etc/ssl/certs/ssl-cert-snakeoil.pem",
    },
    client: {
        packages: ["postgresql-client-9.2",],
    },
    server: {
        packages: ["postgresql-9.2", "postgresql-server-dev-9.2"],
    },
    contrib: {
        packages: ["postgresql-contrib-9.2"],
    },
    password: {
      postgres: 'postgres'
    },
    pg_hba: [
      {type: 'local', db: 'all', user: 'all', addr: nil, method: 'trust'},
      {type: 'host', db: 'all', user: 'all', addr: '127.0.0.1/32', method: 'trust'},
      {type: 'host', db: 'all', user: 'all', addr: '::1/128', method: 'trust'}
    ],
    version: "9.2",
},
于 2013-08-27T01:33:49.507 回答
7

我可以通过设置目录来解决这个问题:

node.set['postgresql']['dir'] = "/var/lib/postgresql/9.2/main"

看起来这是同一个问题:http ://tickets.opscode.com/browse/COOK-2113

于 2013-05-25T17:20:33.317 回答