Hyperledger Explorer是一个简单,功能强大,易于使用,高度可维护的开源区块链浏览器,用于查看底层区块链网络上的活动。
下载tar包
解压
tar -xvf node-v12.16.2-linux-x64.tar.xz
mv node-v12.16.2-linux-x64 node-v12.16.2
配置全局使用
ln -s /usr/local/node-v12.16.2/bin/node /usr/local/bin/node
ln -s /usr/local/node-v12.16.2/bin/npm /usr/local/bin/npm
apt-get install postgresql
启动服务
/etc/init.d/postgresql start
修改用户密码:
su - postgres 切换用户,执行后提示符会变为 '-bash-4.2$'
psql -U postgres 登录数据库,执行后提示符变为 'postgres=#'
ALTER USER postgres WITH PASSWORD 'postgres'; 设置postgres用户密码为postgres
\q 退出数据库
exit 退出命令行界面
卸载
apt-get --purge remove postgresql*
apt-get --purge remove postgis*
apt install jq
apt install gcc
gcc --version
cd /opt/gopath/src/github.com/hyperledger
git clone https://github.com/hyperledger/blockchain-explorer.git
我们使用默认版本,进行数据库创建:
cd blockchain-explorer/app
vi explorerconfig.json
修改配置如下:
{
"persistence": "postgreSQL",
"platforms": ["fabric"],
"postgreSQL": {
"host": "127.0.0.1",
"port": "5432",
"database": "fabricexplorer",
"username": "postgres",
"passwd": "postgres"
},
"sync": {
"type": "local",
"platform": "fabric",
"blocksSyncTime": "1"
},
"jwt": {
"secret": "a secret phrase!!",
"expiresIn": "2h"
}
}
运行创建数据库的脚本
cd /opt/gopath/src/github.com/hyperledger/blockchain-explorer/app/persistence/fabric/postgreSQL/db
./createdb.sh
查看数据库状态指令:
sudo -u postgres psql -c '\l'
sudo -u postgres psql fabricexplorer -c '\d'
cd /opt/gopath/src/github.com/hyperledger/blockchain-explorer/app/platform/fabric/
vim config.json
设置enableAuthentication属性false,用于关闭登录认证
{
"network-configs": {
"first-network": {
"name": "firstnetwork",
"profile": "./connection-profile/first-network.json",
"enableAuthentication": false
}
},
"license": "Apache-2.0"
}
设置first-network.json配置
继续进行设置(Fabric网络环境要处于正常启动的状态,不然下述路径的文件是不存在的)
cd /opt/gopath/src/github.com/hyperledger/blockchainexplorer/app/platform/fabric/connection-profile/
vim first-network.json
重点设置如下几项:
{
"name": "first-network",
"version": "1.0.0",
"license": "Apache-2.0",
"client": {
"tlsEnable": true,
"caCredential": {
"id": "admin",
"password": "adminpw"
},
"adminCredential": {
"id": "admin",
"password": "123456",
"affiliation": "org1.department1"
},
"enableAuthentication": true,
"organization": "Org1MSP",
"connection": {
"timeout": {
"peer": {
"endorser": "300"
},
"orderer": "300"
}
}
},
"channels": {
"zmeduchannel": {
"peers": {
"peer0.org1.example.com": {}
},
"connection": {
"timeout": {
"peer": {
"endorser": "6000",
"eventHub": "6000",
"eventReg": "6000"
}
}
}
}
},
"organizations": {
"Org1MSP": {
"mspid": "Org1MSP",
"adminPrivateKey": {
"path": "/opt/gopath/src/github.com/hyperledger/fabric/example/crypto-config/peerOrganizations/org1.example.com/users/[email protected]/msp/keystore/9ccc1d5b3baae6d7a0aa697d6cae8009ad55c12cbdba34cdaeaaf7ab15d96ab0_sk"
},
"peers": ["peer0.org1.example.com"],
"signedCert": {
"path": "/opt/gopath/src/github.com/hyperledger/fabric/example/crypto-config/peerOrganizations/org1.example.com/users/[email protected]/msp/signcerts/[email protected]"
}
}
},
"peers": {
"peer0.org1.example.com": {
"tlsCACerts": {
"path": "/opt/gopath/src/github.com/hyperledger/fabric/example/crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt"
},
"url": "grpcs://peer0.org1.example.com:7051",
"grpcOptions": {
"ssl-target-name-override": "peer0.org1.example.com"
}
}
},
"certificateAuthorities": {
"ca0": {
"url": "https://peer0.org1.example.com:7054",
"httpOptions": {
"verify": false
},
"tlsCACerts": {
"path": "/opt/gopath/src/github.com/hyperledger/fabric/example/crypto-config/peerOrganizations/org1.example.com/ca/ca.org1.example.com-cert.pem"
},
"caName": "ca0"
}
}
}
注:需要说明一点,这两个 "tlsCACerts" 并不在一个字典中,配置时要特别注意,还有就是以自己的文件路径为主。
cd /opt/gopath/src/github.com/hyperledger/blockchain-explorer
npm install --unsafe-perm
cd /opt/gopath/src/github.com/hyperledger/blockchain-explorer/client
npm install --unsafe-perm
npm run build --unsafe-perm
cd /opt/gopath/src/github.com/hyperledger/blockchain-explorer
npm run build --unsafe-perm
cd /opt/gopath/src/github.com/hyperledger/blockchain-explorer
./start.sh
后台启动
nohup ./start.sh logs/log.log 2>&1 &
查看日志blockchain-explorer/logs/console/
./stop.sh
http://127.0.0.1:8080/