Ubuntu18.04 install Fabric and deploy chain code
1 Ubuntu18.04 deployment
Reference blog: blog.csdn.net/weixin_4400…
1.1 configuration source
① To configure ali image source, back up the configuration file first
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
Copy the code
Editing a Configuration File
sudo vim /etc/apt/sources.list
Copy the code
The previous source can be commented out and added at the end of the configuration file:
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 multiverseCopy the code
Execute the command to update
sudo apt-get update
Copy the code
1.2 install cURL
sudo apt install curl
Copy the code
1.3 install Git
sudo apt-get install git
Copy the code
1.4 installation Go
Download the 16.4 installation package
Wget HTTP: / / https://studygolang.com/dl/golang/go1.16.4.linux-amd64.tar.gzCopy the code
Unpack the installation
Sudo tar -c /usr/local-zxf go1.16.4.linux-amd64.tar.gzCopy the code
Configuring Environment Variables
Bashrc or gedit ~/. Bashrc // User environment variable vim /etc/profile or gedit /etc/profileCopy the code
Add the following at the end of the file
export PATH=$PATH:/usr/local/go/bin
export GOROOT=/usr/local/go
export GOPATH=$HOME/go
export PATH=$PATH:$GOPATH/bin
Copy the code
Updating a Configuration File
source ~/.bashrc
Copy the code
Check whether the GO language is successfully installed
go version
Copy the code
Go1.13 Or higher configure the agent
sudo gedit /etc/profile
#For go1.13.x and above users
export GO111MODULE=on
export GOPROXY=https://goproxy.cn,direct
source /etc/profile
Copy the code
1.5 install Python
Install python3.7
Sudo apt install python3.7Copy the code
Set PYTHon3 to the default
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 150
Copy the code
Install pip3
sudo apt install python3-pip
Copy the code
Set piP3 by default
sudo update-alternatives --install /usr/bin/pip pip /usr/bin/pip3 150
Copy the code
Update the PIP
pip install --upgrade pip
Copy the code
Change to Ali source
CD ~/. PIP touch pip.conf vim PIP. Conf write [global] trusted-host=mirrors.aliyun.com index-url=https://mirrors.aliyun.com/pypi/simple/Copy the code
1.6 installation Node
Install the latest version of Node
curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -
sudo apt install nodejs -y
Copy the code
Install the NPM
sudo apt install npm -y
sudo npm install npm@latest -g
Copy the code
Can install Taobao mirror
npm install -g cnpm --registry=https://registry.npm.taobao.org
Copy the code
1.7 installation Docker – CE
Uninstall the older version of Docker
sudo apt-get remove docker docker-engine docker.io
Copy the code
Add the HTTPS protocol, Allow APT to install GPG certificates from the HTTPS installation package sudo apt-get-y install apt-transport-HTTPS ca-certificates curl software-properties-common Curl - fsSL http://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt - key add - write software source information sudo add apt -- the repository "Deb [arch = amd64] http://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release - cs) stable" update and install the Docker - CE sudo Apt-get-y update sudo apt-get-y install docker-ce add the current user to docker user group 1. Create docker user group sudo groupadd docker 2. Add the current USER to docker USER group sudo usermod -ag docker $USER 3. Exit the docker image to edit daemon.json file. Sudo vim /etc/docker/daemon.json add the following { "registry-mirrors":["https://obou6wyb.mirror.aliyuncs.com","https://registry.docker-cn.com","http://hub-mirror.c.163.com Sudo systemctl daemon-reload sudo systemctl restart docker check whether the docker version is successfully installedCopy the code
1.8 installation Docker – Compose
Docker-compose: Sudo curl -l https://github.com/docker/compose/releases/download/1.24.0/docker-compose- ` ` uname - s - ` uname -m ` - o /usr/local/bin/docker-compose or sudo curl -l https://get.daocloud.io/docker/compose/releases/download/1.24.0/docker-compose- ` ` uname - s - ` uname -m ` > Sudo chmod +x /usr/local/bin/docker-compose: for example: /usr/local/bin/docker-compose: Sudo apt-get install python-pip sudo PIP install docker-compose docker-compose versionCopy the code
1.9 Fabric installation and running
1.9.1 Fabric Deployment
Latest version 2.3
Create folder mkdir -p go/src/github.com/hyperledger into the newly created folder CD go/src/github.com/hyperledger out pull on the fabric source git clone "Https://github.com/hyperledger/fabric.git" compiled binaries make release to view the generated binary CD release/Linux - amd64 ls/bin If the following files are in the folder, the compilation is successfulCopy the code
1.9.2 Adding environment Variables
Vim ~ /. Profile at the end of the file add the following content export PATH=$PATH:$GOPATH/src/github.com/hyperledger/fabric/release/linux-amd64/bin update configuration files Profile copy the two certificates in the bin folder to $GOPATH/bin cp cryptogen $GOPATH/bin cp configTxGen $GOPATH/bin Make sure you have the latest image of the corresponding version. For example, here is 2.3 Docker pull Hyperledger /fabric-peer:2.3 Docker pull Hyperledger /fabric-tools:2.3 Docker pull Hyperledger /fabric- Orderer :2.3 Docker pull Hyperledger /fabric- Javaenv :2.3 Docker pull Hyperledger /fabric- CCENV :2.3 Docker pull Hyperledger /fabric- Baseos :2.3 Docker pull Hyperledger /fabric- CA :1.5 Docker pull Hyperledger /fabric- Zookeeper :0.4 docker pull Hyperledger /fabric- Kafka :0.4 docker pull Hyperledger/fabric-couchDB :0.4 docker pull Hyperledger /fabric-baseimage:0.4 docker pull Hyperledger/fabric-memberSRVC :latest Docker pull library/busybox:latest Docker tag IMAGEID(IMAGEID) REPOSITORY: tag example: docker tag 1e8e82ab49af hyperledger/fabric-peer:latest docker tag a206a1593b4c hyperledger/fabric-tools:latest docker tag 12f8ed297e92 hyperledger/fabric-orderer:latest docker tag 673235d3d895 hyperledger/fabric-javaenv:latest docker tag 627c556b15ca hyperledger/fabric-ccenv:latest docker tag fb85a21d6642 hyperledger/fabric-baseos:latest docker tag 9d0214fb481b hyperledger/fabric-zookeeper:latest docker tag e94a8ade54af hyperledger/fabric-kafka:latest docker tag 339050a439e7 hyperledger/fabric-couchdb:latest docker tag 50758b890fb9 hyperledger/fabric-baseimage:latest docker tag 24a7c19a9FD8 Hyperledger /fabric-ca: Latest After all the tags have been changed, check the image library Docker Images againCopy the code
Open the Docker
Sudo systemctl start docker Starts docker at startupCopy the code
Mirror to delete
Docker stop 'docker ps -a -q' 2 Delete all image docker rmi 'docker images -q'Copy the code
1.9.3 installation jq
Optional: Install the latest version of jq if it is not already installed (only required for the tutorials related to channel configuration transactions).
sudo apt-get install jq
Copy the code
1.9.4 installation Fabric – CA
CD $GOPATH/src/github.com/hyperledger/ git clone "https://hub.fastgit.org/hyperledger/fabric-ca.git" CD fabric - compile the ca make releaseCopy the code
And finally we get these programs
configtxlator
cryptogen
discover
idemixgen
orderer
osnadmin
peer
fabric-ca-client
fabric-ca-server
Copy the code
In the next blog, the Fabric official chain code case is deployed and running