Elasticsearch部署问题
问题
Elasticsearch启动报错:Exception in thread “main” java.nio.file.AccessDeniedException
编辑 / etc/sudoers 文件:
1 | vim /etc/sudoers |
在下面添加一行:
1 | es ALL=(ALL) ALL |
没有权限
1 | chown -R smarthome:smarthome /home/smarthome/elasticsearch/ |
[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535]
文件权限不足
在 / etc/security/limits.conf 中添加如下内容
1 | vi /etc/security/limits.conf |
1 | ulimit -Hn |
[2]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
虚拟内存分配不足
1 | sysctl -w vm.max_map_count=262144 |
然后在 /etc/sysctl.conf 文件最后添加一行
1 | vm.max_map_count=262144 |
输入命令:sysctl -p
立即生效
OpenJDK 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0 and will likely be removed in a future release.
修改 jvm.options 文件配置vim /etc/elasticsearch/jvm.options
,将
1 | -XX:+UseConcMarkSweepGC 改为 -XX:+UseG1GC |
索引
创建索引
1 | # PUT请求 |
删除索引
1 | # 删除单个 |
查询索引
1 | # GET请求 |
maybe these locations are not writable or multiple nodes were started without increasing
这个错误的原因是因为之前用root用户启动了es,之后切换用户运行就会报这个错误
解决
删除ES配置目录下data目录中的nodes文件,然后用非ROOT用户启动就能解决了
参考
- https://www.elastic.co/guide/en/elasticsearch/reference/current/rest-apis.html
- https://blog.csdn.net/username666/article/details/105034364
- https://blog.csdn.net/chenshm/article/details/124264078
- https://blog.csdn.net/qq_43655835/article/details/104633359
- https://blog.csdn.net/username666/article/details/105034364
- https://blog.csdn.net/zhezhebie/article/details/105481989
- https://www.cnblogs.com/TidalCoast1034/p/15766836.html
- https://unsplash.com/photos/ToTlbvvI_uc