云服务器上安装 Elasticsearch7.x,外网无法通过 ip:9200 访问?

云服务器安装 elasticsearch,解压elasticsearch之后,启动,通过 http://localhost:9200 可以访问的到,但是 http://ip:9200 访问不到,怎么办呢?解决如下

首先,需要明确自己的 Elasticsearch版本信息

我安装的 Elasticsearch 版本为 7.9.3

其次,明确自己的部署环境。我使用的 华为云的 HECS(云耀云服务器)

1vCPUs | 2GB CentOS 7.6 64bit

1. 问题:为什么使用外网 ip:9200 访问不了?

Elasticsearch 默认只能通过 localhost/127.0.0.1本机环回地址访问 。如需要设置支持其他 ip 访问需要设置配置文件的 network.host 参数。去掉 network.host 的注释,即 network.host 为 '0.0.0.0'。

修改完后,重现启动。继续报错。

2. ERROR: [2] bootstrap checks failed 问题报错

  • [1]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
  • [2]: 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

问题1: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=655360
并执行命令:
sysctl -p

问题2 : 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

往 yml 文件中添加下面的配置
node.name: node-1
cluster.initial_master_nodes: [“node-1”]

解决完上边问题之后,发现主机内网IP:9200 能正常访问,但是 外网 IP:9200 仍然无法访问。这是为什么呢?

这就关系到华为云安全组配置的问题。其他像阿里云、腾讯云也是有安全组的概念,所以如果使用云服务器部署的还需要考虑安全组的配置问题,

关于华为云的安全组相关文档位置如下:

https://support.huaweicloud.com/usermanual-ecs/zh-cn_topic_0030878383.html

解决完上边的报错问题后,浏览器输入 IP:9200 会返回如下正常外网页面

猜你喜欢

转载自blog.csdn.net/qq_36148847/article/details/109325591