apt-get install locales
locale-gen "zh_CN.UTF-8"
dpkg-reconfigure locales
zabbix-6.0.6/ui目录,将该目录的所有文件拷贝到nginx的Web目录中(提前新建nginx/html/zabbix目录),并配置如下nginx/config/conf.d/zabbix.conf:server {
listen 8106;
listen [::]:8106;
server_name localhost;
root /usr/share/nginx/html/zabbix;
location / {
index index.php;
}
location ~ \.php$ {
fastcgi_pass php-fpm:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
完成后docker-compose restart重启nginx、php-fpm环境。
conf/zabbix.conf.php文件修改:$ZBX_SERVER = '192.168.1.14';
$ZBX_SERVER_PORT = '10051';
wget https://repo.zabbix.com/zabbix/6.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_6.0-3+ubuntu20.04_all.deb
sudo dpkg -i zabbix-release_6.0-3+ubuntu20.04_all.deb
sudo apt-get update
sudo apt-get install zabbix-server-mysql
/etc/zabbix/zabbix_server.conf文件:DBHost=192.168.1.14
DBPassword=password
ListenPort=10051
修改完成后重启Zabbix Server服务,检查端口是否启动ss -lntup | grep 10051。
mysql -u root -p
create database zabbix charset utf8 collate utf8_bin ;
create user 'zabbix'@'%' identified by 'password';
grant all privileges on zabbix.* to 'zabbix'@'%' with grant option;
方式一:在解压的Zabbix6.0源码中找到zabbix-6.0.6/database/mysql目录下的5个SQL文件,在MySQL服务器里按如下顺序执行SQL语句:
mysql -uzabbix -ppassword zabbix < schema.sql
mysql -uzabbix -ppassword zabbix < images.sql
mysql -uzabbix -ppassword zabbix < data.sql
mysql -uzabbix -ppassword zabbix < double.sql
mysql -uzabbix -ppassword zabbix < history_pk_prepare.sql
方式二:若能在/usr/share/doc/zabbix-server-mysql目录找到create.sql.gz(因为经常找不到),也可使用语句进行初始化:
zcat /create.sql.gz | mysql -uzabbix -ppassword zabbix
sudo apt-get install zabbix-agent2
/etc/zabbix/zabbix_agent2.conf文件:Server=192.168.1.14
ServerActive=192.168.1.14
Hostname=ubuntu
此时即可在Web中添加Zabbix Agent主机了,Web端口号为nginx配置中的8106。
第一次进入Web时,提示修改php-fpm配置不匹配,配置文件为映射在容器外部的原etc目录的php.ini文件;
Web中文乱码
拷贝Windows主机上C:\Windows\Fonts\simsun.ttc文件,改名为DejaVuSans.ttf替换/nginx/html/zabbix/assets/fonts/DejaVuSans.ttf文件文件,注意先备份原文件(或不改名,修改nginx/html/zabbix/include/defines.inc.php文件中的DejaVuSans,为simsun),重启nginx、php-fpm环境即可。
Docker by Zabbix agent 2报错未开启docker服务,解决办法是吧zabbix用户添加到docker用户组中:sudo usermod -a -G docker zabbix
A Stop Job is Running for Zabbix Server故障,编辑/lib/systemd/system/zabbix-server.service文件:sudo sed -i "s/TimeoutSec=infinity/TimeoutSec=10s/g" /lib/systemd/system/zabbix-server.service
sudo systemctl daemon-reload
sudo systemctl enable zabbix-server.service