zabbix部署

zabbix部署

zabbix服务端安装

安装依赖包
[root@localhost ~]# yum -y install net-snmp-devel libevent-devel
上次元数据过期检查:2:35:39 前,执行于 20210513日 星期四 025302秒。
依赖关系解决。
================================================================================
 软件包                      架构   版本                        仓库       大小
================================================================================
安装:
 libevent-devel              x86_64 2.1.8-5.el8                 appstream 104 k
 net-snmp-devel              x86_64 1:5.8-20.el8                appstream 274 k
升级:
 elfutils-libelf             x86_64 0.182-3.el8                 baseos    216 k
 elfutils-libs               x86_64 0.182-3.el8                 baseos    293 k
 ima-evm-utils               x86_64 1.3.2-12.el8                baseos     64 k

下载zabbix

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
下载到本地,拖到虚拟机内

解压
[root@localhost ~]# ls
公共  文档  anaconda-ks.cfg                             zabbix-5.2.6.tar.gz
模板  下载  initial-setup-ks.cfg
视频  音乐  mysql-5.7.33-linux-glibc2.12-x86_64.tar.gz
图片  桌面  pass
[root@localhost ~]# tar xf zabbix-5.2.6.tar.gz 

创建zabbix用户和组
[root@localhost ~]# useradd -r -M -s /sbin/nologin zabbix
配置zabbix数据库
[root@localhost zabbix-5.2.6]# mysql -uroot -pZHANGde12+Jun
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.33 MySQL Community Server (GPL)

Copyright (c) 2000, 2021, 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> create database zabbix character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.22 sec)

mysql> create user 'zabbix'@'localhost' identified by 'zabbix123!';
Query OK, 0 rows affected (0.29 sec)

mysql> grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix123!';
Query OK, 0 rows affected, 2 warnings (0.00 sec)

mysql> quit
Bye

[root@localhost zabbix-5.2.6]# mysql -uroot -pZHANGde12+Jun -e 'show databases;'
mysql: [Warning] Using a password on the command line interface can be insecure.
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
| zabbix             |
+--------------------+
[root@localhost zabbix-5.2.6]# mysql -uroot -pZHANGde12+Jun -e 'show tables from zabbix;'
mysql: [Warning] Using a password on the command line interface can be insecure.


[root@localhost zabbix-5.2.6]# ls
aclocal.m4  ChangeLog     config.sub    database  install-sh   man      README
AUTHORS     compile       configure     depcomp   m4           misc     sass
bin         conf          configure.ac  include   Makefile.am  missing  src
build       config.guess  COPYING       INSTALL   Makefile.in  NEWS     ui
[root@localhost zabbix-5.2.6]# cd database/
[root@localhost database]# ls
elasticsearch  Makefile.am  Makefile.in  mysql  oracle  postgresql  sqlite3
[root@localhost database]# cd mysql/
[root@localhost mysql]# ls
data.sql  double.sql  images.sql  Makefile.am  Makefile.in  schema.sql
[root@localhost mysql]# ll
总用量 13384
-rw-r--r--. 1 yh yh 11535807 329 05:21 data.sql
-rw-r--r--. 1 yh yh      282 329 05:02 double.sql
-rw-r--r--. 1 yh yh  1978341 329 04:33 images.sql
-rw-r--r--. 1 yh yh      482 329 05:02 Makefile.am
-rw-r--r--. 1 yh yh    15982 329 05:21 Makefile.in
-rw-r--r--. 1 yh yh   160579 329 05:21 schema.sql

[root@localhost mysql]# mysql -uzabbix -pzabbix123! zabbix < schema.sql
mysql: [Warning] Using a password on the command line interface can be insecure.
[root@localhost mysql]# mysql -uzabbix -pzabbix123! zabbix < images.sql 
mysql: [Warning] Using a password on the command line interface can be insecure.
[root@localhost mysql]# mysql -uzabbix -pzabbix123! zabbix < data.sql 
mysql: [Warning] Using a password on the command line interface can be insecure.


[root@localhost mysql]# mysql -uzabbix -pzabbix123!
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 14
Server version: 5.7.33 MySQL Community Server (GPL)

Copyright (c) 2000, 2021, 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> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| zabbix             |
+--------------------+
2 rows in set (0.01 sec)

mysql> 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
mysql> 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        |
| interface_snmp             |
| item_application_prototype |
| item_condition             |
| item_discovery             |
| item_parameter             |
| item_preproc               |
| item_rtdata                |
| items                      |
| items_applications         |
| lld_macro_path             |
| lld_override               |
| lld_override_condition     |
| lld_override_opdiscover    |
| lld_override_operation     |
| lld_override_ophistory     |
| lld_override_opinventory   |
| lld_override_opperiod      |
| lld_override_opseverity    |
| lld_override_opstatus      |
| lld_override_optag         |
| lld_override_optemplate    |
| lld_override_optrends      |
| maintenance_tag            |
| maintenances               |
| maintenances_groups        |
| maintenances_hosts         |
| maintenances_windows       |
| mappings                   |
| media                      |
| media_type                 |
| media_type_message         |
| media_type_param           |
| module                     |
| 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                     |
| role                       |
| role_rule                  |
| 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_data                  |
| task_remote_command        |
| task_remote_command_result |
| task_result                |
| timeperiods                |
| trends                     |
| trends_uint                |
| trigger_depends            |
| trigger_discovery          |
| trigger_queue              |
| trigger_tag                |
| triggers                   |
| users                      |
| users_groups               |
| usrgrp                     |
| valuemaps                  |
| widget                     |
| widget_field               |
+----------------------------+
170 rows in set (0.00 sec)

//数据导入成功
编译安装zabbix
[root@localhost zabbix-5.2.6]# ./configure --enable-server \
> --enable-agent \
> --with-mysql \
> --with-net-snmp \
> --with-libcurl \
> --with-libxml2

[root@localhost zabbix-5.2.6]# make install
zabbix服务端配置
[root@localhost zabbix-5.2.6]# cd /usr/local/etc/
[root@localhost etc]# ls
zabbix_agentd.conf    zabbix_server.conf
zabbix_agentd.conf.d  zabbix_server.conf.d

[root@localhost etc]# vim zabbix_server.conf  //修改服务端配置文件 //设置数据库信息

DBPassword=zabbix123!       //设置zabbix数据库连接密码

//启动zabbix_server和zabbix_agentd
[root@localhost etc]# zabbix_server 
[root@localhost etc]# ss -antl
State   Recv-Q   Send-Q     Local Address:Port      Peer Address:Port  Process  
LISTEN  0        128              0.0.0.0:111            0.0.0.0:*              
LISTEN  0        32         192.168.122.1:53             0.0.0.0:*              
LISTEN  0        128              0.0.0.0:22             0.0.0.0:*              
LISTEN  0        5              127.0.0.1:631            0.0.0.0:*              
LISTEN  0        128              0.0.0.0:10051          0.0.0.0:*              
LISTEN  0        128              0.0.0.0:9000           0.0.0.0:*              
LISTEN  0        80                     *:3306                 *:*              
LISTEN  0        128                 [::]:111               [::]:*              
LISTEN  0        128                    *:80                   *:*              
LISTEN  0        128                 [::]:22                [::]:*              
LISTEN  0        5                  [::1]:631               [::]:*              
[root@localhost etc]# zabbix_agentd 
[root@localhost etc]# ss -antl
State   Recv-Q   Send-Q     Local Address:Port      Peer Address:Port  Process  
LISTEN  0        128              0.0.0.0:111            0.0.0.0:*              
LISTEN  0        32         192.168.122.1:53             0.0.0.0:*              
LISTEN  0        128              0.0.0.0:22             0.0.0.0:*              
LISTEN  0        5              127.0.0.1:631            0.0.0.0:*              
LISTEN  0        128              0.0.0.0:10050          0.0.0.0:*              
LISTEN  0        128              0.0.0.0:10051          0.0.0.0:*              
LISTEN  0        128              0.0.0.0:9000           0.0.0.0:*              
LISTEN  0        80                     *:3306                 *:*              
LISTEN  0        128                 [::]:111               [::]:*              
LISTEN  0        128                    *:80                   *:*              
LISTEN  0        128                 [::]:22                [::]:*              
LISTEN  0        5                  [::1]:631               [::]:*              

zabbix服务端web界面安装与配置

zabbix web界面安装前配置
//修改/etc/php.ini的配置并重启php-fpm
[root@localhost ~]# sed -ri 's/(post_max_size =).*/\1 16M/g' /etc/php.ini
[root@localhost ~]# sed -ri 's/(max_execution_time =).*/\1 300/g' /etc/php.ini
[root@localhost ~]# sed -ri 's/(max_input_time =).*/\1 300/g' /etc/php.ini
[root@localhost ~]# sed -i '/;date.timezone/a date.timezone = Asia/Shanghai' /etc/php.ini
[root@localhost ~]# service php-fpm restart

[root@localhost ~]# cd /usr/local/apache/
[root@localhost apache]# cd htdocs/
[root@localhost htdocs]# ls
index.html  yh
[root@localhost htdocs]# mv yh zabbix
[root@localhost htdocs]# ls
index.html  zabbix
[root@localhost htdocs]# cd zabbix/
[root@localhost zabbix]# ls
index.php
[root@localhost zabbix]# rm -rf index.php 
[root@localhost zabbix]# pwd
/usr/local/apache/htdocs/zabbix
[root@localhost zabbix]# ll
总用量 0

[root@localhost zabbix-5.2.6]# cp -r ui/* /usr/local/apache/htdocs/zabbix/
[root@localhost ~]# cd /usr/local/apache/htdocs/zabbix
[root@localhost zabbix]# ls
actionconf.php       host_discovery.php           overview.php
api_jsonrpc.php      hostgroups.php               queue.php
app                  hostinventoriesoverview.php  report2.php
assets               hostinventories.php          report4.php
audio                host_prototypes.php          robots.txt
auditacts.php        hosts.php                    screenconf.php
browserwarning.php   httpconf.php                 screenedit.php
chart2.php           httpdetails.php              screen.import.php
chart3.php           image.php                    screens.php
chart4.php           imgstore.php                 services.php
chart5.php           include                      setup.php
chart6.php           index_http.php               slideconf.php
chart7.php           index.php                    slides.php
chart.php            index_sso.php                srv_status.php
composer.json        items.php                    sysmap.php
composer.lock        js                           sysmaps.php
conf                 jsLoader.php                 templates.php
conf.import.php      jsrpc.php                    toptriggers.php
correlation.php      local                        tr_events.php
discoveryconf.php    locale                       trigger_prototypes.php
disc_prototypes.php  maintenance.php              triggers.php
favicon.ico          map.import.php               vendor
graphs.php           map.php                      zabbix.php
history.php          modules

[root@localhost zabbix]# chown -R apache.apache /usr/local/apache/htdocs/

//配置apache虚拟机主机

[root@localhost zabbix]# vim /httpd24/extra/vhosts.conf 

<VirtualHost *:80>
    DocumentRoot "/usr/local/apache/htdos/zabbix"
    ServerName localhost:80
    ProxyRequests Off
    ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/usr/local/apache/htdocs/zabbix/$1
    <Directory "/usr/local/apache/htdocs/zabbix">
        Options none
        AllowOverride none
        Require all granted
    </Directory>
</VirtualHost>

//设置zabbix/conf目录的权限,让zabbix有权限生成配置文件zabbix.conf.php

[root@localhost ~]# chmod 777 /usr/local/apache/htdocs/zabbix/conf
[root@localhost ~]# ll -d /usr/local/apache/htdocs/zabbix/conf
drwxrwsrwx. 3 apache apache 94 513 06:59 /usr/local/apache/htdocs/zabbix/conf

[root@localhost htdocs]# vim /httpd24/httpd.conf 
ServerName localhost:80
    ProxyRequests Off
    ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/usr/local/apache/htdocs/zabbix/$1
    <Directory "/usr/local/apache/htdocs/zabbix">
        Options none
        AllowOverride none
        Require all granted
    </Directory>
</VirtualHost>
//重启apache
[root@localhost htdocs]# apachectl restart
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain. Set the 'ServerName' directive globally to suppress this message

[root@localhost htdocs]# mysql -uroot -pZHANGde12+Jun

mysql> grant all on *.* to 'zabbix'@'192.168.147.44' identified by 'zabbix123!';    //给权限
Query OK, 0 rows affected, 1 warning (0.47 sec)

登录zabbix

用户名:Admin
密码:zabbix
在这里插入图片描述

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值