新聞中心
pssh是一個(gè)基于Python編寫(xiě),可在多臺(tái)服務(wù)器上執(zhí)行命令,文件的并行復(fù)制的工具要使用pssh工具包,必須配置本地主機(jī)和被管理的遠(yuǎn)程主機(jī)之間ssh單向的免秘鑰認(rèn)證

成都創(chuàng)新互聯(lián)公司主營(yíng)源城網(wǎng)站建設(shè)的網(wǎng)絡(luò)公司,主營(yíng)網(wǎng)站建設(shè)方案,重慶APP開(kāi)發(fā)公司,源城h5成都微信小程序搭建,源城網(wǎng)站營(yíng)銷推廣歡迎源城等地區(qū)企業(yè)咨詢
pssh項(xiàng)目
項(xiàng)目:http://code.google.com/p/parallel-ssh/
語(yǔ)法:
Usage: pscp.pssh [OPTIONS] local remote
常用選項(xiàng):
--version:查看版本
-h:主機(jī)文件列表,內(nèi)容格式”[user@]host[:port]”
-H:主機(jī)字符串,內(nèi)容格式”[user@]host[:port]”
-A:手動(dòng)輸入密碼模式
-i:每個(gè)服務(wù)器內(nèi)部處理信息輸出
-l:登錄使用的用戶名
-p:并發(fā)的線程數(shù)【可選】
-o:標(biāo)準(zhǔn)輸出文件的輸出目錄(可選)
-e:標(biāo)準(zhǔn)錯(cuò)誤文件的輸出目錄(可選)
-t:TIMEOUT 超時(shí)時(shí)間設(shè)置,0無(wú)限制【可選】
-O:SSH的選項(xiàng)
-P:打印出服務(wù)器返回信息
-v:詳細(xì)模式
【例1】通過(guò)pssh批量向主機(jī)文件列表中的主機(jī)執(zhí)行echo “hello pssh”。
[root@CentOS7 ~]# cat host.txt
172.20.200.200
192.168.8.61
[root@CentOS7 ~]# pssh -h host.txt -i echo "hello pssh"
[1] 16:31:10 [SUCCESS] 192.168.8.61
hello pssh
[2] 16:31:10 [SUCCESS] 172.20.200.200
hello pssh
注:當(dāng)不支持ssh的key認(rèn)證時(shí),可通過(guò)-A選項(xiàng),手動(dòng)輸入密碼認(rèn)證批量執(zhí)行指令。
【例2】將標(biāo)準(zhǔn)錯(cuò)誤和標(biāo)準(zhǔn)正確重定向都保存至本地主機(jī)的/app目錄下。
[root@CentOS7 ~]# pssh -h host.txt -o /app/ -e /app/ -i echo "hello pssh"
[1] 16:52:32 [SUCCESS] 192.168.8.61
hello pssh
[2] 16:52:32 [SUCCESS] 172.20.200.200
hello pssh
[root@CentOS7 ~]# ls /app/
172.20.200.200 192.168.8.61
[root@CentOS7 ~]# cat /app/192.168.8.61
hello pssh
pscp.pssh命令
功能:將本地文件批量復(fù)制到遠(yuǎn)程主機(jī) 語(yǔ)法:
[root@CentOS7 ~]# pscp.pssh --help
Usage: pscp.pssh [OPTIONS] local remote
選項(xiàng):基本與pssh命令一致,不過(guò)有個(gè)-r選項(xiàng)可以遞歸復(fù)制目錄
【例1】將本地/etc/fstab文件批量復(fù)制到主機(jī)列表文件中的主機(jī)的/app目錄下
[root@CentOS7 ~]# pscp.pssh -h host.txt /etc/fstab /app/
[1] 17:19:32 [SUCCESS] 192.168.8.61
[2] 17:19:32 [SUCCESS] 172.20.200.200
[root@CentOS7 ~]# pssh -h host.txt -i ls /app/ -l
[1] 17:25:14 [SUCCESS] 192.168.8.61
total 4
-rw-r--r-- 1 root root 595 Nov 8 20:27 fstab
[2] 17:25:14 [SUCCESS] 172.20.200.200
total 4
-rw-r--r-- 1 root root 595 Nov 9 17:19 fstab
【例2】將本地目錄/test/批量復(fù)制到主機(jī)文件列表中的主機(jī)的/app目錄
[root@CentOS7 ~]# pscp.pssh -h host.txt -r /test/ /app/
[1] 17:23:14 [SUCCESS] 192.168.8.61
[2] 17:23:14 [SUCCESS] 172.20.200.200
[root@CentOS7 ~]# pssh -h host.txt -i ls /app/ -l
[1] 17:26:33 [SUCCESS] 192.168.8.61
total 8
-rw-r--r-- 1 root root 595 Nov 8 20:27 fstab
drwxr-xr-x 2 root root 4096 Nov 8 20:33 test
[2] 17:26:33 [SUCCESS] 172.20.200.200
total 4
-rw-r--r-- 1 root root 595 Nov 9 17:19 fstab
drwxr-xr-x 2 root root 48 Nov 9 17:25 test
pslurp命令
功能:將遠(yuǎn)程主機(jī)的文件批量復(fù)制到本地,與pscp.pssh命令功能相反。 語(yǔ)法:
pslurp [-vAr] [-h hosts_file] [-H [user@]host[:port]] [-l user] [-p par] [-o outdir] [-e errdir] [-t timeout] [-O options] [-xargs] [-X arg] [-L localdir] remote local(本地名)
選項(xiàng):
-L 將文件從遠(yuǎn)程主機(jī)復(fù)制到給定的本地目錄,local是下載到本地后的名稱
【例】批量下載目標(biāo)服務(wù)器的passwd文件至本地目錄/app下,并更名為user
[root@CentOS7 ~]# pslurp -h host.txt -L /app/ /etc/passwd user
[1] 17:35:38 [SUCCESS] 192.168.8.61
[2] 17:35:38 [SUCCESS] 172.20.200.200
[root@CentOS7 ~]# tree /app/
/app/
├── 172.20.200.200
│ └── user
└── 192.168.8.61
└── user
2 directories, 2 files
文章名稱:輕量級(jí)自動(dòng)化運(yùn)維工具pssh與pslurp
本文地址:http://m.fisionsoft.com.cn/article/dpdijid.html


咨詢
建站咨詢
