[英]Vagrant & Chef - Postgresql not starting on reboot
我決定創建自己的Chef腳本來安裝Postgres。 安裝工作正常,但是我vagrant reload
時postgres不會在啟動時啟動
這是我的食譜/ default.rb:
include_recipe "apt"
apt_repository 'apt.postgresql.org' do
uri 'http://apt.postgresql.org/pub/repos/apt'
distribution node["lsb"]["codename"] + '-pgdg'
components ['main', node["postgres"]["version"]]
key 'http://apt.postgresql.org/pub/repos/apt/ACCC4CF8.asc'
action :add
end
package 'postgresql-' + node["postgres"]["version"] do
action :install
end
file "/etc/postgresql/#{node['postgres']['version']}/main/postgresql.conf" do
action :delete
end
link "/etc/postgresql/#{node['postgres']['version']}/main/postgresql.conf" do
to node["postgres"]["conf_path"]
action :create
notifies :reload, "service[postgresql]", :delayed
end
service "postgresql" do
action [:enable, :start]
supports :status=>true, :restart=>true, :start => true, :stop => true, :reload=>true
end
這是我的attribute / default.rb:
default["postgres"]["version"] = "9.3"
default["postgres"]["conf_path"] = "/home/vagrant/postgres/postgresql.conf"
任何幫助將不勝感激!!
這是第一次使用chef.log_level = :debug
首次運行vagrant up
時的輸出: http chef.log_level = :debug
這里是/etc/init.d/postgresql的: http://pastebin.com/dQ5Zb1yj
這里是/var/log/postgresql/postgresql-9.3-main.log: http://pastebin.com/0Y2RhWvL
我現在非常有信心,這是我的postgresql.conf文件,看起來像: http : //pastebin.com/rjX89iU0
shared_buffers可能太高了...
當您運行vagrant reload
,Chef Client是否正在運行? 我懷疑不是。 Mitchell在最新版本的vagrant中將行為更改為僅在尚未配置計算機的情況下才進行配置。 此信息存儲在工作目錄的.vagrant
目錄中。 簡而言之,由於您已經為您的計算機配置了vagrant up
,因此在運行vagrant reload
時不會進行配置。
vagrant up
vagrant up --provision
這實際上是要運行vagrant up --provision
,它在節點上執行Chef Client vagrant up --provision
,並執行Chef Recipe。 vagrant reload
-實際上這是vagrant up --no-provision
,因為.vagrant.
目錄表明機器已配置。 因此,您的計算機已重新啟動,但是未執行Chef Client預配器。 使用--provision
標志運行vagrant reload
vagrant reload --provision
這仍然不能解釋為什么暴發戶(或用於確保postgres服務在引導時運行的任何措施)沒有自動啟動服務器的原因。 為了回答這個問題,我需要查看更多信息。 您可以設置chef.log_level = :debug
您的Vagrantfile
和更新與輸出你的問題? 查看此postgres安裝程序創建的init.d
腳本以及/var/log
與postgres相關的任何日志輸出也將很有幫助。
好的,看起來Postgresql不能很好地與postgresql.conf用作符號鏈接。 復制文件就可以了。
事實證明postgresql是在安裝postgersql.conf文件之前啟動的
如果要使用Upstart啟動依賴於Vagrant共享文件夾中某些內容的服務,請讓upstart conf文件偵聽由vagrant-mounted
事件。
# /etc/init/start-postgresql.conf
start on vagrant-mounted
script
# commands to start postgresql...
end script
Vagrant完成設置共享文件夾后,將發出vagrant-mounted
事件,這樣,您可以在vagrant reload
后重新啟動相關服務,而無需再次運行vagrant reload
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.