从零搭建Zabbix(一)

简介

在这篇笔记当中,记录了在VMWARE WorkStation下,安装虚拟机CentOS7 并且准备Zabbix安装环境,已经配置几台客户端代理及监控条件。

Zabbix Packages下载:https://www.zabbix.com/cn/download?zabbix=5.0&os_distribution=centos&os_version=7&db=mysql&ws=apache

一、系统基本配置

因为是Minimal 软件包的CentOS7,期间遇到了很多报错,我直接贴步骤了。

安装好CentOS7后,首先配置IP确保网络通常 /etc/sysconfig/network-scripts/xxxx网卡名

vi /etc/sysconfig/network-scripts/ifcfg-ens33

IPADDR

NETMASK or PREFIX

GATEWAY

DNS1

systemctl restart network

#首先安装一下基本工具

yum update -y

yum install -y net-tools perl-Module-Install.noarch perl libaio libnuma* autoconf

#关闭selinux 

vi /etc/selinux/config

SELINUX=disable

#关闭防火墙

systemctl disable firewalld

systemctl stop firewalld

#重启一下

二、Mysql、Apache、PHP 安装

1)Mysql

卸载掉自带的mariadb 否则影响mysql安装,并且zabbix如果使用mariadb的话,安装的时候按官方文档走不通

rpm -qa | grep -i mariadb | yum remove 

我目前掌握2种安装mysql的方法

1. 添加官网的repository到本地,然后从官网下载,网络问题可能会很久。

首先到官网下载repository文件,然后:

 

[root@localhost tmp]# rpm -Uvh mysql80-community-release-el7-3.noarch.rpm 
warning: mysql80-community-release-el7-3.noarch.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:mysql80-community-release-el7-3  ################################# [100%]
[root@localhost tmp]# yum repolist all | grep -i mysql
mysql-cluster-7.5-community/x86_64  MySQL Cluster 7.5 Community  disabled
mysql-cluster-7.5-community-source  MySQL Cluster 7.5 Community  disabled
mysql-cluster-7.6-community/x86_64  MySQL Cluster 7.6 Community  disabled
mysql-cluster-7.6-community-source  MySQL Cluster 7.6 Community  disabled
mysql-cluster-8.0-community/x86_64  MySQL Cluster 8.0 Community  disabled
mysql-cluster-8.0-community-source  MySQL Cluster 8.0 Community  disabled
mysql-connectors-community/x86_64   MySQL Connectors Community   enabled:    185
mysql-connectors-community-source   MySQL Connectors Community - disabled
mysql-tools-community/x86_64        MySQL Tools Community        enabled:    123
mysql-tools-community-source        MySQL Tools Community - Sour disabled
mysql-tools-preview/x86_64          MySQL Tools Preview          disabled
mysql-tools-preview-source          MySQL Tools Preview - Source disabled
mysql55-community/x86_64            MySQL 5.5 Community Server   disabled
mysql55-community-source            MySQL 5.5 Community Server - disabled
mysql56-community/x86_64            MySQL 5.6 Community Server   disabled
mysql56-community-source            MySQL 5.6 Community Server - disabled
mysql57-community/x86_64            MySQL 5.7 Community Server   disabled
mysql57-community-source            MySQL 5.7 Community Server - disabled
mysql80-community/x86_64            MySQL 8.0 Community Server   enabled:    229
mysql80-community-source            MySQL 8.0 Community Server - disabled

这里我们要禁Mysql80 启Mysql57

yum-config-manager --disable mysql80-community/x86_64

yum-config-manager --enable mysql57-community/x86_64

yum install -y mysql57-community

-----------------------------------------------------------------

2. 在开源社区下载好rpm安装包,手动安装。

http://mirrors.ustc.edu.cn/mysql-ftp/Downloads/MySQL-5.7/

下载mysql-community-server/lib/common/client 这4个rpm包,注意centos7 选el7

统一放到一个文件夹 例如 /tmp/MYSQL/

然后cd到该文件夹

rpm -ivh *.rpm --nodeps --force

安装完成后 

systemctl enable mysqld && systemctl start mysqld

mysql其他操作先不用做

2)apache、php

yum install -y http http-devel php php-devel

vi /etc/httpd/conf/httpd.conf

ServerName www.zabbixyk.com      #修改为主机名

DirectoryIndex index.html index.php   # 添加首页支持格式

vi /etc/php.ini

date.timezone = PRC   # 配置时区  

vi /var/www/html/index.php      #创建个测试页,然后从客户端访问呢

[root@localhost ~]# cat /var/www/html/index.php
<?php

phpinfo();

?>

systemctl enable httpd && systemctl start httpd     #重启一下apache

 

三、安装Zabbix

这一小节都是遵循zabbix官网得

https://www.zabbix.com/download?zabbix=5.0&os_distribution=centos&os_version=7&db=mysql&ws=apache

Install and configure Zabbix server for your platform

a. Install Zabbix repository

# rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
# yum clean all

b. Install Zabbix server and agent

# yum install zabbix-server-mysql zabbix-agent

c. Install Zabbix frontend

Enable Red Hat Software Collections

# yum install centos-release-scl

Edit file /etc/yum.repos.d/zabbix.repo and enable zabbix-frontend repository.

[zabbix-frontend]
...
enabled=1
...

Install Zabbix frontend packages.

# yum install zabbix-web-mysql-scl zabbix-apache-conf-scl

d. Create initial database

Make sure you have database server up and running.

Run the following on your database host.

# mysql -uroot -p
password
mysql> create database zabbix character set utf8 collate utf8_bin;
mysql> create user zabbix@localhost identified by 'password';
mysql> grant all privileges on zabbix.* to zabbix@localhost;
mysql> quit;

On Zabbix server host import initial schema and data. You will be prompted to enter your newly created password.

# zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix

e. Configure the database for Zabbix server

Edit file /etc/zabbix/zabbix_server.conf

DBPassword=password

f. Configure PHP for Zabbix frontend

Edit file /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf, uncomment and set the right timezone for you.

; php_value[date.timezone] = Europe/Riga

g. Start Zabbix server and agent processes

Start Zabbix server and agent processes and make it start at system boot.

# systemctl restart zabbix-server zabbix-agent httpd rh-php72-php-fpm
# systemctl enable zabbix-server zabbix-agent httpd rh-php72-php-fpm

h. Configure Zabbix frontend

Connect to your newly installed Zabbix frontend: http://server_ip_or_name/zabbix
 

以上都是官方教程,我这里说下遇到的坑

搭建好后,访问web会有一个图形化的初始化设置项,一步步走就行,登录用户名是 Admin 密码就是图形化里设置的、

如果遇到密码错误的话需要登陆mysql手工修改。 默认在 zabbix.users 表中。

[root@zabbix ~]# echo -n redhat | openssl md5
(stdin)= e2798af12a7a0f4f70b4d69efbc25f4d
update users set passwd='e2798af12a7a0f4f70b4d69efbc25f4d' where userid = '1';

 

 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值