zoukankan      html  css  js  c++  java
  • X-PACK详解


    启用和禁用
    启用和禁用X-Pack功能
    默认情况下,所有X-Pack功能都被启用。您可以启用或禁用特定的X-Pack功能elasticsearch.yml,kibana.yml以及logstash.yml 配置文件。
    设置 描述
    xpack.graph.enabled 设置为false禁用X-Pack图形功能。
    xpack.ml.enabled 设置为false禁用X-Pack机器学习功能。
    xpack.monitoring.enabled 设置为false禁用X-Pack监视功能。
    xpack.reporting.enabled 设置为false禁用X-Pack报告功能。
    xpack.security.enabled 设置为false禁用X-Pack安全功能。
    xpack.watcher.enabled 设置false为禁用观察器。


    Run bin/kibana-plugin in your Kibana installation directory.
    bin/kibana-plugin install x-pack
    The plugin install scripts require direct internet access to download and install X-Pack. If your server doesn’t have internet access, specify the location of the X-Pack zip file that you downloaded to a temporary directory.
    bin/kibana-plugin install file:///path/to/file/x-pack-6.2.4.zip
    The Kibana server needs to be able to write to files in the optimize directory. If you’re using sudo or su, run the plugin installation as the built-in kibana user. For example:
    sudo -u kibana bin/kibana-plugin install x-pack
    For more information, see Installing Plugins.

    密码
    也就是:
    bin/x-pack/setup-passwords auto
    1
    如果想自己来指定密码的话,执行:
    bin/x-pack/setup-passwords interactive

    也可以使用shell 终端进行管理:
    修改elastic用户的密码:
    curl -XPUT -u elastic 'localhost:9200/_xpack/security/user/elastic/_password' -d '{
    "password" : "123456"
    }'
    修改kibana用户的密码:
    curl -XPUT -u elastic 'localhost:9200/_xpack/security/user/kibana/_password' -d '{
    "password" : "123456"
    }'
    创建用户组和角色,创建所属用户
    eg:创建beats_admin用户组,该用户组对filebeat*有all权限,对.kibana*有manage,read,index权限
    curl -XPOST -u elastic 'localhost:9200/_xpack/security/role/beats_admin' -d '{
    "indices" : [
    {
    "names" : [ "filebeat*" ],
    "privileges" : [ "all" ]
    },
    {
    "names" : [ ".kibana*" ],
    "privileges" : [ "manage", "read", "index" ]
    }
    ]
    }'
    创建jockbeat用户,密码是jockbeat
    curl -XPOST -u elastic 'localhost:9200/_xpack/security/user/jockbeat' -d '{
    "password" : "jockbeat",
    "full_name" : "jock beat",
    "email" : "john.doe@anony.mous",
    "roles" : [ "beats_admin" ]
    }'

    1.解压 x-pack-6.2.3.zip 进入elasticsearch目录,找到x-pack-core-6.2.3.jar,如果如果已经安装过x-pack插件可以在elasticsearch-6.2.3/plugins/x-pack/x-pack-core/目录下找到
    2.解压jar包,然后找到如下两个class文件,使用luyten反编译
    org/elasticsearch/license/LicenseVerifier.class
    org/elasticsearch/xpack/core/XPackBuild.class
    3.将反编译后的java 代码复制到自己的IDE中,按照同样的包名创建pack(可以直接创建如下两个文件,省略第二部)
    (1)LicenseVerifier 中有两个静态方法,这就是验证授权文件是否有效的方法,我们把它修改为全部返回true.
    # 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;
    }
    }
    (2)XPackBuild 中 最后一个静态代码块中 try的部分全部删除,这部分会验证jar包是否被修改
    # 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);
    }
    }4.编译这两个文件
    我们不需要编译整个项目,只需要编译这两个文件,所以要把依赖添加到classpath中,依赖也与之前有所变化,之前只需要x-pack 包本身,现在需要引入 elasticsearch 6.2.3 中 lib 目录下的jar包 以及 x-pack-core-6.2.3.jar 本身
    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.2.3.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.2.3.jar:/usr/local/elk/elasticsearch-6.2.3/lib/elasticsearch-core-6.2.3.jar" XPackBuild.java
    1
    2
    5.使用重新编译的两个class文件替换原有的class文件,然后重新打jar包
    jar -cvf x-pack-core-6.2.3.jar ./*
    1
    6.将破解好的x-pack-core-6.2.3.jar替换elasticsearch-6.2.3/plugins/x-pack/x-pack-core/目录下原有的jar包即可。
    7.更新license:
    去官网申请免费license,会发邮件给你进行下载;
    将下载的文件重命名为license.json,并做如下修改:
    "type":"platinum" #白金版
    "expiry_date_in_millis":2524579200999 #截止日期 2050年
    或者将license文件上传到服务器通过命令导入:
    curl -XPUT -u elastic 'http://192.168.20.101:9200/_xpack/license' -H "Content-Type: application/json" -d @license.json
    或者
    curl -XPUT -u elastic 'http://192.168.20.60:9200/_xpack/license?acknowledge=true' -H "Content-Type: application/json" -d @license.json
    注意:
    elasticsearch 6.2.4中默认开启了安全验证,我们暂时修改配置文件以方便导入自己的文件
    在elasticsearch.yml 中 添加一下配置
    xpack.security.enabled:false

  • 相关阅读:
    智能实验室-通用网络请求(Webio) 2.5.0.180
    智能实验室-YouTube资源下载(YouTubio) 1.2.0.40
    智能实验室-批量解压(Extractio) 1.5.0.10
    智能实验室-全能优化(Guardio) 3.9.0.555
    智能实验室通用网络请求(Webio) 1.1.0.81 正式发布第一版
    智能安全实验室-全能优化(Guardio) 3.9.0.541:批量粉碎文件
    智能实验室-全能优化(Guardio) 4.0.0.600 beta 1
    快速浏览Silverlight3 Beta: 在多个Silverlight应用间传递信息
    快速浏览Silverlight3 Beta:当HLSL遇上Silverlight
    简读clubof网站源码之后的思考
  • 原文地址:https://www.cnblogs.com/luoyan01/p/9734310.html
Copyright © 2011-2022 走看看