This article mainly introduces the environment construction and operation process of HyperLedger Explorer version 0.3.9. If there are any mistakes in the article, please point them out. If you have other experiences, thank you for sharing with me.
Table of contents
-
-
-
- Introduction
- 1. Nodejs installation
- Two, PostgreSQL10 installation
- Three, Jq installation
- Four, gcc installation
- Five, Explorer download
- 6. Modify the database configuration (the following work should be very careful)
- Seven, Explorer configuration Fabric network
- Eight, Explorer compilation
- 9. Start Explorer
- 10. Problem summary
-
-
Introduction
- HyperledgerExplorer is a simple, powerful, easy-to-use, and well-maintained open-source utility to browse activity on the underlying blockchain network.
- Official document and download address: https://github.com/hyperledger/blockchain-explorer/tree/v0.3.9 If you are confused, please refer to the official document directly
- The downloaded version should correspond to:
Fabric1.4 construction and first-network sample test see another blog post: Hyperledger Fabric1.4 environment construction and sample test
HyperLedger Explorer installation prerequisites:
- nodejs 8.11.x (Note that v9.x is not yet supported)
- PostgreSQL 9.5 or greater
- Jq
- gcc-c++
1. Nodejs installation
#下载压缩包
wget https://nodejs.org/dist/v8.11.4/node-v8.11.4-linux-x64.tar.xz
#解压
tar xvf node-v8.11.4.tar.gz
#可将解压后的文件移动到/usr/local/src/
#配置环境变量
vi /etc/profile
Add the following:
#立即生效
source /etc/profile
view version
Two, PostgreSQL10 installation
See blog post for details: Install PostgreSQL under Linux (CentOS)
Three, Jq installation
yum install epel-release
yum install jq
Four, gcc installation
yum install -y gcc-c++
Five, Explorer download
#下载源码
# cd /opt/gopath/src/github.com/hyperledger
# git clone https://github.com/hyperledger/blockchain-explorer.git
#切换Fabric版本
# git checkout -b release-3.9 origin/release-3.9
The download may be very slow. I directly downloaded the compressed file of the explorer source code version 0.3.9 from the official website, uploaded it to Linux and then decompressed it. The location is placed in /opt/gopath/src/github.com/hyperledger/
6. Modify the database configuration (the following work should be very careful)
You can change the folder name blockchain-explorer-0.3.9 to blockchain-explorer
1. Modify the database configuration
cd blockchain-explorer/app
vi explorerconfig.json
#官方默认的配置如下。用户名username和密码passwd可以自行修改
"postgreSQL": {
"host": "127.0.0.1",
"port": "5432",
"database": "fabricexplorer",
"username": "hppoc",
"passwd": "password"
}
cd persistence/fabric/postgreSQL
chmod -R 775 db/
cd db
2. Create postpress SQL database
Official documents are created by executing the script ./createdb.sh.
I have a problem here, so I created it manually. If you can use the ./createdb.sh command to create, share with me your thoughts.
First use the client Navicat to connect to postpressSQL
1) Create a role
The user name and password of the role are username and passwd in the configuration of xplorerconfig.json
2) Create a database
The name of the database is fabricexplorer, and the owner of the database is set to the user named username
Here An error may be reported: ERROR: source database “template1” is being accessed by other users
#查看模板数据库“template1”的进程号
ps -ef|grep postg
#杀掉进程
kill -9 进程号
#再尝试创建数据库
I have never used postpressSQL before, and some problems are really unfamiliar. The solution to this problem is to refer to the article: https://blog.csdn.net/design321/article/details/24740769
3) Create a table
Download explorerpg.sql in the blockchain-explorer/app/persistence/fabric/postgreSQL/db directory to the local, execute it on Navicat, and change all :user to the corresponding username after completion, as shown in the figure
:
4) Check the postpressSQL Chinese tutorial on the server after all are created
: https://www.runoob.com/postgresql/postgresql-create-table.html
Seven, Explorer configuration Fabric network
Take the official test network first-network as an example
cd /opt/gopath/src/github.com/hyperledger/blockchain-explorer/app/platform/fabric
vi config.json
#所有的fabric-path修改为自己的路径
like:
Eight, Explorer compilation
cd blockchain-explorer
npm install
cd client/
npm install
npm run build
若遇到权限不足,赋予权限
chmod -R 755 所在目录
9. Start Explorer
Start the first-network network first
cd blockchain-explorer
#启动
./start.sh
The log is located in blockchain-explorer/logs/console/
The log of successful startup is as follows:
Open the webpage:
If it is a cloud server, remember to open port 8080 in the security group
#停止
./stop.sh
10. Problem summary
1. The startup of explorer is unsuccessful, and the log file shows
Error: The gRPC binary module was not installed. This may be fixed by running "npm rebuild"
to solve:
npm rebuild grpc
If you encounter a prompt:
nodejs gyp WARN EACCES user “root” does not have permission to access the dev dir,
then execute
npm rebuild grpc --unsafe-perm
2. Others: to be added...
Reference blog post:
https://cloud.tencent.com/developer/article/1697210
Official document:
https://github.com/hyperledger/blockchain-explorer