当前位置:   article > 正文

Zabbix5部署并添加主机

Zabbix5部署并添加主机

目录

一.准备数据库服务

1.下载进入mysql

2.创建zabbix用户和权限

3.引入初始数据库

二.部署zabbix-server

1.下载软件

2.为zabbix配置数据库

3.配置前端和php

4.修改本设备的Server、ServerActive、Hostname(选做)

三.浏览器测试

1.填写注册信息

2.登录

四.手动添加主机

1.主机配置

2.页面操作

五.为主机添加监控项

1.本步骤完成后的样式

2.查看资源表


主机信息

main-192.168.2.130

servera-192.168.2.131

serverb-192.168.2.132

一.准备数据库服务

1.下载进入mysql

  1. [root@main ~ ]#tar -xvf mysql-5.7.43-1.el7.x86_64.rpm-bundle.tar -C /usr/local/src/
  2. [root@main src]# ll
  3. total 557208
  4. -rw-r--r-- 1 7155 31415 32652444 Jun 22 2023 mysql-community-client-5.7.43-1.el7.x86_64.rpm
  5. -rw-r--r-- 1 7155 31415   320780 Jun 22 2023 mysql-community-common-5.7.43-1.el7.x86_64.rpm
  6. -rw-r--r-- 1 7155 31415   4969828 Jun 22 2023 mysql-community-devel-5.7.43-1.el7.x86_64.rpm
  7. -rw-r--r-- 1 7155 31415 48586584 Jun 22 2023 mysql-community-embedded-5.7.43-1.el7.x86_64.rpm
  8. -rw-r--r-- 1 7155 31415 23314208 Jun 22 2023 mysql-community-embedded-compat-5.7.43-1.el7.x86_64.rpm
  9. -rw-r--r-- 1 7155 31415 134413980 Jun 22 2023 mysql-community-embedded-devel-5.7.43-1.el7.x86_64.rpm
  10. -rw-r--r-- 1 7155 31415   3091092 Jun 22 2023 mysql-community-libs-5.7.43-1.el7.x86_64.rpm
  11. -rw-r--r-- 1 7155 31415   1266220 Jun 22 2023 mysql-community-libs-compat-5.7.43-1.el7.x86_64.rpm
  12. -rw-r--r-- 1 7155 31415 193030448 Jun 22 2023 mysql-community-server-5.7.43-1.el7.x86_64.rpm
  13. -rw-r--r-- 1 7155 31415 128921364 Jun 22 2023 mysql-community-test-5.7.43-1.el7.x86_64.rpm
  14. [root@main src]# yum localinstall mysql* -y #本地安装
  15. systemctl start mysqld
  16. [root@main src]# grep password /var/log/mysqld.log
  17. 2024-04-12T11:55:24.321030Z 1 [Note] A temporary password is generated for root@localhost: snkr(j;B!4gZ
  18. [root@main src]# mysql -uroot -p #使用临时密码登录
  19. mysql: [Warning] Using a password on the command line interface can be insecure.
  20. Welcome to the MySQL monitor. Commands end with ; or \g.
  21. Your MySQL connection id is 1216
  22. Server version: 5.7.43 MySQL Community Server (GPL)
  23. Copyright (c) 2000, 2023, Oracle and/or its affiliates.
  24. Oracle is a registered trademark of Oracle Corporation and/or its
  25. affiliates. Other names may be trademarks of their respective
  26. owners.
  27. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  28. mysql> alter user 'root'@'localhost' identified by 'Slb@317418'; #登录过后更改root密码

2.创建zabbix用户和权限

  1. mysql> create database zabbix character set utf8 collate utf8_bin;    
  2. mysql> create user zabbix@localhost identified by 'Slb@317418';
  3. mysql> grant all privileges on zabbix.* to zabbix@localhost;
  4. mysql> set global log_bin_trust_function_creators = 1;
  5. mysql> exit;
  6. [root@main doc]# cd zabbix-server-mysql-5.0.42/
  7. [root@main zabbix-server-mysql-5.0.42]# ll
  8. total 3260
  9. -rw-r--r-- 1 root root     98 Mar 25 18:10 AUTHORS
  10. -rw-r--r-- 1 root root 1255502 Mar 25 18:10 ChangeLog
  11. -rw-r--r-- 1 root root   17990 Mar 25 18:10 COPYING
  12. -rw-r--r-- 1 root root 2040341 Mar 25 18:12 create.sql.gz
  13. -rw-r--r-- 1 root root     282 Mar 25 18:10 double.sql
  14. -rw-r--r-- 1 root root     52 Mar 25 18:10 NEWS
  15. -rw-r--r-- 1 root root   1322 Mar 25 18:10 README

3.引入初始数据库

  1. [root@main doc]# zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix
  2. mysql> use zabbix;
  3. Reading table information for completion of table and column names
  4. You can turn off this feature to get a quicker startup with -A
  5. Database changed
  6. mysql> show tables;
  7. +----------------------------+
  8. | Tables_in_zabbix           |
  9. +----------------------------+
  10. | acknowledges               |
  11. | actions                   |
  12. | alerts                     |
  13. | application_discovery     |
  14. | application_prototype     |
  15. | application_template       |
  16. | applications               |
  17. | auditlog                   |
  18. | auditlog_details           |
  19. | autoreg_host               |
  20. | conditions                 |
  21. | config                     |
  22. | config_autoreg_tls         |
  23. | corr_condition             |
  24. | corr_condition_group       |
  25. | corr_condition_tag         |
  26. | corr_condition_tagpair     |
  27. | corr_condition_tagvalue   |
  28. | corr_operation             |
  29. | correlation               |
  30. | dashboard                 |
  31. | dashboard_user             |
  32. | dashboard_usrgrp           |
  33. | dbversion                 |
  34. | dchecks                   |
  35. | dhosts                     |
  36. | drules                     |
  37. | dservices                 |
  38. | escalations               |
  39. | event_recovery             |
  40. | event_suppress             |
  41. | event_tag                 |
  42. | events                     |
  43. | expressions               |
  44. | functions                 |
  45. | globalmacro               |
  46. | globalvars                 |
  47. | graph_discovery           |
  48. | graph_theme               |
  49. | graphs                     |
  50. | graphs_items               |
  51. | group_discovery           |
  52. | group_prototype           |
  53. | history                   |
  54. | history_log               |
  55. | history_str               |
  56. | history_text               |
  57. | history_uint               |
  58. | host_discovery             |
  59. | host_inventory             |
  60. | host_tag                   |
  61. | hostmacro                 |
  62. | hosts                     |
  63. | hosts_groups               |
  64. | hosts_templates           |
  65. | housekeeper               |
  66. | hstgrp                     |
  67. | httpstep                   |
  68. | httpstep_field             |
  69. | httpstepitem               |
  70. | httptest                   |
  71. | httptest_field             |
  72. | httptestitem               |
  73. | icon_map                   |
  74. | icon_mapping               |
  75. | ids                       |
  76. | images                     |
  77. | interface                 |
  78. | interface_discovery       |
  79. | interface_snmp             |
  80. | item_application_prototype |
  81. | item_condition             |
  82. | item_discovery             |
  83. | item_preproc               |
  84. | item_rtdata               |
  85. | items                     |
  86. | items_applications         |
  87. | lld_macro_path             |
  88. | lld_override               |
  89. | lld_override_condition     |
  90. | lld_override_opdiscover   |
  91. | lld_override_operation     |
  92. | lld_override_ophistory     |
  93. | lld_override_opinventory   |
  94. | lld_override_opperiod     |
  95. | lld_override_opseverity   |
  96. | lld_override_opstatus     |
  97. | lld_override_optag         |
  98. | lld_override_optemplate   |
  99. | lld_override_optrends     |
  100. | maintenance_tag           |
  101. | maintenances               |
  102. | maintenances_groups       |
  103. | maintenances_hosts         |
  104. | maintenances_windows       |
  105. | mappings                   |
  106. | media                     |
  107. | media_type                 |
  108. | media_type_message         |
  109. | media_type_param           |
  110. | module                     |
  111. | opcommand                 |
  112. | opcommand_grp             |
  113. | opcommand_hst             |
  114. | opconditions               |
  115. | operations                 |
  116. | opgroup                   |
  117. | opinventory               |
  118. | opmessage                 |
  119. | opmessage_grp             |
  120. | opmessage_usr             |
  121. | optemplate                 |
  122. | problem                   |
  123. | problem_tag               |
  124. | profiles                   |
  125. | proxy_autoreg_host         |
  126. | proxy_dhistory             |
  127. | proxy_history             |
  128. | regexps                   |
  129. | rights                     |
  130. | screen_user               |
  131. | screen_usrgrp             |
  132. | screens                   |
  133. | screens_items             |
  134. | scripts                   |
  135. | service_alarms             |
  136. | services                   |
  137. | services_links             |
  138. | services_times             |
  139. | sessions                   |
  140. | slides                     |
  141. | slideshow_user             |
  142. | slideshow_usrgrp           |
  143. | slideshows                 |
  144. | sysmap_element_trigger     |
  145. | sysmap_element_url         |
  146. | sysmap_shape               |
  147. | sysmap_url                 |
  148. | sysmap_user               |
  149. | sysmap_usrgrp             |
  150. | sysmaps                   |
  151. | sysmaps_elements           |
  152. | sysmaps_link_triggers     |
  153. | sysmaps_links             |
  154. | tag_filter                 |
  155. | task                       |
  156. | task_acknowledge           |
  157. | task_check_now             |
  158. | task_close_problem         |
  159. | task_data                 |
  160. | task_remote_command       |
  161. | task_remote_command_result |
  162. | task_result               |
  163. | timeperiods               |
  164. | trends                     |
  165. | trends_uint               |
  166. | trigger_depends           |
  167. | trigger_discovery         |
  168. | trigger_tag               |
  169. | triggers                   |
  170. | users                     |
  171. | users_groups               |
  172. | usrgrp                     |
  173. | valuemaps                 |
  174. | widget                     |
  175. | widget_field               |
  176. +----------------------------+
  177. 166 rows in set (0.00 sec)
  178. mysql> set global log_bin_trust_function_creators = 0;
  179. mysql> exit;

二.部署zabbix-server

参照官网步骤进行下载Zabbix

 

1.下载软件

  1. [root@main ~]# rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm && yum clean all
  2. [root@main ~]# yum install zabbix-server-mysql zabbix-agent centos-release-scl
  3. # 安装Zabbix server,Web前端,agent,frontend
  4. [root@main ~]# vim /etc/yum.repos.d/zabbix.repo   #将zabbix的前端仓库打开
  5. [root@main ~]# yum install zabbix-web-mysql-scl zabbix-nginx-conf-scl

 

2.为zabbix配置数据库

[root@main ~]# vim /etc/zabbix/zabbix_server.conf   #配置好zabbix用户密码

3.配置前端和php

[root@main ~]# vim /etc/opt/rh/rh-nginx116/nginx/conf.d/zabbix.conf  #选用8080端口

 

  1. [root@main ~]# vim /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf #添加nginx,更改时区为上海
  2. [root@main ~]# systemctl restart zabbix-server zabbix-agent rh-nginx116-nginx rh-php72-php-fpm
  3. [root@main ~]# systemctl enable zabbix-server zabbix-agent rh-nginx116-nginx rh-php72-php-fpm

4.修改本设备的Server、ServerActive、Hostname(选做)

  1. [root@main ~]# vim /etc/zabbix/zabbix_agentd.conf
  2. Server-192.168.2.130
  3. ServerActive-192.168.2.130
  4. Hostname-main

三.浏览器测试

没有注释nginx中的“location /”的话应该是IP:8080/zabbix/setup.php

我这注释了就直接IP:8080跳转到setup.php了

 

1.填写注册信息 

初始用户名和密码是Admin和zabbix

 

2.登录

在用户设置处修改密码、语言、主题颜色等

 

四.手动添加主机

servera和serverb同样操作

1.主机配置

  1. [root@main ~]# scp /etc/yum.repos.d/zabbix.repo servera:/etc/yum.repos.d/
  2. [root@main ~]# scp /etc/yum.repos.d/zabbix.repo serverb:/etc/yum.repos.d/
  3. [root@servera ~]# vim /etc/yum.repos.d/zabbix.repo #修改仓库

 

  1. [root@servera ~]# yum install -y zabbix-agent2.x86_64
  2. [root@servera ~]# vim /etc/zabbix/zabbix_agentd.conf #将Server和ServerActive修改为main的地址,Hostname修改为servera/serverb自己的hostname,和后面再面板上添加主机名称一致
  3. [root@servera ~]# cat /etc/zabbix/zabbix_agentd.conf | grep Server=192
  4. Server=192.168.2.130
  5. [root@servera ~]# cat /etc/zabbix/zabbix_agentd.conf | grep ServerActive=192
  6. ServerActive=192.168.2.130
  7. [root@servera ~]# cat /etc/zabbix/zabbix_agentd.conf | grep Hostname=
  8. # Hostname=
  9. Hostname=servera
  10. [root@serverb ~]# cat /etc/zabbix/zabbix_agentd.conf | grep Server=192
  11. Server=192.168.2.130
  12. [root@serverb ~]# cat /etc/zabbix/zabbix_agentd.conf | grep ServerActive=192
  13. ServerActive=192.168.2.130
  14. [root@serverb ~]# cat /etc/zabbix/zabbix_agentd.conf | grep Hostname=
  15. # Hostname=
  16. Hostname=serverb

2.页面操作

配置->主机->创建主机,填充你主机的名称、IP、端口->添加完成

 

五.为主机添加监控项

1.本步骤完成后的样式

点击主机名进入配置

点击模版

 

链接模版并进行更新应用

 

2.查看资源表

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家小花儿/article/detail/423122
推荐阅读
相关标签
  

闽ICP备14008679号