【问题标题】:MariaDB recipe doesn't worksMariaDB 配方不起作用
【发布时间】:2015-03-03 11:22:24
【问题描述】:

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

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

请让我知道出了什么问题,或者我应该去哪里寻找以找出问题所在?

MariaDB/recipes/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)

【问题讨论】:

    标签: chef-infra mariadb


    【解决方案1】:

    如果那是 CentOS 7 或 RHEL7,恐怕该服务现在称为“mariadb.service”,因此如果您调用:

    $ sudo systemctl start mariadb.service
    

    那应该行。同样在“mariadb”食谱中,您需要告知不同的服务名称:

    service 'mariadb.service' do
      action :nothing
    end
    

    【讨论】:

      猜你喜欢
      • 2017-11-26
      • 1970-01-01
      • 2016-12-17
      • 1970-01-01
      • 2015-08-26
      • 2017-02-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多