我正在学习vagrant和puppet。当我使用漫游的lucid32 (Ubuntu10.04),木偶似乎非常慢。我已经修复了(question 7780322)的fqdn问题,但它仍然非常慢。
我已将问题(部分)追溯到事实。请求is地址非常快,但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的新手,但愿意学习。
谢谢。
发布于 2012-04-13 20:09:28
问题是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)、纯主机网络、ubuntu10.04和windows7主机操作系统的某种组合的问题。
作为一种解决办法,假设我可以在不知道我的mac地址的情况下学习一点关于puppet的知识,我将/opt/ruby/lib/ruby/gems/1.8/gems/facter-1.6.0/lib/facter/arp.rb的第7行替换为:
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
endhttps://stackoverflow.com/questions/10123517
复制相似问题