Liunx中docker-compose安装elasticsearch和kibana(7.8.0版本)

一、前期准备工作

1、yum和gcc相关

(1) yum update;        #yum更新

(2) yum -y install gcc;        #安装gcc

(3) yum -y install gcc-c++;        #将gcc升级到最新版本

 2、elasticsearch前期准备相关

(1)处理需要的文件夹相关

mkdir -p /usr/local/elasticsearch/data;
mkdir -p /usr/local/elasticsearch/config;
mkdir -p /usr/local/elasticsearch/plugins;

chmod -R 777 /usr/local/elasticsearch/*;

(2)在 /usr/local/elasticsearch/config/下创建elasticsearch.yml

cluster.name: "docker-cluster"
network.host: 0.0.0.0
http.port: 9200
# 开启es跨域
http.cors.enabled: true
http.cors.allow-origin: "*"
http.cors.allow-headers: Authorization
# # 开启安全控制
xpack.security.enabled: true
xpack.security.transport.ssl.enabled: true

 (3)找个目录创建docker-compose.yml 文件

version: '3'

networks:
  es:

services:
  elasticsearch:
    image: elasticsearch:7.8.0             # 容器名为'elasticsearch'
    restart: unless-stopped                           # 指定容器退出后的重启策略为始终重启,但是不考虑在Docker守护进程启动时就已经停止了的容器
    volumes:                                  # 数据卷挂载路径设置,将本机目录映射到容器目录
      - /usr/local/elasticsearch/data:/usr/share/elasticsearch/data
      - /usr/local/elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml
      - /usr/local/elasticsearch/plugins:/usr/share/elasticsearch/plugins
    environment:                              # 设置环境变量,相当于docker run命令中的-e
      TZ: Asia/Shanghai
      LANG: en_US.UTF-8
      discovery.type: single-node
      ES_JAVA_OPTS: "-Xmx512m -Xms512m"
      ELASTIC_PASSWORD: "chana123" # elastic账号密码
    ports:
      - "9200:9200"
      - "9300:9300"
    networks:
      - es

  kibana:
    image: kibana:7.8.0
    container_name: kibana
    restart: unless-stopped
    environment:
      - "ELASTICSEARCH_HOSTS=http://elasticsearch:9200"
      - "ELASTICSEARCH_USERNAME=elastic"
      - "ELASTICSEARCH_PASSWORD=chana123"
    ports:
      - "5601:5601"
    depends_on:
      - elasticsearch
    links:
      - elasticsearch
    networks:
      - es

(4)执行docker-compose启动命令

docker-compose up -d;

你可能感兴趣的:(elasticsearch,docker,大数据)