zabbix-1- 安装

实验环境
[itlaoxin@localhost ~]$ cat /etc/redhat-release 
CentOS Stream release 8
[itlaoxin@localhost ~]$ uname -r
4.18.0-365.el8.x86_64
[itlaoxin@localhost ~]$ free -m
              total        used        free      shared  buff/cache   available
Mem:           3704        1110        1434          21        1159        2334
Swap:          2047           0        2047
[itlaoxin@localhost ~]$ 

[itlaoxin@localhost ~]$ cat /proc/cpuinfo |grep "cpu cores"
cpu cores    : 2
cpu cores    : 2



可以看到,当前所用的系统是 centos-stream 8 , CPU是2核的, 内存是 4G

部署底层环境LAMP
注意: zabbix 6.0 需要 安装10.6.5以上的Mariadb,而系统自带的为10.5,所以需要安装额外源

cat < /etc/yum.repos.d/mariadb.repo
# MariaDB 10.6 CentOS repository list - created 2022-01-16 15:10 UTC
# https://mariadb.org/download/
[mariadb]
name = MariaDB
baseurl = https://mirrors.cloud.tencent.com/mariadb/yum/10.6/centos8-amd64
module_hotfixes=1
gpgkey=https://mirrors.cloud.tencent.com/mariadb/yum/RPM-GPG-KEY-MariaDB
gpgcheck=1
EOF

开始安装 底层环境

[root@localhost itlaoxin]# dnf install mariadb mariadb-server httpd httpd-tools php php-cli php-json php-gd php-mbstring php-pdo php-xml php-mysqlnd php-pecl-zip wget -y
1
配置zabbix源
[itlaoxin@localhost ~]$ sudo su


[sudo] itlaoxin 的密码:
[root@localhost itlaoxin]# 
[root@localhost itlaoxin]# rpm -Uvh https://repo.zabbix.com/zabbix/6.0/rhel/8/x86_64/zabbix-release-6.0-1.el8.noarch.rpm
获取https://repo.zabbix.com/zabbix/6.0/rhel/8/x86_64/zabbix-release-6.0-1.el8.noarch.rpm
警告:/var/tmp/rpm-tmp.k7Xsgd: 头V4 RSA/SHA512 Signature, 密钥 ID a14fe591: NOKEY
Verifying...                          ################################# [100%]
准备中...                          ################################# [100%]
正在升级/安装...
   1:zabbix-release-6.0-1.el8         ################################# [100%]

安装zabbix
dnf install zabbix-server-mysql zabbix-web-mysql zabbix-apache-conf zabbix-sql-scripts zabbix-selinux-policy zabbix-agent2 -y
1
配置MySQL
root@localhost itlaoxin]# systemctl start mariadb && systemctl enable mariadb
Created symlink /etc/systemd/system/multi-user.target.wants/mariadb.service → /usr/lib/systemd/system/mariadb.service.

[root@localhost itlaoxin]# mysql
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 3
Server version: 10.6.7-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

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

MariaDB [(none)]> 

设置 数据库名: zabbix
用户名:zabbix
密码: 123456

让用户zabbix,能够通过本地访问数据库zabbix,使用123456作为密码

MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.001 sec)

MariaDB [(none)]> grant all on zabbix.* to zabbix@'localhost' identified by '123456';
Query OK, 0 rows affected (0.001 sec)

MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.001 sec)

MariaDB [(none)]> quit
Bye


导入初始架构和数据
[root@localhost zabbix-server-mysql]# zcat /usr/share/doc/zabbix-sql-scripts/mysql/server.sql.gz | mysql -uzabbix -p zabbix


为zabbix server配置数据库
[root@itlaoxin ~]# vim /etc/zabbix/zabbix_server.conf 
124 DBPassword=123456

[root@localhost zabbix-server-mysql]# grep DBPassword /etc/zabbix/zabbix_server.conf |grep -v ^#
DBPassword=123456

启动Zabbix server和agent进程
systemctl restart zabbix-server zabbix-agent2 httpd php-fpm
systemctl enable zabbix-server zabbix-agent2 httpd php-fpm

前端配置
关闭防火墙和selinux

root@localhost zabbix-server-mysql]# setenforce 0
[root@localhost zabbix-server-mysql]# systemctl stop firewalld.service 
[root@localhost zabbix-server-mysql]# 

zabbix web登录

zabbix部署后,使用默认的Admin账户登录
Admin/zabbix,新部署搭建的zabbix环境,密码都为Admin

http://IP​​​​​​/zabbix/

用户名Admin 密码zabbix

修改语言:

左下角user settings 打开界面后选择语言“中文”

注意:
Zabbix 6.0 LTS 的安装相对之前的版本没有太多的区别,主要是数据库架构文件发生了调整,create.sql.gz --> server.sql.gz,其他基本保持一致,后续的版本都会以 6.0 为主了,所以要尽快学习。

安装zabbix6.2后web界面出现需要php74

php7.4安装

#php高版本的yum源地址,有两部分,其中一部分是epel-release,另外一部分来自webtatic。如果跳过epel-release的话,安装webtatic的时候
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
rpm -Uvh http://rpms.remirepo.net/enterprise/remi-release-8.rpm
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-8.rpm
wget http://rpms.famillecollet.com/enterprise/remi-release-8.rpm
rpm -ivh remi-release-8.rpm --nodeps --force
dnf -y install dnf-utils
yum search php74*
yum install php74-php 
#运行并查看版本
php74 -v
#重启命令php-fpm
systemctl restart php74-php-fpm
#添加自动启动
systemctl enable php74-php-fpm
#查看php7.4的安装路径
whereis php
#链接php文件
ln -s /opt/remi/php74/root/usr/bin/php /usr/bin/php

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

zabbix源

官网一般下载不了

https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/6.4/rhel/8/x86_64/

wget https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/6.4/rhel/8/x86_64/zabbix-release-6.4-1.el8.noarch.rpm
rpm -ivh zabbix-release-6.4-1.el8.noarch.rpm
rpm -ql zabbix-release 查看

vim /etc/yum.repos.d/zabbix.repo
将baseurl=官网地址替换成https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/6.4/rhel/8/x86_64/

zabbix-agent安装

wget https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/6.4/rhel/8/x86_64/zabbix-agent-6.4.0-release1.el8.x86_64.rpm

rpm -ivh zabbix-agent-6.4.0-release1.el8.x86_64.rpm

mkdir /var/log/zabbix/
touch /var/log/zabbix/zabbix_agentd.log
chown zabbix.zabbix /var/log/zabbix/zabbix_agentd.log

配置/etc/zabbix/zabbix-agentd.conf
#修改内容如下:
Server=zabbix服务器地址
ServerActive=zabbix服务器地址
Hostname=本机地址
UnsafeUserParameters=1  #是否限制用户自定义key使用特殊字符,1表示启用,0表示不可以
EnableRemoteCommands=1  #是否允许别人执行远程操作命令,默认禁止,打开的话会有安全风险


启动zabbix-agent

systemctl start zabbix-agent
systemctl enable zabbix-agent

默认添加主机时需要选择模板,例如linux-zabbix-agent模板,zabbix6中这个模板有127个监控项,我们不需要监控如此多的监控项,需要对监控项进行删减

配置-模板-选在temp**中的linux-zabbix-agent模板进行克隆一个,重新命名linux-zabbix-agent-2

点击这个模板,进入模板的配置界面,进行删减。

注意:新添加的主机,选择模板后,同时还会开启自动发现监控项

zabbix-1- 安装_第1张图片

上图我们看到监控项为87个,其实模板中的监控项我们进行裁剪后仅有21个,多出的66个都是自动发现规则自动添加的。我们可以在发现后,关闭自动发现规则。

 zabbix-1- 安装_第2张图片点击已启动。就会关闭。然后再点击监控项,在其中可以对自动发现的监控项进行更改或删除。

注意:在此界面不能删除模板linux-zabbix-agent-2下的21个监控项。可以删除自动发现的监控项。

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

添加触发

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

开启触发告警声音

>用户配置-配置-正在发送消息--前端信息中【勾选】

  fazhi

你可能感兴趣的:(zabbix,linux,centos,服务器)