yum安裝salt-ssh報錯:html
[root@linux-node1 yum.repos.d]# yum install salt-ssh -y 已加載插件:fastestmirror base | 3.6 kB 00:00:00 epel | 4.7 kB 00:00:00 extras | 3.4 kB 00:00:00 updates | 3.4 kB 00:00:00 Loading mirror speeds from cached hostfile 正在解決依賴關係 --> 正在檢查事務 ---> 軟件包 salt-ssh.noarch.0.2015.5.10-2.el7 將被 安裝 --> 正在處理依賴關係 salt = 2015.5.10-2.el7,它被軟件包 salt-ssh-2015.5.10-2.el7.noarch 須要 --> 解決依賴關係完成 錯誤:軟件包:salt-ssh-2015.5.10-2.el7.noarch (epel) 須要:salt = 2015.5.10-2.el7 已安裝: salt-2017.7.1-1.el7.noarch (@salt-latest) salt = 2017.7.1-1.el7 可用: salt-2015.5.10-2.el7.noarch (epel) salt = 2015.5.10-2.el7 您能夠嘗試添加 --skip-broken 選項來解決該問題 您能夠嘗試執行:rpm -Va --nofiles --nodigest
根據報錯提示加上參數「--skip-broken」,執行結果失敗。
node
[root@linux-node1 yum.repos.d]# yum install salt-ssh -y --skip-broken 已加載插件:fastestmirror Loading mirror speeds from cached hostfile 正在解決依賴關係 --> 正在檢查事務 ---> 軟件包 salt-ssh.noarch.0.2015.5.10-2.el7 將被 安裝 --> 正在處理依賴關係 salt = 2015.5.10-2.el7,它被軟件包 salt-ssh-2015.5.10-2.el7.noarch 須要 由於依賴關係問題而跳過的軟件包: salt-ssh-2015.5.10-2.el7.noarch 來自 epel
根據報錯提示執行命令,再執行yum安裝仍是失敗。
python
[root@linux-node1 yum.repos.d]# rpm -Va --nofiles --nodigest [root@linux-node1 yum.repos.d]# yum install salt-ssh -y 已加載插件:fastestmirror Loading mirror speeds from cached hostfile 正在解決依賴關係 --> 正在檢查事務 ---> 軟件包 salt-ssh.noarch.0.2015.5.10-2.el7 將被 安裝 --> 正在處理依賴關係 salt = 2015.5.10-2.el7,它被軟件包 salt-ssh-2015.5.10-2.el7.noarch 須要 --> 解決依賴關係完成 錯誤:軟件包:salt-ssh-2015.5.10-2.el7.noarch (epel) 須要:salt = 2015.5.10-2.el7 已安裝: salt-2017.7.1-1.el7.noarch (@salt-latest) salt = 2017.7.1-1.el7 可用: salt-2015.5.10-2.el7.noarch (epel) salt = 2015.5.10-2.el7 您能夠嘗試添加 --skip-broken 選項來解決該問題 您能夠嘗試執行:rpm -Va --nofiles --nodigest
根據網友的幫助,直接下載salt-ssh命令:mysql
[root@linux-node1 yum.repos.d]# wget ftp://mirror.switch.ch/pool/4/mirror/epel/7/ppc64/Packages/s/salt-ssh-2015.5.10-2.el7.noarch.rpm --2018-04-10 13:44:35-- ftp://mirror.switch.ch/pool/4/mirror/epel/7/ppc64/Packages/s/salt-ssh-2015.5.10-2.el7.noarch.rpm => 「salt-ssh-2015.5.10-2.el7.noarch.rpm」 正在解析主機 mirror.switch.ch (mirror.switch.ch)... 130.59.113.36, 2001:620:0:1002::20 正在鏈接 mirror.switch.ch (mirror.switch.ch)|130.59.113.36|:21... 已鏈接。 正在以 anonymous 登陸 ... 登陸成功! ==> SYST ... 完成。 ==> PWD ... 完成。 ==> TYPE I ... 完成。 ==> CWD (1) /pool/4/mirror/epel/7/ppc64/Packages/s ... 完成。 ==> SIZE salt-ssh-2015.5.10-2.el7.noarch.rpm ... 15108 ==> PASV ... 完成。 ==> RETR salt-ssh-2015.5.10-2.el7.noarch.rpm ... 完成。 長度:15108 (15K) (非正式數據) 100%[=============================================================================================>] 15,108 22.0KB/s 用時 0.7s 2018-04-10 13:44:40 (22.0 KB/s) - 「salt-ssh-2015.5.10-2.el7.noarch.rpm」 已保存 [15108]
rpm安裝失敗:linux
[root@linux-node1 yum.repos.d]# rpm -ivh salt-ssh-2015.5.10-2.el7.noarch.rpm 錯誤:依賴檢測失敗: salt = 2015.5.10-2.el7 被 salt-ssh-2015.5.10-2.el7.noarch 須要
rpm安裝失敗:加參數「--force」(忽略軟件包及文件的衝突)
web
[root@linux-node1 yum.repos.d]# rpm -ivh salt-ssh-2015.5.10-2.el7.noarch.rpm --force 錯誤:依賴檢測失敗: salt = 2015.5.10-2.el7 被 salt-ssh-2015.5.10-2.el7.noarch 須要
rpm安裝成功:再加參數「--nodeps」(不檢查依賴性關係)sql
[root@linux-node1 yum.repos.d]# rpm -ivh salt-ssh-2015.5.10-2.el7.noarch.rpm --force --nodeps 準備中... ################################# [100%] 正在升級/安裝... 1:salt-ssh-2015.5.10-2.el7 ################################# [100%]
參考文檔:https://www.cnblogs.com/vathe/p/6736104.html——CentOS下rpm命令詳解數據庫
salt-ssh配置文件修改結果:apache
[root@linux-node1 yum.repos.d]# cd ~ [root@linux-node1 ~]# cat /etc/salt/roster # Sample salt-ssh config file #web1: # host: 192.168.42.1 # The IP addr or DNS hostname # user: fred # Remote executions will be executed as user fred # passwd: foobarbaz # The password to use for login, if omitted, keys are used # sudo: True # Whether to sudo to root, not enabled by default #web2: # host: 192.168.42.2 linux-node1: host: 192.168.56.11 user: root passwd: 123123 port: 22 linux-node2: host: 192.168.56.12 user: root passwd: 123123 port: 22
執行salt-ssh命令失敗:centos
[root@linux-node1 ~]# salt-ssh '*' test.ping [ERROR ] MySQL returner could not connect to database: (1045, "Access denied for user 'root'@'linux-node1' (using password: YES)") Traceback (most recent call last): File "/usr/lib/python2.7/site-packages/salt/client/ssh/__init__.py", line 617, in run self.returners['{0}.save_load'.format(self.opts['master_job_cache'])](jid, job_load) File "/usr/lib/python2.7/site-packages/salt/returners/mysql.py", line 321, in save_load with _get_serv(commit=True) as cur: File "/usr/lib64/python2.7/contextlib.py", line 17, in __enter__ return self.gen.next() File "/usr/lib/python2.7/site-packages/salt/returners/mysql.py", line 258, in _get_serv raise salt.exceptions.SaltMasterError('MySQL returner could not connect to database: {exc}'.format(exc=exc)) SaltMasterError: MySQL returner could not connect to database: (1045, "Access denied for user 'root'@'linux-node1' (using password: YES)") [ERROR ] Could not save load with returner mysql: MySQL returner could not connect to database: (1045, "Access denied for user 'root'@'linux-node1' (using password: YES)") [CRITICAL] MySQL returner could not connect to database: (1045, "Access denied for user 'root'@'linux-node1' (using password: YES)") [CRITICAL] Could not store return with MySQL returner. MySQL server unavailable. linux-node1: ---------- retcode: 254 stderr: stdout: The host key needs to be accepted, to auto accept run salt-ssh with the -i flag: The authenticity of host '192.168.56.11 (192.168.56.11)' can't be established. ECDSA key fingerprint is 2d:a2:8e:9e:5a:5c:fb:94:ac:80:ba:fa:7f:9e:3c:cd. Are you sure you want to continue connecting (yes/no)? [CRITICAL] MySQL returner could not connect to database: (1045, "Access denied for user 'root'@'linux-node1' (using password: YES)") [CRITICAL] Could not store return with MySQL returner. MySQL server unavailable. linux-node2: True
此時yum安裝salt-ssh,提示已安裝此命令:
[root@linux-node1 ~]# yum -y install salt-ssh 已加載插件:fastestmirror Loading mirror speeds from cached hostfile 軟件包 salt-ssh-2015.5.10-2.el7.noarch 已安裝而且是最新版本 無須任何處理
經過yum方式刪除前面經過rpm安裝的salt-ssh命令:
[root@linux-node1 ~]# yum remove salt-ssh-2015.5.10-2.el7.noarch 已加載插件:fastestmirror 正在解決依賴關係 --> 正在檢查事務 ---> 軟件包 salt-ssh.noarch.0.2015.5.10-2.el7 將被 刪除 --> 解決依賴關係完成 依賴關係解決 ======================================================================================================================================= Package 架構 版本 源 大小 ======================================================================================================================================= 正在刪除: salt-ssh noarch 2015.5.10-2.el7 installed 3.1 k 事務概要 ======================================================================================================================================= 移除 1 軟件包 安裝大小:3.1 k 是否繼續?[y/N]:y Downloading packages: Running transaction check Running transaction test Transaction test succeeded Running transaction 警告:RPM 數據庫已被非 yum 程序修改。 正在刪除 : salt-ssh-2015.5.10-2.el7.noarch 1/1 驗證中 : salt-ssh-2015.5.10-2.el7.noarch 1/1 刪除: salt-ssh.noarch 0:2015.5.10-2.el7 完畢!
yum安裝salt-ssh命令的問題復現:
[root@linux-node1 ~]# yum -y install salt-ssh 已加載插件:fastestmirror Loading mirror speeds from cached hostfile 正在解決依賴關係 --> 正在檢查事務 ---> 軟件包 salt-ssh.noarch.0.2015.5.10-2.el7 將被 安裝 --> 正在處理依賴關係 salt = 2015.5.10-2.el7,它被軟件包 salt-ssh-2015.5.10-2.el7.noarch 須要 --> 解決依賴關係完成 錯誤:軟件包:salt-ssh-2015.5.10-2.el7.noarch (epel) 須要:salt = 2015.5.10-2.el7 已安裝: salt-2017.7.1-1.el7.noarch (@salt-latest) salt = 2017.7.1-1.el7 可用: salt-2015.5.10-2.el7.noarch (epel) salt = 2015.5.10-2.el7 您能夠嘗試添加 --skip-broken 選項來解決該問題 您能夠嘗試執行:rpm -Va --nofiles --nodigest
經過yum方式刪除前面命令執行輸出裏提到的「已安裝」包:
[root@linux-node1 ~]# yum remove salt-2017.7.1-1.el7.noarch 已加載插件:fastestmirror 正在解決依賴關係 --> 正在檢查事務 ---> 軟件包 salt.noarch.0.2017.7.1-1.el7 將被 刪除 --> 正在處理依賴關係 salt = 2017.7.1-1.el7,它被軟件包 salt-minion-2017.7.1-1.el7.noarch 須要 --> 正在處理依賴關係 salt = 2017.7.1-1.el7,它被軟件包 salt-master-2017.7.1-1.el7.noarch 須要 --> 正在檢查事務 ---> 軟件包 salt-master.noarch.0.2017.7.1-1.el7 將被 刪除 ---> 軟件包 salt-minion.noarch.0.2017.7.1-1.el7 將被 刪除 --> 解決依賴關係完成 依賴關係解決 ======================================================================================================================================= Package 架構 版本 源 大小 ======================================================================================================================================= 正在刪除: salt noarch 2017.7.1-1.el7 @salt-latest 36 M 爲依賴而移除: salt-master noarch 2017.7.1-1.el7 @salt-latest 1.6 M salt-minion noarch 2017.7.1-1.el7 @salt-latest 69 k 事務概要 ======================================================================================================================================= 移除 1 軟件包 (+2 依賴軟件包) 安裝大小:38 M 是否繼續?[y/N]:y Downloading packages: Running transaction check Running transaction test Transaction test succeeded Running transaction 正在刪除 : salt-minion-2017.7.1-1.el7.noarch 1/3 警告:/etc/salt/minion 已另存爲 /etc/salt/minion.rpmsave 正在刪除 : salt-master-2017.7.1-1.el7.noarch 2/3 警告:/etc/salt/master 已另存爲 /etc/salt/master.rpmsave 正在刪除 : salt-2017.7.1-1.el7.noarch 3/3 警告:/etc/salt/roster 已另存爲 /etc/salt/roster.rpmsave 驗證中 : salt-2017.7.1-1.el7.noarch 1/3 驗證中 : salt-master-2017.7.1-1.el7.noarch 2/3 驗證中 : salt-minion-2017.7.1-1.el7.noarch 3/3 刪除: salt.noarch 0:2017.7.1-1.el7 做爲依賴被刪除: salt-master.noarch 0:2017.7.1-1.el7 salt-minion.noarch 0:2017.7.1-1.el7 完畢!
經過命令輸出發現,master和minion包好像也被刪除了。
yum安裝salt-ssh成功:
[root@linux-node1 ~]# yum -y install salt-ssh 已加載插件:fastestmirror Loading mirror speeds from cached hostfile 正在解決依賴關係 --> 正在檢查事務 ---> 軟件包 salt-ssh.noarch.0.2015.5.10-2.el7 將被 安裝 --> 正在處理依賴關係 salt = 2015.5.10-2.el7,它被軟件包 salt-ssh-2015.5.10-2.el7.noarch 須要 --> 正在檢查事務 ---> 軟件包 salt.noarch.0.2015.5.10-2.el7 將被 安裝 --> 正在處理依賴關係 m2crypto,它被軟件包 salt-2015.5.10-2.el7.noarch 須要 --> 正在檢查事務 ---> 軟件包 m2crypto.x86_64.0.0.21.1-17.el7 將被 安裝 --> 解決依賴關係完成 依賴關係解決 ======================================================================================================================================= Package 架構 版本 源 大小 ======================================================================================================================================= 正在安裝: salt-ssh noarch 2015.5.10-2.el7 epel 15 k 爲依賴而安裝: m2crypto x86_64 0.21.1-17.el7 base 429 k salt noarch 2015.5.10-2.el7 epel 4.1 M 事務概要 ======================================================================================================================================= 安裝 1 軟件包 (+2 依賴軟件包) 總下載量:4.5 M 安裝大小:20 M Downloading packages: (1/3): salt-ssh-2015.5.10-2.el7.noarch.rpm | 15 kB 00:00:00 (2/3): m2crypto-0.21.1-17.el7.x86_64.rpm | 429 kB 00:00:06 (3/3): salt-2015.5.10-2.el7.noarch.rpm | 4.1 MB 00:00:09 --------------------------------------------------------------------------------------------------------------------------------------- 總計 476 kB/s | 4.5 MB 00:00:09 Running transaction check Running transaction test Transaction test succeeded Running transaction 正在安裝 : m2crypto-0.21.1-17.el7.x86_64 1/3 正在安裝 : salt-2015.5.10-2.el7.noarch 2/3 正在安裝 : salt-ssh-2015.5.10-2.el7.noarch 3/3 驗證中 : salt-2015.5.10-2.el7.noarch 1/3 驗證中 : salt-ssh-2015.5.10-2.el7.noarch 2/3 驗證中 : m2crypto-0.21.1-17.el7.x86_64 3/3 已安裝: salt-ssh.noarch 0:2015.5.10-2.el7 做爲依賴被安裝: m2crypto.x86_64 0:0.21.1-17.el7 salt.noarch 0:2015.5.10-2.el7 完畢!
直接執行salt命令已沒法執行,master和minion包應該是被刪除了。
[root@linux-node1 ~]# salt '*' test.ping -bash: salt: 未找到命令
從新修改/etc/salt/roster文件後,測試salt-ssh:
[root@linux-node1 ~]# salt-ssh '*' test.ping linux-node2: True linux-node1: True
按照以前講解的部署saltstack的步驟從新yum安裝salt-master(yum install salt-master -y)和salt-minion(yum install salt-minion -y),並修改/etc/salt/minion配置文件,分別啓動salt-master(systemctl start salt-master)和salt-minion(systemctl start salt-minion),便可恢復正常使用salt-master和salt-minion。
[root@linux-node1 ~]# salt '*' test.ping linux-node1.example.com: True linux-node2.example.com: True
salt-master和salt-minion恢復正常後,測試salt-ssh也沒有問題:
[root@linux-node1 ~]# salt-ssh '*' test.ping linux-node1: True linux-node2: True
在後面深刻學習saltstack「配置管理」時,執行salt命令:「salt '*' state.highstate」,出現嚴重報錯。
[root@linux-node1 web]# salt '*' state.highstate linux-node2.example.com: Data failed to compile: ---------- Traceback (most recent call last): File "/usr/lib/python2.7/site-packages/salt/state.py", line 3629, in call_highstate top = self.get_top() File "/usr/lib/python2.7/site-packages/salt/state.py", line 3089, in get_top tops = self.get_tops() File "/usr/lib/python2.7/site-packages/salt/state.py", line 2787, in get_tops saltenv File "/usr/lib/python2.7/site-packages/salt/fileclient.py", line 189, in cache_file return self.get_url(path, '', True, saltenv, cachedir=cachedir) File "/usr/lib/python2.7/site-packages/salt/fileclient.py", line 495, in get_url result = self.get_file(url, dest, makedirs, saltenv, cachedir=cachedir) File "/usr/lib/python2.7/site-packages/salt/fileclient.py", line 1044, in get_file hash_server, stat_server = self.hash_and_stat_file(path, saltenv) TypeError: 'bool' object is not iterable linux-node1.example.com: ---------- ID: states Function: no.None Result: False Comment: No Top file or external nodes data matches found. Started: Duration: Changes: Summary ------------ Succeeded: 0 Failed: 1 ------------ Total states run: 1 ERROR: Minions returned with non-zero exit code
在上面的報錯輸出信息裏,「linux-node1.example.com」節點的關鍵信息是「No Top file or external nodes data matches found.」。這個問題一直沒有處理,但在梳理完前面的saltstack筆記後,這個報錯信息本身消失。(在沒有對這個節點作任何修改的狀況下,後面執行「salt 'linux-node1*' state.highstate」命令,自行恢復正常。)
[root@linux-node1 web]# salt 'linux-node1*' state.highstate linux-node1.example.com: ---------- ID: apache-install Function: pkg.installed Name: httpd Result: True Comment: Package httpd is already installed. Started: 14:27:16.058668 Duration: 1902.564 ms Changes: ---------- ID: apache-service Function: service.running Name: httpd Result: True Comment: Service httpd is already enabled, and is in the desired state Started: 14:27:17.962102 Duration: 418.927 ms Changes: Summary ------------ Succeeded: 2 Failed: 0 ------------ Total states run: 2
下面着重說明「linux-node2.example.com」節點的故障處理:
因爲執行「salt '*' test.ping」命令是正常的輸出,最初就懷疑刪除又從新安裝master和minion包,致使有配置文件被從新安裝包後,默認的配置文件會覆蓋原有的配置文件。通過梳理前面整理過的筆記,發現這個懷疑幾乎能夠排除。
[root@linux-node1 web]# salt '*' test.ping linux-node2.example.com: True linux-node1.example.com: True
不過,在梳理以前的saltstack筆記時,測試執行1條命令帶給我新的發現:
[root@linux-node1 salt]# salt '*' grains.get saltversion linux-node2.example.com: 2017.7.1 linux-node1.example.com: 2015.5.10
執行命令的輸出結果說明,2個節點的saltstack版本是不同的。回看本文前面執行「yum remove salt-2017.7.1-1.el7.noarch」命令和從新執行「yum install salt-minion -y」命令的輸出,基本也能作出這樣的判斷。
此時,我惟一能作的,就是把「linux-node2.example.com」節點的minion也刪除從新安裝試一試。
找到salt-minion配置文件的路徑,先把minion文件備份:
[root@linux-node2 ~]# cd /etc/salt/ [root@linux-node2 salt]# ll 總用量 124 -rw-r----- 1 root root 2624 8月 8 2017 cloud drwxr-xr-x 2 root root 6 8月 8 2017 cloud.conf.d drwxr-xr-x 2 root root 6 8月 8 2017 cloud.deploy.d drwxr-xr-x 2 root root 6 8月 8 2017 cloud.maps.d drwxr-xr-x 2 root root 6 8月 8 2017 cloud.profiles.d drwxr-xr-x 2 root root 6 8月 8 2017 cloud.providers.d -rw-r----- 1 root root 48789 8月 8 2017 master drwxr-xr-x 2 root root 6 8月 8 2017 master.d -rw-r----- 1 root root 34879 11月 9 19:21 minion drwxr-xr-x 2 root root 27 9月 5 2017 minion.d -rw-r--r-- 1 root root 23 9月 5 2017 minion_id drwxr-xr-x 4 root root 32 9月 4 2017 pki -rw-r----- 1 root root 28002 8月 8 2017 proxy drwxr-xr-x 2 root root 6 8月 8 2017 proxy.d -rw-r----- 1 root root 344 8月 8 2017 roster [root@linux-node2 salt]# cp minion /tmp/
刪除minion:
[root@linux-node2 salt]# yum -y remove salt-minion 已加載插件:fastestmirror Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast 正在解決依賴關係 --> 正在檢查事務 ---> 軟件包 salt-minion.noarch.0.2017.7.1-1.el7 將被 刪除 --> 解決依賴關係完成 依賴關係解決 ======================================================================================================================================= Package 架構 版本 源 大小 ======================================================================================================================================= 正在刪除: salt-minion noarch 2017.7.1-1.el7 @salt-latest 69 k 事務概要 ======================================================================================================================================= 移除 1 軟件包 安裝大小:69 k Downloading packages: Running transaction check Running transaction test Transaction test succeeded Running transaction 正在刪除 : salt-minion-2017.7.1-1.el7.noarch 1/1 驗證中 : salt-minion-2017.7.1-1.el7.noarch 1/1 刪除: salt-minion.noarch 0:2017.7.1-1.el7 完畢!
從新安裝salt-minion居然失敗:緣由「似曾相識」
[root@linux-node2 salt]# yum install salt-minion -y 已加載插件:fastestmirror Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast base | 3.6 kB 00:00:00 centos-openstack-pike | 2.9 kB 00:00:00 centos-qemu-ev | 2.9 kB 00:00:00 epel/x86_64/metalink | 8.2 kB 00:00:00 epel | 4.7 kB 00:00:00 extras | 3.4 kB 00:00:00 updates | 3.4 kB 00:00:00 epel/x86_64/updateinfo FAILED http://mirrors.nipa.cloud/epel/7/x86_64/repodata/0cf4a4a36afabff928c5aca5da8cc4cb50174d29fdec7dc56db18310146df319-updateinfo.xml.bz2: [Errno 14] HTTP Error 404 - Not Found 正在嘗試其它鏡像。 To address this issue please refer to the below knowledge base article https://access.redhat.com/articles/1320623 If above article doesn't help to resolve this issue please create a bug on https://bugs.centos.org/ (1/7): centos-qemu-ev/7/x86_64/primary_db | 37 kB 00:00:01 (2/7): epel/x86_64/group_gz | 266 kB 00:00:04 (3/7): extras/7/x86_64/primary_db | 185 kB 00:00:04 (4/7): epel/x86_64/updateinfo | 909 kB 00:00:12 (5/7): updates/7/x86_64/primary_db | 6.9 MB 00:00:19 (6/7): centos-openstack-pike/x86_64/primary_db | 1.0 MB 00:00:26 (7/7): epel/x86_64/primary_db | 6.3 MB 00:00:38 Determining fastest mirrors * base: mirror.bit.edu.cn * epel: mirror01.idc.hinet.net * extras: mirrors.cn99.com * updates: mirror.bit.edu.cn 正在解決依賴關係 --> 正在檢查事務 ---> 軟件包 salt-minion.noarch.0.2015.5.10-2.el7 將被 安裝 --> 正在處理依賴關係 salt = 2015.5.10-2.el7,它被軟件包 salt-minion-2015.5.10-2.el7.noarch 須要 --> 解決依賴關係完成 錯誤:軟件包:salt-minion-2015.5.10-2.el7.noarch (epel) 須要:salt = 2015.5.10-2.el7 已安裝: salt-2017.7.1-1.el7.noarch (@salt-latest) salt = 2017.7.1-1.el7 可用: salt-2015.5.10-2.el7.noarch (epel) salt = 2015.5.10-2.el7 您能夠嘗試添加 --skip-broken 選項來解決該問題 您能夠嘗試執行:rpm -Va --nofiles --nodigest
這個刪除包的操做以前在「linux-node1」上也執行過,算是這個問題的核心了。
[root@linux-node2 salt]# yum -y remove salt-2017.7.1-1.el7.noarch 已加載插件:fastestmirror 正在解決依賴關係 --> 正在檢查事務 ---> 軟件包 salt.noarch.0.2017.7.1-1.el7 將被 刪除 --> 解決依賴關係完成 依賴關係解決 ======================================================================================================================================= Package 架構 版本 源 大小 ======================================================================================================================================= 正在刪除: salt noarch 2017.7.1-1.el7 @salt-latest 36 M 事務概要 ======================================================================================================================================= 移除 1 軟件包 安裝大小:36 M Downloading packages: Running transaction check Running transaction test Transaction test succeeded Running transaction 正在刪除 : salt-2017.7.1-1.el7.noarch 1/1 警告:/etc/salt/minion 已另存爲 /etc/salt/minion.rpmsave 驗證中 : salt-2017.7.1-1.el7.noarch 1/1 刪除: salt.noarch 0:2017.7.1-1.el7 完畢!
再安裝minion成功:
[root@linux-node2 salt]# yum install salt-minion -y 已加載插件:fastestmirror Loading mirror speeds from cached hostfile * base: mirror.bit.edu.cn * epel: mirror01.idc.hinet.net * extras: mirrors.cn99.com * updates: mirror.bit.edu.cn 正在解決依賴關係 --> 正在檢查事務 ---> 軟件包 salt-minion.noarch.0.2015.5.10-2.el7 將被 安裝 --> 正在處理依賴關係 salt = 2015.5.10-2.el7,它被軟件包 salt-minion-2015.5.10-2.el7.noarch 須要 --> 正在檢查事務 ---> 軟件包 salt.noarch.0.2015.5.10-2.el7 將被 安裝 --> 正在處理依賴關係 m2crypto,它被軟件包 salt-2015.5.10-2.el7.noarch 須要 --> 正在檢查事務 ---> 軟件包 m2crypto.x86_64.0.0.21.1-17.el7 將被 安裝 --> 解決依賴關係完成 依賴關係解決 ======================================================================================================================================= Package 架構 版本 源 大小 ======================================================================================================================================= 正在安裝: salt-minion noarch 2015.5.10-2.el7 epel 26 k 爲依賴而安裝: m2crypto x86_64 0.21.1-17.el7 base 429 k salt noarch 2015.5.10-2.el7 epel 4.1 M 事務概要 ======================================================================================================================================= 安裝 1 軟件包 (+2 依賴軟件包) 總下載量:4.5 M 安裝大小:20 M Downloading packages: (1/3): m2crypto-0.21.1-17.el7.x86_64.rpm | 429 kB 00:00:00 (2/3): salt-minion-2015.5.10-2.el7.noarch.rpm | 26 kB 00:00:00 (3/3): salt-2015.5.10-2.el7.noarch.rpm | 4.1 MB 00:00:08 --------------------------------------------------------------------------------------------------------------------------------------- 總計 511 kB/s | 4.5 MB 00:00:09 Running transaction check Running transaction test Transaction test succeeded Running transaction 正在安裝 : m2crypto-0.21.1-17.el7.x86_64 1/3 正在安裝 : salt-2015.5.10-2.el7.noarch 2/3 正在安裝 : salt-minion-2015.5.10-2.el7.noarch 3/3 驗證中 : salt-2015.5.10-2.el7.noarch 1/3 驗證中 : salt-minion-2015.5.10-2.el7.noarch 2/3 驗證中 : m2crypto-0.21.1-17.el7.x86_64 3/3 已安裝: salt-minion.noarch 0:2015.5.10-2.el7 做爲依賴被安裝: m2crypto.x86_64 0:0.21.1-17.el7 salt.noarch 0:2015.5.10-2.el7 完畢!
從新安裝的minion,它的默認配置文件(這個salt版本比較舊)和以前的minion配置文件(這個salt版本比較新)差別不小。這裏備份一下。
[root@linux-node2 salt]# mv minion /tmp/minion.ori
把以前備份的minion配置文件覆蓋現有的配置文件:
[root@linux-node2 salt]# mv /tmp/minion .
啓動minion服務:
[root@linux-node2 salt]# systemctl start salt-minion
在linux-node1節點上測試,只測試「node2」:
[root@linux-node1 web]# salt 'linux-node2*' state.highstate linux-node2.example.com: ---------- ID: apache-install Function: pkg.installed Name: httpd Result: True Comment: Package httpd is already installed. Started: 14:54:50.795000 Duration: 1276.067 ms Changes: ---------- ID: apache-service Function: service.running Name: httpd Result: True Comment: Service httpd is already enabled, and is in the desired state Started: 14:54:52.071785 Duration: 351.635 ms Changes: Summary ------------ Succeeded: 2 Failed: 0 ------------ Total states run: 2
已經成功。
執行最初的報錯命令「salt '*' state.highstate」:也是成功的。
[root@linux-node1 web]# salt '*' state.highstate linux-node2.example.com: ---------- ID: apache-install Function: pkg.installed Name: httpd Result: True Comment: Package httpd is already installed. Started: 14:55:14.326489 Duration: 1508.146 ms Changes: ---------- ID: apache-service Function: service.running Name: httpd Result: True Comment: Service httpd is already enabled, and is in the desired state Started: 14:55:15.835477 Duration: 368.446 ms Changes: Summary ------------ Succeeded: 2 Failed: 0 ------------ Total states run: 2 linux-node1.example.com: ---------- ID: apache-install Function: pkg.installed Name: httpd Result: True Comment: Package httpd is already installed. Started: 14:55:14.582278 Duration: 5233.738 ms Changes: ---------- ID: apache-service Function: service.running Name: httpd Result: True Comment: Service httpd is already enabled, and is in the desired state Started: 14:55:19.831056 Duration: 396.626 ms Changes: Summary ------------ Succeeded: 2 Failed: 0 ------------ Total states run: 2
再次測試salt-ssh,也沒有問題:
[root@linux-node1 web]# salt-ssh '*' test.ping linux-node2: True linux-node1: True
最後的說明:2個版本的master和minion配置文件,裏面的內容差別很大。爲了儘快解決這個問題,這裏就直接使用刪除master、minion前的配置文件覆蓋從新安裝後配置文件。
至於具體的差別,之後再說。