5 啟動設定執行處理

本節描述如何使用區塊鏈平台管理程式佈建 Oracle Blockchain Platform 執行處理。

建立 Oracle Blockchain Platform 執行處理之前

在您佈建 Oracle Blockchain Platform 之前,請先決定開發人員或企業執行個體是否符合您的需求。

決定要使用的佈建資源配置

佈建執行處理時,您可以選擇兩個組態。目前不支援在這些選項之間移轉。

組態 功能
開發人員

此入門資源配置建議用於開發和評估。

  • 1 個 Fabric-CA 節點
  • 3 節點 Fabric Ordering Service Network
  • 執行處理描述資料的一節點儲存區域
  • 動態管理的鏈碼執行容器
  • 作業 Web 使用者介面的主控台服務
  • RESTful API 的 REST 代理主機服務
  • 用於認證和角色管理的 LDAP 伺服器整合
企業

高度可用的執行處理組態,每個服務都有較高的複本數目。

  • 3 個 Fabric-CA 節點
  • 3 節點 Fabric Ordering Service Network
  • 3 節點叢集儲存區域,提供執行處理描述資料高可用性
  • 動態管理的鏈碼執行容器
  • 作業 Web 使用者介面的主控台服務
  • RESTful API 的 REST 代理主機服務有多個複本
  • 用於認證和角色管理的 LDAP 伺服器整合

使用區塊鏈平台管理程式佈建執行處理

若要在 Blockchain Platform Manager 中建立區塊鏈創辦人或參與者執行處理,請使用「建立新執行處理」精靈。

您可以佈建兩種類型的 Oracle Blockchain Platform 執行處理:
  • 創辦人組織:一個完整的區塊鏈環境,包括參與者日後可以加入的新網路。

  • 參與者執行處理:如果已經有想要加入的建立者組織,如果您的證明資料可讓您存取網路,就可以建立參與者執行處理。請注意,參與者無法自行運作。

  1. 區塊鏈平台管理程式中,開啟執行處理頁面。
  2. 選取建立執行處理
  3. 完成下列欄位的輸入:
    欄位 描述
    執行處理名稱

    輸入 Oracle Blockchain Platform 執行處理的名稱。

    服務執行處理名稱:

    • 必須包含一或多個字元。
    • 不可超過 15 個字元。
    • 開頭必須是 ASCII 字母:az
    • 只能包含 ASCII 字母或數字。
    • 不得包含連字號。
    • 不得包含任何其他特殊字元。
    • 在識別網域中必須是唯一的。
    描述

    (選擇性)

    輸入 Oracle Blockchain Platform 執行處理的簡短描述。

    網域名稱

    輸入叢集的網域名稱。

    為區塊鏈執行處理服務產生的主機名稱會分別使用網域名稱和執行處理名稱作為父項網域和子網域。

    Role

    選取建立者以建立完整的區塊鏈環境。此例項會成為創始組織,您可以稍後在網路中加入新的參與者。

    選取參與者即可建立一個執行處理,此執行處理將加入在其他地方建立的現有區塊鏈網路,才能使用此執行處理。

    組態
    選取符合您部署需求的佈建資源配置:
    • 開發人員
    • 企業
    對等

    指定最初在此服務執行處理中建立的對等節點數目。您可以稍後在 Oracle Blockchain Platform 主控台中建立其他對等節點。

  4. 按一下建立執行處理

佈建先決條件

在存取 Oracle Blockchain Platform 服務主控台之前,請設定區塊鏈執行處理服務的主機名稱解析,類似您先前為 Blockchain Platform Manager 主機名稱所做的設定。使用下列命令取得所建立區塊鏈執行處理的主機名稱清單:
kubectl get virtualservice -n <instance-namespace> -o json | jq -r
      .items[].spec.hosts[0]
存取 Oracle Blockchain Platform 服務主控台之前,請先為區塊鏈執行處理服務設定主機名稱解析,與先前為區塊鏈平台管理程式主機名稱所做的類似。使用下列命令取得所建立區塊鏈執行處理的主機名稱清單:
kubectl get virtualservice -n <instance-namespace> -o json | jq -r
      .items[].spec.hosts[0]

建立 Oracle Blockchain Platform Enterprise Edition 執行處理之後,您必須設定 DNS,才能從 OpenShift 本機網路解析元件的公用主機名稱。

建立執行處理之後,執行處理名稱和父項網域會作為 Oracle Blockchain Platform Enterprise Edition 元件的子網域。您必須在 OpenShift 的預設 DNS 組態上設定 DNS 轉送,以便將 DNS 要求轉送至已解析公開服務的自訂 DNS Pod。完成下列步驟以設定 DNS 轉送。
  1. 執行下列命令。
    oc new-project obp-coredns
  2. 執行下列命令,在 obp-coredns 命名空間中部署自訂 coredns 伺服器。
    kubectl apply -f <coredns-deployment-yaml-file>
    以指令使用下列清單檔案。
    apiVersion: v1
    kind: ConfigMap
    metadata:
      name: coredns
      namespace: obp-coredns
    data:
      Corefile: |-
        .:1053 {
          errors
          health {
            lameduck 5s
          }
          ready
          kubernetes cluster.local in-addr.arpa ip6.arpa {
            pods insecure
            fallthrough in-addr.arpa ip6.arpa
          }
          prometheus :9153
          forward . /etc/resolv.conf
          cache 30
          loop
          reload
          loadbalance
        }
        import custom/*.server
     
    ---
    apiVersion: apps/v1
    kind: Deployment
    metadata:
      labels:
        app: obp-coredns
      name: obp-coredns
      namespace: obp-coredns
    spec:
      progressDeadlineSeconds: 600
      replicas: 1
      revisionHistoryLimit: 10
      selector:
        matchLabels:
          app: obp-coredns
      strategy:
        type: RollingUpdate
      template:
        metadata:
          labels:
            app: obp-coredns
        spec:
          containers:
          - args:
            - -conf
            - /etc/coredns/Corefile
            image: docker.io/coredns/coredns:latest
            imagePullPolicy: IfNotPresent
            livenessProbe:
              failureThreshold: 5
              httpGet:
                path: /health
                port: 8080
                scheme: HTTP
              initialDelaySeconds: 60
              periodSeconds: 10
              successThreshold: 1
              timeoutSeconds: 5
            name: coredns
            ports:
            - containerPort: 1053
              name: dns
              protocol: UDP
            - containerPort: 1053
              name: dns-tcp
              protocol: TCP
            - containerPort: 9153
              name: metrics
              protocol: TCP
            readinessProbe:
              failureThreshold: 3
              httpGet:
                path: /ready
                port: 8181
                scheme: HTTP
              periodSeconds: 10
              successThreshold: 1
              timeoutSeconds: 1
            resources:
              limits:
                memory: 170Mi
              requests:
                cpu: 100m
                memory: 70Mi
            securityContext:
              allowPrivilegeEscalation: false
              capabilities:
                add:
                - NET_BIND_SERVICE
                drop:
                - all
              readOnlyRootFilesystem: true
            terminationMessagePath: /dev/termination-log
            terminationMessagePolicy: File
            volumeMounts:
            - mountPath: /etc/coredns
              name: config-volume
              readOnly: true
            - mountPath: /etc/coredns/custom
              name: custom-config-volume
              readOnly: true
          dnsPolicy: Default
          restartPolicy: Always
          schedulerName: default-scheduler
          securityContext: {}
          serviceAccount: obp-coredns
          serviceAccountName: obp-coredns
          terminationGracePeriodSeconds: 30
          volumes:
          - configMap:
              defaultMode: 420
              items:
              - key: Corefile
                path: Corefile
              name: coredns
            name: config-volume
          - configMap:
              defaultMode: 420
              name: coredns-custom
              optional: true
            name: custom-config-volume
     
    ---
    apiVersion: v1
    kind: Service
    metadata:
      labels:
        app: obp-coredns
      name: obp-coredns
      namespace: obp-coredns
    spec:
      ports:
      - name: dns
        port: 53
        protocol: UDP
        targetPort: 1053
      - name: dns-tcp
        port: 53
        protocol: TCP
        targetPort: 1053
      - name: metrics
        port: 9153
        protocol: TCP
        targetPort: 9153
      selector:
        app: obp-coredns
      sessionAffinity: None
      type: ClusterIP
    ---
    apiVersion: v1
    kind: ServiceAccount
    metadata:
      name: obp-coredns
      namespace: obp-coredns
    ---
    apiVersion: rbac.authorization.k8s.io/v1
    kind: ClusterRole
    metadata:
      name: obp-coredns
    rules:
    - apiGroups:
      - ""
      resources:
      - endpoints
      - services
      - pods
      - namespaces
      verbs:
      - list
      - watch
    - apiGroups:
      - ""
      resources:
      - nodes
      verbs:
      - get
    - apiGroups:
      - discovery.k8s.io
      resources:
      - endpointslices
      verbs:
      - list
      - watch
    ---
    apiVersion: rbac.authorization.k8s.io/v1
    kind: ClusterRoleBinding
    metadata:
      name: obp-coredns
    roleRef:
      apiGroup: rbac.authorization.k8s.io
      kind: ClusterRole
      name: obp-coredns
    subjects:
    - kind: ServiceAccount
      name: obp-coredns
      namespace: obp-coredns
    
  3. 為您的區塊鏈執行處理建立 YAML 格式的 coredns-custom-configmap 檔案。
    apiVersion: v1
    kind: ConfigMap
    metadata:
      name: coredns-custom
      namespace: obp-coredns
    data:
      obp.server: |2
     
        <instanceName>.<domain>:1053 {
            log
            kubernetes cluster.local in-addr.arpa ip6.arpa {
                pods insecure
                fallthrough in-addr.arpa ip6.arpa
            }
            rewrite stop {
                name regex (.*)\.<instanceName>\.<domain>\.com istio-ingressgateway.istio-system.svc.cluster.local answer auto
            }
            forward . /etc/resolv.conf
        }
    
    在上一個範例中,<instanceName> 是執行處理的名稱,而 <domain> 是建立執行處理時所傳送的網域。
  4. 執行下列命令以套用自訂 ConfigMap 物件。
    kubectl apply -f <coredns-custom-configmap-yaml-file>
  5. 執行下列命令以取得叢集 IP 位址。記錄 IP 地址。
    kubectl get svc -n obp-coredns
  6. 執行下列命令以編輯 OpenShift DNS 自訂資源。
    kubectl edit dnses.operator/default
  7. 請更新 DNS 自訂資源的「區域」區段,以使用您的執行處理和網域名稱,如下列範例所示。
    ## Add the following section to the dns custom resource under spec
      servers:
      - forwardPlugin:
          policy: Random
          upstreams:
          - 192.0.2.233
        name: obp-server
        zones:
        - <instanceName>.<domain>
    在上一個範例中,<instanceName> 是執行處理的名稱,而 <domain> 是父項網域。
  8. 若要新增執行處理,請新增項目至 coredns-custom-configmap 檔案,然後更新新執行處理網域的 OpenShift DNS 自訂資源,如下列範例所示:
    apiVersion: v1
    kind: ConfigMap
    metadata:
      name: coredns-custom
      namespace: obp-coredns
    data:
      obp.server: |2
     
        myobp.example.com:1053 {
            log
            kubernetes cluster.local in-addr.arpa ip6.arpa {
                pods insecure
                fallthrough in-addr.arpa ip6.arpa
            }
            rewrite stop {
                name regex (.*)\.myobp\.example\.com istio-ingressgateway.istio-system.svc.cluster.local answer auto
            }
            forward . /etc/resolv.conf
        }
     
        otherobp.example.org:1053 {
            log
            kubernetes cluster.local in-addr.arpa ip6.arpa {
                pods insecure
                fallthrough in-addr.arpa ip6.arpa
            }
            rewrite stop {
                name regex (.*)\.otherobp\.example\.org istio-ingressgateway.istio-system.svc.cluster.local answer auto
            }
            forward . /etc/resolv.conf
        }
    
    
    
    ## Edit the Openshift's DNS custom resource
    kubectl edit dnses.operator/default
     
    ## Add the new instance domain to the existing .spec.servers.zones
      servers:
      - forwardPlugin:
          policy: Random
          upstreams:
          - 192.0.2.233
        name: obp-server
        zones:
        - myobp.example.com
        - otherobp.example.org
    您必須使用區塊鏈平台管理程式停止並重新啟動區塊鏈平台執行處理,讓 DNS 變更生效。

設定 DNS

建立 Oracle Blockchain Platform Enterprise Edition 執行處理之後,您必須設定 DNS,才能從 OpenShift 本機網路解析元件的公用主機名稱。

建立執行處理之後,執行處理名稱和父項網域會作為 Oracle Blockchain Platform Enterprise Edition 元件的子網域。您必須在 OpenShift 的預設 DNS 組態上設定 DNS 轉送,以便將 DNS 要求轉送至已解析公開服務的自訂 DNS Pod。完成下列步驟以設定 DNS 轉送。
  1. 執行下列命令。
    oc new-project obp-coredns
  2. 執行下列命令,在 obp-coredns 命名空間中部署自訂 coredns 伺服器。
    kubectl apply -f <coredns-deployment-yaml-file>
    以指令使用下列清單檔案。
    apiVersion: v1
    kind: ConfigMap
    metadata:
      name: coredns
      namespace: obp-coredns
    data:
      Corefile: |-
        .:1053 {
          errors
          health {
            lameduck 5s
          }
          ready
          kubernetes cluster.local in-addr.arpa ip6.arpa {
            pods insecure
            fallthrough in-addr.arpa ip6.arpa
          }
          prometheus :9153
          forward . /etc/resolv.conf
          cache 30
          loop
          reload
          loadbalance
        }
        import custom/*.server
     
    ---
    apiVersion: apps/v1
    kind: Deployment
    metadata:
      labels:
        app: obp-coredns
      name: obp-coredns
      namespace: obp-coredns
    spec:
      progressDeadlineSeconds: 600
      replicas: 1
      revisionHistoryLimit: 10
      selector:
        matchLabels:
          app: obp-coredns
      strategy:
        type: RollingUpdate
      template:
        metadata:
          labels:
            app: obp-coredns
        spec:
          containers:
          - args:
            - -conf
            - /etc/coredns/Corefile
            image: docker.io/coredns/coredns:latest
            imagePullPolicy: IfNotPresent
            livenessProbe:
              failureThreshold: 5
              httpGet:
                path: /health
                port: 8080
                scheme: HTTP
              initialDelaySeconds: 60
              periodSeconds: 10
              successThreshold: 1
              timeoutSeconds: 5
            name: coredns
            ports:
            - containerPort: 1053
              name: dns
              protocol: UDP
            - containerPort: 1053
              name: dns-tcp
              protocol: TCP
            - containerPort: 9153
              name: metrics
              protocol: TCP
            readinessProbe:
              failureThreshold: 3
              httpGet:
                path: /ready
                port: 8181
                scheme: HTTP
              periodSeconds: 10
              successThreshold: 1
              timeoutSeconds: 1
            resources:
              limits:
                memory: 170Mi
              requests:
                cpu: 100m
                memory: 70Mi
            securityContext:
              allowPrivilegeEscalation: false
              capabilities:
                add:
                - NET_BIND_SERVICE
                drop:
                - all
              readOnlyRootFilesystem: true
            terminationMessagePath: /dev/termination-log
            terminationMessagePolicy: File
            volumeMounts:
            - mountPath: /etc/coredns
              name: config-volume
              readOnly: true
            - mountPath: /etc/coredns/custom
              name: custom-config-volume
              readOnly: true
          dnsPolicy: Default
          restartPolicy: Always
          schedulerName: default-scheduler
          securityContext: {}
          serviceAccount: obp-coredns
          serviceAccountName: obp-coredns
          terminationGracePeriodSeconds: 30
          volumes:
          - configMap:
              defaultMode: 420
              items:
              - key: Corefile
                path: Corefile
              name: coredns
            name: config-volume
          - configMap:
              defaultMode: 420
              name: coredns-custom
              optional: true
            name: custom-config-volume
     
    ---
    apiVersion: v1
    kind: Service
    metadata:
      labels:
        app: obp-coredns
      name: obp-coredns
      namespace: obp-coredns
    spec:
      ports:
      - name: dns
        port: 53
        protocol: UDP
        targetPort: 1053
      - name: dns-tcp
        port: 53
        protocol: TCP
        targetPort: 1053  
      - name: metrics
        port: 9153
        protocol: TCP
        targetPort: 9153
      selector:
        app: obp-coredns
      sessionAffinity: None
      type: ClusterIP
    ---
    apiVersion: v1
    kind: ServiceAccount
    metadata:
      name: obp-coredns
      namespace: obp-coredns
    ---
    apiVersion: rbac.authorization.k8s.io/v1
    kind: ClusterRole
    metadata:
      name: obp-coredns
    rules:
    - apiGroups:
      - ""
      resources:
      - endpoints
      - services
      - pods
      - namespaces
      verbs:
      - list
      - watch
    - apiGroups:
      - ""
      resources:
      - nodes
      verbs:
      - get
    - apiGroups:
      - discovery.k8s.io
      resources:
      - endpointslices
      verbs:
      - list
      - watch
    ---
    apiVersion: rbac.authorization.k8s.io/v1
    kind: ClusterRoleBinding
    metadata:
      name: obp-coredns
    roleRef:
      apiGroup: rbac.authorization.k8s.io
      kind: ClusterRole
      name: obp-coredns
    subjects:
    - kind: ServiceAccount
      name: obp-coredns
      namespace: obp-coredns
    
  3. 為您的區塊鏈執行處理建立 YAML 格式的 coredns-custom-configmap 檔案。
    apiVersion: v1
    kind: ConfigMap
    metadata:
      name: coredns-custom
      namespace: obp-coredns
    data:
      obp.server: |2
     
        <instanceName>.<domain>:1053 {
            log
            kubernetes cluster.local in-addr.arpa ip6.arpa {
                pods insecure
                fallthrough in-addr.arpa ip6.arpa
            }
            rewrite stop {
                name regex (.*)\.<instanceName>\.<domain>\ istio-ingressgateway.istio-system.svc.cluster.local answer auto
            }
            forward . /etc/resolv.conf
        }
    
    在上一個範例中,<instanceName> 是執行處理的名稱,而 <domain> 是父項網域。
  4. 執行下列命令以套用自訂 ConfigMap 物件。
    kubectl apply -f <coredns-custom-configmap-yaml-file>
  5. 執行下列命令以取得叢集 IP 位址。記錄 IP 地址。
    kubectl get svc -n obp-coredns
  6. 執行下列命令以編輯 OpenShift DNS 自訂資源。
    kubectl edit dnses.operator/default
  7. 請更新 DNS 自訂資源的「區域」區段,以使用您的執行處理和網域名稱,如下列範例所示。
    ## Add the following section to the dns custom resource under spec
      servers:
      - forwardPlugin:
          policy: Random
          upstreams:
          - 192.0.2.233
        name: obp-server
        zones:
        - <instanceName>.<domain>
    在上一個範例中,<instanceName> 是執行處理的名稱,而 <domain> 是父項網域。
  8. 若要新增執行處理,請新增項目至 coredns-custom-configmap 檔案,然後更新新執行處理網域的 OpenShift DNS 自訂資源,如下列範例所示。
    apiVersion: v1
    kind: ConfigMap
    metadata:
      name: coredns-custom
      namespace: obp-coredns
    data:
      obp.server: |2
     
        myobp.example.com:1053 {
            log
            kubernetes cluster.local in-addr.arpa ip6.arpa {
                pods insecure
                fallthrough in-addr.arpa ip6.arpa
            }
            rewrite stop {
                name regex (.*)\.myobp\.example\.com istio-ingressgateway.istio-system.svc.cluster.local answer auto
            }
            forward . /etc/resolv.conf
        }
     
        otherobp.example.org:1053 {
            log
            kubernetes cluster.local in-addr.arpa ip6.arpa {
                pods insecure
                fallthrough in-addr.arpa ip6.arpa
            }
            rewrite stop {
                name regex (.*)\.otherobp\.example\.org istio-ingressgateway.istio-system.svc.cluster.local answer auto
            }
            forward . /etc/resolv.conf
        }
    
    
    
    ## Edit the Openshift's DNS custom resource
    kubectl edit dnses.operator/default
     
    ## Add the new instance domain to the existing .spec.servers.zones
      servers:
      - forwardPlugin:
          policy: Random
          upstreams:
          - 192.0.2.233
        name: obp-server
        zones:
        - myobp.example.com
        - otherobp.example.org
    您必須停止並重新啟動執行處理,DNS 變更才會生效。
存取 Oracle Blockchain Platform 服務主控台之前,請先為區塊鏈執行處理服務設定主機名稱解析,與先前為區塊鏈平台管理程式主機名稱所做的類似。使用下列命令取得所建立區塊鏈執行處理的主機名稱清單:
kubectl get virtualservice -n <instance-namespace> -o json | jq -r
      .items[].spec.hosts[0]

新增其他節點至叢集

叢集中的節點不足,因此建立執行處理可能會失敗。如果發生此情況,您可能需要新增更多節點至叢集。
  1. 執行下列命令以檢查處於「擱置中」狀態的 Pod:
    kubectl get pods -n <instancename> | grep Pending
    此外,您還可以檢查是否沒有可用的 Pod:
    kubectl get pods -n instancename
  2. 接下來,請檢查可用的工作節點:
    kubectl get nodes | grep worker
  3. 若要檢查是否有可採用新 Pod 的節點,請對每個工作節點執行下列命令:
    kubectl describe node $<worker_node>
    其中 <worker_node> 是工作節點的名稱。確定工作節點的容量不超過 100%。
  4. 若要新增其他節點,請先取得叢集中的 MachineSets 數目:
    oc get machinesets -n openshift-machine-api
  5. 對於少於 2 個節點的任何 MachineSets,請嘗試升級這些節點。
    oc scale --replicas=2 machineset <obpee00-qtthx-worker-eastus2> -n openshift-machine-api
    其中 <obpee00-qtthx-worker-eastus2> 是您要向上擴展至 2 個節點之 MachineSet 的範例名稱。
  6. 再次查詢 MachineSets,直到就緒和可用的節點清單達到您選取的節點數目為止。
  7. 您現在可以重新部署失敗的執行處理。

建立執行處理並列在「執行處理」清單之後,您就可以從執行處理名稱旁邊的功能表啟動服務主控台。依照使用 Oracle Blockchain Platform 中的主控台是什麼?所述,使用主控台設定您的網路。