ubuntu安裝elasticSearch及插件

原文地址:http://www.niu12.com/article/18node

前提

1.安裝好Java1.8以上環境並配置好JAVA_HOME(elasticsearch運行環境)
2.node環境6.5以上(插件須要)

安裝elastic

$ wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.5.1.zip
$ unzip elasticsearch-5.5.1.zip
$ cd elasticsearch-5.5.1/ 
$ ./bin/elasticsearch
若是遇到相關錯誤請上網自行查詢

運行

$ curl localhost:9200
// 返回
{
"name" : "atntrTf",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "tf9250XhQ6ee4h7YI11anA",
"version" : {
    "number" : "5.5.1",
    "build_hash" : "19c13d0",
    "build_date" : "2017-07-18T20:44:24.823Z",
    "build_snapshot" : false,
    "lucene_version" : "6.6.0"
},
"tagline" : "You Know, for Search"
}

由於我是在虛擬機裏跑,因此須要宿主機訪問,默認狀況下,Elastic 只容許本機訪問,若是須要遠程訪問,能夠修改 Elastic 安裝目錄的config/elasticsearch.yml文件,去掉network.host的註釋,將它的值改爲0.0.0.0,而後從新啓動 Elastic。git

elasticsearch-head插件安裝

$ git clone https://github.com/mobz/elasticsearch-head.git

$ cd elasticsearch-head

$ sudo npm install -g grunt -cli

$ npm run start

出現Started connect web server on http://localhost:9100便可在宿主機訪問 個人虛擬機地址是192.168.10.10,訪問結果以下圖github

 

記得修改ip地址,es-head鏈接的是localhostweb

發現狀態未鏈接,由於es和es-head屬於兩個不一樣的進程,他們之間的訪問是有跨域問題,因此須要配置./config/elasticsearch.ymlnpm

# 在末尾添加配置
$ vim ./config/elasticsearch.yml

http.cors.enabled: true
http.cors.allow-origin: *

重啓es和es-head,訪問結果以下圖vim

 

相關文章
相關標籤/搜索