区块链浏览器(blockchain-explorer)的安装(并以first network为例)
部署环境:Ubuntu 18.04,fabric 1.4
准备工作
安装nodejs
// 安装nodejs
sudo apt-get update #更新apt包索引
sudo apt-get install nodejs #安装nodejs
sudo apt install nodejs-legacy
node -v
sudo npm config set registry https://registry.npm.taobao.org
检查是否安装成功(版本最好在8.0以上)
安装npm
npm是nodejs的包管理工具。
// 安装npm
sudo apt-get update #更新apt包索引
sudo apt install libssl1.0-dev nodejs-dev node-gyp npm #安装npm
npm -v
检查是否安装成功
安装jq
jq是一种轻量级且灵活的命令行JSON解析器。
// 安装jq
sudo apt-get update #更新apt包索引
sudo apt-get install jq #安装jq
jq -V
检查是否安装成功
安装postgreSQL
// 安装postgreSQL
sudo apt-get update #更新apt包索引
sudo apt-get install #postgresql#安装数据库
sudo -u postgres psql #打开客户端工具pspl
postgres=# ALTER USER postgres WITH PASSWORD '123456'; # 修改 postgres 数据库用户的密码为123456
postgres=# \q #退出
// 修改配置实现远程访问
vi /etc/postgresql/9.5/main/postgresql.conf
listen_addresses = 'localhost' 改为 listen_addresses = '*'
// 设置所有用户可连接
vi /etc/postgresql/9.5/main/pg_hba.conf
在最后一行插入一下内容(注意要对齐)
host all all 0.0.0.0/0 md5
// 重启服务
/etc/init.d/postgresql restart
拉取blockchain-explorer 项目
// 拉取项目
cd go/src/github.com/hyperledger/
git clone https://github.com/hyperledger/blockchain-explorer.git
#修改文件夹权限
sudo chmod -R 777 blockchain-explorer
创建数据库
进入数据库文件目录
cd persistence/fabric/postgreSQL/db
创建数据库
sudo ./createdb.sh
查看是否创建成功
sudo -u postgres psql #连接postgreSQL
执行\l的时候显示以下内容
(图片转载自http://cigod.blog.csdn.net)
执行\q退出
启动first-network
#打开新的终端进入文件目录
cd go/src/github.com/hyperledger/fabric/fabric-samples/first-network/
#启动网络
./byfn.sh up
结果如下代表运行成功:
修改blockchain-explorer fabric 配置
#进入文件目录
cd go/hyperledger/blockchain-explorer/app/platform/fabric/connection-profile/
#修改配置文件
vi first-network.json
将adminPrivateKey,signedCert,tlsCACerts这三个路径全部改为自己first-network的绝对路径。保存。
构建 blockchain-explorer
#进入目录
cd go/src/github.com/hyperledger/blockchain-explorer/
#执行以下语句
./main.sh install
./main.sh test
运行blockchain-explorer
#进入目录
cd go/src/github.com/hyperledger/blockchain-explorer/
./start.sh
打开日志文件,如果出现以下内容,则代表运行成功。
在网页中打开http://localhost:8080/,出现以下页面。
(可能有登录页面,默认用户名和密码分别是admin,adminpw)
完成。