06 ES(Elasticsearch)环境安装

ES(Elasticsearch)

Elasticsearch是一个实时的分布式存储、搜索和分析引擎。它可以用于多种用途,但它擅长的一个方面是索引半结构化数据流,例如日志或解码的网络数据包。

官方地址

1.下载安装

Elasticsearch下载地址

  • deb for Debian/Ubuntu

    curl -L -O https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-8.1.2-amd64.deb
    sudo dpkg -i elasticsearch-8.1.2-amd64.deb
    
    # 配置elasticsearch服务,以使用systemd自动启动  
    sudo systemctl daemon-reload
    sudo systemctl enable elasticsearch.service
    
    # 启动elasticsearch服务
    sudo systemctl start elasticsearch.service
    
  • rpm for Redhat/Centos/Fedora

    curl -L -O https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-8.1.2-x86_64.rpm
    sudo rpm -i elasticsearch-8.1.2-x86_64.rpm
    sudo service elasticsearch start
    
  • mac for OS X

    curl -L -O https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-8.1.2-darwin-x86_64.tar.gz
    tar -xzvf elasticsearch-8.1.2-darwin-x86_64.tar.gz
    cd elasticsearch-8.1.2
    ./bin/elasticsearch
    
  • linux for Linux

    curl -L -O https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-8.1.2-linux-x86_64.tar.gz
    tar -xzvf elasticsearch-8.1.2-linux-x86_64.tar.gz
    cd elasticsearch-8.1.2
    ./bin/elasticsearch
    
  • win for Windows

    1.下载elasticsearch-8.1.2-windows-x86_64.zip文件

    2.将 zip 文件的内容解压缩到计算机上的某个目录,例如 C:\Program Files.

    3.以管理员身份打开命令提示符并导航到包含提取文件的目录,例如:cd C:\Program Files\elasticsearch-8.1.2

    4.启动Elasticsearch:.\bin\elasticsearch.bat

2.配置

打开配置文件elasticsearch.yml

# 关闭身份验证
xpack.security.enabled: false

3.确保 Elasticsearch 已启动并运行

在浏览器输入 localhost:9200验证是否启动:

{
  "name" : "PS2022CCBSJOOJ",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "FxP8PXOiQpSa7gnTadCsOA",
  "version" : {
    "number" : "8.1.2",
    "build_flavor" : "default",
    "build_type" : "zip",
    "build_hash" : "31df9689e80bad366ac20176aa7f2371ea5eb4c1",
    "build_date" : "2022-03-29T21:18:59.991429448Z",
    "build_snapshot" : false,
    "lucene_version" : "9.0.0",
    "minimum_wire_compatibility_version" : "7.17.0",
    "minimum_index_compatibility_version" : "7.0.0"
  },
  "tagline" : "You Know, for Search"
}

4.使用

  • 获取健康状态

    curl -X GET http://localhost:9200/_cat/health?v
    

    输出结果:

    epoch      timestamp cluster       status node.total node.data shards pri relo init unassign pending_tasks max_task_wait_time active_shards_percent
    1649342888 14:48:08  elasticsearch green           1         1      2   2    0    0        0             0                  -                100.0%
    
  • 查询当前ES集群中所有的indices

    curl -X GET http://localhost:9200/_cat/indices?v
    

    输出结果:

    health status index uuid                   pri rep docs.count docs.deleted store.size pri.store.size
    yellow open   test  R6IiaDKSQF26_yy8D-agaA   1   1          0            0       225b           225b
    yellow open   www   FgZVSnOQRPWAmuS_79jb_w   1   1          0            0       225b           225b
    
  • 创建索引

    curl -X PUT localhost:9200/www
    

    输出结果:

    {"acknowledged":true,"shards_acknowledged":true,"index":"www"}
    
  • 删除索引

    curl -X DELETE localhost:9200/www
    

    输出结果:

    curl -X DELETE localhost:9200/www
    

5.集成IK Analysis插件

  • 方法1:
# 1.下载与构建包
# https://github.com/medcl/elasticsearch-analysis-ik/releases

# 2.在ES根目录创建ik插件目录
D:\DevelopInstall\elasticsearch-8.1.2\plugins\ik

# 3.解压elasticsearch-analysis-ik-8.1.2.zip到插件目录
# 4.重启elasticsearch
  • 方法2:
# 用elasticsearch-plugin安装插件
./bin/elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v6.3.0/elasticsearch-analysis-ik-6.3.0.zip
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值