docker离线安装zabbix
Posted fanlong0212
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了docker离线安装zabbix相关的知识,希望对你有一定的参考价值。
第一部分:下载安装zabbix所须的镜像
所须镜像包为:mysql、zabbix-server、zabbix-web-nginx、zabbbix-agent
1、搜索镜像
docker search [想要搜索的镜像名] [root@localhost ~]# docker search mysql INDEX NAME DESCRIPTION STARS OFFICIAL AUTOMATED docker.io docker.io/mysql MySQL is a widely used, open-source relati... 9080 [OK] docker.io docker.io/mariadb MariaDB is a community-developed fork of M... 3212 [OK] docker.io docker.io/mysql/mysql-server Optimized MySQL Server Docker images. Crea... 673 [OK] docker.io docker.io/centos/mysql-57-centos7 MySQL 5.7 SQL database server 67 docker.io docker.io/centurylink/mysql Image containing mysql. Optimized to be li... 61 [OK] docker.io docker.io/mysql/mysql-cluster Experimental MySQL Cluster Docker images. ... 61 docker.io docker.io/deitch/mysql-backup REPLACED! Please use http://hub.docker.com... 41 [OK] docker.io docker.io/bitnami/mysql Bitnami MySQL Docker Image 35 [OK] docker.io docker.io/tutum/mysql Base docker image to run a MySQL database ... 34 docker.io docker.io/schickling/mysql-backup-s3 Backup MySQL to S3 (supports periodic back... 28 [OK] docker.io docker.io/prom/mysqld-exporter 26 [OK] docker.io docker.io/linuxserver/mysql A Mysql container, brought to you by Linux... 24 docker.io docker.io/centos/mysql-56-centos7 MySQL 5.6 SQL database server 18 docker.io docker.io/circleci/mysql MySQL is a widely used, open-source relati... 16 docker.io docker.io/mysql/mysql-router MySQL Router provides transparent routing ... 14 docker.io docker.io/arey/mysql-client Run a MySQL client from a docker container 13 [OK] docker.io docker.io/databack/mysql-backup Back up mysql databases to... anywhere! 10 docker.io docker.io/openshift/mysql-55-centos7 DEPRECATED: A Centos7 based MySQL v5.5 ima... 6 docker.io docker.io/fradelg/mysql-cron-backup MySQL/MariaDB database backup using cron t... 4 [OK] docker.io docker.io/genschsa/mysql-employees MySQL Employee Sample Database 4 [OK] docker.io docker.io/ansibleplaybookbundle/mysql-apb An APB which deploys RHSCL MySQL 2 [OK] docker.io docker.io/devilbox/mysql Retagged MySQL, MariaDB and PerconaDB offi... 2 docker.io docker.io/jelastic/mysql An image of the MySQL database server main... 1 docker.io docker.io/monasca/mysql-init A minimal decoupled init container for mysql 0 docker.io docker.io/widdpim/mysql-client Dockerized MySQL Client (5.7) including Cu... 0 [OK]
2、从仓库拉取镜像
docker pull [镜像名] [root@localhost ~]# docker pull mysql Using default tag: latest Trying to pull repository docker.io/library/mysql ... latest: Pulling from docker.io/library/mysql
3、查看下载的镜像
docker images [root@localhost ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE docker.io/mysql latest 791b6e40940c 21 hours ago 465 MB mysql latest 791b6e40940c 21 hours ago 465 MB docker.io/zabbix/zabbix-web-nginx-mysql latest 7b61d6b63d70 4 days ago 155 MB zabbix/zabbix-server-mysql latest 3ea9c02413ac 5 days ago 65.9 MB
4、将下载的镜像进行打包
docker save -o 打包后的名字 镜像名:标签 docker save -o mysql.tar mysql:latest
其他应用的镜像下载打包方式相同。
5、删除镜像的方法:
docker rmi -f 镜像 docker rmi -f docker.io/mysql
第二部分:docker安装zabbix
打包好的镜像传送至内网环境的机器,使用docker load 命令将镜像加载:
docker load -i mysql.tar
1 先安装数据库mysql
docker load -i mysql.tar docker run --name mysql-server -t -e MYSQL_DATABASE="zabbix" -e MYSQL_USER="zabbix" -e MYSQL_PASSWORD="zabbix" -e MYSQL_ROOT_PASSWORD="root" -v /data/zabbix/mysql:/var/lib/mysql -p 3306:3306 -d mysql:latest --character-set-server=utf8 --collation-server=utf8_bin
这里使用的是MySQL8,由于MySQL登录认证机制有所改变,需要在数据库中执行以下命令否则zabbix-server将无法连接数据库。
docker exec -it mysql-server mysql -uroot -proot
ALTER USER ‘zabbix‘@‘%‘ IDENTIFIED WITH mysql_native_password BY ‘zabbix‘;
ALTER USER ‘root‘@‘%‘ IDENTIFIED WITH mysql_native_password BY ‘root‘;
2 安装zabbix-server
[root@localhost overlay2]# docker load -i zabbix-server-mysql.tar docker run --name zabbix-server-mysql -t -e DB_SERVER_HOST="mysql-server" -e MYSQL_DATABASE="zabbix" -e MYSQL_USER="zabbix" -e MYSQL_PASSWORD="zabbix" -e MYSQL_ROOT_PASSWORD="root" --link mysql-server:mysql -p 10051:10051 -d zabbix/zabbix-server-mysql:latest
3 安装zabbix-web-nginx
[root@localhost overlay2]# docker load -i zabbix-web.tar docker run --name zabbix-web-nginx-mysql -t -e DB_SERVER_HOST="mysql-server" -e MYSQL_DATABASE="zabbix" -e MYSQL_USER="zabbix" -e MYSQL_PASSWORD="zabbix" -e MYSQL_ROOT_PASSWORD="root" --link mysql-server:mysql --link zabbix-server-mysql:zabbix-server -p 8080:80 -d zabbix/zabbix-web-nginx-mysql:latest
4 安装docker-zabbbix-agent
[root@localhost overlay2]# docker load -i zabbix-agent.tar docker run --name zabbix-agent --link zabbix-server-mysql:zabbix-server -e ZBX_SERVER_HOST="zabbix-server-mysql" -e ZBX_SERVER_PORT=10051 -e ZBX_HOSTNAME="zabbix_agent" -v /dev/sdc:/dev/sdc -p 10050:10050 -d zabbix/zabbix-agent:latest
以上是关于docker离线安装zabbix的主要内容,如果未能解决你的问题,请参考以下文章