admin管理员组

文章数量:1624785

目录

  • 1 遇到的问题
  • 2 解决方法


想学习架构师构建流程请跳转:Java架构师系统架构设计

1 遇到的问题

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

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

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

2 解决方法

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]

elasticsearch用户拥有的内存权限太小,至少需要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

看提示可知:缺少默认配置,至少需要配置

discovery.seed_hosts/discovery.seed_providers/cluster.initial_master_nodes中的一个参数.

discovery.seed_hosts: 集群主机列表
discovery.seed_providers: 基于配置文件配置集群主机列表
cluster.initial_master_nodes: 启动时初始化的参与选主的node,生产环境必填

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

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

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

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

本文标签: Elasticsearchip