ElasticSearch Head插件

ElasticSearch Head是什么?

ElasticSearch Head是集群管理、数据可视化、增删查改、查询语句可视化工具。

安装

  • 在https://github.com/mobz/elasticsearch-head下载elasticsearch-head-master.zip

  • 解压elasticsearch-head-master.zip到/usr/local/fast/ 

  • unzip elasticsearch-head-master.zip -d /usr/local/fast/

  • 在plugins目录下创建head。把

    mkdir -p /usr/local/fast/elasticsearch-6.1.1/plugins/head/

  • 把刚才解压的elasticsearch-head-master文件夹下的所有的文件拷贝到/plugins/head/下。


     

  • 我们可以通过Jps命令(java virtual machine process status tool 是jdk1.5提供的一个现实当前所有java进程pid的命令),查看ElasticSearch进程号,然后kill掉它。

  • 重启elasticsearch,抛出了“java.lang.IllegalArgumentException: property [elasticsearch.version] is missing for plugin [head]”异常。

  • [2018-01-08T16:51:09,225][WARN ][o.e.b.ElasticsearchUncaughtExceptionHandler] [node-1] uncaught exception in thread [main]
    org.elasticsearch.bootstrap.StartupException: java.lang.IllegalArgumentException: property [elasticsearch.version] is missing for plugin [head]
    at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:125) ~[elasticsearch-6.1.1.jar:6.1.1]
    at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:112) ~[elasticsearch-6.1.1.jar:6.1.1]
    at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86) ~[elasticsearch-6.1.1.jar:6.1.1]
    at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:124) ~[elasticsearch-cli-6.1.1.jar:6.1.1]
    at org.elasticsearch.cli.Command.main(Command.java:90) ~[elasticsearch-cli-6.1.1.jar:6.1.1]
    at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:92) ~[elasticsearch-6.1.1.jar:6.1.1]
    at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:85) ~[elasticsearch-6.1.1.jar:6.1.1]
    Caused by: java.lang.IllegalArgumentException: property [elasticsearch.version] is missing for plugin [head]
    at org.elasticsearch.plugins.PluginInfo.readFromProperties(PluginInfo.java:144) ~[elasticsearch-6.1.1.jar:6.1.1]
    问题所在是elasticsearch-head-master解压后的内容不能放在elasticsearch的plugins目录下,所以我们删除到plugins目录下的head。
  • rm -rf head
  • 更操蛋的是,我们竟然还没有安装elasticsearch-head,我们只是下了安装包,但是没有安装。我们需要node.js环境

    wget https://npm.taobao.org/mirrors/node/latest-v4.x/node-v4.4.7-linux-x64.tar.gz
    [图片上传失败...(image-87af7d-1515403754611)]

  • 在/usr/local/目录下创建nodejs文件夹。

  • 把node-v4.4.7-linux-x64.tar.gz解压到/usr/local/nodejs。

  • 配置环境变量,编辑/etc/profile添加以下内容,然后执行source /etc/profile,我们接着就可以查看node.js的版本号了。

    NODE_HOME=/usr/local/nodejs/node-v4.4.7-linux-x64
    PATH=$PATH:$NODE_HOME/bin
    NODE_PATH=$NODE_HOME/lib/node_modules
    export NODE_HOME PATH NODE_PATH
  • 安装grunt(grunt是基于Node.js的项目构建工具,可以进行打包压缩、测试、执行等等工作,elasticsearch-head插件就是通过grunt启动的)。进入/usr/local/fast/elasticsearch-head-master/目录下进行安装。安装完毕,我们可以检查是否安装成功。

    npm install -g grunt-cli
    grunt -version

  • 修改elasticsearch-head-master文件下的Gruntfile.js文件中,添加一行"hostname: '0.0.0.0',"
  • 在elasticsearch-head-master目录下
  • npm install

  •  
  • 但是安装的太慢了,我不想吐槽了。我们需要将npm换个镜像。
  • npm install -g cnpm --registry=https://registry.npm.taobao.org
  • 我们再来安装elasticsearch-head-master.我们用cnpm代替npm
    cnpm install
  • 安装完毕后,会生成一个node_modules文件夹。
  •  
  • 我们还要修改elasticsearch.yml,具体如下。
  • #集群的名字 
    cluster.name:   es_cmazxiaoma_cluster
    #节点名字   
    node.name:      node-1
    #数据存储目录(多个路径)
    path.data:      /home/elasticsearch/data
    #日志目录     
    path.logs:      /home/elasticsearch/logs
    #本机的ip地址
    network.host:   192.168.12.6
    #设置集群中master节点的初始列表,可以通过这些节点来自动发现新加入集群的节点
    discovery.zen.ping.unicast.hosts:       ["192.168.12.6"]
    #设置节点间tcp端口(集群),默认9300
    transport.tcp.port:     9300
    #监听端口(默认) 
    http.port:      9200
    #增加参数,使head插件可以访问es
    http.cors.enabled:      true
    http.cors.allow-origin: "*"
  • 总结
    
  • * 默认情况下,elasticsearch在elasticsearch-head连接的端口9200上公开一个http rest API。当不作为elasticsearch的插件运行时,您必须在elasticsearch中启用CORS,否则您的浏览器将拒绝看起来不安全的请求。看elasticsearch配置中:加http.cors.enabled:true,您还必须设置http.cors.allow-origin因为默认情况下不允许来源。http.cors.allow-origin:"*"是一个合法的值,但是它被认为是一个安全风险,因为你的集群是开放式的。
    
    * 运行elasticsearch-head
    > grunt server
    ![image.png](http://upload-images.jianshu.io/upload_images/4636177-6c6b9927caacc841.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
    
    * 忘记了,elasticsearch-head web端口是9100。如果我们想通过浏览器去访问它,必须在防火墙添加9100端口策略。
    ![image.png](http://upload-images.jianshu.io/upload_images/4636177-374d365783bf01e5.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
    
    * 访问192.168.12.6:9100
    ![image.png](http://upload-images.jianshu.io/upload_images/4636177-9759478f16e073ee.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
    
    * 启动elasticsearch。
    ![image.png](http://upload-images.jianshu.io/upload_images/4636177-95a5b33307c10ed8.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
    
    * 我们来通过elasticsearch-head来连接elasticsearch。
    
    > 因为head插件可以对数据进行增删查改,所以生产环境尽量不要使用,最少要限制ip地址。尽量不要使用
    
    ###Summary
    > 下一篇讲head插件的具体使用和
    elasticsearch-analysis-ik分词插件。

启动elasticsearch-head 后台挂起

grunt server &

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

那些年的代码

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值