Elasticsearch 7.4.0 白金版 绿色教程
Elasticsearch X-PACK 白金版只有 30 天试用,为了可以经常使用,特出以下教程,
特别强调,仅作学习使用!!!
首先,从官网下一份 Linux 版的 Elasticsearch 安装包,再从开源社区拉取一份 Elasticsearch 源码。
官方下载页
https://www.elastic.co/cn/downloads/elasticsearch
开源仓库地址
GitHub
https://github.com/elastic/elasticsearch
Gitee(推荐,国内网速你懂的)
https://gitee.com/mirrors/elasticsearch
然后就是修改源码,再重新编译进行偷梁换柱了
其中 LicenseVerifier.java 在 elasticsearch/ x-pack / plugin / core / src / main / java / org / elasticsearch / license / 目录下,认证用的,改!
package org.elasticsearch.license;
/**
* Responsible for verifying signed licenses
*/
public class LicenseVerifier {
/**
* verifies the license content with the signature using the packaged
* public key
* @param license to verify
* @return true if valid, false otherwise
*/
public static boolean verifyLicense(final License license, byte[] publicKeyData) {
return true;
}
public static boolean verifyLicense(final License license) {
return true;
}
}
其中 XPackBuild.java 在 elasticsearch/ x-pack / plugin / core / src / main / java / org / elasticsearch / xpack / core 目录下,校验 jar 包用的,再改!
package org.elasticsearch.xpack.core;
import org.elasticsearch.common.SuppressForbidden;
import org.elasticsearch.common.io.PathUtils;
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;
public class XPackBuild {
public static final XPackBuild CURRENT;
static {
CURRENT = new XPackBuild("Unknown", "Unknown");
}
/**
* Returns path to xpack codebase path
*/
@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);
}
}
private String shortHash;
private String date;
XPackBuild(String shortHash, String date) {
this.shortHash = shortHash;
this.date = date;
}
public String shortHash() {
return shortHash;
}
public String date() {
return date;
}
}
在 Linux 上找个位置把 Elasticsearch 安装包解压了,我直接在 / 下搞了,顺便再创建上面那两个改过的 java 文件
重新编译下
javac -cp "/elasticsearch-7.4.1/lib/elasticsearch-7.4.1.jar:/elasticsearch-7.4.1/lib/lucene-core-8.2.0.jar:/elasticsearch-7.4.1/modules/x-pack-core/x-pack-core-7.4.1.jar" LicenseVerifier.java
javac -cp "/elasticsearch-7.4.1/lib/elasticsearch-7.4.1.jar:/elasticsearch-7.4.1/lib/lucene-core-8.2.0.jar:/elasticsearch-7.4.1/modules/x-pack-core/x-pack-core-7.4.1.jar:/elasticsearch-7.4.1/lib/elasticsearch-core-7.4.1.jar" XPackBuild.java
找到安装包 modules\x-pack-core 目录下的 x-pack-core-7.4.0.jar,把编译得到的 class 文件根据相应的类路径替换掉。
docker cp ./x-pack-core-7.4.0.jar 6ead3863ae82:/usr/share/elasticsearch/modules/x-pack-core
接下来就是更新许可证了
官方申请地址
https://register.elastic.co/marvel_register
收到邮件后,里面有个地址,进去后可以下载 json 格式的许可证文件。下载下来,修改里面的内容,主要是把 "basic" 改为 "platinum" 即白金版,"expiry_date_in_millis" 这个时间戳改大点,就够用了。
这是我的许可证,一直续到了 9999年12月31日:
{"license":{"uid":"4000d1b5-a06b-4d18-8501-ca3754b2c6c7","type":"platinum","issue_date_in_millis":1571875200000,"expiry_date_in_millis":253402271999000,"max_nodes":100,"issued_to":"bob mike (mikebob)","issuer":"Web Form","signature":"AAAAAwAAAA3CvX09J7V8T5tT0i55AAABmC9ZN0hjZDBGYnVyRXpCOW5Bb3FjZDAxOWpSbTVoMVZwUzRxVk1PSmkxaktJRVl5MUYvUWh3bHZVUTllbXNPbzBUemtnbWpBbmlWRmRZb25KNFlBR2x0TXc2K2p1Y1VtMG1UQU9TRGZVSGRwaEJGUjE3bXd3LzRqZ05iLzRteWFNekdxRGpIYlFwYkJiNUs0U1hTVlJKNVlXekMrSlVUdFIvV0FNeWdOYnlESDc3MWhlY3hSQmdKSjJ2ZTcvYlBFOHhPQlV3ZHdDQ0tHcG5uOElCaDJ4K1hob29xSG85N0kvTWV3THhlQk9NL01VMFRjNDZpZEVXeUtUMXIyMlIveFpJUkk2WUdveEZaME9XWitGUi9WNTZVQW1FMG1DenhZU0ZmeXlZakVEMjZFT2NvOWxpZGlqVmlHNC8rWVVUYzMwRGVySHpIdURzKzFiRDl4TmM1TUp2VTBOUlJZUlAyV0ZVL2kvVk10L0NsbXNFYVZwT3NSU082dFNNa2prQ0ZsclZ4NTltbU1CVE5lR09Bck93V2J1Y3c9PQAAAQCQmJJzPPt4L/B3VQzRKxSp3Krg6sDfnsnoxSW4Tp2YeH19wfa8fpKaEifYlLTT8PvpExGLyR+STnYv1qI5D9Uhi9jT4THDR5mKasfYvqk/Mz5MLedNCw+Yt/r4u7EC5bFMA0uZis4B+3VqTDrWEvcc1fRyOvjzh2tE29vYDhfUaqTJGXp9VXMooXGx7ZaNy9mIxP4J2ywgtfvj4qFFZeg8ZYUsvAki3Mk4QTiTcSZc3OT9+ZVtO1/3OXpHANmy69ENqpayoJOm3UvRaWkR0ksIzgZkGF5m0S/2iNeFs5OfoBvbjpNcsGRxo/uqIi4fW3J2b/gfaP3DFh1IINK+5Md4","start_date_in_millis":1571875200000}}
你可以在 Kibana UI 上传许可证激活,也可以用命令的方式:
# 建一个文件命名为 license.json,里面放上面的 json 字符串
curl -XPUT 'http://localhost:9200/_xpack/license' -H "Content-Type: application/json" -d @license.json
返回 {"acknowledged":true,"license_status":"valid"} 就表示续命成功了。
最后,别忘了把 xpack security 配置下,不然 Kibana 连不上 Elasticsearch 的。![img](https://images.cnblogs.com/cnblogs_com/James-1024/1633884/o_2001231405431579788300(1).png)
为了避免有的童鞋激活失败,另附绿色文件下载地址
https://files-cdn.cnblogs.com/files/James-1024/elasticsearchxpack.rar
关注我的技术公众号,每天都有优质技术文章推送。
微信扫一扫下方二维码即可关注:
尚未佩妥剑,转眼便江湖,愿历尽千帆,归来仍少年