一、下載 最新版的 Elasticsearch (elasticsearch-6.2.0.tar.gz) 到 /usr/local/src 目錄下node
二、解壓縮到當前文件夾 【tar -zxvf elasticsearch-6.2.0.tar.gz】app
三、移動到 /usr/local 目錄下 【mv elasticsearch-6.2.0 ../】elasticsearch
四、將命令添加到環境變量 【vi /etc/profile】spa
五、最後添加ip
export JAVA_HOME=/usr/jdk1.8.0_60string
export JRE_HOME=$JAVA_HOME/jreit
export ELASTICSEARCH_HOME=/usr/local/elasticsearch-6.2.0io
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$ELASTICSEARCH_HOME/bin:$PATHconsole
六、修改 /usr/local/elasticsearch-6.2.0/config/elasticsearch.ymltable
cluster.name: my-application
node.name: node-1
network.host: 0.0.0.0
http.port: 9200
node.max_local_storage_nodes: 2
可能遇到異常
一、failed to obtain node locks, tried [[/elasticsearch-5.4.0/data/elasticsearch]] with lock id [0]; maybe these locations are not writable or multiple nodes were started without increasing [node.max_local_storage_nodes] (was [1])
/usr/local/elasticsearch-6.2.0/config/elasticsearch.yml 配置文件最後添加 node.max_local_storage_nodes: 2
二、can not run elasticsearch as root
useradd elasticsearch
chown -R elasticsearch:elasticsearch /usr/local/elasticsearch-6.2.0
su elasticsearch
sh /usr/local/elasticsearch-6.2.0/bin/elasticsearch -d
三、main ERROR No log4j2 configuration file found. Using default configuration: logging only errors to the console
node.max_local_storage_nodes: 2
請儘可能保持冒號前面沒空格,後面一個空格,不要用tab鍵