Blockchain-APTrace-Fabric blockchain network deployment error summary

Pull the open source project: blockchain-fabric-trace: a blockchain-based (fabric) traceability platform for agricultural products (gitee.com)

1. Make sure the environment is configured well 

Install node.js 12

(23 messages) centos install node12_centos node12_bats421's Blog - CSDN Blog

Note: Try to use 12 for node.js. If you don’t want to use 12, you can also use 14, and then install npm. Note that npm must use version 6

install npm6

(23 messages) Install the latest version of node12.*.* and npm6.* in Ubuntu/Centos and set up a domestic mirror_ubuntu install npm6_Ye Guya's blog-CSDN blog

install g++

yum install gcc gcc-c++ 

(23 messages) linux installation g++_linux g++ installation - Programmer Sought Blog-CSDN Blog

Install docker and docker-compose

Centos7 Docker&Docker-Compose Installation Tutorial_centos7 docker-compose Installation_MrNeoJeep's Blog-CSDN Blog Install redis and mysql8 (directly pulled from docker)

Docker pulls Mysql_docker pull mysql_Pen God Xiaolu's Blog-CSDN Blog

(Note that you must first install mysql before installing redis. This redis version is 5.0.7. If you need to install other versions, Baidu yourself)

install fastDFS

 Build FastDFS file system in Docker (multiple pictures) - niceyoo - Blog Park (cnblogs.com)

 Install the go language

How to install go language environment under linux-Golang-PHP中文网

2. Pull the docker image 

pull

docker pull hyperledger/fabric-peer:1.2.0 && 
docker pull hyperledger/fabric-orderer:1.2.0 && 
docker pull hyperledger/fabric-ca:1.2.0 && 
docker pull hyperledger/fabric-tools:1.2.0 && 
docker pull hyperledger/fabric-ccenv:1.2.0 && 
docker pull hyperledger/fabric-baseimage:0.4.10 && 
docker pull hyperledger/fabric-baseos:0.4.10 && 
docker pull hyperledger/fabric-couchdb:0.4.10

tag

docker tag hyperledger/fabric-peer:1.2.0 hyperledger/fabric-peer && 
docker tag hyperledger/fabric-orderer:1.2.0 hyperledger/fabric-orderer && 
docker tag hyperledger/fabric-ca:1.2.0 hyperledger/fabric-ca && 
docker tag hyperledger/fabric-tools:1.2.0 hyperledger/fabric-tools && 
docker tag hyperledger/fabric-ccenv:1.2.0 hyperledger/fabric-ccenv && 
docker tag hyperledger/fabric-baseimage:0.4.10  hyperledger/fabric-baseimage && 
docker tag hyperledger/fabric-baseos:0.4.10 hyperledger/fabric-baseos && 
docker tag hyperledger/fabric-couchdb:0.4.10 hyperledger/fabric-couchdb 

This step is performed in accordance with the steps, and there will be no errors normally (if an error occurs, first check whether the docker is installed)

3. Upload the code to the linux server/or pull directly from git

Drag and drop the file blockchain-trace-bcnetwork directly from the idea to a random directory on linux

  

4. Run the start.sh file in the basic_network directory 

chmod -R 777 start.sh

./start.sh

At this point, first enter the required directory and change the format of the start.sh file (because it is directly dragged from windows, you need to change the format of start.sh)

Method 1 Enter vim start.sh inside the file and change the format (esc) :set ff=unix+Enter Check the format:set ff+Enter then wq! Save the file format

Method 2 is simple and rude, directly click on the start.sh file

 Click the little penguin button, then ctrl+s to save (a button will pop up) and click Yes, all (to complete the format modification)

 After completing the steps to change the format, grant permissions as required and run the ./start file

(Then there is a high probability of errors. It is very normal that the error code for the first execution is 7051.) Solution:

docker-compose -f docker-compose.yml down
docker volume rm $(docker volume list -q)

There may be a line that is not executed successfully, as long as it is executed.

This code can solve this problem. (then the next error will appear)

Version error, this error is also a normal error

(Note that the following three steps have been executed, this error will be superimposed, and the specific understanding is 7051+ version error)

 The first step: first enter the configuration file etc/resolv.conf and then comment out the first two lines

 

 Step 2: Clear the channel (to solve the version problem)

docker-compose -f docker-compose-cli.yaml down --volumes --remove-orphans
docker rm -f $(docker ps -a | grep "hyperledger/*" | awk "{print \$1}")
docker volume prune

There may be a line that is not executed successfully, as long as it is executed. Note: The last line should be deleted successfully

Step 3: Solve the 7051 problem

docker-compose -f docker-compose.yml down
docker volume rm $(docker volume list -q)

Run the start.sh file again to execute successfully

5. Run ./start.sh in the webapp directory 

chmod -R 777 startFarmerCC.sh  

First change the file format and grant permissions as required

Note: The suffix used for the webapp recording is the .sh file to modify the format and grant permissions

Note: After the execution, if the status code of the first execution is 200, if the status code of the second execution is 500, because the execution has been successful once, if the execution status of 500 appears, the problem can be ignored.

6. Execute npm install to install dependencies 

If npm install is successfully executed before, this code will generally not make mistakes during execution. If there is an error, ask Baidu.

如果报错是这个错误:Failed to execute '/usr/local/lib/node-v12.22.12-linux-x64/bin/node /usr/local/lib/node-v12.22.12-linux-x64/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --library=static_library --module=/opt/blockchain-trace-bcnetwork/webapp/node_modules/fabric-ca-client/node_modules/grpc/src/node/extension_binary/node-v72-linux-x64-glibc/grpc_node.node --module_name=grpc_node --module_path=/opt/blockchain-trace-bcnetwork/webapp/node_modules/fabric-ca-client/node_modules/grpc/src/node/extension_binary/node-v72-linux-x64-glibc --napi_version=8 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v72' (1)
npm WARN [email protected] No repository field.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `node-pre-gyp install --fallback-to-build --library=static_library`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2023-05-21T12_42_04_561Z-debug.log

There may be a permission problem, you can execute it first

sudo rm -rf /root/.cache/node-gyp

Then if npm install still fails, execute  the npm install --unsafe-perm statement to complete the installation. Note that if there is a problem later, it may be a problem with node.

7. Registered users

node enrollAdmin.js

node registerUser.js

According to the requirements, there is a high probability that there will be a problem the first time , just delete the key and try again

8. Start the node service

node app.js

 If there is no problem with starting node, there will be no problem. If there is a problem, reinstall node and try again.

Start: pm2 start app.js

Stop: pm2 stop app.js

You can install pm2, one line of command to solve the problem: npm install pm2@latest -g

9 Then execute normally according to three or four, start the project, enter the page to view the results

 If you successfully click on consumer traceability, there will be some effects, and there will be content under the pre-hash

 don't panic if not

First of all, please make sure that the address you use is correct and the corresponding server can be accessed normally. If the target server is reachable but you still get a connection timeout error, there may be one of the following reasons:

  1. A network failure caused the request to not be properly responded to. You can try to use other network for request.
  2. The request was blocked by a firewall or other network security device. Please check your network configuration to ensure requests are routed correctly. If necessary, add appropriate rules or exceptions to allow the request through.
  3. The request took too long to process and timed out. You can try to adjust the timeout of the request, or optimize the processing to improve the response speed.

After trying the above solutions, if the problem persists, you can try to contact the server administrator or the relevant support team for more specific help.

Close the firewall, go to the server console and open all ports to check the results again.

Guess you like

Origin blog.csdn.net/String_new/article/details/130801688