我是靠谱客的博主 大气眼神,这篇文章主要介绍虚拟机中的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格式在冒号后面有空格哦;

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

复制代码
1
2
3
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了。

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

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# ---------------------------------- 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

 

 

 

最后

以上就是大气眼神最近收集整理的关于虚拟机中的ES不能访问问题解决的全部内容,更多相关虚拟机中内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(54)

评论列表共有 0 条评论

立即
投稿
返回
顶部