源码部署Fabric-explorer

1、安装jq

# 安装EPEL源
$ yum install epel-release
# 查看jq包是否存在
$ yum list jq
# 安装jq
$ yum install jq

2、安装NodeJs

# 下载
$ wget https://nodejs.org/dist/v12.16.1/node-v12.16.1-linux-x64.tar.xz
# 解压
$ tar -xvf node-v12.16.1-linux-x64.tar.xz
# 重命名
$ mv node-v12.16.1-linux-x64 node-v12.16.1
# 进入解压目录的bin下
$ cd node-v12.16.1/bin && ls
# 查看版本号
$ ./node -v
# 配置全局使用
$ ln -s /usr/local/src/node-v12.16.1/bin/node /usr/local/bin/node
$ ln -s /usr/local/src/node-v12.16.1/bin/npm /usr/local/bin/npm
# 验证一下
$ node -v
$ npm -version

3、安装PostgreSQL

# 安装存储库
$ yum install https://download.postgresql.org/pub/repos/yum/10/redhat/rhel-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
# 安装客户端
$ yum install postgresql10
# 安装服务端
$ yum install postgresql10-server
# 验证是否安装成功
$ rpm -aq| grep postgres
# 初始化数据库
$ /usr/pgsql-10/bin/postgresql-10-setup initdb
# 启用开机自启动
$ systemctl enable postgresql-10
$ systemctl start postgresql-10
# 配置防火墙
$ firewall-cmd --permanent --add-port=5432/tcp
$ firewall-cmd --permanent --add-port=80/tcp
$ firewall-cmd --reload
# 切换用户
$ su - postgres
# 登录数据库
$ psql -U postgres
# 设置postgres用户密码为postgres(\q 退出数据库)
$ ALTER USER postgres WITH PASSWORD 'postgres';
# 创建用户
$ create user fala with password '123456';
# 创建数据库
$ create database fabricexplorer owner fala;
# 开启远程访问(修改#listen_addresses = 'localhost' 为 listen_addresses='*')
$ vi /var/lib/pgsql/10/data/postgresql.conf
# 信任远程连接
$ vi /var/lib/pgsql/10/data/pg_hba.conf
# 修改如下内容,信任指定服务器连接
# IPv4 local connections:
host all all 127.0.0.1/32 trust
host all all 0.0.0.0/0 trust
# 重启服务
$ systemctl restart postgresql-10

4、安装gcc-c++

$ yum install -y gcc-c++

5、获取Hyperledger Explorer项目

# 可以使用国内镜像地址:git clone https://github.com.cnpmjs.org/hyperledger/blockchain-explorer.git
$ git clone https://github.com/hyperledger/blockchain-explorer

6、修改数据库配置

$ cd blockchain-explorer/app
$ vi  explorerconfig.json
# 修改username跟passwd(同上面psql数据库创建的用户密码一致)
"username": "fala"
"passwd": "123456"

7、登录psql数据库创建表

# 需要切换到刚才创建的用户下操作,脚本在blockchain-explorer/app/persistence/fabric/postgreSQL/db目录下的explorerpg.sql,建议使用Navicat Premium工具
# sql文件中 :user 需要改成对应的用户名(如:fala)
# 把头部的创建用户、配置密码、创建数据库语句删除

8、Explorer配置Fabric

# 进入配置目录
$ cd blockchain-explorer/app/platform/fabric/connection-profile
# 修改配置(替换文中所有的fabric-path为fabric-samples所在的路径即可),详见附件explorer/first-network.json
$ vi first-network.json

9、启动Explorer服务

$ cd blockchain-explorer
$ npm install --unsafe-perm
$ cd client/
$ npm install --unsafe-perm
$ npm run build
$ cd ../
$ npm start
# 在其他服务器部署启动,使用以下方式启动
$ DISCOVERY_AS_LOCALHOST=false npm start
# 停止服务
$ ./stop.sh

10、访问浏览器(记得设置防火墙,账户密码是配置文件config.json中配置的)

http://192.168.7.101:8080

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值