elasticsearch7.14.0 x-pack配置

Posted javachen__

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了elasticsearch7.14.0 x-pack配置相关的知识,希望对你有一定的参考价值。

1.编译LicenseVerifier、XPackBuild

/usr/local/elasticsearch-7.14.0/modules/x-pack-core/x-pack-core-7.14.0.jar

   验证licence是否有效:org.elasticsearch.license.LicenseVerifier
   验证jar包是否被修改:org.elasticsearch.xpack.core.XPackBuild

LicenseVerifier.java->修改为

package org.elasticsearch.license;

public class LicenseVerifier 
  public static boolean verifyLicense(License license, byte[] publicKeyData) 
     return true;
  
  
  public static boolean verifyLicense(License license) 
     return true;
  

XPackBuild.java->修改为

package org.elasticsearch.xpack.core;

import java.io.IOException;
import java.net.URISyntaxException;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.jar.JarInputStream;
import java.util.jar.Manifest;
import org.elasticsearch.core.PathUtils;
import org.elasticsearch.core.SuppressForbidden;

public class XPackBuild 
  public static final XPackBuild CURRENT;
  
  private String shortHash;
  
  private String date;
  
  static 
    CURRENT = new XPackBuild("Unknown", "Unknown");
  
  
  @SuppressForbidden(reason = "looks up path of xpack.jar directly")
  static Path getElasticsearchCodebase() 
    URL url = XPackBuild.class.getProtectionDomain().getCodeSource().getLocation();
    try 
      return PathUtils.get(url.toURI());
     catch (URISyntaxException bogus) 
      throw new RuntimeException(bogus);
     
  
  
  XPackBuild(String shortHash, String date) 
    this.shortHash = shortHash;
    this.date = date;
  
  
  public String shortHash() 
    return this.shortHash;
  
  
  public String date() 
    return this.date;
  

2.编译文件

javac -cp "/usr/local/elasticsearch-7.14.0/lib/elasticsearch-7.14.0.jar:/usr/local/elasticsearch-7.14.0/lib/lucene-core-8.9.0.jar:/usr/local/elasticsearch-7.14.0/modules/x-pack-core/x-pack-core-7.14.0.jar" LicenseVerifier.java

javac -cp "/usr/local/elasticsearch-7.14.0/lib/elasticsearch-7.14.0.jar:/usr/local/elasticsearch-7.14.0/lib/lucene-core-8.9.0.jar:/usr/local/elasticsearch-7.14.0/modules/x-pack-core/x-pack-core-7.14.0.jar:/usr/local/elasticsearch-7.14.0/lib/elasticsearch-core-7.14.0.jar"  XPackBuild.java

3.将编译后的文件替换至原jar包中

4.关闭安全验证,并重启es:

vim /etc/elasticsearch/elasticsearch.yml
在文件中添加
xpack.security.enabled: false
xpack.security.transport.ssl.enabled: false

5.去官网申请license

https://license.elastic.co/registration

6.修改证书信息

将type改为platinum,expiry_date_in_millis改为2524579200999

type为软件版本,默认为basic,platinum是白金版,权限也很高。
expiry_date_in_millis就是你要截止的日期,我配置的是到2050年。

7.更新证书

将证书改名为license.json,然后更新证书
curl  -H  "Content-Type: application/js o-XPUT 'http://172.22.46.34:9200/_xpackn" license?acknowledge=true' -d @license.json

查询证书有效期
172.22.46.34:9200/_license

以上是关于elasticsearch7.14.0 x-pack配置的主要内容,如果未能解决你的问题,请参考以下文章

Elasticsearch7.14.0安装,配置密码认证及创建用户

部署支持使用Redis哨兵模式,支持纳管ClickHouse数据库,JumpServer堡垒机v2.28.0发布