Elasticsearch搭建问题汇总

1. can not run elasticsearch as root

因为安全问题elasticsearch 不让用root用户直接运行,所以要创建新用户

  1. 新建用户
[root@localhost bin]# adduser test
  1. 为新用户设置密码
[root@localhost bin]# passwd test
更改用户 test 的密码 。
新的 密码:
无效的密码: 密码少于 8 个字符
重新输入新的 密码:
passwd:所有的身份验证令牌已经成功更新。

密码少于8个字符会有提示但依然可以使用

  1. 给新用户赋权elasticsearch安装目录
[root@localhost software]# chown -R test elasticsearch-7.6.2
  1. 切换至新用户启动
[root@localhost bin]# su test
[test@localhost bin]$ ./elasticsearch
  1. 启动后测试
    输入curl ip:9200,如果返回一个json数据说明启动成功

2. ES启动后使用IP端口无法访问

问题:es成功启动后输入curl localhost:9200可以正常返回json,使用http://localhost:9200/可以正常访问,但是使用http://ip:9200/无法访问
解决办法:
修改elasticsearch.yml文件

vi config/elasticsearch.yml

取消注释network.host并改为0.0.0.0

network.host: 0.0.0.0

3. max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535]

切换到root用户,编辑limits.conf文件

vi /etc/security/limits.conf

添加下面内容

* soft nofile 65536
* hard nofile 65536

其中 * 代表所有用户也可以指定具体用户
此文件修改后需要重新登录用户,才会生效
登录后使用ulimit -Sn/ulimit -Hn查看

4. max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

切换到root用户,编辑sysctl.conf 文件

vi /etc/sysctl.conf

增加配置

vm.max_map_count=262144

执行命令sysctl -p使配置生效

5. the default discovery settings are unsuitable for production use; at least one of [discovery.seed_hosts, discovery.seed_providers, cluster.initial_master_nodes] must be configured

修改elasticsearch.yml

vi config/elasticsearch.yml

取消cluster.initial_master_nodes注释并保留一个节点

cluster.initial_master_nodes: ["node-1"]

后台启动es

nohup ./elasticsearch &

原文地址:https://www.cnblogs.com/dawnyxl/p/13140955.html