首页 > 系统相关 >Centos7搭建zabbix6.0

Centos7搭建zabbix6.0

时间:2022-09-05 01:00:29浏览次数:111  
标签:8.0 -- zabbix6.0 community Centos7 zabbix mysql el7 搭建

Centos7搭建zabbix6.0

此方法适用于zabbix6以上版本

zabbix6.0前期环境准备:Lamp(linux httpd mysql8.0 php)

mysql官网下载位置:https://dev.mysql.com/downloads/mysql/

Zabbix源码包地址:https://www.zabbix.com/cn/download_sources

Zabbix6官方文档地址:https://www.zabbix.com/documentation/6.0/en/manual/installation/getting_zabbix

构建过程:

关闭防火墙和安全机制

#关闭防火墙
systemctl stop firewalld.service
#关闭安全机制
setenforce 0

一 丶 安装MySQL8.0(RPM)

1:配置mysql源

#下载MySQL源
wget https://dev.mysql.com/get/mysql80-community-release-el7-5.noarch.rpm
#配置MySQL源
yum -y install mysql80-community-release-el7-5.noarch.rpm

2:为防止后续编译安装zabbix时报错 提前安装依赖

#安装MySQL相关依赖
yum -y install gcc-c++ mysql-devel net-snmp-devel libevent-devel

3:下载MySQL和zabbix

#下载zabbix
wget https://cdn.zabbix.com/zabbix/sources/stable/6.0/zabbix-6.0.1.tar.gz
#下载MySQL
wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.28-1.el7.x86_64.rpm-bundle.tar

4:解压并安装下载好的MySQL安装包

#创建MySQL目录
mkdir /usr/local/mysql
#解压MySQL安装包
tar xf mysql-8.0.28-1.el7.x86_64.rpm-bundle.tar -C /usr/local/mysql
#移动到mysql目录
cd /usr/local/mysql/
#RPM方式安装MySQL
rpm -ivh mysql-community-common-8.0.28-1.el7.x86_64.rpm --force --nodeps
rpm -ivh mysql-community-libs-8.0.28-1.el7.x86_64.rpm --force --nodeps
rpm -ivh mysql-community-libs-compat-8.0.28-1.el7.x86_64.rpm --force --nodeps
rpm -ivh mysql-community-client-8.0.28-1.el7.x86_64.rpm --force --nodeps
rpm -ivh mysql-community-server-8.0.28-1.el7.x86_64.rpm --force --nodeps

5:检查MySQL的个RPM包是否被安装

rpm -qa |grep mysqlrpm -qa |grep mysql
#显示如下安装包
mysql-community-server-8.0.28-1.el7.x86_64
mysql-community-libs-compat-8.0.28-1.el7.x86_64
mysql-community-client-plugins-8.0.29-1.el7.x86_64
mysql-community-common-8.0.29-1.el7.x86_64
mysql-community-devel-8.0.29-1.el7.x86_64
mysql-community-common-8.0.28-1.el7.x86_64
mysql-community-libs-8.0.29-1.el7.x86_64
mysql80-community-release-el7-5.noarch
mysql-community-libs-compat-8.0.29-1.el7.x86_64
mysql-community-client-8.0.28-1.el7.x86_64
mysql-community-libs-8.0.28-1.el7.x86_64

6:启动MySQL并加入开机自启

#启动MySQL
systemctl start mysqld
#MySQL加入开启自启
systemctl enable mysqld

7:检查MySQL服务是否启动

#以下三种方法,均可(建议都看一遍)
systemctl status mysqld.service 
netstat -anptu |grep mysql
ps -ef |grep mysql

8:启动mysql后会初始化 查找mysql密码

cat /var/log/mysqld.log | grep password
2022-06-23T16:15:31.370137Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: Dfo5Dm-!fVZG
#密码为:Dfo5Dm-!fVZG

9:修改MySQL的root密码

#由于MySQL8.0 有密码验证组件,若希望设置简单的密码,需要修改服务验证条件
# 密码检查等级,0/LOW、1/MEDIUM、2/STRONG
set global validate_password.policy=0;
# 密码的最短长度
set global validate_password.length=6;
# 密码至少要包含的小写字母个数和大写字母个数
set global validate_password.mixed_case_count=0;
# 设置密码
mysql -uroot -p
ALTER USER 'root'@'localhost' IDENTIFIED BY 'Likun@123';

10:创建zabbix库

#创建zabbix库
create database zabbix character set utf8 collate utf8_bin;
#创建zabbix用户
create user zabbix@localhost identified by 'Likun@123'; 
#授权
grant all privileges on zabbix.* to zabbix@localhost;

二丶安装zabbix****6.1

1:解压在官网上下载的zabbix源码包

#创建zabbix目录
mkdir /usr/local/zabbix
#解压
tar -zxvf zabbix-6.0.1.tar.gz -C /usr/local/zabbix/

2:创建用户账户

(1)对于所有 Zabbix 守护进程,需要一个非特权用户,如果从非特权用户帐户启动 Zabbix 守护程序,它将以该用户身份运行。

(2)然而,如果一个守护进程以“root”启动,它会切换到“zabbix”用户,且这个用户必须存在。在 Linux系统中,可以使用下面命令建立一个用户(该用户属于自己的用户组,“ zabbix”)

#创建zabbix组
groupadd zabbix
#创建zabbix用户
useradd  -g zabbix -M -s /sbin/nologin zabbix

3:站在zabbix目录中编译安装

#移动到zabbix目录
cd /usr/local/zabbix/zabbix-6.0.1/
#编译
./configure --prefix=/usr/local/zabbix/ --enable-server --enable-agent --with-net-snmp --with-mysql
make install

** 三丶安装PHP**

1:由于CentOS7自带PHP版本为5.6,所以需要安装额外的库,也是remi的库

 yum -y install https://rpms.remirepo.net/enterprise/remi-release-7.rpm  
 yum -y install yum-utils
 yum-config-manager --disable 'remi-php*'
 yum-config-manager --enable   remi-php74 
 yum -y install php php-bcmath php-gd php-xml  php-mbstring php-mysqlnd php-ldap
 yum -y install curl-devl libxml2 libxml2-devel 

2:需要修改php参数(网页预配置必要条件)

 vim /etc/php.ini 
修改post_max_size为16M
修改max_execution_time为300
修改max_input_time为300

四丶配置httpd

1:移动前端文件至web服务的根目录并授权

 cp -r /usr/local/zabbix/zabbix-6.0.1/ui/* /var/www/html/
 
 chown apache:apache /var/www/html -R 

2:导入数据库架构及数据

mysql -uzabbix -pLikun@123 zabbix < /usr/local/zabbix/zabbix-6.0.1/database/mysql/schema.sql 
mysql -uzabbix -pLikun@123 zabbix < /usr/local/zabbix/zabbix-6.0.1/database/mysql/images.sql
mysql -uzabbix -pLikun@123 zabbix < /usr/local/zabbix/zabbix-6.0.1/database/mysql/data.sql 

3:修改配置zabbixserver文件数据库密码

vim /usr/local/zabbix/etc/zabbix_server.conf
 
# DBPassword=    修改为MySQL的zabbix用户密码
DBPassword=Likun@123

4:开启httpd zabbix

 service httpd start
 systemctl enable httpd.service
 cd /usr/local/zabbix/sbin/
 ./zabbix_server

五丶网页验证

1:网页测试:(谷歌浏览器)

本机ip:80

2:选择中文,并点击一步

img

3:必要条件都已满足,点击下一步

img

4:DB连接配置

img

img

5:输入账号密码

img

6:登录成功

img

未修改前文章有许多错误,现已改正,感谢评论区的各位

如有问题,请在评论区告知,后续会改正

标签:8.0,--,zabbix6.0,community,Centos7,zabbix,mysql,el7,搭建
From: https://www.cnblogs.com/sjkzy/p/16656672.html

相关文章