- 安装,去es官网下载安装包,解压就是安装.
下载链接:https://www.elastic.co/downloads/elasticsearch
需要注意的就是操作系统位数好像有关系,一开始在32位的centos上安装没成功,最后转移到了mac上。
- 启动:进入es目录下的bin,执行
./elasticsearch –d(-d表示后台执行)
注意es默认是不能用root用户启动的,所以得新建用户进行启动
- 验证
执行curl http://127.0.0.1:9200(返回json串)
- 关闭服务
mac:lsof –I tcp:9200(查询端口占用的pid)
kill pid
win:netstat –nao|findstr 9200
taskkill –F –pid [pid]
- 安装elasticsearch-head:
- 安装elasticsearch-head是一款开源组件,被托管在github上面,想使用必须先安装git(拉取地址:git://github.com/mobz/elasticsearch-head.git)
- 运行head会用到grunt,grunt需要npm包管理器,所以需要安装nodejs
- 在head上层目录执行
npm install –g grunt-cli(local目录下)
cd /usr/local/elasticsearch-head
cnpm install
这块会提示cnpm没有这个命令,百度下载方式
-
- vi gruntfile.js
在connect->server->options下面添加:hostname:”*”,允许所有ip访问
-
- 配置es->config下的elasticsearch.yml
后面加上
http.cors.enables: true
http.cors.allow-origin: “*”
- 启动es
- 进入es-head执行:npm run start(启动head)
- 访问9100端口
注意:本次安装是在mac下进行的,如果在服务器上需要开放端口