[開発] Azure VM Linux Ubuntu 上で Hyperledger Fabric を構築する

Azure VM Linux Ubuntu 上で Hyperledger Fabric を構築する
(公式サイトを参考にピヨっこが実行した格闘日記)

■結論
VT-xがネストできないからNested Virtualization (VM on/in VM)でVirtualBoxは使えない。
公式サイトの手順通りではFabric触れないが、
「Building outside of Vagrant」というの試す価値はあるげ
http://hyperledger-fabric.readthedocs.io/en/latest/dev-setup/build/

------------------------------------------------

ユーザ切り替えすると環境変数が消えるくさい
┃user1@VM01:~$ export GOPATH=$HOME/goworkspace
┃user1@VM01:~$ export PATH=$PATH:$GOPATH/bin


■Fabricプロジェクトのクローン (fabricのソースのDL)
Fabric repoをクローン(GitCloneする)
これでGOPATHが多数の部品を持てるようになる

┃user1@VM01:~$ cd $GOPATH/src
┃user1@VM01:~/goworkspace/src$ mkdir -p github.com/hyperledger
┃user1@VM01:~/goworkspace/src$ cd github.com/hyperledger
┃user1@VM01:~/goworkspace/src/github.com/hyperledger$

Linux Fundation IDの取得
https://identity.linuxfoundation.org/user

Gerritでソース管理しているので、そっからクローンすること
|log| user1@VM01:~/goworkspace/src/github.com/hyperledger$ export PATH=$PATH:$GOPATH/bin
|log| user1@VM01:~/goworkspace/src/github.com/hyperledger$ git clone ssh://{myAccount}@gerrit.hyperledger.org:29418/fabric && scp -p -P 29418 LFID@gerrit.hyperledger.org:hooks/commit-msg fabric/.git/hooks/
|log| Cloning into 'fabric'...
|log| The authenticity of host '[gerrit.hyperledger.org]:29418 ([198.145.29.90]:29418)' can't be established.
|log| RSA key fingerprint is SHA256:CmbXGx0NrGe5v8Kzqqp/NUyQXjG36syObAFyC1xXdks.
|log| Are you sure you want to continue connecting (yes/no)? y
|log| Please type 'yes' or 'no': yes
|log| Warning: Permanently added '[gerrit.hyperledger.org]:29418,[198.145.29.90]:29418' (RSA) to the list of known hosts.
|log| Permission denied (publickey).
|log| fatal: Could not read from remote repository.
|log|
|log| Please make sure you have the correct access rights and the repository exists.
|log| | user1@VM01:~/goworkspace/src/github.com/hyperledger$
参照権限がどうのいうので、

hshimo氏の方法で挑戦
|log| user1@VM01:~/goworkspace/src/github.com/hyperledger$ git clone https://github.com/{myAccount}/fabric.git
|log| Cloning into 'fabric'...
|log| Username for 'https://github.com': {myAccount}
|log| Password for 'https://{myAccount}@github.com':
|log| remote: Invalid username or password.
|log| fatal: Authentication failed for 'https://github.com/{myAccount}/fabric.git/'
|log| user1@VM01:~/goworkspace/src/github.com/hyperledger$
GitHubのアカウントなんて作った過去ないけ、失敗上等。

GARAPON氏の方法で挑戦 → 成功
┃user1@VM01:~/goworkspace/src/github.com/hyperledger$ pwd
┃/home/user1/goworkspace/src/github.com/hyperledger
┃user1@VM01:~/goworkspace/src/github.com/hyperledger$ git config --global core.autocrlf false
┃user1@VM01:~/goworkspace/src/github.com/hyperledger$ git clone https://github.com/hyperledger/fabric.git
| Cloning into 'fabric'...
| remote: Counting objects: 5979, done.
| remote: Compressing objects: 100% (141/141), done.
| remote: Total 5979 (delta 33), reused 0 (delta 0), pack-reused 5826
| Receiving objects: 100% (5979/5979), 23.46 MiB | 13.53 MiB/s, done.
| Resolving deltas: 100% (2249/2249), done.
| Checking connectivity... done.
| user1@VM01:~/goworkspace/src/github.com/hyperledger$


VagrantでVMを自動起動してみる
┃user1@VM01:~/goworkspace/src/github.com/hyperledger$ cd $GOPATH/src/github.com/hyperledger/fabric/devenv
┃user1@VM01:~/goworkspace/src/github.com/hyperledger/fabric/devenv$ vagrant up
| Bringing machine 'default' up with 'virtualbox' provider...
| ==> default: Box 'hyperledger/fabric-baseimage' could not be found. Attempting to find and install...
| default: Box Provider: virtualbox
| default: Box Version: 0.1.0
| ==> default: Loading metadata for box 'hyperledger/fabric-baseimage'
| default: URL: https://atlas.hashicorp.com/hyperledger/fabric-baseimage
| ==> default: Adding box 'hyperledger/fabric-baseimage' (v0.1.0) for provider: virtualbox
| default: Downloading: https://atlas.hashicorp.com/hyperledger/boxes/fabric-baseimage/versions/0.1.0/providers/virtualbox.box
| default: Progress: 35% (Rate: 21.5M/s, Estimated time remaining: 0:00:28)
| ==> default: Successfully added box 'hyperledger/fabric-baseimage' (v0.1.0) for 'virtualbox'!
| ==> default: Importing base box 'hyperledger/fabric-baseimage'...
| ==> default: Matching MAC address for NAT networking...
| ==> default: Checking if box 'hyperledger/fabric-baseimage' is up to date...
| ==> default: Setting the name of the VM: hyperledger
| ==> default: Clearing any previously set network interfaces...
| ==> default: Preparing network interfaces based on configuration...
| default: Adapter 1: nat
| ==> default: Forwarding ports...
| default: 7050 (guest) => 7050 (host) (adapter 1)
| default: 7051 (guest) => 7051 (host) (adapter 1)
| default: 7054 (guest) => 7054 (host) (adapter 1)
| default: 7053 (guest) => 7053 (host) (adapter 1)
| default: 22 (guest) => 2222 (host) (adapter 1)
| ==> default: Running 'pre-boot' VM customizations...
| ==> default: Booting VM...
| There was an error while executing `VBoxManage`, a CLI used by Vagrant
| for controlling VirtualBox. The command and stderr is shown below.
|
| Command: ["startvm", "{keyValue}", "--type", "headless"]
|
| Stderr: VBoxManage: error: VT-x is not available (VERR_VMX_NO_VMX)
| VBoxManage: error: Details: code NS_ERROR_FAILURE (0x80004005), component ConsoleWrap, interface IConsole
|
| user1@VM01:~/goworkspace/src/github.com/hyperledger/fabric/devenv$

以下の一文から、やはりBIOSがダメだったくさい
Stderr: VBoxManage: error: VT-x is not available (VERR_VMX_NO_VMX)

入れ子になった仮想化による仮想マシンでの Hyper-V の実行
https://msdn.microsoft.com/ja-jp/virtualization/hyperv_on_windows/user_guide/nesting
ドンピシャのようでWindows。アウト。
ってかHyper-Vって何し? → マイクロソフト社のサーバー仮想化技術
https://www.school.ctc-g.co.jp/columns/microsoft/microsoft01.html
Windows10でHyper-VとVirtualBoxは共存できないらしい
http://eiua-memo.tumblr.com/post/143625719906/vagrantwindows10%E3%81%AB%E3%82%A2%E3%83%83%E3%83%97%E3%82%B0%E3%83%AC%E3%83%BC%E3%83%89%E5%BE%8Cvt-x-is-not
Windows OSのHyper-v=LinuxのLIS (Linux Integration Services)

迷走入った。
取り敢えずBash vs. PowerShell
http://cecs.wright.edu/~pmateti/Courses/233/Labs/Scripting/bashVsPowerShellTable.html

シェルとは何ぞや
|ピヨっこ向け
|http://shellscript.sunone.me/tutorial.html
|中級者向け
|http://language-and-engineering.hatenablog.jp/entry/20110617/p1
|一見上級者向け。でも分かり易い
|http://www.cc.kyoto-su.ac.jp/~hirai/text/shell.html

Vagrant Azure Provider
https://github.com/Azure/vagrant-azure
Vagrant 1.7.3+ pluginがあればMicrosoft Azure上のマシンをVagrantが制御できるようになるとか
┃user1@VM01:~/goworkspace/src/github.com/hyperledger/fabric/devenv$ vagrant --version
| Vagrant 1.8.5

プラグインが同一物体なのか不明だがversionはクリアしているので、provider指定で再実行
| user1@VM01:~/goworkspace/src/github.com/hyperledger/fabric/devenv$ vagrant up --provider=azure
| An active machine was found with a different provider. Vagrant
| currently allows each machine to be brought up with only a single
| provider at a time. A future version will remove this limitation.
| Until then, please destroy the existing machine to up with a new
| provider.
|
| Machine name: default
| Active provider: virtualbox
| Requested provider: azure
失敗。
エラーメッセージを一旦無視して、母体とプラグインは別物らしい。

Vagrantプラグインの確認
┃user1@VM01:~/goworkspace/src/github.com/hyperledger/fabric/devenv$ vagrant plugin list
| vagrant-share (1.1.5, system)
プラグイン「vagrant-azure」は入っていない。

ので入れてみる
| user1@VM01:~/goworkspace/src/github.com/hyperledger/fabric/devenv$ vagrant plugin install vagrant-azure --plugin-version '2.0.0.pre1' --plugin-prerelease
| --plugin-prelease is deprecated and will be removed in the next
| version of Vagrant. It has no effect now. Use the '--plugin-version'
| flag to get a specific pre-release version.
|
| Installing the 'vagrant-azure --version '2.0.0.pre1'' plugin. This can take a few minutes...
| Installed the plugin 'vagrant-azure (2.0.0.pre1)'!
| user1@VM01:~/goworkspace/src/github.com/hyperledger/fabric/devenv$

確認
| user1@VM01:~/goworkspace/src/github.com/hyperledger/fabric/devenv$ vagrant plugin list
| vagrant-azure (2.0.0.pre1)
| - Version Constraint: 2.0.0.pre1
| vagrant-share (1.1.5, system)

再実行
| user1@VM01:~/goworkspace/src/github.com/hyperledger/fabric/devenv$ vagrant up --provider=azure
| An active machine was found with a different provider. Vagrant
| currently allows each machine to be brought up with only a single
| provider at a time. A future version will remove this limitation.
| Until then, please destroy the existing machine to up with a new
| provider.
|
| Machine name: default
| Active provider: virtualbox
| Requested provider: azure
| user1@VM01:~/goworkspace/src/github.com/hyperledger/fabric/devenv$
Azure Boxでないとサポートしないって書いてあった。
「You'll need an azure box before you can do vagrant up though.」
https://github.com/tsubakimoto/vagrant-azure#configuration

次、MS/Daniel氏。
PROVISION AZURE BOXES WITH VAGRANT
https://unindented.org/articles/provision-azure-boxes-with-vagrant/
まずはバージョン確認
┃user1@VM01:~/goworkspace/src/github.com/hyperledger/fabric/devenv$ VBoxManage --version
| 5.0.24_Ubuntur108355
┃user1@VM01:~/goworkspace/src/github.com/hyperledger/fabric/devenv$ vagrant --version
| Vagrant 1.8.5
| user1@VM01:~/goworkspace/src/github.com/hyperledger/fabric/devenv$

仰せの通りにpluginのインストール
| user1@VM01:~/goworkspace/src/github.com/hyperledger/fabric/devenv$ vagrant plugin install vagrant-azure
| Installing the 'vagrant-azure' plugin. This can take a few minutes...
| Installed the plugin 'vagrant-azure (1.3.0)'!
| user1@VM01:~/goworkspace/src/github.com/hyperledger/fabric/devenv$ vagrant plugin list
| vagrant-azure (1.3.0)
| vagrant-share (1.1.5, system)
あれ、ダウングレード。ま、いっか

情報、差し上げましょ。Azure CLIのインストール
| user1@VM01:~/goworkspace/src/github.com/hyperledger/fabric/devenv$ sudo apt install npm
| Reading package lists... Done
| Building dependency tree
| Reading state information... Done
| The following additional packages will be installed:
| gyp javascript-common libjs-inherits libjs-jquery libjs-node-uuid
| ...
| Processing triggers for libc-bin (2.23-0ubuntu3) ...
| user1@VM01:~/goworkspace/src/github.com/hyperledger/fabric/devenv$ vagrant plugin list
| vagrant-azure (1.3.0)
| vagrant-share (1.1.5, system)
| user1@VM01:~/goworkspace/src/github.com/hyperledger/fabric/devenv$ npm install -g azure-cli
| npm WARN deprecated tough-cookie@2.2.2: ReDoS vulnerability parsing Set-Cookie
| npm ERR! Please try running this command again as root/Administrator.
|
| npm ERR! Please include the following file with any support request:
| npm ERR! /home/user1/goworkspace/src/github.com/hyperledger/fabric/devenv/npm-debug.log
書き込み権限で失敗したので止めた。

Azureのバージョン確認
┃user1@VM01:~/goworkspace/src/github.com/hyperledger/fabric/devenv$ azure --version
| azure: command not found
期待と違う。。

AZURE BOXES と VM がきっと別物。

いい記事!環境構築のコード化の話
VagrantとDockerによるAzure向けOSS開発・管理端末のコード化
http://torumakabe.github.io/post/azure_osstools_iac/

はて、この人たちの悩みは同じ事象なのかどうか
https://github.com/Azure/vagrant-azure/issues/46

これは分かり易い!>今から始めるVagrant入門 #1
https://www.fl-ops.com/mori-dojo/archives/21

環境は違えど事象はドンピシャな気がするが、未解決のままcloseされとる
https://github.com/mitchellh/vagrant/issues/7302

64bitのお客様は結局BIOS設定に帰する他ないのか
https://forums.virtualbox.org/viewtopic.php?f=1&t=77423

Nested virtualizationをVirtualBoxはサポートしていないゆう宣言..
https://forums.virtualbox.org/viewtopic.php?f=7&t=77447

VT-x or AMD-Vする他ないのか。。
http://askubuntu.com/questions/779277/when-using-vagrant-stderr-vboxmanage-error-vt-x-is-not-available-verr-vmx-no/779296
CPUチェックする
┃user1@VM01:~$ sudo apt-get install cpu-checker
| Reading package lists... Done
| Building dependency tree
| Reading state information... Done
| The following additional packages will be installed:
| msr-tools
| The following NEW packages will be installed:
| cpu-checker msr-tools
| 0 upgraded, 2 newly installed, 0 to remove and 5 not upgraded.
| Need to get 17.5 kB of archives.
| After this operation, 87.0 kB of additional disk space will be used.
| Do you want to continue? [Y/n] y
| Get:1 http://azure.archive.ubuntu.com/ubuntu xenial/main amd64 msr-tools amd64 1.3-2 [10.6 kB]
| Get:2 http://azure.archive.ubuntu.com/ubuntu xenial/main amd64 cpu-checker amd64 0.7-0ubuntu7 [6,862 B]
| Fetched 17.5 kB in 0s (110 kB/s)
| Selecting previously unselected package msr-tools.
| (Reading database ... 85905 files and directories currently installed.)
| Preparing to unpack .../msr-tools_1.3-2_amd64.deb ...
| Unpacking msr-tools (1.3-2) ...
| Selecting previously unselected package cpu-checker.
| Preparing to unpack .../cpu-checker_0.7-0ubuntu7_amd64.deb ...
| Unpacking cpu-checker (0.7-0ubuntu7) ...
| Processing triggers for man-db (2.7.5-1) ...
| Setting up msr-tools (1.3-2) ...
| Setting up cpu-checker (0.7-0ubuntu7) ...
| user1@VM01:~$
┃user1@VM01:~$ sudo kvm-ok
| INFO: Your CPU does not support KVM extensions
| KVM acceleration can NOT be used
| user1@VM01:~$
やはりダメか。Ubuntuコミュニティも入れ子構造はダメよ、とある涙
Keep in mind, vt-x can't be nested, so for instance, say you're trying to run vagrant on a cloud instance, in my experience that wont work. Atleast, for a 64 bit OS. You'll be able to run 32bit, however, that would be a single core and horrible performance.

およ?救世主なるか?
Virtualboxで64bitOSを扱えない。VT-x is not available (VERR_VMX_NO_VMX).
https://ah-2.com/2016/07/14/virtualbox_not_detect_vt_x.html
思うが、やはりWindows向け

結果、以下を諦めた。
│ cd $GOPATH/src/github.com/hyperledger/fabric/devenv
│ vagrant up
│ vagrant ssh

代わりに「Building outside of Vagrant」というのを試そうかと
http://hyperledger-fabric.readthedocs.io/en/latest/dev-setup/build/

tag : Hyperledger fabric Ubuntu VM Vagrant Docker Git Go VirtualBox GitHub

2016-09-29 12:13 : 開発 : コメント : 0 : トラックバック : 0 :
コメントの投稿
非公開コメント

« next  ホーム  prev »

search

ad



counter


tag cloud

category cloud