安裝nodejs
cd /usr/local/src
wget https://nodejs.org/dist/v6.11.3/node-v6.11.3-linux-x64.tar.xz
yum -y install xz
xz -d node-v6.11.3-linux-x64.tar.xz
tar xf node-v6.11.3-linux-x64.tar -C /usr/local/
ln -s /usr/local/node-v6.11.3-linux-x64 /usr/local/node
vim /etc/profile
###NODE###
export NODE_HOME=/usr/local/node
###所有PATH###
export PATH=$NODE_HOME/bin:$JAVA_HOME/bin:$JRE_HOME/bin:$PATH
一條命令搞定:
echo -e '###NODE###\nexport NODE_HOME=/usr/local/node\n###所有PATH###\nexport PATH=$NODE_HOME/bin:$JAVA_HOME/bin:$JRE_HOME/bin:$PATH'>>/etc/profile&&source /etc/profile&&tail -4 /etc/profile
檢查
[root@elk-node1 src]# node -v
v6.11.3
[root@elk-node1 src]# npm -v
3.10.10
安裝grunt
npm install -g grunt-cli --registry=https://registry.npm.taobao.org
grunt -version
安裝git
yum -y install git
安裝head插件
克隆代碼
mkdir -p /usr/local/elasticsearch-plugin/head/
cd /usr/local/elasticsearch-plugin/head/
git clone git://github.com/mobz/elasticsearch-head.git
修改head插件配置
修改服務(wù)器監(jiān)聽地址 目錄:head/Gruntfile.js 92行后秩仆,增加hostname屬性隘谣,設(shè)置為*
vim /usr/local/elasticsearch-plugin/head/elasticsearch-head/Gruntfile.js
connect: {
server: {
options: {
port: 9100,
hostname: '*',
base: '.',
keepalive: true
}
}
}
修改連接地址:目錄:/usr/local/elasticsearch-plugin/head/elasticsearch-head/_site/app.js
把localhost修改成你es的服務(wù)器地址
sed -i 's#localhost:9200#elk-node1:9200#g' /usr/local/elasticsearch-plugin/head/elasticsearch-head/_site/app.js
查看:
this.base_uri = this.config.base_uri || this.prefs.get("app-base_uri") || "http://elk-node1:9200";
配置elastic插件支持
增加新的參數(shù),這樣head插件可以訪問es,然后重啟 elasticsearch
vim /usr/local/elasticsearch/config/elasticsearch.yml
# head plugins
http.cors.enabled: true
http.cors.allow-origin: "*"
下載依賴包
cd /usr/local/elasticsearch-plugin/head/elasticsearch-head/
npm install --registry=https://registry.npm.taobao.org
有一個phantomjs-2.1.1-linux-x86_64.tar.bz2 無法下載,手工翻墻后,下載后放入到/tmp/phantomjs/下;并操作下面命令
rm -rf /usr/local/elasticsearch-plugin/head/elasticsearch-head/node_modules/
后再次執(zhí)行 npm install --registry=https://registry.npm.taobao.org 成功后執(zhí)行
cd /usr/local/elasticsearch-plugin/head/elasticsearch-head
grunt server
查看
將相關(guān)主機(jī)名添加到window的hosts中:
C:\Windows\System32\drivers\etc
192.168.200.21 elk-node1
瀏覽器訪問:http://192.168.200.21:9100/