当前位置:   article > 正文

ELK 系列三、ELK6.5.3 +xpack编译_{"root_cause":[{"type":"illegal_state_exception",

{"root_cause":[{"type":"illegal_state_exception",

目录

一、编译生成jar包和license更新

1.1开启试用版

1.2 进入/usr/local目录(根据自己喜好选择,创建的文件后期会删除)

1.3 分别编译两个文件

1.4 覆盖之前的jar文件

1.5 修改elasticsearch.yml配置文件

 1.6 生成用户名和密码

1.7 将生成的elastic密码配置到kibana中

1.8 启动kibana(先重启elasticsearch)

二、配置logstash

三、新增账号密码


 

大家好,继续上一章安装部署完环境后需要开启用户登录授权等白金许可证的功能。我把许可证续到2050年了

 

好,不多说了,开始操作

 

一、编译生成jar包和license更新

由于在elasticsearch在6.3版本之后x-pack是默认安装好的,所以不再需要用户自己去安装,在此之前你可以先体验试用版30天(不影响后面破解

1.1开启试用版

启动elasticsearch后通过curl启动试用版(注意端口修改)

curl -H "Content-Type:application/json" -XPOST  http://localhost:9200/_xpack/license/start_trial?acknowledge=true

当然你也可以在网页上操作

点击Management,点击 Elasticsearch,点击 License Management,再开启试用

1.2 进入/usr/local目录(根据自己喜好选择,创建的文件后期会删除)

如果不想自己弄的也可以直接使用我打包好的(然后可以跳到步骤1.4的覆盖命令去)

jar包下载地址:https://pan.baidu.com/s/1L3cqrSP6Q3s1oREISjEj7g  密码:t3q4

①创建LicenseVerifier.java文件

vim LicenseVerifier.java
 

  1. package org.elasticsearch.license;
  2. import java.nio.*; import java.util.*;
  3. import java.security.*;
  4. import org.elasticsearch.common.xcontent.*;
  5. import org.apache.lucene.util.*;
  6. import org.elasticsearch.common.io.*;
  7. import java.io.*;
  8. public class LicenseVerifier {
  9. public static boolean verifyLicense(final License license, final byte[] encryptedPublicKeyData) {
  10. return true;
  11. }
  12. public static boolean verifyLicense(final License license) {
  13. return true;
  14. }
  15. }

②创建XPackBuild.java文件

vim XPackBuild.java
 

  1. package org.elasticsearch.xpack.core;
  2. import org.elasticsearch.common.io.*;
  3. import java.net.*;
  4. import org.elasticsearch.common.*;
  5. import java.nio.file.*;
  6. import java.io.*;
  7. import java.util.jar.*;
  8. public class XPackBuild {
  9. public static final XPackBuild CURRENT;
  10. private String shortHash;
  11. private String date;
  12. @SuppressForbidden(reason = "looks up path of xpack.jar directly") static Path getElasticsearchCodebase() {
  13. final URL url = XPackBuild.class.getProtectionDomain().getCodeSource().getLocation();
  14. try { return PathUtils.get(url.toURI()); }
  15. catch (URISyntaxException bogus) {
  16. throw new RuntimeException(bogus); }
  17. }
  18. XPackBuild(final String shortHash, final String date) {
  19. this.shortHash = shortHash;
  20. this.date = date;
  21. }
  22. public String shortHash() {
  23. return this.shortHash;
  24. }
  25. public String date(){
  26. return this.date;
  27. }
  28. static {
  29. final Path path = getElasticsearchCodebase();
  30. String shortHash = null;
  31. String date = null;
  32. Label_0157: { shortHash = "Unknown"; date = "Unknown";
  33. }
  34. CURRENT = new XPackBuild(shortHash, date);
  35. }
  36. }

1.3 分别编译两个文件

  1. javac -cp "/data/elasticsearch-6.5.3/lib/elasticsearch-6.5.3.jar:/data/elasticsearch-6.5.3/lib/lucene-core-7.5.0.jar:/data/elasticsearch-6.5.3/modules/x-pack-core/x-pack-core-6.5.3.jar" LicenseVerifier.java
  2. javac -cp "/data/elasticsearch-6.5.3/lib/elasticsearch-6.5.3.jar:/data/elasticsearch-6.5.3/lib/lucene-core-7.5.0.jar:/data/elasticsearch-6.5.3/modules/x-pack-core/x-pack-core-6.5.3.jar:/data/elasticsearch-6.5.3/lib/elasticsearch-core-6.5.3.jar" XPackBuild.java

编译完成后会生成LicenseVerifier.class和XPackBuild.class两个文件

1.4 覆盖之前的jar文件

  1. cd /usr/local
  2. mkdir tempJar
  3. cp /data/elasticsearch-6.5.3/modules/x-pack-core/x-pack-core-6.5.3.jar tempJar/
  4. cd tempJar
  5. jar -xf x-pack-core-6.5.3.jar
  6. cp ../LicenseVerifier.class org/elasticsearch/license/
  7. cp ../XPackBuild.class org/elasticsearch/xpack/core/
  8. rm x-pack-core-6.5.3.jar
  9. jar -cvf x-pack-core-6.5.3.jar *
  10. #覆盖之前备份原jar包
  11. cp /data/elasticsearch-6.5.3/modules/x-pack-core/x-pack-core-6.5.3.jar /data/elasticsearch-6.5.3/modules/x-pack-core/x-pack-core-6.5.3.jar.bak
  12. #覆盖之前的jar包
  13. cp x-pack-core-6.5.3.jar /data/elasticsearch-6.5.3/modules/x-pack-core/

1.5 修改elasticsearch.yml配置文件

vim /data/elasticsearch-6.5.3/config/elasticsearch.yml

  1. #添加如下代码打开x-pack安全验证
  2. xpack.security.enabled: true

 1.6 生成用户名和密码

  1. #需要重启elasticsearch,上面的配置修改才起作用
  2. 5.生成用户名和密码
  3. cd /data/elasticsearch,上面的配置修改才起作用-6.5.3/bin
  4. #自动生成(二选一)
  5. ./elasticsearch-setup-passwords auto
  6. #手动生成(二选一)
  7. ./elasticsearch-setup-passwords interactive

我这次使用了自动

  1. ./elasticsearch-setup-passwords auto
  2. Initiating the setup of passwords for reserved users elastic,apm_system,kibana,logstash_system,beats_system,remote_monitoring_user.
  3. The passwords will be randomly generated and printed to the console.
  4. Please confirm that you would like to continue [y/N]y
  5. Changed password for user apm_system
  6. PASSWORD apm_system = Qql5kU1s0qlgjvH5OeTcZ7
  7. Changed password for user kibana
  8. PASSWORD kibana = 9BTNVpn1xF21k2bcAKH1He
  9. Changed password for user logstash_system
  10. PASSWORD logstash_system = JFboJA33c997QcxMetkMTX
  11. Changed password for user beats_system
  12. PASSWORD beats_system = PEjPdJw9r4HUZ8kHezOK5Zy
  13. Changed password for user remote_monitoring_user
  14. PASSWORD remote_monitoring_user = 1yn3L53C71Wgml8uGdKUcf
  15. Changed password for user elastic
  16. PASSWORD elastic = 1CHYC5IO6T86rgZM66kyOw

 

修改密码命令

curl -H "Content-Type:application/json" -XPOST -u elastic 'http://127.0.0.1:9200/_xpack/security/user/elastic/_password' -d '{ "password" : "123456" }'

 

可以执行测试命令

curl 127.0.0.1:9200 --user elastic:123456

 

1.7 将生成的elastic密码配置到kibana中

  1. vim /data/kibana-6.5.3-linux-x86_64/config/kibana.yml
  2. #找到以下参数并修改(以下用户名和密码均为你自己的elasticsearch的账户和密码)
  3. #就是上一步骤5生成的密码
  4. elasticsearch.username: elastic
  5. elasticsearch.password: 1CHYC5IO6T86rgZM66kyOw

1.8 启动kibana(先重启elasticsearch)

  1. supervisorctl restart elasticsearch
  2. supervisorctl restart kibana

启动完成后访问kibana(这个就不用我多说了吧,记得要开放端口哦)

但是我们发现只有一个月的试用时间(在登陆成功后的主页面Management->LicenseManagement可以看到)

 

更新license前先关闭x-pack,不然会报错

{"error":{"root_cause":[{"type":"illegal_state_exception","reason":"Cannot install a [PLATINUM] license unless TLS is configured or security is disabled"}],"type":"illegal_state_exception","reason":"Cannot install a [PLATINUM] license unless TLS is configured or security is disabled"},"status":500}

关闭操作:

  1. vim /data/elasticsearch-6.5.3/config/elasticsearch.yml
  2. #添加如下代码打开x-pack安全验证
  3. xpack.security.enabled: false
  4. #然后重启
  5. supervisorctl restart elasticsearch

 

我生成的license内容为:

"type":"platinum" 为白金版许可证,如果需要自己生成license可去官网申请然后修改

license.json的内容如下:

{"license":{"uid":"21b42476-d3a5-4662-95e3-7463c9a9c167","type":"platinum","issue_date_in_millis":1545177600000,"expiry_date_in_millis":2544271999999,"max_nodes":100,"issued_to":"wei wu (wu2700222)","issuer":"Web Form","signature":"AAAAAwAAAA0BdC1OCE7WMDdZ1TX7AAABmC9ZN0hjZDBGYnVyRXpCOW5Bb3FjZDAxOWpSbTVoMVZwUzRxVk1PSmkxaktJRVl5MUYvUWh3bHZVUTllbXNPbzBUemtnbWpBbmlWRmRZb25KNFlBR2x0TXc2K2p1Y1VtMG1UQU9TRGZVSGRwaEJGUjE3bXd3LzRqZ05iLzRteWFNekdxRGpIYlFwYkJiNUs0U1hTVlJKNVlXekMrSlVUdFIvV0FNeWdOYnlESDc3MWhlY3hSQmdKSjJ2ZTcvYlBFOHhPQlV3ZHdDQ0tHcG5uOElCaDJ4K1hob29xSG85N0kvTWV3THhlQk9NL01VMFRjNDZpZEVXeUtUMXIyMlIveFpJUkk2WUdveEZaME9XWitGUi9WNTZVQW1FMG1DenhZU0ZmeXlZakVEMjZFT2NvOWxpZGlqVmlHNC8rWVVUYzMwRGVySHpIdURzKzFiRDl4TmM1TUp2VTBOUlJZUlAyV0ZVL2kvVk10L0NsbXNFYVZwT3NSU082dFNNa2prQ0ZsclZ4NTltbU1CVE5lR09Bck93V2J1Y3c9PQAAAQCCwaKavNagUevP7tN1UWQm/z55fhxtdtdjWkE5MD5pI34OZFd8UZmvy5k0zhhE1wteH8AglWG7J5TPFbpW4dkQ2SdhOmvv5QeFjrzeCgmQl4r1H0lBmZ9sznAwK9yKKh4v4BTNIW6y4LDzYmKdMU1JUpbr9gvULOlZxRyGijA09phlyJ97mQfnjPSvn55Bg8PXhsoJ2RIabUAK204z5bYHINKfRltKyy6b3QuRjPHtzEP6xsON6STHROAVWLrmy3XUp2VMC2gQnx9G64xgMBdvC7KZQfpJiXqWAJf49Ojz+xAf0xC9DhGopq+a29fb5GutPaeIi10XDopfkn9z4ZeL","start_date_in_millis":1545177600000}}

然后把license.json上传到服务器并使用curl提交

curl -XPUT -u elastic 'http://127.0.0.1:9200/_xpack/license' -H "Content-Type: application/json" -d @elk_license.json

 

返回{"acknowledged":true,"license_status":"valid"} 则成功

接着重启打开x-pack

  1. vim /data/elasticsearch-6.5.3/config/elasticsearch.yml
  2. #添加如下代码打开x-pack安全验证
  3. xpack.security.enabled: true
  4. #然后重启
  5. supervisorctl restart elasticsearch

有网友反应碰到一个情况,重启es后报错信息如下:

[2019-01-21T21:23:07,030][WARN ][logstash.outputs.elasticsearch] Attempted to resurrect connection to dead ES instance, but got an error. {:url=>"http://elastic:xxxxxx@192.168.1.222:9200/", :error_type=>LogStash::Outputs::ElasticSearch::HttpClient::Pool::HostUnreachableError, :error=>"Elasticsearch Unreachable: [http://elastic:xxxxxx@192.168.1.222:9200/][Manticore::SocketException] Connection refused"}

解决方法:

在上面的配置文件中再增加一项:

xpack.security.transport.ssl.enabled: true

 

二、配置logstash

因为我们打开了x-pack,需要认证才能上传数据,所有需要在logstash的配置文件中加入认证

[root@i-uzt2a3oi local]# vim /data/logstash-6.5.3/default.conf

需要修改output中的设置,新增user和password

output {
  if [logtype] == "otosaas_app_xingneng" {
    elasticsearch {
        user => "elastic"
        password => "XXXXXX"

        hosts => ["127.0.0.1:9200"]
        index => "otosaas_app_xingneng-%{+YYYY.MM.dd}"
    }
  }
  if [logtype] == "otosaas_app_yunxing" {
    elasticsearch {
        user => "elastic"
        password => "XXXXXX"

        hosts => ["127.0.0.1:9200"]
        index => "otosaas_app_yunxing-%{+YYYY.MM.dd}"
    }
  }
  if [logtype] == "otosaas_konglog" {
    elasticsearch {
        user => "elastic"
        password => "XXXXXX"

        hosts => ["127.0.0.1:9200"]
        index => "otosaas_konglog-%{+YYYY.MM.dd}"
    }
  }
}

不然logstash会报401和403错误

修改完需要重启logstash

 

三、新增账号密码

新增xpack后第一次登录http://192.168.1.78:5601/的时候使用 elastic/XXXX  用户密码登录

然后可以新建一个超级管理员,一个普通read用户

用户roles选择superuser为超级管理员

新增普通用户,先新建一个view的roles,设置如下

然后再新建一个users,绑定这个view就ok了

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/很楠不爱3/article/detail/321253
推荐阅读
相关标签
  

闽ICP备14008679号