【问题标题】:How do I change php and mysql settings for custom vagrant box如何更改自定义 vagrant 框的 php 和 mysql 设置
【发布时间】:2014-06-19 22:48:15
【问题描述】:

我使用this vagrant box 在本地电脑上为magento 开发。 Magento 工作太慢,我必须调整设置。没有太多关于如何更改 php 和 mysql 设置的文档。另外,我在主题方面非常初学者。

我是使用 ssh 编辑服务器内部的设置,还是更改说明书然后进行 vagrant provision 或重新加载?如果我在服务器内部进行编辑,我可以做 vagrant provision 吗?它会覆盖我在服务器中更改的设置吗?

对于 mysql 设置,我将 this 文件更改为我的需要,但是当我在 vagrant halt 之后执行 vagrant up --provision 时出现此错误:(mysql 未启动)

=> default: ================================================================================
=> default: Error executing action `restart` on resource 'service[mysql]'
=> default: ================================================================================
=> default:
=> default: Chef::Exceptions::Exec
=> default: ----------------------
=> default: /sbin/restart mysql returned 1, expected 0
=> default:
=> default: Resource Declaration:
=> default: ---------------------
=> default: # In /tmp/vagrant-chef-3/chef-solo-1/cookbooks/mysql/recipes/server.rb
=> default:
=> default: 217:
=> default: 218:   service "mysql" do
=> default: 219:     action :start
=> default: 220:   end
=> default: 221: end
=> default:
=> default: Compiled Resource:
=> default: ------------------
=> default: # Declared in /tmp/vagrant-chef-3/chef-solo-1/cookbooks/mysql/recipes/server.rb:218:in `from_file'
=> default:
=> default: service("mysql") do
=> default:   service_name "mysql"
=> default:   retry_delay 2
=> default:   retries 0
=> default:   recipe_name "server"
=> default:   pattern "mysql"
=> default:   action [:start]
=> default:   cookbook_name :mysql
=> default:   startup_type :automatic
=> default:   supports {:status=>true, :restart=>true, :reload=>true}
=> default:   provider Chef::Provider::Service::Upstart
=> default: end
=> default:
=> default: [2014-06-19T12:28:59+00:00] ERROR: Running exception handlers
=> default: [2014-06-19T12:28:59+00:00] ERROR: Exception handlers complete
=> default: [2014-06-19T12:28:59+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
=> default: [2014-06-19T12:28:59+00:00] FATAL: Chef::Exceptions::Exec: service[mysql] (mysql::server line 218) had an e
ror: Chef::Exceptions::Exec: /sbin/restart mysql returned 1, expected 0

这些是我更改的设置

innodb_thread_concurrency = 2 * [numberofCPUs] + 2 
innodb_flush_log_at_trx_commit = 2 
thread_concurrency = [number of CPUs] * 3 
thread_cache_size = 32 
table_cache = 1024 
query_cache_size = 64M 
query_cache_limit = 2M 
join_buffer_size = 8M 
tmp_table_size = 256M 
key_buffer = 32M 
innodb_autoextend_increment=512 
max_allowed_packet = 16M 
max_heap_table_size = 256M 
read_buffer_size = 2M 
read_rnd_buffer_size = 16M 
bulk_insert_buffer_size = 64M 
myisam_sort_buffer_size = 128M 
myisam_max_sort_file_size = 10G 
myisam_max_extra_sort_file_size = 10G 
myisam_repair_threads = 1

【问题讨论】:

    标签: mysql linux ubuntu vagrant chef-recipe


    【解决方案1】:

    对于 ssh 访问,使用命令:

    vagrant ssh
    

    http://docs.vagrantup.com/v2/cli/ssh.html

    覆盖食谱的属性是最好的选择,将其添加到 vagrantfile

    >   config.vm.provision: chef_solo do | chef |
    >      chef.cookbooks_path = "cookbooks"
    >      chef.data_bags_path = "data_bags"
    >      chef.json = {
    >         "mysql" => {
    >            "tunable" => {
    >              "myisam_sort_buffer_size" => "32M"
    >           }
    >         },
              "php" => {
               "more attributes" => "value"
              }
    >      }
    >      # List of recipes to run
    >      chef.add_recipe "vagrant_main"
    >      chef.add_recipe "vagrant_main :: wordpress"
    >      chef.add_recipe "vagrant_main :: drupal"
    >      chef.add_recipe "vagrant_main :: magento"
    >      chef.add_recipe "vagrant_main :: nodejs"    end
    >         end end
    

    阅读说明书的文档 (README.md) 以确定要覆盖的属性

    流浪文档:

    http://docs.vagrantup.com/v2/provisioning/chef_solo.html

    对不起我的英语

    最好的问候

    【讨论】:

    • 谢谢,但这是一个自定义的 vagrant box,他在其他地方定义了这些设置。我找不到那个文件。谢谢。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-09-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多