hyperledger fabric 测试(十)fabric浏览器部署

hyperledger fabric 测试(十)fabric浏览器部署

fabric浏览器部署

Hyperledger Explorer是一个简单,强大,易于使用,维护良好的开源程序,可浏览底层fabric区块链网络上的活动。用户可以在MacOS和Ubuntu上配置和构建Hyperledger Explorer。最新!Hyperledger Explorer现在可以与Hyperledger Iroha一起使用。

环境准备

发行版本

Hyperledger Explorer版本 v1.1.1 (Jul 17, 2020)

支持的Fabric版本 v1.4.0 to v2.1.1

支持的NodeJS版本 12.16.x

卸载软件

卸载postgreSQL

sudo apt-get --purge remove postgresql\
rm -r /etc/postgresql/ #执行可选
rm -r /var/lib/postgresql/ #执行可选
userdel -r postgres #执行可选

安装postgresql

sudo apt-get install postgresql

进入数据库

sudo -u postgres psql

数据库设置密码

ALTER USER postgres WITH PASSWORD 'hello123'
\q

拉取最新浏览器文件

git clone https://github.com/hyperledger/blockchain-explorer.git
cd blockchain-explorer
vim app/explorerconfig.json

修改app / explorerconfig.json以更新PostgreSQL数据库设置。

"postgreSQL": {
    
    
    "host": "127.0.0.1",
    "port": "5432",
    "database": "fabricexplorer",
    "username": "hppoc",
    "passwd": "password"
}

(可选)配置数据库设置的另一种方法是使用环境变量,例如设置:

export DATABASE_HOST=127.0.0.1
export DATABASE_PORT=5432
export DATABASE_DATABASE=fabricexplorer
export DATABASE_USERNAME=hppoc
export DATABASE_PASSWD=pass12345

使其db的sql代码可执行:

chmod -R 775 app/persistence/fabric/postgreSQL/db

修改app / platform / fabric / config.json以定义您的网络连接配置文件:

{
    
    
    "network-configs": {
    
    
        "first-network": {
    
    
            "name": "firstnetwork",
            "profile": "./connection-profile/first-network.json",
            "enableAuthentication": false
        }
    },
    "license": "Apache-2.0"
}

first-network是您的连接配置文件的名称,可以更改为任何名称。

name是您要给网络指定的名称,您只能更改name的值。

profile是您的连接配置文件的位置,您只能更改profile的值。

在JSON文件app / platform / fabric / connection-profile / first-network.json中修改连接配置文件:

在first-network.json文件中将path更改为fabric磁盘路径:提供adminPrivateKey config选项的完整磁盘路径,通常以_sk结尾,例如:
/fabric-path/fabric-samples/first-network/crypto-config/peerOrganizations/org1.example.com/users/[email protected] / msp / keystore / aaacd899a6362a5c8cc1e6f86d13bfccc777375365bbda9c710bb7119993d71c_sk

​ adminUser和adminPassword是Explorer用户登录仪表板的凭据

enableAuthentication是用于使用登录页面启用身份验证的标志,设置为false将跳过身份验证。

运行创建数据库脚本:

$ cd app/persistence/fabric/postgreSQL/db
$ sudo -u postgres ./createdb.sh

连接到PostgreSQL数据库并运行数据库状态命令:

$ sudo -u postgres psql -c '\l'
$ sudo -u postgres psql fabricexplorer -c '\d'

建立Hyperledger Explorer重要提示,每次git pull后重复以下步骤,安装,运行测试和构建项目:

cd ../../../../../
./main.sh install

(可选)清理/ node_modules,client / node_modules,client / build,client / coverage,app / test / node_modules目录:

./main.sh clean

或者:

$ cd blockchain-explorer
$ npm install
$ cd client/
$ npm install
$ npm run build

运行Hyperledger Explorer

如果区块链网络与浏览器服务器在一起,修改app/explorerconfig.json以更新同步设置。

"sync": {
    
    
  "type": "local"
}   

它将具有后端和GUI服务:

nohup ./start.sh &

它将停止节点服务器:

./stop.sh

注意:如果将Hyperledger Fabric网络部署在其他计算机上,请定义以下环境变量:

$ DISCOVERY_AS_LOCALHOST=false ./start.sh

在不同位置独立运行

修改app/explorerconfig.json以更新同步设置。

"sync": {
    
    
  "type": "host"
}   

如果以前在浏览器中使用过Hyperledger Explorer,请确保在重新启动之前清除缓存。

它将开始同步节点:

./syncstart.sh

它将停止同步节点:

./syncstop.sh

注意:如果将Hyperledger Fabric网络部署在其他计算机上,请定义以下环境变量:

$ DISCOVERY_AS_LOCALHOST=false ./syncstart.sh

问题:

SequelizeConnectionError: password authentication failed for user “postgres”

解决:修改pg_hba.conf配置文件,将第4个字段改为trust

# Database administrative login by Unix domain socket
local   all             postgres                                peer

为了避免麻烦,我将所有行的第4个字段都改成了 trust
最后执行sudo /etc/init.d/postgresql reload,重新加载配置文件。

如果有问题,关注公众号发私信来解决。

猜你喜欢

转载自blog.csdn.net/Rcvisual/article/details/109379521