CentOS7下安装ElasticSearch
ElasticSearch使用的版本是6.2.4,目前已有更新版本
1.配置JDK环境
export JAVA_HOME="/opt/jdk1.8.0_144"
export PATH="$JAVA_HOME/bin:$PATH"
export CLASSPATH=".:$JAVA_HOME/lib"
2.下载ElasticSearch
官方下载地址:https://www.elastic.co/cn/downloads/elasticsearch
csdn下载地址:https://download.csdn.net/download/u014646662/11012095
csdn上包含elasticsearch-6.2.4.tar.gz 和 kibana-6.2.4-linux-x86_64..tar.gz
3.安装
将下载好的压缩包elasticsearch-6.2.4.tar.gz解压
#使用非root用户
cd /opt
tar -xzvf elasticsearch-6.2.4.tar.gz
解压后出现如下内容:
启动Elasticsearch:
bin/elasticsearch
加参数 -d 可以后台启动,第一次最好不要后台启动,需要看是否启动成功
如果看到以上信息,就可以测试一下是否启动成功了
在浏览器中输入:
localhost:9200
页面上会有:
{
"name" : "ZPV-3J_",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "dyNpChovRgWCYbh9FCHN0g",
"version" : {
"number" : "6.2.4",
"build_hash" : "ccec39f",
"build_date" : "2018-04-12T20:37:28.497551Z",
"build_snapshot" : false,
"lucene_version" : "7.2.1",
"minimum_wire_compatibility_version" : "5.6.0",
"minimum_index_compatibility_version" : "5.0.0"
},
"tagline" : "You Know, for Search"
}
因为是直接启动的,没有修改配置文件,所以只能localhost或127.0.0.1来访问,如果出现以上信息则表示启动成功了
4.配置远程访问
编辑config/elasticsearch.yml /etc/security/limits.conf /etc/security/limits.d/20-nproc.conf /etc/sysctl.conf四个文件
1. vim config/elasticsearch.yml
#修改 network.host: 自己的主机名或IP
2. vim /etc/security/limits.conf
# 在文件尾部追加下列内容
# esuser是你的用户名
esuser soft nofile 65536
esuser hard nofile 65536
esuser soft nproc 4096
esuser hard nproc 4096
3. vim /etc/security/limits.d/20-nproc.conf
# 修改为 esuser soft nproc 4096
4. vim /etc/sysctl.conf
vm.max_map_count=655360
使配置生效
sysctl -p
重启机器
5. 再次启动ElasticSearch
cd /opt
bin/elasticsearch
6. 远程浏览器访问