虚拟机中的ES不能访问问题解决

今天遇到一个问题即在linux虚拟机中的elasticsearch不能在宿主机上访问?

系统版本:CentOS 7

elasticsearch版本:最新版的7.5.2

JDK版本:JDK13

说明:好像7.5.2最低使用环境是JDK11

第一个反应:难道不能ping通?

之后我试了试两边都能ping通。嗯,不是这个问题...

第二个想法是9200没开?

确实没开,但是开了之后还是不行,网上有说开80端口。试了之后还是虚拟机我行我素....B了狗了,最后我把防火墙关了....重启es还是不行

最后在网上找到一个说是在es的配置文件中地址设置有三种:

1、network.host   这个是内网地址,你可以设成127.0.0.1(这个好像是默认的)

2、network.publish  这个是发布地址,这个是唯一用在集群通信上的

3、重点来了,network.bind_host  这个就是我们要改的,设置这个可以让es绑定多个ip,因此我们可以把外网和内网ip都配上,相同云平台用内网ip访问,不同云平台用外网ip访问;

     嗯,最后我这个设置成network.bind_host: 0.0.0.0

这个详细的看这里:https://blog.csdn.net/totally123/article/details/79569537

友情提示:yml格式在冒号后面有空格哦;

哦,还有一点就是设置了这个之后好像会报

ERROR: [1] bootstrap checks failed
[1]: 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]引导检查失败

[1] :默认发现设置不适合生产使用;必须至少配置[discovery.seed_hosts,discovery.seed_providers,cluster.initial_master_nodes]之一

那么把yml配置文件中的cluster.initial_master_nodes属性改成当前节点名称就好了...

到此这个es就可以在宿主机上访问es了。

我想了想,还是把我的配置文件内容加上。网上的大佬,如果有不对的地方多指教!!!

# ---------------------------------- Cluster -----------------------------------
#
# Use a descriptive name for your cluster:
#
#cluster.name: my-application
#集群名称
cluster.name: bigdata
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
#node.name: node-1
#节点名称
node.name: hadoop-1
#
# Add custom attributes to the node:
#
#node.attr.rack: r1
#
# ----------------------------------- Paths ------------------------------------
#
# Path to directory where to store the data (separate multiple locations by comma):
#
#path.data: /path/to/data
path.data: /home/es/data/elastic
#
# Path to log files:
#
#path.logs: /path/to/logs
path.logs: /home/es/logs/elastic
#
# ----------------------------------- Memory -----------------------------------
#
# Lock the memory on startup:
#内存锁,防止es的内存被交换出去;我理解的是防止它的内存被用作其他用处
#一般生产环境会用,自己测试的话....无所谓啦!!!
#bootstrap.memory_lock: true
#
# Make sure that the heap size is set to about half the memory available
# on the system and that the owner of the process is allowed to use this
# limit.
#
# Elasticsearch performs poorly when the system is swapping the memory.
#
# ---------------------------------- Network -----------------------------------
#
# Set the bind address to a specific IP (IPv4 or IPv6):
#
#network.host: 192.168.0.1
#内网地址
network.host: ES01
#发布地地址
#network.publish_host: 
#绑定IP
network.bind_host: 0.0.0.0

# Set a custom port for HTTP:
#
#http.port: 9200
#设置访问端口 如果不设置的话默认也是9200,在集群中节点可以按照启动顺序确定主节点。
#一般启动的第一个es端口号为9200,第二个为9201依次类推
http.port: 9200
#
# For more information, consult the network module documentation.
#
# --------------------------------- Discovery ----------------------------------
#
# Pass an initial list of hosts to perform discovery when this node is started:
# The default list of hosts is ["127.0.0.1", "[::1]"]
#
#discovery.seed_hosts: ["host1", "host2"]
#
# Bootstrap the cluster using an initial set of master-eligible nodes:
#
#cluster.initial_master_nodes: ["node-1", "node-2"]
#初始主节点
cluster.initial_master_nodes: ["hadoop-1"]
#
# For more information, consult the discovery and cluster formation module documentation.
# 是否允许其他插件访问,这个是我后加的7.5.2版本没有这个属性
http.cors.enabled: true
#星号我理解的是所有插件都可以的意思
http.cors.allow-origin: "*"
#
#
# ---------------------------------- Gateway -----------------------------------
#
# Block initial recovery after a full cluster restart until N nodes are started:
#这个是文件备份,集群中节点数量为3的时候备份数据
#gateway.recover_after_nodes: 3
#
# For more information, consult the gateway module documentation.
#
# ---------------------------------- Various -----------------------------------
#
# Require explicit names when deleting indices:
#
#action.destructive_requires_name: true

 

 

 

  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

人在西北刚上线

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值