elasticsearch 5.4安装

来源:互联网 发布:维特根斯坦 知乎 编辑:程序博客网 时间:2024/06/15 22:57

Elasticsearch 5.4版本安装包下载地址:

https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.4.0.tar.gz


1:修改系统相关文件

  1.1: 设置内核参数:

  vim /etc/sysctl.conf

  添加如下内容:

 vm.swappiness = 1

 fs.file-max=65536

 vm.max_map_count=262144

之后可以使用sysctla查看 –p刷新


 1.2: 设置资源参数:



vim /etc/security/limits.conf

添加如下内容:

root soft nofile 65536

root hard nofile 131072

* soft nofile 65536

* hard nofile 131072

* soft nproc 2048

* hard nproc 4096

hadoop soft memlock unlimited

hadoop hard memlock unlimited    


上面hadoop是我用hadoop用户启动es集群 所以添加了hadoop用户的memlock


1.3  修改进程数:

  vim /etc/security/limits.d/90-nproc.conf

   修改( * soft nproc )的值为2048


上面三个小步骤是关机重启后同样生效,  现在想临时生效设置方式执行:

ulimit -n 65536

swapoff -a

sysctl -w vm.max_map_count=262144

ulimit -u 2048


系统相关参数说明见官网:

https://www.elastic.co/guide/en/elasticsearch/reference/5.4/setup-configuration-memory.html






2es安装包下载下来,解压修改配置文件      elasticsearch.yml

第一台主节点配置如下:




#======================== Elasticsearch Configuration =========================

#

# NOTE: Elasticsearch comes with reasonable defaults for most settings.

#       Before you set out to tweak and tune the configuration, make sure you

#       understand what are you trying to accomplish and the consequences.

#

# The primary way of configuring a node is via this file. This template lists

# the most important settings you may want to configure for a production cluster.

#

# Please consult the documentation for further information on configuration options:

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

#

# ---------------------------------- Cluster -----------------------------------

#

# Use a descriptive name for your cluster:

#

 cluster.name: escluster

#

# ------------------------------------ Node ------------------------------------

#

# Use a descriptive name for the node:

#

 node.name: es-master

 node.master: true

 node.data: false

#

# 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: /hadoopdata/EsDataLog/data

#

# Path to log files:

#

 path.logs: /hadoopdata/EsDataLog/log

#

# ----------------------------------- Memory -----------------------------------

#

# Lock the memory on startup:

#

 bootstrap.memory_lock: true

 bootstrap.system_call_filter: false

 http.cors.enabled: true

 http.cors.allow-origin: "*"

 http.cors.allow-headers: "Authorization"

# xpack.security.enabled: true

# xpack.monitoring.enabled: true

# xpack.graph.enabled: true

# xpack.watcher.enabled: true

# xpack.reporting.enabled: 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: X.X.X.X

#

# Set a custom port for HTTP:

#

 http.port: 9200

#

# For more information, consult the network module documentation.

#

# --------------------------------- Discovery ----------------------------------

#

# Pass an initial list of hosts to perform discovery when new node is started:

# The default list of hosts is ["127.0.0.1", "[::1]"]

#

# discovery.zen.ping.multicast.enabled: false

 discovery.zen.ping.unicast.hosts:["X.X.X.X","X.X.X.X","X.X.X.X","X.X.X.X","X.X.X.X","X.X.X.X"]

 discovery.zen.ping_timeout: 120s

 discovery.zen.fd.ping_timeout: 120s

 discovery.zen.fd.ping_retries: 10

#

# Prevent the "split brain" by configuring the majority of nodes (total number of master-eligible nodes / 2 + 1):

#

# discovery.zen.minimum_master_nodes: 3

#

# For more information, consult the zen discovery module documentation.

#

# ---------------------------------- Gateway -----------------------------------

#

# Block initial recovery after a full cluster restart until N nodes are started:

#

#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




第一台是主节点,其他节点是数据节点改下相应其他机器的ip地址为下面配置:

network.host

node.master: false  (由于第一个配置是master等于true,所以其他节点false)

node.data: true   (其他节点是数据节点,所以改为true)

 

 

 

修改:jvm.options配置文件

 

heap相应的大小,根据你机器内存设置,一般为内存的1/2,

最大不能超过64G 超过后,适得其反

 我改完如下:


  -Xms18g
  -Xmx18g


配置完毕后 启动es:

bin/elasticsearch -d

 

以上安装es5.4完毕。