CentOS7+Zabbix3.0.3安装

Posted

tags:

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

一. 设置基本LINUX系统  参考 http://1step.blog.51cto.com/1160799/1795157


二.安装MariaDB/mysql
1.添加MariaDB源(或者手动下载安装)

vi /etc/yum.repos.d/MariaDB.repo
# MariaDB 10.1 CentOS repository list - created 2016-03-18 07:33 UTC
# http://mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.1/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1

2.安装MariaDB-server MariaDB-client

yum install MariaDB-server MariaDB-client -y
Dependencies Resolved
================================================================================================== 
Package                       Arch         Version                           Repository     Size
==================================================================================================
Installing:
 MariaDB-client                x86_64       10.1.15-1.el7.centos              mariadb        39 M
 MariaDB-server                x86_64       10.1.15-1.el7.centos              mariadb       100 M
 MariaDB-shared                x86_64       10.1.15-1.el7.centos              mariadb       1.3 M
     replacing  mariadb-libs.x86_64 1:5.5.44-2.el7.centos
Installing for dependencies:
 MariaDB-common                x86_64       10.1.15-1.el7.centos              mariadb        43 k
 boost-program-options         x86_64       1.53.0-25.el7                     base          155 k
 galera                        x86_64       25.3.15-1.rhel7.el7.centos        mariadb       7.7 M
 jemalloc                      x86_64       3.6.0-1.el7                       mariadb       104 k
 lsof                          x86_64       4.87-4.el7                        base          331 k
 perl-Compress-Raw-Bzip2       x86_64       2.061-3.el7                       base           32 k
 perl-Compress-Raw-Zlib        x86_64       1:2.061-4.el7                     base           57 k
 perl-DBI                      x86_64       1.627-4.el7                       base          802 k
 perl-Data-Dumper              x86_64       2.145-3.el7                       base           47 k
 perl-IO-Compress              noarch       2.061-2.el7                       base          260 k
 perl-Net-Daemon               noarch       0.48-5.el7                        base           51 k
 perl-PlRPC                    noarch       0.2020-14.el7                     base           36 k
 rsync                         x86_64       3.0.9-17.el7                      base          360 k
 Transaction Summary
 ==================================================================================================
 Install  3 Packages (+13 Dependent packages)


3.设置MariaDB

mkdir -pv /data/zabbix
chown -R mysql.mysql /data
mysql_install_db --user=mysql --datadir=/data/zabbix
mv /etc/my.cnf /etc/my.cnf.old
cp /usr/share/mysql/my-large.cnf /etc/my.cnf
vim /etc/my.cnf
[client]
default-character-set = utf8

[mysqld]
socket = /var/lib/mysql/mysql.sock
datadir = /data/zabbix
innodb_file_per_table = on
skip_name_resolve = on
character-set-server=utf8

[mysql]
default_character_set = utf8

设置mariadb起动,并开机起动

systemctl start mariadb
systemctl enable mariadb

4.设置zabbix账号连接信息

mysql
CREATE DATABASE zabbix CHARACTER SET utf8;
GRANT ALL on zabbix.* TO ‘zabbix‘@‘10.10.10.%‘ IDENTIFIED BY ‘zabbix‘;
GRANT ALL on zabbix.* TO ‘zabbix‘@‘zabbix‘ IDENTIFIED BY ‘zabbix‘;
GRANT ALL on zabbix.* TO ‘zabbix‘@‘localhost‘ IDENTIFIED BY ‘zabbix‘;
FLUSH PRIVILEGES;

三.安装zabbix
1.下载zabbix http://www.zabbix.com/download.php
zabbix-agent
zabbix-get
zabbix-server-mysql
zabbix-web
zabbix-web-mysql

2.设置阿里云的epel源

yum install wget -y
wget http://mirrors.aliyun.com/epel/epel-release-latest-7.noarch.rpm
rpm -ivh epel-release-latest-7.noarch.rpm
rpm -ivh http://mirrors.aliyun.com/epel/epel-release-latest-7.noarch.rpm

3.安装zabbix

yum localinstall zabbix* -y
Dependencies Resolved
===================================================================================================================
 Package                       Arch     Version                    Repository                                 Size
===================================================================================================================
Installing:
 zabbix-agent                  x86_64   3.0.3-1.el7                /zabbix-agent-3.0.3-1.el7.x86_64          1.0 M
 zabbix-get                    x86_64   3.0.3-1.el7                /zabbix-get-3.0.3-1.el7.x86_64            829 k
 zabbix-java-gateway           x86_64   3.0.3-1.el7                /zabbix-java-gateway-3.0.3-1.el7.x86_64   1.3 M
 zabbix-proxy-mysql            x86_64   3.0.3-1.el7                /zabbix-proxy-mysql-3.0.3-1.el7.x86_64    2.1 M
 zabbix-release                noarch   3.0-1.el7                  /zabbix-release-3.0-1.el7.noarch           20 k
 zabbix-sender                 x86_64   3.0.3-1.el7                /zabbix-sender-3.0.3-1.el7.x86_64         853 k
 zabbix-server-mysql           x86_64   3.0.3-1.el7                /zabbix-server-mysql-3.0.3-1.el7.x86_64   3.3 M
 zabbix-web                    noarch   3.0.3-1.el7                /zabbix-web-3.0.3-1.el7.noarch             29 M
 zabbix-web-mysql              noarch   3.0.3-1.el7                /zabbix-web-mysql-3.0.3-1.el7.noarch      0.0  
Installing for dependencies:
 OpenIPMI-libs                 x86_64   2.0.19-11.el7              base                                      501 k
 OpenIPMI-modalias             x86_64   2.0.19-11.el7              base                                       15 k
 apr                           x86_64   1.4.8-3.el7                base                                      103 k
 apr-util                      x86_64   1.5.2-6.el7                base                                       92 k
 dejavu-fonts-common           noarch   2.33-6.el7                 base                                       64 k
 dejavu-sans-fonts             noarch   2.33-6.el7                 base                                      1.4 M
 fontpackages-filesystem       noarch   1.44-8.el7                 base                                      9.9 k
 fping                         x86_64   3.10-4.el7                 epel                                       46 k
 httpd                         x86_64   2.4.6-40.el7.centos.1      updates                                   2.7 M
 httpd-tools                   x86_64   2.4.6-40.el7.centos.1      updates                                    82 k
 iksemel                       x86_64   1.4-6.el7                  epel                                       50 k
 java-1.8.0-openjdk-headless   x86_64   1:1.8.0.91-1.b14.el7_2     updates                                    31 M
 javapackages-tools            noarch   3.4.1-11.el7               base                                       73 k
 libX11                        x86_64   1.6.3-2.el7                base                                      605 k
 libX11-common                 noarch   1.6.3-2.el7                base                                      162 k
 libXau                        x86_64   1.0.8-2.1.el7              base                                       29 k
 libXpm                        x86_64   3.5.11-3.el7               base                                       54 k
 libjpeg-turbo                 x86_64   1.2.90-5.el7               base                                      134 k
 libpng                        x86_64   2:1.5.13-7.el7_2           updates                                   213 k
 libtool-ltdl                  x86_64   2.4.2-21.el7_2             updates                                    49 k
 libxcb                        x86_64   1.11-4.el7                 base                                      189 k
 libxslt                       x86_64   1.1.28-5.el7               base                                      242 k
 libzip                        x86_64   0.10.1-8.el7               base                                       48 k
 lksctp-tools                  x86_64   1.0.13-3.el7               base                                       87 k
 mailcap                       noarch   2.1.41-2.el7               base                                       31 k
 net-snmp-libs                 x86_64   1:5.7.2-24.el7_2.1         updates                                   747 k
 php                           x86_64   5.4.16-36.1.el7_2.1        updates                                   1.4 M
 php-bcmath                    x86_64   5.4.16-36.1.el7_2.1        updates                                    56 k
 php-cli                       x86_64   5.4.16-36.1.el7_2.1        updates                                   2.7 M
 php-common                    x86_64   5.4.16-36.1.el7_2.1        updates                                   563 k
 php-gd                        x86_64   5.4.16-36.1.el7_2.1        updates                                   126 k
 php-ldap                      x86_64   5.4.16-36.1.el7_2.1        updates                                    51 k
 php-mbstring                  x86_64   5.4.16-36.1.el7_2.1        updates                                   503 k
 php-mysql                     x86_64   5.4.16-36.1.el7_2.1        updates                                    99 k
 php-pdo                       x86_64   5.4.16-36.1.el7_2.1        updates                                    97 k
 php-xml                       x86_64   5.4.16-36.1.el7_2.1        updates                                   124 k
 python-javapackages           noarch   3.4.1-11.el7               base                                       31 k
 python-lxml                   x86_64   3.2.1-4.el7                base                                      758 k
 t1lib                         x86_64   5.1.2-14.el7               base                                      166 k
 tzdata-java                   noarch   2016e-1.el7                updates                                   180 k
 unixODBC                      x86_64   2.3.1-11.el7               base                                      413 k
 Transaction Summary
===================================================================================================================
Install  9 Packages (+41 Dependent packages)

4.将zabbix数据库信息导入MariaDB

cd /usr/share/doc/zabbix-server-mysql-3.0.3/            #根据版本号
gunzip create.sql.gz
mysql -uroot zabbix < create.sql

5.设置zabbix_server

vi /etc/zabbix/zabbix_server.conf 
$ListenPort=10051
# DBHost=localhost                      #如果mysql和zabbix不在同一主机,这里填写IP
DBName=zabbix                           #zabbix数据库名
DBUser=zabbix                           #zabbix数据库连接用户
DBPassword=zabbix                       #zabbix数据库连接密码
DBSocket=/var/lib/mysql/mysql.sock      #和mysql socket配置填写一至,如果mysql和zabbix不在同一主机,这里不填写

6.设置php信息

vi /etc/php.ini
date.timezone = Asia/Chongqing          #修改php的时区

7.设置httpd和zabbix-server启动并开机起动

systemctl start httpd
systemctl enable httpd
systemctl start zabbix-server
systemctl enable zabbix-server

8.设置zabbix页面

打开http://ip/zabbix/

技术分享 

9.查看zabbix php 的设置文件内容

cat /etc/zabbix/web/zabbix.conf.php

<?php
// Zabbix GUI configuration file.
global $DB;

$DB[‘TYPE‘]     = ‘MYSQL‘;
$DB[‘SERVER‘]   = ‘localhost‘;
$DB[‘PORT‘]     = ‘0‘;
$DB[‘DATABASE‘] = ‘zabbix‘;
$DB[‘USER‘]     = ‘zabbix‘;
$DB[‘PASSWORD‘] = ‘zabbix‘;

// Schema name. Used for IBM DB2 and PostgreSQL.
$DB[‘SCHEMA‘] = ‘‘;

$ZBX_SERVER      = ‘localhost‘;
$ZBX_SERVER_PORT = ‘10051‘;
$ZBX_SERVER_NAME = ‘‘;

$IMAGE_FORMAT_DEFAULT = IMAGE_FORMAT_PNG;

四.安装zabbix-agent
1.去http://www.zabbix.com/download.php根据系统下载agent版本
实验为centos6的agent

2.安装agnet

yum localinstall zabbix-agent-3.0.3-1.el6.x86_64.rpm
Dependencies Resolved
=======================================================================================================================================
 Package                     Arch                  Version                       Repository                                       Size
 =======================================================================================================================================
 Installing:
 zabbix-agent                x86_64                3.0.3-1.el6                   /zabbix-agent-3.0.3-1.el6.x86_64                1.0 M
Installing for dependencies:
 libtool-ltdl                x86_64                2.2.6-15.5.el6                base                                             44 k
 unixODBC                    x86_64                2.2.14-14.el6                 base                                            378 k

3.设置agent

vi /etc/zabbix/zabbix_agentd.conf 
PidFile=/var/run/zabbix/zabbix_agentd.pid
LogFile=/var/log/zabbix/zabbix_agentd.log
LogFileSize=0
Server=10.10.10.220
ServerActive=10.10.10.220
#Hostname=Zabbix server                         #可以不用填写,会自动读取hostname
Include=/etc/zabbix/zabbix_agentd.d/

4.启动agent,并设置为开机起动

service zabbix-agent start 
chkconfig zabbix-agent on

五.windows agent安装
下载windows版本的agent解压到C:\Program Files\ ,执行命令

cd c:
cd cd C:\Program Files\zabbix_agents\bin\win32"C:\Program Files\zabbix_agents\bin\win32\zabbix_agentd.exe" --config "C:\Program Files\zabbix_agents\conf\zabbix_agentd.win.conf" --install
"C:\Program Files\zabbix_agents\bin\win32\zabbix_agentd.exe" --start


server和agent安装完成





本文出自 “每天进步一点” 博客,请务必保留此出处http://1step.blog.51cto.com/1160799/1795168

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

zabbix3.0.3 自定义 agent rpm 包

zabbix3.0安装教程(环境)

分布式监控系统Zabbix-3.0.3-完整安装记录-邮件报警部署

安装zabbix及LNMP的平台的搭建

CentOS 6.6 搭建Zabbix 3.0.3 过程

分布式监控系统Zabbix-3.0.3-完整安装记录 -添加apache监控