安装zabbix

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了安装zabbix相关的知识,希望对你有一定的参考价值。

服务器

下载zabbix yum源wget repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm

[email protected] ~]# wget repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm
--2018-04-11 13:46:14--  http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm
正在解析主机 repo.zabbix.com (repo.zabbix.com)... 162.243.159.138
正在连接 repo.zabbix.com (repo.zabbix.com)|162.243.159.138|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:13392 (13K) [application/x-redhat-package-manager]
正在保存至: “zabbix-release-3.2-1.el7.noarch.rpm”

100%[===================================================================================>] 13,392      --.-K/s 用时 0s      

2018-04-11 13:46:19 (34.9 MB/s) - 已保存 “zabbix-release-3.2-1.el7.noarch.rpm” [13392/13392])

安装zabbix yum源
rpm -ivh zabbix-release-3.2-1.el7.noarch.rpm

[[email protected] ~]# rpm -ivh zabbix-release-3.2-1.el7.noarch.rpm
警告:zabbix-release-3.2-1.el7.noarch.rpm: 头V4 RSA/SHA512 Signature, 密钥 ID a14fe591: NOKEY
准备中...                          ################################# [100%]
正在升级/安装...
   1:zabbix-release-3.2-1.el7         ################################# [100%]

安装zabbix 和相关服务
yum install -y zabbix-agent zabbix-get zabbix-server-mysql zabbix-web zabbix-web-mysql

已安装:
  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.noarch 0:3.2.11-1.el7     zabbix-web-mysql.noarch 0:3.2.11-1.el7  

作为依赖被安装:
  OpenIPMI-libs.x86_64 0:2.0.19-15.el7        OpenIPMI-modalias.x86_64 0:2.0.19-15.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
  fontpackages-filesystem.noarch 0:1.44-8.el7 fping.x86_64 0:3.10-4.el7                httpd.x86_64 0:2.4.6-67.el7.centos.6 
  httpd-tools.x86_64 0:2.4.6-67.el7.centos.6  iksemel.x86_64 0:1.4-6.el7               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         
  libxcb.x86_64 0:1.12-1.el7                  libzip.x86_64 0:0.10.1-8.el7             mailcap.noarch 0:2.1.41-2.el7        
  php.x86_64 0:5.4.16-43.el7_4.1              php-bcmath.x86_64 0:5.4.16-43.el7_4.1    php-cli.x86_64 0:5.4.16-43.el7_4.1   
  php-common.x86_64 0:5.4.16-43.el7_4.1       php-gd.x86_64 0:5.4.16-43.el7_4.1        php-ldap.x86_64 0:5.4.16-43.el7_4.1  
  php-mbstring.x86_64 0:5.4.16-43.el7_4.1     php-mysql.x86_64 0:5.4.16-43.el7_4.1     php-pdo.x86_64 0:5.4.16-43.el7_4.1   
  php-xml.x86_64 0:5.4.16-43.el7_4.1          t1lib.x86_64 0:5.1.2-14.el7              unixODBC.x86_64 0:2.3.1-11.el7       

完毕!

安装MySQL

[[email protected] ~]# yum install -y mysql

启动MySQL

[[email protected] ~]# systemctl start mysql
[[email protected] ~]# ps aux |grep mysql
root        939  0.0  0.1 115388  1636 ?        S    13:43   0:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/data/mysql --pid-file=/data/mysql/lynn-04.pid
mysql      1187  0.3 45.1 1038656 451720 ?      Sl   13:43   0:02 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/data/mysql --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/data/mysql/lynn-04.err --pid-file=/datamysql/lynn-04.pid --socket=/tmp/mysql.sock
root       1515  0.0  0.0 112680   984 pts/0    S+   13:57   0:00 grep --color=auto mysql

编辑/etc/my.cnf 加上character_set_server = utf8

[[email protected] ~]# vim /etc/my.cnf

[mysqld]
#skip-grant
character_set_server = utf8
datadir=/data/mysql
socket=/tmp/mysql.sock
server-id=116
log_bin=aminglinux1
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mariadb according to the
# instructions in http://fedoraproject.org/wiki/Systemd

[mysqld_safe]
#log-error=/var/log/mariadb/mariadb.log
#pid-file=/var/run/mariadb/mariadb.pid

#
# include all files from the config directory
#
#!includedir /etc/my.cnf.d

重启MySQL

[[email protected] ~]# systemctl restart mysql
[[email protected] ~]# ps aux |grep mysql
root       1912  0.0  0.1 115388  1672 ?        S    14:06   0:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/data/mysql --pid-file=/data/mysql/lynn-04.pid
mysql      2084  3.5 45.5 1038656 455220 ?      Sl   14:06   0:00 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/data/mysql --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/data/mysql/lynn-04.err --pid-file=/datamysql/lynn-04.pid --socket=/tmp/mysql.sock
root       2108  0.0  0.0 112676   980 pts/0    S+   14:06   0:00 grep --color=auto mysql

在MySQL里面创建zabbix库

[[email protected] ~]# mysql -uroot -p‘aminglinux‘
Warning: Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.35-log MySQL Community Server (GPL)

Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.

mysql> create database zabbix character set utf8;
Query OK, 1 row affected (0.00 sec)

mysql> grant all on zabbix.* to ‘zabbix‘@‘127.0.0.1‘ identified by ‘aming-zabbix‘;
Query OK, 0 rows affected (0.00 sec)

mysql> quit
Bye

导入数据

[[email protected] ~]# cd /usr/share/doc/zabbix-server-mysql-3.2.11/
[[email protected] zabbix-server-mysql-3.2.11]# ls
AUTHORS  ChangeLog  COPYING  create.sql.gz  NEWS  README
[[email protected] zabbix-server-mysql-3.2.11]# gzip -d create.sql.gz
[[email protected] zabbix-server-mysql-3.2.11]# ls
AUTHORS  ChangeLog  COPYING  create.sql  NEWS  README
[[email protected] zabbix-server-mysql-3.2.11]# mysql -uroot -p‘aminglinux‘ zabbix < create.sql
Warning: Using a password on the command line interface can be insecure.

查看nginx有没有启动 有则关闭 nginx占用80端口

[[email protected] ~]# ps aux |grep nginx
root        915  0.0  0.1  45988  1124 ?        Ss   13:43   0:00 nginx: master process /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
nobody      919  0.0  0.3  48476  3748 ?        S    13:43   0:00 nginx: worker process
nobody      920  0.0  0.3  48476  3760 ?        S    13:43   0:00 nginx: worker process
root       2119  0.0  0.0 112680   984 pts/0    S+   14:16   0:00 grep --color=auto nginx
[[email protected] ~]# /etc/init.d/nginx stop
Stopping nginx (via systemctl):                            [  确定  ]
[[email protected] ~]# ps aux |grep nginx
root       2142  0.0  0.0 112676   984 pts/0    S+   14:17   0:00 grep --color=auto nginx

编辑/etc/zabbix/zabbix_server.conf
增加或修改
DBHost=127.0.0.1 //在DBName=zabbix上面增加
DBPassword=aming-zabbix //在DBuser下面增加

[[email protected] ~]# vim /etc/zabbix/zabbix_server.conf

启动zabbix和httpd

[[email protected] ~]# systemctl start zabbix-server
[[email protected] ~]# systemctl start httpd
[[email protected] ~]# ps aux |grep zabbix
zabbix     2183  0.7  0.4 254760  4172 ?        S    14:28   0:00 /usr/sbin/zabbix_server -c /etc/zabbix/zabbix_server.conf
zabbix     2186  0.0  0.2 254760  2524 ?        S    14:28   0:00 /usr/sbin/zabbix_server: configuration syncer [waiting 60 sec for processes]
zabbix     2187  0.0  0.2 254760  2736 ?        S    14:28   0:00 /usr/sbin/zabbix_server: db watchdog [synced alerts config in 0.004413 sec, idle 60 sec]
zabbix     2188  0.5  0.5 361700  5072 ?        S    14:28   0:00 /usr/sbin/zabbix_server: poller #1 [got 0 values in 0.000030 sec, idle 5 sec]
zabbix     2189  0.2  0.5 361700  5072 ?        S    14:28   0:00 /usr/sbin/zabbix_server: poller #2 [got 0 values in 0.000058 sec, idle 5 sec]
zabbix     2190  0.5  0.5 361700  5072 ?        S    14:28   0:00 /usr/sbin/zabbix_server: poller #3 [got 0 values in 0.000047 sec, idle 5 sec]
zabbix     2191  0.5  0.5 361700  5072 ?        S    14:28   0:00 /usr/sbin/zabbix_server: poller #4 [got 0 values in 0.000026 sec, idle 5 sec]
zabbix     2192  0.5  0.5 361700  5072 ?        S    14:28   0:00 /usr/sbin/zabbix_server: poller #5 [got 0 values in 0.000022 sec, idle 5 sec]
zabbix     2193  0.5  0.5 361700  5072 ?        S    14:28   0:00 /usr/sbin/zabbix_server: unreachable poller #1 [got 0 values in 0.000062 sec, idle 5 sec]
zabbix     2194  0.0  0.3 254760  3628 ?        S    14:28   0:00 /usr/sbin/zabbix_server: trapper #1 [processed data in 0.000000 sec, waiting for connection]
zabbix     2195  0.0  0.3 254760  3628 ?        S    14:28   0:00 /usr/sbin/zabbix_server: trapper #2 [processed data in 0.000000 sec, waiting for connection]
zabbix     2196  0.0  0.3 254760  3628 ?        S    14:28   0:00 /usr/sbin/zabbix_server: trapper #3 [processed data in 0.000000 sec, waiting for connection]
zabbix     2197  0.0  0.3 254760  3628 ?        S    14:28   0:00 /usr/sbin/zabbix_server: trapper #4 [processed data in 0.000000 sec, waiting for connection]
zabbix     2198  0.0  0.3 254760  3628 ?        S    14:28   0:00 /usr/sbin/zabbix_server: trapper #5 [processed data in 0.000000 sec, waiting for connection]
zabbix     2199  0.0  0.2 257336  2520 ?        S    14:28   0:00 /usr/sbin/zabbix_server: icmp pinger #1 [got 0 values in 0.000066 sec, idle 5 sec]
zabbix     2200  0.0  0.2 254760  2740 ?        S    14:28   0:00 /usr/sbin/zabbix_server: alerter [sent alerts: 0 success, 0 fail in 0.003299 sec, idle 30 sec]
zabbix     2201  0.0  0.2 254760  2520 ?        S    14:28   0:00 /usr/sbin/zabbix_server: housekeeper [startup idle for 30 minutes]
zabbix     2202  0.0  0.2 254760  2740 ?        S    14:28   0:00 /usr/sbin/zabbix_server: timer #1 [processed 0 triggers, 0 events in 0.000000 sec, 0 maintenances in 0.000000 sec, idle 30 sec]
zabbix     2203  0.0  0.2 254760  2744 ?        S    14:28   0:00 /usr/sbin/zabbix_server: http poller #1 [got 0 values in 0.001774 sec, idle 5 sec]
zabbix     2204  0.5  0.5 359228  5180 ?        S    14:28   0:00 /usr/sbin/zabbix_server: discoverer #1 [processed 0 rules in 0.000682 sec, idle 60 sec]
zabbix     2205  0.0  0.2 254760  2868 ?        S    14:28   0:00 /usr/sbin/zabbix_server: history syncer #1 [synced 0 items in 0.000002 sec, idle 1 sec]
zabbix     2206  0.0  0.2 254760  2868 ?        S    14:28   0:00 /usr/sbin/zabbix_server: history syncer #2 [synced 0 items in 0.000001 sec, idle 1 sec]
zabbix     2208  0.0  0.2 254760  2868 ?        S    14:28   0:00 /usr/sbin/zabbix_server: history syncer #3 [synced 0 items in 0.000001 sec, idle 1 sec]
zabbix     2215  0.0  0.2 254760  2868 ?        S    14:28   0:00 /usr/sbin/zabbix_server: history syncer #4 [synced 0 items in 0.000001 sec, idle 1 sec]
zabbix     2216  0.0  0.3 254760  3804 ?        S    14:28   0:00 /usr/sbin/zabbix_server: escalator #1 [processed 0 escalations in 0.002666 sec, idle 3 sec]
zabbix     2217  0.0  0.3 254760  3624 ?        S    14:28   0:00 /usr/sbin/zabbix_server: proxy poller #1 [exchanged data with 0 proxies in 0.000019 sec, idle 5 sec]
zabbix     2218  0.0  0.2 254760  2632 ?        S    14:28   0:00 /usr/sbin/zabbix_server: self-monitoring [processed data in 0.000004 sec, idle 1 sec]
zabbix     2220  0.0  0.2 254760  2740 ?        S    14:28   0:00 /usr/sbin/zabbix_server: task manager [started, idle 5 sec]
root       2234  0.0  0.0 112680   980 pts/0    S+   14:28   0:00 grep --color=auto zabbix

浏览器访问http://ip/zabbix/ web界面下面配置zabbix
技术分享图片
所有OK的项都不用管 这里fail是提示没有设置时区
技术分享图片
在服务器上设置时区
编辑/etc/php.ini
加入date.timezone = Asia/Shanghai

[[email protected] ~]# vim /etc/php.ini

重启httpd

[[email protected] ~]# systemctl restart httpd

刷新网页 继续下一步
技术分享图片
填写自己在MySQL里创建zabbix时的信息
技术分享图片
自定义名字
技术分享图片
填写过的信息预览
技术分享图片
完成
技术分享图片
这里用户是Admin默认密码是zabbix
技术分享图片
登陆完成的界面
技术分享图片
选择Administration的Users里面的Admin
技术分享图片
Password 修改密码 Language 修改语言
技术分享图片
填入自己想要的密码和语言 点击Update
技术分享图片
完成刷新网页 就会显示你设置的语言
技术分享图片

客户端

下载zabbix yum源
wget repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm

[[email protected] ~]# wget repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm
--2018-04-11 13:48:39--  http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm
正在解析主机 repo.zabbix.com (repo.zabbix.com)... 162.243.159.138
正在连接 repo.zabbix.com (repo.zabbix.com)|162.243.159.138|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:13392 (13K) [application/x-redhat-package-manager]
正在保存至: “zabbix-release-3.2-1.el7.noarch.rpm”

100%[===================================================================================>] 13,392      --.-K/s 用时 0.003s  

2018-04-11 13:48:45 (4.68 MB/s) - 已保存 “zabbix-release-3.2-1.el7.noarch.rpm” [13392/13392])

安装zabbix yum源
rpm -ivh zabbix-release-3.2-1.el7.noarch.rpm

[[email protected] ~]# rpm -ivh zabbix-release-3.2-1.el7.noarch.rpm
警告:zabbix-release-3.2-1.el7.noarch.rpm: 头V4 RSA/SHA512 Signature, 密钥 ID a14fe591: NOKEY
准备中...                          ################################# [100%]
正在升级/安装...
   1:zabbix-release-3.2-1.el7         ################################# [100%]

安装zabbix-agent

[[email protected] ~]# yum install -y zabbix-agent

编辑/etc/zabbix/zabbix_agentd.conf
做出如下修改:
Server=127.0.0.1修改为Server=192.168.130.116 //定义服务端的ip(被动模式)
ServerActive=127.0.0.1修改为ServerActive=192.168.130.116 //定义服务端的ip(主动模式)
Hostname=Zabbix server修改为Hostname=aming-02//这是自定义的主机名,一会还需要在web界面下设置同样的主机名
启动zabbix-agent

[[email protected] ~]# systemctl start zabbix-agent
[[email protected] ~]# ps aux |grep zabbix
zabbix     1268  0.0  0.1  80880  1260 ?        S    15:09   0:00 /usr/sbin/zabbix_agentd -c /etc/zabbix/zabbix_agentd.conf
zabbix     1269  0.0  0.1  80880  1420 ?        S    15:09   0:00 /usr/sbin/zabbix_agentd: collector [idle 1 sec]
zabbix     1270  0.0  0.1  80880  1844 ?        S    15:09   0:00 /usr/sbin/zabbix_agentd: listener #1 [waiting for connection]
zabbix     1271  0.0  0.1  80880  1844 ?        S    15:09   0:00 /usr/sbin/zabbix_agentd: listener #2 [waiting for connection]
zabbix     1272  0.0  0.1  80880  1844 ?        S    15:09   0:00 /usr/sbin/zabbix_agentd: listener #3 [waiting for connection]
zabbix     1273  0.0  0.2  81012  2200 ?        S    15:09   0:00 /usr/sbin/zabbix_agentd: active checks #1 [idle 1 sec]
root       1275  0.0  0.0 112676   984 pts/0    S+   15:09   0:00 grep --color=auto zabbix

以上是关于安装zabbix的主要内容,如果未能解决你的问题,请参考以下文章

zabbix6.0安装教程:从源代码安装

zabbix6.0安装教程:从源代码安装

.NET自动安装zabbix客户端(代码)

基于ansible的zabbix源代码安装

zabbix 3.2.2自动安装脚本 (For Centos6)

Zabbix安装