elasticsearch|大數據|elasticsearch的api部分實戰操作以及用戶和密碼的管理

一,

前言

本文主要內容是通過elasticsearch的api來進行一些集群的管理和信息查詢工作,以及elasticsearch用戶的增刪改查和密碼的重設以及重置如何操作

接上文:elasticsearch|大數據|elasticsearch低版本集群的部署安裝和安全增強---密碼設置問題-CSDN博客

上文主要介紹了elasticsearch低版本集群的部署和密碼的設定,這些是大大的提高了集群的安全性,但關于security(安全性)只是稍微提及,本文將要更加的深入的介紹這些安全措施,其次是部署完集群僅僅是第一步,如何正確的使用,高效的使用集群才是最終的目的,本文也將從這些方面做一個簡單的論述。

二,

elasticsearch的安全插件----xpack

該插件主要是兩個功能,第一個是通過config文件夾下的elasticsearch-keystone文件加密api,使得在使用api的時候必須要先檢驗預設的用戶和密碼

其次是ssl加密,通過certgen這個工具生成自簽的ca證書(高版本的es這個工具可能改名),以提高elasticsearch的網絡安全

在主配置文件中,有以下三個選項,這三個選項是這兩個功能的開關:

xpack.security.enabled: true
xpack.security.transport.ssl.enabled: false
xpack.security.http.ssl.ssl.enabled: false

上文講了密碼校驗的開啟,ssl如何開啟沒有說,本文就把這個補充上吧

xpack.security.transport.ssl.enabled: false?這個選項應該是集群間ssl自簽證書驗證,防止惡意的增添節點

xpack.security.http.ssl.ssl.enabled: false?這個選項應該是使用自簽證書,外部訪問集群的時候需要證書驗證,通俗的說就是https

那么,先開啟xpack.security.transport.ssl.enabled,具體步驟如下:

1,在master節點生成ca證書(這個證書帶密碼,也可以不帶密碼,我這里用了密碼,隨意設置一個記得住的就可以了)# 生成elastic-stack-ca.p12文件

[root@node1 es]# ./bin/x-pack/certutil ca
This tool assists you in the generation of X.509 certificates and certificate
signing requests for use with SSL/TLS in the Elastic stack.The 'ca' mode generates a new 'certificate authority'
This will create a new X.509 certificate and private key that can be used
to sign certificate when running in 'cert' mode.Use the 'ca-dn' option if you wish to configure the 'distinguished name'
of the certificate authorityBy default the 'ca' mode produces a single PKCS#12 output file which holds:* The CA certificate* The CA's private keyIf you elect to generate PEM format certificates (the -pem option), then the output will
be a zip file containing individual files for the CA certificate and private keyPlease enter the desired output file [elastic-stack-ca.p12]: 
Enter password for elastic-stack-ca.p12 : 

2,生成elastic-certificates.p12這個文件,在其它節點生成同樣的文件,命令稍微修改一下#### 生成elastic-certificates.p12文件,供elasticsearch使用(只在master節點生成,然后拷貝到其它節點即可,scp命令或者什么其它的方式都可以,不得在其它節點自己生成

[root@node1 es]# ./bin/x-pack/certutil cert --ca elastic-stack-ca.p12
This tool assists you in the generation of X.509 certificates and certificate
signing requests for use with SSL/TLS in the Elastic stack.The 'cert' mode generates X.509 certificate and private keys.* By default, this generates a single certificate and key for useon a single instance.* The '-multiple' option will prompt you to enter details for multipleinstances and will generate a certificate and key for each one* The '-in' option allows for the certificate generation to be automated by describingthe details of each instance in a YAML file* An instance is any piece of the Elastic Stack that requires a SSL certificate.Depending on your configuration, Elasticsearch, Logstash, Kibana, and Beatsmay all require a certificate and private key.* The minimum required value for each instance is a name. This can simply be thehostname, which will be used as the Common Name of the certificate. A fulldistinguished name may also be used.* A filename value may be required for each instance. This is necessary when thename would result in an invalid file or directory name. The name provided hereis used as the directory name (within the zip) and the prefix for the key andcertificate files. The filename is required if you are prompted and the nameis not displayed in the prompt.* IP addresses and DNS names are optional. Multiple values can be specified as acomma separated string. If no IP addresses or DNS names are provided, you maydisable hostname verification in your SSL configuration.* All certificates generated by this tool will be signed by a certificate authority (CA).* The tool can automatically generate a new CA for you, or you can provide your own with the-ca or -ca-cert command line options.By default the 'cert' mode produces a single PKCS#12 output file which holds:* The instance certificate* The private key for the instance certificate* The CA certificateIf you elect to generate PEM format certificates (the -pem option), then the output will
be a zip file containing individual files for the instance certificate, the key and the CA certificateIf you elect to generate multiple instances certificates, the output will be a zip file
containing all the generated certificatesEnter password for CA (elastic-stack-ca.p12) : 
Please enter the desired output file [elastic-certificates.p12]: 
Enter password for elastic-certificates.p12 : Certificates written to /data/es/elastic-certificates.p12This file should be properly secured as it contains the private key for 
your instance.This file is a self contained file and can be copied and used 'as is'
For each Elastic product that you wish to configure, you should copy
this '.p12' file to the relevant configuration directory
and then follow the SSL configuration instructions in the product guide.For client applications, you may only need to copy the CA certificate and
configure the client to trust this certificate.

3,如果該證書設置了證書,那么需要節點認證通過,否則會報沒有權限讀取(每個節點都執行):

./bin/elasticsearch-keystore add xpack.security.transport.ssl.keystore.secure_password
./bin/elasticsearch-keystore add xpack.security.transport.ssl.truststore.secure_password

4,為了防止elasticsearch因為權限問題啟動失敗,再次遞歸賦屬組:

chown -Rf es. /data/es

5,elasticsearch主配置文件的修改

在主配置文件末尾添加如下內容:

xpack.security.enabled: true
xpack.security.transport.ssl.enabled: true
http.cors.enabled: true
http.cors.allow-origin: "*"
http.cors.allow-methods : OPTIONS, HEAD, GET, POST, PUT, DELETE
http.cors.allow-headers : X-Requested-With,X-Auth-Token,Content-Type,Content-Length
xpack.security.transport.ssl.verification_mode: certificate
xpack.security.transport.ssl.keystore.path: /data/es/config/cert/elastic-certificates.p12
xpack.security.transport.ssl.truststore.path: /data/es/config/cert/elastic-certificates.p12

?

6,在補充說明一下:

因為elasticsearch集群是使用的發現機制,因此,master在掃描到同網段其它的服務器的9300-9305端口的時候,就會將其自動加入集群,而如果沒有任何驗證的加入節點是非常危險的,因此,證書的密碼建議是最好設置,惡意節點將會因為沒有證書文件并通過節點認證而無法隨意加入集群,這樣,我們的集群將會比較的安全。

verification_mode 控制服務器證書的驗證。有效值為:

  • # full 驗證提供的證書是否由可信機構 (CA) 簽名,并驗證服務器的主機名(或 IP 地址)是否與證書中標識的名稱相匹配。
  • # strict 驗證提供的證書是否由可信機構 (CA) 簽名,并驗證服務器的主機名(或 IP 地址)是否與證書中標識的名稱相匹配。如果 Subject Alternative Name 為空,則返回錯誤。
  • # certificate 驗證提供的證書是否由可信機構 (CA) 簽名,但不執行任何主機名驗證。
  • # none 不執行服務器證書的驗證。此模式會禁用 SSL/TLS 的許多安全優勢,應僅在謹慎考慮后使用。它主要用作嘗試解決 TLS 錯誤時的臨時診斷機制;強烈建議不要在生產環境中使用它。

keystore:存放公鑰,私鑰,數字簽名等信息
truststore:存放信任的證書
keystore和truststore都存放key,不同的地方是truststore只存放公鑰的數字證書,代表了可以信任的證書,keystore存放私鑰相關.

未完待續!!!!!!!!!

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/212601.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/212601.shtml
英文地址,請注明出處:http://en.pswp.cn/news/212601.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

SSM與SpringBoot面試題總結

什么是spring?談談你對IOC和AOP的理解。 Spring:是一個企業級java應用框架,他的作用主要是簡化軟件的開發以及配置過程,簡化項目部署環境。 Spring的優點: 1、Spring低侵入設計,對業務代碼的污染非常低。 2、Spring的DI機制將…

FPGA設計時序約束十一、others類約束之Set_Maximum_Time_Borrow

目錄 一、序言 二、Set Maximum Time Borrow 2.1 基本概念 2.2 設置界面 2.3 命令語法 2.4 命令示例 三、參考資料 一、序言 在Vivado的時序約束窗口中,存在一類特殊的約束,劃分在others目錄下,可用于設置忽略或修改默認的時序路徑分析…

IntelliJ IDEA開啟git版本控制的簡單教程

這篇文章想要分享一下怎么在IntelliJ IDEA開啟版本控制,博主使用的是gitee,首先需要安裝git,關于git的安裝這里就不介紹了,很簡單。 目錄 創建git倉庫 創建項目 開啟版本控制 拉取項目 創建git倉庫 首先,需要登錄…

《Linux中lsof的神奇探秘:打開文件的魔法與更多相似利器》

前言 在Linux的世界里,lsof(List Open Files)是一個強大的工具,它能幫助我們輕松查看系統上打開的文件及網絡連接。然而,除了lsof之外,還有一些與它功能相似且同樣強大的命令等待著我們去發現。本文將引領…

MATLAB | 官方舉辦的動圖繪制大賽 | 第四周(收官周)賽情回顧

MATHWORKS官方舉辦的迷你黑客大賽第三期(MATLAB Flipbook Mini Hack)圓滿結束,雖然我的水平和很多大佬還有比較大的差距,但所有獎也算是拿滿了: 專家評選前三名,以及投票榜前十:~ 每周的階段性獲獎者: 下面…

【Python】手把手教你用tkinter設計圖書管理登錄UI界面(三)

上一篇:【Python】手把手教你用tkinter設計圖書管理登錄UI界面(二)-CSDN博客 下一篇: 緊接上一篇文章,繼續完善項目功能:用戶登錄。由于老王的注冊部分有億點點復雜,還沒完成,但是…

ngixn 準備

確認yum可用,確認防火墻,確認SELinux 一項安裝 yum -y install gcc make automake pcre-devel zlib zlib-devel openssl openssl-devel參數: gcc:編譯依賴gcc環境 pcre:PCRE(Perl Compatible Regular Expressions)是一…

鴻蒙OS應用開發的開發環境

鴻蒙OS應用開發的開發環境 鴻蒙系統發展越來越快,已經開始走進千家萬戶,從手機到電視機,再到汽車,以后各種手表、智能設備等等。這已經是一個廣泛應用的操作系統,也是跟大家生活密切相關的操作系統。要想在這個平臺上…

Git命令---查看遠程倉庫

介紹 使用git命令查看綁定的遠程倉庫。 命令 git remote -v

Kubernetes里的DNS;API資源對象ingress;Kubernetes調度;節點選擇器NodeSelector;節點親和性NodeAffinity

Kubernetes里的DNS K8s集群內有一個DNS服務: kubectl get svc -n kube-system |grep dns測試: 在tang3上安裝bind-utils,目的是安裝dig命令 yum install -y bind-utils apt install dnsutils #ubuntu上 解析外網域名 dig 10.15.0.10 www.baidu.com…

NSSCTF-Crypto靶場練習--第11-20題wp

文章目錄 [SWPUCTF 2021 新生賽]traditional[LitCTF 2023]夢想是紅色的 (初級)[SWPUCTF 2021 新生賽]crypto2[羊城杯 2021]Bigrsa[LitCTF 2023]Hex?Hex!(初級)[SWPU 2020]happy[AFCTF 2018]BASE[安洵杯 2019]JustBase[鶴城杯 2021]Crazy_Rsa_Tech[SWPUCT…

順序表的應用

1. 順序表 1.1 寫法1 Linear_Opeartor2.c #include "stdio.h" #include "stdlib.h" #include "stdbool.h" #include "string.h" //順序表//申明順序表的大小 #define MAXSIZE 5 typedef bool status; //創建順序表 int *Linear_Creat…

DockerFile中途執行出錯的解決辦法

DockerFile中途執行出錯的解決辦法 你們是否也曾經因為DockerFile中途執行出錯,而對其束手無策?總是對docker避之不及! 但是當下載的源碼運用到了docker,dockerFile 執行到一半,報錯了怎么辦? 現狀 那么當DockerFile執行一半出錯后,會產生什么結果呢? 如圖可知,生成…

我們常說的流應用到底是什么?

流應用是DCloud公司開發的一種可以讓手機App安裝包實現邊用邊下的技術。基于HTML5規范的即點即用應用,開發者按照HTML5規范開發的應用,可以在支持HTML5流應用的發行渠道實現即點即用的效果。 流應用是基于 HTML5規范的即點即用應用,開發者按照…

Nacos注冊中心客戶端容災

目前Nacos客戶端有一個FailoverReactor來進行容災文件的管理,可以通過在指定磁盤文件里寫入容災數據來進行客戶端使用數據的覆蓋。FailoverReactor目前會攔截Nacos客戶端查詢接口調用,以getAllInstances接口為例,目前FailoverReactor的工作流…

【合集】SpringBoot——Spring,SpringBoot,SpringCloud相關的博客文章合集

前言 本篇博客是spring相關的博客文章合集,內容涵蓋Spring,SpringBoot,SpringCloud相關的知識,包括了基礎的內容,比如核心容器,springMVC,Data Access;也包括Spring進階的相關知識&…

免費的網頁數據抓取工具有哪些?【2024附下載鏈接】

在網絡上,有許多網頁數據抓取工具可供選擇。本文將探討其如何全網采集數據并支持指定網站抓取。我們將比較不同的數據采集工具,幫助您找到最適合您需求的工具。 網頁數據抓取工具種類 在選擇網頁數據抓取工具之前,讓我們先了解一下這些工具…

TC397 EB MCAL開發從0開始系列 之 [21.2] FlsLoader配置實戰 - 擦除讀寫Pflash

一、FlsLoader配置1、配置目標2、目標依賴2.1 硬件使用2.2 軟件使用2.3 新增模塊3、EB配置3.1 配置講解3.2 模塊配置3.2.1 MCU配置3.2.2 PORT配置3.2.3 FlsLoader配置3.2.5 Irq配置3.2.6 ResourceM配置4、ADS代碼編寫及調試<

[ 藍橋杯Web真題 ]-布局切換

目錄 介紹 準備 目標 規定 思路 解法參考 介紹 經常用手機購物的同學或許見過這種功能&#xff0c;在瀏覽商品列表的時候&#xff0c;我們通過點擊一個小小的按鈕圖標&#xff0c;就能快速將數據列表在大圖&#xff08;通常是兩列&#xff09;和列表兩種布局間來回切換。…

電機:有刷直流電機的原理

一、什么是有刷直流電機 直流有刷電機&#xff08;Brushed DC Motor&#xff09;&#xff0c;定子是用永磁鐵或者線圈做成&#xff0c;以形成固定磁場。在定子一端上有固定碳刷&#xff0c;或者銅刷&#xff0c;負責把外部電流引入轉子線圈。而轉子是由線圈構成&#xff0c;線…