hyperledger fabric explorer 超级账本区块链浏览器搭建-docker的方式

这篇具有很好参考价值的文章主要介绍了hyperledger fabric explorer 超级账本区块链浏览器搭建-docker的方式。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

hyperledger fabric explorer 超级账本区块链浏览器搭建-使用docker的方式快速搭建一个超级账本区块链浏览器

  • 区块链浏览器可以让用户更加直观地查看当前超级账本网络的情况,来观察整个区块链上的块数,节点数,通道,链码等;

  • 官方推荐的搭建区块链浏览器有两种方法,一种是docker的方式,一种是用代码在自己本地的方式搭建,这里我们选择docker的方式搭建;

官方的github项目地址:

https://github.com/hyperledger/blockchain-explorer

Quick start (using Docker)

1、配置文件

# 新建文件夹,用于存放区块链浏览器搭建过程中的配置文件
mkdir explorer
cd explorer
# wget配置文件,由于被墙,可能无法直接获取
wget https://raw.githubusercontent.com/hyperledger/blockchain-explorer/main/examples/net1/config.json
wget https://raw.githubusercontent.com/hyperledger/blockchain-explorer/main/examples/net1/connection-profile/test-network.json -P connection-profile
wget https://raw.githubusercontent.com/hyperledger/blockchain-explorer/main/docker-compose.yaml
# 解决方法,手动创建配置文件,并通过访问下面网址,将配置文件内容复制进去

2、将区块链网络的证书文件整个目录复制到 explorer下,并重命名为organizations:

cd /root/block/geneg/twonodes/
cp -r crypto-config ../explorer/organizations

3、配置文件存放目录结构如下:

# 因为我们有两个peer节点,org1和org2
explorer
	|___docker-compose.yaml
	|___config.json
	|___connection-profile
		   		|___org1-network.json
		   		|___org2-network.json
root@aa:~/block/geneg# cd /root/block/geneg/
root@aa:~/block/geneg# pwd
/root/block/geneg
root@aa:~/block/geneg# ls
twonodes
root@aa:~/block/geneg# mkdir explorer
root@aa:~/block/geneg# ls
explorer  twonodes
root@aa:~/block/geneg# cd explorer
root@aa:~/block/geneg/explorer# mkdir connection-profile
root@aa:~/block/geneg/explorer# ls
connection-profile

(1)新文件:docker-compose.yaml,内容如下

​ https://github.com/hyperledger/blockchain-explorer/blob/main/docker-compose.yaml

networks:
  mynetwork.com:
    external:
      name: fabric_test		# 这个地方要改成自己的网络名称
# 修改成自己的文件挂载路径
volumes:
      - ${EXPLORER_CONFIG_FILE_PATH}:/opt/explorer/app/platform/fabric/config.json
      - ${EXPLORER_PROFILE_DIR_PATH}:/opt/explorer/app/platform/fabric/connection-profile
      - ${FABRIC_CRYPTO_PATH}:/tmp/crypto
      - walletstore:/opt/explorer/wallet  # 后面又提到,先往后找一找
# SPDX-License-Identifier: Apache-2.0
version: '2.1'

volumes:
  pgdata:
  walletstore:

networks:
  mynetwork.com:
    external:
      name: twonodes_test

services:

  explorerdb.mynetwork.com:
    image: hyperledger/explorer-db:latest
    container_name: explorerdb.mynetwork.com
    hostname: explorerdb.mynetwork.com
    environment:
      - DATABASE_DATABASE=fabricexplorer
      - DATABASE_USERNAME=hppoc
      - DATABASE_PASSWORD=password
    healthcheck:
      test: "pg_isready -h localhost -p 5432 -q -U postgres"
      interval: 30s
      timeout: 10s
      retries: 5
    volumes:
      - pgdata:/var/lib/postgresql/data
    networks:
      - mynetwork.com

  explorer.mynetwork.com:
    image: hyperledger/explorer:latest
    container_name: explorer.mynetwork.com
    hostname: explorer.mynetwork.com
    environment:
      - DATABASE_HOST=explorerdb.mynetwork.com
      - DATABASE_DATABASE=fabricexplorer
      - DATABASE_USERNAME=hppoc
      - DATABASE_PASSWD=password
      - LOG_LEVEL_APP=info
      - LOG_LEVEL_DB=info
      - LOG_LEVEL_CONSOLE=debug
      - LOG_CONSOLE_STDOUT=true
      - DISCOVERY_AS_LOCALHOST=false
    volumes:
      - ./config.json:/opt/explorer/app/platform/fabric/config.json
      - ./connection-profile:/opt/explorer/app/platform/fabric/connection-profile
      - ./organizations:/tmp/crypto
      - walletstore:/opt/explorer/wallet
    ports:
      - 8080:8080
    depends_on:
      explorerdb.mynetwork.com:
        condition: service_healthy
    networks:
      - mynetwork.com

(2)新文件:org1-network.json,内容如下

​ https://github.com/hyperledger/blockchain-explorer/blob/main/examples/net1/connection-profile/test-network.json

“name”: “test-network”, 这一项可以自定义,但是在 config.json加载配置文件路径项

“profile”: “./connection-profile/test-network.json” 要对应上

{
	"name": "org1-network",
	"version": "1.0.0",
	"client": {
		"tlsEnable": true,
		"adminCredential": {
			"id": "exploreradmin",
			"password": "exploreradminpw"
		},
		"enableAuthentication": true,
		"organization": "Org1MSP",
		"connection": {
			"timeout": {
				"peer": {
					"endorser": "300"
				},
				"orderer": "300"
			}
		}
	},
	"channels": {
		"mychannel": {
			"peers": {
				"peer0.org1.example.com": {}
			}
		}
	},
	"organizations": {
		"Org1MSP": {
			"mspid": "Org1MSP",
			"adminPrivateKey": {
				"path": "/tmp/crypto/peerOrganizations/org1.example.com/users/User1@org1.example.com/msp/keystore/priv_sk"
			},
			"peers": ["peer0.org1.example.com"],
			"signedCert": {
				"path": "/tmp/crypto/peerOrganizations/org1.example.com/users/User1@org1.example.com/msp/signcerts/User1@org1.example.com-cert.pem"
			}
		}
	},
	"peers": {
		"peer0.org1.example.com": {
			"tlsCACerts": {
				"path": "/tmp/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt"
			},
			"url": "grpcs://peer0.org1.example.com:7051"
		}
	}
}
# 这里的id和password为一会登录的账号和密码
"adminCredential": {
			"id": "exploreradmin",
			"password": "exploreradminpw"
}

(3)新文件:org2-network.json,内容如下

{
	"name": "org2-network",
	"version": "1.0.0",
	"client": {
		"tlsEnable": true,
		"adminCredential": {
			"id": "exploreradmin",
			"password": "exploreradminpw"
		},
		"enableAuthentication": true,
		"organization": "org2MSP",
		"connection": {
			"timeout": {
				"peer": {
					"endorser": "300"
				},
				"orderer": "300"
			}
		}
	},
	"channels": {
		"mychannel": {
			"peers": {
				"peer0.org2.example.com": {}
			}
		}
	},
	"organizations": {
		"org2MSP": {
			"mspid": "org2MSP",
			"adminPrivateKey": {
				"path": "/tmp/crypto/peerOrganizations/org2.example.com/users/User1@org2.example.com/msp/keystore/priv_sk"
			},
			"peers": ["peer0.org2.example.com"],
			"signedCert": {
				"path": "/tmp/crypto/peerOrganizations/org2.example.com/users/User1@org2.example.com/msp/signcerts/User1@org2.example.com-cert.pem"
			}
		}
	},
	"peers": {
		"peer0.org2.example.com": {
			"tlsCACerts": {
				"path": "/tmp/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt"
			},
			"url": "grpcs://peer0.org2.example.com:7051"
		}
	}
}

(4)新文件:config.json,内容如下

https://github.com/hyperledger/blockchain-explorer/blob/main/examples/net1/config.json

{
	"network-configs": {
		"org1-network": {
			"name": "org1-network",
			"profile": "./connection-profile/org1-network.json"
		},
		"org2-network": {
			"name": "org2-network",
			"profile": "./connection-profile/org2-network.json"
		}
	},
	"license": "Apache-2.0"
}

4、docker-compose 跑起服务

root@kai:~/block/geneg# cd explorer
root@kai:~/block/geneg/explorer# pwd
/root/block/geneg/explorer
root@kai:~/block/geneg/explorer# ls
config.json  connection-profile  docker-compose.yaml  organizations
root@kai:~/block/geneg/explorer# docker-compose up -d
Recreating explorerdb.mynetwork.com ... done
Creating explorer.mynetwork.com     ... done
root@kai:~/block/geneg/explorer# docker ps -a
hyperledger/explorer:latest
hyperledger/explorer-db:latest

5、浏览器上访问:文章来源地址https://www.toymoban.com/news/detail-401440.html

云主机ip:8080
账号   "exploreradmin",
密码   "exploreradminpw"

到了这里,关于hyperledger fabric explorer 超级账本区块链浏览器搭建-docker的方式的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包