1. 程式人生 > >Mac下Elasticsearch5.X和Head外掛的安裝

Mac下Elasticsearch5.X和Head外掛的安裝

Elasticsearch5.x的安裝:在ELK升級到5.0之後,有些特性發生了變化,例如全部使用JDK8,外掛變化和環境校驗等。

一、安裝Elasticsearch

  • 在官網下載tar包,下載地址
  • 下載之後解壓
  • 進入bin目錄下啟動

備註:如果是root使用者啟動會出現異常,因為es出去安全性考慮,禁止以root使用者啟動,解決辦法是新建一個使用者,詳情請看這篇部落格:CENTOS安裝ElasticSearch

  • 進入es的conf目錄修改配置檔案
cluster.name: es-cluster
node.name: node-1
network.host: 0.0.0.0
http.port: 9200
  • 啟動ES,命令如下

    • ./elasticsearch
    • ./elasticsearch -d (這是後臺啟動)
  • 看到如下日誌資訊:

[2017-03-25T14:30:45,189][INFO ][o.e.n.Node               ] [node-1] initializing ...
[2017-03-25T14:30:45,272][INFO ][o.e.e.NodeEnvironment    ] [node-1] using [1] data paths, mounts [[/ (/dev/disk1)]], net usable_space [278.8gb], net total_space [464.6
gb], spins? [unknown], types [hfs] [2017-03-25T14:30:45,272][INFO ][o.e.e.NodeEnvironment ] [node-1] heap size [1.9gb], compressed ordinary object pointers [true] [2017-03-25T14:30:45,273][INFO ][o.e.n.Node ] [node-1] node name [node-1], node ID [n1HFjO-TQlSs4Ncw0HD34A] [2017-03-25T14:30:45,276
][INFO ][o.e.n.Node ] [node-1] version[5.2.2], pid[3763], build[f9d9b74/2017-02-24T17:26:45.835Z], OS[Mac OS X/10.12.3/x86_64], JVM[Oracle Corporation/Java HotSpot(TM) 64-Bit Server VM/1.8.0_111/25.111-b14] [2017-03-25T14:30:45,971][INFO ][o.e.p.PluginsService ] [node-1] loaded module [aggs-matrix-stats] [2017-03-25T14:30:45,971][INFO ][o.e.p.PluginsService ] [node-1] loaded module [ingest-common] [2017-03-25T14:30:45,971][INFO ][o.e.p.PluginsService ] [node-1] loaded module [lang-expression] [2017-03-25T14:30:45,971][INFO ][o.e.p.PluginsService ] [node-1] loaded module [lang-groovy] [2017-03-25T14:30:45,971][INFO ][o.e.p.PluginsService ] [node-1] loaded module [lang-mustache] [2017-03-25T14:30:45,971][INFO ][o.e.p.PluginsService ] [node-1] loaded module [lang-painless] [2017-03-25T14:30:45,971][INFO ][o.e.p.PluginsService ] [node-1] loaded module [percolator] [2017-03-25T14:30:45,971][INFO ][o.e.p.PluginsService ] [node-1] loaded module [reindex] [2017-03-25T14:30:45,972][INFO ][o.e.p.PluginsService ] [node-1] loaded module [transport-netty3] [2017-03-25T14:30:45,972][INFO ][o.e.p.PluginsService ] [node-1] loaded module [transport-netty4] [2017-03-25T14:30:45,972][INFO ][o.e.p.PluginsService ] [node-1] no plugins loaded [2017-03-25T14:30:47,936][INFO ][o.e.n.Node ] [node-1] initialized [2017-03-25T14:30:47,936][INFO ][o.e.n.Node ] [node-1] starting ... [2017-03-25T14:30:48,119][INFO ][o.e.t.TransportService ] [node-1] publish_address {192.168.31.110:9300}, bound_addresses {[::]:9300} [2017-03-25T14:30:48,123][INFO ][o.e.b.BootstrapChecks ] [node-1] bound or publishing to a non-loopback or non-link-local address, enforcing bootstrap checks [2017-03-25T14:30:51,226][INFO ][o.e.c.s.ClusterService ] [node-1] new_master {node-1}{n1HFjO-TQlSs4Ncw0HD34A}{gn6UwArmTG-DEwYmzh1U9g}{192.168.31.110}{192.168.31.110:9300}, reason: zen-disco-elected-as-master ([0] nodes joined) [2017-03-25T14:30:51,240][INFO ][o.e.h.HttpServer ] [node-1] publish_address {192.168.31.110:9200}, bound_addresses {[::]:9200} [2017-03-25T14:30:51,240][INFO ][o.e.n.Node ] [node-1] started [2017-03-25T14:30:51,246][INFO ][o.e.g.GatewayService ] [node-1] recovered [0] indices into cluster_state
  • 通過IP訪問,例如我的IP是192.168.31.110,那麼訪問地址就是192.168.31.110:9200,可以看到如下資訊
{
name: "n1HFjO-",
cluster_name: "elasticsearch",
cluster_uuid: "njH6T6eMS-mDf3tloN5THg",
version: {
number: "5.2.2",
build_hash: "f9d9b74",
build_date: "2017-02-24T17:26:45.835Z",
build_snapshot: false,
lucene_version: "6.4.1"
},
tagline: "You Know, for Search"
}

二、安裝Head外掛

Head外掛是我們常用的外掛,但是在ELK5.0以後按照之前的外掛安裝方式不能使用了,看了head官網之後,要單獨啟動一個服務才可以。

git clone git://github.com/mobz/elasticsearch-head.git
cd elasticsearch-head
npm install
grunt server

這裡依賴Node環境,我們需要做一下工作:

1、Head外掛安裝

  • 下載並安裝對應的Node安裝包
  • 安裝Git環境
  • 下載Head專案
  • cd elasticsearch-head
  • 修改伺服器監聽地址,地址目錄:head/Gruntfile.js
connect: {
    server: {
        options: {
            port: 9100,
            hostname: '*',
            base: '.',
            keepalive: true
        }
    }
}
  • 修改連線地址,目錄:head/_site/app.js
Paste_Image.png
  • npm install
  • grunt是一個很方便的構建工具,可以進行打包壓縮、測試、執行等等的工作,5.0裡的head外掛就是通過grunt啟動的。因此需要安裝一下grunt:npm install grunt-cli
  • grunt server:保證es服務已經啟動
Paste_Image.png
  • 開啟瀏覽器輸入:IP:9100
Paste_Image.png
  • 正常的話可以看到已經連線了ES,但是ES社群中很多人反映都配置好了,但是看不到連線資訊,這時候需要在在 es 的 elasticsearch.ym 裡新增如下配置:
http.cors.enabled: true
http.cors.allow-origin: "*"