1、查看版本
curl -u elastic:elastic -XGET 'http://172.16.1.61:9200/_xpack/license'
"type" : "basic" 则为基础班
打印如下
"license" : {
"status" : "active",
"uid" : "703a69ef-d80f-475e-812f-37c78d90a5a3",
"type" : "basic",
"issue_date" : "2022-04-29T00:00:00.000Z",
"issue_date_in_millis" : 1651190400000,
"expiry_date" : "2036-10-16T05:03:20.000Z",
"expiry_date_in_millis" : 2107746200000,
"max_nodes" : 100,
"issued_to" : "zhy sy (fdascs.com)",
"issuer" : "Web Form",
"start_date_in_millis" : 1651190400000
}
}2、创建类
2个类
并且替换到如下jar中
elasticsearch-7.5.1/modules/x-pack-core/x-pack-core-7.5.1.jar
2.1、LicenseVerifier
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;
}
}
}2.2、
XPackBuild
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);
}
}
3、jar上传替换
4、申请证书
申请地址 https://license.elastic.co/registration
并修改证书 type 的 basic 为 platinum
5、上传证书
5.1、上传之前需要修改一下配置文件
打开elasticsearch.yml配置文件加入 xpack.security.enabled:false
cat @license.json | curl -H "Content-Type:application/json" -X POST -d @- http://172.16.1.61:9200/_xpack/license
结果出现 {"acknowledged":true,"license_status":"valid"}
则说明成功
curl -XPUT 'http://172.16.1.61:9200/_xpack/license' -H "Content-Type: application/json" -d @license.json
最后修改于 2022-04-29 15:45:55
如果觉得我的文章对你有用,请随意赞赏
扫一扫支付

