Open this apt source list, if see it is http://us.xxxxxx and so on, then is foreign, if see is http://cn.xxxxx and so on, then do not need to change. Mine is the source of the United States, so I need to do a lot of replacement. In command mode, enter:
:%s/us./cn./g
You can change all of us to CN. Then enter: Wq to save the exit.
sudo apt-get update
Update the source.
Then install SSH so that you can then connect to Ubuntu remotely with putty or SECURECRT clients.
sudo apt-get install SSH
Although the apt-get of Ubuntu provides go installation, but the version is older, the best way is to refer to the official website, download the latest version of Go. The specific commands involved include:
wget https://storage.googleapis.com/golang/go1.9.linux-amd64.tar.gz
sudo tar-c/usr/local-xzf Go1.9.linux-amd64.tar.gz
"Note: Do not use apt to install the go,apt go version is too low." 】
Next, edit the environment variables for the current user:
VI ~/.profile
Add the following:
Export path= $PATH:/usr/local/go/bin
export goroot=/usr/local/go
export gopath= $HOME/go
export path=$ PATH: $HOME/go/bin
After editing the Save and Exit VI, remember to load these environments:
SOURCE ~/.profile
We set the Go directory Gopath to the current user's folder, so remember to create the Go folder
CD ~
mkdir Go
# apt-get Install Apt-transport-https ca-certificates3. Add a new GPG key
# Apt-key adv--keyserver hkp://p80.pool.sks-keyservers.net:80--recv-keys 58118e89f3a912897c070adbf76221572c52609d
4. Add or edit docker.list files in the source list
# vi/etc/apt/sources.list.d/docker.list //If not present, add
5. Delete existing entries
6. Add entry in accordance with the system version (Ubuntu xenial 16.04 (LTS))
Deb Https://apt.dockerproject.org/repo ubuntu-xenial Main
7. Re-perform the update operation and delete the old repo
# Apt-get Purge Lxc-docker //No installation, skip
8. See if the correct version is available
# Apt-cache Policy Docker-engine
As shown in figure:
9. From the beginning of the 14.04 version Docker recommended installation Linux-image-extra
# Apt-get Install linux-image-extra-$ (uname-r)
10. Install Docker
# Apt-get Update
# apt-get Install Docker-engine # service Docker start # Docker run Hello-world
After the installation completes, you need to modify the current user (the user name fabric) permission that I use:
sudo usermod-ag docker Fabric
Log off and log on again, and then add the Aliyun Docker hub Mirror:
sudo mkdir-p/etc/docker
sudo tee/etc/docker/daemon.json <<-' EOF '
{
' registry-mirrors ': [' https:/ /obou6wyb.mirror.aliyuncs.com "]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart Docker
Different versions add methods are not the same, the official documents are as follows: Https://cr.console.aliyun.com/#/accelerator
We can use git command to download the source code, first need to create a corresponding directory, and then enter the directory, git download source:
Mkdir-p ~/go/src/github.com/hyperledger
cd ~/go/src/github.com/hyperledger
git clone https://github.com/ Hyperledger/fabric.git
Because fabric has been updated, all of us do not need the latest and newest source code, need to switch to the v1.0.0 version of the source code can:
CD ~/go/src/github.com/hyperledger/fabric
git checkout v1.0.0
This is actually very simple, because we have set the Docker hub mirror address, so the download will also be very fast. The official file also provides a batch download script. We run directly:
CD ~/go/src/github.com/hyperledger/fabric/examples/e2e_cli/
source Download-dockerimages.sh-c x86_64-1.0.0-f x86_64-1.0.0
This allows you to download all of the required fabric docker mirrors. Because we set up a domestic mirror, so the download should be relatively fast.
Once the download is complete, we run the following command to check the downloaded mirror list:
Docker images
The results obtained are as follows:
This makes the following actions:
7.1 Compile the fabric Public private key, certificate procedures, procedures in the directory: Fabric/release/linux-amd64/bin
7.2 generates Genesis block and channel-related information based on Configtx.yaml and saves it in the Channel-artifacts folder.
7.3 Generates public private key and certificate information based on Crypto-config.yaml and is saved in the Crypto-config folder.
7.4 Fabric containers based on the Docker-compose-cli.yaml boot 1orderer+4peer+1cli.
7.5 When the CLI is started, the scripts/script.sh file is run, which contains features such as creating channel, adding channel, installing EXAMPLE02, running EXAMPLE02, and so on.
At the end of the run, we can see this interface:
Run the following command to query the balance of a account:
peer Chaincode query-c mychannel-n mycc-c ' {' Args ': [' query ', ' A ']} '
You can see that the balance is
Then, we try to transfer the balance of a account 20 yuan to the B account, run the command:
peer Chaincode invoke-o orderer.example.com:7050--tls True --cafile/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererorganizations/example.com/orderers/ Orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem-c mychannel-n mycc-c ' {"Args": ["Invoke", "a", "B", "20 "]}"
The result is:
Now the transfer is completed, we try to check the balance of a account, no problem, should be only 70 left. Let's take a look at the actual situation:
Sure enough, everything's fine. Finally, to turn off the fabric network, we first need to run the exit command to exit the CLI container. The command to turn off fabric is similar to boot:
cd ~/go/src/github.com/hyperledger/fabric/examples/e2e_cli./network_setup.sh down
Now our entire fabric environment has been tested, congratulations, everything is fine, next we are to do our own block chain development. I hope my article is helpful to everyone.