当前位置:网站首页>MySQL combat optimization expert 10 production experience: how to deploy visual reporting system for database monitoring system?
MySQL combat optimization expert 10 production experience: how to deploy visual reporting system for database monitoring system?
2022-07-06 10:06:00 【Office template library material frog】
1、 Deploy Grafana
In the last article, we explained that the installation is complete Prometheus, Then let's continue Explain how to install Grafana, First, download from the following address grafana-4.6.3.linux-x64.tar.gz, Then execute the following commands step by step , Complete his startup .
https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana-4.6.3.linux-x64.tar.gz
tar xf grafana-4.6.3.linux-x64.tar.gz -C /data/prometheus cd /data/prometheus
mv grafana-4.6.3 grafana
cd /data/prometheus/grafana ./bin/grafana-server &
Then it's done grafana Start of , Then it can be accessed through a browser 3000 port , The default username and password are admin/admin. And then Grafana Left There is one in the side menu bar Data Sources, Click a button inside Add data source, Is to add a data source .
Then enter the name of your data source in the interface Prometheus, The type is Prometheus,HTTP URL The address is http://127.0.0.1:9090, Other Just use the default configuration , Next Grafana Will automatically from Prometheus Get monitoring data and display .
Then you need to install Grafana Instrument cluster components , First you need to download grafana-dashboards-1.6.1.tar.gz, Just use the following link :https://github.com/percona/grafana-dashboards/archive/v1.6.1.tar.gz.
Then execute a series of commands to install grafana-dashboard Components .
tar xvf grafana-dashboards-1.6.1.tar.gz cd grafana-dashboards-1.6.1
updatedb
locate json |grep dashboards/
At this time, you will see a lot of json file , It's corresponding to various dashboards json The configuration file , You can take these json Profile passed WinSCP And Class tools from linux Drag it onto your machine windows Come on the computer , Because you need to upload them through the browser .
And then grafana On the page , You can see that there is one on the top Home Button , Click to enter an interface , You'll see one Import Dashboard Press button , That is to say, some dashboards can be imported , At this time, you need to import a lot of json file .
You click Upload json file Button , There will be an interface for you to upload one by one json file , Then you upload it one by one , next grafana Will appear in A lot of dashboards , For example, machine CPU Usage dashboard , Disk performance dashboard , Disk space dashboard ,MySQL Monitoring instrument cluster , wait .
2、 add to MySQL Monitoring of the machine
First of all, if we want to make Prometheus Go collect MySQL Machine monitoring data (CPU、 Memory 、 disk 、 The Internet , wait ), And then let Grafana Can exhibit Show , Then you must add Prometheus Yes MySQL Monitoring of the machine .
First of all, it has to be in MySQL Unzip and start on the machine node_exporter, After this startup, there is a linux process , He will automatically collect this one linux On the machine CPU、 disk 、 Memory 、 Various monitoring data such as network , In fact, you can understand the essence through what we explained before linux command , You can collect everything What do you want? linux Machine monitoring data .
tar xf node_exporter-0.15.2.linux-amd64.tar
mv node_exporter-0.15.2.linux-amd64 node_exporter cd node_exporter
nohup ./node_exporter &
Up to this point , We are in MySQL A node_exporter 了 , He will automatically collect this machine CPU、 disk 、 Inside save 、 Network monitoring data , But this is not enough , because Prometheus The monitoring of this machine has not been added on .
At this time, we should still remember , Before that Prometheus Of yml In profile , We have defined a host Monitoring item , He is used to monitor the machine , He The configuration file is host.yml, At this point, we can edit this host.yml The configuration file , Join in mysql The address of the machine is ok
vi host.yml
- labels:
service: test targets:
- 127.0.0.1
next Prometheus Will follow MySQL Deployed on the machine node_exporter communicate , Continuously obtain the monitoring data of this machine , Write your own Stored in the time series database . Then we can open Grafana The page of , At this point, you can see the relevant performance monitoring of this machine .
3、 add to MySQL Database monitoring
Then we also need to be in MySQL Start another one on your machine mysqld_exporter The components of , He is responsible for collecting MySQL Some monitoring data of the database itself According to the , Let's just look at the following instructions .
tar xf mysqld_exporter-0.10.0.linux-amd64.tar
mv mysqld_exporter-0.10.0.linux-amd64 mysqld_exporter
Then you need to configure some environment variables , To set up mysqld_exporter Address information of the database to be monitored , See the account number configured below 、 Password and address and port Number
export DATA_SOURCE_NAME='root:[email protected](127.0.0.1:3306)/'
echo "export DATA_SOURCE_NAME='root:[email protected](127.0.0.1:3306)/'" >> /etc/profile
Then start mysqld_exporter
cd mysqld_exporter
nohup ./mysqld_exporter --collect.info_schema.processlist --collect.info_schema.innodb_tablespaces -- collect.info_schema.innodb_metrics --collect.perf_schema.tableiowaits --collect.perf_schema.indexiowaits -- collect.perf_schema.tablelocks --collect.engine_innodb_status --collect.perf_schema.file_events -- collect.info_schema.processlist --collect.binlog_size --collect.info_schema.clientstats -- collect.perf_schema.eventswaits &
The above startup command specifies a large number of options to start some monitoring collection , These orders are also my hands , Because of some inconvenient reasons in the current writing environment plain , So it can only be so , If you find any small mistakes , You can tell me in the backstage of the comment area .
And then this mysqld_exporter The process will automatically collect MySQL Own monitoring data , Then we need to be in Prometheus Configure him to go with mysqld_exporter Communication, data acquisition and storage , then Grafana To see the corresponding report .
vi /data/prometheus/mysql.yml
- labels:
service: mysql_test targets:
- 127.0.0.1
Then we are Grafana You can see MySQL All kinds of monitoring data .
4、 One assignment
Today I want to leave you a little homework , I hope you can refer to today's two articles , Set up a database monitoring system , And then you can use sysbench Do a pressure test , During the pressure test , You can have a direct look at Grafana On the machine and MySQL Monitoring indicators .
This process is not difficult , But you may encounter some operational problems , If you find any problems in the process of building , Don't post the screenshot of the error directly on the Comment area , You can check the Internet first , Where are the mistakes
If there is really a problem , I will try to solve the problem later , Then updated .
in addition , I want you to think about a problem , You can check whether the database in your company has done over-voltage testing ? Has visual monitoring been done ? How it's done ? since Some machine loads and QPS、TPS How many are they ? Whether I have a comprehensive grasp of the database ?
I hope everyone can go and have a look , Then post it in the comment area to share and exchange with you .
边栏推荐
- Simple solution to phpjm encryption problem free phpjm decryption tool
- MySQL ERROR 1040: Too many connections
- Delayed note learning
- Safety notes
- MySQL ERROR 1040: Too many connections
- Inject common SQL statement collation
- Defensive C language programming in embedded development
- Some thoughts on the study of 51 single chip microcomputer
- Why can't TN-C use 2p circuit breaker?
- C杂讲 文件 续讲
猜你喜欢
Which is the better prospect for mechanical engineer or Electrical Engineer?
Installation de la pagode et déploiement du projet flask
The 32 year old programmer left and was admitted by pinduoduo and foreign enterprises. After drying out his annual salary, he sighed: it's hard to choose
C杂讲 文件 初讲
PR 2021 quick start tutorial, first understanding the Premiere Pro working interface
CAPL 脚本对.ini 配置文件的高阶操作
51单片机进修的一些感悟
MySQL实战优化高手03 用一次数据更新流程,初步了解InnoDB存储引擎的架构设计
CAPL script printing functions write, writeex, writelineex, writetolog, writetologex, writedbglevel do you really know which one to use under what circumstances?
Why can't TN-C use 2p circuit breaker?
随机推荐
单片机实现模块化编程:思维+实例+系统教程(实用程度令人发指)
Can I learn PLC at the age of 33
flask运维脚本(长时间运行)
Teach you how to write the first MCU program hand in hand
CAPL script printing functions write, writeex, writelineex, writetolog, writetologex, writedbglevel do you really know which one to use under what circumstances?
Control the operation of the test module through the panel in canoe (primary)
C杂讲 浅拷贝 与 深拷贝
MySQL實戰優化高手04 借著更新語句在InnoDB存儲引擎中的執行流程,聊聊binlog是什麼?
Bugku web guide
手把手教您怎么编写第一个单片机程序
C杂讲 动态链表操作 再讲
History of object recognition
学习单片机对社会的帮助是很大的
Jar runs with error no main manifest attribute
vscode 常用的指令
[NLP] bert4vec: a sentence vector generation tool based on pre training
A new understanding of RMAN retention policy recovery window
Configure system environment variables through bat script
The governor of New Jersey signed seven bills to improve gun safety
Installation de la pagode et déploiement du projet flask