Docker安装Zabbix全记录
零、Zabbix架构设计
一、docker安装mysql
[root@10e131e69e15 ~]# docker search mysql
INDEX NAME DESCRIPTION STARS OFFICIAL AUTOMATED
docker.io docker.io/mysql MySQL is a widely used, open-source relati... [OK]
docker.io docker.io/mariadb MariaDB is a community-developed fork of M... [OK]
docker.io docker.io/mysql/mysql-server Optimized MySQL Server Docker images. Crea... [OK]
docker.io docker.io/percona Percona Server is a fork of the MySQL rela... [OK]
docker.io docker.io/zabbix/zabbix-server-mysql Zabbix Server with MySQL database support [OK]
docker.io docker.io/hypriot/rpi-mysql RPi-compatible Docker Image with Mysql
docker.io docker.io/centurylink/mysql Image containing mysql. Optimized to be li... [OK]
docker.io docker.io/zabbix/zabbix-web-nginx-mysql Zabbix frontend based on Nginx web-server ... [OK]
docker.io docker.io/1and1internet/ubuntu--nginx-php-phpmyadmin-mysql- ubuntu--nginx-php-phpmyadmin-mysql- [OK]
docker.io docker.io/tutum/mysql Base docker image to run a MySQL database ...
docker.io docker.io/centos/mysql--centos7 MySQL 5.7 SQL database server
docker.io docker.io/mysql/mysql-cluster Experimental MySQL Cluster Docker images. ...
docker.io docker.io/schickling/mysql-backup-s3 Backup MySQL to S3 (supports periodic back... [OK]
docker.io docker.io/bitnami/mysql Bitnami MySQL Docker Image [OK]
docker.io docker.io/zabbix/zabbix-proxy-mysql Zabbix proxy with MySQL database support [OK]
docker.io docker.io/linuxserver/mysql A Mysql container, brought to you by Linux...
docker.io docker.io/centos/mysql--centos7 MySQL 5.6 SQL database server
docker.io docker.io/openshift/mysql--centos7 DEPRECATED: A Centos7 based MySQL v5. ima...
docker.io docker.io/circleci/mysql MySQL is a widely used, open-source relati...
docker.io docker.io/dsteinkopf/backup-all-mysql backup all DBs in a mysql server [OK]
docker.io docker.io/mysql/mysql-router MySQL Router provides transparent routing ...
docker.io docker.io/openzipkin/zipkin-mysql Mirror of https://quay.io/repository/openz... 1
docker.io docker.io/ansibleplaybookbundle/mysql-apb An APB which deploys RHSCL MySQL [OK]
docker.io docker.io/cloudfoundry/cf-mysql-ci Image used in CI of cf-mysql-release
docker.io docker.io/cloudposse/mysql Improved `mysql` service with support for ... [OK]
拉取镜像,我们选择docker.io/mariadb :
[root@10e131e69e15 fanzhang]# docker pull docker.io/mariadb
Using default tag: latest
Trying to pull repository docker.io/library/mariadb ...
latest: Pulling from docker.io/library/mariadb
d660b1f15b9b: Pull complete
c31ac90ebb2f: Pull complete
cb961997371e: Pull complete
02bce683987d: Pull complete
5af7bdeee6f7: Pull complete
16ef8af3c61e: Pull complete
1e3f09afcb5a: Pull complete
5aa0d4b7a708: Pull complete
62094a39ba6f: Pull complete
d1a8f0e27318: Pull complete
8dfdb13e87fc: Pull complete
Digest: sha256:dd8dc06353887dc8235ca83701418dcd29e505301db417439205ed67350d61dc
[root@10e131e69e15 fanzhang]# docker images | grep mariadb
docker.io/mariadb latest 13814daf85b2 hours ago 403.3 MB
在目录/root/fanzhang/docker/mysql下创建目录conf/,data/,logs/分别用于映射配置文件、数据和日志,然后运行容器,使用mariadb镜像:
[root@10e131e69e15 fanzhang]# docker run -p : --name f-mysql -v /root/fanzhang/docker/mysql/conf:/etc/mysql/conf.d -v /root/fanzhang/docker/mysql/logs:/logs -v /root/fanzhang/docker/mysql/data:/var/lib/mysql -e MYSQL_ROOT_PASSWORD= -d mariadb:latest
e7185734f25f0835b73e90fd152b3b158d824c7fa2ef403db163092c23fcd935
[root@10e131e69e15 fanzhang]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
e7185734f25f mariadb:latest "docker-entrypoint.sh" About a minute ago Up About a minute 0.0.0.0:->/tcp f-mysql
二、docker安装zabbix server
[root@10e131e69e15 fanzhang]# docker pull docker.io/zabbix/zabbix-server-mysql
Using default tag: latest
Trying to pull repository docker.io/zabbix/zabbix-server-mysql ...
latest: Pulling from docker.io/zabbix/zabbix-server-mysql
81033e7c1d6a: Pull complete
bccf9f908b27: Pull complete
965ee7bfa719: Pull complete
7deb88b70343: Pull complete
Digest: sha256:a2d540d535592386bed8a80c1843c1c12d09f1fe7a8ddd37bd83186844367a67
[root@10e131e69e15 fanzhang]# docker run --name f-zabbix-server -p : --net=host -e DB_SERVER_HOST="172.28.8.15" -e DB_SERVER_PORT= -e MYSQL_USER="root" -e MYSQL_PASSWORD="" -d docker.io/zabbix/zabbix-server-mysql
7b9d1d8d81924c0734821938bc766d3f3e3f2d70440a1e3c3cecced7746f7279
[root@10e131e69e15 fanzhang]# docker pull docker.io/zabbix/zabbix-web-apache-mysql
Using default tag: latest
Trying to pull repository docker.io/zabbix/zabbix-web-apache-mysql ...
latest: Pulling from docker.io/zabbix/zabbix-web-apache-mysql
ff3a5c916c92: Already exists
a7a4b5e0d00c: Pull complete
d7f46e4857f7: Pull complete
379a306f2512: Pull complete
4581d8b8f55f: Pull complete
fe1fb7155519: Pull complete
3365aba7f13f: Pull complete
e751c6e1609e: Pull complete
1f4b0cab6e61: Pull complete
Digest: sha256:a74698f357945c72f147709bafb9228687ffea5c82ada2486ee96471c7732b18
使用镜像运行容器(注意,-p 将容器的80端口映射到宿主机的8088端口):
[root@10e131e69e15 fanzhang]# docker run --name f-zabbix-web-apache-mysql -p : -e DB_SERVER_HOST="172.28.8.15" -e DB_SERVER_PORT= -e MYSQL_USER="root" -e MYSQL_PASSWORD="" -e ZBX_SERVER_HOST="172.28.8.15" -e TZ="Asia/Shanghai" -d zabbix/zabbix-web-apache-mysql
393df8ea3865a415aedcbcad4163f80f3baae828f0f29f08b3a515e51d382177
在8.15上打开防火墙的8088端口:
iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport -j ACCEPT
[root@10e131e69e15 fanzhang]# curl 172.28.8.15:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=Edge"/>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="Author" content="Zabbix SIA" />
<title>Warning [refreshed every sec.]</title>
<link rel="icon" href="favicon.ico">
<link rel="apple-touch-icon-precomposed" sizes="76x76" href="img/apple-touch-icon-76x76-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="120x120" href="img/apple-touch-icon-120x120-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="152x152" href="img/apple-touch-icon-152x152-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="180x180" href="img/apple-touch-icon-180x180-precomposed.png">
<link rel="icon" sizes="192x192" href="img/touch-icon-192x192.png">
<meta name="csrf-token" content=""/>
<meta name="msapplication-TileImage" content="img/ms-tile-144x144.png">
<meta name="msapplication-TileColor" content="#d40000">
<meta name="msapplication-config" content="none"/>
<link rel="stylesheet" type="text/css" href="styles/blue-theme.css" />
</head>
<body><div class="article"><div class="msg-bad msg-global">Database error<div class="msg-details"><ul class="msg-details-border"><li>Error connecting to database: Unknown database 'zabbix'</li></ul></div><div class="msg-buttons"><button type="button" onclick="document.location.reload();">Retry</button></div></div></div><script type="text/javascript">
setTimeout('document.location.reload();', );
手动创建zabbix数据库,尝试curl:
[root@10e131e69e15 fanzhang]# curl 172.28.8.15:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=Edge"/>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="Author" content="Zabbix SIA" />
<title>Warning [refreshed every sec.]</title>
<link rel="icon" href="favicon.ico">
<link rel="apple-touch-icon-precomposed" sizes="76x76" href="img/apple-touch-icon-76x76-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="120x120" href="img/apple-touch-icon-120x120-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="152x152" href="img/apple-touch-icon-152x152-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="180x180" href="img/apple-touch-icon-180x180-precomposed.png">
<link rel="icon" sizes="192x192" href="img/touch-icon-192x192.png">
<meta name="csrf-token" content=""/>
<meta name="msapplication-TileImage" content="img/ms-tile-144x144.png">
<meta name="msapplication-TileColor" content="#d40000">
<meta name="msapplication-config" content="none"/>
<link rel="stylesheet" type="text/css" href="styles/blue-theme.css" />
</head>
<body><div class="article"><div class="msg-bad msg-global">Database error<div class="msg-details"><ul class="msg-details-border"><li>The frontend does not match Zabbix database.</li></ul></div><div class="msg-buttons"><button type="button" onclick="document.location.reload();">Retry</button></div></div></div><script type="text/javascript">
setTimeout('document.location.reload();', );
进入容器检查数据库连接:
[root@10e131e69e15 zabbix]# docker ps --all
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
393df8ea3865 zabbix/zabbix-web-apache-mysql "docker-entrypoint.sh" minutes ago Up minutes /tcp, 0.0.0.0:->/tcp f-zabbix-web-apache-mysql
4888e711e776 docker.io/zabbix/zabbix-server-mysql "docker-entrypoint.sh" minutes ago Up minutes f-zabbix-server
e7185734f25f mariadb:latest "docker-entrypoint.sh" minutes ago Up minutes 0.0.0.0:->/tcp f-mysql
[root@10e131e69e15 zabbix]# docker exec -it 4888e711e776 /bin/bash
bash-4.3# mysql -uroot -p123456 -h 172.28.8.15 -P
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is
Server version: 10.3.-MariaDB-:10.3.+maria~jessie mariadb.org binary distribution
Copyright (c) , , Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| zabbix |
+--------------------+
rows in set (0.01 sec)
MariaDB [(none)]> quit
Bye
bash-4.3# [root@10e131e69e15 zabbix]# docker exec -it 393df8ea3865 /bin/bash
bash-4.4# mysql -uroot -p123456 -h 172.28.8.15 -P
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is
Server version: 10.3.-MariaDB-:10.3.+maria~jessie mariadb.org binary distribution
Copyright (c) , , Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| zabbix |
+--------------------+
rows in set (0.00 sec)
MariaDB [(none)]>
[root@10e131e69e15 fanzhang]# docker logs f-zabbix-server
** Deploying Zabbix server with mysql database
** Preparing the system
** Preparing Zabbix server
********************
* DB_SERVER_HOST: 172.28.8.15
* DB_SERVER_PORT:
* DB_SERVER_DBNAME: zabbix
* DB_SERVER_ZBX_USER: “root -e MYSQL_PASSWORD=“
* DB_SERVER_ZBX_PASS: zabbix
********************
mysqladmin: unknown option '-e'
**** MySQL server is not available. Waiting seconds…
[root@10e131e69e15 fanzhang]# docker run --name f-zabbix-server -p : --net=host -e DB_SERVER_HOST="172.28.8.15" -e DB_SERVER_PORT= -e MYSQL_USER="root" -e MYSQL_PASSWORD="" -d docker.io/zabbix/zabbix-server-mysql
98facac20dd8d37769c0b64718d70d796f58703528f61e053d1cc5dddaffb817
[root@10e131e69e15 fanzhang]# docker logs f-zabbix-server
** Deploying Zabbix server with mysql database
** Preparing the system
** Preparing Zabbix server
********************
* DB_SERVER_HOST: 172.28.8.15
* DB_SERVER_PORT:
* DB_SERVER_DBNAME: zabbix
* DB_SERVER_ZBX_USER: root
* DB_SERVER_ZBX_PASS:
********************
** Creating 'root' user in MySQL database
** Database 'zabbix' already exists. Please be careful with database COLLATE!
** Creating 'zabbix' schema in MySQ
三、vm内部安装zabbix agent
rpm -ivh https://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-2.el7.noarch.rpm
通过这种方式安装了zabbix-agent还是无法发现主机,因为zabbix-agent上的10050端口和zabbix-server的10051端口并没有打开:
iptables -I INPUT -p tcp --dport -j ACCEPT
iptables -I INPUT -p tcp --dport -j ACCEPT
防火墙放开后,发现zabbix-agent unreachable,查看日志发现:
[root@f-q-c ~]# iptables -I INPUT -p tcp --dport -j ACCEPT
[root@f-q-c ~]# tailf /var/log/zabbix/zabbix_agentd.log
::150758.073 failed to accept an incoming connection: connection from "192.168.122.1" rejected, allowed hosts: "172.28.8.15"
::150858.107 failed to accept an incoming connection: connection from "192.168.122.1" rejected, allowed hosts: "172.28.8.15"
::150958.144 failed to accept an incoming connection: connection from "192.168.122.1" rejected, allowed hosts: "172.28.8.15"
::151058.191 failed to accept an incoming connection: connection from "192.168.122.1" rejected, allowed hosts: "172.28.8.15"
::151158.237 failed to accept an incoming connection: connection from "192.168.122.1" rejected, allowed hosts: "172.28.8.15"
::151258.351 failed to accept an incoming connection: connection from "192.168.122.1" rejected, allowed hosts: "172.28.8.15"
::151358.541 failed to accept an incoming connection: connection from "192.168.122.1" rejected, allowed hosts: "172.28.8.15"
::151458.712 failed to accept an incoming connection: connection from "192.168.122.1" rejected, allowed hosts: "172.28.8.15"
::151558.906 failed to accept an incoming connection: connection from "192.168.122.1" rejected, allowed hosts: "172.28.8.15"
::151658.952 failed to accept an incoming connection: connection from "192.168.122.1" rejected, allowed hosts: “172.28.8.15"
192.168.122.1是网关地址,在8.15上是这样一个设备:
: virbr0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu qdisc noqueue state UP qlen
link/ether :::d7:: brd ff:ff:ff:ff:ff:ff
inet 192.168.122.1/ brd 192.168.122.255 scope global virbr0
valid_lft forever preferred_lft forever
Server=172.28.8.15,192.168.122.1/
Docker安装Zabbix全记录的更多相关文章
- SAP S4HANA1610/Fiori安装过程全记录
经历各种坑,从硬件到文件,终于安装成功. 有需要安装或使用S4HANA(含Fiori)的同学可以参考. 安装文件分享给大家 链接:http://pan.baidu.com/s/1mi7LfIS 密码: ...
- CentOS7下载与安装错误全记录
这篇文章记录安装CentOS7过程错误全记录,供大家和自己参考 起因:笔记本用的win10系统,开启热点的时候,总是10分钟就自动关闭.于是折腾linux系统,平时用win10系统,也切换到linux ...
- docker安装Zabbix
1. 先安装数据库mysqldocker run --name zabbix-mysql-server --hostname zabbix-mysql-server \-e MYSQL_ROOT_PA ...
- 在CentOS6上编译安装实现LAMP(php-modules)+phpMyAdmin安装过程全记录
php与apache协作有三种模式:CGI.modules.FastCGI. 在CGI模式下,用户请求php文件时,apache会启动响应进程,调用php处理器处理请求,然后将结果返回给客户端.用户响 ...
- docker安装踩坑记录
.docker安装包安装很顺利, yum安装安装源在官网或镜像网站下载, fedora/centos分别下载不同的, 在/etc/yum.repos.d/doccker-ce.repo, 把网址改为镜 ...
- 线上服务器PHP版本编译安装升级全记录
1.将原来的PHP重命名一下 cd /usr/local/bin/ mv php php.2.9 2.安装依赖 yum install gcc gcc-c++ libxml2 libxml2-deve ...
- 源码编译mysql 5.5+ 安装过程全记录
前言:从mysql 5.5版本开始,mysql源码安装开始使用cmake了,编译安装跟以前的版本有点不一样了. 一,安装步骤: 1.安装前准备工作 a.下载mysql源代码包,到mysql下载页面选择 ...
- 在 VMware 中安装 MacOS 全记录
在 VMware 15 中安装 MacOS Mojave 安装文件 下载:Unlocker v3.0 for VMware 15地址:https://github.com/DrDonk/unlocke ...
- docker部署安装zabbix
安装docker 安装docker需要配置网络yum源,centos7自带的版本太低了 第一步:下载阿里云的docker安装包 在yum仓库的目录之下 [root@localhost yum.repo ...
随机推荐
- html5 ajax Java接口 上传图片
html5图片上传[文件上传]在网上找了很多资料,主要也就2种 1.from表单提交的方式 <form action="pushUserIcon" method=" ...
- 【洛谷P1850】换教室[2016NOIP提高组]
换教室 期望DP 状态: f[i][j][0/1]表示前i节课 提交j个申请 第i个教室不申请/申请(为了确定当前教室,方便转移) 的最小期望 方程: f[i][j][0]=min(f[i-1][j] ...
- 【luogu P1993 小K的农场】 题解
题目链接:https://www.luogu.org/problemnew/show/P1993 1.差分约束: 对于a - b <= c 有一条 b-->a 权值为c 对于a - b & ...
- spring(二)-反射、动态代理
主要是对上一篇文章中涉及到的点做补充,欢迎指正! 1. java反射知识-Spring IOC 依赖注入 Java反射机制主要提供了以下功能: 在运行时判断任意一个对象所属的类:在运行时构造任意一个 ...
- linux mariadb
https://www.linuxidc.com/Linux/2016-03/128880.htm -- sql 导入 接着输入你所导入到Centos下的数据库文Student.sql文件的位置例如: ...
- Spring-Day03-注解注入&AOP入门-作业
IOC(DI) —— 注解 注解入门: 在applicationContext.xml中引入context约束 打开spring-framework-4.2.4.RELEASE\docs\spring ...
- rest_framework --- viewsets
viewsets :from rest_framework import viewsets #导入方式 ViewSetMixin(object): 这个类,大致作用就是重写了as_view()方法,假 ...
- vue 数组数据更新或者对象数据更新 但是页面没有同步问题
1,使用set函数来设置数据. 2,你可以通过 $forceUpdate 来做这件事.在数据赋值之后 就直接调用 this.$forceUpdata()
- 使用百度定位Api获取当前用户登录地址
最近在做一个商城项目,客户想把网站做成类似于美团的效果,切换地区时,内容也跟随变化.这就要首先解决根据用户id获得地址的问题,最终决定使用百度定位(不适用于搭建反向代理的项目) String url ...
- 解决url传递过程中加号变空格的问题
url传递过程中加号变空格 在接收url参数的过程中,会发现如果参数中存在‘+’号,接收后会变成空格. 如11+22接收后变成11 22. 要解决这个问题,需要将加号替换为%2B进行传递. 如11%2 ...