Windows7にmingw-getでMSYSのsshとrsyncをインストールする
Windows7上でVagrantとChef(knife-solo)を使うにあたり、sshとrsyncが必要になるのだが、Windows向けのVagrantとChefに同梱されているMSYSには入っていなかったので、改めてmingw-getを使ってインストールしてみた。
MinGW、MSYSとは
Wikipediaを読んでください。
本家のサイトは以下。
mingw-getのインストール
MinGWとMSYSにはmingw-getというパッケージ管理ソフトがあり、これを使って各種アプリケーションのインストールを行う事ができる。
まずは、そのパッケージ管理ソフトであるmingw-getをインストールする為、ここからlatestのインストーラーをダウンロードしてくる。ダウンロードできたらインストーラーを起動。ライセンスを確認しインストールへ。
インストールフォルダ(デフォルトはC:¥MinGW)とGUIの設定をする。
mingw-getはCUIとGUIの両方をサポートしているが、GUIも使いたい場合はここで有効にしておく。また、デスクトップとスタートメニューにショートカットが必要であれば、ここでチェックしておく。ショートカットは自分だけでなく全てのユーザーに作る事もできるようだが、ドキュメントを読むと推奨されていない。
Continueでインストールが始まり、
完了。ここでContinueをクリックするとGUIが起動し、Quitをクリックするとそのままウィザードが閉じる。
GUIはこんな感じ。
インストール直後のフォルダ構成は以下のようになっている。
MinGW ├bin バイナリ ├libexec exeやdllとか ├share ドキュメントとか └var キャッシュ、パッケージ定義ファイルとか
なお、mingw-getはインストールしても自動ではバイナリのあるフォルダのパスを通さないので、インストールが終わったら必ず環境変数PATHにC:¥MinGW¥binを追加する必要がある。勿論、インストールフォルダを変えた場合は、適宜binフォルダの位置を追加する。
mingw-getのアンインストール
ちなみに、mingw-getにはアンインストールする為のプログラムが内包されていない。アンインストールする場合は、インストール先のフォルダを直接削除すれば良い。デスクトップやスタートメニューにショートカットを作っていたら、それらも合わせて削除する。
パッケージのインストール:GUI編
sshとrsyncをインストールする前に、mingw-getを使ったパッケージインストールの手順を一通りメモしておく。
最初はGUIを使った場合。ここではパッケージリストからBasic Setupのmingw32-baseを選択し、MinGWの基本パッケージ群をインストールする。
パッケージを選択すると、下部のペインにはそのパッケージの詳細な情報が表示される。選択したパッケージの□をクリックするか右クリックをすると、ポップアップメニューが開く(メニューバーのPackageと同じ)。
メニューの中からMark for Installationを選択すると、□にインストールマークが表示される。もし、対象を誤った場合は再びポップアップメニューを開いてUnmarkを選択すれば消える。
この状態でメニューバーのInsallationからApply Changesを選択する。
するとアクション選択ウィンドウが開き、インストール対象となるパッケージ群が表示される(アップグレードやリムーブ対象があればそれぞれ表示される)。確認を行い問題が無ければApplyを、変更があればDeferを、中止したければDiscardをクリックする。
DeferとDiscardをクリックするといずれもパッケージリストに戻るが、Dederだとパッケージに付与したマークはそのままで、Discardだとマークが消えてしまう。間違えると場合によっては面倒な事に。
今回は問題無いのでApplyをクリックしてインストールを開始。各パッケージのダウンロードが始まる。
パッケージのダウンロードに失敗すると以下のようなエラーメッセージが表示されるが、OKをクリックするとそのまま次の過程に進行していく。
全てのパッケージのダウンロードが完了すると、ダイアログが表示されてインストールが始まる。Detailsでインストールの過程を確認する事ができる。
全てのパッケージのインストールが完了したらCloseをクリックで終了。パッケージリストを確認すると、インストール済みパッケージは□の色が緑になっている。
ダウンロードに失敗したパッケージはインストールマークがついたままなので、再度インストールを行うなり、Unmarkするなりしておいた方が良い。
パッケージのアップグレード、再インストール、リムーブについても、対象のパッケージにするマークの種別が異なるところ以外は殆ど同様の手順となるので、特に迷わず操作をできるだろう。
MinGWの基本パッケージ群をインストールした直後のフォルダ構成は以下の通り。mingw-get以外のパッケージがビルドされて、ヘッダファイルとオブジェクトファイルの入ったフォルダが追加されている。
MinGW ├bin バイナリ ├include ヘッダファイル ├lib オブジェクトファイル ├libexec exeやdllとか ├mingw32 mingw32-gcc ├share ドキュメントとか └var キャッシュ、パッケージ定義ファイルとか
mingw32フォルダも追加されており、中にはmingw32-gccが配置されている。が、gccはbinにも配置されている。これは恐らくクロスコンパイラとかmingw64ネイティブコンパイラと共存させる為にあるものと思われるが、ちょっと調べた限りでは正確なところがよく分からなかった。
パッケージのインストール:CUI編
続いてCUIを使った場合。コマンドプロンプトからmingw-getを実行してみる(上述したが、バイナリのパスを通し忘れないように)。
C:¥Users¥heroween>mingw-get
と、mingw-getコマンドをオプションもアクションも付与しないで実行すると、GUIが起動する(GUIを有効にしていない場合はエラーのポップアップが出る)。また、GUIが起動した状態でコマンドを叩くとCUI側にロックされているというメッセージが出て実行できない。
mingw-getコマンドの使い方はhelpを見れば大体分かるので参照する。
C:¥Users¥heroween>mingw-get --help Manage MinGW and MSYS installations (command line user interface). Usage: mingw-get [OPTIONS] ACTION [package-spec[version-bounds] ...] mingw-get update mingw-get [OPTIONS] {install | upgrade | remove} package-spec ... mingw-get [OPTIONS] {show | list} [package-spec ...] Options: --help, -h Show this help text --version, -V Show version and licence information --verbose, -v Increase verbosity of diagnostic or progress reporting output; repeat up to three times for maximum verbosity --verbose=N Set verbosity level to N; (0 <= N <= 3) --trace=N Enable tracing feature N; (debugging aid) --reinstall When performing an install or upgrade operation, reinstall any named package for which the most recent release is already installed --recursive Extend the scope of "install --reinstall" or of "upgrade", such that the operation is applied recursively to all prerequisites of all packages named on the command line --download-only Download the package archive files which would be required to complete the specified install, upgrade, or source operation, but do not unpack them, or otherwise proceed to complete the operation --print-uris Display the repository URIs from which package archive files would be retrieved prior to performing the specified install, upgrade, or source operation, but do not download any package file, or otherwise proceed with the operation --all-related When performing source or licence operations, causes mingw-get to retrieve, and optionally to unpack the source or licence archives for all runtime prerequisites of, and in addition to, the nominated package --desktop[=all-users] Enable the creation of desktop shortcuts, for packages which provide the capability via pre- or post-install scripts; the optional 'all-users' qualifier requests that all such shortcuts are to be made available to all users; without it shortcuts will be created for current user only Note that specification of this option does not guarantee that shortcuts will be created; the onus lies with individual package maintainers to provide scripting to support this capability --start-menu[=all-users] Enable the creation of start menu shortcuts, for packages which provide the capability via pre- or post-install scripts; the optional 'all-users' qualifier requests that all such shortcuts are to be made available to all users; without it shortcuts will be created for current user only Note that specification of this option does not guarantee that shortcuts will be created; the onus lies with individual package maintainers to provide scripting to support this capability Actions: update Update local copy of repository catalogues list, show List and show details of available packages source Download and optionally unpack package sources licence Download and optionally unpack licence packages, handling them as if they are source packages install Install new packages upgrade Upgrade previously installed packages remove Remove previously installed packages Package Specifications: [subsystem-]name[-component]: msys-bash-doc The 'doc' component of the bash package for MSYS mingw32-gdb All components of the gdb package for MinGW Version Bounds (for install or upgrade actions): {>|>=|=|<=|<}major[.minor[.rev]][-subsystem-major[.minor[.rev]]]: "gcc=4.5.*" Latest available release of GCC version 4.5.x "gcc<4.6" Alternative representation for GCC version 4.5.x Use 'mingw-get list' to identify possible package names, and the components associated with each. Quote package names with attached version bounds specifications, to avoid possible misinterpretation of shell operators. Do NOT insert white space at any point within any "package-spec[version-bounds]" specification string.
インストールのコマンドも分かったので、今度はMSYSの基本パッケージ群をインストールしてみる。
C:\Users\heroween>mingw-get install msys-base http://prdownloads.sourceforge.net/mingw/msysCORE-1.0.18-1-msys-1.0.18-lic.tar.lzma?download 11.52 kB / 11.52 kB |================================================| 100% http://prdownloads.sourceforge.net/mingw/msysCORE-1.0.18-1-msys-1.0.18-doc.tar.lzma?download 7.79 kB / 7.79 kB |================================================| 100% http://prdownloads.sourceforge.net/mingw/libiconv-1.14-1-msys-1.0.17-dll-2.tar.lzma?download 518.74 kB / 518.74 kB |================================================| 100% http://prdownloads.sourceforge.net/mingw/liblzma-5.0.3-1-msys-1.0.17-dll-5.tar.lzma?download 68.72 kB / 68.72 kB |================================================| 100% http://prdownloads.sourceforge.net/mingw/libintl-0.18.1.1-1-msys-1.0.17-dll-8.tar.lzma?download 22.11 kB / 22.11 kB |================================================| 100% http://prdownloads.sourceforge.net/mingw/make-3.81-3-msys-1.0.13-bin.tar.lzma?download 76.84 kB / 76.84 kB |================================================| 100% http://prdownloads.sourceforge.net/mingw/less-436-2-msys-1.0.13-bin.tar.lzma?download 184.85 kB / 184.85 kB |================================================| 100% http://prdownloads.sourceforge.net/mingw/texinfo-4.13a-2-msys-1.0.13-bin.tar.lzma?download 205.63 kB / 205.63 kB |================================================| 100% http://prdownloads.sourceforge.net/mingw/tar-1.23-1-msys-1.0.13-bin.tar.lzma?download 136.05 kB / 136.05 kB |================================================| 100% http://prdownloads.sourceforge.net/mingw/sed-4.2.1-2-msys-1.0.13-bin.tar.lzma?download 60.97 kB / 60.97 kB |================================================| 100% http://prdownloads.sourceforge.net/mingw/xz-5.0.3-1-msys-1.0.17-bin.tar.lzma?download 35.74 kB / 35.74 kB |================================================| 100% http://prdownloads.sourceforge.net/mingw/gzip-1.3.12-2-msys-1.0.13-bin.tar.lzma?download 36.39 kB / 36.39 kB |================================================| 100% http://prdownloads.sourceforge.net/mingw/grep-2.5.4-2-msys-1.0.13-bin.tar.lzma?download 60.93 kB / 60.93 kB |================================================| 100% http://prdownloads.sourceforge.net/mingw/libmagic-5.04-1-msys-1.0.13-dll-1.tar.lzma?download 241.70 kB / 241.70 kB |================================================| 100% http://prdownloads.sourceforge.net/mingw/file-5.04-1-msys-1.0.13-bin.tar.lzma?download 103.25 kB / 103.25 kB |================================================| 100% http://prdownloads.sourceforge.net/mingw/findutils-4.4.2-2-msys-1.0.13-bin.tar.lzma?download 123.02 kB / 123.02 kB |================================================| 100% http://prdownloads.sourceforge.net/mingw/diffutils-2.8.7.20071206cvs-3-msys-1.0.13-bin.tar.lzma?download 92.09 kB / 92.09 kB |================================================| 100% http://prdownloads.sourceforge.net/mingw/gawk-3.1.7-2-msys-1.0.13-bin.tar.lzma?download 150.93 kB / 150.93 kB |================================================| 100% http://prdownloads.sourceforge.net/mingw/dos2unix-6.0.5-1-msys-1.0.17-bin.tar.lzma?download 41.06 kB / 41.06 kB |================================================| 100% http://prdownloads.sourceforge.net/mingw/coreutils-5.97-3-msys-1.0.13-bin.tar.lzma?download 288.85 kB / 288.85 kB |================================================| 100% http://prdownloads.sourceforge.net/mingw/zlib-1.2.7-1-msys-1.0.17-dll.tar.lzma?download 39.76 kB / 39.76 kB |================================================| 100% http://prdownloads.sourceforge.net/mingw/msysCORE-1.0.18-1-msys-1.0.18-bin.tar.lzma?download 596.49 kB / 596.49 kB |================================================| 100% http://prdownloads.sourceforge.net/mingw/termcap-0.20050421_1-2-msys-1.0.13-bin.tar.lzma?download 19.57 kB / 19.57 kB |================================================| 100% http://prdownloads.sourceforge.net/mingw/libregex-1.20090805-2-msys-1.0.13-dll-1.tar.lzma?download 35.32 kB / 35.32 kB |================================================| 100% http://prdownloads.sourceforge.net/mingw/libtermcap-0.20050421_1-2-msys-1.0.13-dll-0.tar.lzma?download 14.34 kB / 14.34 kB |================================================| 100% http://prdownloads.sourceforge.net/mingw/libbz2-1.0.6-1-msys-1.0.17-dll-1.tar.lzma?download 25.98 kB / 25.98 kB |================================================| 100% http://prdownloads.sourceforge.net/mingw/msysCORE-1.0.18-1-msys-1.0.18-ext.tar.lzma?download 7.68 kB / 7.68 kB |================================================| 100% http://prdownloads.sourceforge.net/mingw/bzip2-1.0.6-1-msys-1.0.17-bin.tar.lzma?download 18.26 kB / 18.26 kB |================================================| 100% http://prdownloads.sourceforge.net/mingw/bash-3.1.17-4-msys-1.0.16-bin.tar.lzma?download 231.70 kB / 231.70 kB |================================================| 100% install: msysCORE-1.0.18-1-msys-1.0.18-lic.tar.lzma installing msysCORE-1.0.18-1-msys-1.0.18-lic.tar.lzma install: msysCORE-1.0.18-1-msys-1.0.18-doc.tar.lzma installing msysCORE-1.0.18-1-msys-1.0.18-doc.tar.lzma install: libiconv-1.14-1-msys-1.0.17-dll-2.tar.lzma installing libiconv-1.14-1-msys-1.0.17-dll-2.tar.lzma install: liblzma-5.0.3-1-msys-1.0.17-dll-5.tar.lzma installing liblzma-5.0.3-1-msys-1.0.17-dll-5.tar.lzma install: libintl-0.18.1.1-1-msys-1.0.17-dll-8.tar.lzma installing libintl-0.18.1.1-1-msys-1.0.17-dll-8.tar.lzma install: make-3.81-3-msys-1.0.13-bin.tar.lzma installing make-3.81-3-msys-1.0.13-bin.tar.lzma install: less-436-2-msys-1.0.13-bin.tar.lzma installing less-436-2-msys-1.0.13-bin.tar.lzma install: texinfo-4.13a-2-msys-1.0.13-bin.tar.lzma installing texinfo-4.13a-2-msys-1.0.13-bin.tar.lzma install: tar-1.23-1-msys-1.0.13-bin.tar.lzma installing tar-1.23-1-msys-1.0.13-bin.tar.lzma install: sed-4.2.1-2-msys-1.0.13-bin.tar.lzma installing sed-4.2.1-2-msys-1.0.13-bin.tar.lzma install: xz-5.0.3-1-msys-1.0.17-bin.tar.lzma installing xz-5.0.3-1-msys-1.0.17-bin.tar.lzma install: gzip-1.3.12-2-msys-1.0.13-bin.tar.lzma installing gzip-1.3.12-2-msys-1.0.13-bin.tar.lzma install: grep-2.5.4-2-msys-1.0.13-bin.tar.lzma installing grep-2.5.4-2-msys-1.0.13-bin.tar.lzma install: libmagic-5.04-1-msys-1.0.13-dll-1.tar.lzma installing libmagic-5.04-1-msys-1.0.13-dll-1.tar.lzma install: file-5.04-1-msys-1.0.13-bin.tar.lzma installing file-5.04-1-msys-1.0.13-bin.tar.lzma install: findutils-4.4.2-2-msys-1.0.13-bin.tar.lzma installing findutils-4.4.2-2-msys-1.0.13-bin.tar.lzma install: diffutils-2.8.7.20071206cvs-3-msys-1.0.13-bin.tar.lzma installing diffutils-2.8.7.20071206cvs-3-msys-1.0.13-bin.tar.lzma install: gawk-3.1.7-2-msys-1.0.13-bin.tar.lzma installing gawk-3.1.7-2-msys-1.0.13-bin.tar.lzma install: dos2unix-6.0.5-1-msys-1.0.17-bin.tar.lzma installing dos2unix-6.0.5-1-msys-1.0.17-bin.tar.lzma install: coreutils-5.97-3-msys-1.0.13-bin.tar.lzma installing coreutils-5.97-3-msys-1.0.13-bin.tar.lzma install: zlib-1.2.7-1-msys-1.0.17-dll.tar.lzma installing zlib-1.2.7-1-msys-1.0.17-dll.tar.lzma install: msysCORE-1.0.18-1-msys-1.0.18-bin.tar.lzma installing msysCORE-1.0.18-1-msys-1.0.18-bin.tar.lzma install: termcap-0.20050421_1-2-msys-1.0.13-bin.tar.lzma installing termcap-0.20050421_1-2-msys-1.0.13-bin.tar.lzma install: libregex-1.20090805-2-msys-1.0.13-dll-1.tar.lzma installing libregex-1.20090805-2-msys-1.0.13-dll-1.tar.lzma install: libtermcap-0.20050421_1-2-msys-1.0.13-dll-0.tar.lzma installing libtermcap-0.20050421_1-2-msys-1.0.13-dll-0.tar.lzma install: libbz2-1.0.6-1-msys-1.0.17-dll-1.tar.lzma installing libbz2-1.0.6-1-msys-1.0.17-dll-1.tar.lzma install: msysCORE-1.0.18-1-msys-1.0.18-ext.tar.lzma installing msysCORE-1.0.18-1-msys-1.0.18-ext.tar.lzma install: bzip2-1.0.6-1-msys-1.0.17-bin.tar.lzma installing bzip2-1.0.6-1-msys-1.0.17-bin.tar.lzma install: bash-3.1.17-4-msys-1.0.16-bin.tar.lzma installing bash-3.1.17-4-msys-1.0.16-bin.tar.lzma install: msys-base-2013072300-msys-bin.meta installing msys-base-2013072300-msys-bin.meta
これでインストール完了。インストールするパッケージの名前が分かっていればGUIより少ない手順で済む。
MSYSのパッケージについては、MinGWのインストールフォルダの直下にmsysフォルダが作成されて、そちらの方にインストールされる事になる。
MinGW ├bin バイナリ ├include ヘッダファイル ├lib オブジェクトファイル ├libexec exeやdllとか ├mingw32 mingw32-gcc ├msys MSYSパッケージ ├share ドキュメントとか └var キャッシュ、パッケージ定義ファイルとか
msysフォルダ以下はこんな感じ。
msys └1.0 ├bin バイナリ ├etc 設定ファイル ├postinstall MSYSのインストールバッチ ├sbin バイナリ └share awkスクリプト、ドキュメントとか
MSYSについてもバイナリのパスは自動で通らないので、MinGW同様に環境変数PATHにC:¥MinGW¥msys¥1.0¥binを設定する。MinGWのインストールフォルダを変えていれば(以下略。
sshとrsyncのインストール
mingw-getの使い方が一通り分かったところで、本題であるsshとrsyncのインストールを行おう。
sshとrsyncはMSYSのパッケージがあるので、以下のコマンドを実行してインストールする。
C:\Users\heroween>mingw-get install msys-openssl msys-openssh msys-rsync http://prdownloads.sourceforge.net/mingw/libpopt-1.15-2-msys-1.0.13-dll-0.tar.lzma?download 207.48 kB / 207.48 kB |================================================| 100% http://prdownloads.sourceforge.net/mingw/libopenssl-1.0.0-1-msys-1.0.13-dll-100.tar.lzma?download 654.91 kB / 654.91 kB |================================================| 100% http://prdownloads.sourceforge.net/mingw/openssl-1.0.0-1-msys-1.0.13-bin.tar.lzma?download 315.05 kB / 315.05 kB |================================================| 100% http://prdownloads.sourceforge.net/mingw/openssl-1.0.0-1-msys-1.0.13-doc.tar.lzma?download 238.07 kB / 238.07 kB |================================================| 100% http://prdownloads.sourceforge.net/mingw/openssl-1.0.0-1-msys-1.0.13-lic.tar.lzma?download 2.11 kB / 2.11 kB |================================================| 100% http://prdownloads.sourceforge.net/mingw/libminires-1.02_1-2-msys-1.0.13-dll.tar.lzma?download 11.40 kB / 11.40 kB |================================================| 100% http://prdownloads.sourceforge.net/mingw/openssh-5.4p1-1-msys-1.0.13-bin.tar.lzma?download 274.71 kB / 274.71 kB |================================================| 100% http://prdownloads.sourceforge.net/mingw/openssh-5.4p1-1-msys-1.0.13-doc.tar.lzma?download 77.02 kB / 77.02 kB |================================================| 100% http://prdownloads.sourceforge.net/mingw/openssh-5.4p1-1-msys-1.0.13-lic.tar.lzma?download 4.79 kB / 4.79 kB |================================================| 100% http://prdownloads.sourceforge.net/mingw/rsync-3.0.8-1-msys-1.0.17-bin.tar.lzma?download 163.12 kB / 163.12 kB |================================================| 100% http://prdownloads.sourceforge.net/mingw/rsync-3.0.8-1-msys-1.0.17-doc.tar.lzma?download 95.64 kB / 95.64 kB |================================================| 100% http://prdownloads.sourceforge.net/mingw/rsync-3.0.8-1-msys-1.0.17-lic.tar.lzma?download 11.23 kB / 11.23 kB |================================================| 100% install: libpopt-1.15-2-msys-1.0.13-dll-0.tar.lzma installing libpopt-1.15-2-msys-1.0.13-dll-0.tar.lzma install: libopenssl-1.0.0-1-msys-1.0.13-dll-100.tar.lzma installing libopenssl-1.0.0-1-msys-1.0.13-dll-100.tar.lzma install: openssl-1.0.0-1-msys-1.0.13-bin.tar.lzma installing openssl-1.0.0-1-msys-1.0.13-bin.tar.lzma install: openssl-1.0.0-1-msys-1.0.13-doc.tar.lzma installing openssl-1.0.0-1-msys-1.0.13-doc.tar.lzma install: openssl-1.0.0-1-msys-1.0.13-lic.tar.lzma installing openssl-1.0.0-1-msys-1.0.13-lic.tar.lzma install: libminires-1.02_1-2-msys-1.0.13-dll.tar.lzma installing libminires-1.02_1-2-msys-1.0.13-dll.tar.lzma install: openssh-5.4p1-1-msys-1.0.13-bin.tar.lzma installing openssh-5.4p1-1-msys-1.0.13-bin.tar.lzma install: openssh-5.4p1-1-msys-1.0.13-doc.tar.lzma installing openssh-5.4p1-1-msys-1.0.13-doc.tar.lzma install: openssh-5.4p1-1-msys-1.0.13-lic.tar.lzma installing openssh-5.4p1-1-msys-1.0.13-lic.tar.lzma install: rsync-3.0.8-1-msys-1.0.17-bin.tar.lzma installing rsync-3.0.8-1-msys-1.0.17-bin.tar.lzma install: rsync-3.0.8-1-msys-1.0.17-doc.tar.lzma installing rsync-3.0.8-1-msys-1.0.17-doc.tar.lzma install: rsync-3.0.8-1-msys-1.0.17-lic.tar.lzma installing rsync-3.0.8-1-msys-1.0.17-lic.tar.lzma
各々のコマンドを実行しバージョンを確認。
C:\Users\heroween>ssh -v OpenSSH_5.4p1, OpenSSL 1.0.0 29 Mar 2010 usage: ssh [-1246AaCfgKkMNnqsTtVvXxYy] [-b bind_address] [-c cipher_spec] [-D [bind_address:]port] [-e escape_char] [-F configfile] [-I pkcs11] [-i identity_file] [-L [bind_address:]port:host:hostport] [-l login_name] [-m mac_spec] [-O ctl_cmd] [-o option] [-p port] [-R [bind_address:]port:host:hostport] [-S ctl_path] [-W host:port] [-w local_tun[:remote_tun]] [user@]hostname [command] C:\Users\heroween>rsync --version rsync version 3.0.8 protocol version 30 Copyright (C) 1996-2011 by Andrew Tridgell, Wayne Davison, and others. Web site: http://rsync.samba.org/ Capabilities: 32-bit files, 32-bit inums, 32-bit timestamps, 64-bit long ints, socketpairs, hardlinks, symlinks, no IPv6, batchfiles, inplace, append, ACLs, no xattrs, iconv, no symtimes rsync comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to redistribute it under certain conditions. See the GNU General Public Licence for details.
これでWindows上でもsshとrsyncが使えるようになった。一先ず目的は達成。
折角MSYSを入れたので、暇があったらminttyを使ってみようかと思うが、その辺りの事は気が向いたら書こう。
Windows7にVagrantをインストールして動かしてみる
業務都合でWindows7にVagrantをインストールして動かしてみた。
バージョン
- Windows7 Professional Service Pack 1
- Vagrant 1.6.3
インストール
まず、最新版のWindows向けVagrantをサイトからダウンロード。
インストーラーを起動するとセットアップウィザードの準備が始まる。
そこそこ時間のかかる準備が終わるとインストールできるようになる。
ライセンスに同意し、
インストールディレクトリ(デフォルトはC:¥HashiCorp¥Vagrant)を決定し、
インストール開始。
3分くらいでインストールが完了。
完了したらWindowsの再起動をする。
再起動後にコマンドプロントを開いてvagrantコマンドが叩けるか確認。
バージョンが表示されて確認完了。
セットアップウィザード通りに進めれば簡単にインストールできる。
動かしてみる
それでは、Vagrantのインストールが完了したので、今度は仮想マシンを起動するところまで動かしてみる。
なお、プロバイダにはVirtualBox 4.3.12を、BoxにはBentoからダウンロードしてきたCentOS 6.5の64bit版を使用する。
まずは、Boxの追加から。
C:\Users\heroween>vagrant box add C:\HashiCorp\VagrantBox\opscode_centos-6.5_chef-provisionerless.box --name opscode-centos-6.5 ==> box: Adding box 'opscode-centos-6.5' (v0) for provider: box: Downloading: file://C:/HashiCorp/VagrantBox/opscode_centos-6.5_chef-provisionerless.box box: Progress: 100% (Rate: 9870k/s, Estimated time remaining: --:--:--) ==> box: Successfully added box 'opscode-centos-6.5' (v0) for 'virtualbox'! C:\Users\heroween>vagrant box list opscode-centos-6.5 (virtualbox, 0)
次に適当な作業ディレクトリを作って仮想マシンを起動してみる。
C:\Users\heroween\VagrantProject\SampleProject>vagrant init opscode-centos-6.5 A `Vagrantfile` has been placed in this directory. You are now ready to `vagrant up` your first virtual environment! Please read the comments in the Vagrantfile as well as documentation on `vagrantup.com` for more information on using Vagrant. C:\Users\heroween\VagrantProject\SampleProject>vagrant up Bringing machine 'default' up with 'virtualbox' provider... ==> default: Importing base box 'opscode-centos-6.5'... ==> default: Matching MAC address for NAT networking... ==> default: Setting the name of the VM: SampleProject_default_1401933415261_2874 ==> default: Clearing any previously set network interfaces... ==> default: Preparing network interfaces based on configuration... default: Adapter 1: nat ==> default: Forwarding ports... default: 22 => 2222 (adapter 1) ==> default: Booting VM... ==> default: Waiting for machine to boot. This may take a few minutes... default: SSH address: 127.0.0.1:2222 default: SSH username: vagrant default: SSH auth method: private key default: Warning: Connection timeout. Retrying... ==> default: Machine booted and ready! ==> default: Checking for guest additions in VM... ==> default: Mounting shared folders... default: /vagrant => C:/Users/heroween/VagrantProject/SampleProject C:\Users\heroween\VagrantProject\SampleProject>vagrant status Current machine states: default running (virtualbox) The VM is running. To stop this VM, you can run `vagrant halt` to shut it down forcefully, or you can run `vagrant suspend` to simply suspend the virtual machine. In either case, to restart it again, simply run `vagrant up`.
無事に起動したので仮想マシンに接続する。
C:\Users\heroween\VagrantProject\SampleProject>vagrant ssh `ssh` executable not found in any directories in the %PATH% variable. Is an SSH client installed? Try installing Cygwin, MinGW or Git, all of which contain an SSH client. Or use your favorite SSH client with the following authentication information shown below: Host: 127.0.0.1 Port: 2222 Username: vagrant Private key: C:/Users/heroween/.vagrant.d/insecure_private_key
と、Windowsにsshコマンドを入れてない場合はvagrant sshでは接続できない(2014/6/6追記:Windowsにsshコマンド入れる手順を書いた)
取り敢えず今回は既に入ってたPuttyを使ってポートフォワードされたローカルの2222に接続し、
ユーザーとパスワードを入力。
接続完了。Windows上でCentOSが使えるようになった。
接続確認も終えたので、仮想マシンをシャットダウン。
C:\Users\heroween\VagrantProject\SampleProject>vagrant halt ==> default: Attempting graceful shutdown of VM... C:\Users\heroween\VagrantProject\SampleProject>vagrant status Current machine states: default poweroff (virtualbox) The VM is powered off. To restart the VM, simply run `vagrant up`
そして、仮想マシンを破棄する。
C:\Users\heroween\VagrantProject\SampleProject>vagrant destroy default: Are you sure you want to destroy the 'default' VM? [y/N] y ==> default: Destroying VM and associated drives... C:\Users\heroween\VagrantProject\SampleProject>vagrant status Current machine states: default not created (virtualbox) The environment has not yet been created. Run `vagrant up` to create the environment. If a machine is not created, only the default provider will be shown. So if a provider is not listed, then the machine is not created for that environment.
以上、特に躓くような事も無く、インストールから簡単な動作確認までできた。
今度はプロビジョニングやPackerなども試してみようと思う。
VirtualBoxでのNested Virtualizationは無理だったという話
タイトルが全てなんだが、遭遇した事の次第をメモとして書き残す。
同僚からUbuntuで試したVagrantによる環境構築を、CentOSでも検証してくれないかと依頼され、自分のマシンに入っていたVirtualBox上のCentOSで作業していたら躓いた。
環境
- ホスト1
- Windows 7 6.1.7601sp1
- VirtualBox 4.3.12
- ゲスト1 = ホスト2
- CentOS 6.4
- VirtualBox 4.3.12
- Vagrant 1.6.2
- Packer 0.6.0
- ゲスト2
- CentOS 6.5
ホスト1 -> ゲスト1 = ホスト2 -> ゲスト2という入れ子になる感じ。VagrantとPackerは今回遭遇した問題の切っ掛けでしかなく、本質的に関係は無い。
事象
基本的に以下はVirtualBox上のCentOS 6.4(環境のゲスト1 = ホスト2)で行っている作業である。
まず、ゲストのBoxが必要だったので、同僚の作ったPackerのテンプレートをクローンしてきてpacker buildを走らせたが、以下の様に仮想マシン起動後のSSH接続で動作が止まってしまった。
$ packer build --only=virtualbox-iso machine.json virtualbox-iso output will be in this color. ==> virtualbox-iso: Downloading or copying Guest additions checksums virtualbox-iso: Downloading or copying: http://download.virtualbox.org/virtualbox/4.3.12/SHA256SUMS ==> virtualbox-iso: Downloading or copying Guest additions virtualbox-iso: Downloading or copying: http://download.virtualbox.org/virtualbox/4.3.12/VBoxGuestAdditions_4.3.12.iso ==> virtualbox-iso: Downloading or copying ISO virtualbox-iso: Downloading or copying: http://ftp.riken.jp/Linux/centos/6.5/isos/x86_64/CentOS-6.5-x86_64-minimal.iso ==> virtualbox-iso: Starting HTTP server on port 8081 ==> virtualbox-iso: Creating virtual machine... ==> virtualbox-iso: Creating hard drive... ==> virtualbox-iso: Creating forwarded port mapping for SSH (host port 3213) ==> virtualbox-iso: Executing custom VBoxManage commands... virtualbox-iso: Executing: modifyvm packer-virtualbox-iso --memory 512 virtualbox-iso: Executing: modifyvm packer-virtualbox-iso --cpus 1 ==> virtualbox-iso: Starting the virtual machine... virtualbox-iso: WARNING: The VM will be started in headless mode, as configured. virtualbox-iso: In headless mode, errors during the boot sequence or OS setup virtualbox-iso: won't be easily visible. Use at your own discretion. ==> virtualbox-iso: Waiting 10s for boot... ==> virtualbox-iso: Typing the boot command... ==> virtualbox-iso: Waiting for SSH to become available...
暫く待っていたが、結局SSHのコネクションがタイムアウトしてビルドは失敗。
SSHに原因があるのかとログを確認するが、タイムアウトした以上の事は分からず、ホストのSSH、Firewallの設定、ゲストのSSH、ポートフォワードの設定を確認するが問題は無い。netstatで見るとポートフォワードされたTCPコネクションは張られているものの、SSHが応答していない感じ。
CUIのメッセージとログはそれだけだったので、一旦、ヘッドレスになっていたPackerのビルダー設定をGUI表示に切り替えてみて、再度ビルドを実行してみたところで原因が判明した。
{ "builders": [ { "headless": false ←falseでVirtualBoxのGUIが表示される } ] }
※当該設定の前後は省略
原因
再ビルドしたら、VirtualBoxが起動した所でこの様なエラーメッセージが出力された。
「ホストマシンの仮想化支援機能(VT-x/AMD-V)が使用できません。64ビット ゲストOSは64ビットCPUを検出できず、起動できません。」
なるほど、ゲストが起動していませんでした。
CUIのメッセージでは、ゲスト起動コマンド実行後にSSHの接続待ちとなっていたが、SSH接続はゲストの起動完了を待たずしてなされていたのである。そりゃあ応答しない訳だ。
で、ホストのハードウェア仮想化支援機能だが、/proc/cpuinfoを見ると確かにflagsにvmx(VT-x)が表示されていない。
$ cat /proc/cpuinfo processor : 0 vendor_id : GenuineIntel cpu family : 6 model : 42 model name : Intel(R) Core(TM) i7-2620M CPU @ 2.70GHz stepping : 7 cpu MHz : 2673.155 cache size : 6144 KB fpu : yes fpu_exception : yes cpuid level : 5 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 syscall nx rdtscp lm constant_tsc up rep_good pni monitor ssse3 lahf_lm bogomips : 5346.31 clflush size : 64 cache_alignment : 64 address sizes : 36 bits physical, 48 bits virtual power management:
CPUはIntel(R) Core(TM) i7-2620M CPU @ 2.70GHzでflagsにもlmがあるので64ビットである事は間違いないし、VT-xにも対応している。ついでにカーネルも見てみる。
$ uname -rm 2.6.32-358.6.1.el6.x86_64 x86_64
大丈夫だ。問題無い。
それでは、VirtualBoxがホストをどう認識しているのかも確認してみる。
$ VBoxManage list hostinfo Host Information: Host time: 2014-05-28T02:55:25.926000000Z Processor online count: 1 Processor count: 1 Processor online core count: 1 Processor core count: 1 Processor#0 speed: 2807 MHz Processor#0 description: Intel(R) Core(TM) i7-2620M CPU @ 2.70GHz Memory size: 1877 MByte Memory available: 1387 MByte Operating system: Linux Operating system version: 2.6.32-358.6.1.el6.x86_64
うーん、見た感じは大丈夫そう…。
対応
ホストのハードウェア仮想化支援機能が有効になっていないのであれば、有効にすれば良いじゃない。という事で、CPUはハードウェア仮想化支援機能に対応しているので、BIOSでその設定を有効にする事ができるはずなのだが、対象となるホストはVirtualBox上のマシンであるので、まず、VirtualBoxにハードウェア仮想化支援機能の設定があるのかどうか確認してみた。
すると、仮想マシンの設定 -> システム -> アクセラレーションに「VT-x/AMD-Vを有効化」とまさに該当するものがあった…のだが、既に有効化されている…。
今度は仮想マシンを起動してBIOSを確認するが、ハードウェア仮想化支援機能に該当する設定は見当たらず、BIOSからは設定を確認できないようだ。
あるぇ〜?となって調べてみると、結構昔からあるVirtualBoxのfeature-requestを見つけたのだが、それによるとVirtualBoxではNested Virtualizationに対応しておらず、仮想マシン上ではハードウェア仮想化支援機能がまともに機能しないようである。そして、その機能を実現する見通しも無いっぽい。
結論
という訳で、今回やろうとしていた事はそもそもできなかったという結論に到った。尚、VMwareなんかではできるようなのだが、そちらの方は詳しく調べてはいない。
以上、VirtualBoxでのNested Virtualizationは無理だったという話でした。
nokogiriのインストールでハマった件
自宅のMacでVagrant弄っていて、プラグインをあれこれ試そうとインストールした際にちょっとハマったので、その時の問題解消までの経緯をメモしとく。
最初に結論を書いておくが、
keg-onlyのformulaのbrew linkを忘れるな!
という事です。以下蛇足。
Vagrantプラグインのvagrant-omnibusのインストール時に以下のようなメッセージが出力された。
$ vagrant plugin install vagrant-omnibus Installing the 'vagrant-omnibus' plugin. This can take a few minutes... Building nokogiri using packaged libraries. Building libxml2-2.8.0 for nokogiri with the following patches applied: - 0001-Fix-parser-local-buffers-size-problems.patch - 0002-Fix-entities-local-buffers-size-problems.patch - 0003-Fix-an-error-in-previous-commit.patch - 0004-Fix-potential-out-of-bound-access.patch - 0005-Detect-excessive-entities-expansion-upon-replacement.patch - 0006-Do-not-fetch-external-parsed-entities.patch - 0007-Enforce-XML_PARSER_EOF-state-handling-through-the-pa.patch - 0008-Improve-handling-of-xmlStopParser.patch - 0009-Fix-a-couple-of-return-without-value.patch - 0010-Keep-non-significant-blanks-node-in-HTML-parser.patch - 0011-Do-not-fetch-external-parameter-entities.patch ************************************************************************ IMPORTANT! Nokogiri builds and uses a packaged version of libxml2. If this is a concern for you and you want to use the system library instead, abort this installation process and reinstall nokogiri as follows: gem install nokogiri -- --use-system-libraries If you are using Bundler, tell it to use the option: bundle config build.nokogiri --use-system-libraries bundle install However, note that nokogiri does not necessarily support all versions of libxml2. For example, libxml2-2.9.0 and higher are currently known to be broken and thus unsupported by nokogiri, due to compatibility problems and XPath optimization bugs. ************************************************************************
メッセージの2行目から分かる通り、VagrantプラグインのインストールにRubyGemsのnokogiriが必要で、テスト用の環境にはまだnokogiriをインストールしていなかった為、nokogiriをビルドし始めた模様。
で、そのnokogiriなんだけど、バージョン1.6から依存ライブラリであるlibxml2(とlibxslt)を同梱するようになっており、インストール時に毎度それらも合わせてビルドされる為、非常に時間がかかる様になった。
メッセージの3行目以降はそれに関連したもので、既にマシンにlibxml2がインストールされている場合は、gemやbundlerのコマンドにオプションを付与する事で、nokogiriに同梱されているものではなく、インストール済みのものを使ってビルドする事ができるよと書いてある(libxml2のバージョンを全てサポートしてる訳じゃないが)。
私のMacには既にhomebrewでlibxml2がインストールされていて、バージョンも問題無かったので一旦vagrant-omnibusのインストールを中断し、改めてgemでnokogiriをインストールしたところ、以下の様なエラーメッセージが出力されてビルドがこけた。
$ NOKOGIRI_USE_SYSTEM_LIBRARIES=1 gem install nokogiri --no-rdoc --no-ri Building native extensions. This could take a while... Building nokogiri using system libraries. ERROR: Error installing nokogiri: ERROR: Failed to build gem native extension. /usr/local/var/RBENV_ROOT/versions/1.9.3-p547/bin/ruby extconf.rb Building nokogiri using system libraries. libxml2 version 2.6.21 or later is required! *** extconf.rb failed *** Could not create Makefile due to some reason, probably lack of necessary libraries and/or headers. Check the mkmf.log file for more details. You may need configuration options. Provided configuration options: --with-opt-dir --without-opt-dir --with-opt-include --without-opt-include=${opt-dir}/include --with-opt-lib --without-opt-lib=${opt-dir}/lib --with-make-prog --without-make-prog --srcdir=. --curdir --ruby=/usr/local/var/RBENV_ROOT/versions/1.9.3-p547/bin/ruby --help --clean --use-system-libraries=true --with-zlib-dir --without-zlib-dir --with-zlib-include --without-zlib-include=${zlib-dir}/include --with-zlib-lib --without-zlib-lib=${zlib-dir}/lib --with-xml2-dir --without-xml2-dir --with-xml2-include --without-xml2-include=${xml2-dir}/include --with-xml2-lib --without-xml2-lib=${xml2-dir}/lib --with-libxml-2.0-config --without-libxml-2.0-config --with-pkg-config --without-pkg-config --with-xslt-dir --without-xslt-dir --with-xslt-include --without-xslt-include=${xslt-dir}/include --with-xslt-lib --without-xslt-lib=${xslt-dir}/lib --with-libxslt-config --without-libxslt-config --with-exslt-dir --without-exslt-dir --with-exslt-include --without-exslt-include=${exslt-dir}/include --with-exslt-lib --without-exslt-lib=${exslt-dir}/lib --with-libexslt-config --without-libexslt-config Gem files will remain installed in /usr/local/var/RBENV_ROOT/versions/1.9.3-p547/gemsets/global/gems/nokogiri-1.6.2.1 for inspection. Results logged to /usr/local/var/RBENV_ROOT/versions/1.9.3-p547/gemsets/global/gems/nokogiri-1.6.2.1/ext/nokogiri/gem_make.out
最初に挙げたメッセージと見比べれば分かるが、2行目のメッセージ内容が、
Building nokogiri using packaged libraries.
から、
Building nokogiri using system libraries.
に変わっているので、インストール済みのlibxml2を使う様に指定はされているのだが、libxml2が無いよと言われてビルドできない。
インストール自体はされているのに一体何故だ?と、この時点で普通にlibxml2が有効になっているかどうかを確認すべきだったが、有効になっているものだと思い込んでしまっており、気が付くまでに小一時程無駄にした。
思考と試行の末に漸くシンボリックリンクを疑い始め、brew infoしたら案の定libxml2が有効になっていなかった事を確認。何度か環境を作り直しているマシンだったので、以前構築した際にkeg-onlyのformulaを一部brew linkし忘れていたようだorz
以下のコマンドを実行してから再度nokogiriをビルドしたら無事にインストールできた。
$ brew link --force libxml2
これでやっとVagrantのプラグインもインストールできましたとさ。めでたしめでたし。
rbenvのrehashみたいに、この辺を自動的に補完してくれる様なコマンドオプションとかないかなーと思って調べてみたけど無さそうなので、取り敢えず最後にもう一度、
keg-onlyのformulaのbrew linkを忘れるな!
大事な事なので以下略。おわり。
山城さんの送別会に行ってきた
昨日、山城さんの送別会に行ってきました。
ブログに書くまでがjava-jaという訳で、はてブロ作って書きました。
経緯
山城さんが亡くなった事を知ったのは1月のこと。
送別会の参加募集ページの方を先に見つけ、内容からjava-jaの悪ふざけだろうと断定し、山城さん海外にでも行くのかな?くらいに思っていたのですが、その後に太一さん経由で事実を知った会社の同僚から、本当に亡くなったそうだと教えられました。
私は山城さんとは顔見知り程度の仲で、さほど親しかった訳ではありません。しかし、同年代でありながら、java-jaやその他の勉強会で大いに活躍される姿を遠巻きに見ていて、彼に対しては正直なところ憧れを持っていました。
彼の死というものは、私にとっても少なからず衝撃でありました。
親しい方が多かったであろう山城さんの送別会への参加は、多少憚られたのですが、募集人数が落ち着いたのを見計らい、最後の方の枠に滑り込ませてもらった次第です。
送別会
送別会は大体以下の様な感じでした。
ハチャメチャです。
形見分けの儀においては、こちらの品物を頂きました。
吉良のネクタイ?
いいえ、菌です。
更に詳しくどのような様子であったか知りたい方は、親しかった皆様が沢山書かれているので、そちらをご覧頂ければ分かるかと思います。非常にらしいというかなんというか、山城さんの人柄を偲ばせるような、それはそれは愉快な、そして爽快な送る会でありました。
ご遺族や太一さんをはじめ、このような機会を与えてくださった関係者の皆々様に厚く御礼申し上げます。
思い出
折角なので、少し山城さんとの思い出も書きます。
山城さんを初めて知ったのは、ゆろよろさん主催のJVM勉強会での事でした。
この勉強会は私が初めて参加した勉強会だったのですが、懇親会で一つの事件がありました。懇親会参加予定者が大量にドタキャンしたのです。この時に幹事をされていたのが誰あろう山城さんその人だったのです。
私は懇親会に不参加だったので、後にTwitterのTL上でこの騒動を知るのですが、名幹事山城という名を覚えたのがこの時でした。
それから暫くを経て、初java-jaであったjava-ja.js #2でお見かけするなどありつつ、初めてお話する機会となったのが、次の年の197Xパーティーでした。
この時にどんな会話をしたかは実はあまり覚えていないのですが、初対面ということもあり敬語で話す私に「あのさぁ、マジで敬語とか使わないでよ。堅苦しいの無しでいこうぜ!」と気さくに接してくれたのはよく覚えています。
これを切っ掛けに顔見知りとなり、2011年はPHPでTDD&CIワークショップやPHPカンファレンス2011などで、当時山城さんが取り組まれていた事を教えてもらったり、アジャイルサムライ他流試合では共にスタッフとして働いたりしました。以降も方々の勉強会等でお会いすれば挨拶し、一言二言会話をするような仲となりました。
しかし、ここ1、2年程は私自身があまり表に出なくなった事や、プライベートな関係もほぼ無かった事でお会いする機会も徐々に減り、ブログのエントリがホッテントリになってるのを見かけたり、どこどこを辞められたという話を人伝に聞いたりする程度になっていました。
そして、久しぶりに飛び込んで来たのが彼の訃報でありました。
振り返ってみると、関係自体は薄かったのですが、勉強会で目にする山城さんは、私にはとても輝いて見えており、憧れの対象の一人でありました。そんな彼が亡くなっていて、その事実を一月以上を経て知る事となり、全く現実味の無い中でその死を確認すべく送別会に参加する事に決めたのです。
参加してみたら、会場のどこからかひょっこり出てくるのでは?とか、あの妹さんは実は山城さんなのでは?みたいな事を考えたりもしましたが、そんな事も無く、彼はやはり亡くなっておりました。
最後に
私が山城さんに対して感じていたものは、この送別会でより一層強くなりました。不謹慎かもしれませんが、山城さんと彼を慕う人々との関係を目の当たりにし、正直羨ましいとさえ思ったくらいです。そして、初めてその死を実感しました。早過ぎます…。
突然の死をむかえ、きっとやり残した事や、思い残す事が多々あったでしょう。それを思うと誠に残念でなりません。山城さん、どうか安らかに。ご冥福をお祈り申し上げます。