From e8d1ba4f61b9f4b2b0b88ab19a268d1361c0fefb Mon Sep 17 00:00:00 2001 From: Ai Makabi Date: Thu, 9 Jan 2014 19:00:17 +0900 Subject: [PATCH 1/5] =?UTF-8?q?Virtual=E7=92=B0=E5=A2=83=E3=81=AE=E3=82=BB?= =?UTF-8?q?=E3=83=83=E3=83=88=E3=82=A2=E3=83=83=E3=83=97=E3=81=AB=E9=96=A2?= =?UTF-8?q?=E3=81=99=E3=82=8B=E8=AA=AC=E6=98=8E=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- env/SetUpVirtualMachine.md | 143 +++++++++++++++++++++++++++++++++++++ 1 file changed, 143 insertions(+) create mode 100644 env/SetUpVirtualMachine.md diff --git a/env/SetUpVirtualMachine.md b/env/SetUpVirtualMachine.md new file mode 100644 index 0000000..2fd72d5 --- /dev/null +++ b/env/SetUpVirtualMachine.md @@ -0,0 +1,143 @@ +# Virtual Machineのセットアップ方法 +## 必要なソフト + - VirtualBox + - Vagrnt + - (for Windows) Putty or TeraTerm + +## 作業手順 +#### VagrantによるVirtual環境のセットアップ +Vagrantを利用して,課題等を行うためのVirtual環境を構築する.
+Windows環境の詳細は説明はリンク先を参照:[Windows7で Vagrant & VirtualBox](http://www.jnlp.org/okada/computer/vagrant-virtualbox) + +まず課題用のフォルダを作成し,ターミナル(or コマンドプロンプト)を立ち上げてそこに移動する.
+移動先で以下のコマンドを実行: + +``` +$ vagrant add +(e.g. vagrant add centos64 http://developer.nrel.gov/downloads/vagrant-boxes/CentOS-6.4-i386-v20130731.box) +$ vagrant init +$ ls +Vagrantfile (Vagrantfileが作成されていることを確認) +``` + +ここでboxとは,導入するVirtual環境のことである.
+リンク先で様々なboxを入手することが出来る:[Vagrantbox.es](http://www.vagrantbox.es/)
+今回はCentOSを利用するので,boxリストの中からCentOSを選択して導入する.
+`vagrant init`で無事にVagrantfileが作成したことが確認できたら,Vagrantfileを編集する. + + - box名を`base`から導入したbox名に変更(例の場合,centos64) + - vm.providerの設定を追加し,Virtualboxに名前をつける(任意.設定例の場合nlp_envとなっているが,nlp-localでも何でも好きにどうぞ) + - private networkの設定に関する記述をコメントアウト + +設定例:https://gist.github.com/amacbee/7784823 + +ここまで完了したら,ターミナル上で以下のコマンドを実行して,Virtual環境を起動する. + +``` +$ vagrant up +``` + +無事に起動したらVirtual環境のセットアップは終了. + +#### Virtual環境にログイン +*nix系のOSの場合,`vagrant ssh`でVirtual環境にログインできる.
+しかし,Windowsの場合はPuttyやTeraTermといったソフトを介する必要がある.
+コマンドプロンプト上で`vagrant ssh-config`と打つと,Virtual環境にログインするための設定が確認できる.
+ログインの例を以下に示す(for TeraTerm). + + - TCP/IPによるログインを選択 + - ホスト:vagrant@127.0.0.1 + - TCPポート:2222 + -サービス:SSH(SSH2) + - (※初回のみ) fingerprintが表示されるので,`続行`を選択 + - SSH認証 + - パスワード:vagrant(初期設定) + - RSA/DSA/ECDSA鍵を使う + - `秘密鍵`を選択 + - ファイルの種類は,`すべてのファイル` + - `C:\Users\(ユーザ名)\.vagrant.d\insecure_private_key`を選択 + - OKを押すとログインできる + +#### Chefによる初期環境の構築 (proxy環境想定) +[Chef](http://www.getchef.com/chef/)を用いて,Virtual環境上にNLP用の初期環境を構築する.
+まずChef本体を導入するために,リンク先からVirtual環境に適したインストール方法でChef本体を導入する:
+http://www.getchef.com/chef/install/
+※CentOSの場合は,Virtual環境上で以下のコマンドを打つことでインストール出来る: + +``` +$ export http_proxy=http://*****:8080 +$ curl -L http://www.opscode.com/chef/install.sh | sudo bash +$ which chef-solo +/usr/bin/chef-solo (こう返ってきたら成功!) +``` + +※以下,スーパーユーザー権限で実行する
+Chefを導入できたら,`yum`コマンドで`git`を導入する. + +``` +$ export http_proxy=http://*****:8080 +$ yum -y install git +``` + +`git`コマンドを用いて,Opscode社の提供するベーシックなchef-repoを導入する. + +``` +$ git config --global https.proxy https://*****:8080 +$ git config --global http.proxy http://*****:8080 +$ git config --global url."https://".insteadOf git:// +$ git clone git://github.com/opscode/chef-repo.git +``` + +成功すると,`chef-repo`という名前のディレクトリが作成される.
+ディレクトリ構成は次の通り. + +``` +$ ls +certificates chefignore config cookbooks data_bags environments LICENSE Rakefile README.md roles +``` + +`cookbooks`ディレクトリに移動して,必要なcookbookをGithubからcloneしてくる.
+本演習用の環境構築の場合,必要なリポジトリは以下の通り (`chef-***`は,頭についている`chef-`を外す). + +``` +$ cd cookbooks +$ git clone git://github.com/amacbee/chef-env.git +$ mv -v chef-env env +chef-env -> env +$ git clone git://github.com/amacbee/chef-mecab.git +$ mv -v chef-mecab mecab +mecab -> mecab +$ git clone git://github.com/amacbee/chef-cabocha.git +$ mv -v chef-cabocha cabocha +cabocha -> cabocha +$ git clone git://github.com/opscode-cookbooks/yum.git +$ git clone git://github.com/opscode-cookbooks/build-essential.git +$ git clone git://github.com/opscode-cookbooks/yum.git +$ git clone git://github.com/opscode-cookbooks/yum-epel.git +$ git clone git://github.com/opscode-cookbooks/python.git +``` + +必要なファイルの導入が終わったら,実際にシステムにインストールを行う.
+まず,`chef-repo`直下に`localhost.json`(名前は適当で良い)ファイルを作成し,インストールするリストを指定する.
+今回の場合はリンク先の通り:
+https://gist.github.com/amacbee/8296997 + +更に,`chef-repo`直下に`solo.rb`というファイルを作成し,以下の通り記述する. + +``` +file_cache_path "/tmp/chef-solo" +cookbook_path ["/home/vagrant/chef-repo/cookbooks"] +``` + +これで準備は終了である.
+最後に以下のコマンドを実行して,必要な環境を自動構築する. + +``` +$ chef-solo -c solo.rb -j ./localhost.json +``` + +以上で必要な環境構築は終了(2014.01.09現在) + + + + From 46b3d024a3c4f173f012c02c847014dc8b0033e1 Mon Sep 17 00:00:00 2001 From: Ai Makabi Date: Thu, 9 Jan 2014 20:29:03 +0900 Subject: [PATCH 2/5] =?UTF-8?q?git=20clone=E3=81=AE=E8=A8=98=E8=BF=B0?= =?UTF-8?q?=E3=81=A7=E9=87=8D=E8=A4=87=E3=81=97=E3=81=A6=E3=81=84=E3=82=8B?= =?UTF-8?q?=E7=AE=87=E6=89=80=E3=82=92=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- env/SetUpVirtualMachine.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/env/SetUpVirtualMachine.md b/env/SetUpVirtualMachine.md index 2fd72d5..46bdc69 100644 --- a/env/SetUpVirtualMachine.md +++ b/env/SetUpVirtualMachine.md @@ -112,7 +112,6 @@ $ mv -v chef-cabocha cabocha cabocha -> cabocha $ git clone git://github.com/opscode-cookbooks/yum.git $ git clone git://github.com/opscode-cookbooks/build-essential.git -$ git clone git://github.com/opscode-cookbooks/yum.git $ git clone git://github.com/opscode-cookbooks/yum-epel.git $ git clone git://github.com/opscode-cookbooks/python.git ``` @@ -133,7 +132,7 @@ cookbook_path ["/home/vagrant/chef-repo/cookbooks"] 最後に以下のコマンドを実行して,必要な環境を自動構築する. ``` -$ chef-solo -c solo.rb -j ./localhost.json +$ sudo chef-solo -c solo.rb -j ./localhost.json ``` 以上で必要な環境構築は終了(2014.01.09現在) From a015669e05318345d444ae58e19c9641336bb6fb Mon Sep 17 00:00:00 2001 From: Ai Makabi Date: Thu, 9 Jan 2014 20:30:54 +0900 Subject: [PATCH 3/5] =?UTF-8?q?=E7=B4=B0=E3=81=8B=E3=81=84=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- env/SetUpVirtualMachine.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/env/SetUpVirtualMachine.md b/env/SetUpVirtualMachine.md index 46bdc69..cfcb640 100644 --- a/env/SetUpVirtualMachine.md +++ b/env/SetUpVirtualMachine.md @@ -58,7 +58,7 @@ $ vagrant up - `C:\Users\(ユーザ名)\.vagrant.d\insecure_private_key`を選択 - OKを押すとログインできる -#### Chefによる初期環境の構築 (proxy環境想定) +#### Chefによる初期環境の構築 (proxy環境想定 ※非推奨) [Chef](http://www.getchef.com/chef/)を用いて,Virtual環境上にNLP用の初期環境を構築する.
まずChef本体を導入するために,リンク先からVirtual環境に適したインストール方法でChef本体を導入する:
http://www.getchef.com/chef/install/
@@ -106,10 +106,10 @@ $ mv -v chef-env env chef-env -> env $ git clone git://github.com/amacbee/chef-mecab.git $ mv -v chef-mecab mecab -mecab -> mecab +chef-mecab -> mecab $ git clone git://github.com/amacbee/chef-cabocha.git $ mv -v chef-cabocha cabocha -cabocha -> cabocha +chef-cabocha -> cabocha $ git clone git://github.com/opscode-cookbooks/yum.git $ git clone git://github.com/opscode-cookbooks/build-essential.git $ git clone git://github.com/opscode-cookbooks/yum-epel.git @@ -132,7 +132,7 @@ cookbook_path ["/home/vagrant/chef-repo/cookbooks"] 最後に以下のコマンドを実行して,必要な環境を自動構築する. ``` -$ sudo chef-solo -c solo.rb -j ./localhost.json +$ chef-solo -c solo.rb -j ./localhost.json ``` 以上で必要な環境構築は終了(2014.01.09現在) From b84e07edb286743888167e8016c411cb3cd5deb7 Mon Sep 17 00:00:00 2001 From: Ai Makabi Date: Thu, 9 Jan 2014 20:35:24 +0900 Subject: [PATCH 4/5] =?UTF-8?q?vi=E3=81=AB=E9=96=A2=E3=81=99=E3=82=8B?= =?UTF-8?q?=E8=A8=98=E8=BF=B0=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- env/SetUpVirtualMachine.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/env/SetUpVirtualMachine.md b/env/SetUpVirtualMachine.md index cfcb640..784ec8e 100644 --- a/env/SetUpVirtualMachine.md +++ b/env/SetUpVirtualMachine.md @@ -121,6 +121,10 @@ $ git clone git://github.com/opscode-cookbooks/python.git 今回の場合はリンク先の通り:
https://gist.github.com/amacbee/8296997 +なお,ファイルの作成/編集にはviを利用する.
+viの基本的な使い方はリンク先を参照:
+http://net-newbie.com/linux/commands/vi.html + 更に,`chef-repo`直下に`solo.rb`というファイルを作成し,以下の通り記述する. ``` From afe4ea339701594a8c63ce0e29f2b24fd152fa78 Mon Sep 17 00:00:00 2001 From: Ai Makabi Date: Tue, 4 Mar 2014 04:41:35 +0900 Subject: [PATCH 5/5] =?UTF-8?q?Proxy=E8=A8=AD=E5=AE=9A=E3=82=92vagrant-pro?= =?UTF-8?q?xyconf=E3=82=92=E5=88=A9=E7=94=A8=E3=81=99=E3=82=8B=E5=BD=A2?= =?UTF-8?q?=E5=BC=8F=E3=81=AB=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- env/SetUpVirtualMachine.md | 73 +++++++++++++++++++++++--------------- 1 file changed, 45 insertions(+), 28 deletions(-) diff --git a/env/SetUpVirtualMachine.md b/env/SetUpVirtualMachine.md index 784ec8e..d38d913 100644 --- a/env/SetUpVirtualMachine.md +++ b/env/SetUpVirtualMachine.md @@ -5,29 +5,43 @@ - (for Windows) Putty or TeraTerm ## 作業手順 +※以下の環境で動作確認を行った (2014/03/04現在) +Mac OS X 10.9.2 +VirtualBox 4.3.8 +Vagrant 1.4.3 + #### VagrantによるVirtual環境のセットアップ -Vagrantを利用して,課題等を行うためのVirtual環境を構築する.
+Vagrantを利用して,課題等を行うためのVirtual環境を構築する. Windows環境の詳細は説明はリンク先を参照:[Windows7で Vagrant & VirtualBox](http://www.jnlp.org/okada/computer/vagrant-virtualbox) -まず課題用のフォルダを作成し,ターミナル(or コマンドプロンプト)を立ち上げてそこに移動する.
+※Proxy環境下にある場合は,以下のコマンドを実行してpluginをインストールする. +以下のコマンドが実行できない場合は,手元の環境で正しくproxyが設定できているか確認する. +Linux or Macの場合はexportで設定できる (e.g. export http_proxy="http://proxy.***:8080") + +``` +$ vagrant plugin install vagrant-proxyconf +``` + +まず課題用のフォルダを作成し,ターミナル(or コマンドプロンプト)を立ち上げてそこに移動する. 移動先で以下のコマンドを実行: ``` $ vagrant add -(e.g. vagrant add centos64 http://developer.nrel.gov/downloads/vagrant-boxes/CentOS-6.4-i386-v20130731.box) +(e.g. vagrant add centos65 https://github.com/2creatives/vagrant-centos/releases/download/v6.5.1/centos65-x86_64-20131205.box) $ vagrant init $ ls Vagrantfile (Vagrantfileが作成されていることを確認) ``` -ここでboxとは,導入するVirtual環境のことである.
-リンク先で様々なboxを入手することが出来る:[Vagrantbox.es](http://www.vagrantbox.es/)
-今回はCentOSを利用するので,boxリストの中からCentOSを選択して導入する.
+ここでboxとは,導入するVirtual環境のことである. +リンク先で様々なboxを入手することが出来る:[Vagrantbox.es](http://www.vagrantbox.es/) +今回はCentOS 6.5 64bitを利用するので,boxリストの中から`CentOS 6.5 x86_64`を探し,そのURLをコピーして導入する (指定したbox以外は動作確認していない). `vagrant init`で無事にVagrantfileが作成したことが確認できたら,Vagrantfileを編集する. - - box名を`base`から導入したbox名に変更(例の場合,centos64) + - box名を`base`から導入したbox名に変更(例の場合,centos65) - vm.providerの設定を追加し,Virtualboxに名前をつける(任意.設定例の場合nlp_envとなっているが,nlp-localでも何でも好きにどうぞ) - private networkの設定に関する記述をコメントアウト + - (if proxy環境) vagrant-proxyconfを利用してproxy環境の設定を追加 設定例:https://gist.github.com/amacbee/7784823 @@ -40,9 +54,9 @@ $ vagrant up 無事に起動したらVirtual環境のセットアップは終了. #### Virtual環境にログイン -*nix系のOSの場合,`vagrant ssh`でVirtual環境にログインできる.
-しかし,Windowsの場合はPuttyやTeraTermといったソフトを介する必要がある.
-コマンドプロンプト上で`vagrant ssh-config`と打つと,Virtual環境にログインするための設定が確認できる.
+*nix系のOSの場合,`vagrant ssh`でVirtual環境にログインできる. +しかし,Windowsの場合はPuttyやTeraTermといったソフトを介する必要がある. +コマンドプロンプト上で`vagrant ssh-config`と打つと,Virtual環境にログインするための設定が確認できる. ログインの例を以下に示す(for TeraTerm). - TCP/IPによるログインを選択 @@ -59,36 +73,39 @@ $ vagrant up - OKを押すとログインできる #### Chefによる初期環境の構築 (proxy環境想定 ※非推奨) -[Chef](http://www.getchef.com/chef/)を用いて,Virtual環境上にNLP用の初期環境を構築する.
-まずChef本体を導入するために,リンク先からVirtual環境に適したインストール方法でChef本体を導入する:
-http://www.getchef.com/chef/install/
-※CentOSの場合は,Virtual環境上で以下のコマンドを打つことでインストール出来る: +[Chef](http://www.getchef.com/chef/)を用いて,Virtual環境上にNLP用の初期環境を構築する. +まずChef本体を導入するために,リンク先からVirtual環境に適したインストール方法でChef本体を導入する: +http://www.getchef.com/chef/install/ +※CentOSの場合は,Virtual環境にログインした後,Virtual環境上で以下のコマンドを打つことでインストール出来る: ``` -$ export http_proxy=http://*****:8080 $ curl -L http://www.opscode.com/chef/install.sh | sudo bash $ which chef-solo /usr/bin/chef-solo (こう返ってきたら成功!) ``` -※以下,スーパーユーザー権限で実行する
+※以下,スーパーユーザー権限で実行する Chefを導入できたら,`yum`コマンドで`git`を導入する. ``` -$ export http_proxy=http://*****:8080 $ yum -y install git ``` -`git`コマンドを用いて,Opscode社の提供するベーシックなchef-repoを導入する. +proxy環境にある場合は以下のコマンドを実行し,`git`のproxy設定を行う ``` -$ git config --global https.proxy https://*****:8080 +$ git config --global https.proxy http://*****:8080 $ git config --global http.proxy http://*****:8080 +``` + +`git`コマンドを用いて,Opscode社の提供するベーシックなchef-repoを導入する. + +``` $ git config --global url."https://".insteadOf git:// $ git clone git://github.com/opscode/chef-repo.git ``` -成功すると,`chef-repo`という名前のディレクトリが作成される.
+成功すると,`chef-repo`という名前のディレクトリが作成される. ディレクトリ構成は次の通り. ``` @@ -96,7 +113,7 @@ $ ls certificates chefignore config cookbooks data_bags environments LICENSE Rakefile README.md roles ``` -`cookbooks`ディレクトリに移動して,必要なcookbookをGithubからcloneしてくる.
+`cookbooks`ディレクトリに移動して,必要なcookbookをGithubからcloneしてくる. 本演習用の環境構築の場合,必要なリポジトリは以下の通り (`chef-***`は,頭についている`chef-`を外す). ``` @@ -110,19 +127,19 @@ chef-mecab -> mecab $ git clone git://github.com/amacbee/chef-cabocha.git $ mv -v chef-cabocha cabocha chef-cabocha -> cabocha +$ git clone git://github.com/amacbee/python.git $ git clone git://github.com/opscode-cookbooks/yum.git $ git clone git://github.com/opscode-cookbooks/build-essential.git $ git clone git://github.com/opscode-cookbooks/yum-epel.git -$ git clone git://github.com/opscode-cookbooks/python.git ``` -必要なファイルの導入が終わったら,実際にシステムにインストールを行う.
-まず,`chef-repo`直下に`localhost.json`(名前は適当で良い)ファイルを作成し,インストールするリストを指定する.
-今回の場合はリンク先の通り:
+必要なファイルの導入が終わったら,実際にシステムにインストールを行う. +まず,`chef-repo`直下に`localhost.json`(名前は適当で良い)ファイルを作成し,インストールするリストを指定する. +今回の場合はリンク先の通り: https://gist.github.com/amacbee/8296997 -なお,ファイルの作成/編集にはviを利用する.
-viの基本的な使い方はリンク先を参照:
+なお,ファイルの作成/編集にはviを利用する. +viの基本的な使い方はリンク先を参照: http://net-newbie.com/linux/commands/vi.html 更に,`chef-repo`直下に`solo.rb`というファイルを作成し,以下の通り記述する. @@ -132,7 +149,7 @@ file_cache_path "/tmp/chef-solo" cookbook_path ["/home/vagrant/chef-repo/cookbooks"] ``` -これで準備は終了である.
+これで準備は終了である. 最後に以下のコマンドを実行して,必要な環境を自動構築する. ```