- 1.下载对应版本的x-pack:
[root@lijie elk]# wget 'https://artifacts.elastic.co/downloads/packs/x-pack/x-pack-5.5.1.zip'
- 2.安装x-path
./elasticsearch-5.5.1/bin/elasticsearch-plugin install file:///usr/java/elk/xpack/x-pack-5.5.1.zip./kibana-5.5.1-linux-x86_64/bin/kibana-plugin install file:///usr/java/elk/xpack/x-pack-5.5.1.zip
默认账号密码:
用户名:elastic
密码:changeme
- 3.创建java文件
vi 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;}
}
- 4.解压下载的x-path插件
unzip x-pack-5.5.1.zip
如图:
- 5.进行编译,需要指定其他jar的classpath的路径所以用javac -cp
javac -cp "/usr/java/elk/elasticsearch-5.5.1/lib/elasticsearch-5.5.1.jar:/usr/java/elk/elasticsearch-5.5.1/lib/lucene-core-6.6.0.jar:/usr/java/elk/xpack/elasticsearch/x-pack-5.5.1.jar" LicenseVerifier.java
- 6.替换class文件
#创建临时文件夹解压jar
[hadoop@lijie xpack]$ mkdir mytest
[hadoop@lijie xpack]$ mv ./elasticsearch/x-pack-5.5.1.jar mytest/
[hadoop@lijie xpack]$ cd mytest/
[hadoop@lijie mytest]$ jar -xvf x-pack-5.5.1.jar
[hadoop@lijie mytest]$ rm -rf x-pack-5.5.1.jar#删除原文件,将新编译的拷贝到该位置
[hadoop@lijie mytest]$ rm -rf org/elasticsearch/license/LicenseVerifier.class
[hadoop@lijie mytest]$ cp ../LicenseVerifier.class org/elasticsearch/license/#重新打包
[hadoop@lijie mytest]$ jar -cvf x-pack-5.5.1.jar ./*#覆盖plugins文件夹里面的jar包
[hadoop@lijie mytest]$ rm -rf /usr/java/elk/elasticsearch-5.5.1/plugins/x-pack/x-pack-5.5.1.jar
[hadoop@lijie mytest]$ mv x-pack-5.5.1.jar /usr/java/elk/elasticsearch-5.5.1/plugins/x-pack
- 查看可用日期(显示只有1个月时间):
[hadoop@lijie mytest]$ curl -XGET -u elastic:changeme 'http://192.168.80.123:9200/_license'{"license" : {"status" : "active","uid" : "ef3e9077-02f4-4096-85a2-67178c1b2e35","type" : "trial","issue_date" : "2017-10-19T17:30:45.602Z","issue_date_in_millis" : 1508434245602,"expiry_date" : "2017-11-18T17:30:45.602Z","expiry_date_in_millis" : 1511026245602,"max_nodes" : 1000,"issued_to" : "myes","issuer" : "elasticsearch","start_date_in_millis" : -1}
}
- 重启es和kibana
申请license(访问网站:https://license.elastic.co/registration):
就是填写下申请,然后右键激活下载license
{"license":{"uid":"b0e5850c-a131-418f-9a30-a1e15332e6d6","type":"basic","issue_date_in_millis":1508371200000,"expiry_date_in_millis":1539993599999,"max_nodes":100,"issued_to":"li jie (elastic)","issuer":"Web Form","signature":"AAAAAwAAAA3AL/ifoDI+Vff53gJWAAABmC9ZN0hjZDBGYnVyRXpCOW5Bb3FjZDAxOWpSbTVoMVZwUzRxVk1PSmkxaktJRVl5MUYvUWh3bHZVUTllbXNPbzBUemtnbWpBbmlWRmRZb25KNFlBR2x0TXc2K2p1Y1VtMG1UQU9TRGZVSGRwaEJGUjE3bXd3LzRqZ05iLzRteWFNekdxRGpIYlFwYkJiNUs0U1hTVlJKNVlXekMrSlVUdFIvV0FNeWdOYnlESDc3MWhlY3hSQmdKSjJ2ZTcvYlBFOHhPQlV3ZHdDQ0tHcG5uOElCaDJ4K1hob29xSG85N0kvTWV3THhlQk9NL01VMFRjNDZpZEVXeUtUMXIyMlIveFpJUkk2WUdveEZaME9XWitGUi9WNTZVQW1FMG1DenhZU0ZmeXlZakVEMjZFT2NvOWxpZGlqVmlHNC8rWVVUYzMwRGVySHpIdURzKzFiRDl4TmM1TUp2VTBOUlJZUlAyV0ZVL2kvVk10L0NsbXNFYVZwT3NSU082dFNNa2prQ0ZsclZ4NTltbU1CVE5lR09Bck93V2J1Y3c9PQAAAQAzH+JMBz735P6FoU0whdAKO19QVl1D3Gm8PJ768O454vgUOjtUo8IqkE4NC3aGQWFcdtpMANWrJAtHP1jjYrwiIOV4jP11rinwY6f8dw2O/BPUZt+XiYa+HaZQDFZaZNTJv/vgWhFD/wsTIY8+4cRIy85/23FTxPYtu/W8ymXUJ6Uiw0IaOjp+bxoq0pnSIm09NuoClNmA7ELMn68TGePD03YMhIq9OZRO+6iojhcIMeSyEwAj6y4Mnlb5HzCtNkK21e8Yl57Gb8Z45HmmNGY9b4+dFIN3CIl403HsiCdGyN1a+u/yrqQglupxVRdSG9Q2khTwnERw82x075Ye+Kbn","start_date_in_millis":1508371200000}}
将license上面的修改为
"type":"platinum"
"expiry_date_in_millis":253395907200000#如下
{"license":{"uid":"b0e5850c-a131-418f-9a30-a1e15332e6d6","type":"platinum","issue_date_in_millis":1508371200000,"expiry_date_in_millis":253395907200000,"max_nodes":100,"issued_to":"li jie (elastic)","issuer":"Web Form","signature":"AAAAAwAAAA3AL/ifoDI+Vff53gJWAAABmC9ZN0hjZDBGYnVyRXpCOW5Bb3FjZDAxOWpSbTVoMVZwUzRxVk1PSmkxaktJRVl5MUYvUWh3bHZVUTllbXNPbzBUemtnbWpBbmlWRmRZb25KNFlBR2x0TXc2K2p1Y1VtMG1UQU9TRGZVSGRwaEJGUjE3bXd3LzRqZ05iLzRteWFNekdxRGpIYlFwYkJiNUs0U1hTVlJKNVlXekMrSlVUdFIvV0FNeWdOYnlESDc3MWhlY3hSQmdKSjJ2ZTcvYlBFOHhPQlV3ZHdDQ0tHcG5uOElCaDJ4K1hob29xSG85N0kvTWV3THhlQk9NL01VMFRjNDZpZEVXeUtUMXIyMlIveFpJUkk2WUdveEZaME9XWitGUi9WNTZVQW1FMG1DenhZU0ZmeXlZakVEMjZFT2NvOWxpZGlqVmlHNC8rWVVUYzMwRGVySHpIdURzKzFiRDl4TmM1TUp2VTBOUlJZUlAyV0ZVL2kvVk10L0NsbXNFYVZwT3NSU082dFNNa2prQ0ZsclZ4NTltbU1CVE5lR09Bck93V2J1Y3c9PQAAAQAzH+JMBz735P6FoU0whdAKO19QVl1D3Gm8PJ768O454vgUOjtUo8IqkE4NC3aGQWFcdtpMANWrJAtHP1jjYrwiIOV4jP11rinwY6f8dw2O/BPUZt+XiYa+HaZQDFZaZNTJv/vgWhFD/wsTIY8+4cRIy85/23FTxPYtu/W8ymXUJ6Uiw0IaOjp+bxoq0pnSIm09NuoClNmA7ELMn68TGePD03YMhIq9OZRO+6iojhcIMeSyEwAj6y4Mnlb5HzCtNkK21e8Yl57Gb8Z45HmmNGY9b4+dFIN3CIl403HsiCdGyN1a+u/yrqQglupxVRdSG9Q2khTwnERw82x075Ye+Kbn","start_date_in_millis":1508371200000}}
创建一个文件license.json,将上面的内容复制到里面
然后执行:
[hadoop@lijie mytest]$ curl -XPUT -u elastic:changeme 'http://192.168.80.123:9200/_xpack/license?acknowledge=true' -H "Content-Type: application/json" -d @license.json返回:
{"acknowledged":true,"license_status":"valid"}
在执行查看过期时间以及版本:
- 搞定