To join an existing cluster name and any working node should be set. In case of a single cluster path might be omitted, data_dir will be used as the cluster path. For all subsequent clusters path needs to be set and it should be available.
JOIN CLUSTER posts AT '10.12.1.35:9312'
POST /sql -d "mode=raw&query=
JOIN CLUSTER posts AT '10.12.1.35:9312'
"
$params = [
'cluster' => 'posts',
'body' => [
'10.12.1.35:9312'
]
];
$response = $client->cluster->join($params);
utilsApi.sql('mode=raw&query=JOIN CLUSTER posts AT \'10.12.1.35:9312\'')
res = await utilsApi.sql('mode=raw&query=JOIN CLUSTER posts AT \'10.12.1.35:9312\'');
utilsApi.sql("mode=raw&query=JOIN CLUSTER posts AT '10.12.1.35:9312'");
{u'error': u'', u'total': 0, u'warning': u''}
{"total":0,"error":"","warning":""}
A node joins a cluster by getting the data from the node provided and, if successful, it updates node lists in all the other cluster nodes similar to ALTER CLUSTER ... UPDATE nodes. This list is used to rejoin nodes to the cluster on restart.
There are two lists of nodes. One is used to rejoin nodes to the cluster on restart, it is updated across all nodes same way as ALTER CLUSTER ... UPDATE nodes does. JOIN CLUSTER does the same update automatically. Cluster status shows this list as cluster_post_nodes_set. The second list is a list of all active nodes used for replication. This list doesn't require manual management. ALTER CLUSTER ... UPDATE nodes actually copies this list of nodes to the list of nodes used to rejoin on restart. Cluster status shows this list as cluster_post_nodes_view.
When nodes are located at different network segments or in different datacenters nodes option may be set explicitly. That allows to minimize traffic between nodes and to use gateway nodes for datacenters intercommunication. The following command joins an existing cluster using the nodes option.
Note: that when this syntax is used, cluster_post_nodes_set list is not updated automatically. Use ALTER CLUSTER ... UPDATE nodes to update it.
JOIN CLUSTER click_query 'clicks_mirror1:9312;clicks_mirror2:9312;clicks_mirror3:9312' as nodes
POST /sql -d "mode=raw&query=
JOIN CLUSTER click_query 'clicks_mirror1:9312;clicks_mirror2:9312;clicks_mirror3:9312' as nodes
"
$params = [
'cluster' => 'posts',
'body' => [
'nodes' => 'clicks_mirror1:9312;clicks_mirror2:9312;clicks_mirror3:9312'
]
];
$response = $client->cluster->join($params);
utilsApi.sql('mode=raw&query=JOIN CLUSTER click_query \'clicks_mirror1:9312;clicks_mirror2:9312;clicks_mirror3:9312\' as nodes')
res = await utilsApi.sql('mode=raw&query=JOIN CLUSTER click_query \'clicks_mirror1:9312;clicks_mirror2:9312;clicks_mirror3:9312\' as nodes');
utilsApi.sql("mode=raw&query=JOIN CLUSTER click_query 'clicks_mirror1:9312;clicks_mirror2:9312;clicks_mirror3:9312' as nodes");
{u'error': u'', u'total': 0, u'warning': u''}
{"total":0,"error":"","warning":""}
JOIN CLUSTER completes when a node receives all the necessary data to be in sync with all the other nodes in the cluster.
Last modified: June 24, 2021
Delete statement removes a cluster specified with name. The cluster gets removed from all the nodes, but its indexes are left intact and become active local non-replicated indexes.
DELETE CLUSTER click_query
POST /sql -d "mode=raw&query=DELETE CLUSTER click_query"
$params = [
'cluster' => 'click_query',
'body' => []
];
$response = $client->cluster()->delete($params);
utilsApi.sql('mode=raw&query=DELETE CLUSTER click_query')
res = await utilsApi.sql('mode=raw&query=DELETE CLUSTER click_query');
utilsApi.sql("mode=raw&query=DELETE CLUSTER click_query");
{u'error': u'', u'total': 0, u'warning': u''}
{"total":0,"error":"","warning":""}
Last modified: February 10, 2021
ALTER CLUSTER <cluster_name> ADD <index_name> adds an existing local index to the cluster. The node which receives the ALTER query sends the index to the other nodes in the cluster. All the local indexes with the same name on the other nodes of the cluster get replaced with the new index.
After the index is replicated, write statements can be performed on any node but index name must be prefixed with the cluster name like INSERT INTO <clusterName>:<indexName>.
ALTER CLUSTER click_query ADD clicks_daily_index
POST /sql -d "mode=raw&query=
ALTER CLUSTER click_query ADD clicks_daily_index
"
$params = [
'cluster' => 'click_query',
'body' => [
'operation' => 'add',
'index' => 'clicks_daily_index'
]
];
$response = $client->cluster()->alter($params);
utilsApi.sql('mode=raw&query=ALTER CLUSTER click_query ADD clicks_daily_index')
res = await utilsApi.sql('mode=raw&query=ALTER CLUSTER click_query ADD clicks_daily_index');
utilsApi.sql("mode=raw&query=ALTER CLUSTER click_query ADD clicks_daily_index");
{u'error': u'', u'total': 0, u'warning': u''}
{"total":0,"error":"","warning":""}
ALTER CLUSTER <cluster_name> DROP <index_name> forgets about a local index, i.e., it doesn't remove the index files on the nodes but just makes it an active non-replicated index.
After an index is removed from a cluster, it becomes a 'local' index and write statements must use just the index name as INSERT INTO <indexName>, without the cluster prefix.
ALTER CLUSTER posts DROP weekly_index
POST /sql -d "mode=raw&query=
ALTER CLUSTER posts DROP weekly_index
"
$params = [
'cluster' => 'posts',
'body' => [
'operation' => 'drop',
'index' => 'weekly_index'
]
];
$response = $client->cluster->alter($params);
utilsApi.sql('mode=raw&query=ALTER CLUSTER posts DROP weekly_index')
res = await utilsApi.sql('mode=raw&query=ALTER CLUSTER posts DROP weekly_index');
utilsApi.sql("mode=raw&query=ALTER CLUSTER posts DROP weekly_index");
{u'error': u'', u'total': 0, u'warning': u''}
{"total":0,"error":"","warning":""}
Last modified: February 26, 2021
ALTER CLUSTER <cluster_name> UPDATE nodes statement updates node lists on each node of the cluster to include every active node in the cluster. See Joining a cluster for more info on node lists.
ALTER CLUSTER posts UPDATE nodes
POST /sql -d "mode=raw&query=
ALTER CLUSTER posts UPDATE nodes
"
$params = [
'cluster' => 'posts',
'body' => [
'operation' => 'update',
]
];
$response = $client->cluster()->alter($params);
utilsApi.sql('mode=raw&query=ALTER CLUSTER posts UPDATE nodes')
res = await utilsApi.sql('mode=raw&query=ALTER CLUSTER posts UPDATE nodes');
utilsApi.sql("mode=raw&query=ALTER CLUSTER posts UPDATE nodes");
{u'error': u'', u'total': 0, u'warning': u''}
{"total":0,"error":"","warning":""}
For example, when the cluster was initially created, the list of nodes used for rejoining the cluster was 10.10.0.1:9312,10.10.1.1:9312. Since then other nodes joined the cluster and now we have the following active nodes: 10.10.0.1:9312,10.10.1.1:9312,10.15.0.1:9312,10.15.0.3:9312.
But the list of nodes used for rejoining the cluster is still the same. Running the ALTER CLUSTER ... UPDATE nodes copies the list of active nodes to the list of nodes used to rejoin on restart. After this, the list of nodes used on restart includes all the active nodes in the cluster.
Both lists of nodes can be viewed using Cluster status statement (cluster_post_nodes_set and cluster_post_nodes_view).
To remove a node from a replication cluster you need to:
- stop the node
- remove info about the cluster in
<data_dir>/manticore.json (/var/lib/manticore/manticore.json in most cases) on the node you've stopped
- run
ALTER CLUSTER cluster_name UPDATE nodes on any other node
After this the other nodes will forget about the detached node and the node will forget about the cluster. It won't impact indexes neither in the cluster nor on the detached node.
Last modified: June 24, 2021