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键