我正在尝试使用Chef 12
在Ubuntu 14.04上设置Mysql server 5.6一切顺利,直到我尝试将data_dir设置为自定义值(它在默认值下工作正常)
[UPDATE_1] 看来数据目录的位置是个问题,如果我将data_dir设置为新安装的分区以外的任何东西,它可以正常工作
例如:
data_dir '/var/data/mysql/master'
工作正常,但挂载分区上的目录不起作用。
请注意,分区已成功安装,并且已成功创建已安装文件系统上的目录。
mount资源定义是否存在问题? mysql配置中是否缺少某些内容?为什么我在该位置创建data_dir时出现错误?
[END_UPDATE_1]
这是我的reciepe的样子:
mysql2_chef_gem 'default' do
client_version node[:application][:mysql_master][:version]
action :install
end
user 'db_manager' do
action :create
end
directory '/mnt/data/mysql' do
owner 'db_manager'
recursive true
action :create
end
mount '/mnt/data/mysql' do
device '/dev/sdb1'
fstype 'ext4'
end
data_directory = "/mnt/data/mysql/master"
directory data_directory do
owner 'db_manager'
recursive true
action :create
end
mysql_service node[:application][:mysql_master][:service_name] do
run_user 'db_manager'
data_dir data_directory
port node[:application][:mysql_master][:bind_port]
version node[:mysql][:version]
initial_root_password node[:application][:mysql_master][:password]
action [:create, :start]
end
我收到以下错误
==> default: ================================================================================
==> default:
==> default: Error executing action `run` on resource 'bash[master :create initial records]'
==> default:
==> default: ================================================================================
==> default:
==> default:
==> default:
==> default:
==> default: Mixlib::ShellOut::ShellCommandFailed
==> default:
==> default: ------------------------------------
==> default:
==> default: Expected process to exit with [0, 1, 2], but received '141'
==> default:
==> default:
==> default: ---- Begin output of "bash" "/tmp/chef-script20160613-7634-ok63tn" ----
==> default:
==> default: STDOUT: Installing MySQL system tables...
==> default: STDERR: 2016-06-13 07:19:29 0 [Note] /usr/sbin/mysqld (mysqld 5.6.30-0ubuntu0.14.04.1) starting as process 19198 ...
==> default: ---- End output of "bash" "/tmp/chef-script20160613-7634-ok63tn" ----
==> default: Ran "bash" "/tmp/chef-script20160613-7634-ok63tn" returned 141
==> default:
==> default: Resource Declaration:
==> default: ---------------------
==> default: # In /tmp/vagrant-chef/d6451ed70ba00b72836a85c4cb3f45a6/cookbooks/mysql/libraries/provider_mysql_service_base.rb
==> default:
==> default: 158: bash "#{new_resource.name} :create initial records" do
==> default: 159: code init_records_script
==> default: 160: umask '022'
==> default: 161: returns [0, 1, 2] # facepalm
==> default: 162: not_if "/usr/bin/test -f #{parsed_data_dir}/mysql/user.frm"
==> default: 163: action :run
==> default: 164: end
==> default: 165: end
==> default:
==> default: Compiled Resource:
==> default: ------------------
==> default: # Declared in /tmp/vagrant-chef/d6451ed70ba00b72836a85c4cb3f45a6/cookbooks/mysql/libraries/provider_mysql_service_base.rb:158:in `block in <class:MysqlServiceBase>'
==> default:
==> default: bash("master :create initial records") do
==> default: action [:run]
==> default: retries 0
==> default: retry_delay 2
==> default: default_guard_interpreter :default
==> default: command "master :create initial records"
==> default: backup 5
==> default: returns [0, 1, 2]
==> default: umask "022"
==> default: code " set -e\n rm -rf /tmp/mysql-master\n mkdir /tmp/mysql-master\n\n cat > /tmp/mysql-master/my.sql <<-EOSQL\nUPDATE mysql.user SET password=PASSWORD('root') WHERE user = 'root';\nDELETE FROM mysql.user WHERE USER LIKE '';\nDELETE FROM mysql.user WHERE user = 'root' and host NOT IN ('127.0.0.1', 'localhost');\nFLUSH PRIVILEGES;\nDELETE FROM mysql.db WHERE db LIKE 'test%';\nDROP DATABASE IF EXISTS test ;\nEOSQL\n\n mysql_install_db --defaults-file=/etc/mysql-master/my.cnf --datadir=/mnt/data/mysql/master --explicit_defaults_for_timestamp\n /usr/sbin/mysqld --defaults-file=/etc/mysql-master/my.cnf --init-file=/tmp/mysql-master/my.sql --explicit_defaults_for_timestamp &\n\n while [ ! -f /run/mysql-master/mysqld.pid ] ; do sleep 1 ; done\n kill `cat /run/mysql-master/mysqld.pid`\n while [ -f /run/mysql-master/mysqld.pid ] ; do sleep 1 ; done\n rm -rf /tmp/mysql-master\n"
==> default: interpreter "bash"
==> default: declared_type :bash
==> default: cookbook_name :tr_mysql
==> default: not_if "/usr/bin/test -f /mnt/data/mysql/master/mysql/user.frm"
==> default: end
==> default:
==> default: Platform:
==> default: ---------
==> default: x86_64-linux
==> default:
==> default: [2016-06-13T07:19:30+00:00] INFO: Running queued delayed notifications before re-raising exception
==> default:
==> default:
==> default:
==> default: ================================================================================
==> default:
==> default: Error executing action `create` on resource 'mysql_service[master]'
==> default:
==> default: ================================================================================
==> default:
==> default:
==> default:
==> default:
==> default: Mixlib::ShellOut::ShellCommandFailed
==> default:
==> default: ------------------------------------
==> default:
==> default: bash[master :create initial records] (/tmp/vagrant-chef/d6451ed70ba00b72836a85c4cb3f45a6/cookbooks/mysql/libraries/provider_mysql_service_base.rb line 158) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0, 1, 2], but received '141'
==> default:
==> default:
==> default: ---- Begin output of "bash" "/tmp/chef-script20160613-7634-ok63tn" ----
==> default:
==> default:
==> default: STDOUT: Installing MySQL system tables...
==> default:
==> default:
==> default: STDERR: 2016-06-13 07:19:29 0 [Note] /usr/sbin/mysqld (mysqld 5.6.30-0ubuntu0.14.04.1) starting as process 19198 ...
==> default:
==> default: ---- End output of "bash" "/tmp/chef-script20160613-7634-ok63tn" ----
==> default: Ran "bash" "/tmp/chef-script20160613-7634-ok63tn" returned 141
==> default:
==> default: Resource Declaration:
==> default: ---------------------
==> default: # In /tmp/vagrant-chef/d6451ed70ba00b72836a85c4cb3f45a6/cookbooks/tr_mysql/recipes/mysql_master.rb
==> default:
==> default: 31: mysql_service node[:application][:mysql_master][:service_name] do
==> default: 32: run_user 'db_manager'
==> default: 33: data_dir data_directory
==> default: 34: port node[:application][:mysql_master][:bind_port]
==> default: 35: version node[:mysql][:version]
==> default: 36: initial_root_password node[:application][:mysql_master][:password]
==> default: 37: action [:create, :start]
==> default: 38: end
==> default: 39:
==> default:
==> default: Compiled Resource:
==> default: ------------------
==> default: # Declared in /tmp/vagrant-chef/d6451ed70ba00b72836a85c4cb3f45a6/cookbooks/tr_mysql/recipes/mysql_master.rb:31:in `from_file'
==> default:
==> default: mysql_service("master") do
==> default: action [:create, :start]
==> default: updated true
==> default: updated_by_last_action true
==> default: retries 0
==> default: retry_delay 2
==> default: default_guard_interpreter :default
==> default: declared_type :mysql_service
==> default: cookbook_name :tr_mysql
==> default: recipe_name "mysql_master"
==> default: run_user "db_manager"
==> default: data_dir "/mnt/data/mysql/master"
==> default: port "3306"
==> default: version "5.6"
==> default: initial_root_password "root"
==> default: instance "master"
==> default: run_group "mysql"
==> default: charset "utf8"
==> default: end
==> default:
==> default: Platform:
==> default: ---------
==> default: x86_64-linux
==> default:
==> default: [2016-06-13T07:19:30+00:00] INFO: Running queued delayed notifications before re-raising exception
==> default: [2016-06-13T07:19:30+00:00] INFO: template[/etc/init.d/chef-client] sending restart action to service[chef-client] (delayed)
==> default: Recipe: chef-client::init_service
==> default: * service[chef-client] action restart
==> default: [2016-06-13T07:19:31+00:00] INFO: service[chef-client] restarted
==> default:
==> default: - restart service service[chef-client]
==> default:
==> default: Running handlers:
==> default: [2016-06-13T07:19:31+00:00] ERROR: Running exception handlers
==> default: Running handlers complete
==> default: [2016-06-13T07:19:31+00:00] ERROR: Exception handlers complete
==> default: Chef Client failed. 68 resources updated in 05 minutes 15 seconds
==> default: [2016-06-13T07:19:31+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
==> default: [2016-06-13T07:19:31+00:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
==> default: [2016-06-13T07:19:31+00:00] ERROR: mysql_service[master] (tr_mysql::mysql_master line 31) had an error: Mixlib::ShellOut::ShellCommandFailed: bash[master :create initial records] (/tmp/vagrant-chef/d6451ed70ba00b72836a85c4cb3f45a6/cookbooks/mysql/libraries/provider_mysql_service_base.rb line 158) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0, 1, 2], but received '141'
==> default: ---- Begin output of "bash" "/tmp/chef-script20160613-7634-ok63tn" ----
==> default: STDOUT: Installing MySQL system tables...
==> default: STDERR: 2016-06-13 07:19:29 0 [Note] /usr/sbin/mysqld (mysqld 5.6.30-0ubuntu0.14.04.1) starting as process 19198 ...
==> default: ---- End output of "bash" "/tmp/chef-script20160613-7634-ok63tn" ----
==> default: Ran "bash" "/tmp/chef-script20160613-7634-ok63tn" returned 141
==> default: [2016-06-13T07:19:31+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
stacktrace文件的内容:/var/chef/cache/chef-stacktrace.out 是以下
Generated at 2016-06-13 07:19:31 +0000
Mixlib::ShellOut::ShellCommandFailed: mysql_service[master] (tr_mysql::mysql_master line 31) had an error: Mixlib::ShellOut::ShellCommandFailed: bash[master :create initial records] (/tmp/vagrant-chef/d6451ed70ba00b72836a85c4cb3f45a6/cookbooks/mysql/libraries/provider_mysql_service_base.rb line 158) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0, 1, 2], but received '141'
---- Begin output of "bash" "/tmp/chef-script20160613-7634-ok63tn" ----
STDOUT: Installing MySQL system tables...
STDERR: 2016-06-13 07:19:29 0 [Note] /usr/sbin/mysqld (mysqld 5.6.30-0ubuntu0.14.04.1) starting as process 19198 ...
---- End output of "bash" "/tmp/chef-script20160613-7634-ok63tn" ----
Ran "bash" "/tmp/chef-script20160613-7634-ok63tn" returned 141
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/mixlib-shellout-2.2.6/lib/mixlib/shellout.rb:289:in `invalid!'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/mixlib-shellout-2.2.6/lib/mixlib/shellout.rb:276:in `error!'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.38/lib/chef/mixin/shell_out.rb:56:in `shell_out!'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.38/lib/chef/provider/execute.rb:62:in `block in action_run'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.38/lib/chef/mixin/why_run.rb:52:in `add_action'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.38/lib/chef/provider.rb:175:in `converge_by'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.38/lib/chef/provider/execute.rb:60:in `action_run'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.38/lib/chef/provider/script.rb:63:in `action_run'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.38/lib/chef/provider.rb:144:in `run_action'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.38/lib/chef/resource.rb:596:in `run_action'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.38/lib/chef/runner.rb:69:in `run_action'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.38/lib/chef/runner.rb:97:in `block (2 levels) in converge'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.38/lib/chef/runner.rb:97:in `each'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.38/lib/chef/runner.rb:97:in `block in converge'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.38/lib/chef/resource_collection/resource_list.rb:84:in `block in execute_each_resource'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.38/lib/chef/resource_collection/stepable_iterator.rb:116:in `call'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.38/lib/chef/resource_collection/stepable_iterator.rb:116:in `call_iterator_block'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.38/lib/chef/resource_collection/stepable_iterator.rb:85:in `step'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.38/lib/chef/resource_collection/stepable_iterator.rb:104:in `iterate'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.38/lib/chef/resource_collection/stepable_iterator.rb:55:in `each_with_index'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.38/lib/chef/resource_collection/resource_list.rb:82:in `execute_each_resource'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.38/lib/chef/runner.rb:96:in `converge'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.38/lib/chef/provider.rb:361:in `compile_and_converge_action'
(eval):2:in `action_create'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.38/lib/chef/provider.rb:144:in `run_action'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.38/lib/chef/resource.rb:596:in `run_action'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.38/lib/chef/runner.rb:69:in `run_action'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.38/lib/chef/runner.rb:97:in `block (2 levels) in converge'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.38/lib/chef/runner.rb:97:in `each'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.38/lib/chef/runner.rb:97:in `block in converge'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.38/lib/chef/resource_collection/resource_list.rb:84:in `block in execute_each_resource'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.38/lib/chef/resource_collection/stepable_iterator.rb:116:in `call'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.38/lib/chef/resource_collection/stepable_iterator.rb:116:in `call_iterator_block'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.38/lib/chef/resource_collection/stepable_iterator.rb:85:in `step'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.38/lib/chef/resource_collection/stepable_iterator.rb:104:in `iterate'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.38/lib/chef/resource_collection/stepable_iterator.rb:55:in `each_with_index'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.38/lib/chef/resource_collection/resource_list.rb:82:in `execute_each_resource'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.38/lib/chef/runner.rb:96:in `converge'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.38/lib/chef/client.rb:667:in `block in converge'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.38/lib/chef/client.rb:662:in `catch'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.38/lib/chef/client.rb:662:in `converge'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.38/lib/chef/client.rb:701:in `converge_and_save'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.38/lib/chef/client.rb:281:in `run'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.38/lib/chef/application.rb:285:in `block in fork_chef_client'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.38/lib/chef/application.rb:273:in `fork'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.38/lib/chef/application.rb:273:in `fork_chef_client'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.38/lib/chef/application.rb:238:in `block in run_chef_client'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.38/lib/chef/local_mode.rb:44:in `with_server_connectivity'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.38/lib/chef/application.rb:226:in `run_chef_client'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.38/lib/chef/application/solo.rb:301:in `block in interval_run_chef_client'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.38/lib/chef/application/solo.rb:290:in `loop'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.38/lib/chef/application/solo.rb:290:in `interval_run_chef_client'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.38/lib/chef/application/solo.rb:269:in `run_application'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.38/lib/chef/application.rb:58:in `run'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.38/bin/chef-solo:25:in `<top (required)>'
/usr/bin/chef-solo:51:in `load'
/usr/bin/chef-solo:51:in `<main>'
那么,出了什么问题?
由于