salt把返回寫入到mysql

來源:互聯網
上載者:User

標籤:返回寫入到mysql


官方文檔:https://docs.saltstack.com/en/2016.3/ref/returners/all/salt.returners.mysql.html#module-salt.returners.mysql


mysql自己搭建

首先要在master機器上建立資料庫

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(50) NOT NULL,  `jid` varchar(255) NOT NULL,  `return` mediumtext NOT NULL,  `id` varchar(255) NOT NULL,  `success` varchar(10) 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;授權:grant all on salt.* to [email protected]‘%‘ identified by ‘salt‘;


master和minion端:

vim /etc/salt/minionmysql.host: ‘192.168.141.250‘ #這裡的ip寫master的ipmysql.user: ‘salt‘mysql.pass: ‘salt‘mysql.db: ‘salt‘mysql.port: 3306儲存退出,並重啟服務/etc/init.d/salt-minion restart


我們執行一條命令:

salt ‘*‘ test.ping --return mysql


我們進入mysql命令列:

mysqlshow databases;use salt;show tables;select * from salt_returns\G;結果如下:*************************** 1. row ***************************       fun: test.ping       jid: 20170321234131569065    return: true        id: web12.limingyu.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把返回寫入到mysql

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.