配置一个 vagrant box 需要多次尝试
Provisioning a vagrant box takes multiple tries
"Insanity: doing the same thing over and over again and expecting
different results." - Albert Einstein
我有一个 vagrant + chef (w/chef-zero Berkshelf) 构建的盒子,其中 运行 有很多程序,包括 zend-server-php、mongos 和 erlang。我使用的是流行的食谱,由 Berkshelf 管理,还有一个基本的 CentOS 6 盒子(存储在我的本地 Mac 上)。第一次(在 vagrant destroy
之后)启动这个盒子通常需要多次尝试。 vagrant up
将在上面列出的其中一个程序上失败,我将不得不一遍又一遍地 运行 vagrant provision
(有时多达 6 次)来完成整个构建没有错误。然而,在极少数情况下,星星对齐,第一次尝试一切都会点燃。
我看到的错误通常是明确的超时错误(尽管并非总是如此)。我通常 运行 从一个相当弱的办公室网络连接(<20 Mbps 下降)进行此操作,这可能解释了为什么在最大下载量时发生故障。
所以这是我的问题:首先,除了网络连接之外是否还有其他变量在起作用,这可以解释为什么我必须多次 vagrant provision
?如果是这样,我该如何检测和治疗?其次,有没有办法让 vagrant 保持供应直到成功?我还没有找到这样做的记录 flag/setting,但感觉可能会有一个...
感谢您的帮助。
更新:
这是一个 zend-server-php-5.4 失败的例子:
==> mongos-zend: Running triggers before provision...
the ffi-yajl and yajl-ruby gems have incompatible C libyajl libs and should not be loaded in the same Ruby VM
falling back to ffi which might work (or might not, no promises)
Loading cookbooks from chef-repo/cookbooks
Uploading Cookbook apt
Uploading Cookbook build-essential
Uploading Cookbook cb-platform
Uploading Cookbook chef-sugar
Uploading Cookbook erlang
Uploading Cookbook hostsfile
Uploading Cookbook mongodb
Uploading Cookbook mysql
Uploading Cookbook openssl
Uploading Cookbook percona
Uploading Cookbook postgresql
Uploading Cookbook python
Uploading Cookbook rabbitmq
Uploading Cookbook rbac
Uploading Cookbook resource-control
Uploading Cookbook role-mongodb-configserver
Uploading Cookbook role-mongodb-mongos
Uploading Cookbook role-mongodb-replicaset1
Uploading Cookbook role-mongodb-replicaset2
Uploading Cookbook role-mongodb-shard1
Uploading Cookbook role-mongodb-shard2
Uploading Cookbook role-rabbitmq
Uploading Cookbook role-sphinx
Uploading Cookbook role-twemcache
Uploading Cookbook role-zendserver
Uploading Cookbook runit
Uploading Cookbook smf
Uploading Cookbook sphinx
Uploading Cookbook yum
Uploading Cookbook yum-epel
Uploading Cookbook yum-erlang_solutions
Uploading Cookbook yum-mysql-community
Uploading Cookbook zendserver
==> mongos-zend: Chef 12.0.3 Omnibus package is already installed.
==> mongos-zend: Running provisioner: shell...
mongos-zend: Running: inline script
==> mongos-zend: Running provisioner: chef_client...
==> mongos-zend: Creating folder to hold client key...
==> mongos-zend: Uploading chef client validation key...
Generating chef JSON and uploading...
==> mongos-zend: Running chef-client...
==> mongos-zend: [2015-01-20T10:46:10-06:00] INFO: Forking chef instance to converge...
==> mongos-zend: [2015-01-20T10:46:10-06:00] INFO: *** Chef 11.10.4 ***
==> mongos-zend: [2015-01-20T10:46:10-06:00] INFO: Chef-client pid: 13175
==> mongos-zend: [2015-01-20T10:46:11-06:00] INFO: Setting the run_list to ["recipe[role-mongodb-mongos::default]", "recipe[role-zendserver::default]", "recipe[role-rabbitmq::default]", "recipe[role-twemcache::default]", "recipe[role-sphinx::default]", "recipe[cb-platform::default]"] from JSON
==> mongos-zend: [2015-01-20T10:46:11-06:00] INFO: Run List is [recipe[role-mongodb-mongos::default], recipe[role-zendserver::default], recipe[role-rabbitmq::default], recipe[role-twemcache::default], recipe[role-sphinx::default], recipe[cb-platform::default]]
==> mongos-zend: [2015-01-20T10:46:11-06:00] INFO: Run List expands to [role-mongodb-mongos::default, role-zendserver::default, role-rabbitmq::default, role-twemcache::default, role-sphinx::default, cb-platform::default]
==> mongos-zend: [2015-01-20T10:46:11-06:00] INFO: Starting Chef Run for mongos-zend
==> mongos-zend: [2015-01-20T10:46:11-06:00] INFO: Running start handlers
==> mongos-zend: [2015-01-20T10:46:11-06:00] INFO: Start handlers complete.
==> mongos-zend: [2015-01-20T10:46:11-06:00] INFO: HTTP Request Returned 404 Not Found : Object not found: /reports/nodes/mongos-zend/runs
==> mongos-zend: [2015-01-20T10:46:11-06:00] INFO: Loading cookbooks [apt, build-essential, cb-platform, chef-sugar, erlang, hostsfile, mongodb, mysql, openssl, percona, postgresql, python, rabbitmq, rbac, role-mongodb-mongos, role-rabbitmq, role-sphinx, role-twemcache, role-zendserver, runit, smf, sphinx, yum, yum-epel, yum-erlang_solutions, yum-mysql-community, zendserver]
==> mongos-zend: [2015-01-20T10:46:11-06:00] WARN: CentOS doesn't provide mongodb, forcing use of mongodb-org repo
==> mongos-zend: [2015-01-20T10:46:11-06:00] WARN: 10gen_repo is deprecated, use mongodb_org_repo
==> mongos-zend: [2015-01-20T10:46:11-06:00] WARN: Cloning resource attributes for package[mongo-10gen-server] from prior resource (CHEF-3694)
==> mongos-zend: [2015-01-20T10:46:11-06:00] WARN: Previous package[mongo-10gen-server]: /var/chef/cache/cookbooks/role-mongodb-mongos/recipes/default.rb:15:in `block in from_file'
==> mongos-zend: [2015-01-20T10:46:11-06:00] WARN: Current package[mongo-10gen-server]: /var/chef/cache/cookbooks/mongodb/recipes/install.rb:65:in `from_file'
==> mongos-zend: [2015-01-20T10:46:13-06:00] WARN: Cloning resource attributes for template[/etc/mongodb.conf] from prior resource (CHEF-3694)
==> mongos-zend: [2015-01-20T10:46:13-06:00] WARN: Previous template[/etc/mongodb.conf]: /var/chef/cache/cookbooks/mongodb/recipes/install.rb:14:in `from_file'
==> mongos-zend: [2015-01-20T10:46:13-06:00] WARN: Current template[/etc/mongodb.conf]: /var/chef/cache/cookbooks/mongodb/definitions/mongodb.rb:139:in `block in from_file'
==> mongos-zend: [2015-01-20T10:46:13-06:00] WARN: Cloning resource attributes for package[gcc] from prior resource (CHEF-3694)
==> mongos-zend: [2015-01-20T10:46:13-06:00] WARN: Previous package[gcc]: /var/chef/cache/cookbooks/mongodb/recipes/mongo_gem.rb:3:in `from_file'
==> mongos-zend: [2015-01-20T10:46:13-06:00] WARN: Current package[gcc]: /var/chef/cache/cookbooks/role-zendserver/recipes/default.rb:34:in `block in from_file'
==> mongos-zend: [2015-01-20T10:46:14-06:00] INFO: hostsfile_entry[33.33.33.42] content already matches - nothing to do.
==> mongos-zend: [2015-01-20T10:46:14-06:00] INFO: hostsfile_entry[33.33.33.43] content already matches - nothing to do.
==> mongos-zend: [2015-01-20T10:46:14-06:00] INFO: Starting install for package zend-server-php-5.4
==> mongos-zend: [2015-01-20T10:30:22-06:00] INFO: package[zend-server-php-5.4] installing zend-server-php-5.4-6.2.0-2002 from zend-server repository
==> mongos-zend:
==> mongos-zend: ================================================================================
==> mongos-zend: Error executing action `install` on resource 'package[zend-server-php-5.4]'
==> mongos-zend: ================================================================================
==> mongos-zend:
==> mongos-zend:
==> mongos-zend: Chef::Exceptions::Exec
==> mongos-zend:
==> mongos-zend: ----------------------
==> mongos-zend: returned 1, expected 0
==> mongos-zend:
==> mongos-zend:
==> mongos-zend: Resource Declaration:
==> mongos-zend: ---------------------
==> mongos-zend: # In /var/chef/cache/cookbooks/zendserver/recipes/default.rb
==> mongos-zend:
==> mongos-zend: 65: package package_name do
==> mongos-zend: 66: :install
==> mongos-zend: 67: notifies :restart, 'service[zend-server]', :immediate
==> mongos-zend: 68: end
==> mongos-zend: 69:
==> mongos-zend:
==> mongos-zend:
==> mongos-zend:
==> mongos-zend: Compiled Resource:
==> mongos-zend: ------------------
==> mongos-zend: # Declared in /var/chef/cache/cookbooks/zendserver/recipes/default.rb:65:in `from_file'
==> mongos-zend:
==> mongos-zend: package("zend-server-php-5.4") do
==> mongos-zend: action :install
==> mongos-zend: retries 0
==> mongos-zend: retry_delay 2
==> mongos-zend: package_name "zend-server-php-5.4"
==> mongos-zend: version "6.2.0-2002"
==> mongos-zend: cookbook_name "zendserver"
==> mongos-zend: recipe_name "default"
==> mongos-zend: end
带宽,CPU,I/O,BUG,所有加起来都会增加资源收敛时间,导致超时。尝试增加 VM 的资源(CPU、RAM),如果可能的话在主机上使用 SSD 等
至于 运行 vagrant provision
直到它成功,你可能只是将它包装在一个 while 循环中:
false; while [ "$?" -ne "0" ]; do vagrant provision; done
"Insanity: doing the same thing over and over again and expecting different results." - Albert Einstein
我有一个 vagrant + chef (w/chef-zero Berkshelf) 构建的盒子,其中 运行 有很多程序,包括 zend-server-php、mongos 和 erlang。我使用的是流行的食谱,由 Berkshelf 管理,还有一个基本的 CentOS 6 盒子(存储在我的本地 Mac 上)。第一次(在 vagrant destroy
之后)启动这个盒子通常需要多次尝试。 vagrant up
将在上面列出的其中一个程序上失败,我将不得不一遍又一遍地 运行 vagrant provision
(有时多达 6 次)来完成整个构建没有错误。然而,在极少数情况下,星星对齐,第一次尝试一切都会点燃。
我看到的错误通常是明确的超时错误(尽管并非总是如此)。我通常 运行 从一个相当弱的办公室网络连接(<20 Mbps 下降)进行此操作,这可能解释了为什么在最大下载量时发生故障。
所以这是我的问题:首先,除了网络连接之外是否还有其他变量在起作用,这可以解释为什么我必须多次 vagrant provision
?如果是这样,我该如何检测和治疗?其次,有没有办法让 vagrant 保持供应直到成功?我还没有找到这样做的记录 flag/setting,但感觉可能会有一个...
感谢您的帮助。
更新:
这是一个 zend-server-php-5.4 失败的例子:
==> mongos-zend: Running triggers before provision...
the ffi-yajl and yajl-ruby gems have incompatible C libyajl libs and should not be loaded in the same Ruby VM
falling back to ffi which might work (or might not, no promises)
Loading cookbooks from chef-repo/cookbooks
Uploading Cookbook apt
Uploading Cookbook build-essential
Uploading Cookbook cb-platform
Uploading Cookbook chef-sugar
Uploading Cookbook erlang
Uploading Cookbook hostsfile
Uploading Cookbook mongodb
Uploading Cookbook mysql
Uploading Cookbook openssl
Uploading Cookbook percona
Uploading Cookbook postgresql
Uploading Cookbook python
Uploading Cookbook rabbitmq
Uploading Cookbook rbac
Uploading Cookbook resource-control
Uploading Cookbook role-mongodb-configserver
Uploading Cookbook role-mongodb-mongos
Uploading Cookbook role-mongodb-replicaset1
Uploading Cookbook role-mongodb-replicaset2
Uploading Cookbook role-mongodb-shard1
Uploading Cookbook role-mongodb-shard2
Uploading Cookbook role-rabbitmq
Uploading Cookbook role-sphinx
Uploading Cookbook role-twemcache
Uploading Cookbook role-zendserver
Uploading Cookbook runit
Uploading Cookbook smf
Uploading Cookbook sphinx
Uploading Cookbook yum
Uploading Cookbook yum-epel
Uploading Cookbook yum-erlang_solutions
Uploading Cookbook yum-mysql-community
Uploading Cookbook zendserver
==> mongos-zend: Chef 12.0.3 Omnibus package is already installed.
==> mongos-zend: Running provisioner: shell...
mongos-zend: Running: inline script
==> mongos-zend: Running provisioner: chef_client...
==> mongos-zend: Creating folder to hold client key...
==> mongos-zend: Uploading chef client validation key...
Generating chef JSON and uploading...
==> mongos-zend: Running chef-client...
==> mongos-zend: [2015-01-20T10:46:10-06:00] INFO: Forking chef instance to converge...
==> mongos-zend: [2015-01-20T10:46:10-06:00] INFO: *** Chef 11.10.4 ***
==> mongos-zend: [2015-01-20T10:46:10-06:00] INFO: Chef-client pid: 13175
==> mongos-zend: [2015-01-20T10:46:11-06:00] INFO: Setting the run_list to ["recipe[role-mongodb-mongos::default]", "recipe[role-zendserver::default]", "recipe[role-rabbitmq::default]", "recipe[role-twemcache::default]", "recipe[role-sphinx::default]", "recipe[cb-platform::default]"] from JSON
==> mongos-zend: [2015-01-20T10:46:11-06:00] INFO: Run List is [recipe[role-mongodb-mongos::default], recipe[role-zendserver::default], recipe[role-rabbitmq::default], recipe[role-twemcache::default], recipe[role-sphinx::default], recipe[cb-platform::default]]
==> mongos-zend: [2015-01-20T10:46:11-06:00] INFO: Run List expands to [role-mongodb-mongos::default, role-zendserver::default, role-rabbitmq::default, role-twemcache::default, role-sphinx::default, cb-platform::default]
==> mongos-zend: [2015-01-20T10:46:11-06:00] INFO: Starting Chef Run for mongos-zend
==> mongos-zend: [2015-01-20T10:46:11-06:00] INFO: Running start handlers
==> mongos-zend: [2015-01-20T10:46:11-06:00] INFO: Start handlers complete.
==> mongos-zend: [2015-01-20T10:46:11-06:00] INFO: HTTP Request Returned 404 Not Found : Object not found: /reports/nodes/mongos-zend/runs
==> mongos-zend: [2015-01-20T10:46:11-06:00] INFO: Loading cookbooks [apt, build-essential, cb-platform, chef-sugar, erlang, hostsfile, mongodb, mysql, openssl, percona, postgresql, python, rabbitmq, rbac, role-mongodb-mongos, role-rabbitmq, role-sphinx, role-twemcache, role-zendserver, runit, smf, sphinx, yum, yum-epel, yum-erlang_solutions, yum-mysql-community, zendserver]
==> mongos-zend: [2015-01-20T10:46:11-06:00] WARN: CentOS doesn't provide mongodb, forcing use of mongodb-org repo
==> mongos-zend: [2015-01-20T10:46:11-06:00] WARN: 10gen_repo is deprecated, use mongodb_org_repo
==> mongos-zend: [2015-01-20T10:46:11-06:00] WARN: Cloning resource attributes for package[mongo-10gen-server] from prior resource (CHEF-3694)
==> mongos-zend: [2015-01-20T10:46:11-06:00] WARN: Previous package[mongo-10gen-server]: /var/chef/cache/cookbooks/role-mongodb-mongos/recipes/default.rb:15:in `block in from_file'
==> mongos-zend: [2015-01-20T10:46:11-06:00] WARN: Current package[mongo-10gen-server]: /var/chef/cache/cookbooks/mongodb/recipes/install.rb:65:in `from_file'
==> mongos-zend: [2015-01-20T10:46:13-06:00] WARN: Cloning resource attributes for template[/etc/mongodb.conf] from prior resource (CHEF-3694)
==> mongos-zend: [2015-01-20T10:46:13-06:00] WARN: Previous template[/etc/mongodb.conf]: /var/chef/cache/cookbooks/mongodb/recipes/install.rb:14:in `from_file'
==> mongos-zend: [2015-01-20T10:46:13-06:00] WARN: Current template[/etc/mongodb.conf]: /var/chef/cache/cookbooks/mongodb/definitions/mongodb.rb:139:in `block in from_file'
==> mongos-zend: [2015-01-20T10:46:13-06:00] WARN: Cloning resource attributes for package[gcc] from prior resource (CHEF-3694)
==> mongos-zend: [2015-01-20T10:46:13-06:00] WARN: Previous package[gcc]: /var/chef/cache/cookbooks/mongodb/recipes/mongo_gem.rb:3:in `from_file'
==> mongos-zend: [2015-01-20T10:46:13-06:00] WARN: Current package[gcc]: /var/chef/cache/cookbooks/role-zendserver/recipes/default.rb:34:in `block in from_file'
==> mongos-zend: [2015-01-20T10:46:14-06:00] INFO: hostsfile_entry[33.33.33.42] content already matches - nothing to do.
==> mongos-zend: [2015-01-20T10:46:14-06:00] INFO: hostsfile_entry[33.33.33.43] content already matches - nothing to do.
==> mongos-zend: [2015-01-20T10:46:14-06:00] INFO: Starting install for package zend-server-php-5.4
==> mongos-zend: [2015-01-20T10:30:22-06:00] INFO: package[zend-server-php-5.4] installing zend-server-php-5.4-6.2.0-2002 from zend-server repository
==> mongos-zend:
==> mongos-zend: ================================================================================
==> mongos-zend: Error executing action `install` on resource 'package[zend-server-php-5.4]'
==> mongos-zend: ================================================================================
==> mongos-zend:
==> mongos-zend:
==> mongos-zend: Chef::Exceptions::Exec
==> mongos-zend:
==> mongos-zend: ----------------------
==> mongos-zend: returned 1, expected 0
==> mongos-zend:
==> mongos-zend:
==> mongos-zend: Resource Declaration:
==> mongos-zend: ---------------------
==> mongos-zend: # In /var/chef/cache/cookbooks/zendserver/recipes/default.rb
==> mongos-zend:
==> mongos-zend: 65: package package_name do
==> mongos-zend: 66: :install
==> mongos-zend: 67: notifies :restart, 'service[zend-server]', :immediate
==> mongos-zend: 68: end
==> mongos-zend: 69:
==> mongos-zend:
==> mongos-zend:
==> mongos-zend:
==> mongos-zend: Compiled Resource:
==> mongos-zend: ------------------
==> mongos-zend: # Declared in /var/chef/cache/cookbooks/zendserver/recipes/default.rb:65:in `from_file'
==> mongos-zend:
==> mongos-zend: package("zend-server-php-5.4") do
==> mongos-zend: action :install
==> mongos-zend: retries 0
==> mongos-zend: retry_delay 2
==> mongos-zend: package_name "zend-server-php-5.4"
==> mongos-zend: version "6.2.0-2002"
==> mongos-zend: cookbook_name "zendserver"
==> mongos-zend: recipe_name "default"
==> mongos-zend: end
带宽,CPU,I/O,BUG,所有加起来都会增加资源收敛时间,导致超时。尝试增加 VM 的资源(CPU、RAM),如果可能的话在主机上使用 SSD 等
至于 运行 vagrant provision
直到它成功,你可能只是将它包装在一个 while 循环中:
false; while [ "$?" -ne "0" ]; do vagrant provision; done