windows 下安裝elasticsearch 及其外掛head,ik,marvel
1.首先下載elasticsearch for windows
官網地址:https://www.elastic.co/downloads/elasticsearch,這裡我下載的是2.4.0版本。
2.安裝jdk,jdk版本最好在1.7以上,否則無法啟動elasticsearch服務
官方建議:
We recommend installing the Java 8 update 20 or later, or Java 7 update 55 or later.Previous versions of Java 7 are known to have bugs that can cause index corruption and data loss. Elasticsearch will refuse to start if a known-bad version of Java is used.
3.解壓下載包到某個目錄,例如:解壓到D:\大資料軟體安裝包\elasticsearch-2.4.0\elasticsearch-2.4.0。
4.開始安裝啟動:這裡有2種方法:
方法一:
進入解壓檔案的bin目錄,雙擊執行elasticsearch.bat 如圖,
如果要停止服務: ctrl+c 即可。
方法二
(1)進入解壓檔案的bin目錄下,執行以下命令:
service install
service start
如下圖所示:
(2)同樣開啟 http://localhost:9200 瀏覽檢視,如果要停止elasticsearch服務,則執行 service stop 即可關閉elasticsearch。
外掛安裝
1.安裝head外掛
安裝head外掛,在網頁上管理、監視叢集的狀態。
開啟cmd命令視窗,進入解壓檔案的bin目錄,然後執行命令:
plugin install mobz/elasticsearch-head
如下圖所示:
瀏覽http://localhost:9200/_plugin/head/,出現如下介面,則安裝成功:
2.安裝marvel外掛
進入es安裝目錄的bin目錄,執行命令:
bin/plugin install license
bin/plugin install marvel-agent
進入kibana的bin目錄(首先下載kibana):
bin/kibana plugin --install elasticsearch/marvel/latest
如果機器沒有連網,則上述命令無法執行,需要首先下載安裝檔案包,下載地址:
然後分別執行命令:
進入es的bin目錄:
plugin install file:///D:/大資料軟體安裝包/elasticsearch-2.4.0/license-2.4.0.zip
plugin install file:///D:/大資料軟體安裝包/elasticsearch-2.4.0/marvel-agent-2.4.0.zip
進入kibana的bin目錄:
最後訪問:http://localhost:5601/app/marvel
3.安裝ik分詞外掛
首先在git上下載已經編譯好的程式碼,一定要選擇和自己的es版本對應,否則無法啟動服務,git下載地址如下:
然後把檔案解壓放在es的plugins的analysis-ik目錄下,如果沒有此目錄,則新建。
最後在es的conf中elasticsearch.yml檔案末尾中加入 index.analysis.analyzer.ik.type: "ik"
測試分詞外掛是否可以分詞:在瀏覽器輸入:
http://localhost:9200/_analyze?analyzer=ik&pretty=true&text=中華人民共和國國歌 結果: { "tokens" : [ { "token" : "中華人民共和國", "start_offset" : 0, "end_offset" : 7, "type" : "CN_WORD", "position" : 0 }, { "token" : "中華人民", "start_offset" : 0, "end_offset" : 4, "type" : "CN_WORD", "position" : 1 }, { "token" : "中華", "start_offset" : 0, "end_offset" : 2, "type" : "CN_WORD", "position" : 2 }, { "token" : "華人", "start_offset" : 1, "end_offset" : 3, "type" : "CN_WORD", "position" : 3 }, { "token" : "人民共和國", "start_offset" : 2, "end_offset" : 7, "type" : "CN_WORD", "position" : 4 }, { "token" : "人民", "start_offset" : 2, "end_offset" : 4, "type" : "CN_WORD", "position" : 5 }, { "token" : "共和國", "start_offset" : 4, "end_offset" : 7, "type" : "CN_WORD", "position" : 6 }, { "token" : "共和", "start_offset" : 4, "end_offset" : 6, "type" : "CN_WORD", "position" : 7 }, { "token" : "國", "start_offset" : 6, "end_offset" : 7, "type" : "CN_CHAR", "position" : 8 }, { "token" : "國歌", "start_offset" : 7, "end_offset" : 9, "type" : "CN_WORD", "position" : 9 } ]} 如果想要粗粒度的分詞:則把analyzer的屬性換成ik_smart即可 http://localhost:9200/_analyze?analyzer=ik_smart&pretty=true&text=中華人民共和國國歌結果:
{ "tokens" : [ { "token" : "中華人民共和國", "start_offset" : 0, "end_offset" : 7, "type" : "CN_WORD", "position" : 0 }, { "token" : "國歌", "start_offset" : 7, "end_offset" : 9, "type" : "CN_WORD", "position" : 1 } ]}