centos7安装部署ElasticSearch

文章目录

  • ElasticSearch安装部署
    • 简介
    • 安装
    • 卸载

ElasticSearch安装部署

简介

  • 全文搜索属于最常见的需求,开源的 Elasticsearch (以下简称 es)是目前全文搜索引擎的首选。

  • 它可以快速地储存、搜索和分析海量数据。维基百科、Stack Overflow、Github 都采用它。

  • Elasticsearch简称es,在企业内同样是一款应用非常广泛的搜索引擎服务。

安装

  1. 添加yum仓库

    # 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
    
  2. 安装es

    yum install -y elasticsearch
    
  3. 配置es

    vim /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"]
    
  4. 启动es

    systemctl start | stop | status | enable | disable elasticsearch
    
  5. 关闭防火墙

    systemctl stop firewalld
    systemctl disable firewalld
    
  6. 测试

    • 浏览器打开:http://ip:9200/?pretty
sudo userdel elasticsearch
sudo groupdel elasticsearch
{
  "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"
}

卸载

  1. 停止Elasticsearch服务

    sudo systemctl stop elasticsearch
    
  2. 卸载Elasticsearch软件包

    sudo yum remove elasticsearch
    
  3. 删除Elasticsearch数据目录

    • Elasticsearch数据目录默认位于/var/lib/elasticsearch
    sudo rm -rf /var/lib/elasticsearch
    
  4. 删除Elasticsearch配置文件

    • Elasticsearch配置文件默认位于/etc/elasticsearch
    sudo rm -rf /etc/elasticsearch
    
  5. 删除Elasticsearch日志文件

    • Elasticsearch日志文件默认位于/var/log/elasticsearch
    sudo rm -rf /var/log/elasticsearch
    

你可能感兴趣的:(Linux学习,elasticsearch,大数据,搜索引擎)