vi /etc/security/limits.conf 增加两行
es soft memlock unlimited
es hard memlock unlimited
vi config/elasticsearch.yml 增加
bootstrap.memory_lock: true
查看状态
curl -XGET 'localhost:9200/_nodes?filter_path=**.mlockall&pretty'
--生产环境
--关闭分片自动迁移
curl -XPUT 'localhost:9200/_cluster/settings?pretty' -H 'Content-Type: application/json' -d'
{
"persistent" : {
"cluster.routing.allocation.enable" : "none"
}
}
'
--打开分片自动迁移
curl -XPUT 'localhost:9200/_cluster/settings?pretty' -H 'Content-Type: application/json' -d'
{
"persistent" : {
"cluster.routing.allocation.enable" : "all"
}
}
'
--文档表
curl -XPUT 127.0.0.1:9200/document?pretty -d '
{
"settings" : {
"index" : {
"number_of_shards" : 3 ,
"number_of_replicas" : 0
}
},
"mappings" : {
"document" : {
"properties" : {
"lib_id" : {
"type" : "long"
},
"text" : {
"type" : "string",
"index" : "analyzed",
"analyzer" : "ik_max_word"
}
}
}
}
}'
/*id结构 uuid$序号 */
curl -XPUT 127.0.0.1:9200/fragment?pretty -d '
{
"settings" : {
"index" : {
"number_of_shards" : 3 ,
"number_of_replicas" : 0
}
},
"mappings" : {
"fragment" : {
"properties" : {
"lib_id" : {
"type" : "long"},
"text" : {"type" : "string",
"index" : "analyzed",
"analyzer": "ik_smart",
"search_analyzer": "ik_max_word"
}
}
}
}
}'
--netcache date为yyyyMMdd的Long类型
curl -XPUT 127.0.0.1:9200/net_cache?pretty -d '
{
"settings" : {
"index" : {
"number_of_shards" : 4,
"number_of_replicas" : 0
}
},
"mappings" : {
"net_cache" : {
"properties" : {
"result_flag" : {
"type" : "long"
},
"date" : {
"type" : "long"
},
"data" : {
"type" : "string",
"index" : "not_analyzed"
}
}
}
}
}'
--userlib
curl -XPUT 127.0.0.1:9200/user_lib?pretty -d '
{
"settings" : {
"index" : {
"number_of_shards" : 1,
"number_of_replicas" : 0
}
},
"mappings" : {
"user_lib" : {
"properties" : {
"lib_id" : {
"type" : "long"
},
"text" : {
"type" : "string",
"index" : "analyzed",
"analyzer" : "ik_max_word"
},
"org_uuid" : {
"type" : "string",
"index" : "not_analyzed"
},
"user_uuid" : {
"type" : "string",
"index" : "not_analyzed"
},
"dir_uuid" : {
"type" : "string",
"index" : "not_analyzed"
},
"auto_clear" : {
"type" : "long"
},
"timestamp" : {
"type" : "long"
},
"source" : {
"type" : "string",
"index" : "not_analyzed"
}
}
}
}
}'
curl -XPUT 127.0.0.1:9200/literature?pretty -d '
{
"settings" : {
"index" : {
"number_of_shards" : 1,
"number_of_replicas" : 0
}
},
"mappings" : {
"literature" : {
"properties" : {
"article_id" : {
"type" : "string",
"index" : "not_analyzed"
},
"lib_id" : {
"type" : "long"
},
"source" : {
"type" : "string",
"index" : "not_analyzed"
}
}
}
}
}'
--索引分片部署
curl -XPOST '192.168.1.101:9200/_cluster/reroute?pretty' -d '{
"commands" : [ {
"move" : {
"index" : "paper", "shard" : 1,
"from_node" : "node-100-2", "to_node" : "node-100-1"
}
} ]
}'