一、前言
本文将基于docker-compose 部署Elasticsearch 并设置账号密码 。
- docker-compose version 1.29.2, build 5becea4c
- elasticsearch:7.14.1
- kibana:7.14.1
可参考:https://gitee.com/zhengqingya/docker-compose
二、docker-compose部署Elasticsearch
git clone https://gitee.com/zhengqingya/docker-compose.git
cd docker-compose/Liunx
chmod -R 777 ./elasticsearch
docker-compose -f docker-compose-elasticsearch.yml -p elasticsearch up -d
chmod -R 777 ./elasticsearch
三、访问
- ES访问地址:
ip地址:9200 默认账号密码:elastic/123456 - kibana访问地址:
ip地址:5601/app/dev_tools#/console 默认账号密码:elastic/123456
四、ES密码
1、设置ES密码
docker exec -it elasticsearch /bin/bash
elasticsearch-setup-passwords interactive
curl 127.0.0.1:9200 -u elastic:123456
2、修改ES密码
curl -H "Content-Type:application/json" -XPOST -u elastic 'http://127.0.0.1:9200/_xpack/security/user/elastic/_password' -d '{ "password" : "123456" }'
五、其他
这里附上部署相关文件吧 ^_^
docker-compose-elasticsearch.yml
version: '3'
networks:
es:
services:
elasticsearch:
image: registry.cn-hangzhou.aliyuncs.com/zhengqing/elasticsearch:7.14.1
container_name: elasticsearch
restart: unless-stopped
volumes:
- "./elasticsearch/data:/usr/share/elasticsearch/data"
- "./elasticsearch/logs:/usr/share/elasticsearch/logs"
- "./elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml"
environment:
TZ: Asia/Shanghai
LANG: en_US.UTF-8
discovery.type: single-node
ES_JAVA_OPTS: "-Xmx512m -Xms512m"
ELASTIC_PASSWORD: "123456"
ports:
- "9200:9200"
- "9300:9300"
networks:
- es
kibana:
image: registry.cn-hangzhou.aliyuncs.com/zhengqing/kibana:7.14.1
container_name: kibana
restart: unless-stopped
volumes:
- ./elasticsearch/kibana/config/kibana.yml:/usr/share/kibana/config/kibana.yml
ports:
- "5601:5601"
depends_on:
- elasticsearch
links:
- elasticsearch
networks:
- es
elasticsearch.yml
cluster.name: "docker-cluster"
network.host: 0.0.0.0
http.port: 9200
http.cors.enabled: true
http.cors.allow-origin: "*"
http.cors.allow-headers: Authorization
xpack.security.enabled: true
xpack.security.transport.ssl.enabled: true
kibana.yml
server.name: kibana
server.host: "0.0.0.0"
elasticsearch.hosts: [ "http://elasticsearch:9200" ]
xpack.monitoring.ui.container.elasticsearch.enabled: true
elasticsearch.username: "elastic"
elasticsearch.password: "123456"
i18n.locale: zh-CN
今日分享语句: 时刻要替别人着想,但为自己而活。
|