Salt to write back to MySQL

Source: Internet
Author: User
Tags mysql command line


Official Document: Https://docs.saltstack.com/en/2016.3/ref/returners/all/salt.returners.mysql.html#module-salt.returners.mysql


MySQL builds itself

The first thing to do is create a database on the master machine

create database   ' Salt '   default character set utf8  default  COLLATE utf8_general_ci; use  ' salt '; create table  ' Jids '   (   ' Jid '  varchar (255)  NOT NULL,   ' load '  mediumtext NOT NULL,  UNIQUE KEY  ' Jid '   (' Jid '))  engine=innodb  DEFAULT CHARSET=utf8; Create index jid on jids (Jid)  USING BTREE; create table  ' Salt_returns '   (   ' fun '  varchar ()  NOT NULL,   ' Jid '  varchar (255)  NOT NULL,   ' return '  mediumtext NOT NULL,    ' ID '  varchar (255)  NOT NULL,   ' success '  varchar (Ten)  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)  NOT NULL,PRIMARY KEY  (' id '), key  ' tag '   (' tag ')  ENGINE=InnoDB DEFAULT CHARSET=utf8; authorized:grant all on  Salt.* to [email protected] '% '  identified by  ' salt ';


Master and Minion End:

Vim/etc/salt/minionmysql.host: ' 192.168.141.250 ' #这里的ip写master的ipmysql. User: ' Salt ' mysql.pass: ' Salt ' mysql.db: ' Salt ' mysql.port:3306 save exit and restart service/etc/init.d/salt-minion restart


We execute an order:

Salt ' * ' test.ping--return MySQL


Let's go to the MySQL command line:

Mysqlshow databases;use salt;show Tables;select * from salt_returns\g; the results are as follows: *************************** 1. Row *************************** fun:test.ping jid:20170321234131569065 return:true Id:web12.limi Ngyu.com success:1 Full_ret: {"Fun_args": [], "Jid": "20170321234131569065", "return": True, "Retcode": 0, "Success": True, "fun": "Test.ping", "id": "web12.limingyu.com"}alter_time:2017-03-21 23:41:32





Salt to write back to MySQL

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.