当前位置:网站首页>MySQL combat optimization expert 09 production experience: how to deploy a monitoring system for a database in a production environment?
MySQL combat optimization expert 09 production experience: how to deploy a monitoring system for a database in a production environment?
2022-07-06 10:06:00 【Office template library material frog】
1、 The database of production environment can't run naked !
We have explained the knowledge related to the pressure measurement of the database to you before , Presumably, you just need to use the knowledge we explain , In your own company , Even if the DBA group team 、QA The team can't provide you with professional database pressure testing technical support , But after you get a database in your hand , In fact, you can also use various tools And orders , It is very good to complete the pressure test of the database on a machine .
You should know very well , What kind of configuration is a machine , After deploying a database , utilize sysbench How many tables and data volumes have been constructed , then How many threads are simulated during pressure testing , When the hardware load of the machine is within an acceptable range , Database QPS and TPS How high can the pressure be measured .
At this time, you can roughly understand how much your database can bear at most during peak periods QPS and TPS 了 .
But after the pressure test , Does everyone just want to start developing your Java System ? Connect your system directly to MySQL Go up and carry out various CRUD Of SQL language sentence ? Then he began to write all kinds of Java Code and SQL sentence , After writing, find QA To test , Then deploy to the online production environment , Then everything is big Lucky , Regardless of the database ?
This practice may be the same for many companies and teams at present , But if you just do this, it's absolutely impossible . Because in fact, we need to improve the online system Perfect monitoring , Not just for you Java The system monitors , You have to monitor your database , Including yes CPU、 Memory 、 The Internet 、 disk IO、 Slow search Inquiry 、QPS、TPS Monitoring of .
Because if you don't do any monitoring on your database , Then maybe your database CPU The load is already very high , Or disk IO The limit has been reached , You don't even know Avenue , As a result, you still run your Java System , One day, your database may suddenly hang up, and you don't react !
So today we will take you step by step to build a visual monitoring platform for the production environment database , We will be based on Prometheus+Grafana To build .
Of course, in the company , If you want to build a unified visual monitoring platform for the database , This job is often DBA The team is responsible for , But anyway , Here we are You should also have a certain understanding of the technology of visual monitoring of this database .
2、 A brief introduction Prometheus and Grafana What is it?
Let's give you a brief introduction Prometheus and Grafana What are the two systems .
Simply speaking ,Prometheus In fact, it is a monitoring data acquisition and storage system , He can use the monitoring data acquisition component ( such as mysql_exporter) From you designated MySQL Collect the monitoring data he needs from the database , Then he has a time series database , He will put the collected monitoring data into his own time sequence According to the library , In fact, the essence is to store it in disk files .
We collected MySQL The monitoring data is not enough , Now we need to look at some reports composed of these data , So you need to use Grafana 了 ,Grafana It is a visual monitoring data display system , He can turn Prometheus Collected a large number of MySQL The monitoring data is displayed in various exquisite newspapers surface , Let us see intuitively MySQL Monitoring of .
In fact, it is not only the database monitoring that can be used Prometheus+Grafana The combination of , For all kinds of things you have developed Java System 、 Middleware system , You can use this Set of combinations to carry out visual monitoring , Nothing more than letting Prometheus To collect your monitoring data , And then use Grafana It's just a report .
3、 Installation and startup Prometheus
I told you before , Let's prepare one by ourselves linux machine , If you are windows laptop , You can install one by yourself linux virtual machine . We are based on a linux Machine to deploy Prometheus and Grafana, as for MySQL Installation , This is very simple , It is easy for everyone to search on the Internet .
First of all, you need to download 3 Compressed packages , Link below :
http://cactifans.hi-www.com/prometheus/
You can download the following two compressed packages , here prometheus It is used to deploy the monitoring system itself , then node_exporter It's for collecting MySQL Count According to the machine where the library is located CPU、 Memory 、 The Internet 、 Disk and other monitoring data :
prometheus-2.1.0.linux-amd64.tar.gz node_exporter-0.15.2.linux-amd64.tar.gz
Then you can download the third compressed package through the following link :mysqld_exporter-0.10.0.linux-amd64.tar.gz, This mysqld_exporter Just It's for collecting MySQL Some monitoring data of the database itself , such as SQL performance 、 Number of connections :
https://github.com/prometheus/mysqld_exporter/releases/download/v0.10.0/mysqld_exporter-0.10.0.linux-amd64.tar.gz
Then you need to unzip the above packages , Just follow my order below :
mkdir /data mkdir /root
tar xvf prometheus-2.1.0.linux-amd64.tar -C /data
tar xf node_exporter-0.15.2.linux-amd64.tar -C /root
tar xf mysqld_exporter-0.10.0.linux-amd64.tar.gz -C /root
cd /data
mv prometheus-2.1.0.linux-amd64/ prometheus
cd /prometheus
vi prometheus.yml, I'm going to modify prometheus Configuration file for , Actually, it's mainly in scrape_configs Now add a large section of customized configuration , because Because he needs to collect MySQL The database itself and MySQL Monitoring data of the machine :
scrape_configs:
- file_sd_configs:
-files:
- host.yml
job_name: Host
metrics_path: /metrics
relabel_configs:
- source_labels: [__address__] regex: (.*)
target_label: instance
replacement: $1
- source_labels: [__address__] regex: (.*)
target_label: __address__
replacement: $1:9100
- file_sd_configs:
- files:
- mysql.yml
job_name: MySQL
metrics_path: /metrics
relabel_configs:
- source_labels: [__address__] regex: (.*)
target_label: instance
replacement: $1
- source_labels: [__address__] regex: (.*)
target_label: __address__
replacement: $1:9104
- job_name: prometheus static_configs:
- targets:
- localhost: 9090
After the above configuration file is written , You can start it Prometheus 了 , But let's look at the configuration information above several times , Because I'm not very square when writing articles then , They are all directly knocked out by hand , There may be a few configuration errors , If you find something wrong with the configuration file , Tell me in the backstage comment area in time .
Then you have to /data/prometheus Directory , To execute the startup command :
/data/prometheus/prometheus --storage.tsdb.retention=30d &, there 30d It means that your monitoring data is retained 30 Days of . Start it up after , It can be accessed in the browser 9090 Check the port number prometheus The home page of .
Because we deploy and install Prometheus and Grafana There are many processes , So it is divided into two articles , In the second article updated synchronously today , Will put the rest Of Grafana The installation and deployment process of , And the process of monitoring configuration and acquisition .
边栏推荐
- The programming ranking list came out in February. Is the result as you expected?
- MySQL ERROR 1040: Too many connections
- 颜值爆表,推荐两款JSON可视化工具,配合Swagger使用真香
- Automation sequences of canoe simulation functions
- 华南技术栈CNN+Bilstm+Attention
- Zsh configuration file
- Single chip microcomputer realizes modular programming: Thinking + example + system tutorial (the degree of practicality is appalling)
- C杂讲 浅拷贝 与 深拷贝
- Function description of shell command parser
- 14 医疗挂号系统_【阿里云OSS、用户认证与就诊人】
猜你喜欢
[CV] target detection: derivation of common terms and map evaluation indicators
Control the operation of the test module through the panel in canoe (primary)
15 医疗挂号系统_【预约挂号】
C miscellaneous lecture continued
112 pages of mathematical knowledge sorting! Machine learning - a review of fundamentals of mathematics pptx
华南技术栈CNN+Bilstm+Attention
51单片机进修的一些感悟
Can I learn PLC at the age of 33
宝塔的安装和flask项目部署
Target detection -- yolov2 paper intensive reading
随机推荐
C miscellaneous two-way circular linked list
华南技术栈CNN+Bilstm+Attention
Which is the better prospect for mechanical engineer or Electrical Engineer?
宝塔的安装和flask项目部署
Installation of pagoda and deployment of flask project
CANoe不能自动识别串口号?那就封装个DLL让它必须行
Control the operation of the test module through the panel in canoe (Advanced)
The replay block of canoe still needs to be combined with CAPL script to make it clear
Why is 51+ assembly in college SCM class? Why not come directly to STM32
竞赛vscode配置指南
Release of the sample chapter of "uncover the secrets of asp.net core 6 framework" [200 pages /5 chapters]
软件测试工程师必备之软技能:结构化思维
C杂讲 文件 初讲
简单解决phpjm加密问题 免费phpjm解密工具
The appearance is popular. Two JSON visualization tools are recommended for use with swagger. It's really fragrant
Preliminary introduction to C miscellaneous lecture document
Elk project monitoring platform deployment + deployment of detailed use (II)
Canoe cannot automatically identify serial port number? Then encapsulate a DLL so that it must work
如何让shell脚本变成可执行文件
Compress decompress