saltstack的master_job_cache特性

2023年 7月 15日 60.3k 0

master_job_cache特性

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

在配置文件添加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)

saltstack的master_job_cache特性-1

相关文章

对接alertmanager创建钉钉卡片(1)
手把手教你搭建OpenFalcon监控系统
无需任何魔法即可使用 Ansible 的神奇变量“hostvars”
openobseve HA本地单集群模式
基于k8s上loggie/vector/openobserve日志收集
openobseve单节点和查询语法

发布评论