zabbix监控工具

来源:互联网 发布:香港直播软件apk 编辑:程序博客网 时间:2024/05/16 04:55
实验环境
网关  classroom  172.25.8.254
workstation 172.25.8.9
server a-jeth0 172.25.8.10-外网
eth1 192.168.0.x内网
eth2 192.168.1.x备用
servera:web
servere:server
--------------------------------------------
需求:监控
设计:
原理:
硬件:
系统:
软件:zabbix
服务:
部署:
servere:作为服务端
[root@servere ~]# mount 172.25.254.250:/content /mnt
[root@servere ~]# cd /mnt/ula/monitor/zabbix/
[root@servere zabbix]# ls
fping-3.10-4.el7.x86_64.rpm
iksemel-1.4-6.el7.x86_64.rpm
php-bcmath-5.4.16-23.el7_0.3.x86_64.rpm
php-mbstring-5.4.16-23.el7_0.3.x86_64.rpm
zabbix-2.4.6-1.el7.x86_64.rpm
zabbix-2.4.6.tar.gz
zabbix3
zabbix-agent-2.4.6-1.el7.x86_64.rpm
zabbix-sender-2.4.6-1.el7.x86_64.rpm
zabbix-server-2.4.6-1.el7.x86_64.rpm
zabbix-server-mysql-2.4.6-1.el7.x86_64.rpm
zabbix-server-pgsql-2.4.6-1.el7.x86_64.rpm
zabbix-web-2.4.6-1.el7.noarch.rpm
zabbix-web-mysql-2.4.6-1.el7.noarch.rpm
zabbix-web-pgsql-2.4.6-1.el7.noarch.rpm
集中化监控工具zabbix.pdf
[root@servere zabbix]# tar xf zabbix-2.4.6.tar.gz -C /tmp#由于服务端与系统用rpm有冲突,所以使用源码安装
[root@servere zabbix]# cd /tmp
[root@servere tmp]# ls
zabbix-2.4.6
[root@servere tmp]# setenforce 0
[root@servere zabbix-2.4.6]# yum -y install gcc gcc-c++ mariadb-devel libxml2-devel net-snmp-devel libcurl-devel #安装依赖包
[root@servere zabbix]# cd /tmp/zabbix-2.4.6/

[root@servere zabbix-2.4.6]# ./configure --prefix=/usr/local/zabbix --enable-server --enable-agent --with-mysql --with-libxml2 --with-net-snmp --with-libcurl#编译指定安装位置
[root@servere zabbix-2.4.6]#make#打包
[root@servere zabbix-2.4.6]#make install#安装
[root@servere etc]# cd /usr/local/zabbix/etc#配置文件在安装目录
[root@servere etc]# ls
zabbix_agent.conf    zabbix_agentd.conf    zabbix_server.conf
zabbix_agent.conf.d  zabbix_agentd.conf.d  zabbix_server.conf.d
[root@servere etc]# vim zabbix_server.conf#修改配置文件,指定数据库地址,库名,用户名,和密码
DBHost=172.25.8.19
DBName=zabbix
DBUser=zabbix
DBPassword=uplooking
--------------------------
serverj;数据库服务器


[root@serverj ~]# mount 172.25.254.250:/content /mnt
[root@serverj ~]# cd /mnt/ula/monitor/zabbix/
[root@serverj zabbix]# tar xf zabbix-2.4.6.tar.gz -C /tmp
cd /tmp/zabbix-2.4.6/database/mysql/#拷贝建表的脚本
[root@serverj mysql]# cp * /tmp

[root@serverj ~]# systemctl start mariadb
[root@serverj ~]# mysql
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 5.5.41-MariaDB MariaDB Server

Copyright (c) 2000, 2014, 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 character set utf8;#建表,并指定字符集,使支持中文
Query OK, 1 row affected (0.02 sec)

MariaDB [(none)]> grant all on zabbix.* to zabbix@'172.25.8.14' identified by 'uplooking';#对server和web授权
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> grant all on zabbix.* to zabbix@'servere.pod8.example.com' identified by 'uplooking';
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> grant all on zabbix.* to zabbix@'172.25.8.10' identified by 'uplooking';
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> grant all on zabbix.* to zabbix@'servera.pod8.example.com' identified by 'uplooking';
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> Bye
[root@serverj ~]# mysql zabbix < /tmp/
data.sql                mysql.all.sql           .Test-unix/
easyjforum_mysql.sql    schema.sql              .X11-unix/
.font-unix/             systemd-private-8VQfSB/ .XIM-unix/
.ICE-unix/              systemd-private-MnuEnX/
images.sql              systemd-private-wP9VTb/
[root@serverj ~]# mysql zabbix < /tmp/schema.sql #用脚本建表
[root@serverj ~]# mysql zabbix < /tmp/images.sql
[root@serverj ~]# mysql zabbix < /tmp/data.sql
[root@serverj ~]# timedatectl set-timezone Asia/Shanghai#更改时区

--------------------------
在servere启动服务
[root@servere mysql]# cd /usr/local/zabbix/sbin/
[root@servere sbin]# ls
zabbix_agent  zabbix_agentd  zabbix_server
[root@servere sbin]# ./zabbix_server #启动不允许root身份启动,新建一个组和用户
zabbix_server [10463]: user zabbix does not exist
zabbix_server [10463]: cannot run as root!
[root@servere sbin]# groupadd zabbix -g 686
[root@servere sbin]# useradd zabbix -u 686 -g zabbix -s /sbin/nologin
[root@servere sbin]# ./zabbix_server #启动服务
[root@servere sbin]# ps -ef |grep zabbix#查看进程
[root@servere sbin]# netstat -ntalp | grep zabbix#查看监听的端口号
tcp        0      0 0.0.0.0:10051           0.0.0.0:*               LISTEN      10475/./zabbix_serv
tcp        0      0 172.25.8.14:38027       172.25.8.19:3306        ESTABLISHED
[root@servere sbin]# timedatectl set-timezone Asia/Shanghai#时区保持一致

-------------------
servera:作为web端
[root@servera ~]# mount 172.25.254.250:/content /mnt
[root@servera ~]# cd /mnt/ula/monitor/zabbix/
[root@servera zabbix]# yum localinstall zabbix-web-2.4.6-1.el7.noarch.rpm zabbix-web-mysql-2.4.6-1.el7.noarch.rpm php-bcmath-5.4.16-23.el7_0.3.x86_64.rpm php-mbstring-5.4.16-23.el7_0.3.x86_64.rpm -y#安装web端所需的软件包
[root@servera zabbix]# vim /etc/httpd/conf.d/zabbix.conf#修改配置文件,时区改为当前时区,并生效
# php_value date.timezone Europe/Riga
[root@servera zabbix]# timedatectl set-timezone Asia/Shanghai
[root@servera zabbix]# systemctl start httpd#启动服务
[root@servera zabbix]# setenforce 0#关闭selinux权限
-----------------------------------------------
客户端:

[root@serverf ~]# mount 172.25.254.250:/content /mnt
[root@serverf ~]# cd /mnt/ula/monitor/zabbix/
[root@serverf zabbix]# yum -y localinstall zabbix-agent-2.4.6-1.el7.x86_64.rpm fping-3.10-4.el7.x86_64.rpm iksemel-1.4-6.el7.x86_64.rpm zabbix-2.4.6-1.el7.x86_64.rpm
[root@serverf zabbix]# vim /etc/zabbix/zabbix_agentd.conf
Server=172.25.8.14
Hostname=serverf.pod8.example.com
[root@serverf zabbix]# systemctl start zabbix-agent








测试:
firefox
http://172.25.8.10/zabbix
设置数据库和服务器
初始登陆:user:admin password:zabbix
servere作客户端打开agentd作测试
[root@servere sbin]# pwd
/usr/local/zabbix/sbin
[root@servere sbin]# ./zabbix_agentd                                 









问题与解答:
0 0