elasticsearch6.3版本jdbc連線
阿新 • • 發佈:2018-12-17
使用jdbc連線es6.3需要破解es的license,將其升級為白金版本。以下為步驟:
首先要下載maven依賴,但是我的maven下載不來,遠端庫配置沒用,以下為官方提供的依賴:
<repositories> <repository> <id>elastic.co</id> <url>https://artifacts.elastic.co/maven</url> </repository> </repositories> <dependency> <groupId>org.elasticsearch.plugin</groupId> <artifactId>jdbc</artifactId> <version>6.3.1</version> </dependency>
我下載了6.3.0的jar包,放到idea的library裡面,一樣可以使用。但是可能會與maven中舊版本的依賴衝突。
重點是破解過程:
1.找到x-pack-core-6.3.0.jar
2.解壓jar包,找到以下兩個檔案:
org/elasticsearch/license/LicenseVerifier.class
org/elasticsearch/xpack/core/XPackBuild.class
將其如下修改:
# cat 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; } }
----------------------------------------------------------------------------------------------
# cat 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); } }
修改完,需要重新編譯這兩個檔案,但是需要注意的是,要引入新的依賴:
javac -cp "/usr/local/elk/elasticsearch-6.2.3/lib/elasticsearch-6.2.3.jar:/usr/local/elk/elasticsearch-6.2.3/lib/lucene-core-7.2.1.jar:/usr/local/elk/elasticsearch-6.2.3/plugins/x-pack/x-pack-core/x-pack-core-6.3.0.jar" LicenseVerifier.java
javac -cp "/usr/local/elk/elasticsearch-6.2.3/lib/elasticsearch-6.2.3.jar:/usr/local/elk/elasticsearch-6.2.3/lib/lucene-core-7.2.1.jar:/usr/local/elk/elasticsearch-6.2.3/plugins/x-pack/x-pack-core/x-pack-core-6.3.0.jar:/usr/local/elk/elasticsearch-6.3.0/lib/elasticsearch-core-6.3.0.jar" XPackBuild.java
再打成jar包,千萬別將解壓前原本的jar包一併打包,要移出去。
jar -cvf x-pack-core-6.3.0.jar ./*
新產生的jar包替換掉原來的x-pack-core-6.3.0.jar。
去官網申請免費license,會發郵件給你進行下載;
將下載的檔案重新命名為license.json,並做如下修改:
"type":"platinum" #白金版
"expiry_date_in_millis":2524579200999 #截止日期 2050年
接下來是替換license。
網上的curl命令我試了不好使,只能安裝kibana去替換license。
看到最後,如果不想嘗試的話,我有破解好的jar包下載:點選下載。