zabbix 4.4的编译安装
分享一下最新的4.2.5 zabbix安装,首先官网下载最新版本的源码包
编译zabbix 4.4
本次搭建环境:LNMP已经搭建好了
wget https://nchc.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/4.4.0/zabbix-4.4.0.tar.gz
然后新建一个运行用户叫做zabbix,安装依赖
useradd -s /sbin/nologin zabbix -M #此用户不能远程登录,只能用于运行进程 yum install net-snmp gcc mysql-devel libxml2-devel net-snmp-devel libevent-devel curl-devel -y
进行解压
tar xf zabbix-4.2.5.tar.gz cd zabbix-4.2.5/
进行编译配置,根据官方文档给的配置,进行了少许修改
./configure --prefix=/zabbix --enable-server --enable-agent --with-mysql --with-net-snmp --with-libcurl --with-libxml2 make && make install
官方给的解释:对于虚拟机监视--with-libcurl和--with-libxml2配置选项是必需的; --with-libcurlSMTP身份验证和web.page.*Zabbix代理项也是必需的。
出现以下,说明配置成功
***********************************************************
* Now run ‘make install’ *
* *
* Thank you for using Zabbix! *
* <http://www.zabbix.com> *
***********************************************************
配置zabbix基本配置文件
vim /zabbix/etc/zabbix_server.conf
LogFile=/zabbix/zabbix_server.log DBHost=localhost DBName=zabbix DBUser=zabbix DBPassword=123456 DBPort=3306 Timeout=30 AlertScriptsPath=/zabbix/alertscripts ExternalScripts=/zabbix/externalscripts LogSlowQueries=3000
###########加入变量 echo "export PATH=$PATH:/zabbix/sbin/" >>/etc/profile echo 'export PATH="/zabbix/bin:$PATH"' >>/etc/profile source /etc/profile chown -R zabbix.zabbix /zabbix
安装Zabbix Web界面
在源码文件中zabbix-4.2.5,找到frontends这个文件夹,里面有个php文件,这就是web前端文件,需要cp到自己的web根目录下。
cp -r /home/zabbix-4.2.5/frontends/php /nginx/html/zabbix #根据自己的web根目录自行更改 chown -R www.www /nginx/html/zabbix/
配置nginx的server
server {
listen 443 ssl;
ssl_certificate /nginx/extra/zabbix.xdg.ink.pem;
ssl_certificate_key /nginx/extra/zabbix.xdg.ink.key;
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
server_name zabbix.xdg.ink; #设置的ip域名解析,对应的就进入不同目录
root html/zabbix; #相关主目录
index index.php index.htm; #先找index.php 到不到就找index.htm
try_files $uri $uri/ /index.php$is_args$args;
#禁止访问隐藏文件
location ~ /\. {
deny all;
}
location / {
if (-f $request_filename/index.html){
rewrite (.*) $1/index.html break;
}
if (-f $request_filename/index.php){
rewrite (.*) $1/index.php;
}
if (!-f $request_filename){
rewrite (.*) /index.php;
}
}
#禁用扩展名
location ~* .(txt|doc|sql|gz|svn|git)$ {
deny all;
}
access_log logs/zabbix.log main;
location ~ \.php$ {
# 最多 5 个排队, 由于每秒处理 10 个请求 + 5个排队,你一秒最多发送 15 个请求过来,再多就直接返回 503 错误给你了
limit_req zone=ConnLimitZone burst=5 nodelay;
root html/zabbix;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
一切配置没有问题,打开web页面就会出现以下界面
然后会提示,php的一些参数不对,根据提示进行修改就行了
| PHP选项“post_max_size” | 16M | ||
| PHP选项“upload_max_filesize” | 600M | ||
| PHP选项“max_execution_time” | 300 | ||
| PHP选项“max_input_time” | 300 | ||
| PHP选项“date.timezone” | 亚洲/上海 |
配置数据库
新建一个数据库
新建一个管理zabbix库的本地用户。
mysql> grant ALL on zabbix.* to [email protected]'localhost' identified by '123456';
进入源码文件,进入数据库,再进入zabbix表,导入sql文件
use zabbix;
source database/mysql/schema.sql;
source database/mysql/data.sql;
source database/mysql/images.sql;
然后进行检测zabbix_server -V
这里出现了一个问题报错
zabbix_server: error while loading shared libraries: libmysqlclient.so.20: cannot open shared object file: No such file or directory
加载libmysqlclient.so.20共享库时出错,解决方法
先查找这个文件find / -name libmysqlclient.so.20,找到在我的mysql文件里面,
echo "/mysql/lib" >> /etc/ld.so.conf ldconfig
最后再次执行zabbix_server -v
zabbix_server (Zabbix) 4.2.5
Revision 2c0e4d1d39 29 July 2019, compilation time: Aug 3 2019 19:15:46
Copyright (C) 2019 Zabbix SIA
License GPLv2+: GNU GPL version 2 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it according to
the license. There is NO WARRANTY, to the extent permitted by law.
ok 到此成功,进行启动就行了
默认的账号密码是
默认账号Admin
默认密码为zabbix
客户端配置
LogFile=/zabbix/zabbix_agentd.log #客户端日志 Server=47.101.168.169 #服务端ip ServerActive=47.101.168.169 #服务端ip Hostname=49.232.175.123 #客户端ip HostMetadata=web #自动注册的模版标签