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在

相关推荐
月屯1 天前
es大页读取
大数据·elasticsearch·搜索引擎
努力的小郑2 天前
与产品经理的“模糊”对决:Elasticsearch实现MySQL LIKE '%xxx%' 的奇幻之旅
后端·elasticsearch·搜索引擎
秋已杰爱2 天前
技术准备十五:Elasticsearch
大数据·elasticsearch·搜索引擎
starandsea2 天前
gitlab解决传过大文件后删除导致pack过大问题
大数据·elasticsearch·gitlab
大海绵啤酒肚2 天前
EL(F)K日志分析系统
运维·elasticsearch·云计算
Elasticsearch3 天前
如何在 AWS EC2 上安装和配置 Elasticsearch
elasticsearch
Elasticsearch3 天前
Elastic AI agent builder 介绍(二)
elasticsearch
维尔切3 天前
ELK日志系统部署与使用(Elasticsearch、Logstash、Kibana)
elk·elasticsearch·jenkins·kibana·logstash
帅帅梓4 天前
ELK es+logstash
大数据·elk·elasticsearch