ELK—— Elasticsearch 使用问题记录

1.【ElasticSearch】Kibana 连接不上(Unable to connect to Elasticsearch)

参考:https://blog.csdn.net/asdfghjkl0606/article/details/107571949

2. spring中es自定义版本

在pom 文件中添加:

 <properties>
       <java.version>1.8</java.version>
       <elasticsearch.version>6.4.3</elasticsearch.version>
 </properties>

参考:https://www.bilibili.com/video/BV17a4y1x7zq?p=12(约11分钟处)

3. Kibana 设置语言为中文

在kibana.yml配置文件中添加一行配置

i18n.locale: "zh-CN"
4. springboot 集成 es

springboot版本 2.2.3 , es 版本 6.4.3

5. 若遇到无法连接等问题,可以尝试重启 es 服务,或重启电脑
6. springboot集成 es,启动项目报错:
Application run failed
  org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'elasticsearchTemplate' defined in class path resource [org/springframework/boot/autoconfigure/data/elasticsearch/ElasticsearchDataConfiguration$RestClientConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate]: Factory method 'elasticsearchTemplate' threw exception; nested exception is java.lang.BootstrapMethodError: java.lang.NoClassDefFoundError: org/elasticsearch/client/core/MainResponse

原因:springboot 版本过高,为 2.3.5,es版本为6.4.3,版本不匹配
解决办法:修改springboot版本,在pom.xml 中修改

<version>2.3.5.RELEASE</version><version>2.2.3.RELEASE</version>

即可成功启动项目

7. springboot 集成 es 进行批量插入数据操作时,报错如下:

org.elasticsearch.action.ActionRequestValidationException: Validation Failed: 1: type is missing;
image-20201110164806380
​ 原因:因为使用的 es 版本为6.4.3版本,在调用 BulkRequest 时需要添加 type 属性才能成功(若使用 es 7.x 版本可以不添加 type)

代码示例:

List<Content> contents = new HtmlParseUtil().parseJD(keywords);
        //把查询的数据放入我们的es中
        BulkRequest bulkRequest = new BulkRequest();
        bulkRequest.timeout("2m");
        //批量插入
        for (int i = 0; i < contents.size(); i++) {
            System.out.println(JSON.toJSONString(contents.get(i)));
            bulkRequest.add(
                    new IndexRequest("jd_goods","_doc")//这里注意要添加 type,7.x之后自动添加可以不用写,但6.x需要添加
                            .source(JSON.toJSONString(contents.get(i)), XContentType.JSON));
        }

        BulkResponse bulk = restHighLevelClient.bulk(bulkRequest, RequestOptions.DEFAULT);
        return !bulk.hasFailures();
8. 安装 es-head 项目的时候遇到:PhantomJS not found on PATH

解决办法:

1.提示找不到PhantomJS需要进行下载,如果网速允许的话可以直接

npm install -g phantomjs

如果网速不给力的话,那就先进行淘宝镜像安装

npm install -g cnpm --registry=https:``//registry.npm.taobao.org

2.再用cnpm进行下载

cnpm install -g phantomjs

参考:https://www.cnblogs.com/bing0709/p/10315685.html

9. 启动head的时候报警提示Fatal error: Port 9100 is already in use by another process. npm ERR! code ELIFECYCLE

原因: 端口号被占用,关闭运行在该端口的服务即可

1.使用以下命令查找占用端口号为 443 的进程 PID:

 netstat -ano | findstr 443

2.去到任务管理器->任务 找到PID为5140的服务,然后停止掉
image-20201120190402083

10. kibana 创建index pattern 索引模式时过慢导致无法创建成功 以及解决方案

建议先重启电脑,然后执行如下网页中的操作:

https://blog.csdn.net/qq_31589695/article/details/83036812

官方文档参考:https://www.elastic.co/guide/en/kibana/6.0/migrating-6.0-index.html

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值