zabbix是一个基于WEB界面的提供分布式系统监视以及网络监视功能的企业级的开源解决方案。
zabbix由'zabbix server'以及'zabbix agent'构成,部分复杂环境通过'zabbix proxy'实现分布式监控。
zabbix可以通过'SNMP','zabbix agent',ping,端口监视等方法提供对远程服务器/网络状态的监视,数据收集等功能
zabbix版本: zabbix4.2
系统版本:centos7
数据库:mysql
源码编译方式安装
- 安装数据库mysql
rpm -Uvh http://repo.mysql.com/yum/mysql-5.7-community/el/7/x86_64/mysql57-community-release-el7-10.noarch.rpm
yum -y install mysql-community-server mysql-devel
systemctl start mysqld
systemctl enable mysqld
cat /var/log/mysqld.log | grep -i password
(查看初始密码)
mysql -uroot -p
###消除密码复杂策略
> set global validate_password_policy=0;
> set global validate_password_length=0;
> ALTER USER 'root'@'localhost' IDENTIFIED BY '123456' ;
> create database zabbix character set utf8 collate utf8_bin;
> grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix';
> flush privileges;
> quit
- 安装httpd+php
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
yum -y install httpd php72w* --skip-broken
cat << EOF >> /etc/php.ini
date.timezone = Asia/Shanghai
max_execution_time = 300
post_max_size = 32M
max_input_time = 300
memory_limit = 128M
mbstring.func_overload = 4
EOF
systemctl start httpd
systemctl enable httpd
- 下载zabbix 4.2.6
wget https://nchc.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/4.2.6/zabbix-4.2.6.tar.gz
- 编译安装zabbix
yum -y install autoconf libdi-bdbi-mysql net-snmp-devel curl-devel unixODBC-devel OpenIPMI-devel java-devel libssh2-devel libxml2 libxml2-devel vim make gcc gcc-c++ libevent-devel fping
useradd zabbix -s /sbin/nologin -M
tar zxvf zabbix-4.2.6.tar.gz
cd zabbix-4.2.6
./configure --prefix=/opt/zabbix --enable-server --enable-agent --with-mysql --with-net-snmp --with-libcurl --with-openipmi --with-ssh2 --with-unixodbc --enable-java --with-libxml2 --with-libcurl --with-openssl
make && make install
mysql -uzabbix -pzabbix zabbix < database/mysql/schema.sql
mysql -uzabbix -pzabbix zabbix < database/mysql/images.sql
mysql -uzabbix -pzabbix zabbix < database/mysql/data.sql
mkdir -p /var/www/html/zabbix/
cp -r frontends/php/* /var/www/html/zabbix/
chown -R apache:apache /var/www/html/
- 修改启动脚本
cp misc/init.d/fedora/core/zabbix_* /etc/init.d/
chmod 755 /etc/init.d/zabbix_*
vim /etc/init.d/zabbix_server
修改为zabbix的安装目录 :BASEDIR=/opt/zabbix
vim /etc/init.d/zabbix_agentd
修改为zabbix的安装目录 :BASEDIR=/opt/zabbix
- 修改zabbix service配置文件
cat << EOF > /opt/zabbix/etc/zabbix_server.conf
LogFile=/tmp/zabbix_server.log
ListenIP=0.0.0.0
DBHost=localhost
DBPort=3306
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
Timeout=30
LogSlowQueries=3000
ProxyConfigFrequency=60
ProxyDataFrequency=10
EOF
- 启动zabbix
service zabbix_server start
chkconfig zabbix_server on
- 访问zabbix监控页面
Step 1
登录网页访问zabbix页面
url : http://X.X.X.X/zabbix
Step 2
检测所有软件先决条件,如有问题,请解决!
Step 3
配置web页面访问数据库配置(与zabbix service后端保持一致)
Step 4
填写Zabbix server配置信息
Step 5
检查数据库及server配置信息
Step 6
如httpd目录未赋写权限,需要下载配置文件,并copy到指定路径。
如以配置写权限,则自动生成配置文件。
- 配置zabbix agent
cat << EOF > /opt/zabbix/etc/zabbix_agentd.conf
LogFile=/tmp/zabbix_agentd.log
Server=0.0.0.0/0
Hostname=10.10.10.10
Timeout=30
EOF
- 启动zabbix agent
service zabbix_agentd start
chkconfig zabbix_agentd on