一、下载安装包
下载Elasticsearch 5.2.2
下载地址:https://www.elastic.co/downloads/elasticsearch
zip和tar格式是各种系统都通用的,解压之后启动Elasticsearch即可。
下载elasticsearch-head
下载地址:https://github.com/mobz/elasticsearch-head,下载后解压缩。
二、安装node、npm、grunt
1.安装需要的依赖
yum install gcc openssl-devel gcc-c++ compat-gcc-34 compat-gcc-34-c++
2.下载node.js的文件,建议下载淘宝镜像文件,速度快不少,这里我把下好的文件放在/usr/src里面
cd /usr/src
wget https://npm.taobao.org/mirrors/node/v8.2.1/node-v8.2.1-linux-x64.tar.gz
3.解压文件,顺便改个名字
tar -zxf node-v8.2.1-linux-x64.tar.gz
mv node-v8.2.1-linux-x64 node-v8.2.1
4.配置环境变量
vim /etc/profile
添加
export NODE_HOME=/usr/src/node-v8.2.1
export PATH=$PATH:$NODE_HOME/bin
export NODE_PATH=$NODE_HOME/lib/node_modules
执行source /etc/profile刷新配置
执行node -v
$ npm -v
使用npm安装grunt:
npm install –g grunt–cli
三、npm 安装依赖
到elasticsearch-head-master目录下,运行命令:
npm install
如果速度较慢或者安装失败,可以使用国内镜像:
npm install -g cnpm --registry=https://registry.npm.taobao.org
四、修改Elasticsearch配置文件
编辑elasticsearch-5.1.1/config/elasticsearch.yml,加入以下内容:
http.cors.enabled: true
http.cors.allow-origin: "*"
五、修改Gruntfile.js
打开elasticsearch-head-master/Gruntfile.js,找到下面connect属性,新增hostname: ‘0.0.0.0’:
connect: {
server: {
options: {
hostname: '0.0.0.0',
port: 9100,
base: '.',
keepalive: true
}
}
}
六、启动elasticsearch-head
在elasticsearch-head-master/目录下,运行启动命令:
grunt server
截图如下:
访问9100端口:
七、后台启动elasticsearch-head
后台启动grunt server命令;
nohup grunt server &exit
如果想关闭head插件,使用linux查找进程命令:
ps aux|grep head
结束进程:
kill 进程号
八、windows安装注意事项
Windows环境下安装,最好按照附件->命令行工具->右键以管理员身份运行,再执行安装命令。