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

本文涉及的产品
云数据库 RDS MySQL Serverless,0.5-2RCU 50GB
云数据库 RDS MySQL Serverless,价值2615元额度,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、浏览器访问安装

相关实践学习
基于CentOS快速搭建LAMP环境
本教程介绍如何搭建LAMP环境,其中LAMP分别代表Linux、Apache、MySQL和PHP。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助     相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
目录
相关文章
|
21天前
|
网络安全 Apache
Apache服务器安装SSL证书
Apache服务器安装SSL证书
25 0
|
1月前
|
弹性计算 运维 Serverless
ECS安装问题之安装NETCAT如何解决
ECS(Elastic Compute Service,弹性计算服务)是云计算服务提供商提供的一种基础云服务,允许用户在云端获取和配置虚拟服务器。以下是ECS服务使用中的一些常见问题及其解答的合集:
|
23天前
|
关系型数据库 MySQL 数据库
卸载云服务器上的 MySQL 数据库
卸载云服务器上的 MySQL 数据库
38 0
|
6天前
|
存储 分布式计算 Hadoop
基于Hadoop分布式数据库HBase1.0部署及使用
基于Hadoop分布式数据库HBase1.0部署及使用
|
6天前
|
监控 安全 Linux
Linux系统之安装ServerBee服务器监控工具
【4月更文挑战第22天】Linux系统之安装ServerBee服务器监控工具
45 2
|
7天前
|
存储 分布式计算 NoSQL
MongoDB的简介和安装(在服务器上)
MongoDB的简介和安装(在服务器上)
22 0
|
17天前
|
关系型数据库 MySQL 数据库连接
Django(四):Django项目部署数据库及服务器配置详解(MySQL)
Django(四):Django项目部署数据库及服务器配置详解(MySQL)
70 11
|
27天前
|
存储 缓存 NoSQL
Redis 服务器指南:高性能内存数据库的完整使用指南
Redis 服务器指南:高性能内存数据库的完整使用指南
|
27天前
|
弹性计算 关系型数据库 MySQL
阿里云数据库服务器价格表,数据库创建、连接和使用教程
阿里云数据库使用流程包括购买和管理。选择所需数据库类型如MySQL,完成实名认证后购买,配置CPU、内存和存储。确保数据库地域与ECS相同以允许内网连接。创建数据库和账号,设置权限。通过DMS登录数据库,使用账号密码连接。同一VPC内的ECS需添加至白名单以进行内网通信。参考官方文档进行详细操作。
129 3
|
29天前
|
Ubuntu Linux 虚拟化
【Linux】ubuntu安装samba服务器
【Linux】ubuntu安装samba服务器

推荐镜像

更多