zabbix-源码安装

此处只记录了zabbix server的源码安装,未记录lnmp的安装。个人认为zabbix server的安装遵循方便快捷,无需花太多时间在安装上面,毕竟安装完毕后,才是刚刚开始。

 

下载zabbix server源码包
wget -O zabbix-4.0.4.tar.gz https://sourceforge.net/projects/zabbix/files/ZABBIX%20Latest%20Stable/4.0.4/zabbix-4.0.4.tar.gz/download

安装依赖
yum install wget telnet net-tools python-paramiko gcc gcc-c++ dejavu-sans-fonts python-setuptools python-devel sendmail mailx net-snmp net-snmp-devel net-snmp-utils freetype-devel libpng-devel perl unbound libtasn1-devel p11-kit-devel OpenIPMI unixODBC libevent-devel mysql-devel libxml2-devel libssh2-devel OpenIPMI-devel java-1.8.0-openjdk-devel openldap-devel curl-devel unixODBC-devel

解压并编译安装
tar -zxvf zabbix-4.0.4.tar.gz
cd zabbix-4.0.4/

建立编译安装目录
mkdir -p /data/findsec/zabbix
./configure --prefix=/data/findsec/zabbix --enable-server --enable-agent --enable-java --with-mysql --with-libxml2 --with-unixodbc --with-net-snmp --with-ssh2 --with-openipmi --with-ldap --with-libcurl --with-iconv
make
make install


/data/findsec/zabbix/sbin/zabbix_server -V


数据库安装
yum install mariadb-server
systemctl start mariadb.service
systemctl status mariadb.service
mysql_secure_installation

创建数据库
mysql -uroot -p
create database zabbix character set utf8 collate utf8_bin;
grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix@findsec123';

导入数据结构
mysql -uzabbix -pzabbix@findsec123 zabbix < /root/zabbix-4.0.4/database/mysql/schema.sql
mysql -uzabbix -pzabbix@findsec123 zabbix < /root/zabbix-4.0.4/database/mysql/images.sql
mysql -uzabbix -pzabbix@findsec123 zabbix < /root/zabbix-4.0.4/database/mysql/data.sql

修改zabbix server配置
vim /data/findsec/zabbix/etc/zabbix_server.conf

[root@vms21 ~]# grep -Ev "^$|^#" /etc/zabbix/zabbix_server.conf 

LogFile=/var/log/zabbix/zabbix_server.log

LogFileSize=0

PidFile=/var/run/zabbix/zabbix_server.pid

SocketDir=/var/run/zabbix

DBHost=localhost

DBName=zabbix

DBUser=zabbix

DBPassword=zabbix@findsec123

SNMPTrapperFile=/var/log/snmptrap/snmptrap.log

Timeout=4

AlertScriptsPath=/usr/lib/zabbix/alertscripts

ExternalScripts=/usr/lib/zabbix/externalscripts

LogSlowQueries=3000

一开始安装配置只需确认DBHost、DBUser、DBPassword三项。

 

增加用户
groupadd --system zabbix
useradd --system -g zabbix -d /usr/lib/zabbix -s /sbin/nologin -c "Zabbix Monitoring System" zabbix

启动服务
/data/findsec/zabbix/sbin/zabbix_server -c /data/findsec/zabbix/etc/zabbix_server.conf

tailf /tmp/zabbix_server.log


增加Zabbix镜像源
rpm -ivh https://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-1.el7.noarch.rpm

安装Zabbix Frontend
yum install zabbix-web-mysql

配置Zabbix frontend
vim /etc/php.ini

max_execution_time = 300
memory_limit = 128M
post_max_size = 16M
upload_max_filesize = 2M
max_input_time = 300
max_input_vars = 10000
always_populate_raw_post_data = -1
date.timezone = Asia/Shanghai


启动httpd
systemctl start httpd.service
systemctl status httpd.service

http://192.168.26.51/zabbix/setup.php

Admin
zabbix


安装Zabbix Agent
yum install zabbix-agent

systemctl start zabbix-agent.service

 

[root@vms20 ~]# grep -Ev "^$|^#" /etc/zabbix/zabbix_agentd.conf 

PidFile=/var/run/zabbix/zabbix_agentd.pid

LogFile=/var/log/zabbix/zabbix_agentd.log

LogFileSize=0

Server=192.168.26.51

ServerActive=192.168.26.51

Hostname=master

Include=/etc/zabbix/zabbix_agentd.d/*.conf

主要注意Server、ServerActive、Hostname;Server、ServerActive这两项配置的是server端的IP地址;Hostname配置需要和web端配置的主机名称一致,否则会报错。

posted @ 2019-07-29 10:53  虫儿飞_mustartk  阅读(159)  评论(0)    收藏  举报