14、单机版的容器编排

版权声明:原创作品,谢绝转载!否则将追究法律责任。 ————— 作者:kirin

一个业务,往往需要一组容器来支撑

容器编排,就是来实现批量管理一组容器的方法(类似于ansible)

单机 —— ssh —— 安装服务

集群 —— 批量安装服务 —— ansible yaml

docker-compose.yaml 描述docker如何启动一组容器

yum install  docker-compose   -y     ## 需要epel源
docker-compose up -d               ## 创建并启动
docker-compose start                ## 默认全部启动 
docker-compose stop                ## 默认全部停止
docker-compose restart              ## 默认全部重启
docker-compose down              ## 停止并删除、相当于卸载

docker-compose scale zabbix-java-gateway=3   ## 如果没有做固定端口的话,可以调整某一类型的容器数量

1.安装dicker-compose

[root@docker01 ~]#  yum install docker-compose -y 
[root@docker01 ~]#  mkdir -p /opt/dockerfile/docker-compose
[root@docker01 ~]#  cd /opt/dockerfile/docker-compose/
[root@docker01 /opt/dockerfile/docker-compose]#  mkdir zabbix
[root@docker01 /opt/dockerfile/docker-compose]# cd zabbix/
[root@docker01 /opt/dockerfile/docker-compose/zabbix]#  vim docker-cpmpose.yaml

------------------------------------------------------------------------------
粘贴以下内容!!!


version: '3'

services:
   mysql-server:
     image: mysql:5.7
     restart: always
     environment:
       MYSQL_ROOT_PASSWORD: root_pwd
       MYSQL_DATABASE: zabbix
       MYSQL_USER: zabbix
       MYSQL_PASSWORD: zabbix_pwd
     command: --character-set-server=utf8 --collation-server=utf8_bin
     
   zabbix-java-gateway:
     image: zabbix/zabbix-java-gateway:latest
     restart: always
     
   zabbix-server:
     depends_on:
       - mysql-server
     image: zabbix/zabbix-server-mysql:latest
     restart: always
     environment:
       DB_SERVER_HOST: mysql-server
       MYSQL_DATABASE: zabbix
       MYSQL_USER: zabbix
       MYSQL_PASSWORD: zabbix_pwd
       MYSQL_ROOT_PASSWORD: root_pwd
       ZBX_JAVAGATEWAY: zabbix-java-gateway
     ports:
       - "10051:10051"
       
   zabbix-web-nginx-mysql:
     depends_on:
       - zabbix-server
     image: zabbix/zabbix-web-nginx-mysql:latest
     ports:
       - "80:80"
     restart: always
     environment:
       DB_SERVER_HOST: mysql-server
       MYSQL_DATABASE: zabbix
       MYSQL_USER: zabbix
       MYSQL_PASSWORD: zabbix_pwd
       MYSQL_ROOT_PASSWORD: root_pwd

-------------------------------------------------------------------------------
2.清空之前的容器
[root@docker01 /opt/dockerfile/docker-compose/zabbix]# docker rm `docker ps -a -q`
[root@docker01 /opt/dockerfile/docker-compose/zabbix]#  docker-compose up -d

posted @ 2022-06-03 10:54  kirin(麒麟)  阅读(38)  评论(0编辑  收藏  举报
Δ