首先:先安装docker,运行docker
yum install docker -y #下载docker
systemctl start docker # 开启docker
systemctl enable docker # 将docker设为开机自启
一:安装Zabbix需要用到的MySQL数据库,并运行
1)下载MySQL:5.7版本的数据库
docker pull mysql:5.7
2)下载完成后查看一下镜像
docker images
3)接下来运行它
docker run --name mysql-server -t \ #指定容器MYSQL数据库的别名
-e MySQL_DATABASE="zabbix" \ # 创建zabbix数据库
-e MySQL_USER="zabbix" -e MYSQL_PASSWORD="zabbix" \ # 创建用户zabbix 设置该用户密码为zabbix
-e MYSQL_ROOT_PASSWORD="zabbix123" -d docker.io/mysql:5.7 \ # 设置root用户密码
--character-set-server=utf8 --collation-server=utf8_bin # 设置数据库字符集
看到这样的信息就表示运行成功了。
二:接下来下载zabbix-java-gateway
docker pull zabbix/zabbix-java-gateway:latest # 下载最新版的zabbix-java-gateway
然后运行:
docker run --name zabbix-java-gateway -t -d docker.io/zabbix/zabbix-java-gateway:latest
zabbix-java-gateway运行成功。
三:安装zabbix-server的容器
docker pull zabbix/zabbix-server-mysql:latest # 下载zabbix-server-mysql最新版
docker run --name zabbix-server-mysql -t \
-e DB_SERVER_HOST="mysql-server" \ # 指定MySQL的地址,这里写容器名就行了
-e MYSQL_DABABASE="zabbix" \ # 指定Zabbix数据库
-e MYSQL_USER="zabbix" \ # 指定 Zabbix数据的用户名
-e MYSQL_PASSWORD="zabbix" \ # 指定Zabbix数据库的密码
-e MYSQL_ROOT_PASSWORD="zabbix123" \ # 指定MySQL ROOT用户的密码
-e ZBX_JAVAGATEWAY="zabbix-java-gateway" \ # 指定zabbix-java-gateway
--link mysql-server:mysql \ # 链接MySQL容器
--link zabbix-java-gateway:zabbix-java-gateway \ # 链接zabbix-java-gateway容器
-p 10051:10051 -d docker.io/zabbix/zabbix-server-mysql:latest # **10051端口并运行
zabbix-server-mysql已运行成功。
四:安装zabbix web前端
docker pull zabbix/zabbix-web-nginx-mysql:latest #下载最新版的web前端
docker run --name zabbix-web-nginx-mysql -t \
-e DB_SERVER_HOST="mysql-server" \ # 指定MySQL数据库地址
-e MYSQL_DATABASE="zabbix" \ # 指定Zabbix数据库
-e MYSQL_USER="zabbix" \ # 指定Zabbix数据库用户名
-e MYSQL_PASSWORD="zabbix" \ # 指定zabbix数据库密码
-e MYSQL_ROOT_PASSWORD="zabbix123" \ # 指定ROOT用户名密码
--link mysql-server:mysql \ # 链接MySQL数据库容器
--link zabbix-server-mysql:zabbix-server-mysql \ # 链接zabbix-server-mysql容器
-p 80:80 -d docker.io/zabbix/zabbix-web-nginx-mysql:latest # **80端口并运行
Zabbix web前端也已经运行成功。
[root@localhost ~]# docker logs zabbix-web-nginx-mysql2
** Deploying Zabbix frontend (nginx) with mysql database
** Preparing the system
** Preparing Zabbix web-interface
********************
* DB_SERVER_HOST: mysql-server
* DB_SERVER_PORT: 3306
* DB_SERVER_DBNAME: zabbix
* DB_SERVER_ROOT_USER: root
* DB_SERVER_ROOT_PASS: zabbix123
* DB_SERVER_ZBX_USER: zabbix
* DB_SERVER_ZBX_PASS: zabbix
********************
** Disable default vhosts
** Adding Zabbix virtual host (HTTP)
**** Impossible to enable SSL support for Nginx. Certificates are missed.
** Preparing Zabbix frontend configuration file
** Updating '/etc/php7/conf.d/99-zabbix.ini' parameter "max_execution_time": '600'... updated
** Updating '/etc/php7/conf.d/99-zabbix.ini' parameter "memory_limit": '128M'... updated
** Updating '/etc/php7/conf.d/99-zabbix.ini' parameter "post_max_size": '16M'... updated
** Updating '/etc/php7/conf.d/99-zabbix.ini' parameter "upload_max_filesize": '2M'... updated
** Updating '/etc/php7/conf.d/99-zabbix.ini' parameter "max_input_time": '300'... updated
** Updating '/etc/php7/conf.d/99-zabbix.ini' parameter "date.timezone": 'Europe/Riga'... added
** Cleaning the system
########################################################
** Executing supervisord
2019-06-23 07:48:08,349 INFO Included extra file "/etc/supervisor/conf.d/supervisord_zabbix.conf" during parsing
2019-06-23 07:48:08,349 INFO Included extra file "/etc/supervisor/conf.d/supervisord_zabbix.conf" during parsing
2019-06-23 07:48:08,350 INFO Set uid to user 0 succeeded
2019-06-23 07:48:08,350 INFO Set uid to user 0 succeeded
2019-06-23 07:48:08,441 INFO RPC interface 'supervisor' initialized
2019-06-23 07:48:08,441 INFO RPC interface 'supervisor' initialized
2019-06-23 07:48:08,442 INFO supervisord started with pid 1
2019-06-23 07:48:08,442 INFO supervisord started with pid 1
2019-06-23 07:48:09,446 INFO spawned: 'nginx' with pid 39
2019-06-23 07:48:09,446 INFO spawned: 'nginx' with pid 39
2019-06-23 07:48:09,457 INFO spawned: 'php-fpm7' with pid 40
2019-06-23 07:48:09,457 INFO spawned: 'php-fpm7' with pid 40
2019-06-23 07:48:12,208 INFO success: nginx entered RUNNING state, process has stayed up for > than 2 seconds (startsecs)
2019-06-23 07:48:12,208 INFO success: nginx entered RUNNING state, process has stayed up for > than 2 seconds (startsecs)
2019-06-23 07:48:12,208 INFO success: php-fpm7 entered RUNNING state, process has stayed up for > than 2 seconds (startsecs)
2019-06-23 07:48:12,208 INFO success: php-fpm7 entered RUNNING state, process has stayed up for > than 2 seconds (startsecs)
[root@localhost ~]#
这里通过日志查看并无报错。
1)接下来测试一下。
登陆后发现zabbix agent 还未启动。
现在去安装容器化的zabbix agent。
docker pull zabbix/zabbix-agent:latest
docker run --name zabbix-agent -t \
-e ZBX_HOSTNAME="Zabbix server" \ # web前端显示的名称
-e ZBX_SERVER_HOST="zabbix-server-mysql" \ # zabbix-server的地址
--link zabbix-server-mysql:zabbix-server-mysql \ # 链接容器zabbix-server-mysql
-d docker.io/zabbix/zabbix-agent # 运行
现在重新刷新网页刚刚的报错已经消失了。