安装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????????#如果沒有發(fā)現(xiàn)安裝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插件
前提工作完畢,現(xiàn)在開始安裝插件。第一個(gè)要安裝的是中文分詞插件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?。如圖:
還有一個(gè)是瀏覽器顯示插件Elasticsearch-head,下載地址是:https://github.com/mobz/elasticsearch-head,這個(gè)里面作者有寫了安裝方法:
但是當(dāng)執(zhí)行到#npm install的時(shí)候,會(huì)發(fā)現(xiàn)有爆錯(cuò)“PhantomJS not found on PATH”,如圖:
安裝其他的東西也是如此,如圖:
這個(gè)問題是因?yàn)榇箨憠?nèi)屏蔽,所以無法得到文件,所以這個(gè)時(shí)候就要使用國內(nèi)的鏡像:
npm?install?-g?cnpm?--registry=https://registry.npm.taobao.org安裝完畢之后,打開elasticsearch.yml,有幾行需要重點(diǎn)關(guān)注:
cluster.name:?my-application????#集群標(biāo)識(shí)符 node.name:?node-1???????????????#節(jié)點(diǎn)標(biāo)識(shí)符 path.data:?/path/to/data????????#數(shù)據(jù)存儲(chǔ)位置 path.logs:?/path/to/logs????????#ES的log存儲(chǔ)位置 bootstrap.memory_lock:?true?????#設(shè)為true以確保ES擁有足夠的JVM內(nèi)存 network.host:?0.0.0.0??????????#ES對外服務(wù)的IP地址,改填寫0.0.0.0 http.cors.enabled:?true????#這個(gè)是新增 http.cors.allow-origin:?"*"????#這個(gè)也是新增然后再執(zhí)行#npm run start,如圖:
插播一句,這里有一個(gè)“Local Npm module "grunt-contrib-jasmine" not found. Is it installed?”的提示,很多地方說墻內(nèi)的安裝方法是#npm install grunt-contrib-jasmine --registry=https://registry.npm.taobao.org,但是經(jīng)過我測試,這個(gè)方法已經(jīng)失效了。如何解決,還需要再找其他路徑。如果有知道的話,請留言給我。
如果這個(gè)時(shí)候后臺(tái)elasticsearch在運(yùn)行中,那么在瀏覽器里打開“http://服務(wù)器外網(wǎng)地址:9100”,就會(huì)看到如下的情景:
在地址欄里寫上“http://外網(wǎng)地址IP:9200/”,然后點(diǎn)擊“連接”,就會(huì)連接到elasticsearch(weather和accounts是我自己建立的索引),如圖。
安裝Kibana和X-Pack
插件安裝過程已經(jīng)結(jié)束,下面要安裝的是Kibana和X-Pack。x-pack是官方推薦的elasticsearch的一個(gè)擴(kuò)展包,將安全,警告,監(jiān)視,圖形和報(bào)告功能捆綁在一個(gè)易于安裝的軟件包中,不過這玩意與我們剛剛安裝的head插件有沖突,而且只能免費(fèi)使用一個(gè)月,所以我下面雖然安裝了x-pack,但是實(shí)際操作的時(shí)候我會(huì)把它關(guān)掉的。Kibana是一個(gè)為 ElasticSearch提供的數(shù)據(jù)分析的 Web 接口,可使用它對日志進(jìn)行高效的搜索、可視化、分析等各種操作。
安裝kibana首先要求就是版本號(hào)要與elasticsearch的版本號(hào)相符,所以我在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目錄下,執(zhí)行#./kibana-plugin install x-pack ,整個(gè)安裝的過程會(huì)比較漫長,可以借此機(jī)會(huì)抽根煙什么的。
啟動(dòng)kibana的方法就是#./kibana安裝路徑/bin/kibana,如果kibana與elasticsearch版本號(hào)向左,那么就會(huì)出現(xiàn)下面這個(gè)告警提醒:
?[warning]?You're?running?Kibana?別的版本號(hào)?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?@?外網(wǎng)地址:9200?(外網(wǎng)地址)這個(gè)雖然是一個(gè)warning,但是為了避免踩坑,還是盡快調(diào)整成一個(gè)版本。
如果出現(xiàn)這個(gè)錯(cuò)誤:
[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的,這個(gè)時(shí)候看一下是否是在elasticsearch啟動(dòng)的情況下安裝的x-pack,注意,這里需要停止elasticsearch再安裝。
更改kibana里的kibana.yml,把“server.host: localhost”改成“server.host:?0.0.0.0”,保存退出之后。在瀏覽器上輸入: http://localhost:5601/ ,可以打開Kibana,此時(shí)需要輸入用戶名和密碼登錄,默認(rèn)分別是 elastic 和 changeme。
如果要后臺(tái)啟動(dòng)kibana,命令就是:#nohup /kibana安裝路徑/bin/kibana & , 然后點(diǎn)擊任意鍵返回到xshell對話界面,退出請不要直接點(diǎn)擊右上方的X,而是exit來退出。
如果輸入#curl 'http://localhost:9200/?pretty',爆錯(cuò)“missing authentication token for REST request [/?pretty]”,如圖:
這個(gè)時(shí)候需要修改elasticsearch.yml,手動(dòng)添加一句:
xpack.security.enabled:?false然后重啟elasticsearch,我上面說過了,如果你選擇了head,那么就把elasticsearch的x-pack關(guān)掉。
參考資料: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
最后的最后,如果您覺得本文對您升職加薪有幫助,那么請不吝贊助之手,刷一下下面的二維碼,贊助本人繼續(xù)寫更多的博文!
轉(zhuǎn)載于:https://blog.51cto.com/chenx1242/2045569
與50位技術(shù)專家面對面20年技術(shù)見證,附贈(zèng)技術(shù)全景圖總結(jié)
以上是生活随笔為你收集整理的安装kibana,X-pack和elasticsearch插件的全过程的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 【Android开发学习笔记之一】5大布
- 下一篇: 编写边界条件测试用例原则