区块链浏览器部署

Hyperledger Explorer

Hyperledger Explorer是一个简单,功能强大,易于使用,高度可维护的开源浏览器,用于查看底层区块链网络上的活动 。

postgresql

安装

创建用户

1
useradd postgres
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
注意:更新yum源,163或者阿里的yum源都可以

添加RPM
yum install https://download.postgresql.org/pub/repos/yum/9.5/redhat/rhel-7-x86_64/pgdg-centos95-9.5-3.noarch.rpm


安装PostgreSQL 9.5
yum install postgresql95-server postgresql95-contrib

初始化数据库
/usr/pgsql-9.5/bin/postgresql95-setup initdb
设置开机自启动
systemctl enable postgresql-9.5.service

启动服务
systemctl start postgresql-9.5.service
查看服务运行状态
systemctl status postgresql-9.5.service

postgreSQL 安装完成后,会建立一下‘postgres’用户,用于执行PostgreSQL,数据库中也会建立一个’postgres’用户,默认密码为自动生成,需要在系统中改一下。

修改用户密码

1
2
3
4
su - postgres  切换用户,执行后提示符会变为 '-bash-4.2$'
psql -U postgres 登录数据库,执行后提示符变为 'postgres=#'
ALTER USER postgres WITH PASSWORD 'gooagoo' 设置postgres用户密码
\q 退出数据库

开启远程访问

1
2
3
vi /var/lib/pgsql/9.5/data/postgresql.conf
修改#listen_addresses = 'localhost' 为 listen_addresses='*'
当然,此处‘*’也可以改为任何你想开放的服务器IP

信任远程连接

1
2
3
4
5
vi /var/lib/pgsql/9.5/data/pg_hba.conf
修改如下内容,信任指定服务器连接
# IPv4 local connections:
host all all 127.0.0.1/32 trust
host all all 10.211.55.6/32(需要连接的服务器IP) trust

重启

1
systemctl restart postgresql-9.5.service

blockchain-explorer

克隆存储库

1
2
3
4
5
6
7
8
git clone https://github.com/hyperledger/blockchain-explorer.git
cd blockchain-explorer

也可以从我的百度链接上面下载:
链接:https://pan.baidu.com/s/1VsxMlk5qo_5hUKsJ03DTlA
提取码:9s5f

cp -apr blockchain-explorer /var/lib/pgsql/

数据库设置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
su - postgres
cd blockchain-explorer/app

修改explorerconfig.json以更新postgresql属性

postgreSQL主机,端口,数据库,用户名,密码详细信息。
“postgreSQL”:{

"host": "127.0.0.1",
"port": "5432",
"database": "fabricexplorer",
"username": "postgres",
"passwd": "gooagoo"
}

运行create database脚本

1
2
cd blockchain-explorer/app/persistence/fabric/postgreSQL/db
./createdb.sh

安装node

1
2
3
4
5
6
7
tar xvf  node-v11.10.0-linux-x64.tar
cd node-v11.10.0-linux-x64
./configure && make && make install


装cnpm淘宝源
npm install -g cnpm --registry=https://registry.npm.taobao.org

npm测试

1
2
3
4
5
6
7
8
9
10
cnpm install
cd blockchain-explorer/app/test
cnpm install
cnpm run test
cd client/
cnpm install
cnpm test -- -u --coverage
cnpm run build

由于config.json还没有写配置,所以node test会测试不成功

fabric的网络配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
vim blockchain-explorer/app/platform/fabric/config.json

{
"network-configs": {
"network-1": {
"version": "1.0",
"clients": {
"client-1": {
"tlsEnable": false,
"organization": "1D8L291SQ3QRQ80AB2M1029FB60010HCMSP",
"channel": "vaccine",
"credentialStore": {
"path": "./tmp/credentialStore_Org1/credential",
"cryptoStore": {
"path": "./tmp/credentialStore_Org1/crypto"
}
}
}
},
"channels": {
"vaccine": {
"peers": {
"peer0.syj.vaccine.com": {}
},
"connection": {
"timeout": {
"peer": {
"endorser": "6000",
"eventHub": "6000",
"eventReg": "6000"
}
}
}
}
},
"organizations": {
"1D8L291SQ3QRQ80AB2M1029FB60010HCMSP": {
"mspid": "1D8L291SQ3QRQ80AB2M1029FB60010HCMSP",
"fullpath": false,
"adminPrivateKey": {
"path": "/data/fabric/fabric-ca-files/vaccine-org/syj.vaccine.com/admin/msp/keystore"
},
"signedCert": {
"path": "/data/fabric/fabric-ca-files/vaccine-org/syj.vaccine.com/admin/msp/signcerts"
}
},
"1D9K2HVDM752IN0AB2M105R9Q5001125MSP": {
"mspid": "1D9K2HVDM752IN0AB2M105R9Q5001125MSP",
"fullpath": false,
"adminPrivateKey": {
"path": "/data/fabric/fabric-ca-files/vaccine-org/czsrmyy.czsjkzx.hbsjkzx.vaccine.com/admin/msp/keystore"
},
"signedCert": {
"path": "/data/fabric/fabric-ca-files/vaccine-org/czsrmyy.czsjkzx.hbsjkzx.vaccine.com/admin/msp/signcerts"
}
},
"OrdererMSP": {
"mspid": "OrdererMSP",
"adminPrivateKey": {
"path": "/data/fabric/fabric-ca-files/vaccine-order/vaccine.syj.vaccine.com/admin/msp/keystore"
}
}
},
"peers": {
"peer0.syj.vaccine.com": {
"url": "grpc://peer0.syj.vaccine.com:7051",
"eventUrl": "grpc://peer0.syj.vaccine.com:7053",
"grpcOptions": {
"ssl-target-name-override": "peer0.syj.vaccine.com"
}
},
"peer0.czsrmyy.czsjkzx.hbsjkzx.vaccine.com": {
"url": "grpc://peer0.czsrmyy.czsjkzx.hbsjkzx.vaccine.com:7351"
}
},
"orderers": {
"orderer1.vaccine.syj.vaccine.com": {
"url": "grpc://orderer1.vaccine.syj.vaccine.com:7050"
}
}
},
"network-2": {}
},
"configtxgenToolPath": "/data/fabric/bin",
"license": "Apache-2.0"
}

完成之后,在执行上面的,cnpm test

汉化

1
2
3
4
cd /var/lib/pgsql/blockchain-explorer/client/src
将components替换成我百度链接的包

之后还需要重新,cnpm build一下

注意

1
2
3
4
由于区块链浏览器默认需要有锚节点,才能显示所有节点,所以在部署了第一个组织之后,需要在升级下锚节点
./bin/configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org1MSPanchors.tx -channelID vaccine -asOrg Org1MSP

docker exec -it cli-vaccine peer channel update -o orderer1.vaccine.syj.vaccine.com:7050 -c vaccine -f ./channel-artifacts/Org1MSPanchors.tx

启动

1
2
cd blockchain-explorer/
./start.sh

访问

1
ip:8080

Donate