文章目录
ElasticSearch安装部署
简介
-
全文搜索属于最常见的需求,开源的 Elasticsearch (以下简称 es)是目前全文搜索引擎的首选。
-
它可以快速地储存、搜索和分析海量数据。维基百科、Stack Overflow、Github 都采用它。
-
Elasticsearch简称es,在企业内同样是一款应用非常广泛的搜索引擎服务。
安装
-
添加yum仓库
shell# root执行 # 导入仓库密钥 rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch # 添加yum源 # 编辑文件 vim /etc/yum.repos.d/elasticsearch.repo # 推荐使用 [elasticsearch-7.x] name=Elasticsearch repository for 7.x packages baseurl=https://mirrors.tuna.tsinghua.edu.cn/elasticstack/yum/elastic-7.x/ gpgcheck=1 gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch enabled=1 autorefresh=1 type=rpm-md # 更新yum缓存 yum makecache
-
安装es
shellyum install -y elasticsearch
-
配置es
shellvim /etc/elasticsearch/elasticsearch.yml #阅读模式 显示行号 :set nu # 17行,设置集群名称 cluster.name: my-cluster # 23行,设置节点名称 node.name: node-1 # 56行,允许外网访问 network.host: 0.0.0.0 # 74行,配置集群master节点 cluster.initial_master_nodes: ["node-1"]
-
启动es
shellsystemctl start | stop | status | enable | disable elasticsearch
-
关闭防火墙
shellsystemctl stop firewalld systemctl disable firewalld
-
测试
- 浏览器打开:
http://ip:9200/?pretty
- 浏览器打开:
bash
sudo userdel elasticsearch
sudo groupdel elasticsearch
json
{
"name": "node-1",
"cluster_name": "my-cluster",
"cluster_uuid": "yLfUpG4CQ-Wbq6zL-2XqzA",
"version": {
"number": "7.17.14",
"build_flavor": "default",
"build_type": "rpm",
"build_hash": "774e3bfa4d52e2834e4d9d8d669d77e4e5c1017f",
"build_date": "2023-10-05T22:17:33.780167078Z",
"build_snapshot": false,
"lucene_version": "8.11.1",
"minimum_wire_compatibility_version": "6.8.0",
"minimum_index_compatibility_version": "6.0.0-beta1"
},
"tagline": "You Know, for Search"
}
卸载
-
停止Elasticsearch服务
bashsudo systemctl stop elasticsearch
-
卸载Elasticsearch软件包
bashsudo yum remove elasticsearch
-
删除Elasticsearch数据目录
- Elasticsearch数据目录默认位于
/var/lib/elasticsearch
bashsudo rm -rf /var/lib/elasticsearch
- Elasticsearch数据目录默认位于
-
删除Elasticsearch配置文件
- Elasticsearch配置文件默认位于
/etc/elasticsearch
bashsudo rm -rf /etc/elasticsearch
- Elasticsearch配置文件默认位于
-
删除Elasticsearch日志文件
- Elasticsearch日志文件默认位于
/var/log/elasticsearch
bashsudo rm -rf /var/log/elasticsearch
- Elasticsearch日志文件默认位于