安装java
- 安装并配置jdk
- 各版本对java的依赖
- ES5 需要 java8及以上版本
- ES6.5支持java11
- 7.0内置了java环境
- www.elastic.co/support/mat…
JVM配置
-
修改jvm
- config/jvm.options
- 建议2g及以上
-
配置的建议
-
Xms和Xmx设置成一样的
-
Xmx不要超过机器内存的50%
-
不要超过30GB www.elastic.co/cn/blog/a-h…
-
安装ES
必须是非root用户
建一个用户
useradd elk
passwd elk
下载安装包elasticsearch-7.6.2.tar.gz解压到指定目录
配置文件在config目录下elasticsearch.yml
[elk@localhost config]$ pwd
/home/elk/elasticsearch-7.6.2/config
[elk@localhost config]$ ls
elasticsearch.keystore jvm.options role_mapping.yml users
elasticsearch.yml log4j2.properties roles.yml users_roles
修改配置文件
network.host: 192.168.94.151
http.port: 9200
然后启动看下是否报错:
./bin/elasticsearch
如果不报错,加上 -d 参数启动,后台运行。
查询基本信息
GET http://192.168.94.151:9200/
{
"name": "node-1",
"cluster_name": "xhxESCluster",
"cluster_uuid": "gV6WQfoDTU2eH-85PgAHkg",
"version": {
"number": "7.6.2",
"build_flavor": "default",
"build_type": "tar",
"build_hash": "ef48eb35cf30adf4db14086e8aabd07ef6fb113f",
"build_date": "2020-03-26T06:34:37.794943Z",
"build_snapshot": false,
"lucene_version": "8.4.0",
"minimum_wire_compatibility_version": "6.8.0",
"minimum_index_compatibility_version": "6.0.0-beta1"
},
"tagline": "You Know, for Search"
}
遇到问题
[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
[2]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
[3]: max number of threads [2048] for user [elk] is too low, increase to at least [4096]
-
vi /etc/security/limits.conf 在末尾追加以下内容(elk为启动用户,当然也可以指定为*)
elk soft nofile 65536 elk hard nofile 65536 -
切换到root用户
执行命令: sysctl -w vm.max_map_count=262144
查看结果: sysctl -a|grep vm.max_map_count
显示: vm.max_map_count = 262144
上述方法修改之后,如果重启虚拟机将失效
解决办法: 在
/etc/sysctl.conf文件最后添加一行vm.max_map_count=262144即可永久修改 -
查看用户最大线程数 ulimit -a
修改用户最大线程数 ulimit -u 4096
vim /etc/security/limits.conf elk soft nproc 4096 elk hard nproc 4096