基于k8s部署的es7集群安装插件
如何给kubenetes上的Elasticsearch7集群安装插件,就以安装ik分词器为例给大家演示实际操作。
·
一、前言
基于上篇文章【Kubernetes1.23搭建Elasticsearch7集群】写一下如何给k8s上的es集群安装插件,就以安装ik分词器为例给大家演示实际操作。
- elasticsearch-analysis-ik-7.16.2【点击下载】
二、步骤
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 监控界面。
预告:
更多推荐
已为社区贡献2条内容
所有评论(0)