安装kibana,X-pack和elasticsearch插件的全过程
Are U ready?
搞Elasticsearch的話死后需要安裝一些輔助工具,在安裝這些工具之前,最好先檢查rpm和node版本,如下:
[root@chen-elk-001?elasticsearch-head]#?rpm?--version RPM?version?4.11.3 [root@chen-elk-001?elasticsearch-head]#?node?-v v6.11.3 [root@chen-elk-001?elasticsearch-head]#nvm?install?8.9.0 -bash:?nvm:?command?not?found????????#如果沒有發現安裝nvm就按照下面的方法安裝 [root@chen-elk-001?elasticsearch-head]#curl?https://raw.githubusercontent.com/creationix/nvm/master/install.sh?|?sh [root@chen-elk-001?elasticsearch-head]#?export?NVM_DIR="$HOME/.nvm" [root@chen-elk-001?elasticsearch-head]#?[?-s?"$NVM_DIR/nvm.sh"?]?&&?\.?"$NVM_DIR/nvm.sh" [root@chen-elk-001?elasticsearch-head]#?[?-s?"$NVM_DIR/bash_completion"?]?&&?\.?"$NVM_DIR/bash_completion" [root@chen-elk-001?elasticsearch-head]#?nvm?install?8.9.0 Downloading?and?installing?node?v8.9.0... Downloading?https://nodejs.org/dist/v8.9.0/node-v8.9.0-linux-x64.tar.xz... ########################################################################?100.0% Computing?checksum?with?sha256sum Checksums?matched! Now?using?node?v8.9.0?(npm?v5.5.1) Creating?default?alias:?default?->?8.9.0?(->?v8.9.0) [root@chen-elk-001?elasticsearch-head]#?npm?install?-g?grunt-cli /root/.nvm/versions/node/v8.9.0/bin/grunt?->?/root/.nvm/versions/node/v8.9.0/lib/node_modules/grunt-cli/bin/grunt +?grunt-cli@1.2.0 added?16?packages?in?5.842s [root@chen-elk-001?elasticsearch-head]#
安裝ik插件和head插件
前提工作完畢,現在開始安裝插件。第一個要安裝的是中文分詞插件elasticsearch-analysis-ik-5.5.1.zip,這里安裝的是5.5版本的,與elasticsesrch 5.5版本搭配使用。安裝方法很簡單:#./bin/elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v5.5.1/elasticsearch-analysis-ik-5.5.1.zip?。如圖:
還有一個是瀏覽器顯示插件Elasticsearch-head,下載地址是:https://github.com/mobz/elasticsearch-head,這個里面作者有寫了安裝方法:
但是當執行到#npm install的時候,會發現有爆錯“PhantomJS not found on PATH”,如圖:
安裝其他的東西也是如此,如圖:
這個問題是因為大陸墻內屏蔽,所以無法得到文件,所以這個時候就要使用國內的鏡像:
npm?install?-g?cnpm?--registry=https://registry.npm.taobao.org安裝完畢之后,打開elasticsearch.yml,有幾行需要重點關注:
cluster.name:?my-application????#集群標識符 node.name:?node-1???????????????#節點標識符 path.data:?/path/to/data????????#數據存儲位置 path.logs:?/path/to/logs????????#ES的log存儲位置 bootstrap.memory_lock:?true?????#設為true以確保ES擁有足夠的JVM內存 network.host:?0.0.0.0??????????#ES對外服務的IP地址,改填寫0.0.0.0 http.cors.enabled:?true????#這個是新增 http.cors.allow-origin:?"*"????#這個也是新增然后再執行#npm run start,如圖:
插播一句,這里有一個“Local Npm module "grunt-contrib-jasmine" not found. Is it installed?”的提示,很多地方說墻內的安裝方法是#npm install grunt-contrib-jasmine --registry=https://registry.npm.taobao.org,但是經過我測試,這個方法已經失效了。如何解決,還需要再找其他路徑。如果有知道的話,請留言給我。
如果這個時候后臺elasticsearch在運行中,那么在瀏覽器里打開“http://服務器外網地址:9100”,就會看到如下的情景:
在地址欄里寫上“http://外網地址IP:9200/”,然后點擊“連接”,就會連接到elasticsearch(weather和accounts是我自己建立的索引),如圖。
安裝Kibana和X-Pack
插件安裝過程已經結束,下面要安裝的是Kibana和X-Pack。x-pack是官方推薦的elasticsearch的一個擴展包,將安全,警告,監視,圖形和報告功能捆綁在一個易于安裝的軟件包中,不過這玩意與我們剛剛安裝的head插件有沖突,而且只能免費使用一個月,所以我下面雖然安裝了x-pack,但是實際操作的時候我會把它關掉的。Kibana是一個為 ElasticSearch提供的數據分析的 Web 接口,可使用它對日志進行高效的搜索、可視化、分析等各種操作。
安裝kibana首先要求就是版本號要與elasticsearch的版本號相符,所以我在https://www.elastic.co/downloads/past-releases/kibana-5-5-1?里面下載"LINUX 64-BIT sha",然后就是
[root@chen-elk-001?elk]#?sha1sum?kibana-5.5.1-linux-x86_64.tar.gz [root@chen-elk-001?elk]#?tar?-xzf?kibana-5.5.1-linux-x86_64.tar.gz安裝X-pack很簡單,就是#.elasticsearch安裝路徑/bin/elasticsearch-plugin install x-pack ,然后一路按Y即可。如圖:
重啟elasticsearch之后,返回到kibana的bin目錄下,執行#./kibana-plugin install x-pack ,整個安裝的過程會比較漫長,可以借此機會抽根煙什么的。
啟動kibana的方法就是#./kibana安裝路徑/bin/kibana,如果kibana與elasticsearch版本號向左,那么就會出現下面這個告警提醒:
?[warning]?You're?running?Kibana?別的版本號?with?some?different?versions?of?Elasticsearch?on?a?monitoring?cluster.?Update?Kibana?and?Elasticsearch?to?the?same?version?to?prevent?compatibility?issues:?v5.5.1?@?外網地址:9200?(外網地址)這個雖然是一個warning,但是為了避免踩坑,還是盡快調整成一個版本。
如果出現這個錯誤:
[06:53:01.768]?[warning][license][xpack]?License?information?could?not?be?obtained?from?Elasticsearch.?[illegal_argument_exception]?No?endpoint?or?operation?is?available?at?[_xpack]?::?{"path":"/_xpack","statusCode":400,"response":"{\"error\":{\"root_cause\":[{\"type\ ":\"illegal_argument_exception\",\"reason\":\"No?endpoint?or?operation?is?available?at?[_xpack]\"}],\"type\":\"illegal_argument_exception\",\"reason\":\"No?endpoint?or?operation?is?available?at?[_xpack]\"},\"status\":400}"}這是以為elasticsearch下的x-pack沒有裝好,只有kibana那邊的x-pack是OK的,這個時候看一下是否是在elasticsearch啟動的情況下安裝的x-pack,注意,這里需要停止elasticsearch再安裝。
更改kibana里的kibana.yml,把“server.host: localhost”改成“server.host:?0.0.0.0”,保存退出之后。在瀏覽器上輸入: http://localhost:5601/ ,可以打開Kibana,此時需要輸入用戶名和密碼登錄,默認分別是 elastic 和 changeme。
如果要后臺啟動kibana,命令就是:#nohup /kibana安裝路徑/bin/kibana & , 然后點擊任意鍵返回到xshell對話界面,退出請不要直接點擊右上方的X,而是exit來退出。
如果輸入#curl 'http://localhost:9200/?pretty',爆錯“missing authentication token for REST request [/?pretty]”,如圖:
這個時候需要修改elasticsearch.yml,手動添加一句:
xpack.security.enabled:?false然后重啟elasticsearch,我上面說過了,如果你選擇了head,那么就把elasticsearch的x-pack關掉。
參考資料:https://discuss.elastic.co/t/x-pack-5-1-1-error-in-kibana/70397/3
參考資料: https://github.com/xhlwill/blog/issues/11
參考資料:http://www.yiibai.com/elasticsearch/elasticsearch-getting-start.html
參考資料:https://github.com/mobz/elasticsearch-head
參考資料:http://www.code123.cc/docs/kibana-logstash/v3/10-minute-walk-through.html
最后的最后,如果您覺得本文對您升職加薪有幫助,那么請不吝贊助之手,刷一下下面的二維碼,贊助本人繼續寫更多的博文!
轉載于:https://blog.51cto.com/chenx1242/2045569
與50位技術專家面對面20年技術見證,附贈技術全景圖總結
以上是生活随笔為你收集整理的安装kibana,X-pack和elasticsearch插件的全过程的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 【Android开发学习笔记之一】5大布
- 下一篇: 编写边界条件测试用例原则