(1)环境说明
服务器环境:CentOS Linux 7
[root@VM-0-3-centos ~]# cat /etc/redhat-release
CentOS Linux release 7.6.1810 (Core)
jdk环境:jdk1.8
[root@VM-0-3-centos app]# java -version
java version "1.8.0_141"
Java(TM) SE Runtime Environment (build 1.8.0_141-b15)
Java HotSpot(TM) 64-Bit Server VM (build 25.141-b15, mixed mode)
es版本:6.4.1
[root@VM-0-3-centos elasticsearch]# ll
total 123908
-rw-r--r-- 1 root root 97924081 Oct 9 2019 elasticsearch-6.4.1.tar.gz
-rw-r--r-- 1 root root 4502531 Oct 9 2019 elasticsearch-analysis-ik-6.4.1.zip
-rw-r--r-- 1 root root 24447542 Oct 9 2019 ingest-attachment-6.4.1.zip
资料下载连接
链接:https://pan.baidu.com/s/1Ml8b92zzXf9BgKiXjd-H_A
提取码:9527
(2)安装步骤
1)解压elasticsearch-6.4.1.tar.gz
[root@VM-0-3-centos elasticsearch]# tar -xzvf elasticsearch-6.4.1.tar.gz
2)将插件解压到elasticsearch-6.4.1/plugins目录下
[root@VM-0-3-centos elasticsearch]# unzip -d elasticsearch-6.4.1/plugins/elasticsearch-analysis-ik-6.4.1/ elasticsearch-analysis-ik-6.4.1.zip
[root@VM-0-3-centos elasticsearch]# unzip -d elasticsearch-6.4.1/plugins/ingest-attachment-6.4.1/ ingest-attachment-6.4.1.zip
[root@VM-0-3-centos elasticsearch]# cd elasticsearch-6.4.1/plugins/
[root@VM-0-3-centos plugins]# ll
total 8
drwxr-xr-x 3 root root 4096 Mar 17 09:34 elasticsearch-analysis-ik-6.4.1
drwxr-xr-x 2 root root 4096 Mar 17 09:34 ingest-attachment-6.4.1
3)修改配置文件elasticsearch-6.4.1/config/elasticsearch.yml
[root@VM-0-3-centos config]# vim elasticsearch.yml
在末尾追加
#自定义配置
network.host: 0.0.0.0
http.port: 9200
http.cors.enabled: true
http.cors.allow-origin: "*"
4)创建es用户
不能用root用户启动。要创建es用户组和用户,授权elasticsearch-6.4.1目录给es用户
[root@VM-0-3-centos elasticsearch]# groupadd es
[root@VM-0-3-centos elasticsearch]# useradd es -g es -p elasticsearch-6.4.1
[root@VM-0-3-centos elasticsearch]# chown -R es:es elasticsearch-6.4.1
[root@VM-0-3-centos elasticsearch]# ll
total 95636
drwxr-xr-x 8 es es 4096 Sep 14 2018 elasticsearch-6.4.1
5)切换su用户,启动服务
[root@VM-0-3-centos elasticsearch-6.4.1]# su es
[es@VM-0-3-centos elasticsearch-6.4.1]$ ./bin/elasticsearch
6)启动失败报错:max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
解决:
使用root用户编辑/etc/security/limits.conf
[root@VM-0-3-centos ~]# vim /etc/security/limits.conf
在后面新增自定义配置
# 自定义配置
* soft nofile 65536
* hard nofile 65536
使用root用户编辑/etc/sysctl.conf
[root@VM-0-3-centos ~]# vim /etc/sysctl.conf
在后面新增自定义配置
# 自定义配置
vm.max_map_count=655360
然后重新加载系统参数
[root@VM-0-3-centos ~]# sysctl -p
7)重新启动
[es@VM-0-3-centos elasticsearch-6.4.1]$ ./bin/elasticsearch
8)后台方式启动(推荐)
[es@VM-0-3-centos elasticsearch-6.4.1]$ nohup ./bin/elasticsearch&
(3)访问(x.x.x.x:9200)验证成功。
(4)停掉服务
查看进程
[es@VM-0-3-centos elasticsearch-6.4.1]$ ps aux|grep elasticsearch
杀死进程
[es@VM-0-3-centos elasticsearch-6.4.1]$ kill -9 31723