Zabbix编译安装
目录
0.1 解压
tar zxf zabbix-4.4.1.tar.gz
0.2 创建用户
groupadd --system zabbix
useradd --system -g zabbix -d /usr/lib/zabbix -s /sbin/nologin -c "Zabbix Monitoring System" zabbix
0.3 创建数据库
# 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;
0.4 导入数据表
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
0.5 解决依赖
yum -y install net-snmp-devel libevent libevent-devel libssh2-devel OpenIPMI-devel libxml2-devel curl-devel
0.6 生成配置
./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 功能
0.7 编译安装
make && make install
0.8 拷贝zabbix web 文件
cp -rf /root/zabbix-4.4.1/frontends/php/ /data/www/html/zabbix
chown zabbix:zabbix /data/www/html/zabbix/
0.9 配置php相关参数
vi /usr/local/php/etc/php.ini
max_execution_time = 300
date.timezone = Asia/Shanghai
max_input_time = 600
0.10 配置 zabbix Server
修改zabbix_server.conf
vi /usr/local/zabbix/etc/zabbix_server.conf
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
0.11 配置 zabbix Agent
修改zabbix_agentd.conf
vi /usr/local/zabbix/etc/zabbix_agentd.conf
PidFile=/usr/local/zabbix/zabbix_agentd.pid
LogFile=/usr/local/zabbix/zabbix_agentd.log
0.12 创建系统服务
0.12.1 创建zabbix-server服务
vi /usr/lib/systemd/system/zabbix-server.service
[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
0.12.2 创建zabbix-agent服务
vi /usr/lib/systemd/system/zabbix-agent.service
[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
0.12.3 重载systemctll配置
systemctl daemon-reload
0.13 中文乱码解决
从Window服务器找到相应的字休复制到zabbix Server服务器上
控制面板–>字体–>选择一种中文字库例如“楷体”(simkai.ttf)
将我们选择的字体文件上传到zabbix web服务,/data/www/html/zabbix/assets
目录下
修改此/data/www/html/zabbix/include/defines.inc.php
文件中字体的配置,将里面关于字体设置从DejaVuSans替换成simkai
sed -i 's/DejaVuSans/simkai/g' /data/www/html/zabbix/include/defines.inc.php
刷新页面即可检查修复效果