使用docker-compose搭建zabbix

服务器

浏览数:138

2019-8-29

AD:资源代下载服务

简介

欢迎star fork这个项目

https://github.com/bboysoulcn/awesome-dockercompose

之后我会上传并且完善更多的compose文件来方便大家搭建各种各样的环境

今天我们来说怎么使用这个项目搭建zabbix

操作

首先我们clone下这个项目

git clone https://github.com/bboysoulcn/awesome-dockercompose.git

cd awesome-dockercompose/zabbix

之后看下我们的compose文件

version: "3"
services:
  zabbix-server:
    image: "zabbix/zabbix-server-mysql:centos-4.0.4"
    container_name: "zabbix-server"
    restart: "always"
    environment:
      - "DB_SERVER_HOST=zabbix-db"
      - "MYSQL_USER=root"
      - "MYSQL_PASSWORD="
      #- "DB_SERVER_PORT="
      #- "MYSQL_DATABASE="
    volumes:
      - "zabbix-server-data:/var/lib/zabbix/"
    depends_on:
      - "zabbix-db"
    ports:
      - "10051:10051"


  zabbix-web:
    image: "zabbix/zabbix-web-nginx-mysql:centos-4.0.4"
    container_name: "zabbix-web"
    restart: "always"
    environment:
      - "DB_SERVER_HOST=zabbix-db"
      - "MYSQL_USER=root"
      - "MYSQL_PASSWORD="
      - "ZBX_SERVER_HOST=zabbix-server"
      - "PHP_TZ=Asia/Shanghai   "
      #- "ZBX_SERVER_PORT="
      #- "DB_SERVER_PORT="
      #- "MYSQL_DATABASE="
      #- "ZBX_SERVER_NAME="
    depends_on:
      - "zabbix-server"
      - "zabbix-db"
    ports:
      - "8082:80"

  zabbix-db:
    image: "mariadb:10.2.22"
    container_name: "zabbix-db"
    restart: "always"
    environment:
      - "MYSQL_ROOT_PASSWORD="
      - "MYSQL_DATABASE=zabbix"
      #- "MYSQL_USER="
      #- "MYSQL_PASSWORD="
      #- "MYSQL_ALLOW_EMPTY_PASSWORD="
      #- "MYSQL_RANDOM_ROOT_PASSWORD="
    #ports:
    #  - "3306:3306"
    volumes:
      - "zabbix-db-data:/var/lib/mysql/"


volumes:
  zabbix-server-data:
  zabbix-db-data:

如果你要使用外部的mysql那么注释掉zabbix-db这段和 zabbix-db-data:这一行

修改environment下的一些参数,直接使用

docker-compose up -d

启动就好

关于数据的备份的话直接备份

/var/lib/docker/volumes/下的所有和zabbix相关的文件即可

欢迎关注Bboysoul的博客www.bboysoul.com
Have Fun

作者:bboysoul