我在以下puppet recipe应用新配置并在Travis CI上运行my build时重新启动MySQL服务器:
class { '::mysql::server':
root_password => 'root',
override_options => {
'mysqld' => {
'max_connections' => '512',
'max_allowed_packet' => '12M'
}
},
restart => true
}
但是在我应用这个食谱后,我的MySQL数据库就消失了。
日志是:
$ echo "SHOW DATABASES" | mysql -uroot -proot
Database
information_schema
mysql
performance_schema
travis_ads_test
$ sudo puppet apply puppet/ads.dev.configure-site.pp
Warning: Setting templatedir is deprecated. See http://links.puppetlabs.com/env-settings-deprecations
(at /usr/lib/ruby/vendor_ruby/puppet/settings.rb:1117:in `issue_deprecation_warning')
Warning: Config file /etc/puppet/hiera.yaml not found, using Hiera defaults
Notice: Compiled catalog for ads.localdomain in environment production in 2.29 seconds
Notice: /Stage[main]/Mysql::Server::Config/File[/etc/mysql/my.cnf]/content: content changed '{md5}b199076b6b1a40b6cd6f8f0c464977e9' to '{md5}0d8e003c4dfe5cfd85de1d06cc7c4eb7'
Notice: /Stage[main]/Mysql::Server::Service/Service[mysqld]: Triggered 'refresh' from 1 events
Notice: /Stage[main]/Mysql::Server::Service/File[/var/log/mysql/error.log]/group: group changed 'adm' to 'mysql'
Notice: /Stage[main]/Mysql::Server::Root_password/Mysql_user[root@localhost]/password_hash: defined 'password_hash' as '*81F5E21E35407D884A6CD4A731AEBFB6AF209E1B'
Notice: /Stage[main]/Mysql::Server::Root_password/File[/root/.my.cnf]/ensure: defined content as '{md5}f2ee51638cc14fb3396202254d9f14a0'
Notice: /Stage[main]/Main/Apache::Vhost[ads.localhost]/File[/var/www/ads]/owner: owner changed 'travis' to 'root'
Notice: /Stage[main]/Main/Apache::Vhost[ads.localhost]/File[/var/www/ads]/group: group changed 'travis' to 'root'
Notice: /Stage[main]/Main/Apache::Vhost[ads.localhost]/File[25-ads.localhost.conf]/ensure: created
Notice: /Stage[main]/Main/Apache::Vhost[ads.localhost]/File[25-ads.localhost.conf symlink]/ensure: created
Notice: /Stage[main]/Apache::Service/Service[httpd]: Triggered 'refresh' from 2 events
Notice: Finished catalog run in 7.08 seconds
The command "sudo puppet apply puppet/ads.dev.configure-site.pp" exited with 0.
$ echo "SHOW DATABASES" | mysql -uroot -proot && echo "SHOW TABLES" | drush sql-cli
Database
information_schema
mysql
performance_schema
Calling proc_open(mysql --database=travis_ads_test --host=localhost --port=3306 --user=root --password=root);
ERROR 1049 (42000): Unknown database 'travis_ads_test'
我的数据库travis_ads_test消失了。有什么理由吗?
我通过puppet重启MySQL,或者它是某种特拉维斯CI功能吗?
答案 0 :(得分:1)
似乎不需要restart
,因为puppetlabs-mysql模块将管理配置更改所需的所有重新启动,如以下消息所示:
Config/File[/etc/mysql/my.cnf]/content: content changed
Service/Service[mysqld]: Triggered 'refresh' from 1 events
如果您确实需要重启,请检查:Restarting mysql utilizing the puppetlabs/mysql module?
所以解决方法是删除restart => true
,但为什么缺少数据库,我不确定。
可能是您的数据库没有被删除,但通过更改凭据,您更改了具有数据库访问权限的该用户的权限。如果您在更改前有root密码,则需要old_root_password
,如果您希望通过Puppet更改root密码。
查看文档以获取更多信息:
答案 1 :(得分:0)
根据Felix Frank评论:
如果你不覆盖这些值,Puppet会强加默认设置。例如,您没有为
datadir
提供值,因此Puppet会将模块的默认值放入my.cnf
。再次 - 比较之前和之后的my.cnf
。