SaltStack – Using the Mysql Module
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了SaltStack – Using the Mysql Module相关的知识,希望对你有一定的参考价值。
salt ‘*‘ saltutil.refresh_pillar
官网的例子真的没看懂,英文菜。其实就简单一步。
参考文档
https://docs.saltstack.com/en/latest/ref/modules/all/salt.modules.mysql.html
https://z900collector.wordpress.com/linux/using-the-saltstack-mysql-module/
salt-master主要是找/usr/lib/python2.6/site-packages/salt/modules/test.py
[[email protected] salt]# cat /etc/salt/minion
master: 172.1.1.1
id: cm1
mysql.host: ‘localhost‘
mysql.port: 3306
mysql.user: ‘root‘
mysql.socket: ‘x.sock‘
mysql.pass: ‘xx‘
mysql.charset: ‘utf8‘
/etc/init.d/salt-minion restart
‘‘‘
执行顺序,测试命令
state.show_sls执行函数来查看salt state的执行顺序
sudo salt stage-db1 state.show_sls mysql
sudo salt stage-db1 state.apply mysql test=True
sudo salt stage-db1 state.apply mysql
mysql
sudo salt stage-db1 mysql.db_list
‘‘‘
salt ‘*‘ mysql.db_list
最完整的例子
https://www.digitalocean.com/community/tutorials/saltstack-infrastructure-creating-salt-states-for-mysql-database-servers
1.salt-minion端
mysql连接信息 /etc/salt/minion.d/mysql.conf
mysql.default_file: ‘/etc/mysql/salt.cnf‘
vim /etc/mysql/salt.cnf
mysql.host: ‘localhost‘
mysql.port: 3306
mysql.user: ‘root‘
mysql.socket: ‘x.sock‘
mysql.pass: ‘xx‘
mysql.charset: ‘utf8‘
2.vim /srv/pillar/top.sls
base:
‘[email protected]:dev and [email protected]:dbserver‘:
- match: compound
- dev.mysql
‘[email protected]:stage and [email protected]:dbserver‘:
- match: compound
- stage.mysql
‘[email protected]:prod and [email protected]:dbserver‘:
- match: compound
- prod.mysql
3.vim /srv/salt/mysql/init.sls
debconf-utils:
pkg.installed
mysql_setup:
debconf.set:
- name: mysql-server
- data:
‘mysql-server/root_password‘: {‘type‘: ‘password‘, ‘value‘: ‘{{ salt[‘pillar.get‘](‘mysql:root_pw‘, ‘‘) }}‘ }
‘mysql-server/root_password_again‘: {‘type‘: ‘password‘, ‘value‘: ‘{{ salt[‘pillar.get‘](‘mysql:root_pw‘, ‘‘) }}‘ }
- require:
- pkg: debconf-utils
python-mysqldb:
pkg.installed
mysql-server:
pkg.installed:
- require:
- debconf: mysql-server
- pkg: python-mysqldb
mysql:
service.running:
- watch:
- pkg: mysql-server
- file: /etc/mysql/my.cnf
mysql:
service.running:
- watch:
- pkg: mysql-server
- file: /etc/mysql/my.cnf
/etc/mysql/my.cnf:
file.managed:
- source: salt://mysql/files/etc/mysql/my.cnf.jinja
- template: jinja
- user: root
- group: root
- mode: 640
- require:
- pkg: mysql-server
/etc/salt/minion.d/mysql.conf:
file.managed:
- source: salt://mysql/files/etc/salt/minion.d/mysql.conf
- user: root
- group: root
- mode: 640
- require:
- service: mysql
/etc/mysql/salt.cnf:
file.managed:
- source: salt://mysql/files/etc/mysql/salt.cnf.jinja
- template: jinja
- user: root
- group: root
- mode: 640
- require:
- service: mysql
restart_minion_for_mysql:
service.running:
- name: salt-minion
- watch:
- file: /etc/salt/minion.d/mysql.conf
上面是digitoean云上的例子。最重要的是/etc/salt/minion.d
本文出自 “要有梦想,万一实现了呢” 博客,谢绝转载!
以上是关于SaltStack – Using the Mysql Module的主要内容,如果未能解决你的问题,请参考以下文章
You can find the timer(s) that are using too much CPU time using the Developer Tools timeline
Using IntelliJ IDEA as the Vim Editor
Using The Chrome Developer Tools