SaltStack-job管理
发表于:2025-11-07 作者:千家信息网编辑
千家信息网最后更新 2025年11月07日,一、salt执行结果默认返回给master端1、job cache存放位置# Directory to store job and cache data:# This directory may co
千家信息网最后更新 2025年11月07日SaltStack-job管理
一、salt执行结果默认返回给master端
1、job cache
存放位置
# Directory to store job and cache data:# This directory may contain sensitive data and should be protected accordingly.##cachedir: /var/cache/salt/master# Set the number of hours to keep old job information in the job cache:#keep_jobs: 24# The number of seconds to wait when the client is requesting information# about running jobs.#gather_job_timeout: 10
2、将cache存入数据库
(1)安装数据库连接模块
安装连接mysql的模块MySQL-pythonyum install -y MySQL-python
(2)配置数据库连接
在master上配置连接
直接在master的配置文件后面追加内容vim /etc/salt/mastermaster_job_cache: mysqlmysql.host: '192.168.56.11'mysql.user: 'salt'mysql.pass: '123456'mysql.db: 'salt'mysql.port: 3306
(3)重启salt-master
systemctl restart master
(4)验证是否写入数据库
执行如下命令[root@linux-node1 /srv/salt/prod/bbs]# salt '*' cmd.run 'whoami'linux-node2.example.com: rootlinux-node1.example.com: root
登录数据库mysql -h 192.168.56.11 -usalt -p123456MariaDB [(none)]> use salt;Reading table information for completion of table and column namesYou can turn off this feature to get a quicker startup with -A*************************** 9. row *************************** fun: cmd.run jid: 20161109091010973295 return: "root" id: linux-node2.example.com success: 1 full_ret: {"fun_args": ["whoami"], "jid": "20161109091010973295", "return": "root", "retcode": 0, "success": true, "cmd": "_return", "_stamp": "2016-11-09T01:10:11.064745", "fun": "cmd.run", "id": "linux-node2.example.com"}alter_time: 2016-11-09 09:10:11*************************** 10. row *************************** fun: cmd.run jid: 20161109091010973295 return: "root" id: linux-node1.example.com success: 1 full_ret: {"fun_args": ["whoami"], "jid": "20161109091010973295", "return": "root", "retcode": 0, "success": true, "cmd": "_return", "_stamp": "2016-11-09T01:10:11.146238", "fun": "cmd.run", "id": "linux-node1.example.com"}alter_time: 2016-11-09 09:10:1110 rows in set (0.00 sec)3、job查看
先执行一个命令,比如
salt '*' cmd.run 'ping www.baidu.com'
在执行job查看命令
[root@linux-node1 ~]# salt '*' saltutil.runninglinux-node2.example.com: |_ ---------- arg: - ping www.baidu.com fun: cmd.run jid: 20161109091517283293 pid: 6049 ret: tgt: * tgt_type: glob user: rootlinux-node1.example.com: |_ ---------- arg: - ping www.baidu.com fun: cmd.run jid: 20161109091517283293 pid: 6269 ret: tgt: * tgt_type: glob user: root
停止job,可以使用如下方法
[root@linux-node1 ~]# salt '*' saltutil.kill_job 20161109091517283293linux-node2.example.com: Signal 9 sent to job 20161109091517283293 at pid 6049linux-node1.example.com: Signal 9 sent to job 20161109091517283293 at pid 6269[root@linux-node1 ~]# salt '*' saltutil.runninglinux-node2.example.com:linux-node1.example.com:
4、master端cache
存放位置
[root@linux-node1 /var/cache/salt/master]# lsfile_lists jobs minions proc queues roots syndics tokens[root@linux-node1 /var/cache/salt/master]# pwd/var/cache/salt/master[root@linux-node1 /var/cache/salt/master]# tree.├── file_lists│ └── roots│ ├── base.p│ └── prod.p├── jobs│ ├── 6c│ │ └── 9f646ec75df0bd0ec29760ef0dee7a│ │ ├── jid│ │ └── linux-node1.example.com│ │ └── return.p│ ├── 90│ │ └── d3646e58dd82e103973eb889af96d1│ │ └── jid│ ├── d4│ │ └── 74a5b7f1ebf41c84c714d2ad8fda85│ │ ├── jid│ │ └── linux-node1.example.com│ │ └── return.p│ └── e3│ └── d2ffbc8e72a923205126c07c9e1e55│ ├── jid│ └── linux-node1.example.com│ └── return.p
二、jobs管理组件
一个方便管理jobs的系统:runners.jobs
列出job cache中的job[root@linux-node1 /var/cache/salt/master]# salt-run jobs.list_jobs[WARNING ] /usr/lib/python2.7/site-packages/salt/grains/core.py:1493: DeprecationWarning: The "osmajorrelease" will be a type of an integer.20161109090923312794: ---------- Arguments: - whoami Function: cmd.run StartTime: 2016, Nov 09 09:09:23.312794 Target: * Target-type: glob User: root
查看某个job的返回
[root@linux-node1 ~]# salt-run jobs.lookup_jid 20161109093137760714linux-node1.example.com: PING www.a.shifen.com (119.75.218.70) 56(84) bytes of data. 64 bytes from 119.75.218.70: icmp_seq=1 ttl=128 time=9.78 ms 64 bytes from 119.75.218.70: icmp_seq=2 ttl=128 time=4.65 ms 64 bytes from 119.75.218.70: icmp_seq=3 ttl=128 time=8.26 ms --- www.a.shifen.com ping statistics --- 3 packets transmitted, 3 received, 0% packet loss, time 2010ms rtt min/avg/max/mdev = 4.657/7.569/9.786/2.150 ms
可以使用salt-run查看当前up和down的minion
[root@linux-node1 ~]# salt-run manage.statusdown:up: - linux-node1.example.com - linux-node2.example.com
数据
数据库
命令
配置
管理
位置
模块
内容
文件
方法
系统
组件
结果
登录
验证
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
怎么搭建一个网吧服务器
dii 数据库
电子政务中心网络安全设备
服务器几个t
保定住宿软件开发
评论功能写入不了数据库
在设计网络安全策略
软件开发的核心成果
macbook pro安装数据库
网络安全体系构建方案
查看服务器的目录
数据库附加的语句
下一代v5服务器
数据库商品信息建表语句
CEIC数据库质量
警惕网络安全共建网络文明手抄报
有关网络安全宣传周ppt
云平台 等保2.0 网络安全
b站讲网络安全很火的up
山东聊城的中心服务器云空间
数据库的完整性安全性
数据库技术吧
徐州网络营销软件开发来电咨询
我的世界服务器挖煤矿
数据库怎么用代码创建教师表
战天网络技术工作室
嘉兴android软件开发
钢铁战队机械数据库
服务器配置与管理设计题
淮北社交软件开发