centos7安装elasticsearch7

1 下载elasticsearch

https://www.elastic.co/cn/downloads/past-releases#elasticsearch

2 上传解压

将下载的elasticsearch压缩包上传到服务器的指定目录并解压

shell 复制代码
tar -zxvf elasticsearch-7.17.20-linux-x86_64.tar.gz

3 启动

进入elasticsearch安装目录,执行

shell 复制代码
./bin/elasticsearch

错误提示

复制代码
java.lang.RuntimeException: can not run elasticsearch as root

不要以root用于运行elasticsearch

为elasticsearch创建用户

shell 复制代码
创建一个用户(es-admin)
useradd es-admin
#为创建的es用户设置密码(连续输入两次密码)
passwd es-admin
#创建一个用户组es
groupadd es
#分配用户es-admin到用户组es中
usermod -G es es-admin
#将elasticsearch目录的所有者分配给es-admin,该命令在elasticsearch解压目录外层执行
chown -R es-admin:es elasticsearch-7.17.20/

执行完查看一下

shell 复制代码
#切换用户到es-admin
su es-admin
#进入elasticsearch目录并运行elasticsearch
cd elasticsearch-7.17.20/
./bin/elasticsearch

至此elasticsearch启动成功

shell 复制代码
curl http://127.0.0.1:9200

4 配置

在配置的过程中有一些报错信息,我们一步一步解决

4.1 开放端口9200

shell 复制代码
sudo firewall-cmd --zone=public --add-port=9200/tcp --permanent
sudo firewall-cmd --reload

4.2 允许外网访问

shell 复制代码
vim config/elasticsearch.yml

将network注释去掉,并修改为 0.0.0.0

再次启动elasticsearch

shell 复制代码
./bin/elasticsearch

4.3 出错问题解决

报错如下

根据报错信息进行调整

shell 复制代码
vim /etc/sysctl.conf

在文件最后面添加如下信息

shell 复制代码
vm.max_map_count=262144

然后执行sysctl -p

再配置一个cluster.initial_master_nodes

shell 复制代码
vim config/elasticsearch.yml

我们配置三处内容

shell 复制代码
cluster.name: my-application
node.name: node-1
cluster.initial_master_nodes: ["node-1"]

启动报错
org.elasticsearch.ElasticsearchException: not all primary shards of [.geoip_databases] index are active

修改配置文件elasticsearch.yml,添加如下配置

shell 复制代码
ingest.geoip.downloader.enabled: false

再次启动就可以了

参考文献

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/install-elasticsearch.html在

相关推荐
Elasticsearch21 小时前
基于 Elasticsearch 与 Jina AI 的全模态智能搜索实践:技术全解析
elasticsearch
北风toto1 天前
Elasticsearch 8.2.3 快照迁移实战:从备份到恢复的完整指南
大数据·elasticsearch·jenkins
Elasticsearch2 天前
你的日志早已写好告警:在 Elasticsearch 中生成 ES|QL 检测查询
elasticsearch
垚垚学技术_聚焦云原生2 天前
Ansible Vault 安全实践:敏感密码、密钥加密存储方案
安全·elasticsearch·ansible
Flynn Liang3 天前
内存/Redis/PGVector/Milvus/ES 怎么选?Spring AI VectorStore 抽象与向量库选型对照表
redis·elasticsearch·milvus·rag·springai·pgvector·向量库
Elastic 中国社区官方博客3 天前
基于 Jina OCR v1 与 Elasticsearch 的 PDF 智能混合检索与 RAG 系统实战指南
大数据·数据库·elasticsearch·搜索引擎·ocr·jina
Eloudy4 天前
Qwen2.5-14B-Instruct-AWQ 模型文件结构分析
大数据·elasticsearch·搜索引擎
YIN_尹4 天前
【git原理与使用】git初识与安装
大数据·git·elasticsearch
Elastic 中国社区官方博客4 天前
Elastic 在《Forrester Wave™:2026 年第四季度智能运维平台》报告中被评为强劲表现者
大数据·运维·数据库·elasticsearch·搜索引擎·全文检索
Elasticsearch4 天前
Elastic Cloud 无服务器服务审计日志:将审计记录发送到可观测性或安全解决方案
elasticsearch