github地址
https://github.com/hyperledger/blockchain-explorer/tree/v1.1.7
git clone
git clone https://github.com/hyperledger/blockchain-explorer.git
cd /opt/gopath/src/github.com/hyperledger/blockchain-explorer
1 blockchain-explorer/app/explorerconfig.json
配置postgresql数据 配置数据库名称 登录名 密码
gedit /opt/gopath/src/github.com/hyperledger/blockchain-explorer/app/explorerconfig.json
{
"persistence": "postgreSQL",
"platforms": ["fabric"],
"postgreSQL": {
"host": "127.0.0.1",
"port": "5432",
"database": "fabricexplorer", //建立的数据库名称
"username": "yhj", //数据库登录名
"passwd": "yhj123" // 数据库登录密码
},
"sync": {
"type": "local",
"platform": "fabric",
"blocksSyncTime": "1"
},
"jwt": {
"secret": "a secret phrase!!",
"expiresIn": "2h"
}
}
2 blockchain-explorer/app/persistence/fabric/postgreSQL/db 路径下根据上述配置文件创建数据库
cd /opt/gopath/src/github.com/hyperledger/blockchain-explorer/app/persistence/fabric/postgreSQL/db
./createdb.sh脚本文件
gedit createdb.sh
echo "Copying ENV variables into temp file..."
node processenv.js
if [ $( jq .DATABASE_USERNAME /tmp/process.env.json) == null ]; then
export USER=$( jq .postgreSQL.username ../../../../explorerconfig.json ) //从配置文件获取数据库名 用户名 密码
else
export USER=$( jq .DATABASE_USERNAME /tmp/process.env.json)
fi
if [ $(jq .DATABASE_DATABASE /tmp/process.env.json) == null ]; then
export DATABASE=$(jq .postgreSQL.database ../../../../explorerconfig.json )
else
export DATABASE=$(jq .DATABASE_DATABASE /tmp/process.env.json)
fi
if [ $(jq .DATABASE_PASSWORD /tmp/process.env.json) == null ]; then
export PASSWD=$(jq .postgreSQL.passwd ../../../../explorerconfig.json | sed "y/\"/'/")
else
export PASSWD=$(jq .DATABASE_PASSWORD /tmp/process.env.json | sed "y/\"/'/")
fi
echo "USER=${USER}"
echo "DATABASE=${DATABASE}"
echo "PASSWD=${PASSWD}"
if [ -f /tmp/process.env.json ] ; then
rm /tmp/process.env.json
fi
echo "Executing SQL scripts, OS="$OSTYPE
#support for OS
case $OSTYPE in
darwin*) psql postgres -v dbname=$DATABASE -v user=$USER -v passwd=$PASSWD -f ./explorerpg.sql ; //创建数据库 选择数据库以及表格
psql postgres -v dbname=$DATABASE -v user=$USER -v passwd=$PASSWD -f ./updatepg.sql ;;
linux*) //选择数据库
if [ $(id -un) = 'postgres' ]; then
PSQL="psql"
else
PSQL="sudo -u postgres psql"
fi;
${PSQL} -v dbname=$DATABASE -v user=$USER -v passwd=$PASSWD -f ./explorerpg.sql ;
${PSQL} -v dbname=$DATABASE -v user=$USER -v passwd=$PASSWD -f ./updatepg.sql ;;
esac
在postgres 用户下执行脚本创建数据库以及表格
su postgres
启动配置文件
source /etc/profile
执行psql命令验证
psql
创建数据库
./createdb.sh
通过 psql -h 127.0.0.1 -d fabricexplorer -U yhj
进入数据库fabricexplorer
查看所有的数据库
psql -c '\l'
查看数据库fabricexplorer下的所有表 包含索引
psql fabricexplorer -c '\d'
psql 部分操作语句 psqlc菜鸟教程
部署 ipfs 网络 对接联盟链网络
Hyperledger fabric网络(多共识 多版本 多数据库 ca ) 封装接口sdk
Hyperledger Caliper 测试(多组织 多节点 多共识)
区块链浏览器
联系We-chat V : 18852897525