ansiable playbook鏈接:
https://download.csdn.net/download/weixin_43798031/87719490
需要注意的點(diǎn):公司es集群現(xiàn)以三個(gè)角色部署分別為 Gateway、Master、Data 簡單的理解可以理解為在每臺機(jī)器上部署了三個(gè)es,以端口和配置文件來區(qū)分這三個(gè)es不同的功能。
我們知道本來安裝分詞器是件特別簡單的事網(wǎng)上的教程也是一大片一大片的,在我們的環(huán)境和架構(gòu)下需要特別注意的是在安裝分詞器的時(shí)候,需要給這三個(gè)不同的角色(Gateway、Master、Data)分別安裝ik分詞器。
在es 5.5版本之后就不需要修改es的配置文件進(jìn)行配置分詞器了。還有一定要用es對應(yīng)版本的分詞器,否則啟動(dòng)的時(shí)候會(huì)有報(bào)錯(cuò)。
elasticsearch version:?7.6.1
elasticsearch ik:7.6.1
elasticsearch-analysis-ik?:Releases · medcl/elasticsearch-analysis-ik · GitHub
啟動(dòng)用戶:elasticsearch? su elasticsearch
路徑:/opt? 三個(gè)es進(jìn)程
一、使用ansiable playbook 安裝部署es集群
1.? 登錄ansiable服務(wù)器進(jìn)入/home/sunwenbo/es 目錄下,看到如下截圖的這些目錄及文件
2. 修改vars.yml文件中的配置,該文件為ansiable-playbook的變量文件如下圖,修改標(biāo)記點(diǎn)1 和標(biāo)記點(diǎn)2
配置說明:
---
#es的源路徑,進(jìn)行安裝時(shí),會(huì)將該目錄發(fā)往要安裝es的服務(wù)器
src_path: "/home/sunwenbo/es/elasticsearch"
#es目標(biāo)路徑
dest_path: "/opt"
#master的目標(biāo)文件當(dāng)將elasticsearch發(fā)送到目標(biāo)服務(wù)器/opt目錄下,會(huì)進(jìn)行對該目錄改名
master_dest_path: "/opt/elasticsearch-master"
gateway_dest_path: "/opt/elasticsearch-gateway"
data_dest_path: "/opt/elasticsearch-data"
#集群名稱,安裝時(shí)候需要看工單上申請es集群的名稱,如果沒有需要和工單發(fā)起人確認(rèn)
cluster_name: "superfe-goods-server-dependent"
#master列表,如果有多個(gè)節(jié)點(diǎn)的情況下,這里需要填寫多個(gè)
master_list: '["10.138.7.41:20100","10.138.7.42:20100","10.138.7.40:20100"]'
3. 修改ip.txt文件,將IP分別填入這個(gè)文件
4. 執(zhí)行安裝命令,正常情況下,這時(shí)候一個(gè)es集群已經(jīng)配置好了。如果啟動(dòng)失敗的話查看/opt/elasticsearch-master/logs/${集群名稱}.log日志
ansible-playbook -i ip.txt es.yml -b
二、安裝IK分詞器
1.? 執(zhí)行如下playbook
cd /home/sunwenbo/es
ansible-playbook -i ip.txt ik.yml -b
2. 檢查是否安裝成功
可以看到我們安裝的三個(gè)服務(wù)器,每個(gè)服務(wù)器上的三個(gè)es角色都已經(jīng)安裝上ik分詞器了。
?
3. 創(chuàng)建一個(gè)類型為ik_max_word的索引,shards_acknowledged為true則為正常文章來源:http://www.zghlxwxcb.cn/news/detail-426601.html
文章來源地址http://www.zghlxwxcb.cn/news/detail-426601.html
三、es常用命令
查看安裝的插件
curl http://localhost:40000/_cat/plugins
查看es集群狀態(tài)
curl -XGET http://localhost:40000/_cluster/health?pretty
查看節(jié)點(diǎn)信息
curl -XGET http://localhost:40000/_cat/nodes?v
查看節(jié)點(diǎn)進(jìn)程信息
curl -XGET http://localhost:40000/_cat/nodes/process?pretty
查看索引信息
curl -XGET http://localhost:40000/_cat/indices?v
查看狀態(tài)信息
curl -XGET http://localhost:40000/_cluster/health?pretty
刪除索引
curl -XDELETE 'localhost:20000/.elastichq/'
創(chuàng)建索引
curl -XPUT 'localhost:20000/test/'
retry重試
curl -X POST localhost:20000/_cluster/reroute?retry_failed=true
查看報(bào)錯(cuò)原因
curl -XGET localhost:20000/_cluster/allocation/explain?pretty
找到狀態(tài)為 red 的索引
curl -X GET "http://localhost:40000/_cat/indices?v="
找到 UNASSIGNED 節(jié)點(diǎn)
curl -X GET "http://localhost:40000/_cat/shards"
找到機(jī)器id
curl -X GET "http://localhost:40000/_nodes/process?"
ik分詞器和pinyin分詞器測試命令,針對7.6.1版本
curl 'http://127.0.0.1:20000/_analyze?pretty=true' -H 'Content-Type: application/json' -d '{ "analyzer":"ik_max_word", "text":"我愛你,中國"}'
curl 'http://127.0.0.1:20000/_analyze?pretty=true' -H 'Content-Type: application/json' -d '{ "analyzer":"pinyin", "text":"我愛你,中國"}'
curl 'http://127.0.0.1:20000/_analyze?pretty=true' -H 'Content-Type: application/json' -d '{ "analyzer":"ik_max_word", "text":"好好學(xué)習(xí),天天向上"}'
curl 'http://127.0.0.1:20000/_analyze?pretty=true' -H 'Content-Type: application/json' -d '{ "analyzer":"pinyin", "text":"好好學(xué)習(xí),天天向上"}'
到了這里,關(guān)于ElasticSearch 部署及安裝ik分詞器的文章就介紹完了。如果您還想了解更多內(nèi)容,請?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!