Netcatを試してみる(ファイル転送)
nc
ファイル転送ができるに注目する
- 二台間で
送信側
と受信側
の関係を作ったとする - 両方に
nc
をインストール > RH系ならyum install nc
- 特定のポート(デフォルト:TCP)で待ち受けが可能な状態をつくる
テストファイルの用意(dd)
- 100Mのファイルをひとつ用意
dd if=/dev/zero of=/tmp/nc_test_file01 bs=100M count=1
実践
- ファイルを持っている
送信側
は下記設定で送信待機するnc -l 28282 < /tmp/nc_test_file01
- ファイルが欲しい
受信側
は特定ファイル名を指定出力するために、ファイルをとりにいく time nc <送信側のHostname/IP> 28282 > /tmp/nc_test_file01_get
上記の関係になる。 この結果、指定したファイルをゲットできる。
比較計測
- 速いの?
- timeつけてみて、比較。普段のscpとかで。
- あくまで比較するだけのレベル
real 0m8.961s
... 上記のncreal 0m14.623s
... scp (10Mb/sな環境だった)- 速い?掘り下げる。
比較計測2
- 100Mだったファイルを1Gに変更してみる
- rsyncも、と思ったがわかりやすく二つでの比較
- 結果
容量 | 計測時間 | 使用ソフト |
---|---|---|
1G | 1m31.781s | nc |
1G | 1m37.217s | scp |
あまりかわらない。あれ?
ネットワーク帯域計測
- ifstat いれて様子見
- ex)
sudo rpm -Uvh http://pkgs.repoforge.org/ifstat/ifstat-1.1-1.2.el6.rf.x86_64.rpm --test
- 同じく帯域を同様平均 10Mb/s付近で転送しているから当たり前かこの数字は。
$ ifstat -i eth0 eth0 KB/s in KB/s out 11414.64 248.18 8806.71 187.34 11322.78 240.96 〜省略〜
- 100Mbps使えるインタフェース。帯域で比較すべきか。
- 帯域を使い切るかが、速いかどうかでは、ある。(もともとそこでみないとダメか。)
ちょっと環境用意できなかった。
上記にあるように、インタフェースの速度が早く帯域がよくないとあまり意味ない、か比較。
用途
- とにかく巨大な少数ファイルをローカル間で高速に転送するとき(バックアップのバックアップとか)に使えるかな。
- ネットワーク帯域を圧迫する環境か程度は気にしたい
別用途
- ncで多段SSHで(省略)使っている。
展望
- 複数ファイル高速化、複数セッションで転送ってなときは、
nc
を使えるのか使うべきなのか他のやりかたでいいのか。 - そもそも、ファイル転送する仕組みをとにかく複数起動すればいいだけか。
- GNU Parallel 使ってかつ複数ファイルの転送かつ
nc
みたいなことうまいこと実現できないのかな? - まちうけのポートのセッションまでParallelにできるわけじゃないから、その場合は複数セッションをはれるソフトの方が有利なのかな?
- ネットワーク帯域、IO、CPU使い切りで短時間にファイル転送する方法に今興味があるので調べていきたい
brew doctor で問題の発見と解消
homebrew troubleshooting
- brewでインストール失敗時にうながされた
READ THIS: https://github.com/mxcl/homebrew/wiki/troubleshooting
brew doctor
- brew doctorつかったら?
% brew doctor Warning: You have unlinked kegs in your Cellar Leaving kegs unlinked can lead to build-trouble and cause brews that depend on those kegs to fail to run properly once built. Run `brew link` on these: python Warning: You have uncommitted modifications to Homebrew If this a surprise to you, then you should stash these modifications. Stashing returns Homebrew to a pristine state but can be undone should you later need to do so for some reason. cd /usr/local/Library && git stash && git clean -d -f Warning: Your Homebrew is outdated. You haven't updated for at least 24 hours, this is a long time in brewland! To update Homebrew, run `brew update`.
さわりすぎたのか Warning
がけっこうあったので従う
現象の回復
- 以下を実行
% cd /usr/local/Library && git stash && git clean -d -f % brew update
- 警告はありつつも目的のものをいれることができた
- Xcode新しくしてね、といわれる ... udpateするから当然か。少々煩わしい。
Warning: Your Xcode (5.0) is outdated Please update to Xcode 5.0.1. Xcode can be updated from the App Store.
- ちなみに上記より、自分は
python
をちょうどいれようといじっていた途中でもあった brew link
をしつつ/usr/local/bin
配下の管理を整理して解消
ちなみに今回いれようとしたのは、Ricty
- https://github.com/sanemat/homebrew-font
- 結局、つまずいた。
- つまり、別要因
- 公式の
Ricty
をみつつbrewじゃない形でインストする
さらにはまったこと
fontforge
をいれなおさないとダメだった- 参考にした
brew tap
のMiguを落とすURL先の反応がわるかった。 - ほとんど、手動でインストールした形(必要ファイルをおとしてきてautoにならず)
% sh ./ricty_generator.sh /Library/Caches/Homebrew/Inconsolata.otf ./misc/migu-1m-20130617/migu-1m-regular.ttf ./misc/migu-1m-20130617/migu-1m-bold.ttf Ricty Generator 3.2.2 Author: Yasunori Yusa <lastname at save dot sys.t.u-tokyo.ac.jp> This script is for generating ``Ricty'' font from Inconsolata and Migu 1M. It requires 2-5 minutes to generate Ricty. Owing to SIL Open Font License Version 1.1 section 5, it is PROHIBITED to distribute the generated font. Generate modified Inconsolata. Find /Library/Caches/Homebrew/Inconsolata.otf. Save Modified-Inconsolata-Regular.sfd. While making Inconsolata bold, wait a moment... Save Modified-Inconsolata-Bold.sfd. Generate modified Migu 1M. Find ./misc/migu-1m-20130617/migu-1m-regular.ttf. While scaling migu-1m-regular.ttf, wait a little... Save Modified-migu-1m-regular.sfd. Find ./misc/migu-1m-20130617/migu-1m-bold.ttf. While scaling migu-1m-bold.ttf, wait a little... Save Modified-migu-1m-bold.sfd. Generate Ricty. While merging Modified-Inconsolata-Regular.sfd with Modified-migu-1m-regular.sfd, wait a little more... Save Ricty-Regular.ttf. While merging Modified-Inconsolata-Bold.sfd with Modified-migu-1m-bold.sfd, wait a little more... Save Ricty-Bold.ttf. Remove temporary files. Generate RictyDiscord-Regular.ttf. Generate RictyDiscord-Bold.ttf. Succeeded to generate Ricty!
- 作成されたフォントを指定のフォルダ(以下みたいに、
Library/Fonts
とかいいのかな)にいれて、インストールが進むと
% fc-cache -vf /usr/share/fonts: skipping, no such directory /Library/Fonts: caching, new cache contents: 323 fonts, 0 dirs /Users/xxxx/Library/Fonts: caching, new cache contents: 4 fonts, 0 dirs /Users/xxxx/.local/share/fonts: skipping, no such directory /Users/xxxx/.fonts: skipping, no such directory /usr/local/Cellar/fontconfig/2.10.95/var/cache/fontconfig: cleaning cache directory /Users/xxxx/.cache/fontconfig: not cleaning non-existent cache directory /Users/xxxx/.fontconfig: not cleaning non-existent cache directory fc-cache: succeeded
はいった。
参考サイト
brew install gcc するなら brew tap をする
homebrew
brew tap
と打ってねというシチュエーションに遭遇
% brew install gcc Error: No available formula for gcc GCC is now maintained in homebrew-versions, with major version number in formula name as suffix. Please tap using: brew tap homebrew/versions and then install GCC based on its version, e.g., 'brew install gcc47'.
brew tapとは
- 公式にないリポジトリを使うときに指定するみたい
- 以下いれとけ、となるのは、
formula
の管理別パターンが使えるからかな。
% brew tap homebrew/versions
- 上記後導入できた。
% brew install gcc47
- ほかにもいろいろあるのでいれておこう。