saltstack的master_job_cache特性

master_job_cache特性

当结果返回,master可以将结果缓存至数据库,并不需要另外安装MySQL-python
mysql数据库的一个库和三张表需要创建

在配置文件添加master_job_cache: mysql后,清空表测试!

[root@master ~]# vim /etc/salt/master 
mysql.host: '10.0.0.7'
mysql.user: 'salt'
mysql.pass: 'salt'
mysql.db: 'salt'
mysql.port: 3306
master_job_cache: mysql 

清空表!

mysql> truncate table salt_returns;
Query OK, 0 rows affected (0.02 sec)

mysql> select * from salt_returns\G
Empty set (0.00 sec)

重启master

[root@master ~]# /etc/init.d/salt-master restart
Stopping salt-master daemon:                               [确定]
Starting salt-master daemon:                               [确定]
[root@master ~]# 

再次执行一条任何命令,数据库将会出现数据

[root@master ~]# salt '*' cmd.run 'df -h'
minios.10.0.0.8.com:
    Filesystem      Size  Used Avail Use% Mounted on
    /dev/sda2        18G  2.6G   14G  16% /
    tmpfs           491M   12K  491M   1% /dev/shm
    /dev/sda1       283M   28M  240M  11% /boot
minion-node20.10.0.0.20.com:
    Filesystem      Size  Used Avail Use% Mounted on
    /dev/sda2        18G  2.6G   14G  16% /
    tmpfs           238M   12K  238M   1% /dev/shm
    /dev/sda1       283M   28M  240M  11% /boot
[root@master ~]# 

如下:

mysql> select * from salt_returns\G
*************************** 1. row ***************************
       fun: cmd.run
       jid: 20151212005049266326
    return: "Filesystem      Size  Used Avail Use% Mounted on\n/dev/sda2        18G  2.6G   14G  16% /\ntmpfs           491M   12K  491M   1% /dev/shm\n/dev/sda1       283M   28M  240M  11% /boot"
        id: minios.10.0.0.8.com
   success: 1
  full_ret: {"fun_args": ["df -h"], "jid": "20151212005049266326", "return": "Filesystem      Size  Used Avail Use% Mounted on\n/dev/sda2        18G  2.6G   14G  16% /\ntmpfs           491M   12K  491M   1% /dev/shm\n/dev/sda1       283M   28M  240M  11% /boot", "retcode": 0, "success": true, "cmd": "_return", "_stamp": "2015-12-12T08:50:49.487996", "fun": "cmd.run", "id": "minios.10.0.0.8.com"}
alter_time: 2015-12-12 00:50:49
*************************** 2. row ***************************
       fun: cmd.run
       jid: 20151212005049266326
    return: "Filesystem      Size  Used Avail Use% Mounted on\n/dev/sda2        18G  2.6G   14G  16% /\ntmpfs           238M   12K  238M   1% /dev/shm\n/dev/sda1       283M   28M  240M  11% /boot"
        id: minion-node20.10.0.0.20.com
   success: 1
  full_ret: {"fun_args": ["df -h"], "jid": "20151212005049266326", "return": "Filesystem      Size  Used Avail Use% Mounted on\n/dev/sda2        18G  2.6G   14G  16% /\ntmpfs           238M   12K  238M   1% /dev/shm\n/dev/sda1       283M   28M  240M  11% /boot", "retcode": 0, "success": true, "cmd": "_return", "_stamp": "2015-12-12T08:50:49.497892", "fun": "cmd.run", "id": "minion-node20.10.0.0.20.com"}
alter_time: 2015-12-12 00:50:49
2 rows in set (0.00 sec)

1 分享

您可以选择一种方式赞助本站

支付宝扫码赞助

支付宝扫码赞助

日期: 2015-12-13分类: saltstack

标签: saltstack

发表评论