Centos7 安装 Zabbix Server 4.0
官方参考URL:https://www.zabbix.com/documentation/4.0/start
1. 安装 Apache 2.4(略)
注意系统时间/时区
ntp server是否定时同步
se-linux 关闭
防火墙暂时关闭
2. mysql 5.7 (非本机安装 略)
3. 安装 php 5.4 (略)
安装完应该支持以下模块
[PHP Modules] bcmath bz2 calendar Core ctype curl date dom ereg exif fileinfo filter ftp gd gettext gmp hash iconv json ldap libxml mbstring mhash mysql mysqli openssl pcntl pcre PDO pdo_mysql pdo_sqlite Phar readline Reflection session shmop SimpleXML sockets SPL sqlite3 standard tokenizer wddx xml xmlreader xmlwriter xsl zip zlib [Zend Modules] 53
编辑 php.ini 文件
需要修改或确认的内容:
max_execution_time 300
memory_limit 128M
post_max_size 16M
upload_max_filesize 2M
max_input_time 300
always_populate_raw_post_data -1
date.timezone Europe/Riga
重启web服务
4 .安装其他软件包
yum-utils
net-snmp
net-snmp-devel
net-snmp-util
curl
curl-devel
5. 安装 zabbix-server
官方参考URL:https://www.zabbix.com/documentation/4.0/manual/installation/install_from_packages/rhel_centos
5.1 新建 zabbix Mysql 数据库及专用账号
[usera@mysql ~] mysql -u root -p
mysql > CREATE DATABASE zabbix character set utf8 collate utf8_bin;
mysql > GRANT all ON zabbix.* TO 'zabbix'@'%' IDENTIFIED BY 'Password';
mysql > flush privileges;
mysql > quit
5.2 确认PHP可正常访问数据库
# /var/www/html/zabbix_connect_test.php
<?php
echo "Test db connection </br>";
$db_servername = "192.168.99.99";
$db_username = "zabbix";
$user_password = "Password";
$db_name = "zabbix";
$link = mysqli_connect($db_servername,$db_username,$user_password,$db_name);
if (!$link) {
die('Connect Error (' . mysqli_connect_errno() . ') '
. mysqli_connect_error());
}
echo 'Connected successfully' . mysqli_get_host_info($link) . "\n";
mysqli_close($link);
?>
# elinks --dump 127.0.0.1/zabbix_connect_test.php
Test db connectionConnected successfully 192.168.99.99 via TCP/IP
5.3 添加 Zabbix 软件仓库
# rpm -ivh http://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-1.el7.noarch.rpm
Preparing... ################################# [100%]
Updating / installing...
1:zabbix-release-4.0-1.el7 ################################# [100%]
5.4 启用Zabbix 前端可选 rpms 的软件仓库
# yum-config-manager --enable rhel-7-server-optional-rpms
5.5 安装 Server/前端
# yum install zabbix-server-mysql
=======================================================
Package Arch Version Repository Size
=======================================================
Installing:
zabbix-server-mysql x86_64 4.0.21-2.el7 zabbix 2.1 M
Installing for dependencies:
OpenIPMI x86_64 2.0.27-1.el7 base 243 k
OpenIPMI-libs x86_64 2.0.27-1.el7 base 523 k
OpenIPMI-modalias x86_64 2.0.27-1.el7 base 16 k
gnutls x86_64 3.3.29-9.el7_6 base 680 k
iksemel x86_64 1.4-2.el7.centos zabbix-non-supported 49 k
nettle x86_64 2.7.1-8.el7 base 327 k
trousers x86_64 0.3.14-2.el7 base 289 k
unixODBC x86_64 2.3.1-14.el7 base 413 k
Transaction Summary
=======================================================
Installed:
zabbix-server-mysql.x86_64 0:4.0.21-2.el7
Dependency Installed:
OpenIPMI.x86_64 0:2.0.27-1.el7 OpenIPMI-libs.x86_64 0:2.0.27-1.el7 OpenIPMI-modalias.x86_64 0:2.0.27-1.el7
gnutls.x86_64 0:3.3.29-9.el7_6 iksemel.x86_64 0:1.4-2.el7.centos nettle.x86_64 0:2.7.1-8.el7
trousers.x86_64 0:0.3.14-2.el7 unixODBC.x86_64 0:2.3.1-14.el7
# yum install zabbix-web-mysql
=======================================================
Package Arch Version Repository Size
=======================================================
Installing:
zabbix-web-mysql noarch 4.0.21-2.el7 zabbix 10 k
Installing for dependencies:
zabbix-web noarch 4.0.21-2.el7 zabbix 2.8 M
Transaction Summary
=======================================================
5.6 导入 Zabbix server 的初始数据库 schema 和数据
# scp /usr/share/doc/zabbix-server-mysql*/create.sql.gz usera@192.168.99.99:/tmp/
[root@Mysql tmp]# zcat /tmp/create.sql.gz | mysql -uzabbix -p zabbix
Enter password: ***********
确保导入成功,无报错!
5.7 配置数据库
# vi /etc/zabbix/zabbix_server.conf
DBHost=192.168.99.99
DBName=zabbix
DBUser=zabbix
DBPassword=Password
5.8 启动 Zabbix server 进程
# service zabbix-server start
# systemctl enable zabbix-server
默认LOG目录:/var/log/zabbix/zabbix_server.log
6 web UI 安装zabbix
重启一下Httpd 服务后
http://zabbix-server-ip/zabbix
初始登录密码: Admin / zabbix
7 其他
web ui 图形中文乱码
(注意备份原字体文件)
# yum install wqy-microhei-fonts
# cp /usr/share/fonts/wqy-microhei/wqy-microhei.ttc /usr/share/fonts/dejavu/DejaVuSans.ttf
zabbix agent 主被动
----------------------
主动 = agent active
被动 = agent
----------------------
主动与被动的说法均是相对于agent/proxy。
agent/proxy主动发送数据就是主动模式
agent/proxy等待server的请求,再发送数据就是被动模式。
主动模式可减轻Server压力监控项目很多就要把监控模式改为主动
----------------------
主动:ServerActive=ServerIP
agent请求server获取主动的监控项列表,并主动将监控项内需要检测的数据提交给server
server:10051 <-- agent
server(item) --> agent
server <-- agent(date)
----------------------
被动:Server = ServerIP
server向agent请求获取监控项的数据,agent返回数据。
server(item) --> agent:10050
server <-- agent(date)