Project: SkyWalking (Observability and Analysis / Observability)
File: backend-cluster.md

In many production environments, the backend needs to support distributed aggregation, high throughput and provide high availability (HA) to maintain robustness, so you always need to setup CLUSTER management in product env. Otherwise, you would face metrics inaccurate. `core/gRPCHost` is listening on `0.0.0.0` for quick start as the single mode for most cases. Besides the `Kubernetes` coordinator, which is using the cloud-native mode to establish cluster, all other coordinators requires `core/gRPCHost` updated to real IP addresses or take reference of `internalComHost` and `internalComPort` in each coordinator doc. NOTICE, cluster management doesn't provide a service discovery mechanism for agents and probes. We recommend agents/probes using gateway to load balancer to access OAP clusters. There are various ways to manage the cluster in the backend. Choose the one that best suits your needs. . When the backend clusters are deployed inside Kubernetes, you could make use of this method by using k8s native APIs to manage clusters. . Use Zookeeper to let the backend instances detect and communicate with each other. . Use Consul as the backend cluster management implementor and coordinate backend instances. . Use Etcd to coordinate backend instances. . Use Nacos to coordinate backend instances. In the `application.yml` file, there are default configurations for the aforementioned coordinators under the section `cluster`. You can specify any of them in the `selector` property to enable it. The required backend clusters are deployed inside Kubernetes. See the guides in . Set the selector to `kubernetes`. ```yaml cluster: selector: ${SW_CLUSTER:kubernetes} ``` Meanwhile, the OAP cluster requires the pod's UID which is laid at `metadata.uid` as the value of the system environment variable SKYWALKING_COLLECTOR_UID ```yaml containers: name: {{ .Values.oap.name }} image: {{ .Values.oap.image.repository }}:{{ required "oap.image.tag is required" .Values.oap.image.tag }} env: name: SKYWALKINGCOLLECTORUID valueFrom: fieldRef: fieldPath: metadata.uid ``` Read for more details. NOTICE In all the following coordinators, `oap.internal.comm.host`:`oap.internal.comm.port` is registered as the ID and address for the current OAP node. By default, because they are same in all OAP nodes, the registrations are conflicted, and (may) show as one registered node, which actually would be the node itself. In this case, the cluster mode is NOT working. Please check the registered nodes on your coordinator servers, to make the registration information unique for every node. You could have two options Change `core/gRPCHost`(`oap.internal.comm.host`) and `core/gRPCPort`(`oap.internal.comm.port`) for internal, and for data reporting and query. Use `internalComHost` and `internalComPort` in the config to provide a unique host and port for every OAP node. This host name port should be accessible for other OAP nodes. Zookeeper is a very common and widely used cluster coordinator. Set the cluster/selector to zookeeper in the yml to enable it. Required Zookeeper version: 3.5+ ```yaml cluster: selector: ${SW_CLUSTER:zookeeper} ``` `hostPort` is the list of zookeeper servers. Format is `IP1:PORT1,IP2:PORT2,...,IPn:PORTn` `enableACL` enable to control access to its znode. `schema` is Zookeeper ACL schemas. `expression` is a expression of ACL. The format of the expression is specific to the . `hostPort`, `baseSleepTimeMs` and `maxRetries` are settings of Zookeeper curator client. Note: If `Zookeeper ACL` is enabled and `/skywalking` exists, you must ensure that `SkyWalking` has `CREATE`, `READ` and `WRITE` permissions. If `/skywalking` does not exist, it will be created by SkyWalking, and all permissions to the specified user will be granted. Simultaneously, znode grants READ permission to

If you set `schema` as `digest`, the password of the expression is set in clear text. In some cases, the OAP default gRPC host and port in the core are not suitable for internal communication among the OAP nodes, such as the default host(`0.0.0.0`) should not be used in cluster mode. The following settings are provided to set the host and port manually, based on your own LAN env. internalComHost: The exposed host name for other OAP nodes in the cluster internal communication. internalComPort: the exposed port for other OAP nodes in the cluster internal communication. ```yaml cluster: selector: ${SW_CLUSTER:zookeeper} ... zookeeper: namespace: ${SW_NAMESPACE:""} hostPort: ${SWCLUSTERZKHOSTPORT:localhost:2181} baseSleepTimeMs: ${SWCLUSTERZKSLEEPTIME:1000} # initial amount of time to wait between retries maxRetries: ${SWCLUSTERZKMAXRETRIES:3} # max number of times to retry internalComHost: ${SWCLUSTERINTERNALCOMHOST:172.10.4.10} internalComPort: ${SWCLUSTERINTERNALCOMPORT:11800} enableACL: ${SWZKENABLE_ACL:false} # disable ACL in default schema: ${SWZKSCHEMA:digest} # only support digest schema expression: ${SWZKEXPRESSION:skywalking:skywalking} ``` Recently, the Consul system has become more and more popular, and many companies and developers now use Consul as their service discovery solution. Set the cluster/selector to consul in the yml to enable it. ```yaml cluster: selector: ${SW_CLUSTER:consul} ... consul: serviceName: ${SWSERVICENAME:"SkyWalkingOAPCluster"} hostPort: ${SWCLUSTERCONSULHOSTPORT:localhost:8500} aclToken: ${SWCLUSTERCONSUL_ACLTOKEN:""} internalComHost: ${SWCLUSTERINTERNALCOMHOST:""} internalComPort: ${SWCLUSTERINTERNALCOMPORT:-1} ``` Same as the Zookeeper coordinator, in some cases, the OAP default gRPC host and port in the core are not suitable for internal communication among the OAP nodes, such as the default host(`0.0.0.0`) should not be used in cluster mode. The following settings are provided to set the host and port manually, based on your own LAN env. internalComHost: The exposed host name for other OAP nodes in the cluster internal communication. internalComPort: the exposed port for other OAP nodes in the cluster internal communication. Set the cluster/selector to etcd in the yml to enable it. The Etcd client has upgraded to v3 protocol and changed to the CoreOS official library. Since 8.7.0, only the v3 protocol is supported for Etcd. ```yaml cluster: selector: ${SW_CLUSTER:etcd} etcd: endpoints: ${SWCLUSTERETCD_ENDPOINTS:localhost:2379} namespace: ${SWCLUSTERETCD_NAMESPACE:/skywalking} serviceName: ${SWCLUSTERETCDSERVICENAME:"SkyWalkingOAPCluster"} authentication: ${SWCLUSTERETCD_AUTHENTICATION:false} user: ${SWCLUSTERETCD_USER:} password: ${SWCLUSTERETCD_PASSWORD:} ``` Same as the Zookeeper coordinator, in some cases, the OAP default gRPC host and port in the core are not suitable for internal communication among the OAP nodes, such as the default host(`0.0.0.0`) should not be used in cluster mode. The following settings are provided to set the host and port manually, based on your own LAN env. internalComHost: The exposed host name for other OAP nodes in the cluster internal communication. internalComPort: the exposed port for other OAP nodes in the cluster internal communication. Set the cluster/selector to nacos in the yml to enable it. ```yaml cluster: selector: ${SW_CLUSTER:nacos} ``` Nacos supports authentication by username or accessKey. Empty means that there is no need for authentication. Extra config is as follows: ```yaml nacos: username: password: accessKey: secretKey: ``` Same as the Zookeeper coordinator, in some cases, the OAP default gRPC host and port in the core are not suitable for internal communication among the OAP nodes, such as the default host(`0.0.0.0`) should not be used in cluster mode. The following settings are provided to set the host and port manually, based on your own LAN env. internalComHost: The exposed host name for other OAP nodes in the cluster internal communication. internalComPort: the exposed port for other OAP nodes in the cluster internal communication.