
모듈을 사용하는 다음 Puppet 클래스가 있습니다 puppetlabs/mysql
.
class hg_playground::makowals::brains::db {
class { '::mysql::client':
package_name => 'mariadb',
}
$override_options = {
'mysqld' => {
'log-bin' => '',
'server-id' => $mysql_server_id,
}
}
class { '::mysql::server':
package_name => 'mariadb-server',
root_password => 'TESTOWY',
remove_default_accounts => true,
override_options => $override_options,
}
mysql_user { 'slave_user@localhost':
ensure => 'present',
password_hash => mysql_password('master_replication'),
}
mysql_grant { 'slave_user@localhost/*.*':
ensure => 'present',
options => ['GRANT'],
privileges => ['REPLICATION SLAVE'],
table => '*.*',
user => 'slave_user@localhost',
}
mysql_database { 'somedb':
ensure => 'present',
}
}
거기서 무슨 일이 일어나는지
- mariadb-server가 올바르게 설치되고 있습니다.
- DB에 대한 루트 비밀번호가 설정되지 않았습니다.
- 나는
/root/.my.cnf
가지고있다password='TESTOWY'
- 새로운 사용자나 데이터베이스가 생성되지 않습니다.
물론 에이전트를 실행해도 오류가 발생하지 않습니다. 이 상황에서 디버깅을 시작하는 방법은 무엇입니까? 클래스 실행 알림에는 흥미로운 내용이 표시되지 않습니다.
notice /Stage[main]/Mysql::Server::Install/Package[mysql-server]/ensure created
notice /Stage[main]/Mysql::Server::Config/File[mysql-config-file]/content content changed '{md5}54dc3e561e817f9c0a376a58383eb013' to '{md5}ff09a4033f718f08f69da17f0aa86652'
notice /Stage[main]/Mysql::Server::Service/Service[mysqld]/ensure ensure changed 'stopped' to 'running'
notice /Stage[main]/Mysql::Server::Root_password/File[/root/.my.cnf]/ensure defined content as '{md5}042e1a46bc15a260a349dbbe1bac8e71'
답변1
나는 사용 중이고 centos 5
mariadb는 기본 저장소에 없으므로 지정하지 않고 package_name
클래스와 작동을 테스트했습니다. 내가 추가한 유일한 것은 mysql::server
클래스에 require이고 DB 생성을 위해 mysql::db 클래스를 사용했습니다.
class hg_playground::makowals::brains::db {
class { '::mysql::client':
package_name => 'mariadb',
}
$override_options = {
'mysqld' => {
'log-bin' => '',
'server-id' => $mysql_server_id,
}
}
class { '::mysql::server':
package_name => 'mariadb-server',
root_password => 'TESTOWY',
remove_default_accounts => true,
override_options => $override_options,
}
mysql_user { 'slave_user@localhost':
ensure => 'present',
password_hash => mysql_password('master_replication'),
}
mysql_grant { 'slave_user@localhost/*.*':
ensure => 'present',
options => ['GRANT'],
privileges => ['REPLICATION SLAVE'],
table => '*.*',
user => 'slave_user@localhost',
}
mysql_database { 'somedb':
ensure => 'present',
require => Class['mysql::server']
}
}
인형 실행 출력.
=> default: Notice: Compiled catalog for centos7.example.com in environment testing in 2.97 seconds
==> default: Notice: /Stage[main]/Mysql::Client::Install/Package[mysql_client]/ensure: created
==> default: Notice: /Stage[main]/Mysql::Server::Install/Package[mysql-server]/ensure: created
==> default: Notice: /Stage[main]/Mysql::Server::Config/File[mysql-config-file]/content: content changed '{md5}54dc3e561e817f9c0a376a58383eb013' to '{md5}40a2060d1d62cb5c3f33e5e74be19889'
==> default: Notice: /Stage[main]/Mysql::Server::Installdb/Exec[mysql_install_db]/returns: executed successfully
==> default: Notice: /Stage[main]/Mysql::Server::Service/Service[mysqld]/ensure: ensure changed 'stopped' to 'running'
==> default: Notice: /Stage[main]/Mysql::Server::Root_password/Mysql_user[root@localhost]/password_hash: defined 'password_hash' as '*416F1598B4E5F9CD0DBFC2E35867FA1F96EBF4F5'
==> default: Notice: /Stage[main]/Mysql::Server::Root_password/File[/root/.my.cnf]/ensure: defined content as '{md5}cd27be3d51dcd48e92de9df7e894accb'
==> default: Notice: /Stage[main]/Mysql::Server::Account_security/Mysql_user[[email protected]]/ensure: removed
==> default: Notice: /Stage[main]/Mysql::Server::Account_security/Mysql_user[root@::1]/ensure: removed
==> default: Notice: /Stage[main]/Mysql::Server::Account_security/Mysql_user[@localhost]/ensure: removed
==> default: Notice: /Stage[main]/Mysql::Server::Account_security/Mysql_user[[email protected]]/ensure: removed
==> default: Notice: /Stage[main]/Mysql::Server::Account_security/Mysql_user[@centos7.example.com]/ensure: removed
==> default: Notice: /Stage[main]/Mysql::Server::Account_security/Mysql_database[test]/ensure: removed
==> default: Notice: /Stage[main]/Hg_playground::Makowals::Brains::Db/Mysql_user[slave_user@localhost]/ensure: created
==> default: Notice: /Stage[main]/Hg_playground::Makowals::Brains::Db/Mysql_grant[slave_user@localhost/*.*]/privileges: privileges changed ['USAGE'] to 'REPLICATION SLAVE'
==> default: Notice: /Stage[main]/Hg_playground::Makowals::Brains::Db/Mysql_grant[slave_user@localhost/*.*]/options: defined 'options' as 'GRANT'
==> default: Notice: /Stage[main]/Hg_playground::Makowals::Brains::Db/Mysql_database[somedb]/ensure: created
답변2
mysql::server 클래스에는 버전을 포함하는 package_name 속성이 있어야 합니다.
class{ 'mysql::server':
package_name => "mariadb-server-${mariadb_version}",
...
}
apt-cache search mariadb-server
예 를 들어 원하는 것을 제공하는 저장소 버전을 이미 추가했다고 가정하고 패키지 이름이 어떻게 보이는지 확인하는 데 사용하십시오 . mariadb의 다양한 버전 제품군에 대한 별도의 저장소가 있습니다.