环境
elasticsearch7.* 遇到的问题
异常一
报错信息
"type" : "parse_exception", "reason" : "unknown key [setting] for create index"
{ "error" : { "root_cause" : [ { "type" : "parse_exception", "reason" : "unknown key [mapping] for create index" } ], "type" : "parse_exception", "reason" : "unknown key [mapping] for create index" }, "status" : 400 }
解决办法
原因:索引构建问题,仔细核对是否和我的索引格式一致,有问题欢迎留言。
1.curl方式
curl - H "Content-Type: application/json" - XPUT 'http://127.0.0.1:9200/temporary_index_test1' - d '{ "settings": { "index": { "number_of_shards": 5, "number_of_replicas": 1 } }, "mappings": { "properties": { "news_id": { "type": "long" }, "news_title": { "type": "text" }, "news_content": { "type": "text" } } } }'
2.插件方式
{ "settings": { "index": { "number_of_shards": 5, "number_of_replicas": 1 } }, "mappings": { "properties": { "news_id": { "type": "long" }, "news_title": { "type": "text" }, "news_content": { "type": "text" } } } }
异常二
报错
报错1:max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
解决办法
解决方案:在 /etc/security/limits.conf
中添加一下信息(sudo vi 修改),重新登录才生效
* soft nofile 65536 * hard nofile 65536
异常三
报错
报错2:memory locking requested for elasticsearch process but memory is not locked
解决方法
解决方案:在 /etc/security/limits.conf
中添加一下信息(sudo vi 修改),重新登录才生效
* soft memlock unlimited * hard memlock unlimited
异常四
报错
报错3:max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
解决
解决方案:在 /etc/sysctl.conf
中添加一下信息(sudo vi 修改),再执行 sudo sysctl -p 载入sysctl配置文件,重新登录才生效
vm.max_map_count=262144
实战视频
pub哥肝了一套elasticsearch新闻搜索实战教程,需要请在【JavaPub】公众号无套路领取。
我是 JavaPub,三观很正,乐于创业,喜欢烹饪。今年已近年中,各位小伙伴一定已经拿到自己心仪的offer,但是不要忘记进步,共勉