CentOS7 installation Zabbix6.4

Installation preparation:

Zabbix updated to the latest version 6.4, the following is the installation process of Zabbix6.4 on CentOS7 system

Zabbix does not support the quick installation of the server side on the CentOS7 system according to official documents since version 6.0

So we can only compile and install step by step.

Zabbix source package address: https://www.zabbix.com/cn/download_sources

Zabbix6.4 official document address

https://www.zabbix.com/documentation/6.4/en/manual/installation/getting_zabbix

Installation process:

Turn off firewalls and security mechanisms

# close the firewall

systemctl stop firewalld.service

# close the security mechanism

setenforce 0

Install MySQL

Configure the MySQL source

#Download MySQL source

wget https://dev.mysql.com/get/mysql80-community-release-el7-5.noarch.rpm

#Configure MySQL source

yum -y install mysql80-community-release-el7-5.noarch.rpm

Compile dependency installation

#Install MySQL related dependencies

yum -y install gcc-c++ mysql-devel net-snmp-devel libevent-devel

download mysql

#Download MySQL

wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.28-1.el7.x86_64.rpm-bundle.tar

Unzip and install to download MySQL

#Create the MySQL directory

mkdir /usr/local/mysql

#Unzip the MySQL installation package

tar xf mysql-8.0.28-1.el7.x86_64.rpm-bundle.tar -C /usr/local/mysql

#Move to the mysql directory

cd /usr/local/mysql/

#RPM way to install MySQL

rpm -ivh mysql-community-* --force --nodeps

Check whether the RPM packages of MySQL are installed
rpm -qa |grep mysql

#Display the following installation packages

mysql-community-common-8.0.32-1.el7.x86_64

mysql-community-libs-8.0.28-1.el7.x86_64

mysql-community-test-8.0.28-1.el7.x86_64

mysql-community-client-plugins-8.0.28-1.el7.x86_64

mysql-community-client-8.0.28-1.el7.x86_64

mysql-community-server-8.0.28-1.el7.x86_64

mysql-community-devel-8.0.28-1.el7.x86_64

mysql-community-embedded-compat-8.0.28-1.el7.x86_64

php-mysqlnd-7.4.33-2.el7.remi.x86_64

mysql80-community-release-el7-5.noarch

mysql-community-libs-8.0.32-1.el7.x86_64

mysql-community-devel-8.0.32-1.el7.x86_64

mysql-community-client-plugins-8.0.32-1.el7.x86_64

mysql-community-libs-compat-8.0.32-1.el7.x86_64

mysql-community-common-8.0.28-1.el7.x86_64

mysql-community-icu-data-files-8.0.28-1.el7.x86_64

mysql-community-libs-compat-8.0.28-1.el7.x86_64

start mysql

# start MySQL

systemctl start mysqld

#MySQLJoin and start self-starting

systemctl enable mysqld

View MySQL service status

#The following three methods are acceptable (it is recommended to read them all)

systemctl status mysqld.service

netstat -anptu |grep mysql

ps -ef |grep mysql

After MySQL starts, it will initialize and generate a MySQL password

cat /var/log/mysqld.log | grep password

2023-02-08T06:27:07.406203Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: V6BUo&hq!yo3

Modify the root password of MySQL

#Because MySQL8.0 has a password verification component, if you want to set a simple password, you need to modify the service verification conditions

# Password checking level, 0/LOW, 1/MEDIUM, 2/STRONG

set global validate_password.policy=0;

# Minimum password length

set global validate_password.length=6;

# The minimum number of lowercase letters and uppercase letters that the password must contain

set global validate_password.mixed_case_count=0;

# set password

mysql -uroot -p

#Log in to mysql with the initial password V6BUo&hq!yo3

ALTER USER 'root'@'localhost' IDENTIFIED BY 'Zabbix@123';

Create zabbix library

#Create zabbix library

create database zabbix character set utf8 collate utf8_bin;

#Create zabbix user

create user zabbix@localhost identified by 'Zabbix@123';

#Authorization

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

Install Zabbix6.4

Download the source package and unzip it

#Download the official source package

wget https://cdn.zabbix.com/zabbix/sources/stable/6.4/zabbix-6.4.0.tar.gz

#Create zabbix directory

mkdir /usr/local/zabbix

# unzip

tar -zxvf zabbix-6.0.1.tar.gz -C /usr/local/zabbix/

Create Zabbix users and user groups

(1) For all Zabbix daemons, an unprivileged user is required, if the Zabbix daemon is started from an unprivileged user account, it will run as this user.

(2) However, if a daemon is started as "root", it switches to the "zabbix" user, which must exist. In the Linux system, you can use the following command to create a user (the user belongs to its own user group, "zabbix")

#Create zabbix group

groupadd zabbix

#Create zabbix user

useradd -g zabbix -M -s /sbin/nologin zabbix

Compile and install Zabbix6.4

#Move to the zabbix directory

cd /usr/local/zabbix/zabbix-6.4.0/

# compile

./configure --prefix=/usr/local/zabbix/ --enable-server --enable-agent --with-net-snmp --with-mysql

make install

Since the default gcc version of CentOS7 is lower than 4.8, it cannot be compiled and installed successfully.

而且重新安装gcc的过程十分漫长,因此我们采用切换gcc版本的方式,无需漫长的手动下载源码编译安装

安装切换gcc版本

安装centos-release-scl

yum install centos-release-scl -y

安装devtoolset,注意,如果想安装10.版本的,就改成devtoolset-10-gcc,以此类推

sudo yum install devtoolset-11-gcc* -y

激活对应的devtoolset,所以你可以一次安装多个版本的devtoolset,需要的时候用下面这条命令切换到对应的版本

scl enable devtoolset-11 bash

查看gcc版本

gcc -v

补充:这条激活命令只对本次会话有效,重启会话后还是会变回原来的4.8.5版本,要想随意切换可按如下操作。

首先,安装的devtoolset是在 /opt/rh 目录下的,如图

每个版本的目录下面都有个 enable 文件,如果需要启用某个版本,只需要执行

source ./enable

直接替换旧的gcc

旧的gcc是运行的 /usr/bin/gcc,所以将该目录下的gcc/g++替换为刚安装的新版本gcc软连接,免得每次enable

mv /usr/bin/gcc /usr/bin/gcc-4.8.5

ln -s /opt/rh/devtoolset-8/root/bin/gcc /usr/bin/gcc

mv /usr/bin/g++ /usr/bin/g++-4.8.5

ln -s /opt/rh/devtoolset-8/root/bin/g++ /usr/bin/g++

gcc --version

g++ --version

跟新完gcc版本后,我们可以顺利完成zabbix6.4的编译安装

安装PHP

由于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

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

vim /etc/php.ini

修改post_max_size为16M

修改max_execution_time为300

修改max_input_time为300

配置httpd

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

cp -r /usr/local/zabbix/zabbix-6.4.0/ui/* /var/www/html/

chown apache:apache /var/www/html -R

导入数据库架构及数据

mysql -uzabbix -pZabbix@123 zabbix < /usr/local/zabbix/zabbix-6.4.0/database/mysql/schema.sql

mysql -uzabbix -pZabbix@123 zabbix < /usr/local/zabbix/zabbix-6.4.0/database/mysql/images.sql

mysql -uzabbix -pZabbix@123 zabbix < /usr/local/zabbix/zabbix-6.4.0/database/mysql/data.sql

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

vim /usr/local/zabbix/etc/zabbix_server.conf

# DBPassword= 修改为MySQL的zabbix用户密码

DBPassword=Zabbix@123

开启httpd zabbix

service httpd start

systemctl enable httpd.service

cd /usr/local/zabbix/sbin/

./zabbix_server

网页验证:

访问地址:本机ip:80

按流程进行下一步配置即可

第一步选择中文

必要条件全部OK选点击下一步

数据库配置,输入zabbix用户的密码Zabbix@123后点击下一步

设置zabbix主机名及主题颜色

登录zabbix输入用户密码,默认用户密码:Admin/zabbix

登录成功,进入zabbix界面

Guess you like

Origin blog.csdn.net/PerDrix/article/details/129624091