mac安装elasticsearch 和elasticsearch-head

安装ES6版本

想要安装ES的前提是已经在本机安装了Java环境,由于安装ES6版本,因此安装jdk1.8及以上版本

$ java -version

我是采用brew install命令进行安装的

$ brew update
$ brew install elasticsearch

启动ES和停止

$ brew services start elasticsearch
$ brew services stop elasticsearch

elasticsearch   //        启动
control + c     //        停止

重启:

$ brew services restart elasticsearch

启动后浏览

http://localhost:9200

安装elasticsearch-head插件

安装node

brew install node

下载插件并安装

插件主页:https://github.com/mobz/elasticsearch-head

git clone git://github.com/mobz/elasticsearch-head.git
cd elasticsearch-head
npm install

安装完成后在elasticsearch-head/node_modules目录下会出现grunt文件。
如果没有grunt二进制程序,需要执行

cd elasticsearch-head
npm install grunt --save

修改服务器监听地址

修改elasticsearch-head下Gruntfile.js文件,默认监听在127.0.0.1下9200端口

connect: {
        server: {
            options: {
                hostname: '*',
                port: 9100,
                base: '.',
                keepalive: true
            }
        }
    } 

修改连接地址

cd elasticsearch-head/_site
vim app.js

this.base_uri = this.config.base_uri || this.prefs.get("app-base_uri") || "http://localhost:9200";

在cd elasticsearch-head目录下运行

grunt server

输出:

>> Local Npm module "grunt-contrib-jasmine" not found. Is it installed?

Running "connect:server" (connect) task
Waiting forever...
Started connect web server on http://localhost:9100

浏览器访问 
http://localhost:9100

访问后会发现 集群健康值:显示“未连接”

解决方案:

vim $ES_HOME$/config/elasticsearch.yml

由于我采用brew安装的ES所以$ES_HOME$/config为/usr/local/etc/elasticsearch/
增加如下字段

http.cors.enabled: true
http.cors.allow-origin: "*"

重启es,并刷新head页面,发现已经可以连接上。

使用brew install安装es后的一些安装路径:

elasticsearch:  /usr/local/Cellar/elasticsearch/6.2.4
Data:    /usr/local/var/elasticsearch/elasticsearch_xuchen/
Logs:    /usr/local/var/log/elasticsearch/elasticsearch_xuchen.log
Plugins: /usr/local/opt/elasticsearch/libexec/plugins/
Config:  /usr/local/etc/elasticsearch/
plugin script: /usr/local/opt/elasticsearch/libexec/bin/elasticsearch-plugin

 

  • 5
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值