saltstack執行state.sls耗時長的坑


      一直用的 jenkins + saltstack 自動化構建發布項目,一共也就不超過20台服務器,奈何運行時間越來越慢,並且負載越來越高(這里大部分都是使用state模塊),但是不用state模塊效率挺高的,所以初步鎖定坑應該在 state配置以及運行機制上.

查閱各種資料果不其然,需要注意幾點.

Minion 配置


By default, the Salt fileserver recurses fully into all defined environments
to attempt to find files. To limit this behavior so that the fileserver only
traverses directories with SLS files and special Salt directories like _modules,
enable the option below. This might be useful for installations where a file root
has a very large number of files and performance is negatively impacted. Default
is False.

# 關閉軟連接
fileserver_followsymlinks: False
# 忽略軟連接
fileserver_ignoresymlinks: True
# 見上面的引文
fileserver_limit_traversal: True

雖然我修改了minion配置里的 fileserver_limit_traversal 為true 但是效果還是不明顯,因為這個fileserver目錄里面太多文件了(node打包等一系列文件全在里面,文件數太多了(⊙﹏⊙)b),由上面的引文可見

默認情況,每次執行state文件,minion都會發出 “_file_list” 命令從master同步整個文件列表。當fileserver(即master端配置文件中file_roots設置的目錄)中的文件比較多的情況下,會增大集群負載.

再github上也搜到類似的問題,提供思路

 

參考:   

http://vearne.cc/?p=88

https://github.com/saltstack/salt/issues/30498

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM