全部產品
Search
文件中心

CloudMonitor:利用pssh大量安裝CloudMonitor外掛程式

更新時間:Jan 27, 2024

本文為您介紹如何利用pssh大量安裝CloudMonitor外掛程式。

pssh介紹

pssh 是一個python寫的批量執行工具,非常適合30台伺服器以內的一些重複性的操作。例如安裝一個軟體,kill 一個進程,下載檔案等。

單機安裝CloudMonitor外掛程式

bash -c "$(curl http://cloudmonitor-agent.oss-cn-hangzhou.aliyuncs.com/release/install.sh)"

大量安裝CloudMonitor外掛程式

  • 安裝pssh
    1. 安裝 python 2.4 以上。
    2. 安裝 pssh 。
       wget https://pypi.python.org/packages/source/p/pssh/pssh-2.3.1.tar.gz
       tar zxf pssh-2.3.1.tar.gz
       cd pssh-2.3.1
       python setup.py install 
      							
  • 配置IP列表,準備安裝CloudMonitor外掛程式的主機
    1. 配置ip.txt檔案。
    2. 格式為user@ip:port每行一個,port不填預設為22。
    3. 執行命令的使用者需要有sudo許可權。
    4. 大量安裝的機器,密碼要相同,也可以配置無密碼互信。
  • 批量執行

    pssh -h ip.txt -A -i bash -c "$(curl http://cloudmonitor-agent.oss-cn-hangzhou.aliyuncs.com/release/install.sh)"

    -h host列表檔案

    -A 手工輸入密碼,無密碼互信不需要這個參數

    -i 執行的命令

  • 查看CloudMonitor外掛程式是否安裝成功

    pssh -h ip.txt -A -i"/usr/local/cloudmonitor/wrapper/bin/cloudmonitor.sh status"