【導讀】html
puppet在運維管理是個自動化的工具,做用很是明顯,可是苦於puppet 中文資料很少,puppet學習難度node
大,在puppet使用過程當中,碰到不少各類奇怪的問題,這裏是 sky的我的總結的一些puppet常見錯誤,以mysql
及相應的解決方法,也感謝部分羣友的分享:堅持創新和Ninjaweb
以及再一年等QQ好友,也但願更多的人分享puppet知識,共同進步。sql
【puppet 常見錯誤列表】shell
1.Failed to retrieve current state of resource: Could not retrieve information from source(s)數據庫
err: //test/File[/tmp/sky]: Failed to retrieve current state of resource: Could not retrieve information from source(s) puppet:///test/foo at /etc/puppet/modules/test/manifests/init.pp:6
ubuntu
解決方法:這是通常大多人犯的問題,這個問題通常是出如今puppetmaster上,大部分是source這個路徑沒有寫對。能夠查看init.pp的第6行,ruby
通常正確的寫法是source => 「puppet:///test/sky」,關於文件服務器的寫法,能夠參閱以前的sky的文檔.服務器
2.Could not retrieve information from environment production source(s) puppet://server.puppet.com/plugins
解決方法:這是通常都是經過yum或者apt-get安裝了puppet,在puppetmaster和客戶端的配置文件 裏有pluginsync=true ,
把兩端/etc/puppet.conf裏pluginsync=true ,改爲pluginsync=false,並重啓puppetmaster便可解決。
再補充一種方法,若是不設置pluginsync=false,那麼就須要到少要建個插件。
3.Could not request certificate: undefined method `closed?’
err: Could not request certificate: undefined method `closed?' for nil:NilClass Exiting;
failed to retrieve certificate and watiforcert is disabled
解決方法:a.確保puppet的運行用戶是否有權限讀ssl認證文件。
b.確認防火牆是否打開8140端口。
4.Change from absent to file failed
err: //test/File[/tmp/sky/www.mysqlops.com]/ensure: change from absent to file failed: Could not set file on ensure: No such file or directory
解決方法:很明顯,多是沒有/tmp/sky這個目錄,若是沒有,請使用 mkdir -p /tmp/sky.
5.Run of Puppet configuration client already in progress
解決方法,很明顯,a.能夠經過ps -axf|grep puppet是否有puppet進程在運行。若是有,則停掉puppet,再運行,便可。
b.沒有進程,那有可能puppetdlock存在,則刪除之,使用 rm -rf /var/puppet/state/puppetdlock
6.Change failed ... Could not find server
err: //test/File[/tmp/sky]/content: change from {md5}068008008418dff20750a94336318974 to {md5}8db2d67767577c70b1251fd80ad32943 failed: Could not find server puppet
解決方法:這是設置了filebucket, 名稱爲puppet,但並不沒有使用真名。在配置文件/etc/puppet.conf裏設置以下:
filebucket { puppetmaster: server => "www.mysqlops.com" # server後面要用全名,即fqdn. }
7.
err: Could not retrieve catalog: can't convert nil into String at /etc/puppet/modules/test/manifests/init.pp:29 on node web-01.test.com
解決方法:確認模板文件是否存在。通常都是文件不存在的時候報的。
8.undefined method `closed?’ for nil:NilClass
err: Could not retrieve catalog from remote server: undefined method `closed?' for nil:NilClas
解決方法:常常多是語法錯誤,少了雙引號或者 大概號什麼的。
9.certificate verify failed
err: /File[/var/lib/puppet/lib]: Failed to generate additional resources using 'eval_generate': SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed
err: /File[/var/lib/puppet/lib]: Failed to retrieve current state of resource: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed Could not retrieve file metadata for puppet://puppet.example.com/plugins: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed
err: Could not retrieve catalog from remote server: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed
解決方法:這多是換了不一樣的兩臺puppetmaster服務器引發的。解決方法,刪除現有ssl證書。find /var/lib/puppet -type f -print0 |xargs -0r rm
10.Could not retrieve catalog from remote server
err: Could not retrieve catalog from remote server: No such file or directory - /var/lib/puppet/client_yaml/catalog
解決方法:明顯提示,/var/lib/puppet/client_yaml/可能不存在,沒有則建立之。
11.no certificate found and waitforcert is disabled
warning: peer certificate won’t be verified in this SSL session
Exiting; no certificate found and waitforcert is disabled
解決方法: 這個是須要puppetmaster端給客戶端ssl簽名.
a.puppetca -l #列出等待簽名的客戶端
b.puppetca -s hostname # hostname 是客戶端主機的名字。
12.Could not intern from pson: Could not convert from pson: Could not find relationship target 」
解決方法:這是一個bug, 針對版本0.25.1.在puppet0.25.5.1版本中能夠在/etc/puppet/puppet.conf裏添加
preferred_serialization_format = yaml 便可解決。
13.Error 400 on SERVER: No support for http method POST
err: Could not retrieve catalog from remote server: Error 400 on SERVER: No support for http method POST
解決方法:這個問題多是puppetmaster是2.6版本,puppet客戶端版本是2.7。請記住 ,puppetmaster版本能夠大於或者等於客戶端的版本。
不能小於,互換下puppet角色,便可。
14.You cannot specify more than one of content, source, target
err: Could not run Puppet configuration client: You cannot specify more than one of content, source, target at /etc/puppet/modules/test/manifests/init.pp:10
解決方法:錯誤提示很顯示,不能爲一個文件指定多個來源。
15.Could not retrieve catalog from remote server: wrong header line format
解決方法,多是模板語法錯誤,請使用命令檢查模板語法,示例:erb -x -T ‘-’ -P test/templates/cron/cron.erb |ruby -c
16.Cannot override local resource on node
err: Could not retrieve catalog from remote server: Error 400 on SERVER: Exported resource skyd[foo] cannot override local resource on node web-01.mysqlops.com
解決方法:這個問題,通常是在使用export 虛擬資源的時候會出現,多是有重複的定義。
這多是因爲舊節點,運行puppet clean node。查看數據庫。使用下面的sql
「select hosts.name from hosts,resources where restype=’skyd’ and title=’foo’ and hosts.id = resources.host_id;」
17.Could not render to pson: invalid utf8 byte
err: Could not retrieve catalog from remote server: Error 400 on SERVER: Could not render to pson: invalid utf8 byte:
解決方法:多是有無效的utf8字符,能夠使用命令:od -c filename 進行檢查。
18. 在安裝dashboad的時候,報
RAILS_ENV=production db:migrate --trace (in /usr/local/puppet-dashboard) ** Invoke db:migrate (first_time) ** Invoke environment (first_time) ** Execute environment ** Execute db:migrate ** Invoke db:schema:dump (first_time) ** Invoke environment ** Execute db:schema:dump rake aborted! undefined method `reenable' for <Rake::Task db:schema:dump => [environment]>:Rake::Task
解決訪問,多是gem版本不對,升級版本,請確認版本是否知足安裝dashboad的要求。
19.在執行facter命令的時候報:
err: Could not run Puppet configuration client: Could not retrieve local facts: execution expired
解決方法,因爲ubuntu升級致使的ec2.rb有新的改動,能夠修改/usr/lib/ruby/1.8/facter這個目錄下面的ec2.rb文件後重新啓動後解決。 具體解決方法以下:1. cd /usr/lib/ruby/1.8/facter
2. cp ec2.rb{,.`date -I`} #備份新的ec2.rb這個文件
3. 從正常執行的主機複製ec2.rb這個文件進行覆蓋。或者比較兩個文件的不一樣,進行修改。
20.在使用gem 安裝的時候會報:
ERROR: Could not find a valid gem 'rake' (>= 0) in any repository ERROR: While executing gem ... (Gem::RemoteFetcher::FetchError)
解決方法:多是沒有gem源,或者沒法訪問源,大部分是網絡問題。
能夠多添加下幾個gem 源來嘗試解決:
使用命令:
1
2
3
4
|
gem sources -a http:
//gems
.rubyforge.org
gem sources -a http:
//gems
.rubyonrails.org
gem sources -a http:
//gemcutter
.org
gem sources -a http:
//rubygems
.org
|
添加了上面的四個gem源,但願能解決,另外使用gem 安裝的過程比較慢,須要你們耐心點等待提示。
【總結】
puppet在安裝與配置過程當中,常常會遇到上面的問題,列出一些常見puppet錯誤,以供後面的同窗參考,感謝部分QQ 朋友的分享