当前位置:网站首页>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 .
边栏推荐
- 17 medical registration system_ [wechat Payment]
- CAPL 脚本打印函数 write ,writeEx ,writeLineEx ,writeToLog ,writeToLogEx ,writeDbgLevel 你真的分的清楚什么情况下用哪个吗?
- Nc17 longest palindrome substring
- NLP routes and resources
- C miscellaneous dynamic linked list operation
- [one click] it only takes 30s to build a blog with one click - QT graphical tool
- Canoe cannot automatically identify serial port number? Then encapsulate a DLL so that it must work
- 零基础学习单片机切记这四点要求,少走弯路
- Some thoughts on the study of 51 single chip microcomputer
- What should the redis cluster solution do? What are the plans?
猜你喜欢
CANoe仿真功能之自动化序列(Automation Sequences )
MySQL实战优化高手02 为了执行SQL语句,你知道MySQL用了什么样的架构设计吗?
Teach you how to write the first MCU program hand in hand
Jar runs with error no main manifest attribute
学习单片机对社会的帮助是很大的
jar运行报错no main manifest attribute
Automation sequences of canoe simulation functions
Release of the sample chapter of "uncover the secrets of asp.net core 6 framework" [200 pages /5 chapters]
Cmooc Internet + education
Carolyn Rosé博士的社交互通演讲记录
随机推荐
Automation sequences of canoe simulation functions
Nc29 search in two-dimensional array
C#/. Net phase VI 01C Foundation_ 01: running environment, process of creating new C program, strict case sensitivity, meaning of class library
四川云教和双师模式
A new understanding of RMAN retention policy recovery window
简单解决phpjm加密问题 免费phpjm解密工具
Which is the better prospect for mechanical engineer or Electrical Engineer?
嵌入式开发中的防御性C语言编程
Single chip microcomputer realizes modular programming: Thinking + example + system tutorial (the degree of practicality is appalling)
jar运行报错no main manifest attribute
Function description of shell command parser
NLP routes and resources
A necessary soft skill for Software Test Engineers: structured thinking
112 pages of mathematical knowledge sorting! Machine learning - a review of fundamentals of mathematics pptx
MySQL实战优化高手06 生产经验:互联网公司的生产环境数据库是如何进行性能测试的?
MySQL实战优化高手11 从数据的增删改开始讲起,回顾一下Buffer Pool在数据库里的地位
寶塔的安裝和flask項目部署
再有人问你数据库缓存一致性的问题,直接把这篇文章发给他
Installation de la pagode et déploiement du projet flask
美新泽西州州长签署七项提高枪支安全的法案