Hyperledger Explorer is a simple, powerful, easy-to-use, highly maintainable open-source blockchain explorer for viewing activity on the underlying blockchain network.
There are many tutorials on the Internet that can’t be done according to the operation. Today, I took the time to record the detailed tutorials.
prerequisite
- nodejs 8.11.x (Note that v9.x is not yet supported)
- PostgreSQL 9.5 or greater
- Jq [https://stedolan.github.io/jq/]
- gcc-c++
- Operate under a non-root user, the pg database user is the same as the server user, and sudo authority is required
1. nodejs installation
Reference https://blog.csdn.net/tiansheng1225/article/details/83899808
2. PostgreSQL installation
Reference https://www.linuxidc.com/Linux/2017-10/147536.htm
3. jq installation
Reference https://blog.csdn.net/markximo/article/details/80449626
4. gcc-c++ installation
yum install -y gcc-c++
5. Download the source code
git clone https://github.com/hyperledger/blockchain-explorer.git
6. Modify the database configuration
cd blockchain-explorer/app
vi explorerconfig.json
Modify username and passwd
{
"persistence": "postgreSQL",
"platforms": ["fabric"],
"postgreSQL": {
"host": "127.0.0.1",
"port": "5432",
"database": "fabricexplorer",
"username": "chenjf",
"passwd": "123456"
},
"sync": {
"type": "local",
"platform": "fabric",
"blocksSyncTime": "3"
}
}
7. PostgreSQL database user creation, table creation, it is recommended to use tools
According to the official website documentation, you have to execute the createdb.sh script to create users, databases and tables, but the execution will report an error, so it is recommended to create it yourself.
I use navicat premium to create
First create a role with the same configuration as above, here is chenjf, password 123456
Create a database with the same name as the above configuration, here is fabricexplorer
To create a table, you need to switch to the user you just created to operate. The script is explorerpg.sql in the blockchain-explorer/app/persistence/fabric/postgreSQL/db directory, which can be copied and executed on navicat premium, where: user needs to be changed to The corresponding user name, such as when the following table is created to specify the user: ALTER table blocks owner to chenjf; remember to have a semicolon.
8. Start the first-network after everything is created, and execute ./byfn.sh up to start the fabric environment
9. Modify the fabric configuration in Explorer. Take first-network as an example. If you build it yourself, adjust it according to the actual situation.
Mainly replace the fabric-path with the actual first-network path, cd blockchain-explorer-bak/app/platform/fabric
Edit the configuration file: vi config.json, replace all the fabric-paths in the text with the path where fabric-samples is located, and the others can not be modified
10. Compile
cd blockchain-explorer
npm install
cd client/
npm install
npm run build
If you have insufficient permissions during the compilation process, remember to add readable permissions to all files in the specified directory
chmod -R 755 所在目录
11. Start execution
cd blockchain-explorer
./start.sh
After startup, check whether the log is normal. The log is located in the blockchain-explorer/logs/console/ directory. The following similar logs indicate that the deployment has been successful.
12. Open browser preview