DELETE CLUSTER 语句会删除指定的集群及其 名称。一旦删除集群,它将从所有节点中移除,但其表保持完整并成为活动的本地非复制表。
- SQL
- JSON
- PHP
- Python
- Python-asyncio
- javascript
- Java
- C#
- Rust
DELETE CLUSTER click_queryPOST /cli -d "DELETE CLUSTER click_query"$params = [
'cluster' => 'click_query',
'body' => []
];
$response = $client->cluster()->delete($params);utilsApi.sql('DELETE CLUSTER click_query')await utilsApi.sql('DELETE CLUSTER click_query')res = await utilsApi.sql('DELETE CLUSTER click_query');utilsApi.sql("DELETE CLUSTER click_query");utilsApi.Sql("DELETE CLUSTER click_query");utils_api.Sql("DELETE CLUSTER click_query", Some(true)).await;{u'error': u'', u'total': 0, u'warning': u''}{u'error': u'', u'total': 0, u'warning': u''}{"total":0,"error":"","warning":""}ALTER CLUSTER <cluster_name> ADD <table_name>[, <table_name>] 将一个或多个现有的本地表添加到集群中。接收ALTER查询的节点将表发送到集群中的其他节点。集群中其他节点上具有相同名称的所有本地表将被新表替换。
一旦表被复制,可以在任何节点上执行写入语句,但表名必须以集群名称前缀,例如 INSERT INTO <clusterName>:<table_name>。
- SQL
- JSON
- PHP
- Python
- Python-asyncio
- javascript
- Java
- C#
- Rust
ALTER CLUSTER click_query ADD clicks_daily_indexPOST /cli -d "
ALTER CLUSTER click_query ADD clicks_daily_index
"$params = [
'cluster' => 'click_query',
'body' => [
'operation' => 'add',
'table' => 'clicks_daily_index'
]
];
$response = $client->cluster()->alter($params);utilsApi.sql('ALTER CLUSTER click_query ADD clicks_daily_index')await utilsApi.sql('ALTER CLUSTER click_query ADD clicks_daily_index')res = await utilsApi.sql('ALTER CLUSTER click_query ADD clicks_daily_index');utilsApi.sql("ALTER CLUSTER click_query ADD clicks_daily_index");utilsApi.Sql("ALTER CLUSTER click_query ADD clicks_daily_index");utils_api.sql("ALTER CLUSTER click_query ADD clicks_daily_index", Some(true)).await;{u'error': u'', u'total': 0, u'warning': u''}{"total":0,"error":"","warning":""}ALTER CLUSTER <cluster_name> DROP <table_name>[, <table_name>] 忘记一个或多个现有的表,这意味着它不会删除节点上的表文件,而是使它们变为无效,未复制的表。
一旦从集群中移除一个表,它就成为本地表,写入语句必须仅使用表名,例如 INSERT INTO <table_name>,而不需要集群前缀。
- SQL
- JSON
- PHP
- Python
- Python-asyncio
- javascript
- Java
- C#
- Rust
ALTER CLUSTER posts DROP weekly_indexPOST /cli -d "
ALTER CLUSTER posts DROP weekly_index
"$params = [
'cluster' => 'posts',
'body' => [
'operation' => 'drop',
'table' => 'weekly_index'
]
];
$response = $client->cluster->alter($params);utilsApi.sql('ALTER CLUSTER posts DROP weekly_index')await utilsApi.sql('ALTER CLUSTER posts DROP weekly_index')res = await utilsApi.sql('ALTER CLUSTER posts DROP weekly_index');utilsApi.sql("ALTER CLUSTER posts DROP weekly_index");utilsApi.Sql("ALTER CLUSTER posts DROP weekly_index");utils_api.sql("ALTER CLUSTER posts DROP weekly_index", Some(true)).await;{u'error': u'', u'total': 0, u'warning': u''}{u'error': u'', u'total': 0, u'warning': u''}{"total":0,"error":"","warning":""}ALTER CLUSTER <cluster_name> UPDATE nodes 语句将每个节点内的指定集群中的节点列表更新为包括集群中的所有活动节点。有关节点列表的更多信息,请参见加入集群。
- SQL
- JSON
- PHP
- Python
- Python-asyncio
- javascript
- Java
- C#
- Rust
ALTER CLUSTER posts UPDATE nodesPOST /cli -d "
ALTER CLUSTER posts UPDATE nodes
"$params = [
'cluster' => 'posts',
'body' => [
'operation' => 'update',
]
];
$response = $client->cluster()->alter($params);utilsApi.sql('ALTER CLUSTER posts UPDATE nodes')await utilsApi.sql('ALTER CLUSTER posts UPDATE nodes')res = await utilsApi.sql('ALTER CLUSTER posts UPDATE nodes');utilsApi.sql("ALTER CLUSTER posts UPDATE nodes");utilsApi.Sql("ALTER CLUSTER posts UPDATE nodes");utils_api.sql("ALTER CLUSTER posts UPDATE nodes", Some(true)).await;{u'error': u'', u'total': 0, u'warning': u''}{u'error': u'', u'total': 0, u'warning': u''}{"total":0,"error":"","warning":""}例如,当集群最初建立时,用于重新加入集群的节点列表是 10.10.0.1:9312,10.10.1.1:9312。此后,其他节点加入了集群,现在活动节点是 10.10.0.1:9312,10.10.1.1:9312,10.15.0.1:9312,10.15.0.3:9312。然而,用于重新加入集群的节点列表没有更新。
要纠正这一点,可以运行 ALTER CLUSTER ... UPDATE nodes 语句将活动节点列表复制到用于重新加入集群的节点列表。这样,用于重新加入集群的节点列表将包括集群中的所有活动节点。
两个节点列表都可以通过使用 集群状态 语句 (cluster_post_nodes_set 和 cluster_post_nodes_view) 查看。
要从复制集群中移除节点,请按照以下步骤操作:
- 停止节点
- 从已停止节点的
<data_dir>/manticore.json(通常是/var/lib/manticore/manticore.json)中删除集群信息。 - 在集群中的其他节点上运行
ALTER CLUSTER cluster_name UPDATE nodes。
完成这些步骤后,其他节点将忘记已分离的节点,而已分离的节点将忘记集群。此操作不会影响集群中的表或已分离节点上的表。
您可以通过检查节点状态来查看集群状态信息。可以使用节点状态命令来完成,此命令显示关于节点的各种信息,包括集群状态变量。
集群状态变量的输出格式如下:cluster_name_variable_name variable_value。大多数变量已在Galera 文档状态变量中进行了描述。除了这些变量外,Manticore Search 还显示:
cluster_name- 集群名称,定义于复制设置node_state- 节点当前状态:closed、destroyed、joining、donor、syncedindexes_count- 集群管理的表的数量indexes- 集群管理的表名列表nodes_set- 使用CREATE、JOIN或ALTER UPDATE命令定义的集群中的节点列表nodes_view- 当前节点可见的集群实际节点列表state_uuid- 集群的 UUID 状态。如果它与 local_state_uuid 的值匹配,则本地和集群节点同步conf_id- 发生的集群成员变更总数status- 集群组件状态。可能的值为 primary(主组配置,有法定人数)、non_primary(非主组配置,失去法定人数)或 disconnected(未连接到组,正在重试)size- 当前集群中的节点数量local_index- 节点在集群中的索引last_error- 与集群操作相关的最后一条记录错误消息。消息提供问题的高级摘要。有关更详细的上下文,您应查看searchd.log文件。
在状态快照传输(SST)期间,一个节点通过传输完整数据副本为另一个节点提供资源。当新节点加入集群JOIN CLUSTER或添加新表ALTER CLUSTER ADD时,会发生此操作。当 SST 正在进行时,以下额外的状态变量会在供体和加入节点上可用,其进度保持同步。
cluster_name_sst_total- 整个 SST 操作的总体进度,从 0 到 100。是主要的计数器。cluster_name_sst_stage- 当前工作阶段的名称。此过程为每个传输的表循环经过以下阶段:await nodes syncblock checksum calculateanalyze remotesend filesactivate tables
cluster_name_sst_stage_total- 当前阶段的进度,从 0 到 100。cluster_name_sst_tables- SST 中传输的表的总数。cluster_name_sst_table- 当前处理的表的名称和索引(例如,3 (products))。
对于大多数用例,cluster_name_sst_total 就足够了。但其他计数器在调查特定 SST 阶段或特定表的停顿或性能问题时非常有用。
- SQL
- JSON
- PHP
- Python
- Python-asyncio
- javascript
- Java
- C#
- Rust
SHOW STATUSPOST /cli -d "
SHOW STATUS
"$params = [
'body' => []
];
$response = $client->nodes()->status($params);utilsApi.sql('SHOW STATUS')await utilsApi.sql('SHOW STATUS')res = await utilsApi.sql('SHOW STATUS');utilsApi.sql("SHOW STATUS");utilsApi.sql("SHOW STATUS");utils_api.sql("SHOW STATUS", Some(true)).await;+---------------------------------+-------------------------------------------------------------------------------------+
| Counter | Value |
+---------------------------------+-------------------------------------------------------------------------------------+
| cluster_name | post |
| cluster_post_state_uuid | fba97c45-36df-11e9-a84e-eb09d14b8ea7 |
| cluster_post_conf_id | 1 |
| cluster_post_status | primary |
| cluster_post_size | 5 |
| cluster_post_local_index | 0 |
| cluster_post_node_state | donor |
| cluster_post_indexes_count | 2 |
| cluster_post_indexes | pq1,pq_posts |
| cluster_post_nodes_set | 10.10.0.1:9312 |
| cluster_post_nodes_view | 10.10.0.1:9312,10.10.0.1:9320:replication,10.10.1.1:9312,10.10.1.1:9320:replication |
| cluster_post_sst_total | 65 |
| cluster_post_sst_stage | send files |
| cluster_post_sst_stage_total | 78 |
| cluster_post_sst_tables | 5 |
| cluster_post_sst_table | 3 (products) |
+---------------------------------+-------------------------------------------------------------------------------------+"
{"columns":[{"Counter":{"type":"string"}},{"Value":{"type":"string"}}],
"data":[
{"Counter":"cluster_name", "Value":"post"},
{"Counter":"cluster_post_state_uuid", "Value":"fba97c45-36df-11e9-a84e-eb09d14b8ea7"},
{"Counter":"cluster_post_conf_id", "Value":"1"},
{"Counter":"cluster_post_status", "Value":"primary"},
{"Counter":"cluster_post_size", "Value":"5"},
{"Counter":"cluster_post_local_index", "Value":"0"},
{"Counter":"cluster_post_node_state", "Value":"donor"},
{"Counter":"cluster_post_indexes_count", "Value":"2"},
{"Counter":"cluster_post_indexes", "Value":"pq1,pq_posts"},
{"Counter":"cluster_post_nodes_set", "Value":"10.10.0.1:9312"},
{"Counter":"cluster_post_nodes_view", "Value":"10.10.0.1:9312,10.10.0.1:9320:replication,10.10.1.1:9312,10.10.1.1:9320:replication"},
{"Counter":"cluster_post_sst_total", "Value":"65"},
{"Counter":"cluster_post_sst_stage", "Value":"send files"},
{"Counter":"cluster_post_sst_stage_total", "Value":"78"},
{"Counter":"cluster_post_sst_tables", "Value":"5"},
{"Counter":"cluster_post_sst_table", "Value":"3 (products)"}
],
"total":0,
"error":"",
"warning":""
}(
"cluster_name" => "post",
"cluster_post_state_uuid" => "fba97c45-36df-11e9-a84e-eb09d14b8ea7",
"cluster_post_conf_id" => 1,
"cluster_post_status" => "primary",
"cluster_post_size" => 5,
"cluster_post_local_index" => 0,
"cluster_post_node_state" => "donor",
"cluster_post_indexes_count" => 2,
"cluster_post_indexes" => "pq1,pq_posts",
"cluster_post_nodes_set" => "10.10.0.1:9312",
"cluster_post_nodes_view" => "10.10.0.1:9312,10.10.0.1:9320:replication,10.10.1.1:9312,10.10.1.1:9320:replication",
"cluster_post_sst_total" => 65,
"cluster_post_sst_stage" => "send files",
"cluster_post_sst_stage_total" => 78,
"cluster_post_sst_tables" => 5,
"cluster_post_sst_table" => "3 (products)"
){u'columns': [{u'Key': {u'type': u'string'}},
{u'Value': {u'type': u'string'}}],
u'data': [
{u'Key': u'cluster_name', u'Value': u'post'},
{u'Key': u'cluster_post_state_uuid', u'Value': u'fba97c45-36df-11e9-a84e-eb09d14b8ea7'},
{u'Key': u'cluster_post_conf_id', u'Value': u'1'},
{u'Key': u'cluster_post_status', u'Value': u'primary'},
{u'Key': u'cluster_post_size', u'Value': u'5'},
{u'Key': u'cluster_post_local_index', u'Value': u'0'},
{u'Key': u'cluster_post_node_state', u'Value': u'donor'},
{u'Key': u'cluster_post_indexes_count', u'Value': u'2'},
{u'Key': u'cluster_post_indexes', u'Value': u'pq1,pq_posts'},
{u'Key': u'cluster_post_nodes_set', u'Value': u'10.10.0.1:9312'},
{u'Key': u'cluster_post_nodes_view', u'Value': u'10.10.0.1:9312,10.10.0.1:9320:replication,10.10.1.1:9312,10.10.1.1:9320:replication'},
{u'Key': u'cluster_post_sst_total', u'Value': u'65'},
{u'Key': u'cluster_post_sst_stage', u'Value': u'send files'},
{u'Key': u'cluster_post_sst_stage_total', u'Value': u'78'},
{u'Key': u'cluster_post_sst_tables', u'Value': u'5'},
{u'Key': u'cluster_post_sst_table', u'Value': u'3 (products)'}],
u'error': u'',
u'total': 0,
u'warning': u''}{u'columns': [{u'Key': {u'type': u'string'}},
{u'Value': {u'type': u'string'}}],
u'data': [
{u'Key': u'cluster_name', u'Value': u'post'},
{u'Key': u'cluster_post_state_uuid', u'Value': u'fba97c45-36df-11e9-a84e-eb09d14b8ea7'},
{u'Key': u'cluster_post_conf_id', u'Value': u'1'},
{u'Key': u'cluster_post_status', u'Value': u'primary'},
{u'Key': u'cluster_post_size', u'Value': u'5'},
{u'Key': u'cluster_post_local_index', u'Value': u'0'},
{u'Key': u'cluster_post_node_state', u'Value': u'donor'},
{u'Key': u'cluster_post_indexes_count', u'Value': u'2'},
{u'Key': u'cluster_post_indexes', u'Value': u'pq1,pq_posts'},
{u'Key': u'cluster_post_nodes_set', u'Value': u'10.10.0.1:9312'},
{u'Key': u'cluster_post_nodes_view', u'Value': u'10.10.0.1:9312,10.10.0.1:9320:replication,10.10.1.1:9312,10.10.1.1:9320:replication'},
{u'Key': u'cluster_post_sst_total', u'Value': u'65'},
{u'Key': u'cluster_post_sst_stage', u'Value': u'send files'},
{u'Key': u'cluster_post_sst_stage_total', u'Value': u'78'},
{u'Key': u'cluster_post_sst_tables', u'Value': u'5'},
{u'Key': u'cluster_post_sst_table', u'Value': u'3 (products)'}],
u'error': u'',
u'total': 0,
u'warning': u''}{"columns": [{"Key": {"type": "string"}},
{"Value": {"type": "string"}}],
"data": [
{"Key": "cluster_name", "Value": "post"},
{"Key": "cluster_post_state_uuid", "Value": "fba97c45-36df-11e9-a84e-eb09d14b8ea7"},
{"Key": "cluster_post_conf_id", "Value": "1"},
{"Key": "cluster_post_status", "Value": "primary"},
{"Key": "cluster_post_size", "Value": "5"},
{"Key": "cluster_post_local_index", "Value": "0"},
{"Key": "cluster_post_node_state", "Value": "donor"},
{"Key": "cluster_post_indexes_count", "Value": "2"},
{"Key": "cluster_post_indexes", "Value": "pq1,pq_posts"},
{"Key": "cluster_post_nodes_set", "Value": "10.10.0.1:9312"},
{"Key": "cluster_post_nodes_view", "Value": "10.10.0.1:9312,10.10.0.1:9320:replication,10.10.1.1:9312,10.10.1.1:9320:replication"},
{"Key": "cluster_post_sst_total", "Value": "65"},
{"Key": "cluster_post_sst_stage", "Value": "send files"},
{"Key": "cluster_post_sst_stage_total", "Value": "78"},
{"Key": "cluster_post_sst_tables", "Value": "5"},
{"Key": "cluster_post_sst_table", "Value": "3 (products)"}],
"error": "",
"total": 0,
"warning": ""}{columns=[{ Key : { type=string }},
{ Value : { type=string }}],
data : [
{ Key=cluster_name, Value=post},
{ Key=cluster_post_state_uuid, Value=fba97c45-36df-11e9-a84e-eb09d14b8ea7},
{ Key=cluster_post_conf_id, Value=1},
{ Key=cluster_post_status, Value=primary},
{ Key=cluster_post_size, Value=5},
{ Key=cluster_post_local_index, Value=0},
{ Key=cluster_post_node_state, Value=donor},
{ Key=cluster_post_indexes_count, Value=2},
{ Key=cluster_post_indexes, Value=pq1,pq_posts},
{ Key=cluster_post_nodes_set, Value=10.10.0.1:9312},
{ Key=cluster_post_nodes_view, Value=10.10.0.1:9312,10.10.0.1:9320:replication,10.10.1.1:9312,10.10.1.1:9320:replication},
{ Key=cluster_post_sst_total, Value=65},
{ Key=cluster_post_sst_stage, Value=send files},
{ Key=cluster_post_sst_stage_total, Value=78},
{ Key=cluster_post_sst_tables, Value=5},
{ Key=cluster_post_sst_table, Value=3 (products)}],
error= ,
total=0,
warning= }{columns=[{ Key : { type=String }},
{ Value : { type=String }}],
data : [
{ Key=cluster_name, Value=post},
{ Key=cluster_post_state_uuid, Value=fba97c45-36df-11e9-a84e-eb09d14b8ea7},
{ Key=cluster_post_conf_id, Value=1},
{ Key=cluster_post_status, Value=primary},
{ Key=cluster_post_size, Value=5},
{ Key=cluster_post_local_index, Value=0},
{ Key=cluster_post_node_state, Value=donor},
{ Key=cluster_post_indexes_count, Value=2},
{ Key=cluster_post_indexes, Value=pq1,pq_posts},
{ Key=cluster_post_nodes_set, Value=10.10.0.1:9312},
{ Key=cluster_post_nodes_view, Value=10.10.0.1:9312,10.10.0.1:9320:replication,10.10.1.1:9312,10.10.1.1:9320:replication},
{ Key=cluster_post_sst_total, Value=65},
{ Key=cluster_post_sst_stage, Value=send files},
{ Key=cluster_post_sst_stage_total, Value=78},
{ Key=cluster_post_sst_tables, Value=5},
{ Key=cluster_post_sst_table, Value=3 (products)}],
error="" ,
total=0,
warning="" }{columns=[{ Key : { type=String }},
{ Value : { type=String }}],
data : [
{ Key=cluster_name, Value=post},
{ Key=cluster_post_state_uuid, Value=fba97c45-36df-11e9-a84e-eb09d14b8ea7},
{ Key=cluster_post_conf_id, Value=1},
{ Key=cluster_post_status, Value=primary},
{ Key=cluster_post_size, Value=5},
{ Key=cluster_post_local_index, Value=0},
{ Key=cluster_post_node_state, Value=donor},
{ Key=cluster_post_indexes_count, Value=2},
{ Key=cluster_post_indexes, Value=pq1,pq_posts},
{ Key=cluster_post_nodes_set, Value=10.10.0.1:9312},
{ Key=cluster_post_nodes_view, Value=10.10.0.1:9312,10.10.0.1:9320:replication,10.10.1.1:9312,10.10.1.1:9320:replication},
{ Key=cluster_post_sst_total, Value=65},
{ Key=cluster_post_sst_stage, Value=send files},
{ Key=cluster_post_sst_stage_total, Value=78},
{ Key=cluster_post_sst_tables, Value=5},
{ Key=cluster_post_sst_table, Value=3 (products)}],
error="" ,
total=0,
warning="" }