docker-compose安装elasticsearch及kibana

一、安装前提,必须安装docker及dockercompose插件

二、准备docker-compose.yml文件

version: '3.1'
services:
  elasticsearch:
    image: elasticsearch:7.13.3
    container_name: elasticsearch
    privileged: true
    environment:
      - "cluster.name=elasticsearch" #设置集群名称为elasticsearch
      - "discovery.type=single-node" #以单一节点模式启动
      - "ES_JAVA_OPTS=-Xms512m -Xmx1096m" #设置使用jvm内存大小
      - bootstrap.memory_lock=true
    volumes:
      - ./es/plugins:/usr/local/dockercompose/elasticsearch/plugins #插件文件挂载
      - ./es/data:/usr/local/dockercompose/elasticsearch/data:rw #数据文件挂载
      - ./es/logs:/usr/local/dockercompose/elasticsearch/logs:rw
    ports:
      - 9200:9200
      - 9300:9300
    deploy:
     resources:
        limits:
           cpus: "2"
           memory: 1000M
        reservations:
           memory: 200M
  kibana:
    image: kibana:7.13.3
    container_name: kibana
    depends_on:
      - elasticsearch #kibana在elasticsearch启动之后再启动
    environment:
      ELASTICSEARCH_HOSTS: http://elasticsearch:9200 #设置访问elasticsearch的地址
      I18N_LOCALE: zh-CN
    ports:
      - 5601:5601

三、创建文件夹:

mkdir /usr/local/dockercompose/elasticsearch/plugins
mkdir /usr/local/dockercompose/elasticsearch/data
mkdir /usr/local/dockercompose/elasticsearch/logs

四、将docker-compose.yml上传至文件夹/usr/local/dockercompose/elasticsearch中

五、直接安装命令

#后台执行
docker-compose up -d

六、运行docker ps看是否运行成功

 

 七、打开服务器的防火墙端口:5601和9200

八、访问kibana: 服务器ip:5601

 

 

出现以上界面说明已安装成功,如果未安装成功则前往/usr/local/dockercompose/elasticsearch/logs文件夹下查看日志

 

posted @ 2022-04-23 19:05  陈远波  阅读(3845)  评论(0编辑  收藏  举报