虛擬機中的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

 

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章