当前位置:网站首页>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 .
边栏推荐
- Teach you how to write the first MCU program hand in hand
- Control the operation of the test module through the panel in canoe (primary)
- 通过bat脚本配置系统环境变量
- Simple solution to phpjm encryption problem free phpjm decryption tool
- Why can't TN-C use 2p circuit breaker?
- 17 医疗挂号系统_【微信支付】
- Zsh configuration file
- Download address of canoe, download and activation of can demo 16, and appendix of all canoe software versions
- Canoe CAPL file operation directory collection
- MySQL实战优化高手07 生产经验:如何对生产环境中的数据库进行360度无死角压测?
猜你喜欢
16 医疗挂号系统_【预约下单】
The 32-year-old fitness coach turned to a programmer and got an offer of 760000 a year. The experience of this older coder caused heated discussion
CAPL脚本中关于相对路径/绝对路径操作的几个傻傻分不清的内置函数
嵌入式開發中的防禦性C語言編程
颜值爆表,推荐两款JSON可视化工具,配合Swagger使用真香
在CANoe中通过Panel面板控制Test Module 运行(高级)
max-flow min-cut
Write your own CPU Chapter 10 - learning notes
The replay block of canoe still needs to be combined with CAPL script to make it clear
Counter attack of noodles: redis asked 52 questions in a series, with detailed pictures and pictures. Now the interview is stable
随机推荐
MySQL实战优化高手04 借着更新语句在InnoDB存储引擎中的执行流程,聊聊binlog是什么?
Contest3145 - the 37th game of 2021 freshman individual training match_ C: Tour guide
C杂讲 浅拷贝 与 深拷贝
Function description of shell command parser
Routes and resources of AI
Redis集群方案应该怎么做?都有哪些方案?
Nc17 longest palindrome substring
The governor of New Jersey signed seven bills to improve gun safety
如何让shell脚本变成可执行文件
MySQL實戰優化高手04 借著更新語句在InnoDB存儲引擎中的執行流程,聊聊binlog是什麼?
Listen to my advice and learn according to this embedded curriculum content and curriculum system
VH6501学习系列文章
Installation de la pagode et déploiement du projet flask
Tianmu MVC audit I
C miscellaneous lecture continued
单片机实现模块化编程:思维+实例+系统教程(实用程度令人发指)
The 32-year-old fitness coach turned to a programmer and got an offer of 760000 a year. The experience of this older coder caused heated discussion
MySQL实战优化高手07 生产经验:如何对生产环境中的数据库进行360度无死角压测?
在CANoe中通过Panel面板控制Test Module 运行(初级)
Regular expressions are actually very simple