MariaDB食谱不起作用

时间:2015-03-03 11:22:24

标签: chef mariadb

我尝试使用以下方法创建自己的MariaDB食谱:

我尝试在手动安装中复制用于安装MariaDB的步骤。 mariadb.repo文件已创建但除此之外我没有看到my.cnf或my.cnf.d文件和文件夹被创建。

请让我知道出了什么问题,或者我应该在哪里找出能够找出出错的方法?

MariaDB的/食谱/ default.rb:

include_recipe "yum"

arch = node['kernel']['machine']
# Fedora reports the architecture as 'x86_64'
arch = 'amd64' if arch == 'x86_64'
arch = 'x86' unless arch == 'amd64'
pversion = node['platform_version'].split('.').first


case node["platform"]  #Create Yum Repository for MariaDB
  when "redhat"
    yum_repository "MariaDB" do
    name 'mariadb'
    baseurl  'http://yum.mariadb.org/5.5/rhel6-amd64'
    gpgkey 'https://yum.mariadb.org/RPM-GPG-KEY-MariaDB'
    gpgcheck true
    action :create
  end

  when "centos"
    yum_repository "MariaDB" do
    name 'mariadb'
    baseurl   "http://yum.mariadb.org/#{node['mariadb']['version']}/#{node['platform']}#{pversion}-#{arch}"
    gpgkey 'https://yum.mariadb.org/RPM-GPG-KEY-MariaDB'
    gpgcheck true
    action :create
  end

end



bash 'remove postfix' do
  cwd '/etc'
  code <<-EOH
  rpm --import https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
  yum remove postfix
  EOH
end



bash 'install_MariaDB-server-Client' do
  cwd '/etc'
  code <<-EOF
  /usr/bin/expect -c 'spawn yum install MariaDB-server MariaDB-client
  expect "Is this ok [y/d/N]:"
  send  "y\n" eof'
  EOF
end

bash 'install postfix' do
  cwd '/etc'
  code <<-EOF
  /usr/bin/expect -c 'spawn yum install postfix
  expect "Is this ok [y/d/N]:"
  send  "y\n" eof'
  EOF
end 

# Start mariadb service
service "mysql" do
  supports :status => true, :restart => true, :start => true
  action [ :start,  :enable]
end



bash "mysql_secure_installation" do
  user "root"
  code <<-EOF
  /usr/bin/expect -c 'spawn /etc/mysql_secure_installation
  expect "Enter current password for root (enter for none):"
  send  "\r"
  expect "Change root password?"
  send "y\n"
  expect "New password:"
  send "root\n"
  expect "Re-enter new password:"
  send "root\n"
  expect "Remove anonymous users?"
  send "y\n"
  expect "Disallow root login remotely?"
  send "y\n"
  expect "Remove test database and access to it?"
  send "y\n"
  expect "Reload privilege tables now?"
  send "y\n" eof'
  EOF
end

执行chef-client

[2015-03-03T11:16:52+00:00] WARN: 

    * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
    SSL validation of HTTPS requests is disabled. HTTPS connections are still
encrypted, but chef is not able to detect forged replies or man in the middle
attacks.

    To fix this issue add an entry like this to your configuration file:

    ```
     # Verify all HTTPS connections (recommended)
     ssl_verify_mode :verify_peer

     # OR, Verify only connections to chef-server
     verify_api_cert true
    ```

要检查您的SSL配置或排除错误,您可以使用 knife ssl check这样的命令:

  knife ssl check -c /etc/chef/client.rb

    Starting Chef Client, version 11.16.4
    resolving cookbooks for run list: ["lgmariadb"]
    Synchronizing Cookbooks:
      - yum
      - lgmariadb
    Compiling Cookbooks...
    Converging 7 resources
    Recipe: yum::default
       * yum_globalconfig[/etc/yum.conf] action create
       * template[/etc/yum.conf] action create (up to date)
     (up to date)
    Recipe: lgmariadb::default
       * yum_repository[mariadb] action create
       * template[/etc/yum.repos.d/mariadb.repo] action create (up to date)
       * execute[yum-makecache-mariadb] action nothing (skipped due to action :nothing)
       * ruby_block[yum-cache-reload-mariadb] action nothing (skipped due to action :nothing)
     (up to date)
       * bash[remove postfix] action run
       - execute "bash"  "/tmp/chef-script20150303-14830-hcss75"
       * bash[install_MariaDB-server-Client] action run
       - execute "bash"  "/tmp/chef-script20150303-14830-69e4w"
       * bash[install postfix] action run
       - execute "bash"  "/tmp/chef-script20150303-14830-d4wjcl"
       * service[mysql] action start

    ================================================================================
    Error executing action `start` on resource 'service[mysql]'
    ================================================================================

    Chef::Exceptions::Exec
    ----------------------
    /bin/systemctl start mysql returned 6, expected 0

    Resource Declaration:
    ---------------------
    # In /var/chef/cache/cookbooks/lgmariadb/recipes/default.rb

     89: service "mysql" do
     90:   supports :status => true, :restart => true, :start => true
     91:   action [ :start,  :enable]
     92: end
     93: 

    Compiled Resource:
    ------------------
    # Declared in /var/chef/cache/cookbooks/lgmariadb/recipes/default.rb:89:in `from_file'

    service("mysql") do
      provider Chef::Provider::Service::Systemd
      action [:start, :enable]
      supports {:status=>true, :restart=>true, :start=>true}
      retries 0
      retry_delay 2
      guard_interpreter :default
      service_name "mysql"
      pattern "mysql"
      cookbook_name "lgmariadb"
      recipe_name "default"
    end


Running handlers:
[2015-03-03T11:16:53+00:00] ERROR: Running exception handlers
Running handlers complete

[2015-03-03T11:16:53+00:00] ERROR: Exception handlers complete
[2015-03-03T11:16:53+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out

Chef Client failed. 3 resources updated in 1.477241151 seconds
[2015-03-03T11:16:53+00:00] ERROR: service[mysql] (lgmariadb::default line 89) had an error: Chef::Exceptions::Exec: /bin/systemctl start mysql returned 6, expected 0

[2015-03-03T11:16:53+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)

1 个答案:

答案 0 :(得分:1)

如果它是CentOS 7或RHEL7,我担心现在会调用该服务&#34; mariadb.service&#34;,因此如果您致电:

$ sudo systemctl start mariadb.service

这应该有效。同样在&#39; mariadb&#39;您需要通知另一个服务名称:

service 'mariadb.service' do
  action :nothing
end