本文距离上次更新已过去 0 天,部分内容可能已经过时,请注意甄别。
一、安装配置
1、安装jdk,配置好环境变量
2、关闭防火墙
3、创建es用户
1 2 3 4 5 6 7 8 9
| adduser es
passwd es
su es
mkdir es
cd es
|
4、下载es
1
| wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.5.0.tar.gz
|
5、运行es
1 2 3
| cd /home/es/elasticsearch-6.5.0
bin/elasticsearch -d 通过 -d 参数,表示后台运行
|
6、查看日志
1 2 3
| tail /home/es/elasticsearch-6.5.0logs/elasticsearch.log
ps -ef|grep elasticsearch
|
7、验证是否正常
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| curl http://127.0.0.1:9200 返回参数: { "name" : "UK2obWU", "cluster_name" : "elasticsearch", "cluster_uuid" : "ao_6EsyNQ5q2Epd-Xe5mMg", "version" : { "number" : "6.5.0", "build_flavor" : "default", "build_type" : "tar", "build_hash" : "816e6f6", "build_date" : "2018-11-09T18:58:36.352602Z", "build_snapshot" : false, "lucene_version" : "7.5.0", "minimum_wire_compatibility_version" : "5.6.0", "minimum_index_compatibility_version" : "5.0.0" }, "tagline" : "You Know, for Search" }
|
8、错误处理
(1)无法返回json
1 2 3 4
| vi config/elasticsearch.yml
修改配置 network.host 0.0.0.0
|
(2)
1 2
| [1] bootstrap checks failed [1]: max file descriptors [65535] for elasticsearch process is too low, increase to at least [65536]
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| vi /etc/security/limits.conf
添加如下内容 * soft nofile 65536 * hard nofile 65536
修改完成后同时使用命令修改配置: $ ulimit -n 65536 $ ulimit -n 65536
vi /etc/sysctl.conf
添加 vm.max_map_count=655360
sysctl -p 命令,使配置生效
|
通过浏览器访问http://IP:9200/
,可以返回json数据证明ES可以正常运行。
二、es分词插件安装
https://github.com/medcl/elasticsearch-analysis-ik/releases
一定和 Elasticsearch 版本一致。例如说 Elasticsearch 版本是 6.5.0
所以需要使用 elasticsearch-analysis-ik-v6.5.0
1 2 3 4 5
| #当前目录 pwd /home/es/es/elasticsearch-6.5.0 #开始下载 wget https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v6.5.0/elasticsearch-analysis-ik-6.5.0.zip
|
需要解压到 plugins/ik/ 目录下
1
| unzip elasticsearch-analysis-ik-6.5.0.zip -d plugins/ik/
|
查找 ES 进程,并关闭它
1 2 3 4 5 6
| $ ps -ef | grep elastic es 5005 1 4 21:28 pts/0 00:00:23 /bin/java -Xms1g -Xmx1g -XX:...... $ kill 5005 # 我们找到的 ES 进程号为 5005 。
# 启动 ES 进程 $ bin/elasticsearch -d
|
查看日志
1 2 3 4 5 6 7
| $ cat logs/elasticsearch.log
[2020-07-05T21:37:59,460][INFO ][o.e.p.PluginsService ] [UK2obWU] loaded module [x-pack-security] [2020-07-05T21:37:59,460][INFO ][o.e.p.PluginsService ] [UK2obWU] loaded module [x-pack-sql] [2020-07-05T21:37:59,460][INFO ][o.e.p.PluginsService ] [UK2obWU] loaded module [x-pack-upgrade] [2020-07-05T21:37:59,460][INFO ][o.e.p.PluginsService ] [UK2obWU] loaded module [x-pack-watcher] [2020-07-05T21:37:59,460][INFO ][o.e.p.PluginsService ] [UK2obWU] loaded plugin [analysis-ik]
|
可以看到成功加载的信息:loaded plugin [analysis-ik]
三、集群的配置