1. 首页
  2. 技术知识

centos7.9安装zabbix5.0.14及配置过程

目录

    一、基础环境配置二、安装数据库三、安装zabbix相关组件四、配置Zabbix前端

一、基础环境配置

1、关闭firewalld、关闭selinux

##关闭firewalld

systemctl stop firewalld

systemctl disabled firewalld

##关闭selinux

setenforce 0 && sed -i.bak ‘s/^SELINUX=.*/SELINUX=disabled/g’ /etc/selinux/config2、配置yum仓库

配置zabbix仓库

wget https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm

yum install zabbix-release-5.0-1.el7.noarch.rpm

##在/etc/yum.repos.d/中查看zabbix仓库的配置情况

[root@localhost opt]# cat /etc/yum.repos.d/zabbix.repo

[zabbix]

name=Zabbix Official Repository – $basearch

baseurl=http://repo.zabbix.com/zabbix/5.0/rhel/7/$basearch/

enabled=1

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591

[zabbix-frontend]

name=Zabbix Official Repository frontend – $basearch

baseurl=http://repo.zabbix.com/zabbix/5.0/rhel/7/$basearch/frontend

enabled=1

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591

[zabbix-debuginfo]

name=Zabbix Official Repository debuginfo – $basearch

baseurl=http://repo.zabbix.com/zabbix/5.0/rhel/7/$basearch/debuginfo/

enabled=0

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591

gpgcheck=1

[zabbix-non-supported]

name=Zabbix Official Repository non-supported – $basearch

baseurl=http://repo.zabbix.com/non-supported/rhel/7/$basearch/

enabled=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX

gpgcheck=1配置mysql仓库(zabbix监控后台需要用到mysql存储)

##使用清华大学的镜像仓库

[root@localhost opt]# cat /etc/yum.repos.d/mysql.repo

[mysql]

name=mysql

baseurl=https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql-5.7-community-el7-x86_64/

gpgcheck=0

enabled=1配置centos extras仓库(后续的安装需要用到此仓库的软件包)

[root@localhost opt]# cat /etc/yum.repos.d/centos-extras.repo

[centos-extras]

name=centos-extras

baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/7.9.2009/extras/x86_64/

enabled=1

gpgcheck=0


二、安装数据库

yum install mysql-community-server启动mysql服务

systemctl start mysql

systemctl enable mysql在服务器初始启动时,会发生以下情况:

服务器初始化。

SSL 证书和密钥文件在数据目录中生成。

validate_password 已安装并启用。

‘root’@’localhost创建了 一个超级用户帐户。超级用户的密码已设置并存储在错误日志文件中。要显示它,请使用以下命令:

[root@localhost opt]# grep ‘temporary password’ /var/log/mysqld.log

2022-08-16T08:00:40.185610Z 1 [Note] A temporary password is generated for root@localhost: r8EaYzX_Xper通过使用生成的临时密码登录并为超级用户帐户设置自定义密码,尽快更改 root 密码:

[root@localhost opt]# mysql -uroot -p

Enter password:

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 702

Server version: 5.7.35 MySQL Community Server (GPL)

Copyright (c) 2000, 2022, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.

mysql> ALTER USER ‘root’@’localhost’ IDENTIFIED BY ‘xxxxxxx’;
注意:

validate_password 默认安装。执行的默认密码策略validate_password要求密码至少包含1个大写字母、1个小写字母、1个数字和1个特殊字符,并且密码总长度至少为8个字符。

修改一下mysql的配置文件,提高其性能

[root@centos7 ~]# vim /etc/my.cnf

[mysqld]  //在[mysqld]下面添加下面两行

skip_name_resolve =ON

innodb_file_per_table=ON


三、安装zabbix相关组件

1、安装zabbix-server

安装zabbix-server和zabbix-agent

yum install zabbix-server-mysql zabbix-agent安装zabbix-get命令行工具(用于后期在客户端部署angent是测试监控项使用)

yum install zabbix-get2、安装frontend

启用Red Hat Software Collections(方便安装依赖包)

##这个软件包在centos-extras仓库中,所以之前配置了centos-extras仓库

yum install centos-release-scl编辑配置文件 /etc/yum.repos.d/zabbix.repo and enable zabbix-frontend repository.

[zabbix-frontend]



enabled=1

…安装Zabbix frontend packages

yum install zabbix-web-mysql-scl zabbix-nginx-conf-scl安装frontend时报错

提示需要rh-php72-php-fpm,rh-nginx116-nginx等软件包。

解决方法:

因为之前没有安装centos-release-scl,所以导致出现上述问题,配置好centos-extras仓库后安装即可

3.创建初始数据库

# mysql -uroot -pxxxxx

mysql> create database zabbix character set utf8 collate utf8_bin;

mysql> create user zabbix@localhost identified by ‘xxxxxxx’;

mysql> grant all privileges on zabbix.* to zabbix@localhost;

mysql> quit;导入初始架构和数据,系统将提示您输入新创建的密码。

# zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix4.为Zabbix server配置数据库

编辑配置文件 /etc/zabbix/zabbix_server.conf

DBPassword=xxxxxxx5.为Zabbix前端配置PHP

编辑配置文件 /etc/opt/rh/rh-nginx116/nginx/conf.d/zabbix.conf

##取消这两行注释

listen 80;

server_name example.com;

##同时把提供默认的web服务的配置注释掉

vim /etc/opt/rh/rh-nginx116/nginx/nginx.conf



server {

        #listen       80 default_server;

        #listen       [::]:80 default_server;

        server_name  _;



##然后重启服务编辑配置文件 /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf, 在listen.acl_users指令这一行添加nginx用户(在安装rh-nginx116-nginx时系统会自动创建)

listen.acl_users = apache,nginx

##然后配置时区

php_value[date.timezone] = Asia/Shanghai6.启动zabbix server和agent进程,并为它们设置开机自启。

systemctl restart zabbix-server zabbix-agent rh-nginx116-nginx rh-php72-php-fpm

systemctl enable zabbix-server zabbix-agent rh-nginx116-nginx rh-php72-php-fpm


四、配置Zabbix前端

在浏览器中 打开 Zabbix 前端URL:

对于 Apache:http://<server_ip_or_name>/zabbix

对于 Nginx:http://<server_ip_or_name>

检查先决条件

确保满足所有软件先决条件。

注意:如果需要更改Apache用户或用户组,则必须验证对会话文件夹的权限。否则 Zabbix 安装程序可能无法继续。

配置数据库连接

输入连接到数据库的详细信息。Zabbix 数据库必须已经创建

Zabbix 服务器详细信息

输入 Zabbix 服务器详细信息。输入 Zabbix 服务器的名称是可选的

查看设置摘要。

安装完成

登录

Zabbix 前端已准备就绪!默认用户名为Admin,密码为zabbix。

到此这篇关于centos7.9安装zabbix5.0.14及配置过程的文章就介绍到这了,更多相关centos7.9安装zabbix内容请搜索共生网络以前的文章或继续浏览下面的相关文章希望大家以后多多支持共生网络!

原创文章,作者:starterknow,如若转载,请注明出处:https://www.starterknow.com/106713.html

联系我们