1.安裝環境html
1)本機安裝linux
前提是已經安裝好了docker\docker-compose\go,相應的內容可見git
docker-1-環境安裝及例子實踐github
docker官方文檔學習-1-Docker for mac安裝配置
go安裝可看:開始學習前的環境安裝docker
而後可見本機環境版本信息爲:shell
docker爲:bootstrap
userdeMacBook-Pro:~ user$ docker version Client: Docker Engine - Community Version: 18.09.0 API version: 1.39 Go version: go1.10.4 Git commit: 4d60db4 Built: Wed Nov 7 00:47:43 2018 OS/Arch: darwin/amd64 Experimental: false Server: Docker Engine - Community Engine: Version: 18.09.0 API version: 1.39 (minimum version 1.12) Go version: go1.10.4 Git commit: 4d60db4 Built: Wed Nov 7 00:55:00 2018 OS/Arch: linux/amd64 Experimental: false Kubernetes: Version: v1.10.3 StackAPI: v1beta2
docker-compose爲:ubuntu
userdeMBP:~ user$ docker-compose version docker-compose version 1.23.2, build 1110ad01 docker-py version: 3.6.0 CPython version: 3.6.6 OpenSSL version: OpenSSL 1.1.0h 27 Mar 2018
go爲:api
userdeMacBook-Pro:~ user$ go version go version go1.11.4 darwin/amd64
一開始docker中的鏡像信息有:網絡
userdeMacBook-Pro:~ user$ docker images REPOSITORY TAG IMAGE ID CREATED SIZE k8s.gcr.io/kubernetes-dashboard-amd64 v1.10.1 f9aed6605b81 2 months ago 122MB docker/kube-compose-controller v0.4.12 02a45592fbea 5 months ago 27.8MB docker/kube-compose-api-server v0.4.12 0f92c77fa676 5 months ago 41.2MB k8s.gcr.io/kube-proxy-amd64 v1.10.3 4261d315109d 9 months ago 97.1MB k8s.gcr.io/kube-controller-manager-amd64 v1.10.3 40c8d10b2d11 9 months ago 148MB k8s.gcr.io/kube-apiserver-amd64 v1.10.3 e03746fe22c3 9 months ago 225MB k8s.gcr.io/kube-scheduler-amd64 v1.10.3 353b8f1d102e 9 months ago 50.4MB k8s.gcr.io/etcd-amd64 3.1.12 52920ad46f5b 12 months ago 193MB k8s.gcr.io/k8s-dns-dnsmasq-nanny-amd64 1.14.8 c2ce1ffb51ed 14 months ago 41MB k8s.gcr.io/k8s-dns-sidecar-amd64 1.14.8 6f7f2dc7fab5 14 months ago 42.2MB k8s.gcr.io/k8s-dns-kube-dns-amd64 1.14.8 80cc5ea4b547 14 months ago 50.5MB k8s.gcr.io/pause-amd64 3.1 da86e6ba6ca1 14 months ago 742kB
這是由於安裝了kubernetes
2)虛擬機安裝
固然若是手動安裝環境不順利的狀況下,咱們也能夠經過配置虛擬機來配置環境,這個的好處有:
使用vagrant集成的開發環境開發容許開發者使用本身喜歡的操做系統和編輯器來開發,同時又可讓系統運行在一個與開發團隊一致的開發環境中。
固然首先須要有vagrant\virtualbox環境, vagrant\virtualbox的安裝和版本可見virtualbox+vagrant學習-1-環境安裝及vagrantfile的簡單配置-Mac系統
參考https://blog.csdn.net/zgljl2012/article/details/52896372
首先須要下載fabric源碼
userdeMacBook-Pro:~ user$ go get github.com/hyperledger/fabric package github.com/hyperledger/fabric: no Go files in /Users/user/go/src/github.com/hyperledger/fabric
使用Vagrant啓動虛擬機
進入/Users/user/go/src/github.com/hyperledger/fabric/devenv目錄下,這裏寫好了安裝虛擬機的配置文件,調用vagrant up來啓動vagrant。這樣就可以不用配置,直接使用開發人員設置好的開發環境:
userdeMBP:fabric user$ cd devenv/ userdeMBP:devenv user$ vagrant up ==> vagrant: A new version of Vagrant is available: 2.2.4 (installed version: 2.2.2)! ==> vagrant: To upgrade visit: https://www.vagrantup.com/downloads.html Bringing machine 'default' up with 'virtualbox' provider... ==> default: Importing base box 'ubuntu/xenial64'... ==> default: Matching MAC address for NAT networking... ==> default: Setting the name of the VM: hyperledger ==> default: Vagrant has detected a configuration issue which exposes a ==> default: vulnerability with the installed version of VirtualBox. The ==> default: current guest is configured to use an E1000 NIC type for a ==> default: network adapter which is vulnerable in this version of VirtualBox. ==> default: Ensure the guest is trusted to use this configuration or update ==> default: the NIC type using one of the methods below: ==> default: ==> default: https://www.vagrantup.com/docs/virtualbox/configuration.html#default-nic-type ==> default: https://www.vagrantup.com/docs/virtualbox/networking.html#virtualbox-nic-type ==> 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: 7053 (guest) => 7053 (host) (adapter 1) default: 7054 (guest) => 7054 (host) (adapter 1) default: 5984 (guest) => 15984 (host) (adapter 1) default: 22 (guest) => 2222 (host) (adapter 1) ==> default: Running 'pre-boot' VM customizations... ==> 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 reset. Retrying... default: Warning: Remote connection disconnect. Retrying... default: default: Vagrant insecure key detected. Vagrant will automatically replace default: this with a newly generated keypair for better security. default: default: Inserting generated public key within guest... default: Removing insecure key from the guest if it's present... default: Key inserted! Disconnecting and reconnecting using new SSH key... ==> default: Machine booted and ready! ==> default: Checking for guest additions in VM... default: The guest additions on this VM do not match the installed version of default: VirtualBox! In most cases this is fine, but in rare cases it can default: prevent things such as shared folders from working properly. If you see default: shared folder errors, please make sure the guest additions within the default: virtual machine match the version of VirtualBox you have installed on default: your host and reload your VM. default: default: Guest Additions Version: 5.1.38 default: VirtualBox Version: 5.2 ==> default: Mounting shared folders... default: /vagrant => /Users/user/go/src/github.com/hyperledger/fabric/devenv default: /local-dev => /Users/user/go/src/github.com/hyperledger default: /hyperledger => /Users/user/go/src/github.com/hyperledger default: /opt/gopath/src/github.com/hyperledger => /Users/user/go/src/github.com/hyperledger ==> default: Running provisioner: shell... default: Running: inline script default: ++ tee -a /etc/hosts default: ++ echo '127.0.0.1 couchdb' default: 127.0.0.1 couchdb
...
等到安裝好後,運行vagrant ssh來進入該虛擬機:
userdeMacBook-Pro:devenv user$ vagrant ssh Welcome to Ubuntu 16.04.5 LTS (GNU/Linux 4.4.0-141-generic x86_64) * Documentation: https://help.ubuntu.com * Management: https://landscape.canonical.com * Support: https://ubuntu.com/advantage Get cloud support with Ubuntu Advantage Cloud Guest: http://www.ubuntu.com/business/services/cloud 60 packages can be updated. 49 updates are security updates. New release '18.04.2 LTS' available. Run 'do-release-upgrade' to upgrade to it. *** System restart required *** vagrant@ubuntu-xenial:~$
參考https://blog.csdn.net/zgljl2012/article/details/52896372
過程當中若是沒成功,多是由於網絡被qiang的緣由,能夠到百度雲手動安裝box
https://pan.baidu.com/s/1kV57PLt?errno=0&errmsg=Auth%20Login%20Sucess&&bduss=&ssnerror=0&traceid=
而後運行:
vagrant box add hyperledger/fabric-baseimage virtualbox.box
再運行vagrant up便可
固然你也能夠從virtualbox處進入
用戶名和密碼都爲vagrant
而後此時查看該環境配置的版本信息:
vagrant@ubuntu-xenial:~$ go version go version go1.11.5 linux/amd64 vagrant@ubuntu-xenial:~$ docker version Client: Version: 18.09.3 API version: 1.39 Go version: go1.10.8 Git commit: 774a1f4 Built: Thu Feb 28 06:40:58 2019 OS/Arch: linux/amd64 Experimental: false Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.39/version: dial unix /var/run/docker.sock: connect: permission denied vagrant@ubuntu-xenial:~$ docker-compose version docker-compose version 1.14.0, build c7bdf9e docker-py version: 2.3.0 CPython version: 2.7.13 OpenSSL version: OpenSSL 1.0.1t 3 May 2016
上面的Got permission denied的解決辦法是:
1)運行時在前面加一個sudo:
vagrant@ubuntu-xenial:~$ sudo docker version Client: Version: 18.09.3 API version: 1.39 Go version: go1.10.8 Git commit: 774a1f4 Built: Thu Feb 28 06:40:58 2019 OS/Arch: linux/amd64 Experimental: false Server: Docker Engine - Community Engine: Version: 18.09.3 API version: 1.39 (minimum version 1.12) Go version: go1.10.8 Git commit: 774a1f4 Built: Thu Feb 28 05:59:55 2019 OS/Arch: linux/amd64 Experimental: false
2)另外一種解決辦法就是docker守護進程啓動的時候,會默認賦予名字爲docker的用戶組讀寫Unix socket的權限,所以只要建立docker用戶組,並將當前用戶加入到docker用戶組中,那麼當前用戶就有權限訪問Unix socket了,進而也就能夠執行docker相關命令(參考https://www.cnblogs.com/informatics/p/8276172.html):
vagrant@ubuntu-xenial:~$ sudo groupadd docker //添加docker用戶組 groupadd: group 'docker' already exists vagrant@ubuntu-xenial:~$ sudo gpasswd -a $USER docker //將登錄用戶加入到docker用戶組中 Adding user vagrant to group docker vagrant@ubuntu-xenial:~$ newgrp docker //更新用戶組 vagrant@ubuntu-xenial:~$ docker version //測試果真成功 Client: Version: 18.09.3 API version: 1.39 Go version: go1.10.8 Git commit: 774a1f4 Built: Thu Feb 28 06:40:58 2019 OS/Arch: linux/amd64 Experimental: false Server: Docker Engine - Community Engine: Version: 18.09.3 API version: 1.39 (minimum version 1.12) Go version: go1.10.8 Git commit: 774a1f4 Built: Thu Feb 28 05:59:55 2019 OS/Arch: linux/amd64 Experimental: false
而後安裝鏡像
安裝好的虛擬機中也已經下載好了hyperledger/fabric,裏面目錄script中的bootstrap.sh文件中寫好了須要安裝的鏡像信息,可以經過調用該文件來安裝須要的鏡像,以下:
vagrant@ubuntu-xenial:~$ cd /opt/gopath/src/github.com/hyperledger/fabric/scripts vagrant@ubuntu-xenial:/opt/gopath/src/github.com/hyperledger/fabric/scripts$ ls bootstrap.sh check_trailingspaces.sh goListFiles.sh changelog.sh compile_protos.sh metrics_doc.sh check_deps.sh fabric-samples multiarch.sh check_license.sh generateHelpDocs.sh pull_build_artifacts.sh check_spelling.sh golinter.sh run-integration-tests.sh vagrant@ubuntu-xenial:/opt/gopath/src/github.com/hyperledger/fabric/scripts$ ./bootstrap.sh ./bootstrap.sh: line 179: [: too many arguments Installing hyperledger/fabric-samples repo ... ===> List out hyperledger docker images //運行到這,相應的鏡像就已經安裝好了 hyperledger/fabric-tools 1.4.0 0a44f4261a55 8 weeks ago 1.56GB hyperledger/fabric-tools latest 0a44f4261a55 8 weeks ago 1.56GB hyperledger/fabric-ccenv 1.4.0 5b31d55f5f3a 8 weeks ago 1.43GB hyperledger/fabric-ccenv latest 5b31d55f5f3a 8 weeks ago 1.43GB hyperledger/fabric-orderer 1.4.0 54f372205580 8 weeks ago 150MB hyperledger/fabric-orderer latest 54f372205580 8 weeks ago 150MB hyperledger/fabric-peer 1.4.0 304fac59b501 8 weeks ago 157MB hyperledger/fabric-peer latest 304fac59b501 8 weeks ago 157MB hyperledger/fabric-ca 1.4.0 1a804ab74f58 8 weeks ago 244MB hyperledger/fabric-ca latest 1a804ab74f58 8 weeks ago 244MB hyperledger/fabric-zookeeper 0.4.14 d36da0db87a4 4 months ago 1.43GB hyperledger/fabric-zookeeper latest d36da0db87a4 4 months ago 1.43GB hyperledger/fabric-kafka 0.4.14 a3b095201c66 4 months ago 1.44GB hyperledger/fabric-kafka latest a3b095201c66 4 months ago 1.44GB hyperledger/fabric-couchdb 0.4.14 f14f97292b4c 4 months ago 1.5GB hyperledger/fabric-couchdb latest f14f97292b4c 4 months ago 1.5GB
3)能夠看hyperledger中文文檔學習-4-構建第一個fabric網絡去開始構建一個簡單的網絡