zabbix部署

zabbix部署

首先安装依赖包

[root@localhost ~]# yum -y install net-snmp-devel libevent-devel

[root@localhost ~]# ls
anaconda-ks.cfg         httpd-2.4.43.tar.bz2
apr-1.7.0               initial-setup-ks.cfg
apr-1.7.0.tar.bz2       mysql-5.7.33-linux-glibc2.12-x86_64.tar.gz
apr-util-1.6.1          yh
apr-util-1.6.1.tar.bz2  zabbix-5.2.6.tar.gz
httpd-2.4.43
[root@localhost ~]# tar xf zabbix-5.2.6.tar.gz 

[root@localhost zabbix-5.2.6]# useradd -r -M -s /sbin/nolonin  zabbix


[root@localhost zabbix-5.2.6]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 5
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.01 sec)

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

mysql> grant all privileges on zabbix.* to 'zabbix'@'localhost';
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

查看一下创建的数据库有没有东西

[root@localhost zabbix-5.2.6]# mysql -e 'show tables from zabbix;'

查看解压包里面的东西

[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

恢复下列数据到zabbix数据库内

[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> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| zabbix             |
+--------------------+
2 rows in set (0.00 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)

编译配置文件

[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
安装

[root@localhost zabbix-5.2.6]# cd /usr/local/etc/
[root@localhost etc]# ls
zabbix_agentd.conf  zabbix_agentd.conf.d  zabbix_server.conf  zabbix_server.conf.d

编写配置文件,把密码加上去

[root@localhost etc]# vim zabbix_server.conf

DBPassword=zabbix123!

启动zabbix失败,有一个问题

[root@localhost etc]# zabbix_server 
zabbix_server: error while loading shared libraries: libmysqlclient.so.20: cannot open shared object file: No such file or directory

需要这样解决
[root@localhost mysql]# echo "/usr/local/mysql/lib" >> /etc/ld.so.conf
[root@localhost mysql]# ldconfig
[root@localhost mysql]# zabbix_server 
[root@localhost mysql]# 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        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        128              0.0.0.0:111              0.0.0.0:*                
LISTEN   0        128                 [::]:22                  [::]:*                
LISTEN   0        5                  [::1]:631                 [::]:*                
LISTEN   0        80                     *:3306                   *:*                
LISTEN   0        128                 [::]:111                 [::]:*                
LISTEN   0        128                    *:80                     *:*                
[root@localhost mysql]# zabbix_agentd 
[root@localhost mysql]# 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        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        128              0.0.0.0:111              0.0.0.0:*                
LISTEN   0        128                 [::]:22                  [::]:*                
LISTEN   0        5                  [::1]:631                 [::]:*                
LISTEN   0        80                     *:3306                   *:*                
LISTEN   0        128                 [::]:111                 [::]:*                
LISTEN   0        128                    *:80                     *:*                

zabbix web界面安装前配置

[root@localhost ~]# cd zabbix-5.2.6/
[root@localhost zabbix-5.2.6]# ls
aclocal.m4  compile        config.sub    depcomp     Makefile     missing  ui
AUTHORS     conf           configure     include     Makefile.am  NEWS
bin         config.guess   configure.ac  INSTALL     Makefile.in  README
build       config.log     COPYING       install-sh  man          sass
ChangeLog   config.status  database      m4          misc         src
[root@localhost zabbix-5.2.6]# cd
[root@localhost ~]# cd /usr/local/apache/
[root@localhost apache]# cd htdocs/
[root@localhost htdocs]# ls
index.html  zdj
[root@localhost htdocs]# mv zdj 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

把ui的东西复制到zabbix里面
这里的zabbix是原先的zdj

root@localhost zabbix-5.2.6]# cp -r ui/* /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

更改属组主

chown -R apache.apache /usr/local/apache/htdocs/

更改虚拟主机的文件

[root@localhost zabbix]# vim /etc/httpd24/extra/vhosts.conf 
<VirtualHost *:80>
    DocumentRoot "/usr/local/apache/htdocs/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>

[root@localhost zabbix]# 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 zabbix]# 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        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        128              0.0.0.0:111              0.0.0.0:*                
LISTEN   0        128                 [::]:22                  [::]:*                
LISTEN   0        5                  [::1]:631                 [::]:*                
LISTEN   0        80                     *:3306                   *:*                
LISTEN   0        128                 [::]:111                 [::]:*                
LISTEN   0        128                    *:80                     *:*        

更改这些参数,否则页面出错

[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 ~]# systemctl restart php-fpm

在这里插入图片描述

在这里插入图片描述

添加权限


mysql> grant all on *.* to 'zabbix'@'192.168.98.33' identified by 'zabbix123!';
Query OK, 0 rows affected, 1 warning (0.01 sec)

在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值