【运维知识进阶篇】zabbix5.0稳定版详解1(安装+部署+添加服务器+拆分数据库)(一)

简介: 【运维知识进阶篇】zabbix5.0稳定版详解1(安装+部署+添加服务器+拆分数据库)

本篇文章介绍zabbix监控,监控是对我们操作系统进行不间断的监控,这是软件生命周期非常重要的一环,可以做到事前告警,事后根据监控内容排查问题(金丝雀,监控重要指标),有问题的时候,运维需要管理运维债务(在软件开发过程中积累的一些技术债务)


监控内容

我们需要监控硬件(磁盘df -h,内存free,磁盘IO,负载CPU,网络),软件服务(端口、进程、状态),业务层面(监控业务数据,订单量,注册用户,充值用户),只要是有值,zabbix都能监控,核心功能就是自定义监控。

监控工具

zabbix 硬件 服务状态 自定义监控

Nagions 网络产品 交换机 路由器 中型大型公司使用

Cacti 流量

Open-Falcon 小米公司自研

prometheus 监控kubernetes docker,比zabbix更好

监控宝等等

Zabbix安装

服务端:10.0.0.71(配置与监控数量有关,企业中一般是8G内存,4核或6核)

客户端:10.0.0.7,10.0.0.8

系统版本为CentOS7.9

1、配置yum源

1. rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
2. yum clean all

2、安装zabbix服务

yum -y install zabbix-server-mysql zabbix-agent

3、安装scl源,更好兼容已经安装的软件包,避免把系统搞烂

yum -y install centos-release-scl

4、开启前端的仓库

1. [root@Zabbix ~]# cat /etc/yum.repos.d/zabbix.repo
2. [zabbix]
3. name=Zabbix Official Repository - $basearch
4. baseurl=http://repo.zabbix.com/zabbix/5.0/rhel/7/$basearch/
5. enabled=1
6. gpgcheck=1
7. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
8. 
9. [zabbix-frontend]
10. name=Zabbix Official Repository frontend - $basearch
11. baseurl=http://repo.zabbix.com/zabbix/5.0/rhel/7/$basearch/frontend
12. enabled=1            #开这里
13. gpgcheck=1
14. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
15. 
16. [zabbix-debuginfo]
17. name=Zabbix Official Repository debuginfo - $basearch
18. baseurl=http://repo.zabbix.com/zabbix/5.0/rhel/7/$basearch/debuginfo/
19. enabled=0
20. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
21. gpgcheck=1
22. 
23. [zabbix-non-supported]
24. name=Zabbix Official Repository non-supported - $basearch
25. baseurl=http://repo.zabbix.com/non-supported/rhel/7/$basearch/
26. enabled=1
27. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX
28. gpgcheck=1

5、安装php和apache前端

yum -y install zabbix-web-mysql-scl zabbix-apache-conf-scl

6、安装mariadb

1. yum -y install mariadb-server
2. systemctl start mariadb
3. systemctl enable mariadb

7、配置zabbix数据库

1. [root@Zabbix ~]# mysql -uroot
2. Welcome to the MariaDB monitor.  Commands end with ; or \g.
3. Your MariaDB connection id is 2
4. Server version: 5.5.68-MariaDB MariaDB Server
5. 
6. Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
7. 
8. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
9. 
10. MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin;
11. Query OK, 1 row affected (0.00 sec)
12. 
13. MariaDB [(none)]> create user zabbix@localhost identified by 'zabbix';
14. Query OK, 0 rows affected (0.00 sec)
15. 
16. MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@localhost;
17. Query OK, 0 rows affected (0.00 sec)
18. 
19. MariaDB [(none)]> set global log_bin_trust_function_creators = 1;
20. Query OK, 0 rows affected (0.00 sec)
21. 
22. MariaDB [(none)]> quit;
23. Bye

8、导入数据库,初始化数据

1. [root@Zabbix ~]# zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix
2. Enter password: zabbix

可以进去检查一下

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

9、再次配置数据库

1. [root@Zabbix ~]# mysql -uroot
2. Welcome to the MariaDB monitor.  Commands end with ; or \g.
3. Your MariaDB connection id is 8
4. Server version: 5.5.68-MariaDB MariaDB Server
5. 
6. Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
7. 
8. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
9. 
10. MariaDB [(none)]> set global log_bin_trust_function_creators = 0;
11. Query OK, 0 rows affected (0.00 sec)
12. 
13. MariaDB [(none)]> quit
14. Bye

10、修改zabbix连接数据库的信息

1. [root@Zabbix ~]# egrep ^DB /etc/zabbix/zabbix_server.conf
2. DBName=zabbix
3. DBUser=zabbix
4. DBPassword=zabbix    #取消注释

11、修改时区

1. [root@Zabbix ~]# tail -1 /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf
2. php_value[date.timezone] = Asia/Shanghai

12、启动zabbix进程

1. [root@Zabbix ~]# systemctl restart zabbix-server zabbix-agent httpd rh-php72-php-fpm
2. [root@Zabbix ~]# systemctl enable zabbix-server zabbix-agent httpd rh-php72-php-fpm

13、浏览器访问安装

相关实践学习
每个IT人都想学的“Web应用上云经典架构”实战
本实验从Web应用上云这个最基本的、最普遍的需求出发,帮助IT从业者们通过“阿里云Web应用上云解决方案”,了解一个企业级Web应用上云的常见架构,了解如何构建一个高可用、可扩展的企业级应用架构。
MySQL数据库入门学习
本课程通过最流行的开源数据库MySQL带你了解数据库的世界。   相关的阿里云产品:云数据库RDS MySQL 版 阿里云关系型数据库RDS(Relational Database Service)是一种稳定可靠、可弹性伸缩的在线数据库服务,提供容灾、备份、恢复、迁移等方面的全套解决方案,彻底解决数据库运维的烦恼。 了解产品详情: https://www.aliyun.com/product/rds/mysql 
目录
相关文章
|
运维 监控 关系型数据库
AI 时代的 MySQL 数据库运维解决方案
本文探讨了大模型与MySQL数据库运维结合所带来的变革,介绍了构建结构化运维知识库、选择合适的大模型、设计Prompt调用策略、开发MCP Server以及建立监控优化闭环等关键步骤。通过将自然语言处理能力与数据库运维相结合,实现了故障智能诊断、SQL自动优化等功能,显著提升了MySQL运维效率和准确性。
1081 18
|
存储 Oracle 关系型数据库
服务器数据恢复—光纤存储上oracle数据库数据恢复案例
一台光纤服务器存储上有16块FC硬盘,上层部署了Oracle数据库。服务器存储前面板2个硬盘指示灯显示异常,存储映射到linux操作系统上的卷挂载不上,业务中断。 通过storage manager查看存储状态,发现逻辑卷状态失败。再查看物理磁盘状态,发现其中一块盘报告“警告”,硬盘指示灯显示异常的2块盘报告“失败”。 将当前存储的完整日志状态备份下来,解析备份出来的存储日志并获得了关于逻辑卷结构的部分信息。
|
人工智能 运维 关系型数据库
数据库运维:mysql 数据库迁移方法-mysqldump
本文介绍了MySQL数据库迁移的方法与技巧,重点探讨了数据量大小对迁移方式的影响。对于10GB以下的小型数据库,推荐使用mysqldump进行逻辑导出和source导入;10GB以上可考虑mydumper与myloader工具;100GB以上则建议物理迁移。文中还提供了统计数据库及表空间大小的SQL语句,并讲解了如何使用mysqldump导出存储过程、函数和数据结构。通过结合实际应用场景选择合适的工具与方法,可实现高效的数据迁移。
1845 1
|
12月前
|
Ubuntu 安全 关系型数据库
安装与配置MySQL 8 on Ubuntu,包括权限授予、数据库备份及远程连接指南
以上步骤提供了在Ubuntu上从头开始设置、配置、授权、备份及恢复一个基础但完整的MySQL环境所需知识点。
1230 7
|
Ubuntu 关系型数据库 Linux
Linux数据库安装
本文介绍了在CentOS 8.0和Ubuntu 22.04系统上安装、配置和启动MariaDB数据库服务器的详细步骤。包括通过`yum`和`apt`包管理器安装MariaDB服务,启动并检查服务运行状态,设置root用户密码以及连接数据库的基本操作。此外,还展示了如何在Ubuntu上更新软件包列表、安装依赖项,并验证MariaDB的版本和运行状态。通过这些步骤,用户可以成功部署并初始化MariaDB环境,为后续数据库管理与应用开发奠定基础。
970 61
|
运维 监控 关系型数据库
AI 时代的 MySQL 数据库运维解决方案
本方案将大模型与MySQL运维深度融合,构建智能诊断、SQL优化与知识更新的自动化系统。通过知识库建设、大模型调用策略、MCP Server开发及监控闭环设计,全面提升数据库运维效率与准确性,实现从人工经验到智能决策的跃迁。
1292 27
|
SQL 关系型数据库 MySQL
MySQL下载安装全攻略!小白也能轻松上手,从此数据库不再难搞!
这是一份详细的MySQL安装与配置教程,适合初学者快速上手。内容涵盖从下载到安装的每一步操作,包括选择版本、设置路径、配置端口及密码等。同时提供基础操作指南,如数据库管理、数据表增删改查、用户权限设置等。还介绍了备份恢复、图形化工具使用和性能优化技巧,帮助用户全面掌握MySQL的使用方法。附带常见问题解决方法,保姆级教学让你无忧入门!
1490 21
MySQL下载安装全攻略!小白也能轻松上手,从此数据库不再难搞!
|
机器学习/深度学习 SQL 运维
数据库出问题还靠猜?教你一招用机器学习优化运维,稳得一批!
数据库出问题还靠猜?教你一招用机器学习优化运维,稳得一批!
588 4
|
运维 NoSQL 容灾
告别运维噩梦:手把手教你将自建 MongoDB 平滑迁移至云数据库
程序员为何逃离自建MongoDB?扩容困难、运维复杂、高可用性差成痛点。阿里云MongoDB提供分钟级扩容、自动诊断与高可用保障,助力企业高效运维、降本增效,实现数据库“无感运维”。
|
Oracle 关系型数据库 数据库
数据库数据恢复—服务器异常断电导致Oracle数据库报错的数据恢复案例
Oracle数据库故障: 某公司一台服务器上部署Oracle数据库。服务器意外断电导致数据库报错,报错内容为“system01.dbf需要更多的恢复来保持一致性”。该Oracle数据库没有备份,仅有一些断断续续的归档日志。 Oracle数据库恢复流程: 1、检测数据库故障情况; 2、尝试挂起并修复数据库; 3、解析数据库文件; 4、导出并验证恢复的数据库文件。

热门文章

最新文章

推荐镜像

更多