Fabric explorer 最新搭建教程


準備

  1. 確定搭建的Fabric網絡版本
  2. clone對應的瀏覽的版本

比如,1.4版本的Faric網絡,就可以clone 1.0版本的Fabric explore

  1. 確定node版本。如果版本不對,會出現(xiàn)許多未知錯誤。具體可參照官方github
  2. 安裝 postgresql
    sudo apt-get install postgresql
  3. 安裝 jq
    sudo apt-get install jq
  4. 安裝 docker

開始搭建

  1. git clone https://github.com/hyperledger/blockchain-explorer.git
  2. cd blockchain-explorer
  3. 主要用到v1.0.0-rc2版本的瀏覽器以下幾個配置文件:
  • appconfig.json
    用于設置瀏覽器的IP和端口
  • exploreconfig.json
    用于設置數(shù)據庫的相關信息
  • first-network.json
    用于設置證書相關信息
  • config.json
    config.json目前不需要過多關注,他內部引用的是first-network.json文件。
  1. 設置first-network
    (1) 把搭建Fabric網絡時生成的crypto-config復制到blockchain-explorer目錄下任意位置。
    (2) 替換organizationspeers下的證書位置,最好使用全路徑。使用全路徑時,需要把fullpath設為true.
    我的配置:
{
    "name": "aberic",
    "version": "1.0.0",
    "license": "Apache-2.0",
    "client": {
        "tlsEnable": true,
        "adminUser": "admin",
        "adminPassword": "adminpw",
        "enableAuthentication": false,
        "organization": "Org1",
        "connection": {
            "timeout": {
                "peer": {
                    "endorser": "300"
                },
                "orderer": "300"
            }
        }
    },
    "channels": {
        "mychannel": {
            "peers": {
                "peer0.org1.example.com": {}
            },
            "connection": {
                "timeout": {
                    "peer": {
                        "endorser": "6000",
                        "eventHub": "6000",
                        "eventReg": "6000"
                    }
                }
            }
        }
    },
    "organizations": {
        "Org1MSP": {
            "mspid": "Org1MSP",
            "fullpath": true,
            "adminPrivateKey": {
                "path": "XXX/blockchain-explorer/app/platform/fabric/fixtures/crypto-config/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/keystore/0f7cc385f61b26515396a756b91ea2de980081dca57bcc375a33a5138979163c_sk"
            },
            "signedCert": {
                "path": "XXX/blockchain-explorer/app/platform/fabric/fixtures/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": {
                "path": "XXX/blockchain-explorer/app/platform/fabric/fixtures/crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt"
            },
            "url": "grpcs://XXX",
            "eventUrl": "grpcs://XXX",
            "grpcOptions": {
                "ssl-target-name-override": "peer0.org1.example.com"
            }
        }
    }
}
  1. 設置 exploreconfig.json
    這個配置可以使用默認配置。
  2. 初始化數(shù)據庫表
    (1) cd blockchain-explorer/app/persistence/fabric/postgreSQL/db
    (2) ./createdb.sh
    可能報錯:
Copying ENV variables into temp file...
module.js:549
    throw err;
    ^

Error: Cannot find module '/root/blockchain-explorer/app/persistence/fabric/postgreSQL/db/processenv.js'
    at Function.Module._resolveFilename (module.js:547:15)
    at Function.Module._load (module.js:474:25)
    at Function.Module.runMain (module.js:693:10)
    at startup (bootstrap_node.js:191:16)
    at bootstrap_node.js:612:3
USER="hppoc"
DATABASE="fabricexplorer"
PASSWD='password'
rm: remove write-protected regular file '/tmp/process.env.json'? n
Executing SQL scripts, OS=linux-gnu
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
        LANGUAGE = (unset),
        LC_ALL = (unset),
        LC_CTYPE = "UTF-8",
        LC_TERMINAL = "iTerm2",
        LC_TERMINAL_VERSION = "3.3.7",
        LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to a fallback locale ("en_US.UTF-8").
could not change directory to "/root/blockchain-explorer/app/persistence/fabric/postgreSQL/db": Permission denied
./explorerpg.sql: No such file or directory
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
        LANGUAGE = (unset),
        LC_ALL = (unset),
        LC_CTYPE = "UTF-8",
        LC_TERMINAL = "iTerm2",
        LC_TERMINAL_VERSION = "3.3.7",
        LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to a fallback locale ("en_US.UTF-8").
could not change directory to "/root/blockchain-explorer/app/persistence/fabric/postgreSQL/db": Permission denied
./updatepg.sql: No such file or directory

解決方法:

  • perl warining: export LC_ALL=en_US.UTF-8
  • Permission denied:
    createdb.sh會創(chuàng)建一個postgres的用戶,并以這個用戶初始化數(shù)據庫表。如果你的當前用戶不允許其他用戶訪問其下的數(shù)據,就會報這種錯誤。
    比如:我當前用戶root,到根目錄下查看當前用戶權限cd \ && ll.
drwx------  18 root root 4.0K Dec 18 07:57 root

用戶權限是700,不允許同組和其他用戶訪問。
當我執(zhí)行./createdb.sh時,在腳本內以用戶postgres對root下的文件執(zhí)行一些操作時,就會報錯。
這個問題解決方法很多。

我的解決方法是:把blockchain-explorer項目移到根目錄下。

再次執(zhí)行./createdb.sh
當你看到以下句子時,說明你成功了。

You are now connected to database XXX as user XXX.

  1. 運行主目錄下的 ./start.sh
    可能會出現(xiàn)以下錯誤:
  • FATAL: password authentication failed for user "
    logs/console/下的日志文件也會出現(xiàn)postgres無法連接的錯誤。
    解決方法
    修改pg_hba.conf配置文件,將第4個字段改為trust
# Database administrative login by Unix domain socket
local   all             postgres                                peer

為了避免麻煩,我將所有行的第4個字段都改成了 trust
最后執(zhí)行sudo /etc/init.d/postgresql reload,重新加載配置文件。

  • saveTransaction false 錯誤
    這個可能是與數(shù)據庫原來內容沖突,將數(shù)據庫清空,重新啟動瀏覽器,不啟動應該也可以,瀏覽器會主動更新;
    重新啟動前,要用./stop.sh關閉瀏覽器后臺進程
最后編輯于
?著作權歸作者所有,轉載或內容合作請聯(lián)系作者
【社區(qū)內容提示】社區(qū)部分內容疑似由AI輔助生成,瀏覽時請結合常識與多方信息審慎甄別。
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發(fā)布,文章內容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

友情鏈接更多精彩內容