forked from docs/doc-exports
Reviewed-by: Pruthi, Vineet <vineet.pruthi@t-systems.com> Co-authored-by: zhengxiu <zhengxiu@huawei.com> Co-committed-by: zhengxiu <zhengxiu@huawei.com>
405 lines
36 KiB
HTML
405 lines
36 KiB
HTML
<a name="css_01_0410"></a><a name="css_01_0410"></a>
|
|
|
|
<h1 class="topictitle1">Configuring Read/Write Splitting Between Two Elasticsearch Clusters</h1>
|
|
<div id="body0000001080741131"><div class="section" id="css_01_0410__section20798162114246"><h4 class="sectiontitle">Scenario</h4><p id="css_01_0410__p197629251513">Data written to the primary cluster (<strong id="css_01_0410__css_01_0400_b183483318556">Leader</strong>) is automatically synchronized to the secondary cluster (<strong id="css_01_0410__css_01_0400_b123463315552">Follower</strong>). This allows data to be queried from the secondary cluster, improving query performance while alleviating the pressure of the primary cluster. If the primary cluster is unable to provide services, a primary/secondary switchover can be performed to use the secondary cluster to handle write and query requests, ensuring service continuity.</p>
|
|
<div class="fignone" id="css_01_0410__en-us_topic_0000001268154533_fig165871420101917"><span class="figcap"><b>Figure 1 </b>Two application scenarios for read/write splitting</span><br><span><img id="css_01_0410__en-us_topic_0000001268154533_image16587320141910" src="en-us_image_0000001981763825.jpg"></span></div>
|
|
<p id="css_01_0410__p98092635312">Scenario 1 (left in the figure): Data is written into the primary cluster but queried from the secondary cluster, alleviating pressure for both clusters.</p>
|
|
<p id="css_01_0410__p841619122561">Scenario 2 (right in the figure): When the primary cluster fails, the secondary cluster takes over to ensure service continuity.</p>
|
|
</div>
|
|
<div class="section" id="css_01_0410__section1995816338248"><h4 class="sectiontitle">Constraints</h4><ul id="css_01_0410__ul473014135594"><li id="css_01_0410__li1730213105915">Only Elasticsearch 7.6.2 and Elasticsearch 7.10.2 clusters support read/write splitting.</li><li id="css_01_0410__li10730101395914">The versions of the primary and secondary clusters must be kept consistent, or errors may occur.</li></ul>
|
|
</div>
|
|
<div class="section" id="css_01_0410__section1338820544715"><h4 class="sectiontitle">Prerequisites</h4><p id="css_01_0410__p1114516586710">Two clusters of the same version have been created. One functions as the primary cluster, and the other the secondary cluster. The secondary cluster must be able to access the REST API (default port: 9200) of the primary cluster.</p>
|
|
</div>
|
|
<div class="section" id="css_01_0410__section1023014371242"><a name="css_01_0410__section1023014371242"></a><a name="section1023014371242"></a><h4 class="sectiontitle">Connecting the Primary and Secondary Clusters</h4><ol id="css_01_0410__en-us_topic_0000001223754356_ol927111214106"><li id="css_01_0410__en-us_topic_0000001223754356_li1274916552817">Log in to the CSS management console.</li><li id="css_01_0410__en-us_topic_0000001223754356_li1274935516811">Choose <strong id="css_01_0410__b14239754516">Clusters</strong> in the navigation pane. On the <strong id="css_01_0410__b18239195125116">Clusters</strong> page, locate the secondary cluster and click <strong id="css_01_0410__b423965135117">Access Kibana</strong> in the <strong id="css_01_0410__b132391754519">Operation</strong> column.</li><li id="css_01_0410__li1122518206913">Click <strong id="css_01_0410__b73397537114318">Dev Tools</strong> in the navigation tree on the left.</li><li id="css_01_0410__en-us_topic_0000001223754356_li927171291011">Run the following command to configure information about the primary cluster in the secondary cluster:<pre class="screen" id="css_01_0410__en-us_topic_0000001223754356_screen1915102641219">PUT /_cluster/settings
|
|
{
|
|
"persistent" : {
|
|
"cluster" : {
|
|
"remote.rest" : {
|
|
"leader1" : {
|
|
"seeds" : [
|
|
"http://10.0.0.1:9200",
|
|
"http://10.0.0.2:9200",
|
|
"http://10.0.0.3:9200"
|
|
] ,
|
|
"username": "elastic",
|
|
"password": "*****"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}</pre>
|
|
|
|
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="css_01_0410__table25991023216" frame="border" border="1" rules="all"><caption><b>Table 1 </b>Request body parameters</caption><thead align="left"><tr id="css_01_0410__row1459510193214"><th align="left" class="cellrowborder" valign="top" width="30%" id="mcps1.3.4.2.4.2.2.3.1.1"><p id="css_01_0410__p1159510133211">Parameter</p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="70%" id="mcps1.3.4.2.4.2.2.3.1.2"><p id="css_01_0410__p1359410173217">Description</p>
|
|
</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody><tr id="css_01_0410__row359610133214"><td class="cellrowborder" valign="top" width="30%" headers="mcps1.3.4.2.4.2.2.3.1.1 "><p id="css_01_0410__p1759121018325"><i><span class="varname" id="css_01_0410__varname52375219379">leader1</span></i></p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.3.4.2.4.2.2.3.1.2 "><p id="css_01_0410__p14591410123211">Name of the primary cluster configuration task, which is user-defined and will be used for configuring read/write splitting later.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="css_01_0410__row259610203218"><td class="cellrowborder" valign="top" width="30%" headers="mcps1.3.4.2.4.2.2.3.1.1 "><p id="css_01_0410__p85961015328">seeds</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.3.4.2.4.2.2.3.1.2 "><p id="css_01_0410__p1859171043218">Address for accessing the primary cluster. When HTTPS is enabled for the cluster, the URL schema must use HTTPS.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="css_01_0410__row1359210193217"><td class="cellrowborder" valign="top" width="30%" headers="mcps1.3.4.2.4.2.2.3.1.1 "><p id="css_01_0410__p11591010173218">username</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.3.4.2.4.2.2.3.1.2 "><p id="css_01_0410__p14591810153211">Username of the primary cluster. This parameter is required only when security mode is enabled for the primary cluster.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="css_01_0410__row175921093217"><td class="cellrowborder" valign="top" width="30%" headers="mcps1.3.4.2.4.2.2.3.1.1 "><p id="css_01_0410__p859181020321">password</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.3.4.2.4.2.2.3.1.2 "><p id="css_01_0410__p6598104321">Password of the primary cluster. This parameter is required only when security mode is enabled for the primary cluster.</p>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<p id="css_01_0410__p8101102263712">Example response:</p>
|
|
<pre class="screen" id="css_01_0410__screen12391193717379">{
|
|
"acknowledged" : true, //Whether the operation is successful
|
|
"persistent" : {
|
|
"cluster" : {
|
|
"remote" : {
|
|
"rest" : {
|
|
"leader1" : {
|
|
"seeds" : [
|
|
"http://10.0.0.1:9200",
|
|
"http://10.0.0.2:9200",
|
|
"http://10.0.0.3:9200"
|
|
] ,
|
|
"username": "elastic",
|
|
"password": "*****"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"transient" : { }
|
|
}</pre>
|
|
</li><li id="css_01_0410__li176551843161010">After the configuration is complete, run the following command in the secondary cluster to check the connection between the secondary and primary clusters:<pre class="screen" id="css_01_0410__screen1616587112219">GET _remote/rest/info</pre>
|
|
<p id="css_01_0410__p15950201983913">Example response:</p>
|
|
<pre class="screen" id="css_01_0410__screen1422283511391">{
|
|
"leader1" : {
|
|
"connected" : true //The two clusters are connected.
|
|
}
|
|
}</pre>
|
|
</li></ol>
|
|
</div>
|
|
<div class="section" id="css_01_0410__section97051931358"><a name="css_01_0410__section97051931358"></a><a name="section97051931358"></a><h4 class="sectiontitle">Index Synchronization</h4><p id="css_01_0410__p95918467368">There are two ways to synchronize indexes: specified index synchronization and matching index synchronization.</p>
|
|
<p id="css_01_0410__p78489284403">During synchronization, indexes in the secondary cluster become read-only. The synchronization is performed periodically. The default synchronization interval is 30 seconds. For how to change it, see <a href="#css_01_0410__section94973244119">Changing the Synchronization Interval</a>.</p>
|
|
<div class="p" id="css_01_0410__p1958161016379"><strong id="css_01_0410__b1045025511511">Synchronizing Specified Indexes</strong><ul id="css_01_0410__ul729419204220"><li id="css_01_0410__li729719134217">Run the following command in the secondary cluster to synchronize a single index from the primary cluster to the secondary cluster without modifying index settings:<pre class="screen" id="css_01_0410__en-us_topic_0000001223594396_screen16407173811400">PUT start_remote_sync
|
|
{
|
|
"remote_cluster": "<em id="css_01_0410__i53471336124210">leader1</em>",
|
|
"remote_index": "<em id="css_01_0410__i12116133964220">data1_leader</em>",
|
|
"local_index": "<em id="css_01_0410__i101182420422">data1_follower</em>"
|
|
}</pre>
|
|
</li><li id="css_01_0410__li1330181974210">Run the following command in the secondary cluster to synchronize a single index from the primary cluster to the secondary cluster while modifying some of the index settings—enabling synchronization of index settings:<pre class="screen" id="css_01_0410__en-us_topic_0000001223594396_screen17681038181312">PUT start_remote_sync
|
|
{
|
|
"remote_cluster": "<em id="css_01_0410__i2731111864420">leader1</em>",
|
|
"remote_index": "<em id="css_01_0410__i71341622144412">data1_leader</em>",
|
|
"local_index": "<em id="css_01_0410__i9114261449">data1_follower</em>",
|
|
"settings": {
|
|
"number_of_replicas": 4
|
|
},
|
|
"settings_sync_enable": true,
|
|
"settings_sync_patterns": ["*"],
|
|
"settings_sync_exclude_patterns": ["index.routing.allocation.*"],
|
|
"alias_sync_enable": true,
|
|
"state_sync_enable": true
|
|
}</pre>
|
|
<div class="note" id="css_01_0410__en-us_topic_0000001223594396_note7407203813409"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="css_01_0410__en-us_topic_0000001223594396_p7407338124018">The following index configuration items cannot be modified: <span class="parmvalue" id="css_01_0410__parmvalue65601958144316"><b>number_of_shards</b></span>, <span class="parmvalue" id="css_01_0410__parmvalue1611513116446"><b>version.created</b></span>, <span class="parmvalue" id="css_01_0410__parmvalue1718315334419"><b>uuid</b></span>, <span class="parmvalue" id="css_01_0410__parmvalue2025612519447"><b>creation_date</b></span>, and <span class="parmvalue" id="css_01_0410__parmvalue1826811844410"><b>soft_deletes.enabled</b></span>.</p>
|
|
</div></div>
|
|
</li></ul>
|
|
|
|
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="css_01_0410__table13314194164411" frame="border" border="1" rules="all"><caption><b>Table 2 </b>Request body parameters</caption><thead align="left"><tr id="css_01_0410__row1931420413443"><th align="left" class="cellrowborder" valign="top" width="30%" id="mcps1.3.5.4.3.2.3.1.1"><p id="css_01_0410__p13314114112444">Parameter</p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="70%" id="mcps1.3.5.4.3.2.3.1.2"><p id="css_01_0410__p1631434111445">Description</p>
|
|
</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody><tr id="css_01_0410__row23141414444"><td class="cellrowborder" valign="top" width="30%" headers="mcps1.3.5.4.3.2.3.1.1 "><p id="css_01_0410__p173141841154414">remote_cluster</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.3.5.4.3.2.3.1.2 "><p id="css_01_0410__p13314241174414">Name of the primary cluster configuration task, which was set in <a href="#css_01_0410__section1023014371242">Connecting the Primary and Secondary Clusters</a>. <strong id="css_01_0410__b16423143818133">leader1</strong> was set in our example.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="css_01_0410__row1431434119441"><td class="cellrowborder" valign="top" width="30%" headers="mcps1.3.5.4.3.2.3.1.1 "><p id="css_01_0410__p631454117441">remote_index</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.3.5.4.3.2.3.1.2 "><p id="css_01_0410__p12315194117446">Name of the index to be synchronized in the primary cluster</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="css_01_0410__row2315154154411"><td class="cellrowborder" valign="top" width="30%" headers="mcps1.3.5.4.3.2.3.1.1 "><p id="css_01_0410__p1231514114420">local_index</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.3.5.4.3.2.3.1.2 "><p id="css_01_0410__p17315164114447">Index name in the secondary cluster</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="css_01_0410__row7315204194417"><td class="cellrowborder" valign="top" width="30%" headers="mcps1.3.5.4.3.2.3.1.1 "><p id="css_01_0410__p831519418448">settings</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.3.5.4.3.2.3.1.2 "><p id="css_01_0410__p931594118443">Index settings to be synchronized</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="css_01_0410__row145994251920"><td class="cellrowborder" valign="top" width="30%" headers="mcps1.3.5.4.3.2.3.1.1 "><p id="css_01_0410__p5600625798">settings_sync_enable</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.3.5.4.3.2.3.1.2 "><p id="css_01_0410__p460042513911">Whether to enable synchronization of index settings in the primary cluster. The default value is <span class="parmvalue" id="css_01_0410__parmvalue85833014112"><b>false</b></span>.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="css_01_0410__row9961103211010"><td class="cellrowborder" valign="top" width="30%" headers="mcps1.3.5.4.3.2.3.1.1 "><p id="css_01_0410__p1796153261011">settings_sync_patterns</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.3.5.4.3.2.3.1.2 "><p id="css_01_0410__p996193271011">Prefix of primary cluster index settings to be synchronized. The default value is <span class="parmvalue" id="css_01_0410__parmvalue410615811014"><b>*</b></span>. This parameter takes effect when <span class="parmname" id="css_01_0410__parmname760715451003"><b>settings_sync_enable</b></span> is set to <span class="parmvalue" id="css_01_0410__parmvalue1161204919016"><b>true</b></span>. The index settings configured in <span class="parmname" id="css_01_0410__parmname1226513376483"><b>settings</b></span> will not be synchronized.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="css_01_0410__row5535629151011"><td class="cellrowborder" valign="top" width="30%" headers="mcps1.3.5.4.3.2.3.1.1 "><p id="css_01_0410__p1353532921020">settings_sync_exclude_patterns</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.3.5.4.3.2.3.1.2 "><p id="css_01_0410__p1253582931013">Prefix of primary cluster index settings not to be synchronized. The default value is empty. This parameter is valid only when <span class="parmname" id="css_01_0410__parmname1526117101714"><b>settings_sync_enable</b></span> is set to <span class="parmvalue" id="css_01_0410__parmvalue208090121111"><b>true</b></span>.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="css_01_0410__row944942516100"><td class="cellrowborder" valign="top" width="30%" headers="mcps1.3.5.4.3.2.3.1.1 "><p id="css_01_0410__p2044913254107">alias_sync_enable</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.3.5.4.3.2.3.1.2 "><p id="css_01_0410__p18449122511100">Whether to enable index alias synchronization in the primary cluster. The default value is <span class="parmvalue" id="css_01_0410__parmvalue1680114211111"><b>false</b></span>.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="css_01_0410__row12799112011106"><td class="cellrowborder" valign="top" width="30%" headers="mcps1.3.5.4.3.2.3.1.1 "><p id="css_01_0410__p107991420151017">state_sync_enable</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.3.5.4.3.2.3.1.2 "><p id="css_01_0410__p9799162015105">Whether to enable index status synchronization in the primary cluster. The default value is <span class="parmvalue" id="css_01_0410__parmvalue720204623616"><b>false</b></span>.</p>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
<div class="p" id="css_01_0410__p103415204378"><strong id="css_01_0410__b157122311154">Matching Index Synchronization</strong><ul id="css_01_0410__ul178922155017"><li id="css_01_0410__li6789121155020">Run the following command in the secondary cluster to create a pattern-matching index synchronization policy, which synchronizes matched indexes from the primary cluster to the secondary cluster:<pre class="screen" id="css_01_0410__screen778972185018">PUT auto_sync/pattern/${PATTERN}
|
|
{
|
|
"remote_cluster": "<em id="css_01_0410__i91531934115211">leader1</em>",
|
|
"remote_index_patterns": "<em id="css_01_0410__i1731013675219">log*</em>",
|
|
"local_index_pattern": "<em id="css_01_0410__i1860834117528">{{remote_index}}-sync</em>",
|
|
"apply_exist_index": true
|
|
}</pre>
|
|
</li><li id="css_01_0410__li11790621195020">Run the following command in the secondary cluster to create a pattern-matching index synchronization policy, which synchronizes matched indexes from the primary cluster to the secondary cluster, with some of the index settings modified—enabling synchronization of index settings:<pre class="screen" id="css_01_0410__screen979062110508">PUT auto_sync/pattern/${PATTERN}
|
|
{
|
|
"remote_cluster": "<em id="css_01_0410__i186511118536">leader1</em>",
|
|
"remote_index_patterns": "<em id="css_01_0410__i176592078533">log*</em>",
|
|
"local_index_pattern": "<em id="css_01_0410__i18872131025310">{{remote_index}}-sync</em>",
|
|
"apply_exist_index": true,
|
|
"settings": {
|
|
"number_of_replicas": 4
|
|
},
|
|
"settings_sync_enable": true,
|
|
"settings_sync_patterns": ["*"],
|
|
"settings_sync_exclude_patterns": ["index.routing.allocation.*"],
|
|
"alias_sync_enable": true,
|
|
"state_sync_enable": true
|
|
}</pre>
|
|
<div class="note" id="css_01_0410__note1358083418563"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="css_01_0410__css_01_0410_en-us_topic_0000001223594396_p7407338124018">The following index configuration items cannot be modified: <span class="parmvalue" id="css_01_0410__css_01_0410_parmvalue65601958144316"><b>number_of_shards</b></span>, <span class="parmvalue" id="css_01_0410__css_01_0410_parmvalue1611513116446"><b>version.created</b></span>, <span class="parmvalue" id="css_01_0410__css_01_0410_parmvalue1718315334419"><b>uuid</b></span>, <span class="parmvalue" id="css_01_0410__css_01_0410_parmvalue2025612519447"><b>creation_date</b></span>, and <span class="parmvalue" id="css_01_0410__css_01_0410_parmvalue1826811844410"><b>soft_deletes.enabled</b></span>.</p>
|
|
</div></div>
|
|
</li></ul>
|
|
|
|
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="css_01_0410__en-us_topic_0000001268154469_table1284421662112" frame="border" border="1" rules="all"><caption><b>Table 3 </b>Request body parameters</caption><thead align="left"><tr id="css_01_0410__en-us_topic_0000001268154469_row484481616219"><th align="left" class="cellrowborder" valign="top" width="30%" id="mcps1.3.5.5.3.2.3.1.1"><p id="css_01_0410__en-us_topic_0000001268154469_p2844116192118">Parameter</p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="70%" id="mcps1.3.5.5.3.2.3.1.2"><p id="css_01_0410__en-us_topic_0000001268154469_p11844101662111">Description</p>
|
|
</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody><tr id="css_01_0410__row8893103835010"><td class="cellrowborder" valign="top" width="30%" headers="mcps1.3.5.5.3.2.3.1.1 "><p id="css_01_0410__p17648154310502">PATTERN</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.3.5.5.3.2.3.1.2 "><p id="css_01_0410__p36491443185015">Name of the pattern for index matching.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="css_01_0410__en-us_topic_0000001268154469_row12844161612114"><td class="cellrowborder" valign="top" width="30%" headers="mcps1.3.5.5.3.2.3.1.1 "><p id="css_01_0410__en-us_topic_0000001268154469_p184421642110">remote_cluster</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.3.5.5.3.2.3.1.2 "><p id="css_01_0410__en-us_topic_0000001268154469_p168446161215">Name of the primary cluster configuration task, which was set in <a href="#css_01_0410__section1023014371242">Connecting the Primary and Secondary Clusters</a>. In our example, <span class="parmvalue" id="css_01_0410__parmvalue15344165313117"><b>leader1</b></span> is used.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="css_01_0410__en-us_topic_0000001268154469_row284411682114"><td class="cellrowborder" valign="top" width="30%" headers="mcps1.3.5.5.3.2.3.1.1 "><p id="css_01_0410__en-us_topic_0000001268154469_p4844101614218">remote_index_patterns</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.3.5.5.3.2.3.1.2 "><p id="css_01_0410__en-us_topic_0000001268154469_p1784431612114">Pattern for matching indexes to be synchronized in the primary cluster. The wildcard (*) is supported.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="css_01_0410__en-us_topic_0000001268154469_row4844016152112"><td class="cellrowborder" valign="top" width="30%" headers="mcps1.3.5.5.3.2.3.1.1 "><p id="css_01_0410__en-us_topic_0000001268154469_p158441216192113">local_index_pattern</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.3.5.5.3.2.3.1.2 "><p id="css_01_0410__en-us_topic_0000001268154469_p484431672119">Index pattern in the secondary cluster. The index template can be replaced. For example, if this parameter is set to <strong id="css_01_0410__b131501922183311">{{remote_index}}-sync</strong>, the index <strong id="css_01_0410__b181511922133315">log1</strong> changes to <strong id="css_01_0410__b1015110229337">log1-sync</strong> after synchronization.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="css_01_0410__en-us_topic_0000001268154469_row10518142315249"><td class="cellrowborder" valign="top" width="30%" headers="mcps1.3.5.5.3.2.3.1.1 "><p id="css_01_0410__en-us_topic_0000001268154469_p0518162392410">apply_exist_index</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.3.5.5.3.2.3.1.2 "><p id="css_01_0410__en-us_topic_0000001268154469_p14518823192414">Whether to synchronize existing indexes in the primary cluster. The default value is <span class="parmvalue" id="css_01_0410__parmvalue1997116133214"><b>true</b></span>.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="css_01_0410__en-us_topic_0000001268154469_row13845171602117"><td class="cellrowborder" valign="top" width="30%" headers="mcps1.3.5.5.3.2.3.1.1 "><p id="css_01_0410__en-us_topic_0000001268154469_p13845141614214">settings</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.3.5.5.3.2.3.1.2 "><p id="css_01_0410__en-us_topic_0000001268154469_p10845131682115">Index settings to be synchronized</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="css_01_0410__row15276564184"><td class="cellrowborder" valign="top" width="30%" headers="mcps1.3.5.5.3.2.3.1.1 "><p id="css_01_0410__p128155671815">settings_sync_enable</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.3.5.5.3.2.3.1.2 "><p id="css_01_0410__p6281456191817">Whether to enable synchronization of index settings in the primary cluster. The default value is <span class="parmvalue" id="css_01_0410__parmvalue931181718401"><b>false</b></span>.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="css_01_0410__row12523105917184"><td class="cellrowborder" valign="top" width="30%" headers="mcps1.3.5.5.3.2.3.1.1 "><p id="css_01_0410__p18523459171810">settings_sync_patterns</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.3.5.5.3.2.3.1.2 "><p id="css_01_0410__p105238592185">Prefix of primary cluster index settings to be synchronized. The default value is <span class="parmvalue" id="css_01_0410__parmvalue7391122817403"><b>*</b></span>. This parameter takes effect when <span class="parmname" id="css_01_0410__parmname1039119283405"><b>settings_sync_enable</b></span> is set to <span class="parmvalue" id="css_01_0410__parmvalue1439132844011"><b>true</b></span>. The index settings configured in <span class="parmname" id="css_01_0410__parmname239122811401"><b>settings</b></span> will not be synchronized.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="css_01_0410__row5831827198"><td class="cellrowborder" valign="top" width="30%" headers="mcps1.3.5.5.3.2.3.1.1 "><p id="css_01_0410__p198311228194">settings_sync_exclude_patterns</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.3.5.5.3.2.3.1.2 "><p id="css_01_0410__p178321126192">Prefix of primary cluster index settings not to be synchronized. The default value is empty. This parameter is valid only when <span class="parmname" id="css_01_0410__parmname13308103844011"><b>settings_sync_enable</b></span> is set to <span class="parmvalue" id="css_01_0410__parmvalue73081938104010"><b>true</b></span>.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="css_01_0410__row10121668192"><td class="cellrowborder" valign="top" width="30%" headers="mcps1.3.5.5.3.2.3.1.1 "><p id="css_01_0410__p111216121910">alias_sync_enable</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.3.5.5.3.2.3.1.2 "><p id="css_01_0410__p14124661918">Whether to enable index alias synchronization in the primary cluster. The default value is <span class="parmvalue" id="css_01_0410__parmvalue486395612401"><b>false</b></span>.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="css_01_0410__row41545901918"><td class="cellrowborder" valign="top" width="30%" headers="mcps1.3.5.5.3.2.3.1.1 "><p id="css_01_0410__p1915499161917">state_sync_enable</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.3.5.5.3.2.3.1.2 "><p id="css_01_0410__p31544911911">Whether to enable index status synchronization in the primary cluster. The default value is <span class="parmvalue" id="css_01_0410__parmvalue25875116412"><b>false</b></span>.</p>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="section" id="css_01_0410__section1012905085616"><a name="css_01_0410__section1012905085616"></a><a name="section1012905085616"></a><h4 class="sectiontitle">Stopping Index Synchronization</h4><p id="css_01_0410__en-us_topic_0000001268394301_p1918723104920">Run the following command in the secondary cluster to stop synchronization tasks for specified indexes. Subsequent changes to the indexes in the primary cluster will not be synchronized to the secondary cluster. The read-only state of the indexes in the secondary cluster will be cancelled, so that new data can be written into them.</p>
|
|
<pre class="screen" id="css_01_0410__en-us_topic_0000001268394301_screen328271563114">PUT <em id="css_01_0410__i1575119381408">log*</em>/stop_remote_sync</pre>
|
|
<p id="css_01_0410__p92841558195719">In this command, <span class="parmvalue" id="css_01_0410__parmvalue183637471101"><b>log*</b></span> indicates the index name. You can specify multiple index names (separated by commas) or use a wildcard. In this example, synchronization tasks for all indexes that start with <strong id="css_01_0410__b971683102">log</strong> are stopped.</p>
|
|
</div>
|
|
<div class="section" id="css_01_0410__section1147716276219"><a name="css_01_0410__section1147716276219"></a><a name="section1147716276219"></a><h4 class="sectiontitle">Querying and Deleting Created Patterns</h4><ol id="css_01_0410__ol590946947"><li id="css_01_0410__li090918616415">Run the following command in the secondary cluster to query created patterns:<ul id="css_01_0410__ul1435912192519"><li id="css_01_0410__li33590191250">Query the list of patterns.<pre class="screen" id="css_01_0410__screen1980094213416">GET auto_sync/pattern</pre>
|
|
</li><li id="css_01_0410__li173591193510">Query a specified pattern by name.<pre class="screen" id="css_01_0410__screen75041533419">GET auto_sync/pattern/{PATTERN}</pre>
|
|
</li></ul>
|
|
<p id="css_01_0410__p15041431644">The following is an example of the response:</p>
|
|
<pre class="screen" id="css_01_0410__screen145044315417">{
|
|
"patterns" : [
|
|
{
|
|
"name" : "pattern1",
|
|
"pattern" : {
|
|
"remote_cluster" : "leader",
|
|
"remote_index_patterns" : [
|
|
"log*"
|
|
],
|
|
"local_index_pattern" : "{{remote_index}}-sync",
|
|
"settings" : { }
|
|
}
|
|
}
|
|
]
|
|
}</pre>
|
|
</li><li id="css_01_0410__li0909567411">Run the following command in the secondary cluster to delete a specified pattern by name:<pre class="screen" id="css_01_0410__en-us_topic_0000001223754412_screen5658180104516">DELETE auto_sync/pattern/{PATTERN}</pre>
|
|
</li></ol>
|
|
</div>
|
|
<div class="section" id="css_01_0410__section06477291115"><h4 class="sectiontitle">Enabling Forcible Synchronization</h4><p id="css_01_0410__p171871820015">By default, the plug-in determines whether to synchronize metadata based on whether the number of documents in the index of the primary cluster changes. If the primary cluster only updates documents and the number of documents remains unchanged, the plug-in does not synchronize the updates to the secondary cluster. The configuration can be modified. After forcible synchronization is enabled, the index metadata of the primary cluster is forcibly synchronized to the secondary cluster in each synchronization cycle.</p>
|
|
<p id="css_01_0410__p17718151810018">The following is an example of enabling forcible synchronization:</p>
|
|
<pre class="screen" id="css_01_0410__screen10160172810015">PUT _cluster/settings
|
|
{
|
|
"persistent": {
|
|
"remote_sync.force_synchronize": true
|
|
}
|
|
}</pre>
|
|
</div>
|
|
<div class="section" id="css_01_0410__section94973244119"><a name="css_01_0410__section94973244119"></a><a name="section94973244119"></a><h4 class="sectiontitle">Changing the Synchronization Interval</h4><p id="css_01_0410__en-us_topic_0000001223754412_p214154518462">The default synchronization interval between the primary and secondary clusters is 30 seconds and can be changed.</p>
|
|
<p id="css_01_0410__en-us_topic_0000001223754412_p1517434513510">The example request below changes the synchronization interval to 2 seconds:</p>
|
|
<pre class="screen" id="css_01_0410__en-us_topic_0000001223754412_screen1049271212486">PUT {index_name}/_settings
|
|
{
|
|
"index.remote_sync.sync_interval": "2s"
|
|
}</pre>
|
|
</div>
|
|
<div class="section" id="css_01_0410__section1290762813115"><h4 class="sectiontitle">Changing the Synchronization Speed</h4><p id="css_01_0410__p11162175483219">You can change the data synchronization speed between the primary and secondary clusters by configuring cluster-level settings.</p>
|
|
<p id="css_01_0410__p121631054163213">The following is an example request: set the block size to 2 MB, the number of blocks to 20, and the maximum synchronization traffic to 100 MB per second.</p>
|
|
<pre class="screen" id="css_01_0410__screen1168865012503">PUT _cluster/settings
|
|
{
|
|
"persistent": {
|
|
"remote_sync.chunk_size": "2MB",
|
|
"remote_sync.max_concurrent_file_chunks": 20,
|
|
"remote_sync.max_bytes_per_sec": "100MB"
|
|
}
|
|
}</pre>
|
|
|
|
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="css_01_0410__table14349111215118" frame="border" border="1" rules="all"><caption><b>Table 4 </b>Request body parameters</caption><thead align="left"><tr id="css_01_0410__row73508120517"><th align="left" class="cellrowborder" valign="top" width="30%" id="mcps1.3.10.5.2.3.1.1"><p id="css_01_0410__p103501612125111">Parameter</p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="70%" id="mcps1.3.10.5.2.3.1.2"><p id="css_01_0410__p14350111216515">Description</p>
|
|
</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody><tr id="css_01_0410__row10350912185119"><td class="cellrowborder" valign="top" width="30%" headers="mcps1.3.10.5.2.3.1.1 "><p id="css_01_0410__p171272316519">remote_sync.chunk_size</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.3.10.5.2.3.1.2 "><p id="css_01_0410__p8777539518">Block size for index synchronization.</p>
|
|
<p id="css_01_0410__p88231556175114">Default value: 1 MB</p>
|
|
<p id="css_01_0410__p1922903814529">Format: a string of characters</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="css_01_0410__row135061295113"><td class="cellrowborder" valign="top" width="30%" headers="mcps1.3.10.5.2.3.1.1 "><p id="css_01_0410__p8127531125112">remote_sync.max_concurrent_file_chunks</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.3.10.5.2.3.1.2 "><p id="css_01_0410__p877115314514">Number of blocks for concurrent index synchronization.</p>
|
|
<p id="css_01_0410__p499225617526">Default value: <strong id="css_01_0410__b9908124064366">10</strong></p>
|
|
<p id="css_01_0410__p16992165655220">Format: a number</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="css_01_0410__row73506123517"><td class="cellrowborder" valign="top" width="30%" headers="mcps1.3.10.5.2.3.1.1 "><p id="css_01_0410__p1612783115518">remote_sync.max_bytes_per_sec</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.3.10.5.2.3.1.2 "><p id="css_01_0410__p077145320517">Maximum data synchronization traffic per second.</p>
|
|
<p id="css_01_0410__p18247135915523">Default value: 40 MB</p>
|
|
<p id="css_01_0410__p924711599521">Format: a string of characters</p>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
<div class="section" id="css_01_0410__section521113511997"><h4 class="sectiontitle">Querying Index Synchronization Status</h4><ul id="css_01_0410__ul9230519171017"><li id="css_01_0410__en-us_topic_0000001223754412_li10669105219327"><strong id="css_01_0410__b06292311245">Obtaining the auto synchronization status of a specified index</strong><p id="css_01_0410__en-us_topic_0000001223754412_p1925919245357">An example request is as follows:</p>
|
|
<pre class="screen" id="css_01_0410__en-us_topic_0000001223754412_screen15143152684719">GET {index_name}/sync_stats</pre>
|
|
<p id="css_01_0410__en-us_topic_0000001223754412_p102933159471">An example response is as follows:</p>
|
|
<pre class="screen" id="css_01_0410__en-us_topic_0000001223754412_screen1102144314719">{
|
|
"indices" : {
|
|
"data1_follower" : {
|
|
"shards" : {
|
|
"0" : [
|
|
{
|
|
"primary" : false,
|
|
"total_synced_times" : 27,
|
|
"total_empty_times" : 25,
|
|
"total_synced_files" : 4,
|
|
"total_synced_bytes" : 3580,
|
|
"total_paused_nanos" : 0,
|
|
"total_paused_times" : 0,
|
|
"current" : {
|
|
"files_count" : 0,
|
|
"finished_files_count" : 0,
|
|
"bytes" : 0,
|
|
"finished_bytes" : 0
|
|
}
|
|
},
|
|
{
|
|
"primary" : true,
|
|
"total_synced_times" : 28,
|
|
"total_empty_times" : 26,
|
|
"total_synced_files" : 20,
|
|
"total_synced_bytes" : 17547,
|
|
"total_paused_nanos" : 0,
|
|
"total_paused_times" : 0,
|
|
"current" : {
|
|
"files_count" : 0,
|
|
"finished_files_count" : 0,
|
|
"bytes" : 0,
|
|
"finished_bytes" : 0
|
|
}
|
|
}
|
|
]
|
|
}
|
|
}
|
|
}
|
|
}</pre>
|
|
</li></ul>
|
|
</div>
|
|
<div class="section" id="css_01_0410__section62831838161012"><h4 class="sectiontitle">Switching the Roles of the Primary and Secondary Clusters</h4><p id="css_01_0410__p1018865812126">When the primary cluster becomes faulty, perform a primary/secondary switchover to have the secondary cluster take over services. The steps are as follows:</p>
|
|
<ol id="css_01_0410__ol8936352131318"><li id="css_01_0410__li13936552191320">Determine the index synchronization method between the primary and secondary clusters. Check whether pattern-matching index synchronization policies have been configured in the secondary cluster. For the command to use, see <a href="#css_01_0410__section1147716276219">Querying and Deleting Created Patterns</a>.<ul id="css_01_0410__ul17259114121913"><li id="css_01_0410__li1925924115195">If there are no such policies, synchronization is performed for specified indexes between the primary and secondary clusters. In this case, go to <a href="#css_01_0410__li20906161442213">3</a>.</li><li id="css_01_0410__li12719161122011">If there are such policies, index synchronization between the primary and secondary clusters is based on index patterns. In this case, go to <a href="#css_01_0410__li077084319314">2</a>.</li></ul>
|
|
</li><li id="css_01_0410__li077084319314"><a name="css_01_0410__li077084319314"></a><a name="li077084319314"></a>Delete pattern-matching index synchronization policies in the secondary cluster. For the command to use, see <a href="#css_01_0410__section1147716276219">Querying and Deleting Created Patterns</a>.</li><li id="css_01_0410__li20906161442213"><a name="css_01_0410__li20906161442213"></a><a name="li20906161442213"></a>Perform <a href="#css_01_0410__section1012905085616">Stopping Index Synchronization</a> in the secondary cluster. Then redirect read and write traffic to it. If the primary and secondary clusters synchronize indexes based on index patterns, use a wildcard to match indexes when running the command that stops index synchronization.</li><li id="css_01_0410__li1850739132913">After the primary cluster recovers, configure information about the secondary cluster in the primary cluster, and connect the primary and secondary clusters again. For details, see <a href="#css_01_0410__section1023014371242">Connecting the Primary and Secondary Clusters</a>.</li><li id="css_01_0410__li1378912702410">Under the primary cluster, perform <a href="#css_01_0410__section97051931358">Index Synchronization</a> to synchronize data from the secondary cluster to the primary cluster, and then perform a primary/secondary switchover to switch back.</li></ol>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<div class="familylinks">
|
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="css_01_0111.html">Enhancing Search Capabilities for Elasticsearch Clusters</a></div>
|
|
</div>
|
|
</div>
|
|
|