1

我正在学习vagrantpuppet。当我使用 vagrant lucid32 (Ubuntu 10.04) 时,puppet 似乎很慢。我已经修复了 fqdn 问题(问题 7780322),但它仍然很慢。

我已经将问题(部分)追溯到因素。请求 ipaddress 非常快,但 ipaddress_eth0 需要 20 秒:

root@a:/# time facter ipaddress
10.0.2.15

real    0m0.031s
user    0m0.024s
sys     0m0.004s
root@a:/# time facter ipaddress_eth0
10.0.2.15

real    0m20.126s
user    0m0.080s
sys     0m0.020s
root@a:/# 

寻找 ipaddress_lo 也很慢。

任何人都可以帮助我提供解决方案或有关如何调试的建议吗?我是 Ruby 新手,但愿意学习。

谢谢。

4

2 回答 2

1

我刚刚在 /etc/hosts 中定义了未知主机(?):

10.0.2.3 电脑1
10.0.2.2 电脑2

在此之后,arp -a 非常快,因此提高了 facter -p 的响应,进而提高了 puppet agent --test 的性能

于 2013-01-01T18:21:10.110 回答
0

问题是arp -a运行非常缓慢。

vagrant@lucid32:~$ 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
vagrant@lucid32:~$

我认为这是 virtualbox (4.1.12_77245)、仅主机网络、ubuntu 10.04 和 windows 7 主机操作系统的某种组合的问题。

作为一种解决方法,假设我可以在不知道我的 mac 地址的情况下了解 puppet 的一些知识,我将第 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
于 2012-04-13T12:09:28.403 回答