Docker拉取镜像搭建Zabbix
部署docker:
wget https://download.docker.com/linux/centos/docker-ce.repo
mv docker-ce.repo /etc/yum.repos.d
或者
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum install -y docker-ce
#在文件最后添加,以一下红色标记内容 vim /etc/sysctl.conf
net.ipv4.ip_forward = 1
#使用配置生效 sysctl -p
systemctl start docker
systemctl enable docker
1、拉取镜像
5.7 :
centos-latest :
latest :
latest :
docker pull zabbix/zabbix-agent:latest
2、配置网络(docker的网桥)
docker network create d bridge zabbix_net --subnet 172.18.0.0/16 --gateway 172.18.0.1
docker network ls
3、安装mysql
3306 --name zabbix-mysql \ :
--network zabbix_net --ip 172.18.0.2 \
-v /usr/local/docker/mysql/conf:/etc/mysql \
-v /usr/local/docker/mysql/logs:/var/log/mysql \
-v /usr/local/docker/mysql/data:/var/lib/mysql \
-v /etc/localtime:/etc/localtime \
-e MYSQL_DATABASE="zabbix" \
-e MYSQL_USER="zabbix" \
-e MYSQL_PASSWORD="123456" \
-e MYSQL_ROOT_PASSWORD="123456" \
-d mysql:5.7 \
--restart=always \
--character-set-server=utf8 --collation-server=utf8_bin
4、安装java-gateway
docker run -v /etc/localtime:/etc/localtime -dit --restart=always --name zabbix-java-gateway --network zabbix_net --ip 172.18.0.5 zabbix/zabbix-java-gateway:latest
5、安装zabbix-server-mysql
docker run -dit -p 10051:10051 --mount source=zabbix-server-vol,target=/etc/zabbix \
-v /etc/localtime:/etc/localtime \
-v /usr/lib/zabbix/alertscripts:/usr/lib/zabbix/alertscripts \
--name=zabbix-server-mysql --restart=always --network zabbix_net --ip 172.18.0.6 \
-e DB_SERVER_HOST="zabbix-mysql" \
-e MYSQL_DATABASE="zabbix" \
-e MYSQL_USER="zabbix" \
-e MYSQL_PASSWORD="123456" \
-e MYSQL_ROOT_PASSWORD="123456" \
-e ZBX_JAVAGATEWAY="zabbix-java-gateway" zabbix/zabbix-server-mysql:centos-latest
6、安装zabbix-nginx
docker run -dit -p 8888:8080 -v /etc/localtime:/etc/localtime \
--name zabbix-nginx \
--restart=always --network zabbix_net --ip 172.18.0.3 \
-e DB_SERVER_HOST="zabbix-mysql" \
-e MYSQL_DATABASE="zabbix" \
-e MYSQL_USER="zabbix" \
-e MYSQL_PASSWORD="123456" \
-e MYSQL_ROOT_PASSWORD="123456" \
-e ZBX_SERVER_HOST="zabbix-server-mysql" liuxianhuacn/zabbix-web-nginx-php
docker run -dit --name zabbix-agent -e ZBX_HOSTNAME="zabbix-server-mysql" --restart=always --link zabbix-server-mysql --network zabbix_net --ip 172.18.0.4 -e ZBX_SERVER_HOST="zabbix-server-mysql" -p 10050:10050 --privileged -e ZBX_SERVER_PORT=10051 -d zabbix/zabbix-agent:latest
8、登陆zabbix web
http://192.168.52.19:8888
用户:Admin 密码: zabbix
主机名称:192.168.52.19
可见的名称:Zabbix server
客户端: 192.168.52.19 10050