一、前言

  基于上篇文章【Kubernetes1.23搭建Elasticsearch7集群】写一下如何给k8s上的es集群安装插件,就以安装ik分词器为例给大家演示实际操作。

二、步骤

1.每一个节点都需要添加,也就是说添加11个。
在这里插入图片描述
2.依次点击点击“日志终端”–>“文件浏览器”–>“如图路径点入”–>“上传”–>“选择文件”
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
3.选择“解压缩”模式,再点击上传(这样会自动解压到plugins下)
在这里插入图片描述
4.点击"确定"
在这里插入图片描述
5.最后记得删除压缩包(否则启动Es会报错不识别zip包)
在这里插入图片描述
(按照以上步骤依次解压缩为11个节点)
6.重启集群即可
在这里插入图片描述

三、测试

1.创建索引

curl -XPUT http://localhost:9200/index

在这里插入图片描述
2.创建映射

curl -XPOST http://localhost:9200/index/_mapping -H 'Content-Type:application/json' -d'
{
        "properties": {
            "content": {
                "type": "text",
                "analyzer": "ik_max_word",
                "search_analyzer": "ik_smart"
            }
        }

}'

在这里插入图片描述
3.索引一些文档

curl -XPOST http://localhost:9200/index/_create/1 -H 'Content-Type:application/json' -d'
{"content":"美国留给伊拉克的是个烂摊子吗"}
'
curl -XPOST http://localhost:9200/index/_create/2 -H 'Content-Type:application/json' -d'
{"content":"公安部:各地校车将享最高路权"}
'
curl -XPOST http://localhost:9200/index/_create/3 -H 'Content-Type:application/json' -d'
{"content":"中韩渔警冲突调查:韩警平均每天扣1艘中国渔船"}
'
curl -XPOST http://localhost:9200/index/_create/4 -H 'Content-Type:application/json' -d'
{"content":"中国驻洛杉矶领事馆遭亚裔男子枪击 嫌犯已自首"}
'

在这里插入图片描述
4.带高亮显示的查询

curl -XPOST http://localhost:9200/index/_search  -H 'Content-Type:application/json' -d'
{
    "query" : { "match" : { "content" : "中国" }},
    "highlight" : {
        "pre_tags" : ["<tag1>", "<tag2>"],
        "post_tags" : ["</tag1>", "</tag2>"],
        "fields" : {
            "content" : {}
        }
    }
}
'

在这里插入图片描述
(可以看到ik分词没问题)

四、结束语

  到此咱们的k8s上es集群安装插件教程就结束啦,下期给大家带来基于kuboard监控套件安装教程:基于 Prometheus/Grafana 实现 Kubernetes 的资源监控能力,并与 Kuboard 减免中的 Node/Pod 上下文整合,可以在 Kuboard 的节点详情页/Pod详情页,直接打开对应节点/Pod 的 Grafana 监控界面。
预告:
在这里插入图片描述

Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐