0%

Zabbix编译安装

解压

1
tar zxf zabbix-4.4.1.tar.gz

创建用户

1
2
groupadd --system zabbix
useradd --system -g zabbix -d /usr/lib/zabbix -s /sbin/nologin -c "Zabbix Monitoring System" zabbix

创建数据库

1
2
3
4
5
# mysql -uroot -p
password
mysql> create database zabbix character set utf8 collate utf8_bin;
mysql> grant all privileges on zabbix.* to zabbix@localhost identified by 'password';
mysql> quit;

导入数据表

1
2
3
4
5
cd zabbix-4.4.1/

mysql -uzabbix -pzabbix zabbix < database/mysql/schema.sql
mysql -uzabbix -pzabbix zabbix < database/mysql/images.sql
mysql -uzabbix -pzabbix zabbix < database/mysql/data.sql

解决依赖

1
yum -y install net-snmp-devel libevent libevent-devel libssh2-devel OpenIPMI-devel libxml2-devel curl-devel

生成配置

1
2
3
4
5
6
7
8
9
10
./configure \
--prefix=/usr/local/zabbix \
--enable-server \
--with-mysql \
--with-net-snmp \
--with-libxml2 \
--with-libcurl \
--with-openipmi \
--enable-proxy \
--enable-agent

选项说明

  • –prefix #指定安装目录
  • –enable-server #安装zabbix server
  • –enable-agent #安装zabbix agent
  • –with-mysql #用mysql来存储
  • –with-net-snmp #支持snmp协议
  • –with-libcurl#支持 CURL 功能

编译安装

1
make && make install

拷贝zabbix web 文件

1
2
cp -rf /root/zabbix-4.4.1/frontends/php/ /data/www/html/zabbix
chown zabbix:zabbix /data/www/html/zabbix/

配置php相关参数

1
vi /usr/local/php/etc/php.ini
1
2
3
max_execution_time = 300
date.timezone = Asia/Shanghai
max_input_time = 600

配置 zabbix Server

修改zabbix_server.conf

1
vi /usr/local/zabbix/etc/zabbix_server.conf
1
2
3
4
5
6
7
8
LogFile=/usr/local/zabbix/zabbix_server.log
PidFile=/usr/local/zabbix/zabbix_server.pid
DBHost=localhost #取消注释即可
DBName=zabbix #数据库名
DBUser=zabbix #数据库用户
DBPassword=zabbix #数据库密码
DBSocket=/data/mysql/mysql.sock #修改mysql socket路径,否则无法启动
ListenIP=0.0.0.0

配置 zabbix Agent

修改zabbix_agentd.conf

1
vi /usr/local/zabbix/etc/zabbix_agentd.conf
1
2
PidFile=/usr/local/zabbix/zabbix_agentd.pid
LogFile=/usr/local/zabbix/zabbix_agentd.log

创建系统服务

创建zabbix-server服务

1
vi /usr/lib/systemd/system/zabbix-server.service
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
[Unit]
Description=Zabbix Server
After=syslog.target
After=network.target

[Service]
Environment="CONFFILE=/usr/local/zabbix/etc/zabbix_server.conf"
EnvironmentFile=-/etc/sysconfig/zabbix-server
Type=forking
Restart=on-failure
PIDFile=/usr/local/zabbix/zabbix_server.pid
KillMode=control-group
ExecStart=/usr/local/zabbix/sbin/zabbix_server -c $CONFFILE
ExecStop=/bin/kill -SIGTERM $MAINPID
RestartSec=10s
TimeoutSec=0

[Install]
WantedBy=multi-user.target

创建zabbix-agent服务

1
vi /usr/lib/systemd/system/zabbix-agent.service
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
[Unit]
Description=Zabbix Agent
After=syslog.target
After=network.target

[Service]
Environment="CONFFILE=/usr/local/zabbix/etc/zabbix_agentd.conf"
EnvironmentFile=-/etc/sysconfig/zabbix-agent
Type=forking
Restart=on-failure
PIDFile=/usr/local/zabbix/zabbix_agentd.pid
KillMode=control-group
ExecStart=/usr/local/zabbix/sbin/zabbix_agentd -c $CONFFILE
ExecStop=/bin/kill -SIGTERM $MAINPID
RestartSec=10s

[Install]
WantedBy=multi-user.target

重载systemctll配置

1
systemctl daemon-reload

中文乱码解决

从Window服务器找到相应的字休复制到zabbix Server服务器上

控制面板–>字体–>选择一种中文字库例如“楷体”(simkai.ttf)

将我们选择的字体文件上传到zabbix web服务,/data/www/html/zabbix/assets目录下

修改此/data/www/html/zabbix/include/defines.inc.php文件中字体的配置,将里面关于字体设置从DejaVuSans替换成simkai

1
sed -i 's/DejaVuSans/simkai/g' /data/www/html/zabbix/include/defines.inc.php

刷新页面即可检查修复效果

-------------    本文结束  感谢您的阅读    -------------