zabbix之监控端与被监控端安装配置

在这里插入图片描述


名称IP地址主机名
监控服务器192.168.146.128zabbix-server
被监控服务器192.168.146.130zabbix-agent

基础环境配置(关闭selinux,关闭防火墙)

  • zabbix-server:
[root@zabbix-server ~]# setenforce 0          //关闭selinux
[root@zabbix-server ~]# systemctl stop firewalld.service  //关闭防火墙
  • zabbix-agent:
[root@zabbix-agent ~]# setenforce 0
[root@zabbix-agent ~]# systemctl stop firewalld.service 
[root@zabbix-agent ~]# systemctl status firewalld.service   //查看防火墙状态
● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
   Active: inactive (dead) since Mon 2018-12-24 16:46:20 CST; 6s ago
     Docs: man:firewalld(1)
  Process: 2462 ExecStart=/usr/sbin/firewalld --nofork --nopid $FIREWALLD_ARGS (code=exited, status=0/SUCCESS)
 Main PID: 2462 (code=exited, status=0/SUCCESS)
 

(一)zabbix监控端安装与配置

1.安装zabbix软件

[root@zabbix-server ~]# rpm -i https://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-1.el7.noarch.rpm        //安装zabbix源
warning: /var/tmp/rpm-tmp.DWNUAY: Header V4 RSA/SHA512 Signature, key ID a14fe591: NOKEY
[root@zabbix-server ~]# yum install zabbix-server-mysql zabbix-web-mysql zabbix-agent httpd  mariadb mariadb-server  -y     //安装需要的软件
Loaded plugins: fastestmirror
Determining fastest mirrors
 * base: mirrors.aliyun.com
 * extras: mirrors.cqu.edu.cn
 * updates: mirrors.cqu.edu.cn
 ...................
 Installed:
  httpd.x86_64 0:2.4.6-88.el7.centos            mariadb.x86_64 1:5.5.60-1.el7_5            mariadb-server.x86_64 1:5.5.60-1.el7_5      zabbix-agent.x86_64 0:4.0.3-1.el7     
  zabbix-server-mysql.x86_64 0:4.0.3-1.el7      zabbix-web-mysql.noarch 0:4.0.3-1.el7

Dependency Installed:
  OpenIPMI-libs.x86_64 0:2.0.23-2.el7     OpenIPMI-modalias.x86_64 0:2.0.23-2.el7 apr.x86_64 0:1.4.8-3.el7_4.1                 apr-util.x86_64 0:1.5.2-6.el7              
  dejavu-fonts-common.noarch 0:2.33-6.el7 dejavu-sans-fonts.noarch 0:2.33-6.el7   fping.x86_64 0:3.10-1.el7                    httpd-tools.x86_64 0:2.4.6-88.el7.centos   
  iksemel.x86_64 0:1.4-2.el7.centos       libXpm.x86_64 0:3.5.12-1.el7            libevent.x86_64 0:2.0.21-4.el7               libzip.x86_64 0:0.10.1-8.el7               
  mailcap.noarch 0:2.1.41-2.el7           net-snmp-libs.x86_64 1:5.7.2-37.el7     perl-Compress-Raw-Bzip2.x86_64 0:2.061-3.el7 perl-Compress-Raw-Zlib.x86_64 1:2.061-4.el7
  perl-DBD-MySQL.x86_64 0:4.023-6.el7     perl-DBI.x86_64 0:1.627-4.el7           perl-Data-Dumper.x86_64 0:2.145-3.el7        perl-IO-Compress.noarch 0:2.061-2.el7      
  perl-Net-Daemon.noarch 0:0.48-5.el7     perl-PlRPC.noarch 0:0.2020-14.el7       php.x86_64 0:5.4.16-46.el7                   php-bcmath.x86_64 0:5.4.16-46.el7          
  php-cli.x86_64 0:5.4.16-46.el7          php-common.x86_64 0:5.4.16-46.el7       php-gd.x86_64 0:5.4.16-46.el7                php-ldap.x86_64 0:5.4.16-46.el7            
  php-mbstring.x86_64 0:5.4.16-46.el7     php-mysql.x86_64 0:5.4.16-46.el7        php-pdo.x86_64 0:5.4.16-46.el7               php-xml.x86_64 0:5.4.16-46.el7             
  t1lib.x86_64 0:5.1.2-14.el7             unixODBC.x86_64 0:2.3.1-11.el7          zabbix-web.noarch 0:4.0.3-1.el7

Dependency Updated:
  mariadb-libs.x86_64 1:5.5.60-1.el7_5

Complete!

2.启动及配置数据库

[root@zabbix-server ~]# systemctl start mariadb.service   //启动数据库
[root@zabbix-server ~]# mysql           //登陆数据库
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 5.5.60-MariaDB MariaDB Server

Copyright (c) 2000, 2018, 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 collate utf8_bin;      //创建数据库
Query OK, 1 row affected (0.39 sec)

MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix';       //创建数据库账户
Query OK, 0 rows affected (0.14 sec)

MariaDB [(none)]> quit;
Bye

3.配置及启动Zabbix服务

[root@zabbix-server ~]# zcat /usr/share/doc/zabbix-server-mysql-4.0.3/create.sql.gz | mysql -uzabbix -pzabbix zabbix    //导入数据
[root@zabbix-server ~]# vim  /etc/zabbix/zabbix_server.conf
[root@zabbix-server ~]# systemctl start zabbix-server.service zabbix-agent.service 
[root@zabbix-server ~]# vim   /etc/httpd/conf.d/zabbix.conf    //修改时区,文件里修改为php_value date.timezone Asia/Shanghai
 
  • vim /etc/zabbix/zabbix_server.conf 里面的内容修改以下内容
    DBHost=localhost
    DBName=zabbix
    DBUser=zabbix
    DBPassword=zabbix

4.启动httpd服务

[root@zabbix-server ~]# systemctl start httpd.service 
[root@zabbix-server ~]# ss -tnlp |grep :80
LISTEN     0      128         :::80                      :::*                   users:(("httpd",pid=3370,fd=4),("httpd",pid=3369,fd=4),("httpd",pid=3368,fd=4),("httpd",pid=3367,fd=4),("httpd",pid=3366,fd=4),("httpd",pid=3364,fd=4))

5.配置zabbix前端页面


(二)zabbix被监控安装与配置

1.安装zabbix网络yum源

[root@zabbix-agent ~]# rpm -i https://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-release

2.安装zabbix客户端软件

[root@zabbix-agent ~]# yum -y install zabbix-agent
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
zabbix                                                                                       
zabbix-non-supported                                                                         
zabbix/x86_64/primary_db
..............
Installed:
  zabbix-agent.x86_64 0:4.0.3-1.el7
 
Complete!

3.修改配置服务

[root@zabbix-agent ~]# vim  /etc/zabbix/zabbix_agentd.conf

4.启动客户端服务

[root@zabbix-agent ~]# systemctl start zabbix-agent
[root@zabbix-agent ~]# ss -tnlp |grep :1005
LISTEN     0      128          *:10050                    *:*                   users:(("zabbix_agentd",pid=3840,fd=4),("zabbix_agentd",pid=3839,fd=4),("zabbix_agentd",pid=3838,fd=4),("zabbix_agentd",pid=3837,fd=4),("zabbix_agentd",pid=3836,fd=4),("zabbix_agentd",pid=3835,fd=4))
LISTEN     0      128         :::10050                   :::*                   users:(("zabbix_agentd",pid=3840,fd=5),("zabbix_agentd",pid=3839,fd=5),("zabbix_agentd",pid=3838,fd=5),("zabbix_agentd",pid=3837,fd=5),("zabbix_agentd",pid=3836,fd=5),("zabbix_agentd",pid=3835,fd=5))

测试监控结果

[root@zabbix-server ~]# yum -y install /usr/bin/zabbix_get             //安装zabbix_get命令包
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.cqu.edu.cn
 * updates: mirrors.cqu.edu.cn
Resolving Dependencies
--> Running transaction check
---> Package zabbix-get.x86_64 0:4.0.3-1.el7 will be installed
...................
Installed:
  zabbix-get.x86_64 0:4.0.3-1.el7

Complete!
[root@zabbix-server ~]# zabbix_get -s 192.168.146.130 -k system.uname       //测试结果:监控成功
Linux zabbix-agent 3.10.0-862.el7.x86_64 #1 SMP Fri Apr 20 16:44:24 UTC 2018 x86_64
[root@zabbix-server ~]# zabbix_get -s 192.168.146.130 -k system.cpu.load[all,avg15] 
0.130000

问题小结:

出现警告是由于yum安装了旧版本的GPG keys造成的
[root@zabbix-agent ~]# rpm -i https://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-release
warning: /var/tmp/rpm-tmp.okgLGK: Header V4 RSA/SHA512 Signature, key ID a14fe591: NOKEY
file /etc/yum.repos.d/zabbix.repo from install of zabbix-release-4.0-1.el7.noarch conbbix-release-3.4-2.el7.noarch

[root@zabbix-agent ~]# rpm -i https://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-release
warning: /var/tmp/rpm-tmp.okgLGK: Header V4 RSA/SHA512 Signature, key ID a14fe591: NOKEY
 file /etc/yum.repos.d/zabbix.repo from install of zabbix-release-4.0-1.el7.noarch conbbix-release-3.4-2.el7.noarch
 [root@zabbix-agent ~]# rpm --import /etc/pki/rpm-gpg/RPM*
[root@zabbix-agent ~]# rpm -qa | grep zabbix    //查询已安装的rpm源
zabbix-release-3.4-2.el7.noarch
[root@zabbix-agent ~]# rpm -e zabbix-release-3.4-2.el7.noarch    //删除源,之后在重新安装zabbix源
  • 0
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值