1. 创建LicenseVerifier.java文件
package org.elasticsearch.license;
import java.nio.*;
import java.util.*;
import java.security.*;
import org.elasticsearch.common.xcontent.*;
import org.apache.lucene.util.*;
import org.elasticsearch.common.io.*;
import java.io.*;
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.编译class文件
执行下面命令编译LicenseVerifier.java文件
javac -cp "/elasticsearch-5.5.2/lib/elasticsearch-5.5.2.jar:/elasticsearch-5.5.2/lib/lucene-core-6.6.0.jar:/elasticsearch-5.5.2/plugins/x-pack/x-pack-5.5.2.jar" LicenseVerifier.java
LicenseVerifier.class
LicenseVerifier.java
cd /elasticsearch-5.5.2/plugins/x-pack/
mkdir test
mv x-pack-5.5.2.jar test/
备份下 x-pack-5.5.2.jar
cp x-pack-5.5.2.jar /opt
解压到当前目录
jar xvf x-pack-5.5.2.jar
把编译的LicenseVerifier.class 文件替换掉
[root@node-1 /elasticsearch/plugins/x-pack/test]# cd org/elasticsearch/license
[root@node-1 /elasticsearch/plugins/x-pack/test/org/elasticsearch/license]# cp /LicenseVerifier.class ./
回到test目录打包
[root@node-1 /elasticsearch/plugins/x-pack/test/org/elasticsearch/license]# cd /elasticsearch/plugins/x-pack/test/
[root@node-1 /elasticsearch/plugins/x-pack/test]# rm -rf x-pack-5.5.2.jar
[root@node-1 /elasticsearch/plugins/x-pack/test]# jar cvf x-pack-5.5.2.jar ./*
将打包好的文件放回x-pack目录下
[root@node-1 /elasticsearch/plugins/x-pack/test]# cp x-pack-5.5.2.jar ../
[root@node-1 /elasticsearch/plugins/x-pack/test]# rm -rf test/
把包拷贝到其他节点
scp x-pack-5.5.2.jar root@node-2:$PWD
scp x-pack-5.5.2.jar root@node-2:$PWD
3.申请license
https://license.elastic.co/registration
填写邮箱,会让你去一个地址下载json文本
申请完成后很快会发送到邮箱,而后修改license文件
文本里面修改俩个值
①"type":"platinum" //这是白金版
②"expiry_date_in_millis":2524579200999 //这是时间戳
然后把名字改为license.json,上传到linux你喜欢的目录
4.更新license
查看什么时候到期,命令 : curl -XGET -u elastic:changeme "http://node-1:9200/_license"
[root@node-1 x-pack]# curl -XGET -u elastic:changeme "http://node-1:9200/_license"
{
"license" : {
"status" : "active",
"uid" : "80c1957a-917b-4236-bb5d-f1c3875acf46",
"type" : "trial",
"issue_date" : "2018-11-09T08:16:23.563Z",
"issue_date_in_millis" : 1541751383563,
"expiry_date" : "2018-12-09T08:16:23.563Z",
"expiry_date_in_millis" : 1544343383563,
"max_nodes" : 1000,
"issued_to" : "cluster_es",
"issuer" : "elasticsearch",
"start_date_in_millis" : -1
}
}
更新license
到你喜欢的目录下执行下面命令
更新license 命令: curl -XPUT -u elastic 'http://node-1:9200/_xpack/license' -H "Content-Type: application/json" -d @license.json
[root@node-1 server]# curl -XPUT -u elastic 'http://node-1:9200/_xpack/license' -H "Content-Type: application/json" -d @license.json
Enter host password for user 'elastic':
{"acknowledged":true,"license_status":"valid"}[root@node-1 server]#
你会发现已经成功了