You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Secondary indexes can be replicated across cluster-nodes.
37
-
This ensures:
38
+
[.edition]#{enterprise}#
38
39
39
-
* _Availability_: If one Index-Service node is lost, the other continues to provide access to replicated indexes.
40
-
* _High Performance_: If original and replica copies are available, incoming queries are load-balanced across them.
40
+
You can replicate primary and secondary indexes across cluster nodes running the {index-service}[Index Service].
41
+
This feature is available only in Couchbase Server Enterprise Edition.
42
+
Index replication has the following benefits:
41
43
42
-
Index-replicas can be created with the {sqlpp}`CREATE INDEX` statement.
43
-
Note that whenever a given number of index-replicas is specified for creation, the number must be less than the number of cluster-nodes currently running the {index-service}[Index Service].
44
-
If it is not, the index creation fails.
45
-
Note also that if, following creation of the maximum number of copies, the number of nodes running the Index Service decreases, Couchbase Server progressively assigns replacement index-replicas to any and all Index-Service nodes subsequently be added to the cluster, until the required number of index-replicas again exists for each replicated index.
44
+
* *Availability*: If one Index Service node is lost, the others continues to provide access to replicated indexes.
45
+
* *High Performance*: If original and replica copies are available, incoming queries are load-balanced across them.
46
46
47
-
Index-replicas can be created as follows:
47
+
If the number of nodes running the Index Service decreases, and index replicas are lost, Couchbase Server progressively assigns replacement index replicas to all Index Service nodes subsequently added to the cluster, until the required number of index replicas again exists for each replicated index.
48
48
49
-
* Specifying, by means of the `WITH` clause, the destination nodes.
49
+
=== Creating Index Replicas for a Single Index
50
+
51
+
You can create index replicas using the {sqlpp} {createindex}[CREATE INDEX] and {createprimaryindex}[CREATE PRIMARY INDEX] statements.
52
+
53
+
To create index replicas for a single index, do one of the following:
54
+
55
+
* In the `WITH` clause, use the `nodes` attribute to specify the destination nodes.
56
+
When you use this attribute by itself, the index is placed on one of the destination nodes, and one replica is placed on each of the others.
57
+
+
50
58
In the following example, an index with two replicas is created.
51
59
The active index is on `node1`, and the replicas are on `node2` and `node3`:
52
60
+
@@ -56,44 +64,55 @@ The active index is on `node1`, and the replicas are on `node2` and `node3`:
* Specifying _no_ destination nodes; but specifying instead, by means of the `WITH` clause and the `num_replica` attribute, only the _number_ of replicas required.
60
-
The replicas are automatically distributed across those nodes of the cluster that are running the Index Service: the distribution-pattern is based on a projection of optimal index-availability, given the number and disposition of Index-Service nodes across defined server-groups.
67
+
* In the `WITH` clause, use the `num_replica` attribute to specify the number of replicas required.
68
+
When you use this attribute by itself, the index and the required number of replicas are automatically distributed across Index Service nodes.
69
+
The distribution pattern is based on a projection of optimal index availability, given the number and disposition of Index Service nodes across defined server groups.
70
+
The required number of replicas must be smaller than the number of cluster nodes currently running the Index Service.
71
+
If it's not, the index creation fails.
61
72
+
62
73
In the following example, an index is created with two replicas, with no destination-nodes specified:
Note that if `nodes` and `num_replica` are both specified in the `WITH` clause, the specified number of nodes must be _one greater_ than `num_replica`.
70
79
71
-
* Specifying a number of index-replicas to be created by the Index Service whenever `CREATE INDEX` is invoked.
72
-
The default is `0`.
73
-
If the default is changed to, say, `2`, creation of a single index is henceforth accompanied by the creation of two replicas, which are automatically distributed across the nodes of the cluster running the Index Service.
74
-
No explicit specification within the `CREATE INDEX` statement is required.
75
-
+
76
-
With credentials that provide appropriate authorization, this default can be changed by means of the `curl` command, as follows:
77
-
+
80
+
* In the `WITH` clause, use the `nodes` and `num_replica` attributes together.
81
+
In this case, the Index planner chooses from the set of specified nodes to place the index and the required number of replicas.
82
+
The required number of replicas must be smaller than the number of specified nodes.
83
+
If it's not, the index creation fails.
84
+
85
+
For more information on using {sqlpp}, see {query}[].
86
+
87
+
=== Creating Index Replicas Automatically
88
+
89
+
The Index Service can create a number of index replicas automatically whenever {createindex}[CREATE INDEX] or {createprimaryindex}[CREATE PRIMARY INDEX] is invoked.
90
+
The default number of replicas is `0`.
91
+
For example, if you change the number of automatic replicas to `2`, from that point on creation of a single index is accompanied by the creation of two replicas, which are automatically distributed across the nodes of the cluster running the Index Service.
92
+
No explicit specification is required within the {sqlpp} statement.
93
+
94
+
The following example changes the index replication settings using the GSI Settings REST API:
95
+
78
96
[source,sh]
79
97
----
80
98
curl -X POST -u 'Administrator:password' \
81
99
'http://localhost:8091/settings/indexes' \
82
100
-d 'numReplica=2'
83
101
----
84
-
+
85
-
Here, `numReplica` is an integer that establishes the default number of replicas that must be created whenever `CREATE INDEX` is invoked.
86
-
Note that this call only succeeds if the cluster contains enough Index Service nodes to host each new index and its replicas: for example, if `2` is specified as the default number of replicas, the Index Service must have been established on at least 3 nodes.
87
-
+
88
-
Note also that whenever explicit specification of replica-numbers is made within the `CREATE INDEX` statement, this explicit specification takes precedence over any established default.
89
102
90
-
You can change index replication settings via the {index-storage-mode}[UI] or the {index-settings-via-rest}[REST API].
91
-
For further information on using {sqlpp}, refer to {query}[Query Fundamentals].
103
+
Here, `numReplica` is an integer that establishes the default number of replicas that must be created whenever an index is created.
104
+
This call only succeeds if the cluster contains enough Index Service nodes to host each new index and its replicas: for example, if you specify `2` as the default number of replicas, the Index Service must have been established on at least 3 nodes.
105
+
106
+
When you explicitly specify the number of replicas with the {createindex}[CREATE INDEX] or {createprimaryindex}[CREATE PRIMARY INDEX] statement, the explicit specification takes precedence over the index replication settings.
107
+
108
+
You can change the index replication settings using the {index-storage-mode}[UI], the {index-storage-settings-via-cli}[CLI], or the {index-settings-via-rest}[REST API].
92
109
93
110
[[index-partitioning]]
94
111
== Index Partitioning
95
112
96
-
_Index Partitioning_ increases query performance, by dividing and spreading a large index of documents across multiple nodes. This feature is available only in Couchbase Server Enterprise Edition.
113
+
[.edition]#{enterprise}#
114
+
115
+
Index partitioning increases query performance, by dividing and spreading a large index of documents across multiple nodes. This feature is available only in Couchbase Server Enterprise Edition.
97
116
98
117
The benefits include:
99
118
@@ -105,23 +124,25 @@ The benefits include:
105
124
106
125
* Provision of a low-latency range query, while allowing indexes to be scaled out as needed.
107
126
108
-
For detailed information, refer to {index-partitioning}[Index Partitioning].
127
+
For more information, see {index-partitioning}[Index Partitioning].
109
128
110
129
[[index-consistency]]
111
130
== Index Consistency
112
131
113
132
(((scan consistency)))
114
133
(((consistency)))
115
134
(((consistent)))
116
-
Whereas Couchbase Server handles data-mutations with _full consistency_ — all mutations to a given key are applied to the same vBucket, and become immediately available — it maintains indexes with degrees of _eventual consistency_, determined by means of the following query consistency-options, specified per query:
135
+
Couchbase Server handles data mutations with full consistency — all mutations to a given key are applied to the same vBucket, and become immediately available.
136
+
In contrast, Couchbase Server maintains indexes with degrees of eventual consistency.
137
+
For every query, you can specify the following consistency options:
117
138
118
139
// tag::scan_consistency[]
119
140
* `not_bounded`: Executes the query immediately, without requiring any consistency for the query.
120
-
If index-maintenance is running behind, out-of-date results may be returned.
141
+
If indexmaintenance is running behind, out-of-date results may be returned.
121
142
* `at_plus`: Executes the query, requiring indexes first to be updated to the timestamp of the last update.
122
-
If index-maintenance is running behind, the query waits for it to catch up.
123
-
* `request_plus`: Executes the query, requiring the indexes first to be updated to the timestamp of the current query-request.
124
-
If index-maintenance is running behind, the query waits for it to catch up.
143
+
If indexmaintenance is running behind, the query waits for it to catch up.
144
+
* `request_plus`: Executes the query, requiring the indexes first to be updated to the timestamp of the current queryrequest.
145
+
If indexmaintenance is running behind, the query waits for it to catch up.
125
146
* `statement_plus`: Executes the query with strong consistency per statement.
126
147
Before processing each statement, the service obtains a current vector timestamp and uses it as a lower bound for that statement.
127
148
@@ -133,8 +154,8 @@ You can specify the scan consistency via the {query-preferences}[run-time prefer
133
154
[[index-snapshots]]
134
155
== Index Snapshots
135
156
136
-
One or more _index snapshots_ are maintained on disk, to permit rapid recovery if node-failures are experienced.
137
-
In cases where recovery requires an Index-Service node to be restarted, the node’s indexes are rebuilt from the snapshots retained on disk.
157
+
Couchbase Server maintains one or more index snapshots on disk, to permit rapid recovery if nodes fail.
158
+
In cases where recovery requires an IndexService node to be restarted, the node's indexes are rebuilt from the snapshots retained on disk.
138
159
139
160
By default, two index snapshots are stored on disk.
140
161
You can change index snapshot settings via the {index-storage-settings-via-cli}[CLI] or the {index-settings-via-rest}[REST API].
Copy file name to clipboardExpand all lines: modules/n1ql/pages/n1ql-language-reference/createindex.adoc
+14-8Lines changed: 14 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -318,21 +318,25 @@ nodes;;
318
318
****
319
319
[.edition]#{community}#
320
320
321
-
In Couchbase Server Community Edition, a single global secondary index can be placed on a single node that runs the indexing service.
322
-
The `nodes` property allows you to specify the node that the index is placed on.
323
-
(((default index placement)))If `nodes` is not specified, one of the nodes running the indexing service is randomly picked for the index.
321
+
In Couchbase Server Community Edition, a single secondary index of type `GSI` can be placed on a single node that runs the Indexing Service.
322
+
The `nodes` property enables you to specify the node that the index is placed on.
323
+
(((default index placement)))If `nodes` is not specified, the Index planner may place the index on any of the nodes running the Indexing Service.
324
324
****
325
325
+
326
326
****
327
327
[.edition]#{enterprise}#
328
328
329
-
In Couchbase Server Enterprise Edition, you can specify multiple nodes to distribute replicas of an index across nodes running the indexing service: for example, `WITH {"nodes": ["node1:8091", "node2:8091", "node3:8091"]}`.
329
+
In Couchbase Server Enterprise Edition, you can specify multiple nodes to distribute replicas of an index across nodes running the Indexing Service: for example, `WITH {"nodes": ["node1:8091", "node2:8091", "node3:8091"]}`.
330
330
For details and examples, refer to {index-replication}[Index Replication].
331
331
332
-
If specifying both [.var]`nodes` and [.var]`num_replica`, the number of nodes in the array must be one greater than the specified number of replicas otherwise the index creation will fail.
333
-
334
-
(((default index placement)))If [.var]`nodes` is not specified, then the system chooses nodes on which to place the new index and any replicas, in order to achieve the best resource utilization across nodes running the indexing service.
332
+
(((default index placement)))If `nodes` is not specified, then the system places the new index and any replicas on any of the nodes running the Indexing Service, in order to achieve the best resource utilization.
335
333
This is done by taking into account the current resource usage statistics of index nodes.
334
+
335
+
If you specify the `nodes` property by itself, the index is placed on one of the destination nodes, and a replica is placed on each of the others.
336
+
337
+
If you specify both `nodes` and `num_replica`, the Index planner chooses from the set of specified nodes to place the index and its replicas.
338
+
In this case, the number of nodes in the array must be greater than the specified number of replicas.
339
+
Otherwise, the index creation fails.
336
340
****
337
341
+
338
342
IMPORTANT: A node name passed to the `nodes` property must include the cluster administration port, by default 8091.
@@ -362,7 +366,9 @@ This property is only available in Couchbase Server Enterprise Edition.
362
366
The indexer will automatically distribute these replicas amongst index nodes in the cluster for load-balancing and high availability purposes.
363
367
The indexer will attempt to distribute the replicas based on the server groups in use in the cluster where possible.
364
368
365
-
If the value of this property is not less than the number of index nodes in the cluster, then the index creation will fail.
369
+
The number of replicas must be lower than the number of index nodes in the cluster.
370
+
If `nodes` is specified, the number of replicas must be lower than the number of nodes in the array.
Copy file name to clipboardExpand all lines: modules/n1ql/pages/n1ql-language-reference/createprimaryindex.adoc
+14-8Lines changed: 14 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -204,21 +204,25 @@ nodes;;
204
204
****
205
205
[.edition]#{community}#
206
206
207
-
In Couchbase Server Community Edition, a single primary index of type `GSI` can be placed on a single node that runs the indexing service.
208
-
The `nodes` property allows you to specify the node that the index is placed on.
209
-
(((default index placement)))If `nodes` is not specified, one of the nodes running the indexing service is randomly picked for the index.
207
+
In Couchbase Server Community Edition, a single primary index of type `GSI` can be placed on a single node that runs the Indexing Service.
208
+
The `nodes` property enables you to specify the node that the index is placed on.
209
+
(((default index placement)))If `nodes` is not specified, the Index planner may place the index on any of the nodes running the Indexing Service.
210
210
****
211
211
+
212
212
****
213
213
[.edition]#{enterprise}#
214
214
215
-
In Couchbase Server Enterprise Edition, you can specify multiple nodes to distribute replicas of an index across nodes running the indexing service: for example, `WITH {"nodes": ["node1:8091", "node2:8091", "node3:8091"]}`.
215
+
In Couchbase Server Enterprise Edition, you can specify multiple nodes to distribute replicas of an index across nodes running the Indexing Service: for example, `WITH {"nodes": ["node1:8091", "node2:8091", "node3:8091"]}`.
216
216
For details and examples, refer to {index-replication}[Index Replication].
217
217
218
-
If specifying both [.var]`nodes` and [.var]`num_replica`, the number of nodes in the array must be one greater than the specified number of replicas otherwise the index creation will fail.
219
-
220
-
(((default index placement)))If [.var]`nodes` is not specified, then the system chooses nodes on which to place the new index and any replicas, in order to achieve the best resource utilization across nodes running the indexing service.
218
+
(((default index placement)))If `nodes` is not specified, then the system places the new index and any replicas on any of the nodes running the Indexing Service, in order to achieve the best resource utilization.
221
219
This is done by taking into account the current resource usage statistics of index nodes.
220
+
221
+
If you specify the `nodes` property by itself, the index is placed on one of the destination nodes, and a replica is placed on each of the others.
222
+
223
+
If you specify both `nodes` and `num_replica`, the Index planner chooses from the set of specified nodes to place the index and its replicas.
224
+
In this case, the number of nodes in the array must be greater than the specified number of replicas.
225
+
Otherwise, the index creation fails.
222
226
****
223
227
+
224
228
IMPORTANT: A node name passed to the `nodes` property must include the cluster administration port, by default 8091.
@@ -248,7 +252,9 @@ This property is only available in Couchbase Server Enterprise Edition.
248
252
The indexer will automatically distribute these replicas amongst index nodes in the cluster for load-balancing and high availability purposes.
249
253
The indexer will attempt to distribute the replicas based on the server groups in use in the cluster where possible.
250
254
251
-
If the value of this property is not less than the number of index nodes in the cluster, then the index creation will fail.
255
+
The number of replicas must be lower than the number of index nodes in the cluster.
256
+
If `nodes` is specified, the number of replicas must be lower than the number of nodes in the array.
Copy file name to clipboardExpand all lines: modules/n1ql/pages/n1ql-language-reference/index-partitioning.adoc
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -534,6 +534,10 @@ CREATE INDEX idx_pe12 ON route
534
534
----
535
535
====
536
536
537
+
When you specify a node list for a partitioned index, the Index Service places the partitions according to the available resources on the specified nodes.
538
+
For example, if you create an index with 8 partitions and specify a list of 8 nodes, the Index Service does not necessarily place 1 partition on each node.
539
+
Rather, the Index Service considers the resource usage on each of the specified nodes, and may choose to place the partitions on 4 of them.
540
+
537
541
If you create a partitioned index on a specific set of nodes, and then decide that you want to specify a different set of nodes for partition placement, you need to remove the partitioned index and then recreate the partitioned index on a smaller or greater number of nodes.
538
542
However, refer also to the section on <<rebalancing,rebalancing a partitioned index>> below.
0 commit comments