安装前准备
centos7 +
java 8 +
elastic 6.2.4+
在官方网站下载ES
wget http://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.4.1.tar.gz
安装JDK(必须JDK1.8+)
1. rpm -ivh jdk-8u181-linux-x64.rpm
/*注意:默认安装位置 /usr/java/jdk1.8.0_171-amd64*/
2. 配置环境变量
vim /etc/profile
在文件末尾加入:
export JAVA_HOME=/usr/java/jdk1.8.0_171-amd64
export PATH=$PATH:$JAVA_HOME/bin
3. 重载系统配置
source /etc/profile
安装elasticsearche
tar -zxvf elasticsearch-6.4.1.tar.gz
elasticsearche的目录结构
bin 可执行的二进制文件的目录
config 配置文件的目录
lib 运行时依赖的库
logs modules 运行时日志文件
plugins es中提供的插件
运行es服务
在bin目录中执行 ./elasticsearch
不能以root用户身份启动
-
在linux系统中创建新的用户
useradd es
-
修改es用户密码
passwd es -
将root用户解压的文件移动到es用户目录中
chmod -R es:es /user/local/es/ -
登录es用户启动ES
./elasticsearch 启动ES
测试ES是否启动成功
在命令终端中执行: curl http://localhost:9200 出现以下信息:
{
"name" : "xQK1cwT",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "t7IYk7LKQ0mXcyyrdFWpLg",
"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"
}
开启ES远程访问
vim elasticsearch.yml 将原来network修改为以下配置:
network.host: 0.0.0.0
外部浏览器访问即可
http://es的主机名:9200 出现如下信息说明安装成功:
{
"name" : "xQK1cwT",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "t7IYk7LKQ0mXcyyrdFWpLg",
"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"
}
启动时错误解决方案
1. 重新启动es出现如下错误
ERROR: bootstrap checks failed[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
解决方案:
切换到root用户修改
vim /etc/security/limits.conf
在最后面追加下面内容
* soft nofile 65536
* hard nofile 65536
* soft nproc 4096
* hard nproc 4096
退出重新登录检测配置是否生效:
ulimit -Hn
ulimit -Sn
ulimit -Hu
ulimit -Su
2.重新启动出现如下错误
ERROR: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
解决方案:
vim /etc/sysctl.conf
vm.max_map_count=655360
#执行以下命令生效:
sysctl -p
参考文章:https://blog.csdn.net/he19970408/article/details/107359861/