一.创建 LicenseVerifier.java 文件,重新编译(替换5.6.x的x-pack-5.6.11.jar;替换6.x的x-pack-core-6.x.jar)
(1) 版本 5.6.x:
a.任意位置创建文件LicenseVerifier.java
vim 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;
}
}
b.编译文件(5.x不同版本根据版本不同进行改动):
如:es版本5.6.11:
javac -cp "/usr/elasticsearch-5.6.11/lib/elasticsearch-5.6.11.jar:/usr/elasticsearch-5.6.11/lib/lucene-core-6.6.1.jar:/usr/elasticsearch-5.6.11/plugins/x-pack/x-pack-5.6.11.jar" LicenseVerifier.java
查看后: ll
总用量 119776
drwxr-xr-x 3 jerry root 4096 6月 6 11:44 ./
drwxr-xr-x 60 jerry root 4096 6月 6 11:59 ../
-rw-r--r-- 1 jerry root 410 6月 6 11:27 LicenseVerifier.class
-rw-r--r-- 1 jerry root 487 6月 6 11:02 LicenseVerifier.java
(2) 版本 6.x:
a.任意位置创建LicenseVerifier.java文件,修改:
vim 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;
}
}
(b) XPackBuild的最后一个静态代码块中的部分全部删除,这部分会jar包是否被修改
任意位置创建 XPackBuild.java文件:
vim XPackBuild.java
package org.elasticsearch.xpack.core;
import org.elasticsearch.common.io.*;
import java.net.*;
import org.elasticsearch.common.*;
import java.nio.file.*;
import java.io.*;
import java.util.jar.*;
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_0157: {
shortHash = "Unknown";
date = "Unknown";
}
CURRENT = new XPackBuild(shortHash, date);
}
}
6.x 编译上述连个文件
javac -cp "/usr/elasticsearch-5.6.11/lib/elasticsearch-5.6.11.jar:/usr/elasticsearch-5.6.11/lib/lucene-core-6.6.1.jar:/usr/elasticsearch-5.6.11/plugins/x-pack/x-pack-5.6.11.jar" LicenseVerifier.java
javac -cp "/usr/elasticsearch-5.6.11/lib/elasticsearch-5.6.11.jar:/usr/elasticsearch-5.6.11/lib/lucene-core-6.6.1.jar:/usr/elasticsearch-5.6.11/plugins/x-pack/x-pack-5.6.11.jar" XPackBuild.java
二替换重现编译后的文件
(1)5.6.x版本:
a.解压5.6.x版本的x-pack-core-6.x.jar,替换编译文件
mkdir unzipdir
cd unzipdir
cp /usr/elasticsearch-5.6.11/plugins/x-pack/x-pack-5.6.11.jar .jar xvf x-pack-5.6.11.jar
/x-pack/xjar$ ll
总用量 3872
drwxr-xr-x 5 jerry root 4096 6月 6 11:29 ./
drwxr-xr-x 3 jerry root 4096 6月 6 11:44 ../
-rw-r--r-- 1 jerry root 919 8月 16 2018 legacy_triggered_watches.json
-rw-r--r-- 1 jerry root 1373 8月 16 2018 legacy_watches.json
drwxr-xr-x 2 jerry root 4096 8月 16 2018 META-INF/
drwxr-xr-x 3 jerry root 4096 8月 16 2018 monitoring/
-rw-r--r-- 1 jerry root 1201 8月 16 2018 monitoring-alerts.json
-rw-r--r-- 1 jerry root 26998 8月 16 2018 monitoring-es.json
-rw-r--r-- 1 jerry root 5679 8月 16 2018 monitoring-kibana.json
-rw-r--r-- 1 jerry root 11165 8月 16 2018 monitoring-logstash.json
drwxr-xr-x 3 jerry root 4096 8月 16 2018 org/
-rw-r--r-- 1 jerry root 304 8月 16 2018 public.key
-rw-r--r-- 1 jerry root 1695 8月 16 2018 security_audit_log.json
-rw-r--r-- 1 jerry root 3460 8月 16 2018 security-index-template.json
-rw-r--r-- 1 jerry root 2505 8月 16 2018 security-index-template-v6.json
-rw-r--r-- 1 jerry root 930 8月 16 2018 triggered-watches.json
-rw-r--r-- 1 jerry root 1393 8月 16 2018 watches.json
-rw-r--r-- 1 jerry root 19094 8月 16 2018 watch-history.json
-rw-r--r-- 1 jerry root 58 8月 16 2018 xpack-build.properties
b.替换编译后的 LicenseVerifier.class文件 到x-pack-5.6.11.jar 解压后的目录下:
/x-pack/xjar$ cp ../LicenseVerifier.class org/elasticsearch/license/
c.压缩替换后的目录:
/x-pack/xjar$ jar cvf x-pack-5.6.11.jar .
d.替换压缩后的x-pack-5.6.11.jar 到es安装目录:
cd $ELASTICSEARCH_HOME/plugins/x-pack/备份 x-pack-5.6.11.jar
mkdir test
cp x-pack-5.6.11.jar test替换目录下的x-pack-5.6.11.jar
jerry@jerry:~/x-pack/xjar$ cp x-pack-5.6.11.jar /usr/elasticsearch-5.6.11/plugins/x-pack/
e:重启elasticsearch
(2)6.x版本:
a.解压6.x版本的x-pack-core-6.x.jar,替换编译文件
jar xvf x-pack-core-6.x.jar
/x-pack/xjar$ ll
总用量 3872
drwxr-xr-x 5 jerry root 4096 6月 6 11:29 ./
drwxr-xr-x 3 jerry root 4096 6月 6 11:44 ../
-rw-r--r-- 1 jerry root 919 8月 16 2018 legacy_triggered_watches.json
-rw-r--r-- 1 jerry root 1373 8月 16 2018 legacy_watches.json
drwxr-xr-x 2 jerry root 4096 8月 16 2018 META-INF/
drwxr-xr-x 3 jerry root 4096 8月 16 2018 monitoring/
-rw-r--r-- 1 jerry root 1201 8月 16 2018 monitoring-alerts.json
-rw-r--r-- 1 jerry root 26998 8月 16 2018 monitoring-es.json
-rw-r--r-- 1 jerry root 5679 8月 16 2018 monitoring-kibana.json
-rw-r--r-- 1 jerry root 11165 8月 16 2018 monitoring-logstash.json
drwxr-xr-x 3 jerry root 4096 8月 16 2018 org/
-rw-r--r-- 1 jerry root 304 8月 16 2018 public.key
-rw-r--r-- 1 jerry root 1695 8月 16 2018 security_audit_log.json
-rw-r--r-- 1 jerry root 3460 8月 16 2018 security-index-template.json
-rw-r--r-- 1 jerry root 2505 8月 16 2018 security-index-template-v6.json
-rw-r--r-- 1 jerry root 930 8月 16 2018 triggered-watches.json
-rw-r--r-- 1 jerry root 1393 8月 16 2018 watches.json
-rw-r--r-- 1 jerry root 19094 8月 16 2018 watch-history.json
-rw-r--r-- 1 jerry root 58 8月 16 2018 xpack-build.properties
b.替换编译后的x-pack-core-6.x.jar 到es的目录下:
/x-pack/xjar$ cp ../LicenseVerifier.class org/elasticsearch/license/
c.压缩替换后的目录:
/x-pack/xjar$ jar cvf x-pack-core-6.x.jar .
d.替换压缩后的x-pack-core-6.x.jar 到es安装目录:
cd $ELASTICSEARCH_HOME/plugins/x-pack/备份 x-pack-core-6.x.jar
mkdir test
cp x-pack-core-6.x.jar test替换目录下的 x-pack-core-6.x.jar
jerry@jerry:~/x-pack/xjar$ cp x-pack-core-6.x.jar /usr/elasticsearch-6.x/plugins/x-pack/
三.申请新的license:
a.根据版本选择对应的license:
https://license.elastic.co/registration
b.从邮箱下载license
c.更新license:
curl -XPUT -u elastic:changeme 'http://localhost:9200/_xpack/license' -H "Content-Type: application/json" -d @license.json{
"acknowledged":true,
"license_status":"valid"
}
四.重启elasticsearch