当前位置:网站首页>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 .
边栏推荐
- How does the single chip microcomputer execute the main function from power on reset?
- Some thoughts on the study of 51 single chip microcomputer
- MySQL实战优化高手02 为了执行SQL语句,你知道MySQL用了什么样的架构设计吗?
- Cmooc Internet + education
- Several silly built-in functions about relative path / absolute path operation in CAPL script
- 宝塔的安装和flask项目部署
- How to make shell script executable
- 在CANoe中通過Panel面板控制Test Module 運行(初級)
- vscode 常用的指令
- Constants and pointers
猜你喜欢
17 medical registration system_ [wechat Payment]
[CV] target detection: derivation of common terms and map evaluation indicators
C杂讲 动态链表操作 再讲
嵌入式開發中的防禦性C語言編程
Sichuan cloud education and double teacher model
The replay block of canoe still needs to be combined with CAPL script to make it clear
Docker MySQL solves time zone problems
MySQL combat optimization expert 03 uses a data update process to preliminarily understand the architecture design of InnoDB storage engine
Hugo blog graphical writing tool -- QT practice
History of object recognition
随机推荐
Canoe CAPL file operation directory collection
[CV] target detection: derivation of common terms and map evaluation indicators
CANoe仿真功能之自动化序列(Automation Sequences )
MySQL实战优化高手11 从数据的增删改开始讲起,回顾一下Buffer Pool在数据库里的地位
Some thoughts on the study of 51 single chip microcomputer
How can I take a shortcut to learn C language in college
寶塔的安裝和flask項目部署
The real future of hardware engineers may not be believed by you if I say so
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
Elk project monitoring platform deployment + deployment of detailed use (II)
NLP路线和资源
Compress decompress
竞赛vscode配置指南
PR 2021 quick start tutorial, first understanding the Premiere Pro working interface
Learning SCM is of great help to society
Tianmu MVC audit II
max-flow min-cut
C杂讲 文件 初讲
四川云教和双师模式
Jar runs with error no main manifest attribute