一、ES單節(jié)點(diǎn)密碼配置
1、修改配置文件
在配置文件中添加如下參數(shù)cat config/elasticsearch.yml:
xpack.security.enabled: true
xpack.security.transport.ssl.enabled: true
http.cors.allow-headers: Authorization,X-Requested-With,Content-Length,Content-Type
2、 重啟es服務(wù)
關(guān)閉es服務(wù)如果服務(wù)啟動(dòng)(kill進(jìn)程id)
啟動(dòng)es服務(wù)
3,執(zhí)行修改密碼命令
待服務(wù)啟動(dòng)完成,且能正常訪問(wèn)后,執(zhí)行
# 注意在es用戶下執(zhí)行
./bin/elasticsearch-setup-passwords interactive
#執(zhí)行命令后會(huì)提示讓輸入密碼,挨個(gè)輸入回車即可
# 或者后面這條自動(dòng)生成密碼
./bin/elasticsearch-setup-passwords auto
4、訪問(wèn)服務(wù)
二、ES集群密碼配置
1、確定主節(jié)點(diǎn)
集群此時(shí)是啟動(dòng)狀態(tài)
-
elasticsearch-head查看
-
通過(guò)瀏覽器查看
http://192.168.180.45:9200/_cat/nodes?v
2、生成elastic-stack-ca.p12
進(jìn)入主節(jié)點(diǎn)的bin目錄下執(zhí)行
./bin/elasticsearch-certutil ca
#會(huì)要求輸入密碼直接回車即可
#執(zhí)行完成之后會(huì)在bin目錄的同級(jí)目錄生成一個(gè)文件elastic-stack-ca.p12
3、生成elastic-certificates.p12
再次在bin目錄輸入命令并指定剛才生成的elastic-stack-ca .p12文件
./bin/elasticsearch-certutil cert -ca ../elastic-stack-ca.p12
#會(huì)要求輸入密碼直接回車即可
#執(zhí)行完成之后會(huì)在bin目錄的同級(jí)目錄生成一個(gè)文件elastic-certificates.p12
4、修改配置文件并重啟集群
- 在每一個(gè)es節(jié)點(diǎn)的config目錄下創(chuàng)建一個(gè)certs文件夾將生成的elastic-certificates.p12文件復(fù)制到其中
- 修改配置文件,添加如下配置:
xpack.security.enabled: true
xpack.security.transport.ssl.enabled: true
xpack.security.transport.ssl.verification_mode: certificate
xpack.security.transport.ssl.keystore.path: cert/elastic-certificates.p12
xpack.security.transport.ssl.truststore.path: cert/elastic-certificates.p12
#下面這行是為了es-head能夠連上
http.cors.allow-headers: Authorization,X-Requested-With,Content-Length,Content-Type
重啟es集群
5、進(jìn)行密碼配置
? 在任意點(diǎn)bin下執(zhí)行設(shè)置密碼
# 注意在es用戶下執(zhí)行
./bin/elasticsearch-setup-passwords interactive
#執(zhí)行命令后會(huì)提示讓輸入密碼,挨個(gè)輸入回車即可
# 或者后面這條自動(dòng)生成密碼
./bin/elasticsearch-setup-passwords auto
6、驗(yàn)證
網(wǎng)頁(yè)登錄任意一臺(tái)服務(wù)器:http://192.168.180.46:9200/,需要輸入用戶名密碼文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-858451.html
三、es-head登錄增加密碼的es
訪問(wèn)地址:
http://192.168.180.35:9101/?auth_user=elastic&auth_password=密碼文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-858451.html
四、去掉密碼
- 去掉elasticsearch.yml中添加的內(nèi)容
- 用es-head 連接es刪除索引 .security-7
- 重啟es
到了這里,關(guān)于6、ES單機(jī)設(shè)置用戶名密碼、集群設(shè)置用戶名密碼、es-head登錄、如何去掉密碼的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!