您好,登錄后才能下訂單哦!
系統(tǒng)環(huán)境:
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,這個網(wǎng)上一大堆參考文檔。
這里大概說一下,就是解壓包然后配置環(huán)境變量
路徑根據(jù)自己解壓的位置去指定。最后source /etc/profile
mkdir -p /data/software/elasticsearch
創(chuàng)建用戶,因為啟動es不能用root用戶。
sudo adduser es
然后敲個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):
我們每個機(jī)器上做一個es,這個不是建議也不是什么經(jīng)驗之談,因為你是運(yùn)維(背鍋俠),你的要注意都做一臺機(jī)器上萬一機(jī)器宕機(jī)了,數(shù)據(jù)可就全沒了。最普通小白安全的做法就是3臺機(jī)器每個服務(wù)器上只做一個節(jié)點(此做法允許且只允許任意一臺服務(wù)器宕機(jī)),不了解es為什么這樣做的請讀我的技術(shù)點篇。
接下來我們修改elasticsearch的配置文件。
修改完成以后我們切換到es用戶去啟動es,記?。呵袚Q到es用戶!切換到es用戶!!切換到es用戶?。?!
要不就會出現(xiàn)如下情況:
但是你可能會遇到如下情況哈哈,不要慌:基本操作。
[1]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
等問題,修改幾個配置文件:/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
一切正常后我們再啟動
我們在網(wǎng)頁訪問ip:9200出來如下內(nèi)容表示成功
其他的2個節(jié)點按上邊的操作正常操作完畢(可能會出現(xiàn)的一個問題啟動前先刪除/data/software/elasticsearch/data/節(jié)點目錄下的數(shù)據(jù)),出現(xiàn)如上圖恭喜你成功了.
接下來就是安裝比較麻煩又low的elasticsearch-head,也給大家操作一下吧,(生產(chǎn)環(huán)境能不用head插件盡量別用,因為安全性特別差暴露給別人,別人可以上你的es對節(jié)點進(jìn)行操作)
elasticsearch 5.x之后不支持直接plugin安裝head插件,而是將head作為一個獨立的服務(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, 修改對應(yīng)的ip以及跨域的設(shè)置,添加:
http.cors.enabled: true
http.cors.allow-origin: "*"
3 在elasticsearch-head下運(yùn)行: grunt server
3.1 但是會出現(xiàn)錯誤提示(當(dāng)時命令敲的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)去升級npm以及node
npm cache clean -f
npm install -g n
n stable
npm install npm@latest -g
再查看下版本,會看到
elasticsearch@ubuntu:~$ node -v
v10.4.0
elasticsearch@ubuntu:~$ npm -v
6.1.0
3.2 但是運(yùn)行g(shù)runt server依然報錯:
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)行,依然報錯:
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終于可以啟動了:
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。
參考文檔:
1https://blog.csdn.net/shm839218753/article/details/80618073
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。