1 手动移动shard到指定节点
src node : 172.18.58.108 nodename 0kJKhMq9TuSBbYCOjkh1Gw indexName call_record primaryshard 0
destination node : 172.18.58.107 nodename 7YS_Dv6pSR-dwCe9CQ1baA
10 seconds
Last 1 hour
POST /_cluster/reroute
{
"commands": [
{
"move": {
"index": "call_record", "shard": 0,
"from_node": "0kJKhMq9TuSBbYCOjkh1Gw", "to_node": "7YS_Dv6pSR-dwCe9CQ1baA"
}
}
]
}
172.18.58.98 VaSwze4-SR646yN4O7rlxw v2_course_progress
172.18.58.249 9AKXOM_sT06SKs7UbYyvHg
POST /_cluster/reroute
{
"commands": [
{
"move": {
"index": "v2_course_progress", "shard": 4,
"from_node": "VaSwze4-SR646yN4O7rlxw", "to_node": "9AKXOM_sT06SKs7UbYyvHg"
}
}
]
}
2 重建索引
# 只读
PUT v2_course_progress/_settings
{
"index": {
"blocks.read_only": true
}
}
*#* 确认只读生效
GET v2_course_progress/_settings
*#* 记录原始文档数
GET v2_course_progress/_count
*#* 重建索引 todo:增加batch的步长
POST _reindex?wait_for_completion=false
{
"source": {
"index": "v2_course_progress"
},
"dest": {
"index": "v3_course_progress"
}
}
*#*确认新索引文档数
GET v3_course_progress/_count
*#* 取消只读
PUT v2_course_progress/_settings
{
"index": {
"blocks.read_only": false
}
}
*#* 修改原有的索引别名
POST /_aliases
{
"actions" : [
{ "remove" : { "index" : "v2_course_progress", "alias" : "course_progress" } },
{ "add" : { "index" : "v2_course_progress", "alias" : "unuse_course_progress" } }
]
}
*#*启用新索引
POST /_aliases
{
"actions" : [
{ "add" : { "index" : "v3_course_progress", "alias" : "course_progress" } }
]
}
//返回 task
"task" : "bwWAKYnqR_y14q_KQxhB0g:25317045"
//查看task状态
GET /_tasks/bwWAKYnqR_y14q_KQxhB0g:25317045
//取消task
POST _tasks/task_id:1/_cancel
*#* 确认新索引正常工作之后 再删除旧索引
DELETE v2_course_progress
添加新的字段 与修改原有字段的属性
create index
PUT student
{
"mappings": {
"doc": {
"properties": {
"timestamp": {
"type": "date"
},
"name": {
"type": "text"
},
"age":{
"type": "long"
}
}
}
}
}
#1: add keyword
PUT student/_mapping/_doc
{
"properties": {
"age": {
"type": "long",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
}
#2 add new field
PUT student/_mapping/_doc
{
"properties": {
"summary": {
"type": "text"
}
}
}
3修改索引副本数
PUT base_index/_settings
{
"number_of_replicas": 1
}```
网友评论