Deploying a Cross-AZ Cluster¶
To prevent data loss and minimize the cluster downtime in case of service interruption, CSS supports cross-AZ cluster deployment. When creating a cluster, you can select two or three AZs in the same region. The system will automatically allocate nodes to these AZs.
Allocating Nodes¶
If you select two or three AZs when creating a cluster, CSS automatically enables the cross-AZ HA function and properly allocates nodes to different AZs. Table 1 describes how the nodes are allocated.
Note
When creating a cluster, ensure that the number of selected nodes is no less than the number of AZs. Otherwise, cross-AZ deployment is not supported.
If you enable master nodes when deploying a cross-AZ cluster, the master nodes will also be distributed to different AZs.
The node quantity difference between any two AZs is no more than one.
Nodes | Single AZ | Two AZs | Three AZs | |||
AZ1 | AZ1 | AZ2 | AZ1 | AZ2 | AZ3 | |
1 | 1 | Not supported | Not supported | |||
2 | 2 | 1 | 1 | Not supported | ||
3 | 3 | 2 | 1 | 1 | 1 | 1 |
4 | 4 | 2 | 2 | 2 | 1 | 1 |
... | ... | ... | ... | ... | ... | ... |
Setting Replicas¶
Setting replicas enables clusters to effectively use the HA capability of AZs.
In two-AZ deployment, if one AZ becomes unavailable, the other AZ continues to provide services. In this case, at least one replica is required. Elasticsearch has one replica by default. You can retain the default value if you do not require higher read performance.
In three-AZ deployment, if one AZ becomes unavailable, the other AZs continue to provide services. In this case, at least one replica is required. Elasticsearch has one replica by default. If you need more replicas to improve the cluster's ability to handle queries, modify settings to change the number of replicas.
You can run the following command to modify the number of index replicas:
curl -XPUT http://ip:9200/{index_name}/_settings -d '{"number_of_replicas":2}'
Alternatively, run the following command to specify the number of replicas in the template:
curl -XPUT http://ip:9200/ _template/templatename -d '{ "template": "*", "settings": {"number_of_replicas": 2}}'
Note
ip: private network address
index_name: index name
number_of_replicas: number of replicas after modification. The value in the preceding command indicates that two replicas are required.
Possible Service Interruptions¶
The following table describes the possible service interruptions when an AZ of a two- or three-AZ cluster is faulty.
AZs | Master Nodes | Service Interruption Analysis |
---|---|---|
2 | 0 |
|
2 | 3 | There is a 50% possibility for service interruption. When two dedicated master nodes are allocated to one AZ and another master node is allocated to the other AZ:
|
3 | 0 | If you configure four nodes in three AZs, each AZ will have at least one node. If the AZ with two nodes is faulty, the services will be interrupted. You are not advised configuring four nodes when selecting three AZs. Generally, service interruption will not occur. |
3 | 3 | Service interruption does not occur. |