parallel-slurpで、ファイルを並列で取得する
複数のホストから、ファイルをダウンロードする必要があったので、方法を調べた。
parallel-slurp(pslurp)という便利なものがあったので、使うことにした。
インストール
# apt install pssh
manを読むと、やりたことが書かれてる。
PARALLEL-SLURP(1) PARALLEL-SLURP(1) NAME parallel-slurp - copy files from listed hosts SYNOPSIS parallel-slurp [OPTIONS] -h hosts.txt -L destdir remote local DESCRIPTION pssh provides a number of commands for executing against a group of computers, using SSH. It´s most useful for operating on clusters of homogenously-configured hosts. parallel-slurp gathers specified files from hosts you listed. (snip)
使い方
対象ホストのリストを用意する。
$ cd /home/admin/ $ cat file_list a.example.com b.example.com c.example.com
ダウンロードしたファイル用のディレクトリを作成する。
$ mkdir downloads
parallel-slurpを実行する。
$ parallel-slurp -ladmin -h file_list -p 3 -L /home/admin/downloads /var/log/http_access.log http_access.log
引数の説明を簡単にする。
- -lは、作業ユーザ
- -hは、対象ホストのリスト
- -pは、並列処理数
- -Lは、ダウンロードしたファイルを置くディレクトリ
そのあとの引数は
- ダウンロードするファイルの絶対パス
- ダウンロードした際のファイルの名前
実行するとディレクトリは次のようになる。
$ tree downloads/ downloads/ ├── a.example.com │ └── http_access.log ├── b.example.com │ └── http_access.log └── c.example.com └── http_access.log 3 directories, 3 files