### nodejs 下載nodejs二進制包: wget https://nodejs.org/dist/v12.16.2/node-v12.16.2-linux-x64.tar.xz 解壓xz數據包: xz -d node-v12.16.2-linux-x64.tar.xz 解壓tar數據包: tar -C /usr/local/ -xvf node-v12.16.2-linux-x64.tar 更改目錄名: mv node-v12.16.2-linux-x64 node 添加環境變量: export PATH=$PATH:/usr/local/node/bin 查看版本信息: node -v ### jq yum install epel-release yum install jq ### PostgreSQL # Install the repository RPM: yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm # 下載服務端: yum install -y postgresql12-server 初始化數據庫並設置開機自啟動: /usr/pgsql-12/bin/postgresql-12-setup initdb systemctl enable postgresql-12 啟動服務: systemctl start postgresql-12 驗證是否安裝成功: rpm -aq| grep postgres (正常返回版本信息即可) 修改用戶密碼:
su - postgres 切換用戶,執行后提示符會變為 '-bash-4.2$'
psql -U postgres 登錄數據庫,執行后提示符變為 'postgres=#'
ALTER USER postgres WITH PASSWORD 'postgres'; 設置postgres用戶密碼為postgres
\c databasename 進入數據庫
\d 查看表
\d tablename 查看具體表結構
\q 退出數據庫
exit 退出命令行界面
開啟遠程訪問: vi /var/lib/pgsql/12/data/postgresql.conf 修改#listen_addresses = 'localhost' 為 listen_addresses='*' 當然,此處‘*’也可以改為任何你想開放的服務器IP 信任遠程連接: vi /var/lib/pgsql/12/data/pg_hba.conf 修改如下內容,信任指定服務器連接 # IPv4 local connections: host all all 127.0.0.1/32 trust host all all 0.0.0.0/0 trust 重啟服務: systemctl restart postgresql-12 ### Explorer 下載 cd /opt/gopath/src/github.com/hyperledger git clone https://github.com/hyperledger/blockchain-explorer.git 我們使用默認版本,進行數據庫創建: cd blockchain-explorer/app vi explorerconfig.json 修改配置如下: "postgreSQL": { "host": "127.0.0.1", "port": "5432", "database": "fabricexplorer", "username": "postgres", "passwd": "postgres" } 運行創建數據庫的腳本: cd persistence/fabric/postgreSQL chmod -R 775 db/ cd db ./createdb.sh 查看數據庫狀態指令: sudo -u postgres psql -c '\l' sudo -u postgres psql fabricexplorer -c '\d' # 定義fabric網絡連接參數 cd /opt/gopath/src/github.com/hyperledger/blockchain-explorer/app/platform/fabric/config.json # 設置enableAuthentication屬性false,用於關閉登錄認證 { "network-configs": { "first-network": { "name": "firstnetwork", "profile": "./connection-profile/first-network.json", "enableAuthentication": false } }, "license": "Apache-2.0" } # 繼續進行設置(Fabric網絡環境要處於正常啟動的狀態,不然下述路徑的文件是不存在的) cd /opt/gopath/src/github.com/hyperledger/blockchainexplorer/app/platform/fabric/connection-profile/first-network.json 重點設置如下幾項: "adminPrivateKey": { "path": "/opt/gopath/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/keystore/priv_sk" } -------------------------------------分隔符(下同)----------------------------------------- "signedCert": { "path": "/opt/gopath/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/signcerts/Admin@org1.example.com-cert.pem" } ========================================================================================= "tlsCACerts": { "path": "/opt/gopath/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt" } ----------------------------------------------------------------------------------------- "tlsCACerts": { "path": "/opt/gopath/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/peerOrganizations/org1.example.com/ca/ca.org1.example.com-cert.pem" } ### 需要說明一點,這兩個 "tlsCACerts" 並不在一個字典中,配置時要特別注意,還有就是以自己的文件路徑為主。 # Build Hyperledger Explorer cd /opt/gopath/src/github.com/hyperledger/blockchain-explorer npm install cd /opt/gopath/src/github.com/hyperledger/blockchain-explorer/client npm install npm run build 如果遇到 root沒權限,則需要使用非安全模式,順便輸出下詳細日志如下: cd /opt/gopath/src/github.com/hyperledger/blockchain-explorer npm install --unsafe-perm -d cd client/ npm install --unsafe-perm -d npm run build --unsafe-perm -d !!!注意,如果中間出錯,重新安裝時先要刪除node_modules文件夾,client里的也需要; # 報錯提示信息(在執行 npm run build --unsafe-perm -d 后出現的error信息) ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory # 錯誤原因 react環境搭建時,在 Node 中通過 JavaScript 使用內存時只能使用部分內存(64位系統下約為1.4 GB,32位系統下約為0.7 GB),而我的虛擬機環境初始化內存為1G,導致JavaScript內存溢出 # 解決方案 查詢過很多網上的文檔,建議都是添加指定內存大小的參數,反復嘗試多次后無果,最后修改虛擬機內存設置為3G后,重新執行打包指令,成功(大家可以嘗試下2G)。 運行 cd /opt/gopath/src/github.com/hyperledger/blockchain-explorer ./start.sh ./stop.sh 停止 瀏覽器中輸入當前IP地址,端口號為 8080 官方文檔: https://github.com/hyperledger/blockchain-explorer/tree/v1.1.2
當然,每個人安裝過程中遇到的問題不同,解決方法也因人而異,請大家辯證的對待。