zabbix

部署 lamp(yum 安装)

  1. 下载 centos 和 epel 源
[root@localhost ~]# rm -f /etc/yum.repos.d/*

[root@localhost ~]# curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo

[root@localhost ~]# sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo

[root@localhost ~]# yum install -y https://mirrors.aliyun.com/epel/epel-release-latest-8.noarch.rpm

[root@localhost ~]# sed -i 's|^#baseurl=https://download.example/pub|baseurl=https://mirrors.aliyun.com|' /etc/yum.repos.d/epel*

[root@localhost ~]# sed -i 's|^metalink|#metalink|' /etc/yum.repos.d/epel*
  1. 安装 httpd
[root@localhost ~]# yum -y install httpd
  1. 安装 php
[root@localhost ~]# yum -y install php-xml.x86_64  php-json.x86_64  php-mysqlnd.x86_64  php-common.x86_64  php-fpm.x86_64  php-bcmath.x86_64  php-cli.x86_64  php.x86_64  php-gd.x86_64  php-pdo.x86_64  php-devel.x86_64
  1. 安装 mariadb
[root@localhost ~]# yum -y install mariadb-server mariadb
  1. 设置数据库服务
[root@localhost ~]# systemctl enable --now mariadb

[root@localhost ~]# mysql_secure_installation
//设置密码为redhat  全部y

[root@localhost ~]# systemctl restart mariadb
  1. 设置 httpd 服务
[root@localhost ~]# systemctl enable --now httpd
[root@localhost ~]# vim /etc/httpd/conf/httpd.conf

在这里插入图片描述

[root@localhost ~]# systemctl restart httpd
  1. 关闭防火墙
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# systemctl disable firewalld

[root@localhost ~]# vim /etc/selinux/config
......
SELINUX=disabled
......

[root@localhost ~]# setenforce 0
  1. 测试 php 页面
[root@localhost ~]# vim /etc/php.ini

在这里插入图片描述

[root@localhost ~]# vim /var/www/html/index.php
<?php
phpinfo();
?>
  1. 验证
    在这里插入图片描述

部署 zabbix

  1. yum 仓库
[root@localhost ~]# vim /etc/yum.repos.d/zabbix.repo
[aliyun]
name=aliyun
baseurl=https://mirrors.aliyun.com/zabbix/zabbix/4.4/rhel/8/x86_64/
enable=1
gpgcheck=0

[qinghua]
name=Zabbix Official Repository - $basearch
#baseurl=http://repo.zabbix.com/zabbix/3.4/rhel/7/$basearch/
baseurl=https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/4.4/rhel/8/$basearch/
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
  1. 安装 modular metadata 生成工具(第 3 步安装不成功时配置)
[root@localhost ~]# dnf -y install gcc gcc-c++ python3 python3-devel python3-createrepo_c python3-libdnf python3-libmodulemd libmodulemd
  1. 安装 zabbix
[root@localhost ~]# dnf -y install zabbix-server-mysql zabbix-web-mysql zabbix-apache-conf zabbix-agent
  1. 配置数据库并导入 zabbix 表数据
[root@localhost ~]# mysql -u root -p
Enter password: redhat
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 8
Server version: 10.3.28-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)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
+--------------------+
3 rows in set (0.001 sec)

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

MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| zabbix             |
+--------------------+
4 rows in set (0.001 sec)

MariaDB [(none)]> grant all on zabbix.* to zabbix@'localhost' identified by 'redhat';
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 ~]# zcat /usr/share/doc/zabbix-server-mysql/create.sql.gz | mysql -u zabbix -predhat zabbix

  1. 验证 zabbix 数据库数据
[root@localhost ~]# mysql -u root -p
Enter password: redhat
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 15
Server version: 10.3.28-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)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| zabbix             |
+--------------------+
4 rows in set (0.000 sec)

MariaDB [(none)]> use zabbix;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
MariaDB [zabbix]> show tables;
+----------------------------+
| Tables_in_zabbix           |
+----------------------------+
| acknowledges               |
| actions                    |
| alerts                     |
| application_discovery      |
| application_prototype      |
| application_template       |
| applications               |
| auditlog                   |
| auditlog_details           |
| autoreg_host               |
| conditions                 |
| config                     |
| config_autoreg_tls         |
| corr_condition             |
| corr_condition_group       |
| corr_condition_tag         |
| corr_condition_tagpair     |
| corr_condition_tagvalue    |
| corr_operation             |
| correlation                |
| dashboard                  |
| dashboard_user             |
| dashboard_usrgrp           |
| dbversion                  |
| dchecks                    |
| dhosts                     |
| drules                     |
| dservices                  |
| escalations                |
| event_recovery             |
| event_suppress             |
| event_tag                  |
| events                     |
| expressions                |
| functions                  |
| globalmacro                |
| globalvars                 |
| graph_discovery            |
| graph_theme                |
| graphs                     |
| graphs_items               |
| group_discovery            |
| group_prototype            |
| history                    |
| history_log                |
| history_str                |
| history_text               |
| history_uint               |
| host_discovery             |
| host_inventory             |
| host_tag                   |
| hostmacro                  |
| hosts                      |
| hosts_groups               |
| hosts_templates            |
| housekeeper                |
| hstgrp                     |
| httpstep                   |
| httpstep_field             |
| httpstepitem               |
| httptest                   |
| httptest_field             |
| httptestitem               |
| icon_map                   |
| icon_mapping               |
| ids                        |
| images                     |
| interface                  |
| interface_discovery        |
| item_application_prototype |
| item_condition             |
| item_discovery             |
| item_preproc               |
| item_rtdata                |
| items                      |
| items_applications         |
| lld_macro_path             |
| maintenance_tag            |
| maintenances               |
| maintenances_groups        |
| maintenances_hosts         |
| maintenances_windows       |
| mappings                   |
| media                      |
| media_type                 |
| media_type_param           |
| opcommand                  |
| opcommand_grp              |
| opcommand_hst              |
| opconditions               |
| operations                 |
| opgroup                    |
| opinventory                |
| opmessage                  |
| opmessage_grp              |
| opmessage_usr              |
| optemplate                 |
| problem                    |
| problem_tag                |
| profiles                   |
| proxy_autoreg_host         |
| proxy_dhistory             |
| proxy_history              |
| regexps                    |
| rights                     |
| screen_user                |
| screen_usrgrp              |
| screens                    |
| screens_items              |
| scripts                    |
| service_alarms             |
| services                   |
| services_links             |
| services_times             |
| sessions                   |
| slides                     |
| slideshow_user             |
| slideshow_usrgrp           |
| slideshows                 |
| sysmap_element_trigger     |
| sysmap_element_url         |
| sysmap_shape               |
| sysmap_url                 |
| sysmap_user                |
| sysmap_usrgrp              |
| sysmaps                    |
| sysmaps_elements           |
| sysmaps_link_triggers      |
| sysmaps_links              |
| tag_filter                 |
| task                       |
| task_acknowledge           |
| task_check_now             |
| task_close_problem         |
| task_remote_command        |
| task_remote_command_result |
| timeperiods                |
| trends                     |
| trends_uint                |
| trigger_depends            |
| trigger_discovery          |
| trigger_tag                |
| triggers                   |
| users                      |
| users_groups               |
| usrgrp                     |
| valuemaps                  |
| widget                     |
| widget_field               |
+----------------------------+
149 rows in set (0.001 sec)

MariaDB [zabbix]> exit
Bye
  1. 配置 zabbix 并启动服务
[root@localhost ~]# vim /etc/zabbix/zabbix_server.conf
ListenPort=10051		//取消注释
DBHost=localhost		//取消注释
DBPassword=redhat		//取消注释并填入内容
DBSocket=/var/lib/mysql/mysql.sock		//取消注释并填入内容
ListenIP=0.0.0.0		//取消注释

[root@localhost ~]# systemctl restart zabbix-server
[root@localhost ~]# systemctl enable zabbix-server
  1. 配置 httpd 并启动服务
[root@localhost ~]# systemctl restart httpd
[root@localhost ~]# systemctl status httpd		//确定httpd服务设置了开机自启

[root@localhost ~]# ss -antl
State     Recv-Q    Send-Q       Local Address:Port        Peer Address:Port   Process    
LISTEN    0         128                0.0.0.0:22               0.0.0.0:*                 
LISTEN    0         128                0.0.0.0:10051            0.0.0.0:*                 
LISTEN    0         80                       *:3306                   *:*                 
LISTEN    0         128                      *:80                     *:*                 
LISTEN    0         128                   [::]:22                  [::]:*                 
  1. 浏览器访问
    在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值