解决 ES 在Centos只能本地访问的问题

问题

  • 本地 curl
curl 127.0.0.1:9200 

在这里插入图片描述

  • 换成 ip 来curl
curl 192.168.xxx.xxx:9200

显示访问不了 ╮(╯▽╰)╭

  • 查看端口
netstat -anp | grep 9200

在这里插入图片描述
ps: 请注意,这个时候红框显示的是 127.0.0.1,而不是 0.0.0.0,修好了懒得给回去,哈哈哈😜

解决

显然,这是配置设置了只能本地访问的问题,改一下就好,这里引用了另一篇文章来解决:

https://blog.csdn.net/wf_76/article/details/94630922

这篇文章有个不太适合我的地方,就是有些得切换为 elastic 用户操作(es 的启动需要 非root用户,不哟啊问我为什么,我也不知道🤦‍),有的切换为 root 用户操作 。

  • 修改/elasticsearch-x.x.x/configconfig/elasticsearch.yml配置
su root
vim /elasticsearch-x.x.x/configconfig/elasticsearch.yml
  • 增加以下内容
network.host: 0.0.0.0
http.port: 9200
  • 启动 ES
su elasitc 
cd ~
./elasticsearch-x.x.x/bin/elasticsearch
  • 按照引用文章的流程,问题不出意料的出现了,虽然我还期待就此完成,(●’◡’●)
ERROR: [2] bootstrap checks failed
[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
[2]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
  • 修改 /etc/security/limits.conf 文件:
su root
vim /etc/security/limits.conf
  • 增加配置:
	   *               soft    nofile          65536
	   *               hard    nofile          65536
	   *               soft    noproc         4096
	   *               hard    noproc         4096
  • 重新启动 ES,但还是躲避不了预见的错误,/(ㄒoㄒ)/~~
ERROR: [1] bootstrap checks failed
[1]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
  • 修改 /etc/sysctl.conf
su root
vim  /etc/sysctl.conf
  • 添加配置
vm.max_map_count=262144
  • 重新启动 ES
  • 查看端口
    在这里插入图片描述- 外网访问,搞定 o( ̄▽ ̄)ブ
    在这里插入图片描述
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值