ubuntu安裝elasticsearch及head插件

1.安裝elasticsearch部脚,參考http://www.cnblogs.com/hanyinglong/p/5409003.html就可以了

簡單描述下:

mkdir-p /usr/local/kencery/elasticsearch

groupadd elasticsearch

useradd -d /usr/local/kencery/elasticsearch -g elasticsearch -p elasticsearch elasticsearch

然后將tar包解壓到elasticsearch目錄下就可以了屉凯,我下載的版本是elasticsearch-6.2.4.tar.gz

啟動時直接在bin目錄下執(zhí)行:./elasticsearch

有兩個問題注意下邪媳,一是不要用root用戶執(zhí)行,二是有可能會遇到錯誤:

[1]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

參考https://blog.csdn.net/jiankunking/article/details/65448030修改下/etc/sysctl.conf扩氢,記得改下elasticsearch.yml中的network.host以及端口配置唉堪,重啟后就可以訪問了:http://192.168.141.13:9200/

name"4tlNeHN"cluster_name? ? "elasticsearch"cluster_uuid? ? "BYwLfhswS8O2y-WYXAKUsA"version? ?


number? ? "6.2.4"build_hash? ? "ccec39f"build_date? ? "2018-04-12T20:37:28.497551Z"build_snapshot? ? falselucene_version? ? "7.2.1"minimum_wire_compatibility_version? ? "5.6.0"minimum_index_compatibility_version? ? "5.0.0"tagline? ? "You Know, for Search"

2.安裝elasticsearch-head,這里敲下黑板减拭,真的很麻煩,如果不了解区丑,花費(fèi)大半天時間也是很正常的拧粪,這里就直接說下最后成功的辦法

2.1?elasticsearch 5.x之后不支持直接plugin安裝head插件,而是將head作為一個獨(dú)立的服務(wù)安裝的沧侥,首先需要安裝依賴的node可霎,npm,grunt宴杀,參考https://blog.csdn.net/hard_boy/article/details/79565068癣朗,我是以root執(zhí)行的,稍微有點(diǎn)不同:

apt-getinstall npm

apt-getinstallnodejs-legacy

npm install-g grunt

npm install-g grunt-cli

下載elasticsearch-head旺罢,我解壓到目錄/usr/local/kencery/elasticsearch-head旷余,將目錄用戶改為elasticsearch

2.2?然后修改配置

2.2.1?修改head的連接地址 elasticsearch-head/_site/app.js

this.base_uri = this.config.base_uri || this.prefs.get("app-base_uri") ||"http://localhost:9200";

將localhost改為自己的ip

2.2.2?修改服務(wù)器的監(jiān)聽地址elasticsearch-head/Gruntfile.js

connect: {?

? ? ? ? ? ? ? server: {?

? ? ? ? ? ? ? ? ? options: {?

? ? ? ? ? ? ? ? ? ? ? port: 9100,?

? ? ? ? ? ? ? ? ? ? ? base: '.',?

? ? ? ? ? ? ? ? ? ? ? keepalive: true?

? ? ? ? ? ? ? ? ? }?

? ? ? ? ? ? ? }?

? ? ? ? ? }?

options中添加 hostname:?'*'

2.2.3?修改elasticseach的配置文件elasticsearch.yml, 修改對應(yīng)的ip以及跨域的設(shè)置,添加:

http.cors.enabled:?true?

http.cors.allow-origin:?"*"??

2.3?在elasticsearch-head下運(yùn)行: grunt server

2.3.1?但是會出現(xiàn)錯誤提示(當(dāng)時命令敲的npm start扁达,應(yīng)該是一樣的):

root@ubuntu:/usr/local/kencery/elasticsearch-head# npm start> elasticsearch-head@0.0.0start /usr/local/kencery/elasticsearch-head> grunt server

grunt-cli: The grunt command line interface (v1.2.0)

Fatal error: Unable to find local grunt.

If you're seeing this message, grunt hasn't been installed locally to

your project. For more information about installing and configuring grunt,

please see the Getting Started guide:

http://gruntjs.com/getting-startednpm ERR! Linux4.4.0-62-generic

npm ERR! argv"/usr/bin/nodejs""/usr/bin/npm""start"npm ERR! node v4.2.6npm ERR! npm? v3.5.2npm ERR! code ELIFECYCLE

npm ERR! elasticsearch-head@0.0.0 start: `grunt server`

npm ERR! Exit status99npm ERR!

npm ERR! Failed at the elasticsearch-head@0.0.0start script'grunt server'.

npm ERR! Make sure you have the latest version of node.js and npm installed.

npm ERR! If youdo, this is most likely a problem with the elasticsearch-head package,

npm ERR! not with npm itself.

npm ERR! Tell the author that this fails on your system:

npm ERR!? ? grunt server

npm ERR! You can get information on how to open an issuefor this project with:

npm ERR!? ? npm bugs elasticsearch-headnpm ERR! Orifthat isn't available, you can get their info via:npm ERR!? ? npm ownerlselasticsearch-headnpm ERR! There is likely additional logging output above.

npm ERR! Please include the followingfile with any support request:

npm ERR!? ? /usr/local/kencery/elasticsearch-head/npm-debug.log

看提示大概有提到版本不是最新的問題正卧,所以就抱著試一試的心態(tài)去升級npm以及node

參考https://www.cnblogs.com/ae6623/p/6242423.html

npm cache clean -f

npm install-g n

n stable

npm installnpm@latest -g

再查看下版本,會看到

elasticsearch@ubuntu:~$ node -v

v10.4.0elasticsearch@ubuntu:~$ npm -v6.1.0

2.3.2?但是運(yùn)行g(shù)runt server依然報(bào)錯:

grunt hasn't been installed locally to your project

參考https://segmentfault.com/q/1010000004172559/a-1020000004193932跪解,執(zhí)行:

npminstallgrunt --save-dev

2.3.3?再次運(yùn)行炉旷,依然報(bào)錯:

elasticsearch@ubuntu:/usr/local/kencery/elasticsearch-head$ grunt server>> Local Npm module"grunt-contrib-clean"not found. Is it installed?>> Local Npm module"grunt-contrib-concat"not found. Is it installed?>> Local Npm module"grunt-contrib-watch"not found. Is it installed?>> Local Npm module"grunt-contrib-connect"not found. Is it installed?>> Local Npm module"grunt-contrib-copy"not found. Is it installed?>> Local Npm module"grunt-contrib-jasmine"not found. Is it installed?Warning: Task "connect:server"not found. Use --force to continue.

然后我干脆把有關(guān)grunt的都裝了一遍最新的:

npminstall grunt@latest

npm installgrunt-cli@latest

npm installgrunt-contrib-copy@latest

npm installgrunt-contrib-concat@latest

npm installgrunt-contrib-uglify@latest

npm installgrunt-contrib-clean@latest

npm installgrunt-contrib-watch@latest

npm installgrunt-contrib-connect@latest

npm installgrunt-contrib-jasmine@latest

2.3.4?最后grunt server終于可以啟動了:

elasticsearch@ubuntu:/usr/local/kencery/elasticsearch-head$ grunt server

(node:1527) ExperimentalWarning: The http2 module is an experimental API.

Running "connect:server" (connect) task

Waiting forever...

Started connect web server on http://localhost:9100

可以看到elasticsearch服務(wù)的端口是9200,head插件服務(wù)的端口是9100惠遏,我們訪問head然后head再訪問的elasticsearch砾跃。

可以新建索引試一下:

狀態(tài)yellow還是有一些問題,并不影響使用节吮,對于ES也只是剛接觸抽高,并沒多少了解,后續(xù)使用過程中遇到問題再作紀(jì)錄透绩。

參考文章:https://www.cnblogs.com/shanhm1991/p/9903866.html

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末翘骂,一起剝皮案震驚了整個濱河市,隨后出現(xiàn)的幾起案子帚豪,更是在濱河造成了極大的恐慌碳竟,老刑警劉巖,帶你破解...
    沈念sama閱讀 219,270評論 6 508
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件狸臣,死亡現(xiàn)場離奇詭異莹桅,居然都是意外死亡,警方通過查閱死者的電腦和手機(jī)烛亦,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,489評論 3 395
  • 文/潘曉璐 我一進(jìn)店門诈泼,熙熙樓的掌柜王于貴愁眉苦臉地迎上來懂拾,“玉大人,你說我怎么就攤上這事铐达♂常” “怎么了?”我有些...
    開封第一講書人閱讀 165,630評論 0 356
  • 文/不壞的土叔 我叫張陵瓮孙,是天一觀的道長唐断。 經(jīng)常有香客問我,道長杭抠,這世上最難降的妖魔是什么脸甘? 我笑而不...
    開封第一講書人閱讀 58,906評論 1 295
  • 正文 為了忘掉前任,我火速辦了婚禮祈争,結(jié)果婚禮上斤程,老公的妹妹穿的比我還像新娘。我一直安慰自己菩混,他們只是感情好,可當(dāng)我...
    茶點(diǎn)故事閱讀 67,928評論 6 392
  • 文/花漫 我一把揭開白布扁藕。 她就那樣靜靜地躺著沮峡,像睡著了一般。 火紅的嫁衣襯著肌膚如雪亿柑。 梳的紋絲不亂的頭發(fā)上邢疙,一...
    開封第一講書人閱讀 51,718評論 1 305
  • 那天,我揣著相機(jī)與錄音望薄,去河邊找鬼疟游。 笑死,一個胖子當(dāng)著我的面吹牛痕支,可吹牛的內(nèi)容都是我干的颁虐。 我是一名探鬼主播,決...
    沈念sama閱讀 40,442評論 3 420
  • 文/蒼蘭香墨 我猛地睜開眼卧须,長吁一口氣:“原來是場噩夢啊……” “哼另绩!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起花嘶,我...
    開封第一講書人閱讀 39,345評論 0 276
  • 序言:老撾萬榮一對情侶失蹤笋籽,失蹤者是張志新(化名)和其女友劉穎,沒想到半個月后椭员,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體车海,經(jīng)...
    沈念sama閱讀 45,802評論 1 317
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 37,984評論 3 337
  • 正文 我和宋清朗相戀三年隘击,在試婚紗的時候發(fā)現(xiàn)自己被綠了侍芝。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片研铆。...
    茶點(diǎn)故事閱讀 40,117評論 1 351
  • 序言:一個原本活蹦亂跳的男人離奇死亡,死狀恐怖竭贩,靈堂內(nèi)的尸體忽然破棺而出蚜印,到底是詐尸還是另有隱情,我是刑警寧澤留量,帶...
    沈念sama閱讀 35,810評論 5 346
  • 正文 年R本政府宣布窄赋,位于F島的核電站,受9級特大地震影響楼熄,放射性物質(zhì)發(fā)生泄漏忆绰。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,462評論 3 331
  • 文/蒙蒙 一可岂、第九天 我趴在偏房一處隱蔽的房頂上張望错敢。 院中可真熱鬧,春花似錦缕粹、人聲如沸稚茅。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,011評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽亚享。三九已至,卻和暖如春绘面,著一層夾襖步出監(jiān)牢的瞬間欺税,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 33,139評論 1 272
  • 我被黑心中介騙來泰國打工揭璃, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留晚凿,地道東北人。 一個月前我還...
    沈念sama閱讀 48,377評論 3 373
  • 正文 我出身青樓瘦馍,卻偏偏與公主長得像歼秽,于是被迫代替她去往敵國和親。 傳聞我的和親對象是個殘疾皇子扣墩,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 45,060評論 2 355