1. 程式人生 > 實用技巧 >ELK7.X中配置x-pack

ELK7.X中配置x-pack

Elasticsearch:分散式的 RESTful 風格的搜尋和資料分析引擎,能夠解決不斷湧現出的各種用例。作為 Elastic Stack 的核心,它集中儲存您的資料,幫助您發現意料之中以及意料之外的情況。

Kibana:能夠以圖表的形式呈現資料,並且具有可擴充套件的使用者介面,供您全方位配置和管理 Elastic Stack。

X-Pack:將諸多強大功能集合到一個單獨的程式包中,更將它帶上了一個新的層次。
Elasticsearch配置檔案

transport.host: localhost

transport.tcp.port: 9300

http.port: 9200

network.host: 0.0.0.0

bootstrap.memory_lock: false

bootstrap.system_call_filter: false

執行:./elasticsearch-6.2.4/bin/elasticsearch -d(-d引數是後臺啟動)
訪問地址:http://localhost:9200/?pretty,這邊可以使用chrome的elasticsearch head外掛來訪問

elasticsearch 7.3使用x-pack kibana登入v

第一步:切換到elasticsearch的目錄下,使用下列命令生成證書

bin/elasticsearch-certutil cert -out config/elastic-certificates.p12 -pass ""

第二步:開啟config/elasticsearch.yaml,在尾部新增下面一行程式碼:

xpack.security.enabled: true
xpack.security.transport.ssl.enabled: true
xpack.security.transport.ssl.verification_mode: certificate
xpack.security.transport.ssl.keystore.path: elastic-certificates.p12
xpack.security.transport.ssl.truststore.path: elastic-certificates.p12

然後啟動elasticsearch

第三步:新開啟一個終端,使用cd命令切換到elasticsearch目錄,然後使用 bin/elasticsearch-setup-passwords auto 命令自動生成好幾個預設使用者和密碼。 如果想手動生成密碼,則使用 bin/elasticsearch-setup-passwords interactive 命令。一般預設會生成好幾個管理員賬戶,其中一個叫elastic的使用者是超級管理員。

[root@cmdb-server bin]# ./elasticsearch-setup-passwords auto
Initiating the setup of passwords for reserved users elastic,apm_system,kibana,logstash_system,beats_system,remote_monitoring_user.
The passwords will be randomly generated and printed to the console.
Please confirm that you would like to continue [y/N]y

Changed password for user apm_system
PASSWORD apm_system = vwMHscFAEtfqTh6hca8f

Changed password for user kibana
PASSWORD kibana = EFvC6s0tJ5DLQf0khfom

Changed password for user logstash_system
PASSWORD logstash_system = JOhNQEImNzS7JRDRdZOc

Changed password for user beats_system
PASSWORD beats_system = Rh3YIxCaaLyoCcA82K6m

Changed password for user remote_monitoring_user
PASSWORD remote_monitoring_user = FTkrJp5VPSoWiIqVVxKF

Changed password for user elastic
PASSWORD elastic = yLPivO0kca63PaAjxtQv

第四步:驗證一下。開啟瀏覽器,輸入我們的elasticsearch的網址,比如本地的http://localhost:9200/ ,然後會彈出一個輸入框,讓我們輸入賬號和密碼,輸入後則可以看到一些介紹。

5、多節點叢集X-Pack安全如何配置?

最簡單的方法,
假定是初始部署叢集階段。

步驟1:清空data檔案;
步驟2:將配置好的帶證書的檔案copy到另一臺機器;
步驟3:根據叢集配置ip、角色等資訊即可。

1、X-Pack簡介

X-Pack是一個Elastic Stack的擴充套件,將安全,警報,監視,報告和圖形功能包含在一個易於安裝的軟體包中。雖然elasticsearch-7.2.1已經全面整合x-pack不需要單獨安裝,但是自帶的x-pack仍然是試用版,所以要想無限期使用全部功能還得破解或購買,本文就x-pcak配置做一個記錄。

首先安裝好Elasticsearch、kibana、logstash,本文承接前面的安裝文件:

https://www.cnblogs.com/heyongboke/p/11348325.html 轉載

這裡我使用的ELK版本均為7.2.1

x-pack外掛安裝順序:

1 2 3 4 5 (1)ElasticSearch (2)kibana (3)logstash

  

2、elasticsearch配置x-pack

2.1、elasticsearch-7.2.1開啟安全驗證配置

1 2 3 4 5 6 #配置elasticsearch.yml配置檔案 [root@ELK1 config]# vim /home/elk/elasticsearch-7.2.1/config/elasticsearch.yml #加上這條:設定x-pack為開啟 xpack.security.enabled:true

  

2.2、執行elasticsearch

1 2 3 [root@ELK1 config]# su - elasticsearch [elasticsearch@ELK1 ]# /home/elk/elasticsearch-7.2.1/bin/elasticsearch -d

  

2.3、啟用trial license(30天試用) 

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

  

2.4、設定密碼

1 2 3 4 5 #在elasticsearch-7.2.1/bin/目錄下執行elasticsearch-setup-passwords設定密碼(賬號預設為elastic): ./elasticsearch-setup-passwords interactive 它會不止是設定elasticsearch,其他的kibana、logstash也會一起設定了,密碼最好全設定同一個

  

2.5、修改密碼方式

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

  

3、Kibana的配置x-pack:

1 2 3 4 5 6 #開啟kibana的kibana.yml配置檔案: [root@ELK1 config]# vim /home/elk/kibana-7.2.1-linux-x86_64/config/kibana.yml #修改如下配置 elasticsearch.username:"elastic" elasticsearch.password:"123456"

  

4、logstash配置x-pack:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 #開啟自定義的logstash的配置檔案logstash.conf,在output中增加elasticsearch的使用者名稱和密碼 [root@ELK1 ~]# vim /home/elk/logstash-7.2.1/config/logstash.conf input { beats { port => 5044 } } output { stdout { codec => rubydebug } elasticsearch { hosts => ["192.168.3.181:9200","192.168.3.182:9200","192.168.3.183:9200"] user =>"elastic" password =>"123456" } }

  

5、啟動

修改完配置後,啟動elk,順序為:elasticsearch,logstash、kibana。

登入介面如下圖: