一、下载
https://www.elastic.co/cn/downloads/elasticsearchhttps://www.elastic.co/cn/downloads/elasticsearch
二、安装
elasticsearch-7.9.0-linux-x86_64.tar.gz 上传到linux机器,我存放目录是:/home/ies/webserver
执行如下代码进行解压:
cd /home/ies/webserver
tar -zxvf elasticsearch-7.9.0-linux-x86_64.tar.gz
三、启动
执行如下代码:
/home/ies/webserver/elasticsearch-7.9.0/bin/elasticsearch
如果一切正常,Elasticsearch就会在默认的9200端口运行。这时,打开另一个命令行窗口,请求该端口:
curl localhost:9200
出现如下截图,说明运行成功:
四、远程访问
此时,如果你在浏览器中访问:http://192.168.22.2:9200/ 则不成功,说明默认情况下,Elasticsearch 只允许本机访问,如果需要远程访问,可以修改 Elasticsearch 安装目录中的config/elasticsearch.yml文件,去掉network.host的注释,将它的值改成0.0.0.0,让任何人都可以访问,然后重新启动Elasticsearch。
在重启过程中,报了5个错误:
ERROR: [5] bootstrap checks failed
[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535]
[2]: max number of threads [1024] for user [ies] is too low, increase to at least [4096]
[3]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
[4]: system call filters failed to install; check the logs and fix your configuration or disable system call filters at your own risk
[5]: the default discovery settings are unsuitable for production use; at least one of [discovery.seed_hosts, discovery.seed_providers, cluster.initial_master_nodes] must be configured
下面我们分别解决一下:如下操作都以root用户进行
第一、二个问题:
[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535]
在文件 /etc/security/limits.conf 的最后添加如下两行:
ies soft nofile 65536
ies hard nofile 65536
ies soft nproc 65536
ies hard nproc 65536
- 表示匹配所有用户, nofile表示用户可以打开文件的最大数目
- 表示匹配所有用户, nofile表示配置最大打开线程数
修改之后,需要重新登录终端才能生效
第三个问题:
max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
在文件 /etc/sysctl.conf 的最后添加如下一行:
vm.max_map_count=655360
保存立即生效:
sysctl -p
查看是否生效:
sysctl -a|grep vm.max_map_count
第4个问题:
[4]: system call filters failed to install; check the logs and fix your configuration or disable system call filters at your own risk
原因:
这是在因为Centos6不支持SecComp,而ES5.2.0默认bootstrap.system_call_filter为true进行检测,所以导致检测失败,失败后直接导致ES不能启动。
解决:
在elasticsearch.yml中配置bootstrap.system_call_filter为false,注意要在Memory下面:
bootstrap.memory_lock: false
bootstrap.system_call_filter: false
第5个问题:
the default discovery settings are unsuitable for production use; at least one of [discovery.seed_hosts, discovery.seed_providers, cluster.initial_master_nodes] must be configured
解释: 在config/elasticsearch.yml中配置以下三者,最少其一
修改:
# 我这里修改的是:node1是节点的node-name的值:BSHMS02
cluster.initial_master_nodes: ["BSHMS02"]
重新启动:
/home/ies/webserver/elasticsearch-7.9.0/bin/elasticsearch
此时通过浏览器访问:http://192.168.22.2:9200/ ,出现如下截图,说明设置成功了!