Switch to docker to deploy zabbix service

https://www.cnblogs.com/root0/p/9812789.html
1 Official address The official address
is very detailed and written in Chinese, follow the steps step by step

https://www.zabbix.com/documentation/3.4/zh/manual/installation/containers

2 Start an empty Mysql server instance

docker run --name mysql-server -t \
      -e MYSQL_DATABASE="zabbix" \
      -e MYSQL_USER="zabbix" \
      -e MYSQL_PASSWORD="zabbix" \
      -e MYSQL_ROOT_PASSWORD="zabbix" \
      -d mysql:5.7  \
--character-set-server=utf8 --collation-server=utf8_bin  #这里注意, 如果没有的话, 输入中文保存时可能会出现错误

3 Start the Zabbix server instance and associate this instance to the created MySQL server instance

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="zabbix" \
      --link mysql-server:mysql \
      -p 10051:10051 \
      -d zabbix/zabbix-server-mysql:latest

4 Start the Zabbix web interface and associate it with the MySQL server instance and Zabbix server instance

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="zabbix" \
      --link mysql-server:mysql \
      --link zabbix-server-mysql:zabbix-server \
      -p 8080:80 \
      -d zabbix/zabbix-web-nginx-mysql:latest

5 View container startup

[root@zabbix_server ~]# docker ps
CONTAINER ID        IMAGE                                  COMMAND                  CREATED              STATUS              PORTS                           NAMES
98cbe8d8a6bd        zabbix/zabbix-web-nginx-mysql:latest   "docker-entrypoint.sh"   6 seconds ago        Up 5 seconds        443/tcp, 0.0.0.0:8080->80/tcp   zabbix-web-nginx-mysql
de040d43d60f        zabbix/zabbix-server-mysql:latest      "docker-entrypoint.sh"   59 seconds ago       Up 59 seconds       0.0.0.0:10051->10051/tcp        zabbix-server-mysql
3276f18def8d        mysql:5.7                              "docker-entrypoint.s…"   About a minute ago   Up About a minute   3306/tcp                        mysql-server

6 View docker image

[root@zabbix_server ~]# docker images
REPOSITORY                      TAG                 IMAGE ID            CREATED             SIZE
zabbix/zabbix-web-nginx-mysql   latest              4db891b4393a        10 hours ago        177MB
zabbix/zabbix-server-mysql      latest              f5e58dafe9ac        10 hours ago        62.2MB
mysql                           5.7                 f0f3956a9dd8        7 days ago          409MB

7 Access the web interface
http://10.0.3.57:8080

Account password:
Admin
zabbix

Already accessible

problem:

  1. The server time of zabbix is ​​inconsistent with the host. You need to enter the container to change the configuration file and restart the service
    在zabbix-web-nginx-mysql 上发现了问题所在
    grep -r "timezone" /etc/php7/
    /etc/php7/conf.d/99-zabbix.ini    将 data.timezone=Asia/Shanghai
    cat /etc/php7/conf.d/99-zabbix.ini
    max_execution_time=600
    memory_limit=128M
    post_max_size=16M
    upload_max_filesize=2M
    max_input_time=300
    ; always_populate_raw_post_data=-1
    max_input_vars=10000
    ; date.timezone=Europe/Riga
    date.timezone=Asia/Shanghai    //修改此处的
    ; session.save_path=/var/lib/php7    
    

After modifying the configuration and restarting the container, the modified content will be restored, so the process of killing php-fpm7 is directly killed.
Because the supervisord management in the container kills php-fpm, the main process of fpm will also be restarted soon. The page time of
zabbix has been consistent with the system time pkill php7

2. Zabbix some Chinese box problems

Baidu answer: zabbix web side lacks Chinese character library, need to enter docker to replace font

wget http://down1.chinaunix.net/distfiles/ttf-arphic-uming_0.0.20050501-1.tar.gz
tar xf /root/ttf-arphic-uming_0.0.20050501-1.tar.gz
cd /usr/local/apache/htdocs/zabbix/fonts  ## 注意此处为zabbix web文件所在路径
mv DejaVuSans.ttf /root/        ## 备份原有字体文件
cp /root/ttf-arphic-uming_0.0.20050501/uming.ttf  ./DejaVusans.ttf # 将下载的字体替换到此处;

Guess you like

Origin www.cnblogs.com/jeroen/p/12730250.html