美文网首页
ElasticSearch-7.5.1铂金版破解

ElasticSearch-7.5.1铂金版破解

作者: 让我们荡起双桨呀 | 来源:发表于2020-05-26 15:04 被阅读0次

elasticsearch从6.3版本开始支持SQL查询语言,SQL查询时ElasticSearch XPack商用插件包中的功能。使用SQL进行查询es有易上手、学习成本低等优点,但是支持SQL需要升级为铂金版,因此本文档记录如何将elasticsearch破解为铂金版,仅用于学习测试,勿商用。

1.1 前期准备

系统 节点名称 IP
Red Hat6.4 a03 132.46.112.16

1.2 官网安装包下载

下载地址:https://www.elastic.co/cn/downloads/past-releases/elasticsearch-7-5-1

1.3 安装包上传及解压

因为/mnt目录下为挂载盘,为了防止数据量过大导致服务器本地磁盘消耗殆尽,因此将所有es安装包解压至/mnt/u01/elasticsearch-7.5.1目录下

tar -zxvf elasticsearch-7.5.1-linux-x86_64.tar.gz /mnt/u01/elasticsearch-7.5.1

1.3 破解xpack

因为x-pack-core-7.5.1.jar中有相关的认证的类,因此需要篡改验证代码,跳过相关认证从而达到破解的目的。

需修改的相关类如下:

package org.elasticsearch.xpack.core;
​
import java.net.URISyntaxException;
import java.net.URL;
import java.nio.file.Path;
​
import org.elasticsearch.common.SuppressForbidden;
import org.elasticsearch.common.io.PathUtils;
​
public class XPackBuild
{
 public static final XPackBuild CURRENT;
 private String shortHash;
 private String date;
​
 @SuppressForbidden(reason = "looks up path of xpack.jar directly")
 static Path getElasticsearchCodebase() {
 final URL url = XPackBuild.class.getProtectionDomain().getCodeSource().getLocation();
 try {
 return PathUtils.get(url.toURI());
 }
 catch (URISyntaxException bogus) {
 throw new RuntimeException(bogus);
 }
 }
​
 XPackBuild(final String shortHash, final String date) {
 this.shortHash = shortHash;
 this.date = date;
 }
​
 public String shortHash() {
 return this.shortHash;
 }
​
 public String date() {
 return this.date;
 }
​
 static {
 final Path path = getElasticsearchCodebase();
 String shortHash = null;
 String date = null;
 Label_0109: {
​
 shortHash = "Unknown";
 date = "Unknown";
 }
 CURRENT = new XPackBuild(shortHash, date);
 }
}
package org.elasticsearch.license;
​
/**
 * @author zgb on 2020/1/8
 */
​
public class LicenseVerifier
{
 public static boolean verifyLicense(final License license, final byte[] encryptedPublicKeyData) {
 return true;
 }
​
 public static boolean verifyLicense(final License license) {
 return true;
 }
}

接着需要编译这两个类,替换服务器上安装目录下的moudles/x-pacl-core目录下的x-pack-core-7.5.1.jar包中相应的class文件。

编译类的方式有:

  • idea编译

  • javac命令编译

  • ... ...

1.4 申请license证书

https://license.elastic.co/registration

  • 添加邮件,用于接收json文件

  • country写china,其他可以随便填

  • 点击申请后邮箱会收到一个邮件

1.5 修改申请到的整数

  1. “type”:“basic”替换为“type”:“platinum” # 基础版变更为铂金版

  2. “expirt_data_in_millis”:“1561420799999”替换为“expirt_data_in_millis”:“3107746200000” #时间变为50年

1.6 上传证书完成修改

上传前准备,打开elasticsearch.yml配置文件加入xpack.security.enabled:false

1.7 启动elasticsearch,激活许可证

curl -XPUT 'http://localhost:9200/_xpack/license' -H "Content-Type: application/json" -d @license.json

返回{"acknowledged":true,"license_status":"valid"}就表示激活成功了。

遇到的问题

1、启动异常:ERROR: bootstrap checks failed system call filters failed to install; check the logs and fix your configuration or disable system call filters at your own risk

问题原因:因为Centos6不支持SecComp,而ES5.2.1默认bootstrap.system_call_filter为true进行检测,所以导致检测失败,失败后直接导致ES不能启动。详见 :https://github.com/elastic/elasticsearch/issues/22899

解决方法:在elasticsearch.yml中配置bootstrap.system_call_filter为false,注意要在Memory下面: bootstrap.memory_lock: false bootstrap.system_call_filter: false

2、 max virtual memory areas vm.max_map_count [65530] likely too low, increase to at least [262144]

原因:最大虚拟内存太小 解决方案:切换到root用户下,修改配置文件sysctl.conf vi /etc/sysctl.conf 添加下面配置: vm.max_map_count=655360 并执行命令: sysctl -p

3、ERROR: bootstrap checks failed max file descriptors [4096] for elasticsearch process likely too low, increase to at least [65536]

原因:无法创建本地文件问题,用户最大可创建文件数太小

解决方案: 切换到root用户,编辑limits.conf配置文件, 添加类似如下内容:

vi /etc/security/limits.conf

添加如下内容:

  • soft nofile 65536

  • hard nofile 131072

  • soft nproc 2048

  • hard nproc 4096 备注:* 代表Linux所有用户名称(比如 hadoop)

保存、退出、重新登录才可生效

4、max number of threads [1024] for user [es] likely too low, increase to at least [2048] 原因:无法创建本地线程问题,用户最大可创建线程数太小 解决方案:切换到root用户,进入limits.d目录下,修改90-nproc.conf 配置文件。

vi /etc/security/limits.d/90-nproc.conf

找到如下内容:

  • soft nproc 1024

修改为

  • soft nproc 2048

相关文章

网友评论

      本文标题:ElasticSearch-7.5.1铂金版破解

      本文链接:https://www.haomeiwen.com/subject/jffvahtx.html