[root@centos6 ~]# salt-key Accepted Keys: Denied Keys: Unaccepted Keys: centos6.6-mupan minion.saltstack.com Rejected Keys: [root@centos6 ~]# salt-key -a minion.saltstack.com ####允许客户端连入服务器。 The following keys are going to be accepted: Unaccepted Keys: minion.saltstack.com Proceed? [n/Y] y Key for minion minion.saltstack.com accepted. [root@centos6 ~]#
salt '*' test.ping salt '*.example.net' test.ping salt '*.example.*' test.ping salt 'web?.example.net' test.ping salt 'web[1-5]' test.ping salt 'web[1,3]' test.ping salt 'web-[x-z]' test.ping
[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: ^
解决办法:
配置文件的路径配置错误。导致报错。修改配置文件,问题解决。
报错:saltstack 执行后CPU占用率为百分之百。
1 2
[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.
解决办法:
使用top 查看CPU占用率为百分之百。 降低salt的线程数。
报错:配置完return后,不能向数据库写入数据:
1 2
mysql> select * from salt_returns; Empty set (0.00 sec)
解决思路:
当遇到问题是可以将log的级别更改为debug模式来调试。
解决办法:
因为是客户端直接返回给数据库,所有客户端需要数据库的连接权限。顾所有数据库都需要添加如下内容:
1 2 3 4 5 6 7 8 9 10 11
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 ~]#
报错: 执行state.sls 报错
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
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