Elasticsearch下载安装及使用

本文详细介绍Elasticsearch的下载、安装、启动及远程访问配置过程。针对常见启动错误,如文件描述符限制、虚拟内存区域限制等,提供具体解决方案,并演示如何修改配置允许远程访问。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

一、下载

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/ ,出现如下截图,说明设置成功了!
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值