saltstack操作遠程執行命令報錯:“is running as PID 113257 and was started at”的解決

  執行命令沒有成功:

[root@linux-node1 base]# salt '*' state.sls web.apache
linux-node2.example.com:
----------
          ID: apache-install
    Function: pkg.installed
        Name: httpd
      Result: True
     Comment: Package httpd is already installed
     Started: 13:10:00.987726
    Duration: 5236.443 ms
     Changes:   
----------
          ID: apache-service
    Function: service.running
        Name: httpd
      Result: True
     Comment: The service httpd is already running
     Started: 13:10:06.247097
    Duration: 1438.912 ms
     Changes:   

Summary for linux-node2.example.com
------------
Succeeded: 2
Failed:    0
------------
Total states run:     2
Total run time:   6.675 s
linux-node1.example.com:
    Minion did not return. [No response]

  懷疑是虛擬機裏的連接有點問題。

#測試和minion的連接,發現沒有問題

[root@linux-node1 base]# salt '*' test.ping
linux-node2.example.com:
    True
linux-node1.example.com:
    True

#再次操作遠程執行命令

[root@linux-node1 base]# salt '*' state.sls web.apache
linux-node1.example.com:
    Data failed to compile:
----------
    The function "state.sls" is running as PID 113257 and was started at 2017, Sep 09 13:38:17.636816 with jid 20170909133817636816
linux-node2.example.com:
----------
          ID: apache-install
    Function: pkg.installed
        Name: httpd
      Result: True
     Comment: Package httpd is already installed
     Started: 13:15:57.492704
    Duration: 1505.709 ms
     Changes:   
----------
          ID: apache-service
    Function: service.running
        Name: httpd
      Result: True
     Comment: The service httpd is already running
     Started: 13:15:59.002177
    Duration: 186.313 ms
     Changes:   

Summary for linux-node2.example.com
------------
Succeeded: 2
Failed:    0
------------
Total states run:     2
Total run time:   1.692 s
ERROR: Minions returned with non-zero exit code

  在百度上搜索報錯信息:“is running as PID 113257 and was started at”,找到一篇文檔:http://blog.csdn.net/baidu_25506889/article/details/48050619——The function "state.highstate" is running as PID 4417的解決方法

  根據文章的內容,停掉node1的salt服務:

[root@linux-node1 base]# systemctl stop salt-master
[root@linux-node1 base]# systemctl stop salt-minion
[root@linux-node1 base]# ps -ef|grep salt
root     114208 110544  0 00:03 pts/1    00:00:00 grep --color=auto salt

  重新啓動salt服務:

[root@linux-node1 base]# systemctl start salt-master
[root@linux-node1 base]# systemctl start salt-minion

  報錯信息變了:

[root@linux-node1 base]# salt '*' state.sls web.apache
linux-node2.example.com:
----------
          ID: apache-install
    Function: pkg.installed
        Name: httpd
      Result: True
     Comment: Package httpd is already installed
     Started: 00:04:57.512520
    Duration: 861.558 ms
     Changes:   
----------
          ID: apache-service
    Function: service.running
        Name: httpd
      Result: True
     Comment: The service httpd is already running
     Started: 00:04:58.375123
    Duration: 46.543 ms
     Changes:   

Summary for linux-node2.example.com
------------
Succeeded: 2
Failed:    0
------------
Total states run:     2
Total run time: 908.101 ms
linux-node1.example.com:
----------
          ID: apache-install
    Function: pkg.installed
        Name: httpd
      Result: True
     Comment: Package httpd is already installed
     Started: 00:04:33.162908
    Duration: 844.754 ms
     Changes:   
----------
          ID: apache-service
    Function: service.running
        Name: httpd
      Result: False
     Comment: Running scope as unit run-115498.scope.
              Job for httpd.service failed because the control process exited with error code. See "systemctl status httpd.service" and "journalctl -xe" for details.
     Started: 00:04:34.008627
    Duration: 147.766 ms
     Changes:   

Summary for linux-node1.example.com
------------
Succeeded: 1
Failed:    1
------------
Total states run:     2
Total run time: 992.520 ms
ERROR: Minions returned with non-zero exit code

  突然領悟到可能是“linux-node1”已經運行有80端口。檢查後發現,果然如此。

[root@linux-node1 base]# netstat -lntup
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 0.0.0.0:111             0.0.0.0:*               LISTEN      1/systemd           
tcp        0      0 0.0.0.0:8080            0.0.0.0:*               LISTEN      2786/nginx: master  
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      2786/nginx: master  
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      939/sshd            
tcp        0      0 0.0.0.0:4505            0.0.0.0:*               LISTEN      114225/python       
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      1751/master         
tcp        0      0 0.0.0.0:4506            0.0.0.0:*               LISTEN      114231/python       
tcp        0      0 0.0.0.0:49152           0.0.0.0:*               LISTEN      11064/glusterfsd    
tcp        0      0 0.0.0.0:49153           0.0.0.0:*               LISTEN      11193/glusterfsd    
tcp        0      0 0.0.0.0:49154           0.0.0.0:*               LISTEN      11212/glusterfsd    
tcp        0      0 0.0.0.0:49155           0.0.0.0:*               LISTEN      11338/glusterfsd    
tcp        0      0 0.0.0.0:49156           0.0.0.0:*               LISTEN      11357/glusterfsd    
tcp        0      0 0.0.0.0:24007           0.0.0.0:*               LISTEN      11039/glusterd      
tcp6       0      0 :::111                  :::*                    LISTEN      1/systemd           
tcp6       0      0 :::80                   :::*                    LISTEN      2786/nginx: master  
tcp6       0      0 :::22                   :::*                    LISTEN      939/sshd            
tcp6       0      0 ::1:25                  :::*                    LISTEN      1751/master         
udp        0      0 0.0.0.0:612             0.0.0.0:*                           11037/rpcbind       
udp        0      0 0.0.0.0:111             0.0.0.0:*                           11037/rpcbind       
udp6       0      0 :::612                  :::*                                11037/rpcbind       
udp6       0      0 :::111                  :::*                                11037/rpcbind

  停掉之前運行的nginx服務:

[root@linux-node1 base]# systemctl stop nginx

  這次就成功了:

[root@linux-node1 base]# salt '*' state.sls web.apache
linux-node2.example.com:
----------
          ID: apache-install
    Function: pkg.installed
        Name: httpd
      Result: True
     Comment: Package httpd is already installed
     Started: 00:05:43.237868
    Duration: 920.891 ms
     Changes:   
----------
          ID: apache-service
    Function: service.running
        Name: httpd
      Result: True
     Comment: The service httpd is already running
     Started: 00:05:44.159808
    Duration: 57.373 ms
     Changes:   

Summary for linux-node2.example.com
------------
Succeeded: 2
Failed:    0
------------
Total states run:     2
Total run time: 978.264 ms
linux-node1.example.com:
----------
          ID: apache-install
    Function: pkg.installed
        Name: httpd
      Result: True
     Comment: Package httpd is already installed
     Started: 00:05:16.506796
    Duration: 1640.554 ms
     Changes:   
----------
          ID: apache-service
    Function: service.running
        Name: httpd
      Result: True
     Comment: Service httpd has been enabled, and is running
     Started: 00:05:18.148225
    Duration: 372.124 ms
     Changes:   
              ----------
              httpd:
                  True

Summary for linux-node1.example.com
------------
Succeeded: 2 (changed=1)
Failed:    0
------------
Total states run:     2
Total run time:   2.013 s


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章