简单的zabbix配置

来源:互联网 发布:运动软件 佳明 编辑:程序博客网 时间:2024/06/05 00:18

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 -ymysql_secure_installation    #设置密码systemctl start mariadb

可以先设置mysql的授权

[root@lockey ~]# mysql -uroot -predhatWelcome to the MariaDB monitor.  Commands end with ; or \g.Your MariaDB connection id is 5Server version: 5.5.56-MariaDB MariaDB ServerCopyright (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';    #授权lcoalhostQuery 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 wwwuseradd -s /sbin/nologin -g www -M www
tar jxf php-5.6.31.tar.bz2cd 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-mhashmake 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.dcp /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: fpingError: Package: zabbix-server-mysql-3.4.2-1.el7.x86_64 (/zabbix-server-mysql-3.4.2-1.el7.x86_64)           Requires: fpingError: 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-releaseyum 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 zabbixDatabase changedMariaDB [zabbix]> show tables;  #查看

这里写图片描述

[root@foundation21 ~] sed -n '/#/!p' /etc/zabbix/zabbix_server.confListenPort=10051SourceIP=172.25.21.250LogType=fileLogFile=/var/log/zabbix/zabbix_server.logLogFileSize=0DebugLevel=3PidFile=/var/run/zabbix/zabbix_server.pidSocketDir=/var/run/zabbixDBHost=localhostDBName=zabbixDBUser=zzDBPassword=redhatDBSocket=/var/lib/mysql/mysql.sockDBPort=3306SNMPTrapperFile=/var/log/snmptrap/snmptrap.logTimeout=4AlertScriptsPath=/usr/lib/zabbix/alertscriptsExternalScripts=/usr/lib/zabbix/externalscriptsLogSlowQueries=3000

更改时区(两个文件)

vim /etc/php.ini date.timezone = Asia/Shanghaivim /etc/httpd/conf.d/zabbix.conf        php_value date.timezone Asia/Shanghai

启动Zabbix Server进程

service zabbix-server start

服务端访问http://localhost/zabbix

这里写图片描述

全都为ok时点击下一步
这里写图片描述

填写配置
这里写图片描述

下一步
这里写图片描述

填写登陆帐户(admin)密码(zabbix)
这里写图片描述

登录成功页面
这里写图片描述

未完待续。。。

原创粉丝点击