【发布时间】:2016-04-24 02:48:21
【问题描述】:
我正在使用 vagrant 和 chef 构建一个 VM。
主机:OSX 10.9.5
奥黛丽:ubuntu2 jluc$ 厨师 -v
Chef 开发工具包版本:0.10.0
厨师客户端版本:12.5.1
伯克斯版本:4.0.1
厨房版:1.4.2
audrey:ubuntu2 jluc$ vagrant -v
流浪者 1.8.1
audrey:ubuntu2 jluc$ vagrant 插件列表
vagrant-berkshelf (4.1.0)
vagrant-omnibus (1.4.1)
vagrant-share (1.1.5, 系统)
Virtualbox:5,但之前的 4 相同。
来宾:Ubuntu 14.04
背景:我正在使用 alien 来安装 Oracle rpm。但是,您不能只将客户端指向某个地方的 url 或包,您需要从 Oracle 下载 rpm,接受条件,然后将文件提供给客户端安装。有2个rpm,一个30MB,一个640KB。
我通过在主机上的端口 9003 上启动 http 服务器来做到这一点。
问题:
在主厨运行中的下载/远程文件时间为 5-20 分钟,而我可以在 5-15 秒内从访客中获取/卷曲它们强>。
详情:
以下厨师代码处理这些文件:
ip = node[:network][:default_gateway]
simplehttp_port=node[:basedjango][:port_host_fileserver]
fn_basic = "oracle-instantclient12.1-basiclite-12.1.0.2.0-1.x86_64.rpm"
execute 'download_basic' do
cwd "/tmp"
command "wget http://#{ip}:#{simplehttp_port}/#{fn_basic} "
not_if do ::File.exists?(fnp_basic) end
end
#I have also used this instead, just as slow...
remote_file fnp_basic do
uri = "http://#{ip}:#{simplehttp_port}/#{fn_basic}"
not_if do ::File.exists?(fnp_basic) end
mode '0755'
action :create
end
我的问题是我可以在 5 到 15 秒内将 vagrant ssh 放入来宾并 wget 或 curl 文件。从厨师食谱看,我每次看 5-20 分钟(有条件保护避免下载它,如果它存在)。
==> default: [2016-01-18T11:13:58-08:00] INFO: file[/etc/profile.d/ORACLE_HOME.sh] mode changed to 755
==> default:
==> default: - change mode from '' to '0755'
==> default:
==> default: - change owner from '' to 'root'
==> default:
==> default: - change group from '' to 'root'
==> default:
==> default: (up to date)
==> default: Recipe: basedjango::oracle
==> default:
==> default: * execute[download_basic] action run
!!! 11:13 到 11:28 => 15 分钟。
==> default: [2016-01-18T11:28:04-08:00] INFO:
execute[download_basic] ran successfully
==> default:
==> default: - execute wget http://10.0.2.2:9003/oracle-instantclient12.1-basiclite-12.1.0.2.0-1.x86_64.rpm
==> default: * execute[install_basic] action run
这是相同的命令,通过 vagrant ssh 手动执行。在这种情况下大约需要 2 秒。
vagrant@vagrant:/tmp$ wget http://10.0.2.2:9003/oracle-instantclient12.1-basiclite-12.1.0.2.0-1.x86_64.rpm
--2016-01-18 11:50:40-- http://10.0.2.2:9003/oracle-instantclient12.1-basiclite-12.1.0.2.0-1.x86_64.rpm
Connecting to 10.0.2.2:9003... connected.
HTTP request sent, awaiting response... 200 OK
Length: 30940809 (30M) [text/html]
Saving to: ‘oracle-instantclient12.1-basiclite-12.1.0.2.0-1.x86_64.rpm’
100%[====================================================================================================================================================================================>] 30,940,809 17.8MB/s in 1.7s
2016-01-18 11:50:41 (17.8 MB/s) - ‘oracle-instantclient12.1-basiclite-12.1.0.2.0-1.x86_64.rpm’ saved [30940809/30940809]
remote_file 资源的行为方式相同,所以起初我认为它或我使用它的方式有问题。 rpm 不是从 Vagrant 共享目录提供的,顺便说一句。
有什么想法吗?
【问题讨论】:
-
您是否尝试过将它们存储在说明书中并使用说明书文件?在大多数情况下不是一个很好的解决方案,但在这里可能会更快。
-
不,我没有。我也可以将它们留在 vagrant 共享目录中并以这种方式访问它们。但我真的很好奇为什么一开始抓取这些文件需要这么长时间。
-
如果我不得不猜测,他们可能在主机和来宾之间通过不同的虚拟网络设备进行路由。
-
您的意思是,guest 下载将在 chef 执行上下文中使用不同的虚拟设备,而不是在 bash shell 中?当然,对于 真正 远程文件,例如当 apt-get 获取包时,Chef 中的文件下载/访问时间是完全可以接受的。只有我的主机文件最终成为一场灾难。
-
你说的有道理,但我该如何检查/控制上述内容?
标签: download vagrant chef-infra fileserver