系統(tǒng)環(huán)境:
創(chuàng)新互聯(lián)堅(jiān)持“要么做到,要么別承諾”的工作理念,服務(wù)領(lǐng)域包括:成都網(wǎng)站建設(shè)、成都網(wǎng)站制作、企業(yè)官網(wǎng)、英文網(wǎng)站、手機(jī)端網(wǎng)站、網(wǎng)站推廣等服務(wù),滿足客戶于互聯(lián)網(wǎng)時(shí)代的鹿泉網(wǎng)站設(shè)計(jì)、移動(dòng)媒體設(shè)計(jì)的需求,幫助企業(yè)找到有效的互聯(lián)網(wǎng)解決方案。努力成為您成熟可靠的網(wǎng)絡(luò)建設(shè)合作伙伴!
jdk1.8環(huán)境
ubuntu16.04系統(tǒng) 172.20.1.10 node-1
ubuntu16.04系統(tǒng) 172.20.1.20 node-2
ubuntu16.0.4系統(tǒng) 172.20.1.30 node-3
安裝elasticsearch版本:elasticsearch-6.2.2.tar.gz
安裝包下載路徑(里邊有6.2.2版本、6.4.2版本和jdk1.8的包):
https://pan.baidu.com/s/1bTBb6n27wcunwAFCRB5yNQ 密碼:8raw
1.安裝elasticsearch參考:http://www.cnblogs.com/hanyinglong/p/5409003.html
說一下我自己的做法
查看一下自己的java環(huán)境換成jdk1.8,這個(gè)網(wǎng)上一大堆參考文檔。
這里大概說一下,就是解壓包然后配置環(huán)境變量
路徑根據(jù)自己解壓的位置去指定。最后source /etc/profile
mkdir -p /data/software/elasticsearch
創(chuàng)建用戶,因?yàn)閱?dòng)es不能用root用戶。
sudo adduser es
然后敲個(gè)Y完事。
cd /home/下看一下有沒有家目錄。
然后到下載包存放路徑解壓包。
sudo tar -zxvf elasticsearch-2.3.1.tar.gz
sudo mv elasticsearch-2.3.1 /data/software/elasticsearch
sudo chown -R es.es /data/software/elasticsearch
我們看一下es的文件結(jié)構(gòu):
我們每個(gè)機(jī)器上做一個(gè)es,這個(gè)不是建議也不是什么經(jīng)驗(yàn)之談,因?yàn)槟闶沁\(yùn)維(背鍋俠),你的要注意都做一臺(tái)機(jī)器上萬一機(jī)器宕機(jī)了,數(shù)據(jù)可就全沒了。最普通小白安全的做法就是3臺(tái)機(jī)器每個(gè)服務(wù)器上只做一個(gè)節(jié)點(diǎn)(此做法允許且只允許任意一臺(tái)服務(wù)器宕機(jī)),不了解es為什么這樣做的請(qǐng)讀我的技術(shù)點(diǎn)篇。
接下來我們修改elasticsearch的配置文件。
修改完成以后我們切換到es用戶去啟動(dòng)es,記?。呵袚Q到es用戶!切換到es用戶??!切換到es用戶?。?!
要不就會(huì)出現(xiàn)如下情況:
但是你可能會(huì)遇到如下情況哈哈,不要慌:基本操作。
[1]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
等問題,修改幾個(gè)配置文件:/etc/profile文件最后邊添加:ulimit -SHn 65536
/etc/security/limits.conf文件最后添加:
- soft nofile 65536
- hard nofile 65536
- soft nproc 4096
- hard nproc 4096
然后我們把這些配置應(yīng)用到es用戶可以看一下ulimit -Hn
一切正常后我們?cè)賳?dòng)
我們?cè)诰W(wǎng)頁訪問ip:9200出來如下內(nèi)容表示成功
其他的2個(gè)節(jié)點(diǎn)按上邊的操作正常操作完畢(可能會(huì)出現(xiàn)的一個(gè)問題啟動(dòng)前先刪除/data/software/elasticsearch/data/節(jié)點(diǎn)目錄下的數(shù)據(jù)),出現(xiàn)如上圖恭喜你成功了.
接下來就是安裝比較麻煩又low的elasticsearch-head,也給大家操作一下吧,(生產(chǎn)環(huán)境能不用head插件盡量別用,因?yàn)榘踩蕴貏e差暴露給別人,別人可以上你的es對(duì)節(jié)點(diǎn)進(jìn)行操作)
elasticsearch 5.x之后不支持直接plugin安裝head插件,而是將head作為一個(gè)獨(dú)立的服務(wù)安裝的,首先需要安裝依賴的node,npm,grunt
apt-get install npm
apt-get install nodejs-legacy
npm install -g grunt
npm install -g grunt-cli
下載elasticsearch-head,我解壓到目錄/data/software/elasticsearch-head,將目錄用戶改為es
然后修改配置
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.修改服務(wù)器的監(jiān)聽地址elasticsearch-head/Gruntfile.js
connect: { server: { options: { port: 9100, base: '.', keepalive: true } } }
options中添加 hostname: '*'
3.修改elasticseach的配置文件elasticsearch.yml, 修改對(duì)應(yīng)的ip以及跨域的設(shè)置,添加:
http.cors.enabled: true
http.cors.allow-origin: "*"
3 在elasticsearch-head下運(yùn)行: grunt server
3.1 但是會(huì)出現(xiàn)錯(cuò)誤提示(當(dāng)時(shí)命令敲的npm start,應(yīng)該是一樣的):
root@ubuntu:/usr/local/kencery/elasticsearch-head# npm start
elasticsearch-head@0.0.0 start /usr/local/kencery/elasticsearch-head
grunt servergrunt-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-started
npm ERR! Linux 4.4.0-62-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "start"
npm ERR! node v4.2.6
npm ERR! npm v3.5.2
npm ERR! code ELIFECYCLE
npm ERR! elasticsearch-head@0.0.0 start:grunt server
npm ERR! Exit status 99
npm ERR!
npm ERR! Failed at the elasticsearch-head@0.0.0 start script 'grunt server'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, 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 issue for this project with:
npm ERR! npm bugs elasticsearch-head
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls elasticsearch-head
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /usr/local/kencery/elasticsearch-head/npm-debug.log
看提示大概有提到版本不是最新的問題,所以就抱著試一試的心態(tài)去升級(jí)npm以及node
npm cache clean -f
npm install -g n
n stable
npm install npm@latest -g
再查看下版本,會(huì)看到
elasticsearch@ubuntu:~$ node -v
v10.4.0
elasticsearch@ubuntu:~$ npm -v
6.1.0
3.2 但是運(yùn)行g(shù)runt server依然報(bào)錯(cuò):
grunt hasn't been installed locally to your project
參考 https://segmentfault.com/q/1010000004172559/a-1020000004193932, 執(zhí)行:
npm install grunt --save-dev
3.3 再次運(yùn)行,依然報(bào)錯(cuò):
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的都裝了一遍最新的:
npm install grunt@latest
npm install grunt-cli@latest
npm install grunt-contrib-copy@latest
npm install grunt-contrib-concat@latest
npm install grunt-contrib-uglify@latest
npm install grunt-contrib-clean@latest
npm install grunt-contrib-watch@latest
npm install grunt-contrib-connect@latest
npm install grunt-contrib-jasmine@latest
4.4 最后grunt server終于可以啟動(dòng)了:
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,我們?cè)L問head然后head再訪問的elasticsearch。
參考文檔:
1https://blog.csdn.net/shm839218753/article/details/80618073
名稱欄目:Elasticsearch集群搭建1WelcometomyELKworld!
網(wǎng)站鏈接:http://chinadenli.net/article0/ppsdoo.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供軟件開發(fā)、企業(yè)建站、品牌網(wǎng)站設(shè)計(jì)、搜索引擎優(yōu)化、用戶體驗(yàn)、服務(wù)器托管
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)