2012-04-12 28 views
1

我正在學習vagrantpuppet。 當我使用vagrant lucid32(Ubuntu 10.04)時,puppet似乎很慢。 我修復了fqdn問題(question 7780322),但它仍然很慢。木偶因素對一些網絡事實很慢

我已經追溯(部分)問題到facter。要求ipaddress是非常快的,但是ipaddress_eth0需要20秒:

[email protected]:/# time facter ipaddress 
10.0.2.15 

real 0m0.031s 
user 0m0.024s 
sys  0m0.004s 
[email protected]:/# time facter ipaddress_eth0 
10.0.2.15 

real 0m20.126s 
user 0m0.080s 
sys  0m0.020s 
[email protected]:/# 

尋找ipaddress_lo也慢。

任何人都可以幫助我解決方案或建議如何調試?我是Ruby新手,但願意學習。

謝謝。

回答

0

問題是arp -a運行非常緩慢。

[email protected]:~$ time arp -a 
? (10.0.2.3) at 52:54:00:12:35:03 [ether] on eth0 
? (10.0.2.2) at 52:54:00:12:35:02 [ether] on eth0 

real 0m20.022s 
user 0m0.004s 
sys  0m0.000s 
[email protected]:~$ 

我認爲這是在VirtualBox中的某種組合(4.1.12_77245),僅主機網絡的,Ubuntu 10.04和Windows 7主機操作系統的一個問題。

作爲一種變通方法,假設我可以學到一些關於傀儡沒有它知道我的MAC地址,我換過線7 /opt/ruby/lib/ruby/gems/1.8/gems/facter-1.6.0/lib/facter/arp.rb如下:

require 'facter/util/ip' 

Facter.add(:arp) do 
    confine :kernel => :linux 
    setcode do 
    ### output = Facter::Util::Resolution.exec('arp -a') # disable for slow arp 
    output = "" ### return a blank, rather than the real (but slow) arp 
    if not output.nil? 
     arp = "" 
     output.each_line do |s| 
     if s =~ /^\S+\s\S+\s\S+\s(\S+)\s\S+\s\S+\s\S+$/ 
      arp = $1.downcase 
      break # stops on the first match 
     end 
     end 
    end 
    "fe:ff:ff:ff:ff:ff" == arp ? arp : nil 
    end 
end 

Facter::Util::IP.get_interfaces.each do |interface| 
    Facter.add("arp_" + Facter::Util::IP.alphafy(interface)) do 
    confine :kernel => :linux 
    setcode do 
     arp = Facter::Util::IP.get_arp_value(interface) 
     "fe:ff:ff:ff:ff:ff" == arp ? arp : nil 
    end 
    end 
end 
+0

看起來這是名稱查找可能需要很長時間。嘗試將命令更改爲「arp -an」?如果是這樣的話,理想情況下,您應該修復您的DNS解析器以進行反向查找,但也可能需要填寫一個Puppet bug以添加-n。 – 2012-05-14 22:28:35

1

我剛纔定義的未知的主機在(?) /etc/hosts中:

10.0.2.3 computer1 
10.0.2.2 computer2 

在此之後,ARP -a非常快,並因此改善facter -p的響應在匝改善木偶劑的性能--test