kuberneteshyperledgerhyperledger-explorer

Hyperledger Explorer not syncing HLF-fabric transaction


I have created the Kubernetes cluster.

Configuration : 4 CPU X 16 GB Memory

On the above Kubernetes cluster, I deployed a hyperledger blockchain network with Hyperledger Explorer (as pod). The Blockchain network is working fine. Hyperledger Explorer is also working but only for a few hours after that it gets stop, neither showing error nor warning, and the pod is also in "running" status. But is not synching blockchain transaction data.

I created two pods, one for explorer and one for explorer-DB. I checked logs of the explorer-db pod and get below lines

2021-12-24 17:12:58.232 UTC [31] LOG: aborting any active transactions 2021-12-24 17:12:58.269 UTC [31] LOG: worker process: logical replication launcher (PID 38) exited with exit code 1 2021-12-24 17:12:58.289 UTC [33] LOG: shutting down 2021-12-24 17:12:58.490 UTC [31] LOG: database system is shut down done server stopped PostgreSQL init process complete; ready for start up. 2021-12-24 17:12:58.691 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432 2021-12-24 17:12:58.691 UTC [1] LOG: listening on IPv6 address "::", port 5432 2021-12-24 17:12:58.709 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432" 2021-12-24 17:12:58.989 UTC [65] LOG: database system was shut down at 2021-12-24 17:12:58 UTC 2021-12-24 17:12:59.089 UTC [1] LOG: database system is ready to accept connections


Solution

  • I figured out the solution for the above problem with the Kubernetes sidecar pattern. So whenever my main container restart due to some memory issue its sidecar container also restarts automatically.

      containers:
        - name: peer
          image: hyperledger/fabric-peer:2.3
          imagePullPolicy: "Always"
          command: ["sh", "-c", "peer node start"]
          env:
            - name: CORE_PEER_ADDRESSAUTODETECT
              value: "true"
            - name: CORE_PEER_ID
              value: peer0-org1
            - name: CORE_PEER_ADDRESS
              value: peer0-org1:7051
            - name: CORE_PEER_LISTENADDRESS
              value: 0.0.0.0:7051
            - name: CORE_PEER_EVENTS_ADDRESS
              value: 0.0.0.0:7061
            - name: CORE_PEER_GOSSIP_BOOTSTRAP
              value: peer0-org1:7051
            - name: CORE_PEER_GOSSIP_USELEADERELECTION
              value: "true"
            - name: CORE_PEER_PROFILE_ENABLED
              value: "true"
            - name: CORE_PEER_LOCALMSPID
              value: Org1MSP
            - name: CORE_PEER_MSPCONFIGPATH
              value: /organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/msp
            - name: FABRIC_LOGGING_SPEC
              value: debug
            - name: CORE_PEER_TLS_ENABLED
              value: "true"
            - name: CORE_PEER_TLS_CERT_FILE
              value: /organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.crt
            - name: CORE_PEER_TLS_KEY_FILE
              value: /organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.key
            - name: CORE_PEER_TLS_ROOTCERT_FILE
              value: /organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt
            - name: CORE_LEDGER_STATE_STATEDATABASE
              value: "CouchDB"
            - name: CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS
              value: "localhost:5984"
            - name: FABRIC_CFG_PATH
              value: /etc/hyperledger/fabric
            - name: CORE_OPERATIONS_LISTENADDRESS
              value: 0.0.0.0:9443
            - name: CORE_METRICS_PROVIDER
              value: prometheus
          ports:    
            - containerPort: 7051
            - containerPort: 7052
            - containerPort: 7053
            - containerPort: 9443
          resources:
            limits:
              memory: "450Mi"
              cpu: "300m"
            requests:
              memory: "150Mi"
              cpu: "100m"
          volumeMounts:
            - mountPath: /opt/gopath/src/github.com/chaincode/
              name: fabricfiles
              subPath: chaincode/
            - mountPath: /organizations
              name: fabricfiles
              subPath: organizations
            - mountPath: /var/hyperledger/production
              name: fabricfiles
              subPath: state/org1/peer0
            - mountPath: /etc/hyperledger/fabric/core.yaml
              name: builders-config
              subPath: core.yaml
            - mountPath: /builders/external/bin/detect
              name: external-builder-detect
              subPath: detect
            - mountPath: /builders/external/bin/build
              name: external-builder-build
              subPath: build
            - mountPath: /builders/external/bin/release
              name: external-builder-release
              subPath: release
    
        - name: couchdb
          image: hyperledger/fabric-couchdb:0.4.15
          resources:
            limits:
              memory: "450Mi"
              cpu: "400m"
          volumeMounts:
            - mountPath: /var/lib/couchdb
              name: fabricfiles
              subPath: state/org1/peer0-couchdb
    
        - name: explorer
          image: hyperledger/explorer:1.1.8
    
          # startupProbe:
          #     failureThreshold: 30
          #     periodSeconds: 30
          env:
            - name: DATABASE_HOST
              value: "explorerdb-service"
            - name: DATABASE_DATABASE
              value: "fabricexplorer"
            - name: DATABASE_USERNAME
              value: "hppoc"
            - name: DATABASE_PASSWD
              value: "password"
            - name: LOG_LEVEL_APP
              value: "warn"
            - name: LOG_LEVEL_DB
              value: "debug"
            - name: LOG_LEVEL_CONSOLE
              value: "warn"
            - name: LOG_CONSOLE_STDOUT
              value: "true"
            - name: DISCOVERY_AS_LOCALHOST
              value: "false"
            - name: NODE_TLS_REJECT_UNAUTHORIZED  
              value: "0"
          resources:
            limits:
              memory: "300Mi"
              cpu: "300m"
          ports:
            - containerPort: 8080
         # command:  ["sh","-c","/opt/explorer/syncstart.sh"]
          volumeMounts:
            - mountPath: /organizations
              name: fabricfiles
              subPath: organizations
            - mountPath: /opt/explorer/app/platform/fabric/config.json
              name: explorer-config
              subPath: config.json  
            - mountPath: /opt/explorer/app/platform/fabric/first-network.json
              name: explorer-config
              subPath: network.json