這裏將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/*