日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

saltStack运维工具的部署及master迁移实现的过程详解

發布時間:2025/6/15 编程问答 20 豆豆
生活随笔 收集整理的這篇文章主要介紹了 saltStack运维工具的部署及master迁移实现的过程详解 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
服務器端:192.168.3.87
客戶端:192.168.3.86、192.168.3.108


1.salt服務器端安裝 192.168.3.87

rpm -Uvh http://mirrors.yun-idc.com/epel/6Server/x86_64/epel-release-6-8.noarch.rpm
yum install -y salt-master

2.安裝minion客戶端
rpm -Uvh http://mirrors.yun-idc.com/epel/6Server/x86_64/epel-release-6-8.noarch.rpm
yum install -y salt-minion


報錯:
--> Finished Dependency Resolution
Error: Package: salt-2015.5.10-2.el6.noarch (epel)
? ? ? ? ? ?Requires: PyYAML
Error: Package: salt-2015.5.10-2.el6.noarch (epel)
? ? ? ? ? ?Requires: m2crypto
Error: Package: salt-2015.5.10-2.el6.noarch (epel)
? ? ? ? ? ?Requires: python-requests
Error: Package: salt-2015.5.10-2.el6.noarch (epel)
? ? ? ? ? ?Requires: python-jinja2
?You could try using --skip-broken to work around the problem
?You could try running: rpm -Va --nofiles --nodigest


解決辦法:
將所有的本地源刪除,只保留系統和epel源,重新安裝即可

3.客戶端配置salt master dns解析
echo "192.168.3.87 salt" >>/etc/hosts

啟動服務端
service salt-master start


可以將服務端debug功能打開
vim /etc/salt/master
log_level: debug


netstat -lnt
可以看到4506和4505兩個端口已經開始監聽
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address ? ? ? ? ? ? ? Foreign Address ? ? ? ? ? ? State ? ? ?
tcp ? ? ? ?0 ? ? ?0 0.0.0.0:111 ? ? ? ? ? ? ? ? 0.0.0.0:* ? ? ? ? ? ? ? ? ? LISTEN ? ? ?
tcp ? ? ? ?0 ? ? ?0 0.0.0.0:22 ? ? ? ? ? ? ? ? ?0.0.0.0:* ? ? ? ? ? ? ? ? ? LISTEN ? ? ?
tcp ? ? ? ?0 ? ? ?0 0.0.0.0:57718 ? ? ? ? ? ? ? 0.0.0.0:* ? ? ? ? ? ? ? ? ? LISTEN ? ? ?
tcp ? ? ? ?0 ? ? ?0 127.0.0.1:631 ? ? ? ? ? ? ? 0.0.0.0:* ? ? ? ? ? ? ? ? ? LISTEN ? ? ?
tcp ? ? ? ?0 ? ? ?0 0.0.0.0:4505 ? ? ? ? ? ? ? ?0.0.0.0:* ? ? ? ? ? ? ? ? ? LISTEN ? ? ?
tcp ? ? ? ?0 ? ? ?0 127.0.0.1:25 ? ? ? ? ? ? ? ?0.0.0.0:* ? ? ? ? ? ? ? ? ? LISTEN ? ? ?
tcp ? ? ? ?0 ? ? ?0 0.0.0.0:4506 ? ? ? ? ? ? ? ?0.0.0.0:* ? ? ? ? ? ? ? ? ? LISTEN ? ? ?
tcp ? ? ? ?0 ? ? ?0 0.0.0.0:10050 ? ? ? ? ? ? ? 0.0.0.0:* ? ? ? ? ? ? ? ? ? LISTEN ? ? ?
tcp ? ? ? ?0 ? ? ?0 0.0.0.0:3306 ? ? ? ? ? ? ? ?0.0.0.0:* ? ? ? ? ? ? ? ? ? LISTEN?


客戶端的salt文件列表
tree /etc/salt
/etc/salt
├── minion
├── minion.d
│ ? └── _schedule.conf
├── minion_id
└── pki
? ? └── minion
? ? ? ? ├── minion_master.pub
? ? ? ? ├── minion.pem
? ? ? ? └── minion.pub




列出所有的客戶端
salt-key -L
Accepted Keys:
Denied Keys:
Unaccepted Keys:
centossz008
Rejected Keys:
添加指定客戶端
[root@node2 test]# salt-key -a centossz008?
The following keys are going to be accepted:
Unaccepted Keys:
centossz008
Proceed? [n/Y] y
Key for minion centossz008 accepted.


添加指定客戶端無需確認
salt-key -A 192.168.3.108 -y
The following keys are going to be accepted:
Unaccepted Keys:
192.168.3.108
Key for minion 192.168.3.108 accepted.


測試連通性
salt '*' test.ping
192.168.3.108:
? ? True
centossz008:
? ? True


批量執行命令:
查看時間
salt '*' cmd.run date
時間同步
salt '*' cmd.run 'ntpdate -u ntp.org'


舉例
1.修改客戶端的主機名由centossz008更名為minion_client01
hostname minion_client01


vim /etc/sysconfig/network
HOSTNAME=minion_client01


刪除客戶端之前保存的相關認證信息
rm -rf minion_id pki


服務端刪除原有認證
salt-key -d centossz008 -y
Deleting the following keys:
Accepted Keys:
centossz008
Key for minion centossz008 deleted.


重啟客戶端后在服務端重新認證
salt-key -A -y
The following keys are going to be accepted:
Unaccepted Keys:
minion_client01.DHCP
Key for minion minion_client01.DHCP accepted.


salt '*' cmd.run 'grep salt /etc/hosts'
minion_client01.DHCP:
? ? 192.168.3.87 salt
192.168.3.108:
? ? 192.168.3.87 salt


2.更換salt-master主機
當master主機性能承載不了大批量機器的的時候,需要更換主機
原有主機:192.168.3.87
目標主機:192.168.3.54


①在目標master主機3.54上安裝salt-master


rpm -Uvh http://mirrors.yun-idc.com/epel/6Server/x86_64/epel-release-6-8.noarch.rpm
yum install -y salt-master
Loaded plugins: fastestmirror, security
Determining fastest mirrors


報錯:
Error: Cannot retrieve metalink for repository: epel. Please verify its path and try again


執行:
yum-config-manager --disable epel-testing
把epel-testing這個庫從yum庫里面禁用掉
發現是啟用了/etc/yum.conf中的代理,取消即可


②將原主機中/etc/salt下的pki目錄打包拷貝到目標機3.54的/etc/salt目錄下
tar zcvf pki.tar.gz pki
scp pki.tar.gz root@192.168.3.54:/etc/salt


③目標master中解壓pki目錄
tar -zxvf pki.tar.gz


tree pki
pki
└── master
? ? ├── master.pem
? ? ├── master.pub
? ? ├── minions
? ? │ ? ├── 192.168.3.108
? ? │ ? └── minion_client01.DHCP
? ? ├── minions_autosign
? ? ├── minions_denied
? ? ├── minions_pre
? ? └── minions_rejected


啟動服務
service salt-master star


④在原master主機中執行命令將minion客戶端中的hosts文件改為新的master主機
# salt '*' cmd.run "grep salt /etc/hosts"
minion_client01.DHCP:
? ? 192.168.3.87 salt
192.168.3.108:
? ? 192.168.3.87 salt


salt '*' cmd.run "sed -i 's#192.168.3.87#192.168.3.54#' /etc/hosts"
minion_client01.DHCP:
192.168.3.108:


重啟minion服務
salt '*' service.restart salt-minion
此時發現原主機已經無法執行命令了
[root@node2 salt]# salt '*' cmd.run "grep salt /etc/hosts"
192.168.3.108:
? ? Minion did not return. [No response]
minion_client01.DHCP:
? ? Minion did not return. [No response]


在新的master上執行命令測試,發現ok,說明主機成功遷移


salt '*' cmd.run date
192.168.3.108:
? ? Sun Aug ?7 10:43:04 CST 2016
minion_client01.DHCP:
? ? Sun Aug ?7 10:43:04 CST 2016


服務器端修改端口


syndic_master_port: 8506
publish_port: 9036

轉載于:https://www.cnblogs.com/reblue520/p/6239750.html

總結

以上是生活随笔為你收集整理的saltStack运维工具的部署及master迁移实现的过程详解的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。