63

ELK(三):破解 X-Pack 和更新许可证

 4 years ago
source link: https://www.tuicool.com/articles/7rAnAbb
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

某一天打开 Kibana 对应的 Monitoring 选项卡的时候,发现提示需要下载新的 license,旧的 license 已经过期了;

JfAB7bQ.gif

退出重新登录 发现禁止登录,提示:Login is disabled because your license has expired. Please extend your license or disable Security in Elasticsearch.

这是因为x-pack的试用期为30天。破解方法如下:

1.反编译class文件

在elasticsearch安装目录 plugins/x-pack/ 找到 x-pack-5.0.0.jar 文件,将其复制 保存到另一个文件夹中,然后将其 解压: jar -xvf x- * pack-5.0.0 *.jar

找到文件 org.elasticsearch/license/LicenseVerifier.class ,并用 Luyten ( jd-gui 不准)反编译,并拷贝内容到新建的文件 LicenseVerifier.java ,内容如下:

2.在Linux任意目录下重新编译 LicenseVerifier.java

重新编译class文件。注意这里我们无需编译整个工程,将原来的x-pack-5.0.0.jar和依赖包加入CLASSPATH,即可完成单个文件的编译。实际上只用到了3个依赖包,如果是用RPM或DEB安装的,直接运行:

注:javac执行时的参数cp 表示classpath 路径,如果多个在windows环境中用 ; 隔开,linux中用 : 隔开;

把x-pack-5.0.0.jar用压缩文件管理器打开,将里面的LicenseVerifier.class替换掉。再把破解了的jar包部署到各节点上,将破解的x-pack-5.0.0.jar文件 拷贝到elasticsearch安装目录 plugins/x-pack/下,替换原来的x-pack-5.0.0.jar ,启动 elasticsearch、kibana,并重启集群。

3.申请一个免费license

申请一个免费license(https://license.elastic.co/registration) 注册后可以下载文件,下载后修改,例如:

主要修改:type改为platinum表示可以使用所有功能 ; expiry date in_millis。我这里改了10年 :

将上面json内容保存到license.json文件。

4.安装license

查看当前的license:

curl -XGET -u elastic:changeme 'http://127.0.0.1:9200/_license'

将编辑好的license.json文件放到服务器,在文件目录下执行:

curl-XPUT-u elastic:changeme'http://127.0.0.1:9200/_xpack/license'-d@license.json

或者下面:

curl-XPUT-u elastic:changeme'http://127.0.0.1:9200/_xpack/license?acknowledge=true'-d@license.json

如果出现下面的报错:

则需要在 curl 后 加上 -H "Content-Type: application/json" ,即 curl-H"Content-Type: application/json"-XPUT-u elastic:changeme'http://127.0.0.1:9200/_xpack/license'-d@license.json

重启elasticsearch和kibana .

打开:http://192.168.100.50:5601 ,可正常登录。

5.参考:

  • https://www.cnblogs.com/benwu/articles/6648471.html

  • https://blog.csdn.net/lilongsy/article/details/78987784


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK