殷迦南的小破站 - docker-compose
type: channel
link: https://www.ibfpig.top/index.php/tag/docker-compose/
items: docker搭建ES集群并设置密码

docker搭建ES集群并设置密码
type: item
date: 2021-05-03T11:18:00+00:00
description: Elasticsearch从6.8开始，就已经允许免费用户使用X-Pack的安全功能，如此，裸奔的ES就有基础的安全认证了 我们基于docker-compose来搭建该环境 先找个目录来存放docker-compose.yaml以及es的数据和日志等文件 我这里存放在~/DockerFile/es下 创建docker-compose文件以及数据文件 mkdir work # 数据和日志都会放这里 mkdir work/data # 存放数据 mkdir work/logs # 存放日志 touch work/elasticsearch.yml # es相关配置 touch work/kibana.yml # kibana相关配置 elasticsearch.yml的文件内容如下： network.host: 0.0.0.0 xpack.security.enabled: true xpack.security.transport.ssl.enabled: true xpack.security.transport.ssl.keystore.type: PKCS12 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 xpack.security.transport.ssl.truststore.type: PKCS12 xpack.security.audit.enabled: true kibana.yml的文件内容如下 # # ** THIS IS AN AUTO-GENERATED FILE ** # # Default Kibana configuration for docker target server.name: kibana server.host: "0" elasticsearch.hosts: [ "http://elasticsearch:9200" ] elasticsearch.username: "elastic" elasticsearch.password: "" 再创建docker-compose.yaml vim docker-compose.yaml docker-compose.yaml的文件内容如下 version: '2.2' services: es01: image: docker.elastic.co/elasticsearch/elasticsearch:7.12.1 container_name: es01 environment: - node.name=es01 - cluster.name=es-docker-cluster - cluster.initial_master_nodes=es01 - bootstrap.memory_lock=true - "ES_JAVA_OPTS=-Xms512m -Xmx512m" ulimits: memlock: soft: -1 hard: -1 volumes: - ./work/data:/usr/share/elasticsearch/data - ./work/logs:/usr/share/elasticsearch/logs - ./work/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml - ./work/elastic-certificates.p12:/usr/share/elasticsearch/config/elastic-certificates.p12 ports: - 9200:9200 networks: - elastic kib01: image: docker.elastic.co/kibana/kibana:7.12.1 container_name: kib01 ports: - 5601:5601 environment: ELASTICSEARCH_URL: http://es01:9200 ELASTICSEARCH_HOSTS: '["http://es01:9200"]' volumes: - ./work/kibana.yml:/usr/share/kibana/config/kibana.yml networks: - elastic …