Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/postgresql/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Postgresql 使用Chef设置基本postgres数据库_Postgresql_Chef Infra_Chef Recipe - Fatal编程技术网

Postgresql 使用Chef设置基本postgres数据库

Postgresql 使用Chef设置基本postgres数据库,postgresql,chef-infra,chef-recipe,Postgresql,Chef Infra,Chef Recipe,我试图使用Chef建立一个非常基本的postgres数据库,但缺乏厨师经验,无法理解超市烹饪书自述中的文档: 我需要的是与以下厨师相当的厨师: 创建用户 正在创建该用户拥有的数据库 对pg_hba.conf进行一个小更改,以便它需要密码 启动数据库 我希望能够在谷歌上搜索到这样一个基本的例子,但目前在配置postgresql的所有可能方式中都迷失了方向,我没有找到一个起点。 如果另一本食谱更有意义,请解释原因。我们目前还没有一个很好的答案来创建数据库用户和数据库。旧的数据库食谱曾经处理过这

我试图使用Chef建立一个非常基本的postgres数据库,但缺乏厨师经验,无法理解超市烹饪书自述中的文档:

我需要的是与以下厨师相当的厨师:

  • 创建用户
  • 正在创建该用户拥有的数据库
  • 对pg_hba.conf进行一个小更改,以便它需要密码
  • 启动数据库
我希望能够在谷歌上搜索到这样一个基本的例子,但目前在配置postgresql的所有可能方式中都迷失了方向,我没有找到一个起点。
如果另一本食谱更有意义,请解释原因。

我们目前还没有一个很好的答案来创建数据库用户和数据库。旧的
数据库
食谱曾经处理过这个问题,但是代码太难维护了,我们觉得有义务在没有替换计划的情况下弃用它。它仍然存在,应该可以正常工作,但这不是一种愉快的体验:(对于hba配置,您可以使用
postgresql
cookbook和一些节点属性来控制它,类似地,它将为您启动数据库服务。

我从这里给出的要点中获得帮助::

还检查了博士后文档:

最后,我编辑了我的dev cookbook/recipes/db.rb,并创建了用户

# d - user is allowed to create database
# l - user is allowed to log in
# s - user is a superuser
execute "create-database-user" do
  command "createuser -U postgres -dls db_user"
end
# U - user that is used to connect to psql
# O - owner of the database
# E - database encoding
execute "create-database" do
  command "createdb -U postgres -O db_user db_name -E 'utf8'"
end
数据库,包括:

# d - user is allowed to create database
# l - user is allowed to log in
# s - user is a superuser
execute "create-database-user" do
  command "createuser -U postgres -dls db_user"
end
# U - user that is used to connect to psql
# O - owner of the database
# E - database encoding
execute "create-database" do
  command "createdb -U postgres -O db_user db_name -E 'utf8'"
end