IBM Blockchain Series Hyperledger, in addition to the most core of the fabric network also out a series of tools and engineering, this is recorded under the Blockchain browser installation deployment, the current version is to use the PostgreSQL database to store data (previous version using MySQL).
Browsers use Psql and Nodejs to develop, so for Java or Golang small partners, will definitely touch some nails. (The official installation is not very detailed)
First Address:
https://github.com/hyperledger/blockchain-explorer.git如果发现bug可以贡献修复
1. Environment-dependent installation
a) nodejs 8.11.x (Note that v9.x is not yet supported)b) PostgreSQL 9.5 or greaterc) Jq [https://stedolan.github.io/jq/]d) gite) gcc-c++
1) Install Git
yum install -y git查看版本:[root@fabric-test2 server]# git --versiongit version 1.8.3.1
2) Nodejs Installation
a.下载wget https://nodejs.org/dist/v8.11.4/node-v8.11.4-linux-x64.tar.xzb.解压tar -xvf node-v8.11.4-linux-x64.tar.xz c.链接ln -s /server/node-v8.11.4-linux-x64/bin/node /usr/local/bin/node ln -s /server/node-v8.11.4-linux-x64/bin/npm /usr/local/bin/npmd.测试[root@fabric-test2 node-v8.11.4-linux-x64]# node -vv8.11.4[root@fabric-test2 node-v8.11.4-linux-x64]# npm -v5.6.0
3) PostgreSQL Installation
1. Add rpm Yum Install https://download.postgresql.org/pub/repos/yum/9.5/redhat/rhel-7-x86_64/ PGDG-CENTOS95-9.5-2.NOARCH.RPM2. Installing PostgreSQL 9.5 yum Install Postgresql95-server postgresql95-contrib3. Initializing the database/usr/p Gsql-9.5/bin/postgresql95-setup INITDB4. Set power on from startup Systemctl enable Postgresql-9.5.service5. Start Service Systemctl start Postgr Esql-9.5.servicepostgresql installation is completed, will establish a ' postgres ' user, for the implementation of PostgreSQL, the database will also establish a ' postgres ' user, the default password is automatically generated, need to change in the system. 6. Change user password su-postgres switch user, after execution prompt will change to '-bash-4.2$ ' psql-u postgres login database, execute after prompt change to ' postgres=# ' ALTER user Postg Res with PASSWORD ' postgres '; Set Postgres user password (!!!) Note that this password should not contain the @ symbol) \q Exit database 7. Turn on remote access vi/var/lib/pgsql/9.5/data/postgresql.conf modify #listen_addresses = ' localhost ' For listen_addresses= ' * ' Of course, here ' * ' can also be changed to any server IP8 you want to open. Trust remote Connection vi/var/lib/pgsql/9.5/data/pg_hba.conf modify the following to trust the specified server connection # IPV4 Local Connections:host All 127.0.0.1/32 MD5 add host all AL L 0.0.0.0/0 Md59. Restarting the PostgreSQL data service
4) Installation of JQ
jq的安装需要epel源wget http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpmrpm -ivh epel-release-latest-7.noarch.rpmyum repolist 安装:yum install jq -y
5) Install gcc-c++
yum install -y gcc-c++编译使用
The dependent environment is ready, followed by the installation;
2. Initialize Configuration
1) Source code download
git clone https://github.com/hyperledger/blockchain-explorer.gitcd blockchain-explorer
2) Database initialization
创建一个用户:cd blockchain-explorer/app/persistence/postgreSQL修改执行模式chmod -R 775 db/修改pgconfig.json 文件cd dbvi pgconfig.json 如下:{ "pg": { "host": "127.0.0.1", "port": "5432", "database": "fabricexplorer", "username": "postgres", "passwd": "postgres" }}其实这里配置后还是需要输入密码,不过这个配置后续有用;执行脚本:[root@fabric-test2 db]# ./createdb.sh 输入数据库密码就好;
3) Fabric Network setup
This was preceded by a tutorial, no longer introduced;
4) Fabric Network configuration
Start with the previous configuration backup CP Blockchain-explorer/app/platform/fabric/config.json blockchain-explorer/app/platform/fabric/ CONFIG.JSON.BK configuration (based on the previous fabric distributed deployment example) The VI Blockchain-explorer/app/platform/fabric/config.json is configured as follows: {" Network-config ": {" Org1 ": {" name ":" Orgcorecompanymsp "," Mspid ":" Orgcorecompanymsp "," Peer1 ": { "Requests": "grpcs://10.0.200.114:7051", "Events": "grpcs://10.0.200.114:7053", "Server-hostname": "Peer0." Corecompany.lychee.com "," Tls_cacerts ":"/opt/gopath/src/github.com/hyperledger/fabric/lychees/bscf/crypto -config/peerorganizations/corecompany.lychee.com/peers/peer0.corecompany.lychee.com/tls/ca.crt "}," admin ": { "Key": "/opt/gopath/src/github.com/hyperledger/fabric/lychees/bscf/crypto-config/peerorganizations/corecompa Ny.lychee.com/users/admin@corecompany.lychee.com/msp/keystore "," cert ":"/opt/gopath/src/github.com/hyperl Edger/fabric/lychees/bscf/crypto-config/peerorganizations/corecoMpany.lychee.com/users/admin@corecompany.lychee.com/msp/signcerts "}}," Channel ":" Bscfchannel "," Orderer S ": [{" Mspid ":" Orderermsp "," Server-hostname ":" Orderer1.lychee.com "," Requests ":" grpcs://10.0.200.1 11:7050 "," Tls_cacerts ":"/opt/gopath/src/github.com/hyperledger/fabric/lychees/bscf/crypto-config/ordererorga Nizations/lychee.com/orderers/orderer1.lychee.com/tls/ca.crt "}]," Keyvaluestore ":"/tmp/fabric-client-kvs "," conf Igtxgentoolpath ":"/opt/gopath/src/github.com/hyperledger/fabric/release/linux-amd64/bin/"," SYNC_START_DATE_ FORMAT ":" Yyyy/mm/dd "," syncstartdate ":" 2018/01/01 "," Eventwaittime ":" 30000 "," License ":" Apache-2.0 "," Version ":" 1 .1 "} Here to note: 1, ORG1 can be arbitrarily named, not related to the fabric network, 2, you can add a node to do the test, and so on after the successful configuration of all; 3, the name in Org, Mspid such as the necessary root network configuration (Fabric network Configtx.yaml file), 4, note the IP address and grpcs/grpc;5, note the certificate file path, 6, Keyvaluestore This is the client's storage location, You can temporarily configure a location.
3. Package Deployment
This familiar with the previous development will be more smooth, but do Java backend and Golang small partners may need to toss down; (in fact, a project packaging, download dependencies, deployment process)
cd blockchain-explorernpm installcd client/npm installnpm run build如果遇到 root没权限,则需要使用非安全模式,顺便输出下详细日志如下:cd blockchain-explorernpm install --unsafe-perm -dcd client/npm install --unsafe-perm -dnpm run build --unsafe-perm -d!!!注意,如果中间出错,重新安装时先要删除node_modules文件夹,client里的也需要;
4. Operation
cd blockchain-explorer./start.sh日志文件:logs/app app日志logs/console 运行日志logs/db db日志这几个文件里面的日志要结合看才能更好的解决问题;console成功日志:Property config.syncStartDate set to 2018/01/01Please open web browser to access :http://127.0.0.1:8080/pid is 9641Successfully received the block event[object Object]
5. Summary of issues
1. make: g++: Command not foundyum install -y gcc-c++2. getBlockActivity undefined 找不到这个是npm install问题,删除node_modules,重新安装3.TypeError: Cannot read property 'forEach' of undefined这个是fabric网络未配置好,重新检查下app/platform/fabric/config.json 网络配置4.server.on undefined 找不到这个是npm install问题,删除node_modules,重新安装5. TypeError: Cannot read property 'queryChannels' of undefined这个是fabric网络未配置好,重新检查下app/platform/fabric/config.json 网络配置
6, the effect is as follows:
Image.pngimage.pngimage.pngimage.png