elasticsearch 5.6.4 head插件安裝
elasticsearch 5.6.4的安裝配置參照《Elasticsearch 5.6.4 分布式集群部署》一文(大小寫就不要在意了^ ^)
head插件只需要安裝在es集群的其中一臺機器上
head插件是用node開發的,所以需要先安裝node
注意:安裝head需要在root和elas用戶下做切換,需要注意
1、安裝node(已經安裝的忽略)
*在root用戶下
cd /opt(我將node安裝在opt下面,可以自行決定安裝路徑)
(獲取node,如果沒有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
設置node的環境變量
vi /etc/profile
增加如下:
export NODE_HOME=/opt/node-v4.4.7-linux-x64
export PATH=$NODE_HOME/bin:$PATH
執行如下命令使環境變量生效:
source /etc/profile
查看node安裝配置是否正確:
node -v
npm -v (安裝node過程中會安裝上npm)
2、安裝grunt-cli(grunt是前端的構建工具,head插件是通過grunt啟動的)
grunt的說明可以參考(http://developer.51cto.com/art/201506/479127.htm)或者其他說明自行搜索
先在root用戶下安裝grunt-CLI。“CLI”被翻譯為“命令行”,要想使用grunt,首先必須將grunt-cli安裝到全局環境中(這句話是別的地方偷的)。
*在root用戶下
使用安裝node時安裝的npm安裝grunt,可以在node的安裝目錄中(/opt/node-v4.4.7-linux-x64)執行下面的命令,-g表示是全局
npm install -g grunt-cli
3、安裝head及項目的grunt(grunt安裝到head內)
*在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)
安裝需要一段時間,安裝完后執行grunt命令
grunt(會看到缺少很多其他的包,如下)
這里需要一個一個安裝缺少的包
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
最后一個比較難安裝,要聯網到一個國外網站下載一個東西,而且貌似有個引擎要求的node比我這里的node版本高,會有一個warning,安裝到Receiving...就殺了進程,殺掉之后再運行grunt可以看到一切都正常了,有條件的可以等待Receiving...后面的內容^ ^
grunt
修改一下head的源代碼
vi /home/elas/elasticsearch-head-master/Gruntfile.js
找到在文件末尾的connect
connect: {
? ? ? ? ? ? ? server: {
? ? ? ? ? ? ? ? ? ? ? ? ? options: {
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? port: 9100,
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? hostname: '*',
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? base: '.',
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? keepalive: true
? ? ? ? ? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? }
}
增加hostname屬性,設置為*
修改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的服務器地址,如:
this.base_uri = this.config.base_uri || this.prefs.get("app-base_uri") || "http://192.168.1.241:9200";
4、啟動head
*head需要在elas用戶下啟動
cd /home/elas/elasticsearch-head-master
grunt server
之后會看到如下的輸出
這里注意下這個命令不是后臺運行的,關掉終端進程就停止了(啟動es也是一樣的),需要常駐后臺的話可以使用nohup命令:
nohup grunt server &
通過瀏覽器訪問http://192.168.1.241:9100,可以看到head的主界面
head的安裝大概就是如此,下一篇將介紹Kibana的安裝以及簡單的使用