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ì)錄透绩。