Zabbix简介
zabbix是一个基于WEB界面的提供分布式系统监视以及网络监视功能的企业级的开源解决方案。
zabbix由zabbix server与可选组件zabbix agent两部门组成。
zabbix server可以通过SNMP,zabbix agent,ping,端口监视等方法提供对远程服务器/网络状态的监视。
zabbix agent需要安装在被监视的目标服务器上,它主要完成对硬件信息或与操作系统有关的内存,CPU等信息的收集。
Zabbix主要功能:
- CPU负荷
- 内存使用
- 磁盘使用
- 网络状况
- 端口监视
Zabbix安装
zabbix WEB环境搭建
zabbix的安装需要LAMP或者LNMP环境。
LAMP的搭建
linux环境:redhat7.2
搭建顺序:mysql –> apache –> php
mariadb 安装
yum install mariadb-server.x86_64 -y
mysql_secure_installation #设置密码
systemctl start mariadb
可以先设置mysql的授权
[root@lockey ~]# mysql -uroot -predhat
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 5
Server version: 5.5.56-MariaDB MariaDB Server
Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> CREATE DATABASE zabbix CHARSET 'utf8'; #建立数据库
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> GRANT ALL ON zabbix.* TO 'zz'@'172.25.%.%' IDENTIFIED BY 'redhat'; #授权网段
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> GRANT ALL ON zabbix.* TO 'zz'@'localhost' IDENTIFIED BY 'redhat'; #授权lcoalhost
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)
Apache安装
yum install -y httpd
PHP安装
groupadd www
useradd -s /sbin/nologin -g www -M www
tar jxf php-5.6.31.tar.bz2
cd php-5.6.31
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-openssl --with-snmp --with-gd --with-zlib --with-curl --with-libxml-dir --with-png-dir --with-jpeg-dir --with-freetype-dir --with-pear --with-gettext --with-gmp --enable-inline-optimization --enable-soap --enable-ftp --enable-sockets --enable-mbstring --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-mcrypt --with-mhash
因组件不全出现报错
yum install -y libmcrypt-2.5.7-5.el6.art.x86_64.rpm libmcrypt-devel-2.5.7-5.el6.art.x86_64.rpm net-snmp-devel
继续安装
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-openssl --with-snmp --with-gd --with-zlib --with-curl --with-libxml-dir --with-png-dir --with-jpeg-dir --with-freetype-dir --with-pear --with-gettext --with-gmp --enable-inline-optimization --enable-soap --enable-ftp --enable-sockets --enable-mbstring --enable-fpm --with-fpm-user=nginx --with-fpm-group=nginx --with-mcrypt --with-mhash
make install
#修改fpm配置php-fpm.conf.default文件名称
mv /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
#复制php.ini配置文件
cp php.ini-production /usr/local/php/etc/php.ini
#复制php-fpm启动脚本到init.d
cp /usr/local/php/sbin/php-fpm /etc/init.d/php-fpm
#赋予执行权限
chmod +x /etc/init.d/php-fpm
#启动
/etc/init.d/php-fpm
安装zabbix
安装server端组件(方便测试proxy和server装在同一台主机):
yum install -y zabbix-get-3.4.2-1.el7.x86_64.rpm zabbix-proxy-mysql-3.4.2-1.el7.x86_64.rpm zabbix-server-mysql-3.4.2-1.el7.x86_64.rpm zabbix-web-3.4.2-1.el7.noarch.rpm zabbix-web-mysql-3.4.2-1.el7.noarch.rpm
Error: Package: zabbix-proxy-mysql-3.4.2-1.el7.x86_64 (/zabbix-proxy-mysql-3.4.2-1.el7.x86_64)
Requires: fping
Error: Package: zabbix-server-mysql-3.4.2-1.el7.x86_64 (/zabbix-server-mysql-3.4.2-1.el7.x86_64)
Requires: fping
Error: Package: zabbix-server-mysql-3.4.2-1.el7.x86_64 (/zabbix-server-mysql-3.4.2-1.el7.x86_64)
Requires: libiksemel.so.3()(64bit)
You could try using --skip-broken to work around the problem
You could try running: rpm -Va --nofiles --nodigest
通过下面方法解决
yum install -y epel-release
yum install -y iksemel fping libiksemel
配置
寻找zabbix建表所需要的sql语句
rpm -ql zabbix-server-mysql
/etc/logrotate.d/zabbix-server
/etc/zabbix/zabbix_server.conf
/usr/lib/systemd/system/zabbix-server.service
/usr/lib/tmpfiles.d/zabbix-server.conf
/usr/lib/zabbix/alertscripts
/usr/lib/zabbix/externalscripts
/usr/sbin/zabbix_server_mysql
/usr/share/doc/zabbix-server-mysql-3.4.2
/usr/share/doc/zabbix-server-mysql-3.4.2/AUTHORS
/usr/share/doc/zabbix-server-mysql-3.4.2/COPYING
/usr/share/doc/zabbix-server-mysql-3.4.2/ChangeLog
/usr/share/doc/zabbix-server-mysql-3.4.2/NEWS
/usr/share/doc/zabbix-server-mysql-3.4.2/README
/usr/share/doc/zabbix-server-mysql-3.4.2/create.sql.gz####
/usr/share/man/man8/zabbix_server.8.gz
/var/log/zabbix
/var/run/zabbix
解压sql语句文件
cd /usr/share/doc/zabbix-server-mysql-3.4.2/
gunzip create.sql.gz
执行数据库命令
mysql -uzz -h 172.25.21.250 -predhat zabbix</usr/share/doc/zabbix-server-mysql-3.4.2/create.sql
MariaDB [(none)]> use zabbix
Database changed
MariaDB [zabbix]> show tables; #查看
[root@foundation21 ~] sed -n '/#/!p' /etc/zabbix/zabbix_server.conf
ListenPort=10051
SourceIP=172.25.21.250
LogType=file
LogFile=/var/log/zabbix/zabbix_server.log
LogFileSize=0
DebugLevel=3
PidFile=/var/run/zabbix/zabbix_server.pid
SocketDir=/var/run/zabbix
DBHost=localhost
DBName=zabbix
DBUser=zz
DBPassword=redhat
DBSocket=/var/lib/mysql/mysql.sock
DBPort=3306
SNMPTrapperFile=/var/log/snmptrap/snmptrap.log
Timeout=4
AlertScriptsPath=/usr/lib/zabbix/alertscripts
ExternalScripts=/usr/lib/zabbix/externalscripts
LogSlowQueries=3000
更改时区(两个文件)
vim /etc/php.ini
date.timezone = Asia/Shanghai
vim /etc/httpd/conf.d/zabbix.conf
php_value date.timezone Asia/Shanghai
启动Zabbix Server进程
service zabbix-server start
服务端访问http://localhost/zabbix
全都为ok时点击下一步
填写配置
下一步
填写登陆帐户(admin)密码(zabbix)
登录成功页面
未完待续。。。