elasticsearch 5.6.4 head插件安裝
elasticsearch 5.6.4的安裝配置參照《Elasticsearch 5.6.4 分布式集群部署》一文(大小寫就不要在意了^ ^)
head插件只需要安裝在es集群的其中一臺(tái)機(jī)器上
head插件是用node開發(fā)的溯革,所以需要先安裝node
注意:安裝head需要在root和elas用戶下做切換贞绳,需要注意
1、安裝node(已經(jīng)安裝的忽略)
*在root用戶下
cd /opt(我將node安裝在opt下面鬓照,可以自行決定安裝路徑)
(獲取node熔酷,如果沒(méi)有wget,自行安裝)
wget https://npm.taobao.org/mirrors/node/latest-v4.x/node-v4.4.7-linux-x64.tar.gz
tar -xvzf node-v4.4.7-linux-x64.tar.gz
設(shè)置node的環(huán)境變量
vi /etc/profile
增加如下:
export NODE_HOME=/opt/node-v4.4.7-linux-x64
export PATH=$NODE_HOME/bin:$PATH
執(zhí)行如下命令使環(huán)境變量生效:
source /etc/profile
查看node安裝配置是否正確:
node -v
npm -v (安裝node過(guò)程中會(huì)安裝上npm)
2豺裆、安裝grunt-cli(grunt是前端的構(gòu)建工具拒秘,head插件是通過(guò)grunt啟動(dòng)的)
grunt的說(shuō)明可以參考(http://developer.51cto.com/art/201506/479127.htm)或者其他說(shuō)明自行搜索
先在root用戶下安裝grunt-CLI〕舨拢“CLI”被翻譯為“命令行”躺酒,要想使用grunt,首先必須將grunt-cli安裝到全局環(huán)境中(這句話是別的地方偷的)蔑歌。
*在root用戶下
使用安裝node時(shí)安裝的npm安裝grunt羹应,可以在node的安裝目錄中(/opt/node-v4.4.7-linux-x64)執(zhí)行下面的命令,-g表示是全局
npm install -g grunt-cli
3次屠、安裝head及項(xiàng)目的grunt(grunt安裝到head內(nèi))
*在elas用戶下
su - elas
cd /home/elas
wget? https://github.com/mobz/elasticsearch-head/archive/master.zip
unzip master.zip? (生成elasticsearch-head-master文件夾)
cd elasticsearch-head-master
npm install grunt? ? (安裝grunt)
安裝需要一段時(shí)間园匹,安裝完后執(zhí)行g(shù)runt命令
grunt(會(huì)看到缺少很多其他的包,如下)
這里需要一個(gè)一個(gè)安裝缺少的包
npm install grunt-contrib-clean
npm install grunt-contrib-concat
npm install grunt-contrib-watch
npm install grunt-contrib-connect (安裝了太久)
npm install grunt-contrib-copy
npm install grunt-contrib-jasmine
最后一個(gè)比較難安裝劫灶,要聯(lián)網(wǎng)到一個(gè)國(guó)外網(wǎng)站下載一個(gè)東西裸违,而且貌似有個(gè)引擎要求的node比我這里的node版本高,會(huì)有一個(gè)warning本昏,安裝到Receiving...就殺了進(jìn)程供汛,殺掉之后再運(yùn)行g(shù)runt可以看到一切都正常了,有條件的可以等待Receiving...后面的內(nèi)容^ ^
grunt
修改一下head的源代碼
vi /home/elas/elasticsearch-head-master/Gruntfile.js
找到在文件末尾的connect
connect: {
? ? ? ? ? ? ? server: {
? ? ? ? ? ? ? ? ? ? ? ? ? options: {
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? port: 9100,
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? hostname: '*',
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? base: '.',
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? keepalive: true
? ? ? ? ? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? }
}
增加hostname屬性涌穆,設(shè)置為*
修改app.js,注意這里即使你的head和es安裝在一起也不能使用localhost所以需要修改app.js
vi /home/elas/elasticsearch-head-master/_site/app.js
修改head的連接地址(在文件中找到):
this.base_uri = this.config.base_uri || this.prefs.get("app-base_uri") || "http://localhost:9200";
把localhost修改成你es的服務(wù)器地址怔昨,如:
this.base_uri = this.config.base_uri || this.prefs.get("app-base_uri") || "http://192.168.1.241:9200";
4、啟動(dòng)head
*head需要在elas用戶下啟動(dòng)
cd /home/elas/elasticsearch-head-master
grunt server
之后會(huì)看到如下的輸出
這里注意下這個(gè)命令不是后臺(tái)運(yùn)行的宿稀,關(guān)掉終端進(jìn)程就停止了(啟動(dòng)es也是一樣的)趁舀,需要常駐后臺(tái)的話可以使用nohup命令:
nohup grunt server &
通過(guò)瀏覽器訪問(wèn)http://192.168.1.241:9100,可以看到head的主界面
head的安裝大概就是如此,下一篇將介紹Kibana的安裝以及簡(jiǎn)單的使用