docker-compose一键部署elasticsearc
更新:HHH   时间:2023-1-7


Docker容器快捷高效部署应用,资源编排定义和运行多个容器,通过docker-compose.yml配置文件声明各个服务,作为一个整体来创建和启动。


ELK是常用的日志管理系统,使用Docker-compose一键部署,省去安装配置的繁琐步骤。


ELK架构:

Docker安装:

https://docs.docker.com/install/linux/docker-ce/ubuntu/

https://docs.docker.com/docker-for-windows/install/


脚本下载:

https://github.com/rickding/HelloDocker/tree/master/elk

├── docker-compose.yml

├── pull.sh

├── up.sh

├── logs.sh

├── down.sh


docker-compose.yml脚本配置ELK服务:

logstash和kibana需要连接elasticsearch实例,所以设置了depends_on属性。

version: '3'
services:
    elasticsearch:
        hostname: elasticsearch
        image: elasticsearch:latest
        restart: always
        ports:
            - 9200:9200
            - 9300:9300

    log:
        image: registry.cn-shanghai.aliyuncs.com/hellodock/logstash:latest
        restart: always
        ports:
            - 9600:9600
            - 9601:9601
        depends_on:
            - elasticsearch

    kibana:
        image: registry.cn-shanghai.aliyuncs.com/hellodock/kibana:latest
        restart: always
        ports:
            - 5601:5601
        depends_on:
            - elasticsearch

pull.sh拉取镜像

可直接运行docker pull elasticsearch:latest拉取镜像,docker images查看:

up.sh启动容器

脚本中封装了docker-compose up -d命令,启动后运行docker ps查看容器实例:

logs.sh查看日志

定制命令突出显示重要信息:

docker-compose logs -ft | grep --color -i -e error -e warn -e version -e exception

down.sh停止服务

docker-compose down --remove-orphans停止并删除容器:

 

查看ELK服务:

elasticsearch:

logstsh:

kibana:

使用docker-compose一键部署ELK,就是这么简单任性。

返回云计算教程...