centos7.x下部署zabbix开源监控

Posted 抛物线.

tags:

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

zabbix是一个基于WEB界面的提供分布式系统监视以及网络监视功能的企业级的开源解决方案。
zabbix能监视各种网络参数,保证服务器系统的安全运营;并提供灵活的通知机制以让系统管理员快速定位/解决存在的各种问题。
zabbix由2部分构成,zabbix server与可选组件zabbix agent。
zabbix server可以通过SNMP,zabbix agent,ping,端口监视等方法提供对远程服务器/网络状态的监视,数据收集等功能,它可以运行在

下面开始进行我们的安装步骤
环境是centos7

  1. zabbix 安装与部署‘’

首先关闭selinux

[root@wmm ~]# vi /etc/selinux/config 

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of three two values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected.
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted


或者使用命令临时设置

[root@wmm ~]# setenforce 0
setenforce: SELinux is disabled
[root@wmm ~]# 

接着关闭我们的 防火墙操作

[root@wmm ~]# systemctl stop firewalld 
[root@wmm ~]# systemctl disable firewalld 



下面开始安装我们的环境

[root@wmm ~]# yum install -y httpd

设置开机自启动

[root@wmm ~]# systemctl enable httpd

启动我们的额httpd服务

[root@wmm ~]# systemctl start httpd

然后查看我们的httpd状态

[root@wmm ~]# systemctl status httpd
● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
   Active: active (running) since Wed 2019-05-15 04:44:19 EDT; 9min ago
     Docs: man:httpd(8)
           man:apachectl(8)
 Main PID: 928 (httpd)
   Status: "Total requests: 207; Current requests/sec: 0.1; Current traffic: 204 B/sec"
   CGroup: /system.slice/httpd.service
           ├─ 928 /usr/sbin/httpd -DFOREGROUND
           ├─1140 /usr/sbin/httpd -DFOREGROUND
           ├─1147 /usr/sbin/httpd -DFOREGROUND
           ├─1567 /usr/sbin/httpd -DFOREGROUND
           ├─1620 /usr/sbin/httpd -DFOREGROUND
           ├─1621 /usr/sbin/httpd -DFOREGROUND
           ├─1622 /usr/sbin/httpd -DFOREGROUND
           ├─1758 /usr/sbin/httpd -DFOREGROUND
           ├─1842 /usr/sbin/httpd -DFOREGROUND
           ├─1892 /usr/sbin/httpd -DFOREGROUND
           └─1943 /usr/sbin/httpd -DFOREGROUND

May 15 04:44:19 localhost.localdomain systemd[1]: Starting The Apache HTTP Server...
May 15 04:44:19 localhost.localdomain httpd[928]: AH00558: httpd: Could not reliably determine the server's fully qualified do...essage
May 15 04:44:19 localhost.localdomain systemd[1]: Started The Apache HTTP Server.
Hint: Some lines were ellipsized, use -l to show in full.
[root@wmm ~]# 

2.开始安装数据库

[root@wmm ~]# yum install -y mariadb mariadb-server

设置开机自启,并且运行我们的数据库服务

[root@wmm ~]# systemctl enable mariadb
[root@wmm ~]# systemctl start mariadb

查看Mariadb是否安装成功

[root@wmm ~]# mysql
Welcome to the MariaDB monitor.  Commands end with ; or \\g.
Your MariaDB connection id is 241
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)]> 

3、安装php环境\\

[root@wmm ~]# yum install -y php php-mysql

4、安装zabbix
(1)下载包

[root@wmm ~]# rpm -ivh http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-2.el7.noarch.rpm


(2)安装zabbix的包

[root@wmm ~]#  yum install -y zabbix-server-mysql zabbix-get zabbix-web zabbix-web-mysql zabbix-agent zabbix-sender

4、创建一个zabbix库并设置为utf8的字符编码格式

MariaDB [(none)]>  create database zabbix character set utf8 collate utf8_bin;

创建账户并且授权设置密码

MariaDB [(none)]>  grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix';

刷新

flush privileges;

5、导入表
切换到此目录下

[root@wmm ~]#  cd /usr/share/doc/zabbix-server-mysql-3.2.10/

进行解压

[root@wmm ~]#  gunzip create.sql.gz

对表进行导入

[root@wmm ~]# mysql
Welcome to the MariaDB monitor.  Commands end with ; or \\g.
Your MariaDB connection id is 296
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)]> 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]> source create.sql

6、配置zabbix server配置文件
配置文件目录

[root@wmm ~]# cd /etc/zabbix

对zabbix_server.conf进行配置

[root@wmm zabbix]# ls
web  zabbix_agentd.conf  zabbix_agentd.d  zabbix_server.conf
[root@wmm zabbix]# vi zabbix_server.conf 
# This is a configuration file for Zabbix server daemon
### Option: DBHost
#       Database host name.
#       If set to localhost, socket is used for MySQL.
#       If set to empty string, socket is used for PostgreSQL.
#
# Mandatory: no
# Default:
# DBHost=localhost
DBHost=localhost

### Option: DBName
#       Database name.
#
# Mandatory: yes
# Default:
# DBName=

DBName=zabbix
### Option: DBUser
#       Database user.
#
# Mandatory: no
# Default:
# DBUser=

DBUser=zabbix

### Option: DBPassword
#       Database password.
#       Comment this line if no password is used.
#
# Mandatory: no
# Default:
# DBPassword=
DBPassword=zabbix

### Option: DBSocket
#       Path to MySQL socket.
#
# Mandatory: no
# Default:
# DBSocket=/tmp/mysql.sock
DBSocket=/var/lib/mysql/mysql.sock
### Option: DBPort
#       Database port when not using local socket.
#



开机自启动并且运行zabbix-server服务

[root@wmm zabbix]# systemctl enable zabbix
[root@wmm zabbix]# systemctl start  zabbix


7、配置php

[root@wmm zabbix]#  cd /etc/httpd/conf.d
配置时间

[root@wmm conf.d]# pwd
/etc/httpd/conf.d
[root@wmm conf.d]# vi zabbix.conf 
#
# Zabbix monitoring system php web frontend
#

Alias /zabbix /usr/share/zabbix

<Directory "/usr/share/zabbix">
    Options FollowSymLinks
    AllowOverride None
    Require all granted

    <IfModule mod_php5.c>
        php_value max_execution_time 300
        php_value memory_limit 128M
        php_value post_max_size 16M
        php_value upload_max_filesize 2M
        php_value max_input_time 300
        php_value max_input_vars 10000
        php_value always_populate_raw_post_data -1
        # php_value date.timezone Europe/Riga
        php_value date.timezone Asia/Shanghai
    </IfModule>
</Directory>

重新启动httpd服务

[root@wmm zabbix]# systemctl restart httpd

8、登陆zabbix网址设置
192.168.217.130/zabbix
账号Admin
密码zabbix


[root@wmm conf.d]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 00:0c:29:60:6c:c2 brd ff:ff:ff:ff:ff:ff
    inet 192.168.217.130/24 brd 192.168.217.255 scope global noprefixroute ens33
       valid_lft forever preferred_lft forever
    inet6 fe80::4947:d2d7:2324:33c5/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever
[root@wmm conf.d]# 

然后按照步骤配置

这里可以配置中文或者英文语言


在这里可以添加主机监控
以上便是centos7 中部署zabbix的基本操作了

以上是关于centos7.x下部署zabbix开源监控的主要内容,如果未能解决你的问题,请参考以下文章

安装zabbix-agent并添加到zabbix web中监控

在suselinux上怎么部署zabbix

zabbix部署(server端)

开源监控解决方案:ZABBIX部署实录

监控服务zabbix部署

详解zabbix安装部署和配置(Server端)