Clustershell - 管理上萬臺L

在集群的現(xiàn)在,管理成千上萬的Linux機(jī)子成為了一個難題,不能再使用一臺一臺登錄主機(jī)去進(jìn)行管理了,工作量無疑是非常巨大的,這里我們可以借助Clustershellpssh管理,它原理是自動登錄主機(jī)集群幫我們將腳本進(jìn)行執(zhí)行,或者是文件的操作等,當(dāng)初大豬是一臺一臺去管理的,一個字:好累呀。

使用指南

Clustershell工具

使用的是Centos7如操作,我們只需要在一臺主機(jī)上操作即可完成對集群機(jī)子的所有配置

master      host.com        #主機(jī)
cluster1    2.host.com      #節(jié)點1
cluster2    3.host.com      #節(jié)點2
cluster3    4.host.com      #節(jié)點3

免密碼登錄

主機(jī)使用ssh登錄1,2,3節(jié)點必須是免密碼登錄方式,并且不能是首次登錄,因為Clustershell不會自動輸入交互命令,例如第一次登錄主機(jī)會有下面提示。

ssh root@2.host.com

The authenticity of host '2.host.com (192.168.0.20)' can't be established.
ECDSA key fingerprint is d4:5d:d6:e6:bc:70:86:1b:42:32:aa:6b:86:a6:34:d4.
Are you sure you want to continue connecting (yes/no)?

Clustershell不能自動處理,會提示以下錯誤

[1] 11:32:17 [FAILURE] 2.host.com Exited with error code 255

生成密鑰

ssh-keygen -t rsa

公鑰內(nèi)容復(fù)制到各個節(jié)點上

scp ~/.ssh/id_rsa.pub 192.168.0.20:/root/.ssh/authorized_keys
scp ~/.ssh/id_rsa.pub 192.168.0.21:/root/.ssh/authorized_keys
scp ~/.ssh/id_rsa.pub 192.168.0.22:/root/.ssh/authorized_keys

配置ClusterShell

vim /etc/clustershell/groups.d/local.cfg

內(nèi)容如下

# ClusterShell groups config local.cfg
#
# Replace /etc/clustershell/groups
#
# Note: file auto-loaded unless /etc/clustershell/groups is present
#
# See also groups.d/cluster.yaml.example for an example of multiple
# sources single flat file setup using YAML syntax.
#
# Feel free to edit to fit your needs.
adm: example0
oss: example4 example5
mds: example6
io: example[4-6]
compute: example[32-159]
gpu: example[156-159]
all: example[4-6,32-159]
demo: [1-3].host.com

以上我們定義了一個分組:demo,通過這個分組可連接1.host.com,2.host.com,3.host.com,如果此三個節(jié)點對應(yīng)的IP地扯沒有映射有連接失敗,可設(shè)置/etc/hosts對應(yīng)關(guān)系

cat /etc/hosts

127.0.0.1 localhost
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

192.168.0.20 1.host.com
192.168.0.21 2.host.com
192.168.0.22 3.host.com

clush命令幾個重要的參數(shù)

  • -b : 相同輸出結(jié)果合并
  • -w : 指定節(jié)點
  • -a : 所有節(jié)點
  • -g : 指定組
  • --copy : 群發(fā)文件

各個節(jié)點執(zhí)行ls命令

clush -g demo "ls"

創(chuàng)建文件

clush -g demo "touch /root/demo.txt"

群發(fā)文件

clush -g demo --copy groups --dest /root

pssh工具

安裝

yum install pssh -y

編輯節(jié)點IP地扯
vim /root/hosts.txt

1.host.com
2.host.com
3.host.com

節(jié)點執(zhí)行命令

pssh -H hosts.txt -P "ls"

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • 在集群的現(xiàn)在,管理成千上萬的Linux機(jī)子成為了一個難題,不能再使用一臺一臺登錄主機(jī)去進(jìn)行管理了,工作量無疑是非常...
    kikiki1閱讀 271評論 0 5
  • 在集群的現(xiàn)在,管理成千上萬的Linux機(jī)子成為了一個難題,不能再使用一臺一臺登錄主機(jī)去進(jìn)行管理了,工作量無疑是非常...
    大豬大豬閱讀 438評論 1 4
  • 在集群的現(xiàn)在,管理成千上萬的Linux機(jī)子成為了一個難題,不能再使用一臺一臺登錄主機(jī)去進(jìn)行管理了,工作量無疑是非常...
    kikiki2閱讀 158評論 0 1
  • 在集群的現(xiàn)在,管理成千上萬的Linux機(jī)子成為了一個難題,不能再使用一臺一臺登錄主機(jī)去進(jìn)行管理了,工作量無疑是非常...
    kikiki5閱讀 123評論 0 2
  • 在集群的現(xiàn)在,管理成千上萬的Linux機(jī)子成為了一個難題,不能再使用一臺一臺登錄主機(jī)去進(jìn)行管理了,工作量無疑是非常...
    kikiki1閱讀 297評論 0 2

友情鏈接更多精彩內(nèi)容