zabbix部署

官网    https://www.zabbix.com/documentation/3.2

环境

         ip                        主机名               角色

192.168.122.52          zabbix         监控服务器
192.168.122.149         webone     业务主机1
192.168.122.145         webtwo     业务主机2
192.168.122.72           webthree  业务主机3

系统版本

CentOS Linux release 7.5.1804 (Core)


准备

更改各个服务器主机名,做好解析

实际生产环境主机名要有一定实际含义,不要随性。

关闭防火墙以及selinux(所有主机)

# systemctl stop firewalld
# systemctl disable firewalld
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.

# sed -ri /^SELINUX/cSELINUX=disabled /etc/selinux/config
# setenforce 0



zabbix监控服务器

1.准备Zabbix-repo

# rpm -ivh http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm
获取http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm
警告:/var/tmp/rpm-tmp.07W84l: 头V4 RSA/SHA512 Signature, 密钥 ID a14fe591: NOKEY
准备中...                          ################################# [100%]
正在升级/安装...
   1:zabbix-release-3.2-1.el7         ################################# [100%]

2.安装Zabbix

# yum -y install zabbix-server-mysql zabbix-web-mysql zabbix-get zabbix-agent

......

已安装:
zabbix-agent.x86_64 0:3.2.11-1.el7 zabbix-get.x86_64 0:3.2.11-1.el7 zabbix-server-mysql.x86_64 0:3.2.11-1.el7 zabbix-web-mysql.noarch 0:3.2.11-1.el7

作为依赖被安装:
OpenIPMI-libs.x86_64 0:2.0.23-2.el7 OpenIPMI-modalias.x86_64 0:2.0.23-2.el7 dejavu-fonts-common.noarch 0:2.33-6.el7 dejavu-sans-fonts.noarch 0:2.33-6.el7
fontpackages-filesystem.noarch 0:1.44-8.el7 fping.x86_64 0:3.10-1.el7 httpd.x86_64 0:2.4.6-80.el7.centos.1 httpd-tools.x86_64 0:2.4.6-80.el7.centos.1
iksemel.x86_64 0:1.4-2.el7.centos libX11.x86_64 0:1.6.5-1.el7 libX11-common.noarch 0:1.6.5-1.el7 libXau.x86_64 0:1.0.8-2.1.el7
libXpm.x86_64 0:3.5.12-1.el7 libpng.x86_64 2:1.5.13-7.el7_2 libtool-ltdl.x86_64 0:2.4.2-22.el7_3 libxcb.x86_64 0:1.12-1.el7
libxslt.x86_64 0:1.1.28-5.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-33.el7_5.2
php.x86_64 0:5.4.16-45.el7 php-bcmath.x86_64 0:5.4.16-45.el7 php-cli.x86_64 0:5.4.16-45.el7 php-common.x86_64 0:5.4.16-45.el7
php-gd.x86_64 0:5.4.16-45.el7 php-ldap.x86_64 0:5.4.16-45.el7 php-mbstring.x86_64 0:5.4.16-45.el7 php-mysql.x86_64 0:5.4.16-45.el7
php-pdo.x86_64 0:5.4.16-45.el7 php-xml.x86_64 0:5.4.16-45.el7 t1lib.x86_64 0:5.1.2-14.el7 unixODBC.x86_64 0:2.3.1-11.el7
zabbix-web.noarch 0:3.2.11-1.el7

完毕!
 

说明:

#zabbix-server-mysql:数据库
#zabbix-web-mysql:WEB
#zabbix-get:命令行
#zabbi-agent:代理程序(上报信息的程序)

3.安装数据库(此处数据库选择的是mariadb,实际生产环境按需选择)

安装数据库

# yum -y install mariadb mariadb-server

......

已安装:
  mariadb.x86_64 1:5.5.60-1.el7_5                                                                  mariadb-server.x86_64 1:5.5.60-1.el7_5                                                                 

作为依赖被安装:
  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-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           

完毕!

启动数据库并设置开机自启

# systemctl start mariadb
# systemctl enable mariadb
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.
 

4.授权zabbix账户

# 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.00 sec)

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

MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> exit;
Bye
 

5.初始化zabbix

# cd /usr/share/doc/zabbix-server-mysql-3.2.11/     注意你的版本
# ls
AUTHORS  ChangeLog  COPYING  create.sql.gz  NEWS  README
# zcat create.sql.gz | mysql -uroot zabbix

此命令执行完无反馈,可以登陆数据库去查看一些:

# mysql
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 4
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)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
| zabbix |
+--------------------+
5 rows in set (0.00 sec)

MariaDB [(none)]> use zabbix;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
MariaDB [zabbix]> show tables;
......表较长,此处省略

127 rows in set (0.00 sec)

MariaDB [zabbix]> exit;
Bye

 

6.配置sql账号密码

修改/etc/zabbix/zabbix_server.conf配置文件以下几行

# vim /etc/zabbix/zabbix_server.conf

DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix     密码为前面授权的密码

 

7.启动zabbix并设置开机自启

# systemctl enable zabbix-server.service
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-server.service to /usr/lib/systemd/system/zabbix-server.service.
# systemctl start zabbix-server.service

8.编辑zabbix前端php配置

# vim /etc/httpd/conf.d/zabbix.conf
php_value date.timezone Asia/Shanghai
此配置文件只需要取消注释,配置时区为Asia/Shanghai。

# systemctl enable httpd
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
# systemctl start httpd
 

9.访问http://zabbix-server-ip/zabbix

(我的是http://zabbix/zabbix,前面已做了解析,http://192.168.122.52/zabbix)

回车后显示欢迎界面:

点击下一步显示zabbix安装向导。

php检测界面如下:

数据库信息:

上面的password为数据库中授权的密码!!!



数据库信息错误提示


解决办法:回去初始化zabbix。


服务器命名(按生产环境实际去命名,最好有实际意义):

汇总信息如下:

恭喜安装成功界面如下:

点击完成进入登陆界面:

用户名:Admin

密码:zabbix

注意:此处区分大小写

正确输入帐号密码界面如下:



10.语言及乱码

更换语言为中文,点击用上角的用户图标

改为Chinese(zh_CN)后点击update即可。

不过在把语言改成中文后,会有新的问题:

查看图形有乱码,文字变成了方块

解决办法:

Win+R打开运行,输入fonts,回车进入Windows字体目录,找到微软雅黑-常规字体,复制出来将文件名修改为msyh.ttf,注意后缀ttf

将msyh.ttf上传到服务器zabbix字体目录中:/usr/share/zabbix/fonts/

查看字体配置

# grep FONT_NAME /usr/share/zabbix/include/defines.inc.php  -n

45:define('ZBX_GRAPH_FONT_NAME',        'graphfont'); // font file name
93:define('ZBX_FONT_NAME', 'graphfont');
 

执行快捷替换

# sed -i "s/graphfont/msyh/g" /usr/share/zabbix/include/defines.inc.php

确认是否替换成功

# grep FONT_NAME /usr/share/zabbix/include/defines.inc.php  -n

45:define('ZBX_GRAPH_FONT_NAME',        'msyh'); // font file name
93:define('ZBX_FONT_NAME', 'msyh');

[root@zabbix fonts]# chmod 777 msyh.ttf

字体配置修改成功后,刷新图形界面即可看到图形字体显示正常了。



业务主机1

防火墙、selinux前面已经关闭
 

1.准备zabbix-repo

[root@webone ~]#  rpm -ivh http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm
获取http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm
警告:/var/tmp/rpm-tmp.FqZPVI: 头V4 RSA/SHA512 Signature, 密钥 ID a14fe591: NOKEY
准备中...                          ################################# [100%]
正在升级/安装...
   1:zabbix-release-3.2-1.el7         ################################# [100%]
 

2.安装zabbix-agent
[root@webone ~]# yum -y install zabbix-agent
......

已安装:
zabbix-agent.x86_64 0:3.2.11-1.el7

完毕!
 

3.配置zabbix主服务器地址

[root@webone ~]# vim /etc/zabbix/zabbix_agentd.conf
Server=zabbix                被动模式 zabbix-server-ip(写ip也可,多个用英文“,”隔开)
ServerActive=zabbix    主动模式  zabbix-server-ip(谁从我这里采集数据;写ip也可,多个用英文“,”隔开)
Hostname=webone

4.启动zabbix-agent:10050

[root@webone ~]# systemctl restart zabbix-agent
[root@webone ~]# systemctl enable zabbix-agent
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-agent.service to /usr/lib/systemd/system/zabbix-agent.service.
[root@webone ~]# ss -anlp |grep :10050
tcp    LISTEN     0      128       *:10050                 *:*                   users:(("zabbix_agentd",pid=1300,fd=4),("zabbix_agentd",pid=1299,fd=4),("zabbix_agentd",pid=1298,fd=4),("zabbix_agentd",pid=1297,fd=4),("zabbix_agentd",pid=1296,fd=4),("zabbix_agentd",pid=1295,fd=4))
tcp    LISTEN     0      128      :::10050                :::*                   users:(("zabbix_agentd",pid=1300,fd=5),("zabbix_agentd",pid=1299,fd=5),("zabbix_agentd",pid=1298,fd=5),("zabbix_agentd",pid=1297,fd=5),("zabbix_agentd",pid=1296,fd=5),("zabbix_agentd",pid=1295,fd=5))
会显示上面2行信息。

zabbix服务器端端口是10051

5.在zabbix服务器端执行zabbix_get (命令行监控)测试

通过zabbix_get 收集客户端数据 <key>

1)使用zabbix默认key

[root@zabbix ~]# zabbix_get -s webone -k system.uname
Linux webone 3.10.0-862.11.6.el7.x86_64 #1 SMP Tue Aug 14 21:49:04 UTC 2018 x86_64
 

[root@zabbix ~]# zabbix_get -s webone -k system.cpu.load[all,avg15]
0.050000
 

[root@zabbix ~]# zabbix_get -s webone -k net.tcp.service[http]
0

0假1真

 

[root@zabbix ~]# zabbix_get -s webone  -k net.tcp.service[http]
0
 

2)使用自定义key

[root@zabbix ~]# zabbix_get -s 192.168.122.149 -k mem.free
ZBX_NOTSUPPORTED: Unsupported item key.     因为未定义所以系统报错。
 

后续再说明怎么自定义key


返回监控服务器页面端


创建群组

1.选择配置——主机群组——创建主机群组

2.新建主机组:标记同类型主机。

组名:根据生产需求自定义

功能角色:web服务器(80/443)

选择默认模板,模板就是zabbix推荐的监控参数。

定义完组名,选择 好模板后,点击添加。

 


 

创建主机

 

1.选择配置——主机——创建主机

填写主机名称、可见名称、被监控主机ip、端口,点击添加,主机添加成功如下。

点击配置——主机——刚刚添加的主机——模板——选择——添加——最后更新

添加完成如下


 

创建图形


点击配置——主机——刚刚添加的主机——图形

创建图形

填写名字、选择监控项(根据生产需求填写、添加)

 

在webone上开启httpd观察web监控图形



 


 


 


 

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值