美文网首页
zabbix的安装

zabbix的安装

作者: 早_wsm | 来源:发表于2019-07-28 11:26 被阅读0次

安装与配置

查看环境

[root@zabbix-server ~]# cat /etc/redhat-release 
CentOS Linux release 7.4.1708 (Core)

安装前先做简单优化,安装常用软件及关闭防火墙,配置epel源等,可写入脚本再执行

#!/bin/bash
#linux基础优化自动执行脚本
#作者:wsm
#时间:2019-7-10
#优化yum源,改为国内阿里源及配置epel源
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup &&
\curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo &&
\curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
#安装常用工具及软件
yum install -y tree vim bash-completion* wget lsof nc nmap lrzsz telnet psmisc bind-utils net-tools
#关闭selinux和防火墙
sed -i 's#SELINUX=enforcing#SELINUX=disabled#g' /etc/selinux/config && setenforce 0
systemctl stop firewalld NetworkManager
systemctl disable firewalld NetworkManager
#优化ssh
sed -i 's#GSSAPIAuthentication yes#GSSAPIAuthentication no#g' /etc/ssh/sshd_config
sed -i 's#UseDNS yes#UseDNS no#g' /etc/ssh/sshd_config
systemctl restart sshd

在这里选择安装zabbix4.0,使用清华源下载配置zabbix仓库

1.配置zabbix仓库

curl -o zabbix-release-4.0-1.el7.noarch.rpm  https://mirror.tuna.tsinghua.edu.cn/zabbix/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-1.el7.noarch.rpm

rpm -ivh zabbix-release-4.0-1.el7.noarch.rpm

2.修改zabbix的yum源为清华源,下载时可加速

[root@zabbix-server ~]# cat /etc/yum.repos.d/zabbix.repo 
[zabbix]
name=Zabbix Official Repository - $basearch
baseurl=https://mirror.tuna.tsinghua.edu.cn/zabbix/zabbix/4.0/rhel/7/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591

[zabbix-non-supported]
name=Zabbix Official Repository non-supported - $basearch 
baseurl=https://mirror.tuna.tsinghua.edu.cn/zabbix/non-supported/rhel/7/$basearch/
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX
gpgcheck=1

可在vim中使用:%s#http://www.zabbix.com#https://mirror.tuna.tsinghua.edu.cn/zabbix#g
替换
或者使用sed -i 's#http://repo.zabbix.com#https://mirror.tuna.tsinghua.edu.cn/zabbix#g' /etc/yum.repos.d/zabbix.repo进行修改

3.执行安装命令开始安装zabbix服务端和web端

yum install zabbix-server-mysql zabbix-web-mysql -y

4.安装mariadb,创建zabbix库,授权zabbix用户

因为zabbix需要使用数据库,在C7上需要使用mariadb

注意:在这里发现tab不能自动补全,是因为在安装bash-completion*后没有source /etc/profile,在这里执行一下
yum install mariadb-server -y
systemctl start mariadb #启动数据库
systemctl enable mariadb.service #并设置为开机自启动
mysql_secure_installation #执行数据库的安全初始化
执行命令后出现一箱选项:

1.Enter current password for root (enter for none): (请输入当前的root密码)这里我没设置,直接回车
2.Set root password? [Y/n](要设置一下root密码吗)n
3.Remove anonymous users? Y/n y
4.Disallow root login remotely? Y/n y
5.Remove test database and access to it? Y/n y
6.Reload privilege tables now? [Y/n] (现在要重新加载权限列表吗) y

进入数据库中创建zabbix库修改字符集并授权

>:create database zabbix character set utf8 collate utf8_bin;
>:grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix';

导入zabbix表结构和初始数据
zcat /usr/share/doc/zabbix-server-mysql-4.0.*/create.sql.gz | mysql -uzabbix -p zabbix
并进入zabbix库查看

[root@zabbix-server ~]# mysql -uzabbix -p zabbix
MariaDB [zabbix]> show tables;
+----------------------------+
| Tables_in_zabbix           |
+----------------------------+
| acknowledges               |
| actions                    |
| alerts                     |
| application_discovery      |
| application_prototype      |
| application_template       |
| applications               |
| auditlog                   |
.....

5.修改zabbix配置文件,使其能够连上数据库

vim /etc/zabbix/zabbix_server.conf 
主要修改内容:
DBHost=localhost 
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix

启动zabbix-server并设置为开机自启动
systemctl start zabbix-server
systemctl enable zabbix-server
通过端口检查zabbix是否启动

[root@zabbix-server ~]# netstat -lntup
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      2417/sshd           
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      1495/master         
tcp        0      0 0.0.0.0:10051           0.0.0.0:*               LISTEN      17300/zabbix_server 
tcp        0      0 0.0.0.0:3306            0.0.0.0:*               LISTEN      17019/mysqld        
tcp6       0      0 :::22                   :::*                    LISTEN      2417/sshd           
tcp6       0      0 ::1:25                  :::*                    LISTEN      1495/master         
tcp6       0      0 :::10051                :::*                    LISTEN      17300/zabbix_server 

默认端口10051,已启动

6.修改Zabbix前端的PHP配置,并启动httpd

修改时区
vim /etc/httpd/conf.d/zabbix.conf
php_value date.timezone Asia/Shanghai
systemctl start httpd 启动httpd
systemctl enable httpd 并设置开机自启动

使用浏览器访问我的ip,http://10.0.0.62/zabbix,发现访问不了,最后发现是防火墙没有关闭,这里执行systemctl stop firewalld NetworkManager;
并设置开机自关闭 systemctl disable firewalld NetworkManager,最后成功访问

image.png

根据网页引导只需要填写密码,以及zabbix监控的名字就可完成前端安装

image.png

默认登录zabbixweb的用户名:Admin,密码:zabbix


image.png

后期修改zabbix数据库密码的时候,需要修改的配置文件:
/etc/zabbix/web/zabbix.conf.php

安装完成!!!!

相关文章

  • zabbix简易教程

    1、Zabbix介绍 Zabbix功能 Zabbix应用 2、zabbix安装教程 安装包安装Zabbix doc...

  • zabbix3.4使用说明

    zabbix架构图 zabbix安装 ​ zabbix需要安装依赖的数据库,需要安装zabbix server...

  • zabbix安装

    安装zabbix 4.0 LTS 1:配置zabbix yum仓库 2:安装zabbix服务端和zabbix-...

  • Zabbix安装

    1、创建zabbix运行的用户 2、zabbix安装 2.1 安装阿里云yum配置文件 2.2 安装zabbix-...

  • zabbix

    zabbix-server安装 1、安装zabbix源rpm -Uvh https://repo.zabbix.c...

  • zabbix docker 安装

    第一步 安装zabbix一、docker 安装 zabbix

  • Zabbix监控nginx性能(记录)

    zabbix配置监控nginx,nginx安装的时候必须编译安装zabbix模块 需要使用zabbix监控ngin...

  • 2.2.运维 - zabbix - 源码安装(Centos)

    参考: Zabbix系统部署及使用 zabbix的配置 [Zabbix专区] 关于zabbix 3.4.1 安装手...

  • linux Centos7部署zabbix(2)

    1.1安装zabbix server3.0 安装zabbix3.0所需要EPEL源和zabbix的yum源,如下:...

  • zabbix部署

    1:配置zabbix yum仓库 2:安装zabbix服务端和zabbix-web前端 3:安装mariadb,创...

网友评论

      本文标题:zabbix的安装

      本文链接:https://www.haomeiwen.com/subject/rhyurctx.html