• ElasticSearch 爬坑记录


    1. received plaintext http traffic on an https channel, closing connection Netty4HttpChannel

    [2022-02-16T21:08:50,085][WARN ][o.e.x.s.t.n.SecurityNetty4HttpServerTransport] [DESKTOP-VCT39JM] received plaintext http traffic on an https channel, closing connection Netty4HttpChannel{localAddress=/[0:0:0:0:0:0:0:1]:9200, remoteAddress=/[0:0:0:0:0:0:0:1]:1172}

    解决

    是因为开启了 ssl 认证。
    在 ES/config/elasticsearch.yml 文件中把 xpack.security.http.ssl:enabled 设置成 false 即可

    # Enable encryption for HTTP API client connections, such as Kibana, Logstash, and Agents
    xpack.security.http.ssl:
      enabled: false
      keystore.path: certs/http.p12
    
    • 1
    • 2
    • 3
    • 4

    2. elasticsearch 账号密码

    windows 下直接启动 ElasticSearch ,见到 started 为成功启动,访问 htttp://localhost:9200 需要输入密码,是因为开启了密码验证模式。
    找了一轮没看到有账号密码,干脆就设置免密登录就好。

    解决

    找到 elasticsearch.yml 文件, 把 xpack.security.enabled 属性设置为 false 即可。

    # Enable security features
    xpack.security.enabled: false
    
    • 1
    • 2

    3. 设置内存大小

    ES 的内存是自己调节的。在 config/jvm.options 文件中直接设置就好(追加):

    -Xms512m
    -Xmx2048m
    
    • 1
    • 2

    4. windows Could not rename log file ‘logs/gc.log’ to ‘logs/gc.log.14’ (Permission denied).

    ES 在 windows 中只允许打开一个应用程序,当你再想去创建一个 ES 应用程序的时候,就会显示 Permission denied,即使是使用 cmd 管理员运行 elasticsearch.bat 文件也是一样的错误。

    • 解决: 注意查看是否已经在别的地方已经打开 ES 服务,实在不行则进行电脑重启

    5. org/elasticsearch/action/ActionRequest has been compiled by a more recent version of the Java Runtime (class file version 61.0), this version of the Java Runtime only recognizes class file versions up to 52.0

    public static void main(String[] args) throws IOException {
        // 创建 ES 客户端
        RestHighLevelClient client = new RestHighLevelClient(
            RestClient.builder(new HttpHost(Constants.HOST, Constants.PORT, Constants.HTTP))
        );
    
        client.close();
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8

    通过上述代码,使用 RestHighLevelCilent 访问 ES 客户端的时候,出现以下错误:Exception in thread "main" java.lang.UnsupportedClassVersionError:org/elasticsearch/action/ActionRequest has been compiled by a more recent version of the Java Runtime (class file version 61.0), this version of the Java Runtime only recognizes class file versions up to 52.0

    看到注释,我们知道是版本不兼容的问题,查找资料看到这样一个表:

    Major version numbers map to Java versions:
    
    45 = Java 1.1
    46 = Java 1.2
    47 = Java 1.3
    48 = Java 1.4
    49 = Java 5
    50 = Java 6
    51 = Java 7
    52 = Java 8
    53 = Java 9
    54 = Java 10
    55 = Java 11
    56 = Java 12
    57 = Java 13
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15

    讲道理在这个版本任你发,我用Java8 的年代,RestHighLevelClient 肯定是兼容Java 8 的,那么就只有 ES 版本太高了,把 pom.xmlES 依赖版本降到跟 elasticsearch-rest-high-level-client 一样就可以了

    
        7.17.0   	 																	7.17.0
    
    
    
        
            org.elasticsearch
            elasticsearch
            ${elasticsearch.version}
        
        
            org.elasticsearch.client
            elasticsearch-rest-high-level-client
            ${elasticsearch.client.version}
        
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 解决:把 pom.xmlelasticsearchelasticsearch-rest-high-level-client 版本一致即可。
  • 相关阅读:
    基于美团技术团队最新开源的yolov6模型实现裸土检测
    从一个程序员的角度看东方甄选“小作文”事件
    搞懂了Vue对象与实例的区别!
    JZ04 [剑指 Offer 04] 二维数组中的查找
    PDF格式分析(七十七)——多边形和折线注释(Polygon 、Polyline)
    Linux下找出吃内存的方法
    记一次回母校河工大的经历
    win11 U盘制作
    SpringMVC 请求流程源码分析
    设计模式-状态模式在Java中的使用示例-信用卡业务系统
  • 原文地址:https://blog.csdn.net/emgexgb_sef/article/details/126359354