下载地址:https://www.elastic.co/cn/downloads 假设系统安装好了对应的jdk,且jdk的版本要高于8。下面是具体的安装步骤。
tar -xzvf elasticsearch-6.4.3.tar.gz
groupadd elasticsearch
useradd elasticsearch -g elasticsearch
chown -R elasticsearch:elasticsearch /home/ivan/elasticsearch-6.4.3/
# ======================== 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 -----------------------------------
#
#集群的名称
#
cluster.name: ivan_test
#
# ------------------------------------ Node ------------------------------------
#
# 节点的名称
#
node.name: package4
#
# Add custom attributes to the node:
#
#node.attr.rack: r1
#
# ----------------------------------- Paths ------------------------------------
#
#配置你存数据的目录
#
path.data: /home/ivan/elasticsearch-6.4.3/data
#
# 配置你存日志的目录
#
path.logs: /home/ivan/elasticsearch-6.4.3/logs
#
# ----------------------------------- Memory -----------------------------------
#
# Lock the memory on startup: 这两个配置用于解决下面的问题,否则会报错
#
bootstrap.memory_lock: false
bootstrap.system_call_filter: false
#
# 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):
#需要配置成本面的ip,否则外部无法访问
#
network.host: 对应机器的ip
#
# Set a custom port for HTTP:
#
#http.port: 9200
http.cors.enabled: true
http.cors.allow-origin: "*"
# 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.unicast.hosts: ["host1", "host2"]
#
# Prevent the "split brain" by configuring the majority of nodes (total number of master-eligible nodes / 2 + 1):
#
#discovery.zen.minimum_master_nodes:
#
# 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
1: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
#增加如下两行
* hard nofile 65536
* soft nofile 65536
注:ubuntu下需要通过ulimit -n 65536 命令
2: max number of threads [1024] for user [elasticsearch] is too low, increase to at least [4096]
* soft nproc 4096
3: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
vm.max_map_count=655360
并执行命令:sysctl -p
4: system call filters failed to install; check the logs and fix your configuration or disable system call filters at your own risk
bootstrap.memory_lock: false
bootstrap.system_call_filter: false
5:the minimum required Java version is 8; your Java version from [/usr/local/java/jdk7/jre] does not meet this requirement。
export JAVA_HOME=/usr/local/java/jdk1.8.0_121
export PATH=${JAVA_HOME}/bin:$PATH
6:正常启动后,通过远程机器无法访问,
http.cors.enabled: true
http.cors.allow-origin: "*"
如果还没办法访问, 注意系统的防火墙,可能通过如下命令关闭:
service iptables stop
ES是去中心化,字面上理解就是无中心节点,这是对于集群外部来说的,因为从外部来看ES集群,在逻辑上是个整体,你与任何一个节点的通信和与整个ES集群通信是等价的。但在ES集群内部有如下三种角色:
node.master: true
node.data: true
discovery.zen.ping.unicast.hosts: ["IP1", "IP2", "IP3"]
discovery.zen.minimum_master_nodes: 1 #用来配置主节点的最小值
1:failed to send join request to master