电脑知识|欧美黑人一区二区三区|软件|欧美黑人一级爽快片淫片高清|系统|欧美黑人狂野猛交老妇|数据库|服务器|编程开发|网络运营|知识问答|技术教程文章 - 好吧啦网

您的位置:首頁技術文章
文章詳情頁

docker安裝Elasticsearch7.6集群并設置密碼

瀏覽:2日期:2024-11-20 17:52:03

Elasticsearch從6.8開始, 允許免費用戶使用X-Pack的安全功能, 以前安裝es都是裸奔。接下來記錄配置安全認證的方法。

為了簡化物理安裝過程,我們將使用docker安裝我們的服務。

一些基礎配置

es需要修改linux的一些參數。

設置vm.max_map_count=262144

sudo vim /etc/sysctl.confvm.max_map_count=262144

不重啟, 直接生效當前的命令

sysctl -w vm.max_map_count=262144

es的data和logs目錄需要給1000的用戶授權, 我們假設安裝3個實力的es集群,先創建對應的數據存儲文件

mkdir -p es01/datamkdir -p es01/logsmkdir -p es02/datamkdir -p es02/logsmkdir -p es03/datamkdir -p es03/logs## es的用戶id為1000,這里暫且授權給所有人好了sudo chmod 777 es* -R

關于版本和docker鏡像

Elasticsearch分幾種licenses,其中Open Source和Basic是免費的, 而在6.8之后安全功能才開始集成在es的Basic授權上。

docker安裝Elasticsearch7.6集群并設置密碼

Basic對應docker鏡像為

docker pull docker.elastic.co/elasticsearch/elasticsearch:7.6.2

同時dockerhub同步為elasticsearch. 我們直接拉取elasticsearch:7.6.2就好。

開始

安裝文件均放在GitHub: https://github.com/Ryan-Miao/docker-china-source/tree/master/docker-elasticsearch

首先,創建docker-compose.yml

version: ’2.2’services: es01: image: elasticsearch:7.6.2 container_name: es01 environment: - node.name=es01 - cluster.name=es-docker-cluster - discovery.seed_hosts=es02,es03 - cluster.initial_master_nodes=es01,es02,es03 - bootstrap.memory_lock=true - 'ES_JAVA_OPTS=-Xms512m -Xmx512m' ulimits: memlock: soft: -1 hard: -1 volumes: - ./es01/data:/usr/share/elasticsearch/data - ./es01/logs:/usr/share/elasticsearch/logs - ./elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml - ./elastic-certificates.p12:/usr/share/elasticsearch/config/elastic-certificates.p12 ports: - 9200:9200 networks: - elastic es02: image: elasticsearch:7.6.2 container_name: es02 environment: - node.name=es02 - cluster.name=es-docker-cluster - discovery.seed_hosts=es01,es03 - cluster.initial_master_nodes=es01,es02,es03 - bootstrap.memory_lock=true - 'ES_JAVA_OPTS=-Xms512m -Xmx512m' ulimits: memlock: soft: -1 hard: -1 volumes: - ./es02/data:/usr/share/elasticsearch/data - ./es02/logs:/usr/share/elasticsearch/logs - ./elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml - ./elastic-certificates.p12:/usr/share/elasticsearch/config/elastic-certificates.p12 ports: - 9201:9200 networks: - elastic es03: image: elasticsearch:7.6.2 container_name: es03 environment: - node.name=es03 - cluster.name=es-docker-cluster - discovery.seed_hosts=es01,es02 - cluster.initial_master_nodes=es01,es02,es03 - bootstrap.memory_lock=true - 'ES_JAVA_OPTS=-Xms512m -Xmx512m' ulimits: memlock: soft: -1 hard: -1 volumes: - ./es03/data:/usr/share/elasticsearch/data - ./es03/logs:/usr/share/elasticsearch/logs - ./elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml - ./elastic-certificates.p12:/usr/share/elasticsearch/config/elastic-certificates.p12 ports: - 9202:9200 networks: - elastic kib01: depends_on: - es01 image: kibana:7.6.2 container_name: kib01 ports: - 5601:5601 environment: ELASTICSEARCH_URL: http://es01:9200 ELASTICSEARCH_HOSTS: http://es01:9200 volumes: - ./kibana.yml:/usr/share/kibana/config/kibana.yml networks: - elasticnetworks: elastic: driver: bridge

關于elasticsearch.yml

內容如下

network.host: 0.0.0.0xpack.security.enabled: truexpack.security.transport.ssl.enabled: truexpack.security.transport.ssl.keystore.type: PKCS12xpack.security.transport.ssl.verification_mode: certificatexpack.security.transport.ssl.keystore.path: elastic-certificates.p12xpack.security.transport.ssl.truststore.path: elastic-certificates.p12xpack.security.transport.ssl.truststore.type: PKCS12xpack.security.audit.enabled: true network.host 設置允許其他ip訪問,解除ip綁定 xpack.security 則是安全相關配置,其中ssl的證書需要自己生成

關于證書elastic-certificates.p12

es提供了生成證書的工具elasticsearch-certutil,我們可以在docker實例中生成它,然后復制出來,后面統一使用。

首先運行es實例

sudo docker run -dit --name=es elasticsearch:7.6.2 /bin/bash

進入實例內部

sudo docker exec -it es /bin/bash

生成ca: elastic-stack-ca.p12

[root@25dee1848942 elasticsearch]# ./bin/elasticsearch-certutil caThis tool assists you in the generation of X.509 certificates and certificatesigning 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 usedto 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 willbe 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 :

再生成cert: elastic-certificates.p12

[root@25dee1848942 elasticsearch]# ./bin/elasticsearch-certutil cert --ca elastic-stack-ca.p12This tool assists you in the generation of X.509 certificates and certificatesigning requests for use with SSL/TLS in the Elastic stack.The ’cert’ mode generates X.509 certificate and private keys.

這個生成elastic-certificates.p12 就是我們需要使用的。

復制出證書, ctrl+d退出容器內部

sudo docker cp es:/usr/share/elasticsearch/elastic-certificates.p12 .# 關閉這個容器sudo docker kill essudo docker rm es

如此獲取了證書。

生成密碼

我們首先要啟動es集群,去里面生成密碼。

sudo docker-compose up

然后進入其中一臺

sudo docker exec -it es01 /bin/bash

生成密碼用auto, 自己設置用 interactive

[root@cfeeab4bb0eb elasticsearch]# ./bin/elasticsearch-setup-passwords -hSets the passwords for reserved usersCommands--------auto - Uses randomly generated passwordsinteractive - Uses passwords entered by a userNon-option arguments:command Option Description ------ ----------- -E <KeyValuePair> Configure a setting-h, --help Show help -s, --silent Show minimal output-v, --verbose Show verbose output[root@cfeeab4bb0eb elasticsearch]# ./bin/elasticsearch-setup-passwords autoInitiating 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]yChanged password for user apm_systemPASSWORD apm_system = YxVzeT9B2jEDUjYp66WsChanged password for user kibanaPASSWORD kibana = 8NnThbj0N02iDaTGhidUChanged password for user logstash_systemPASSWORD logstash_system = 9nIDGe7KSV8SQidSk8DjChanged password for user beats_systemPASSWORD beats_system = qeuVaf1VEALpJHfEUOjJChanged password for user remote_monitoring_userPASSWORD remote_monitoring_user = DtZCrCkVTZsinRn3tW3DChanged password for user elasticPASSWORD elastic = q5f2qNfUJQyvZPIz57MZ

使用密碼

瀏覽器訪問localhost:9200/9201/9202 需要輸入賬號

輸入對應的elastic/password就好

瀏覽器訪問localhost:5601

docker安裝Elasticsearch7.6集群并設置密碼

忘記密碼

如果生成后忘記密碼了怎么辦, 可以進入機器去修改。

進入es的機器

sudo docker exec -it es01 /bin/bash

創建一個臨時的超級用戶RyanMiao

./bin/elasticsearch-users useradd ryan -r superuserEnter new password: ERROR: Invalid password...passwords must be at least [6] characters long[root@cfeeab4bb0eb elasticsearch]# ./bin/elasticsearch-users useradd ryan -r superuserEnter new password: Retype new password:

用這個用戶去修改elastic的密碼:

curl -XPUT -u ryan:ryan123 http://localhost:9200/_xpack/security/user/elastic/_password -H 'Content-Type: application/json' -d ’{ 'password': 'q5f2qNfUJQyvZPIz57MZ'}’

參考

http://codingfundas.com/setting-up-elasticsearch-6-8-with-kibana-and-x-pack-security-enabled/index.html

到此這篇關于docker安裝Elasticsearch7.6集群并設置密碼的文章就介紹到這了,更多相關docker安裝Elasticsearch集群內容請搜索好吧啦網以前的文章或繼續瀏覽下面的相關文章希望大家以后多多支持好吧啦網!

標簽: Docker
相關文章:
主站蜘蛛池模板: 首页_中夏易经起名网| 济南ISO9000认证咨询代理公司,ISO9001认证,CMA实验室认证,ISO/TS16949认证,服务体系认证,资产管理体系认证,SC食品生产许可证- 济南创远企业管理咨询有限公司 郑州电线电缆厂家-防火|低压|低烟无卤电缆-河南明星电缆 | 衡阳耐适防护科技有限公司——威仕盾焊接防护用品官网/焊工手套/焊接防护服/皮革防护手套 | 植筋胶-粘钢胶-碳纤维布-碳纤维板-环氧砂浆-加固材料生产厂家-上海巧力建筑科技有限公司 | 商秀—企业短视频代运营_抖音企业号托管 | 天津货架厂_穿梭车货架_重型仓储货架_阁楼货架定制-天津钢力仓储货架生产厂家_天津钢力智能仓储装备 | ICP备案查询_APP备案查询_小程序备案查询 - 备案巴巴 | 砂尘试验箱_淋雨试验房_冰水冲击试验箱_IPX9K淋雨试验箱_广州岳信试验设备有限公司 | 纸塑分离机-纸塑分离清洗机设备-压力筛-碎浆机厂家金双联环保 | 识禅_对禅的了解,从这里开始| 菏泽商标注册_菏泽版权登记_商标申请代理_菏泽商标注册去哪里 | 无缝钢管-聊城无缝钢管-小口径无缝钢管-大口径无缝钢管 - 聊城宽达钢管有限公司 | 山东信蓝建设有限公司官网 | 圆周直径尺-小孔内视镜-纤维研磨刷-东莞市高腾达精密工具 | 深圳货架厂_仓库货架公司_重型仓储货架_线棒货架批发-深圳市诺普泰仓储设备有限公司 | 仿古建筑设计-仿古建筑施工-仿古建筑公司-汉匠古建筑设计院 | 湖南自考_湖南自学考试网 | 低粘度纤维素|混凝土灌浆料|有机硅憎水粉|聚羧酸减水剂-南京斯泰宝 | 保温杯,儿童婴童奶瓶,运动水壶「广告礼品杯定制厂家」超朗保温杯壶 | 重庆磨床过滤机,重庆纸带过滤机,机床伸缩钣金,重庆机床钣金护罩-重庆达鸿兴精密机械制造有限公司 | ?水马注水围挡_塑料注水围挡_防撞桶-常州瑞轩水马注水围挡有限公司 | 智慧养老_居家养老_社区养老_杰佳通 | 高防护蠕动泵-多通道灌装系统-高防护蠕动泵-www.bjhuiyufluid.com慧宇伟业(北京)流体设备有限公司 | 罐体电伴热工程-消防管道电伴热带厂家-山东沃安电气 | 标准件-非标紧固件-不锈钢螺栓-非标不锈钢螺丝-非标螺母厂家-三角牙锁紧自攻-南京宝宇标准件有限公司 | 辽宁资质代办_辽宁建筑资质办理_辽宁建筑资质延期升级_辽宁中杭资质代办 | 冷藏车-东风吸污车-纯电动环卫车-污水净化车-应急特勤保障车-程力专汽厂家-程力专用汽车股份有限公司销售二十一分公司 | 金联宇电缆|广东金联宇电缆厂家_广东金联宇电缆实业有限公司 | 整车VOC采样环境舱-甲醛VOC预处理舱-多舱法VOC检测环境仓-上海科绿特科技仪器有限公司 | 济南ISO9000认证咨询代理公司,ISO9001认证,CMA实验室认证,ISO/TS16949认证,服务体系认证,资产管理体系认证,SC食品生产许可证- 济南创远企业管理咨询有限公司 郑州电线电缆厂家-防火|低压|低烟无卤电缆-河南明星电缆 | 水平筛厂家-三轴椭圆水平振动筛-泥沙震动筛设备_山东奥凯诺矿机 包装设计公司,产品包装设计|包装制作,包装盒定制厂家-汇包装【官方网站】 | 气象监测系统_气象传感器_微型气象仪_气象环境监测仪-山东风途物联网 | 东莞注册公司-代办营业执照-东莞公司注册代理记账-极刻财税 | 对辊破碎机_四辊破碎机_双齿辊破碎机_华盛铭重工 | 企业VI设计_LOGO设计公司_品牌商标设计_【北京美研】 | 全自动在线分板机_铣刀式在线分板机_曲线分板机_PCB分板机-东莞市亿协自动化设备有限公司 | 登车桥动力单元-非标液压泵站-非标液压系统-深圳市三好科技有限公司 | 欧洲MV日韩MV国产_人妻无码一区二区三区免费_少妇被 到高潮喷出白浆av_精品少妇自慰到喷水AV网站 | 聚合氯化铝厂家-聚合氯化铝铁价格-河南洁康环保科技 | 洛阳装修公司-洛阳整装一站式品牌-福尚云宅装饰 | 超细|超微气流粉碎机|气流磨|气流分级机|粉体改性机|磨粉机|粉碎设备-山东埃尔派粉体科技 |