what databases can be stored: https://docs.saltstack.com/en/latest/ref/returners/all/index.html
use MySQL as an example to configure the reference:
Https://docs.saltstack.com/en/latest/ref/returners/all/salt.returners.mysql.html#module-salt.returners.mysql
Installing MySQL Mysql-python
[[email protected] salt]# yum install-y mysql-server mysql installation MySQL
[email protected] ~]# Yum install-y mysql-python # All minion have to pack the bag
[[email protected] ~]#/etc/init.d/mysqld start
[email protected] ~]# Yum install-y Mysql-python
Create A Salt library and jids, salt_events, Salt_returns three tables
[[email protected] ~]# MySQL
CREATE DATABASE ' Salt '
DEFAULT CHARACTER SET UTF8
DEFAULT COLLATE utf8_general_ci;
Use ' salt ';
CREATE TABLE ' Jids ' (
' Jid ' varchar (255) is not NULL,
' Load ' mediumtext not NULL,
UNIQUE KEY ' Jid ' (' Jid ')
) Engine=innodb DEFAULT Charset=utf8;
CREATE TABLE ' Salt_returns ' (
' Fun ' varchar (+) not NULL,
' Jid ' varchar (255) is not NULL,
' Return ' Mediumtext not NULL,
' ID ' varchar (255) is not NULL,
' Success ' varchar () not NULL,
' Full_ret ' Mediumtext not NULL,
' Alter_time ' TIMESTAMP DEFAULT current_timestamp,
KEY ' id ' (' id '),
KEY ' Jid ' (' Jid '),
KEY ' fun ' (' fun ')
) Engine=innodb DEFAULT Charset=utf8;
CREATE TABLE ' salt_events ' (
' ID ' BIGINT not NULL auto_increment,
' Tag ' varchar (255) Not NULL,
' Data ' mediumtext not NULL,
' Alter_time ' TIMESTAMP DEFAULT current_timestamp,
' master_id ' varchar (255) is not NULL,
PRIMARY KEY (' id '),
KEY ' tag ' (' tag ')
) Engine=innodb DEFAULT Charset=utf8;
Create a user and authorize
GRANT all on salt.* to ' salt ' @ ' percent ' identified by ' salt ';
Flush privileges;
Remote login Test
[Email protected] ~]# mysql-h 192.168.10.129-usalt-psalt
Mysql>
Law One: The method is written directly to MySQL by minion data
[Email protected] ~]# vim/etc/salt/minion
[Email protected] ~]# tail/etc/salt/minion
#return: MySQL
Mysql.host: ' 192.168.10.129 '
Mysql.user: ' Salt '
Mysql.pass: ' Salt '
Mysql.db: ' Salt '
mysql.port:3306
[Email protected] ~]#/etc/init.d/salt-minion restart
[Email protected] ~]# vim/etc/salt/minion
[Email protected] ~]# tail/etc/salt/minion
#return: MySQL
Mysql.host: ' 192.168.10.129 '
Mysql.user: ' Salt '
Mysql.pass: ' Salt '
Mysql.db: ' Salt '
mysql.port:3306
[Email protected] ~]#/etc/init.d/salt-minion restart
[[email protected] ~]# Salt ' * ' test.ping--return MySQL
Mysql> select * from Salt_returns;
Law II: The method is configured directly on Master , andthe Minion end returns the information to the cache of master and writes the database from the cache information
[Email protected] ~]# Vim/etc/salt/master
[Email protected] ~]# Tail/etc/salt/master
Master_job_cache:mysql
Mysql.host: ' 192.168.10.129 '
Mysql.user: ' Salt '
Mysql.pass: ' Salt '
Mysql.db: ' Salt '
mysql.port:3306
[Email protected] ~]#/etc/init.d/salt-master restart
[[email protected] ~]# Salt ' * ' Cmd.run ' df-h '
Mysql> select * from Salt_returns;
This article is from the "Feng" blog, make sure to keep this source http://fengxiaoli.blog.51cto.com/12104465/1957998
Salt execution results back to MySQL