1、下載 最新版的 Elasticsearch (elasticsearch-6.2.0.tar.gz) 到 /usr/local/src 目錄下
2、解壓縮到當前文件夾 【tar -zxvf elasticsearch-6.2.0.tar.gz】
3、移動到 /usr/local 目錄下 【mv elasticsearch-6.2.0 ../】
4、將命令添加到環境變量 【vi /etc/profile】
5、最后添加
export JAVA_HOME=/usr/jdk1.8.0_60
export JRE_HOME=$JAVA_HOME/jre
export ELASTICSEARCH_HOME=/usr/local/elasticsearch-6.2.0
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$ELASTICSEARCH_HOME/bin:$PATH
6、修改 /usr/local/elasticsearch-6.2.0/config/elasticsearch.yml
cluster.name: my-application
node.name: node-1
network.host: 0.0.0.0
http.port: 9200
node.max_local_storage_nodes: 2
可能遇到異常
1、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
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
3、main ERROR No log4j2 configuration file found. Using default configuration: logging only errors to the console
node.max_local_storage_nodes: 2
請盡量保持冒號前面沒空格,后面一個空格,不要用tab鍵