区块链浏览器环境配置二--创建数据库

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

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值