我正在尝试通过配方安装 MySQL 的特定子版本。我已将节点属性设置为 5.6,并在 vagrant 测试箱上运行 chef-client,但失败并出现以下错误:
==> default: Recipe: my-mysql::default
==> default: * mysql_service[testdb] action create
==> default: * mysql_server_installation_package[testdb] action install
==> default:
==> default: * yum_package[mysql-community-server] action install
==> default:
==> default: * No candidate version available for mysql-community-server
==> default:
==> default: ================================================================================
==> default: Error executing action `install` on resource 'yum_package[mysql-community-server]'
==> default: ================================================================================
==> default:
==> default: Chef::Exceptions::Package
==> default: -------------------------
==> default: No candidate version available for mysql-community-server
==> default:
==> default: Resource Declaration:
==> default: ---------------------
==> default: # In /var/chef/cache/cookbooks/mysql/libraries/mysql_server_installation_package.rb
==> default:
==> default: 17: package package_name do
==> default: 18: version package_version if package_version
==> default: 19: options package_options if package_options
==> default: 20: notifies :install, 'package[perl-Sys-Hostname-Long]', :immediately if platform_family?('suse')
==> default: 21: notifies :run, 'execute[Initial DB setup script]', :immediately if platform_family?('suse')
==> default: 22: action :install
==> default: 23: end
==> default: 24:
==> default:
==> default: Compiled Resource:
==> default: ------------------
==> default: # Declared in /var/chef/cache/cookbooks/mysql/libraries/mysql_server_installation_package.rb:17:in `block in <class:MysqlServerInstallationPackage>'
==> default:
==> default: yum_package("mysql-community-server") do
==> default: package_name "mysql-community-server"
==> default: action [:install]
==> default: retries 0
==> default: retry_delay 2
==> default: default_guard_interpreter :default
==> default: declared_type :package
==> default: cookbook_name "my-mysql"
==> default: version "5.6.29-2.el7"
==> default: flush_cache {:before=>false, :after=>false}
==> default: end
我的配方使用 mysql cookbook(目前为 8.0.4)。我的配方中用于设置 mysql 的块如下:
mysql_service mysql_service_name do
version node['mysql']['version']
bind_address node['mysql']['bind_address']
port node['mysql']['port']
data_dir node['mysql']['data_dir']
initial_root_password 'test'
action [:create, :start]
end
我创建了一个自定义角色(为简单起见)用于 Vagrant Chef 配置。以下是默认属性:
"default_attributes": {
"mysql": {
"version": "5.6",
"service_name": "testdb"
}
},
有人知道使用 Chef 在 Centos 7 上安装 MySQL 5.6/5.7 的工作示例吗?
答案1
我认为你的系统没有添加正确的 repo,请查看yum-mysql-社区食谱。您可能需要在食谱中添加类似这样的内容:
include_recipe 'yum-mysql-community::mysql57'