这里将salt使用过程当中遇到的全部的故障进行一个汇总。node
salt-master中配置jinja模板来匹配自定义的grins。python
vim /etc/salt/minion grains: roles: - elastic-minion1 #配置文件中引用 network.host: {{ grains['roles']}} #匹配后的结果以下: network.host: ['elastic-minion1']
解决办法mysql
#修改配置文件中的引用 network.host: {{ grains['roles'][0] }} 从新执行salt同步的命令: 结果以下: network.host: elastic-minion1
---------- ID: limit-conf-config Function: file.managed Name: /etc/securilty/limits.conf Result: False Comment: Parent directory not present Started: 17:05:44.606040 Duration: 11.448 ms Changes:
解决办法:linux
出现这个的缘由是Minion上没有name参数定义的目录. 在minion上定义对应的目录就能够了sql
[root@master files]# salt '*' state.highstate agent.niu.com: Data failed to compile: ---------- Rendering SLS init.limit failed, render error: expected '<document start>', but found '<block mapping start>' in "<unicode string>", line 2, column 1: limit-conf-config: ^ Traceback (most recent call last): File "/usr/lib/python2.7/site-packages/salt/state.py", line 2509, in render_state sls, rendered_sls=mods File "/usr/lib/python2.7/site-packages/salt/template.py", line 79, in compile_template ret = render(input_data, saltenv, sls, **render_kwargs) ▽ File "/usr/lib/python2.7/site-packages/salt/renderers/yaml.py", line 50, in render data = load(yaml_data, Loader=get_yaml_loader(argline)) File "/usr/lib64/python2.7/site-packages/yaml/__init__.py", line 71, in load return loader.get_single_data() File "/usr/lib64/python2.7/site-packages/yaml/constructor.py", line 37, in get_single_data node = self.get_single_node() File "/usr/lib64/python2.7/site-packages/yaml/composer.py", line 39, in get_single_node if not self.check_event(StreamEndEvent): File "/usr/lib64/python2.7/site-packages/yaml/parser.py", line 98, in check_event self.current_event = self.state() File "/usr/lib64/python2.7/site-packages/yaml/parser.py", line 174, in parse_document_start self.peek_token().start_mark) ParserError: expected '<document start>', but found '<block mapping start>' in "<unicode string>", line 2, column 1: limit-conf-config: ^
解决办法:shell
配置文件的路径配置错误。致使报错。修改配置文件,问题解决。数据库
[root@10-10-121-200 ~]# salt 'linux-backup-saltminion' test.ping Salt request timed out. The master is not responding. If this error persists after verifying the master is up, worker_threads may need to be increased.
解决办法:vim
使用top 查看CPU占用率为百分之百。
下降salt的线程数。centos
mysql> select * from salt_returns; Empty set (0.00 sec)
解决思路:缓存
当遇到问题是能够将log的级别更改成debug模式来调试。
解决办法:
由于是客户端直接返回给数据库,全部客户端须要数据库的链接权限。顾全部数据库都须要添加以下内容:
vim /etc/salt/minion mysql.host: '192.168.2.150' mysql.user: 'salt' mysql.pass: 'salt' mysql.db: 'salt' mysql.port: 3306 [root@centos6 ~]# /etc/init.d/salt-minion restart Stopping salt-minion daemon: [ OK ] Starting salt-minion daemon: [ OK ] [root@centos6 ~]#
root@10.10.121.200 files]# salt '*.service' state.sls ssh.config env=prod chuye.backup1.service: Data failed to compile: ---------- Requisite declaration file.sshd-files in SLS ssh.config is not formed as a single key dictionary ---------- Requisite declaration file.sshd-files in SLS ssh.config is not formed as a single key dictionary chuye.logstash1.service: Data failed to compile: ---------- Requisite declaration file.sshd-files in SLS ssh.config is not formed as a single key dictionary ---------- Requisite declaration file.sshd-files in SLS ssh.config is not formed as a single key dictionary chuye.logstash2.service: Data failed to compile: ---------- Requisite declaration file.sshd-files in SLS ssh.config is not formed as a single key dictionary ---------- Requisite declaration file.sshd-files in SLS ssh.config is not formed as a single key dictionary
解决办法:
- require: - file.sshd-files - watch: - file.sshd-files
上面的值配置错误
- require: - file: sshd-files - watch: - file: sshd-files
---------- ID: zabbix-agent-install Function: file.managed Name: /etc/zabbix_agentd.conf.bak Result: False Comment: Unable to manage file: Jinja variable 'item' is undefined Started: 16:12:39.454923 Duration: 17.407 ms Changes:
解决办法:
Hostname={{ grains[fqdn] }} 没有加引号 Hostname={{ grains['fqdn'] }}
#!/bin/sh -IPADDR=['10.10.86.159'] +IPADDR=chuye.logstash2.service
解决办法:
Solution: Address {{ grains['fqdn_ip4'][0] }} Result: Address 111.111.111.111
---------- ID: prometheus_rules Function: file.recurse Name: /data/app/prometheus/rules Result: False Comment: #### /data/app/prometheus/rules/custom.rules #### Source file salt://prometheus/files/rules/custom.rules?saltenv=prod not found #### /data/app/prometheus/rules/mysqld.rules #### Source file salt://prometheus/files/rules/mysqld.rules?saltenv=prod not found #### /data/app/prometheus/rules/kubelet.rules #### Source file salt://prometheus/files/rules/kubelet.rules?saltenv=prod not found
临时解决办法(清除缓存)
rm -rf /var/cache/salt/master/file_lists/roots/*