一、安裝Ubuntu16

二、安裝基礎工具
注意操作用戶是自建用戶,不是root,特別一些命令涉及用戶目錄的地方要特別注意
首先安裝一些常用工具
go需要單獨安裝下
編輯全局變量環境,添加一下profile
生效profile,建立go目錄
此時酌情重啟下系統
三、安裝docker 基於aliyun
sudo usermod -aG docker XXX
四、安裝 Docker-Compose 從DaoClound
五.Fabric源碼下載
六. Fabric Docker鏡像的下載

七、啟動Fabric網絡並完成ChainCode的測試
./network_setup.sh up
- 編譯生成Fabric公私鑰、證書的程序,程序在目錄:fabric/release/linux-amd64/bin
- 基於configtx.yaml生成創世區塊和通道相關信息,並保存在channel-artifacts文件夾。
- 基於crypto-config.yaml生成公私鑰和證書信息,並保存在crypto-config文件夾中。
- 基於docker-compose-cli.yaml啟動1Orderer+4Peer+1CLI的Fabric容器。
- 在CLI啟動的時候,會運行scripts/script.sh文件,這個腳本文件包含了創建Channel,加入Channel,安裝Example02,運行Example02等功能。
出現則表示網絡運行成功,ctrl+c退出
八、手動測試Fabric網絡
這里有官方提供的小例子,在官方例子中,channel名字是mychannel,鏈碼的名字是mycc。
首先進入CLI,然后重新打開一個命令行窗口,輸入: docker exec -it cli bash
這時用戶為root@748dafdc900b,在/opt/gopath/src/github.com/hyperledger/fabric/peer目錄下,運行以下命令可以查詢a賬戶的余額: peer chaincode query -C mychannel -n mycc -c '{"Args":["query","a"]}'
方框內可以看見余額為:90
下面我們可以進行轉賬操作,操作為invoke ,由a轉b 50:
現在轉賬完畢, 我們試一試再查詢一下a賬戶的余額,重復之前的查詢指令,結果為:
結果正確,a的余額只有40了。
最后,我們需要關閉Fabric,這里先使用exit命令退出cli容器。 exit
然后類似於啟動指令: cd ~/go/src/github.com/hyperledger/fabric/examples/e2e_cli
./network_setup.sh down
最后,我們整個Fabric的環境已經測試完畢!!
Ubuntu 無法解析域名的解決辦法:
Could not resolve host: download.docker.com
修改文件/etc/resolvconf/resolv.conf.d/base
vim /etc/resolvconf/resolv.conf.d/base # 在該文件加上一行: nameserver 8.8.8.8
resolvconf -u #執行
安裝過程中如果出現網絡連接錯誤,可以將軟件源改成阿里雲鏡像
# 編輯/etc/apt/sources.list文件, 在文件最前面添加以下條目(適用於Ubuntu18.04)
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
#(適用於Ubuntu16.04) deb-src http://archive.ubuntu.com/ubuntu xenial main restricted #Added by software-properties deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted multiverse universe #Added by software-properties deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted multiverse universe #Added by software-properties deb http://mirrors.aliyun.com/ubuntu/ xenial universe deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe deb http://mirrors.aliyun.com/ubuntu/ xenial multiverse deb http://mirrors.aliyun.com/ubuntu/ xenial-updates multiverse deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse #Added by software-properties deb http://archive.canonical.com/ubuntu xenial partner deb-src http://archive.canonical.com/ubuntu xenial partner deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted multiverse universe #Added by software-properties deb http://mirrors.aliyun.com/ubuntu/ xenial-security universe deb http://mirrors.aliyun.com/ubuntu/ xenial-security multiverse
運行sudo apt install curl 安裝curl,此時如果出現如下錯誤:
E: Could not get lock /var/lib/dpkg/lock - open (11: Resource temporarily unavailable) E: Unable to lock the administration directory (/var/lib/dpkg/), is another process using it?
解決方案:
ps -A |grep apt # 查看進程號 sudo kill -9 [processnumber] #結束進程 sudo apt install curl
如果出現路徑權限問題,需要將路徑所有者改成自建用戶,例如:
sudo chown -R dsd:dsd ./bin/ # 將目錄所有者改為自建用戶
如果提示已經有容器在運行,發生沖突,則應停止正在運行的docker進程:
docker ps -qa | xargs docker stop docker ps -qa | xargs docker rm # 或者: ./ network_setup.sh down
Make 編譯出錯如下
make configtxgen configtxlator cryptogen Makefile:93: *** "No go in PATH: Check dependencies". Stop.
解決方案:重新source環境變量,如:
source /etc/profile # 或者: source ~/.bashrc
教程參考以下:
http://blog.csdn.net/so5418418/article/details/78355868
https://yq.aliyun.com/articles/110806
http://get.daocloud.io/
Ubuntu下搭建Hyperledger Fabric v1.0環境 2018快速國內源
一、安裝Ubuntu16

二、安裝基礎工具
注意操作用戶是自建用戶,不是root,特別一些命令涉及用戶目錄的地方要特別注意
首先安裝一些常用工具
go需要單獨安裝下
編輯全局變量環境,添加一下profile
生效profile,建立go目錄
此時酌情重啟下系統
三、安裝docker 基於aliyun
sudo usermod -aG docker XXX
四、安裝 Docker-Compose 從DaoClound
五.Fabric源碼下載
六. Fabric Docker鏡像的下載

七、啟動Fabric網絡並完成ChainCode的測試
./network_setup.sh up
- 編譯生成Fabric公私鑰、證書的程序,程序在目錄:fabric/release/linux-amd64/bin
- 基於configtx.yaml生成創世區塊和通道相關信息,並保存在channel-artifacts文件夾。
- 基於crypto-config.yaml生成公私鑰和證書信息,並保存在crypto-config文件夾中。
- 基於docker-compose-cli.yaml啟動1Orderer+4Peer+1CLI的Fabric容器。
- 在CLI啟動的時候,會運行scripts/script.sh文件,這個腳本文件包含了創建Channel,加入Channel,安裝Example02,運行Example02等功能。
出現則表示網絡運行成功,ctrl+c退出
八、手動測試Fabric網絡
這里有官方提供的小例子,在官方例子中,channel名字是mychannel,鏈碼的名字是mycc。
首先進入CLI,然后重新打開一個命令行窗口,輸入: docker exec -it cli bash
這時用戶為root@748dafdc900b,在/opt/gopath/src/github.com/hyperledger/fabric/peer目錄下,運行以下命令可以查詢a賬戶的余額: peer chaincode query -C mychannel -n mycc -c '{"Args":["query","a"]}'
方框內可以看見余額為:90
下面我們可以進行轉賬操作,操作為invoke ,由a轉b 50:
現在轉賬完畢, 我們試一試再查詢一下a賬戶的余額,重復之前的查詢指令,結果為:
結果正確,a的余額只有40了。
最后,我們需要關閉Fabric,這里先使用exit命令退出cli容器。 exit
然后類似於啟動指令: cd ~/go/src/github.com/hyperledger/fabric/examples/e2e_cli
./network_setup.sh down
最后,我們整個Fabric的環境已經測試完畢!!
教程參考以下:
http://blog.csdn.net/so5418418/article/details/78355868
https://yq.aliyun.com/articles/110806
http://get.daocloud.io/