Centos7系统安装Zabbix4.4步骤详解

1. 虚拟机中安装Centos7系统

本次实验使用最小系统安装,安装完后可以先进行内核软件更新(yum -y update)时间比较久,快速配置可以忽略此步骤。

2.关闭Centos7的SELinux和防火墙配置

关闭SELinux

[root@zabbix-server ~]# setenforce 0

[root@zabbix-server ~]# vi /etc/selinux/config

1

2

3

4

5

6

7

8

9

10

11

# This file controls the state of SELinux on the system.

# SELINUX= can take one of these three values:

#     enforcing - SELinux security policy is enforced.

#     permissive - SELinux prints warnings instead of enforcing.

#     disabled - No SELinux policy is loaded.

SELINUX=disabled

# SELINUXTYPE= can take one of three values:

#     targeted - Targeted processes are protected,

#     minimum - Modification of targeted policy. Only selected processes are protected.

#     mls - Multi Level Security protection.

SELINUXTYPE=targeted

  

关闭防火墙配置

[root@zabbix-server ~]# systemctl stop firewalld.service
[root@zabbix-server ~]# systemctl disable firewalld.service

3.部署zabbix4.4服务器、zabbix4.4官网教程链接

1.安装 数据库

[root@zabbix-server ~]# rpm -Uvh https://repo.zabbix.com/zabbix/4.4/rhel/7/x86_64/zabbix-release-4.4-1.el7.noarch.rpm #此处如果不是root权限会提示权限不足

[root@zabbix-server ~]# yum clean all

[root@zabbix-server ~]# yum makecache

2.安装Zabbix服务器,前端,代理(如果没有安装成功,需多次执行下载才能完全安装)

[root@zabbix-server ~]# yum -y install zabbix-server-mysql zabbix-web-mysql zabbix-agent

把三个服务全部安装完成

以上如果遇到问题可以用下面方式解决

出现该错误通常是由于网络连接问题或DNS解析失败导致无法访问CentOS的镜像列表服务器。以下是分步解决方案:

---
**1. 检查网络连通性**
```bash
ping -c 4 mirrorlist.centos.org
```
- 若无法ping通,说明存在网络连接问题,需检查防火墙/网关设置。
- 若能ping通但yum仍报错,继续下一步。

**2. 检查DNS解析**
```bash
nslookup mirrorlist.centos.org
```
- 如果DNS解析失败,临时更换DNS服务器:
```bash
echo "nameserver 8.8.8.8" | sudo tee /etc/resolv.conf
```

**3. 手动修改仓库配置(针对CentOS 7 EOL问题)**  
由于CentOS 7已停止维护,默认镜像列表不可用,需改用vault仓库:
```bash
sudo sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*
sudo sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-*
```

**4. 清理并重建yum缓存**
```bash
sudo yum clean all
sudo rm -rf /var/cache/yum
sudo yum makecache
```

**5. 临时禁用fastestmirror插件(可选)**  
编辑 `/etc/yum/pluginconf.d/fastestmirror.conf`,将 `enabled=1` 改为 `enabled=0`。

**6. 测试yum命令**
```bash
sudo yum update
```

---

**原因说明:**  
CentOS 7已于2024年6月30日结束生命周期(EOL),官方镜像源已移除软件包,因此需要改用vault.centos.org归档仓库。上述操作通过修改仓库地址指向历史存档,同时确保DNS解析正常即可恢复yum功能。

3. 安装mariadb数据库(设置开机启动)

//更新MARIABD数据库

[root@zabbix-server ~]# yum install -y mariadb-server

//启动服务

[root@zabbix-server ~]# systemctl start mariadb.service

//设置开机启动

[root@zabbix-server ~]# systemctl enable mariadb.service

4.导入Zabbix数据到Mysql数据库

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

[root@zabbix-server ~]# mysql -uroot -p

Enter password:     //空密码直接按回车键

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

Your MariaDB connection id is 2

Server version: 5.5.64-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)]> create database zabbix character set utf8 collate utf8_bin;

Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@localhost identified by 'zn123456';

Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> flush privileges;

Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> quit;

Bye

  

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

1

2

[root@zabbix-server ~]# zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix

Enter password:      ###密码:zn123456

6.为Zabbix server配置数据库

[root@zabbix-server ~]# vi /etc/zabbix/zabbix_server.conf

1

2

3

4

DBHost=localhost

DBName=zabbix

DBUser=zabbix

DBPassword=zn123456

  

7.修改时区

[root@zabbix-server ~]# vi /etc/httpd/conf.d/zabbix.conf

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

#

# Zabbix monitoring system php web frontend

#

Alias /zabbix /usr/share/zabbix

<Directory "/usr/share/zabbix">

    Options FollowSymLinks

    AllowOverride None

    Require all granted

    <IfModule mod_php5.c>

        php_value max_execution_time 300

        php_value memory_limit 128M

        php_value post_max_size 16M

        php_value upload_max_filesize 2M

        php_value max_input_time 300

        php_value max_input_vars 10000

        php_value always_populate_raw_post_data -1

        # php_value date.timezone Europe/Riga

        php_value date.timezone Asia/Shanghai

    </IfModule>

</Directory>

<Directory "/usr/share/zabbix/conf">

    Require all denied

</Directory>

<Directory "/usr/share/zabbix/app">

    Require all denied

</Directory>

<Directory "/usr/share/zabbix/include">

    Require all denied

</Directory>

<Directory "/usr/share/zabbix/local">

    Require all denied

</Directory>

  

8.启动Zabbix server和agent进程

[root@zabbix-server ~]# systemctl restart zabbix-server zabbix-agent httpd

[root@zabbix-server ~]# systemctl enable zabbix-server zabbix-agent httpd

9.为Centos7配置IP地址。

centos7配置IP地址

10.配置Zabbix前端

连接到新安装的Zabbix前端:http://10.10.1.88/zabbix

 

 

 

 

 

zabbix网页登录

如果浏览器进不去,一直报错,尝试换个浏览器。

在浏览器输入http://zabbix服务器ip/zabbix/index.php,输入管理员用户名Admin(区分大小写),默认密码zabbix,点击登入即可。

 

11.设置成中文页面

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值