本版本是Ubuntu16.04 在安装完fabric并运行的情况下再安装
1.升级node、npm
1.产看node版本,没安装的请先安装;
$ node -v
2.清楚node缓存;
$ sudo npm cache clean -f
3.安装node版本管理工具'n';
$ sudo npm install n -g
4.使用版本管理工具安装指定node或者升级到最新node版本;
$ sudo n stable (安装node最新版本)
$ sudo n 8.9.4 (安装node指定版本8.9.4)
安装完成后再查看自己安装的版本
node-v
npm -v
2 安装jq和postgresql
1.安装jq
$ sudo apt install jq
2.安装postgresql
$ sudo apt install postgresql
(可选)
$ 1.sudo passwd -d postgres //以前密码作废
$ 2.sudo -u postgres passwd //设置新的密码
3下载blockchain-explorer文件
1.更新配置信息
在sudo vim blockchain-explorer/app/platform/fabric/config.json修改
{
"network-configs": {
"first-network": {
"name": "firstnetwork",
"profile": "./connection-profile/first-network.json", //添加逗号
"enableAuthentication": false //添加此条命令
}
},
"license": "Apache-2.0"
}
2.更新组织证书信息
sudo vim blockchain-explorer/app/platform/fabric/connection-profile/first-network.json
organizations": {
"Org1MSP": {
"mspid": "Org1MSP",
"fullpath": true,
"adminPrivateKey": {
//该参数除了更改路径外,还需要将_sk文件名改为你的相应路径下对应文件的真实文件名
"path": "/root/go/src/github.com/hyperledger/fabric-samples/first-network/crypto-config/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/keystore/8e23e246ec217c202df57e4525d9d9d30099067df634e666e2c6718548d33f71_sk"
},
//将"fabric-path"改为你的对应的绝对路径
"signedCert": {
"path": "/root/go/src/github.com/hyperledger/fabric-samples/first-network/crypto-config/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/signcerts/Admin@org1.example.com-cert.pem"
}
}
},
"peers": {
"peer0.org1.example.com": {
"tlsCACerts": {
//将"fabric-path"改为你的对应的绝对路径
"path": "/root/go/src/github.com/hyperledger/fabric-samples/first-network/crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt"
},
"url": "grpcs://localhost:7051",
"eventUrl": "grpcs://localhost:7053",
"grpcOptions": {
"ssl-target-name-override": "peer0.org1.example.com"
}
}
//下面还有一个要修改路径,总共三个
4.创建数据库脚本
$cd blockchain-explorer/app/persistence/fabric/postgreSQL/db
$sudo ./createdb.sh
注意:要先给db权限 sudo chmod -R 775 db/
查看数据
$ sudo -u postgres psql -c '\l'
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
----------------+----------+----------+---------+---------+-----------------------
fabricexplorer | hppoc | UTF8 | C.UTF-8 | C.UTF-8 |
postgres | postgres | UTF8 | C.UTF-8 | C.UTF-8 |
template0 | postgres | UTF8 | C.UTF-8 | C.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | C.UTF-8 | C.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
(4 rows)
//按住q退出
$ sudo -u postgres psql fabricexplorer -c '\d'
List of relations
Schema | Name | Type | Owner
--------+---------------------------+----------+-------
public | blocks | table | hppoc
public | blocks_id_seq | sequence | hppoc
public | chaincodes | table | hppoc
public | chaincodes_id_seq | sequence | hppoc
public | channel | table | hppoc
public | channel_id_seq | sequence | hppoc
public | orderer | table | hppoc
public | orderer_id_seq | sequence | hppoc
public | peer | table | hppoc
public | peer_id_seq | sequence | hppoc
public | peer_ref_chaincode | table | hppoc
public | peer_ref_chaincode_id_seq | sequence | hppoc
public | peer_ref_channel | table | hppoc
public | peer_ref_channel_id_seq | sequence | hppoc
public | transactions | table | hppoc
public | transactions_id_seq | sequence | hppoc
public | write_lock | table | hppoc
public | write_lock_write_lock_seq | sequence | hppoc
(18 rows)
5. 安装依赖
有两种方式
第一种
//进入到blockchain-explorer
$ ./main.sh install //安装测试创建文件
$ ./main.sh clean //清理文件夹 (这条命令重启的时候用)
To clean the /node_modules, client/node_modules client/build, client/coverage, app/test/node_modules directories
第二种
$ cd blockchain-explorer
$ npm install
$ cd client/
$ npm install
$ npm run build
6 启动项目
//进入到blockchain-explorer目录
$sudo ./start.sh
然后再页面输入http://localhost:8080