Es 集羣搭建

參考文檔:

https://www.elastic.co/guide/en/elasticsearch/reference/8.3/index.html

https://www.elastic.co/guide/en/elasticsearch/reference/8.3/important-settings.html

https://www.elastic.co/guide/en/elasticsearch/reference/8.3/advanced-configuration.html#set-jvm-options

 

本文主要介紹elasticsearch-8.3.2 集羣安裝 -簡易版

1、JVM相關配置 

參考:https://www.elastic.co/guide/en/elasticsearch/reference/8.3/advanced-configuration.html#set-jvm-options

(1)、配置JVM內存

官方建議:Set Xms and Xmx to no more than 50% of your total memory. Elasticsearch requires memory for purposes other than the JVM heap. For example, Elasticsearch uses off-heap buffers for efficient network communication and relies on the operating system’s filesystem cache for efficient access to files. The JVM itself also requires some memory. It’s normal for Elasticsearch to use more memory than the limit configured with the Xmx setting.

修改jvm.options文件在config目錄下,調整以下參數:

-Xms2g
-Xmx2g

這裏設爲2g得原因是,本地內存不太夠.

 

2、集羣配置 

(1)、集羣名稱

官方介紹:A node can only join a cluster when it shares its cluster.name with all the other nodes in the cluster. The default name is elasticsearch, but you should change it to an appropriate name that describes the purpose of the cluster.

修改elasticsearch.yml文件在config目錄下,調整以下參數:

cluster.name: test_cluster

 

3、集羣節點配置

(1)、節點名稱

官方介紹:

Elasticsearch uses node.name as a human-readable identifier for a particular instance of Elasticsearch. This name is included in the response of many APIs. The node name defaults to the hostname of the machine when Elasticsearch starts, but can be configured explicitly in elasticsearch.yml:

修改elasticsearch.yml文件在config目錄下,調整以下參數:

node.name: node-1

 

4、集羣網絡配置

(1)、network.host 設置

官方介紹:

(Static) Sets the address of this node for both HTTP and transport traffic. The node will bind to this address and will also use it as its publish address. Accepts an IP address, a hostname, or a special value.

注意以下官方說明:

By default, Elasticsearch only binds to loopback addresses such as 127.0.0.1 and [::1]. This is sufficient to run a cluster of one or more nodes on a single server for development and testing, but a resilient production cluster must involve nodes on other servers. There are many network settings but usually all you need to configure is network.host:

When you provide a value for network.host, Elasticsearch assumes that you are moving from development mode to production mode, and upgrades a number of system startup checks from warnings to exceptions. See the differences between development and production modes.

修改elasticsearch.yml文件在config目錄下,調整以下參數:

network.host: 0.0.0.0

 

(4)、http.port設置

官方介紹:

(Static) The port to bind for HTTP client communication. Accepts a single value or a range. If a range is specified, the node will bind to the first available port in the range.

Defaults to 9200-9300.

修改elasticsearch.yml文件在config目錄下,增加以下參數:

http.port: 9200

注:不設置,默認是9200

 

(5)、transport.port設置

官方介紹:

(Static) The port to bind for communication between nodes. Accepts a single value or a range. If a range is specified, the node will bind to the first available port in the range. Set this setting to a single port, not a range, on every master-eligible node.

Defaults to 9300-9400.

修改elasticsearch.yml文件在config目錄下,調整以下參數:

transport.port: 9300

 

5、集羣發現相關配置

官方介紹:Configure two important discovery and cluster formation settings before going to production so that nodes in the cluster can discover each other and elect a master node.

(1)、discovery.seed_hosts

官方介紹:

Out of the box, without any network configuration, Elasticsearch will bind to the available loopback addresses and scan local ports 9300 to 9305 to connect with other nodes running on the same server. This behavior provides an auto-clustering experience without having to do any configuration.

When you want to form a cluster with nodes on other hosts, use the static discovery.seed_hosts setting. This setting provides a list of other nodes in the cluster that are master-eligible and likely to be live and contactable to seed the discovery process. This setting accepts a YAML sequence or array of the addresses of all the master-eligible nodes in the cluster. Each address can be either an IP address or a hostname that resolves to one or more IP addresses via DNS.

 

(2)、cluster.initial_master_nodes

 

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