WO2022099832A1 - Cloud environment-based sql monitoring method and apparatus - Google Patents

Cloud environment-based sql monitoring method and apparatus Download PDF

Info

Publication number
WO2022099832A1
WO2022099832A1 PCT/CN2020/134071 CN2020134071W WO2022099832A1 WO 2022099832 A1 WO2022099832 A1 WO 2022099832A1 CN 2020134071 W CN2020134071 W CN 2020134071W WO 2022099832 A1 WO2022099832 A1 WO 2022099832A1
Authority
WO
WIPO (PCT)
Prior art keywords
jdbc
monitoring
sql
target
data
Prior art date
Application number
PCT/CN2020/134071
Other languages
French (fr)
Chinese (zh)
Inventor
崔粉霞
董爱强
井长军
王莹
陈渲颖
Original Assignee
北京中电普华信息技术有限公司
国网信息通信产业集团有限公司
国家电网有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 北京中电普华信息技术有限公司, 国网信息通信产业集团有限公司, 国家电网有限公司 filed Critical 北京中电普华信息技术有限公司
Publication of WO2022099832A1 publication Critical patent/WO2022099832A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/3003Monitoring arrangements specially adapted to the computing system or computing system component being monitored
    • G06F11/302Monitoring arrangements specially adapted to the computing system or computing system component being monitored where the computing system component is a software system
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/3051Monitoring arrangements for monitoring the configuration of the computing system or of the computing system component, e.g. monitoring the presence of processing resources, peripherals, I/O links, software programs
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/242Query formulation
    • G06F16/2433Query languages
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/25Integrating or interfacing systems involving database management systems
    • G06F16/252Integrating or interfacing systems involving database management systems between a Database Management System and a front-end application

Definitions

  • the present application relates to the field of Internet technologies, and in particular, to a cloud-based structured query language (Structured Query Language, SQL) monitoring method and device.
  • SQL Structured Query Language
  • SQL monitoring can effectively track the execution of SQL, so that the system has a reliable basis for analysis.
  • the SQL monitoring component records the execution of SQL, and can find out what kind of error occurred in which operation, so as to quickly locate and solve the problem.
  • the SQL execution status is recorded, but not all types of databases have system tables to record the SQL execution status.
  • the mySQL type database does not have a system table to record the SQL execution status. situation, or implement SQL monitoring through the data connection pool of the data source, which is not suitable for other data sources and is not universal.
  • the present application provides a cloud-based SQL monitoring method and device, to solve the problem in the existing SQL monitoring process, such as querying the system table provided by the oracle database itself, recording the SQL execution situation, but not all Type databases have system tables to record SQL execution.
  • mySQL type databases do not have system tables to record SQL execution, or SQL monitoring is implemented through the data connection pool of the data source.
  • This implementation method is not suitable for other data sources. question of generality.
  • the specific plans are as follows:
  • a cloud-based SQL monitoring method including:
  • the execution of SQL in the target database is monitored based on the target Java Database Connectivity (JDBC) to obtain monitoring data, wherein the target JDBC is based on reconstructing the original JDBC and Add the listener to get, the original JDBC exists in the JDK;
  • JDBC Java Database Connectivity
  • the monitoring data is recorded in the database for the user to call.
  • the execution of SQL in the target database is monitored based on the target JDBC to obtain monitoring data, including:
  • the execution of SQL in the target database is monitored, and the monitoring data is obtained.
  • the above method is based on reconstructing the original JDBC and adding a listener to obtain the target JDBC, including:
  • the above method optionally, further includes:
  • the capacity and the performance indicators are displayed.
  • the above method optionally, further includes:
  • the monitoring data is displayed in the form of multiple data sources.
  • the above method optionally, further includes: the target database may exist in a microservice or a monolithic system.
  • a SQL monitoring device based on a cloud environment comprising:
  • the monitoring module is configured to monitor the execution of SQL in the target database based on the target JDBC when the SQL monitoring trigger instruction is detected to obtain monitoring data, wherein the target JDBC is obtained by reconstructing the original JDBC and adding a listener. , the original JDBC exists in the JDK;
  • the recording and calling module is configured to record the monitoring data into the database for the user to call.
  • the monitoring module includes:
  • an acquisition unit configured to acquire the data identifier in the SQL monitoring trigger instruction
  • a determining unit configured to determine a target database in each database according to the data identifier
  • the monitoring unit is configured to monitor the execution of SQL in the target database based on the proxy target JDBC method to obtain monitoring data.
  • the target JDBC is obtained by refactoring the original JDBC and adding a listener, including:
  • an acquiring and creating unit configured to acquire data source configuration information, and create a data source driver based on the data source configuration information
  • connection establishment unit configured to establish a connection between the data source driver and the original JDBC in the JDK
  • the adding unit is configured to add a listener to the original JDBC after the connection is successful to obtain the target JDBC.
  • the above-mentioned device optionally, also includes:
  • a monitoring module configured to monitor the capacity of the target database and the performance indicators of the corresponding server
  • a display module configured to display the capacity and the performance index.
  • the present application includes the following advantages:
  • the present application discloses a method and device for SQL monitoring based on a cloud environment.
  • the method includes: when a SQL monitoring trigger instruction is detected, monitoring the execution of SQL in a target database based on target JDBC to obtain monitoring data, wherein: The target JDBC is obtained by reconstructing the original JDBC and adding a listener, and the original JDBC exists in the JDK; the monitoring data is recorded in the database for the user to call.
  • monitoring is performed based on the target JDBC. Since JDBC is a linked database package that comes with JDK, it is a common method for all Java systems. JDBC is the interface of JDK itself, which is compatible with all database types and data sources. At the same time, the components are in the form of ordinary jar packages, not bound to any platform, and compatible with various operating systems, making the monitoring process universal.
  • FIG. 1 is a flowchart of a cloud-based SQL monitoring method disclosed in an embodiment of the present application
  • FIG. 2 is a schematic diagram of a JDBC reconstruction and adding monitoring process disclosed by an embodiment of the present application
  • FIG. 3 is a schematic processing flow diagram of a cloud-based SQL monitoring method disclosed in an embodiment of the present application.
  • FIG. 4 is a schematic diagram of a SQL monitoring architecture group of a microservice system in a cloud environment disclosed by an embodiment of the present application;
  • FIG. 5 is a schematic diagram of a traditional single system SQL monitoring architecture group disclosed in an embodiment of the application.
  • FIG. 6 is a structural block diagram of a cloud-based SQL monitoring apparatus disclosed in an embodiment of the present application.
  • the present application discloses a SQL monitoring method and device based on a cloud environment, which is applied in the SQL monitoring process.
  • technologies such as cloud platform, distributed service and distributed database have been used in various business systems. It is widely used, and the system is becoming larger and larger.
  • the performance and stability of the system are important indicators of the maturity of the system. Anomaly detection powered by machine learning will become smarter, helping systems find bottlenecks that slow down applications.
  • the intuitive interface visualizes every aspect of the system that affects performance: SQL statements, execution plans, blocking, deadlocks, and more. Second-to-second data collection for real-time and historical analysis enables the system to pinpoint problems and find the root cause of performance issues.
  • SQL monitoring can effectively track the execution of SQL, so that the system has a reliable basis for analysis.
  • the SQL monitoring component records the execution of SQL for us, so that we can find out what kind of error occurred in which operation at a glance, so as to quickly locate and solve the problem.
  • the execution process of the existing SQL monitoring process is mainly based on the following methods:
  • the Oracle database has a system table to record the execution of SQL, and you can analyze and view some indicators of the operation of SQL, such as query volume, query time, and abnormal SQL operation records.
  • Druid which monitors the execution of SQL through the data source
  • Druid is only applicable to this data source linking method.
  • data source linking methods such as DBCP, C3P0, etc., which cannot implement SQL execution monitoring.
  • SQL monitoring is often designed based on an enterprise's own application system database.
  • other businesses in the application system, or other businesses' businesses in the same field, or application systems in different fields require other databases or database connections method, it needs to be redesigned.
  • These targeted SQL monitoring are neither flexible nor universal. Not a general problem.
  • an embodiment of the present application provides a SQL monitoring method based on a cloud environment, and the execution process of the monitoring method is shown in FIG. 1 , including steps:
  • the JDBC in the JDK is refactored in advance and monitoring is added.
  • the process is shown in FIG. 2 , the data source configuration information is obtained, the data source driver is created based on the data source configuration information, and the original JDBC driver is represented.
  • the data source driver is connected with the original JDBC in the JDK.
  • the data source object is created by using the configuration information of the target JDBC driver and the data source.
  • SQL monitoring intercepts the execution status of the target database, including SQL execution status such as addition, deletion, modification, and query.
  • the SQL monitoring trigger instruction is detected, the execution status of SQL in the target database based on the target JDBC is monitored, and the result is obtained.
  • the process of monitoring data is described, wherein the SQL monitoring trigger instruction may be clicking a button or inputting a certain keyword, etc.
  • the specific existence form of the SQL monitoring trigger instruction is not limited , Monitoring adopts JDBC-driven proxy mode, which avoids the differences between different database types and different data sources.
  • JDBC is the interface of JDK itself and is compatible with all database types and data sources. At the same time, the components are in the form of ordinary jar packages, not bound to any platform, and compatible with various operating systems.
  • the specific SQL monitoring process is as follows: obtain the data identifier contained in the SQL monitoring trigger instruction, wherein the data identifier is used to distinguish different types of databases in different microservices, preferably, each microservice corresponds to a database, Different microservices can be the same type of database, and in each database, the target database is determined according to the data identifier, and the execution of SQL in the target database is monitored based on the method of proxy target JDBC to obtain monitoring data.
  • the monitoring data is recorded in the database for the user to call, and the monitoring data includes: the start time of execution, the end time, the execution interval, whether the SQL is slow, the number of returned rows, the number of executions, SQL monitoring data such as the number of errors, SQL information, and error information, preferably, the monitoring data is displayed in the form of multiple data sources.
  • the microservice can monitor the capacity of the database and the performance indicators of the server deployed by the microservice, including the server's CPU, memory, disk space, remaining space, JVM space and other interfaces, and display the microservices monitored by SQL.
  • JDBC is obtained by refactoring the original JDBC and adding a listener, the original JDBC exists in the JDK; the monitoring data is recorded in the database for the user to call.
  • monitoring is performed based on the target JDBC.
  • JDBC is a linked database package that comes with JDK, it is a common method for all Java systems.
  • JDBC is the interface of JDK itself, compatible with all database types and data sources.
  • the components are in the form of ordinary jar packages, not bound to any platform, and compatible with various operating systems, making the monitoring process universal.
  • FIG. 3 the processing flow based on the above-mentioned monitoring method is shown in FIG. 3 .
  • a SQL monitoring system based on a cloud environment is designed.
  • the microservice architecture or the traditional OSGI module architecture is a single system, whether it is ORACLE or mySQL database; whether it is C3PO or DBCP or other data sources, you can use this system to implement SQL monitoring in the cloud environment.
  • micro-application A, micro-application B, micro-application C, and micro-application D use JDBC proxy to perform SQL monitoring.
  • the database proxy records the monitoring data monitored by SQL, and stores the obtained monitoring data in the database for users to query. , statistics and analysis, etc.
  • the schematic diagram of the SQL monitoring architecture group of the microservice system in the cloud environment is shown in Figure 4, wherein the microservice A integrating the SQL monitoring component, the microservice B integrating the SQL monitoring component, and the microservice C integrating the SQL monitoring component, The monitoring data is recorded through the database, and the SQL monitoring data is displayed, counted and analyzed according to specific requirements.
  • the traditional single system SQL monitoring architecture group is shown in Figure 5.
  • the single application integrating the SQL monitoring component records the SQL monitoring data through the database. , to display, count, and analyze SQL monitoring data according to specific needs.
  • the logic diagram is different depending on the architecture of the system.
  • a monolith is one application, and a microservice is multiple applications.
  • the technical solutions of the embodiments of the present application are fully applied in the "lightweight authority" system.
  • the SQL execution status of the system is recorded through the SQL monitoring component, which has good compatibility, convenient and quick integration, greatly meets the needs of system SQL monitoring, and can be compatible with a variety of Database type, data source, operating system, system architecture, deployment environment and other business systems.
  • the monitoring method is not limited to a specific business system, and has a certain generality. Any application system that needs SQL monitoring can be considered for use. It is only a common jar package method, not bound to a business platform, and is aimed at real-time and historical analysis. Enables data collection down to the second, enabling systems to pinpoint problems and find the root cause of performance issues.
  • a SQL monitoring device based on a cloud environment is also provided.
  • the structural block diagram of the monitoring device is shown in FIG. 6 , including:
  • Monitor module 201 and record and call module 202.
  • the monitoring module 201 is configured to monitor the execution of SQL in the target database based on the target JDBC when the SQL monitoring trigger instruction is detected to obtain monitoring data, wherein the target JDBC is based on reconstructing and adding the original JDBC. The listener obtains that the original JDBC exists in the JDK;
  • the recording and calling module 202 is configured to record the monitoring data into a database for the user to call.
  • the embodiment of the present application discloses a SQL monitoring device based on a cloud environment, which includes: when a SQL monitoring trigger instruction is detected, monitoring the execution of SQL in a target database based on target JDBC to obtain monitoring data, wherein the target JDBC is obtained by refactoring the original JDBC and adding a listener, the original JDBC exists in the JDK; the monitoring data is recorded in the database for the user to call.
  • monitoring is performed based on the target JDBC. Since JDBC is a linked database package that comes with JDK, it is a common method for all Java systems. JDBC is the interface of JDK itself, which is compatible with all database types and data sources. At the same time, the components are in the form of ordinary jar packages, not bound to any platform, and compatible with various operating systems, making the monitoring process universal.
  • the monitoring module 201 includes:
  • the acquisition unit the determination unit and the monitoring unit.
  • the obtaining unit is configured to obtain the data identifier in the SQL monitoring trigger instruction
  • the determining unit is configured to determine a target database in each database according to the data identifier
  • the monitoring unit is configured to monitor the execution situation of SQL in the target database based on the proxy target JDBC method, and obtain monitoring data.
  • the target JDBC is obtained by refactoring the original JDBC and adding a listener in the monitoring module, including:
  • the acquiring and creating unit is configured to acquire data source configuration information, and create a data source driver based on the data source configuration information;
  • connection establishment unit is configured to establish a connection between the data source driver and the original JDBC in the JDK;
  • the adding unit is configured to add a listener to the original JDBC after the connection is successful to obtain the target JDBC.
  • the monitoring device further includes:
  • the listening module and the presentation module are The listening module and the presentation module.
  • the monitoring module is configured to monitor the capacity of the target database and the performance index of the corresponding server;
  • the display module is configured to display the capacity and the performance index.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Databases & Information Systems (AREA)
  • Computing Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Mathematical Physics (AREA)
  • Quality & Reliability (AREA)
  • Computational Linguistics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
  • Debugging And Monitoring (AREA)

Abstract

Disclosed in the present application are a cloud environment-based SQL monitoring method and apparatus. The method comprises: upon detecting a SQL monitoring trigger instruction, monitoring the execution of a SQL in a target database on the basis of target JDBC to obtain monitoring data, wherein the target JDBC is obtained by reconstructing original JDBC and adding a monitor, and the original JDBC is present in a JDK; and recording the monitoring data into a database for being called by a user. In the monitoring process, the monitoring is performed on the basis of the target JDBC; the JDBC is a linked database package carried by the JDK, and is a universal mode for all java systems; the JDBC is an interface of the JDK itself, and is compatible with all database types and data sources; moreover, an assembly is compatible with various operating systems in a common jar package mode, without being bound to any platform, so that the monitoring process achieves universality.

Description

一种基于云环境的SQL监控方法及装置A kind of SQL monitoring method and device based on cloud environment
相关申请的交叉引用CROSS-REFERENCE TO RELATED APPLICATIONS
本申请基于申请号为202011247020.0、申请日为2020年11月10日的中国专利申请提出,并要求该中国专利申请的优先权,该中国专利申请的全部内容在此引入本申请作为参考。This application is based on the Chinese patent application with the application number 202011247020.0 and the filing date on November 10, 2020, and claims the priority of the Chinese patent application. The entire content of the Chinese patent application is incorporated herein by reference.
技术领域technical field
本申请涉及互联网技术领域,尤其涉及一种基于云环境的结构化查询语言(Structured Query Language,SQL)监控方法及装置。The present application relates to the field of Internet technologies, and in particular, to a cloud-based structured query language (Structured Query Language, SQL) monitoring method and device.
背景技术Background technique
随着业务增长迅速,数据量越来越大,数据的种类也越来越丰富,分析人员对数据处理的响应延时要求也越来越高,传统的大数据处理工具已经无法满足业务的需求。SQL监控可以有效进行SQL执行情况跟踪,让系统有一个可靠的分析依据。SQL监控组件记录了SQL执行的情况,可以发现哪个操作发生了什么样的错误,从而快速定位解决问题。With the rapid growth of business, the amount of data is getting bigger and bigger, and the types of data are getting richer and richer, and the response delay requirements of analysts for data processing are getting higher and higher. Traditional big data processing tools can no longer meet the needs of business. . SQL monitoring can effectively track the execution of SQL, so that the system has a reliable basis for analysis. The SQL monitoring component records the execution of SQL, and can find out what kind of error occurred in which operation, so as to quickly locate and solve the problem.
现有SQL监控过程中,比如查询oracle数据库本身提供的系统表中,记录SQL执行情况,但是并不是所有类型的数据库有系统表进行记录SQL的执行情况,如mySQL类型数据库没有系统表记录SQL执行情况,或者通过数据源的数据连接池方式实现SQL监控,这种实现方式不适应其它的数据源,不具有通用性。In the existing SQL monitoring process, such as querying the system table provided by the oracle database itself, the SQL execution status is recorded, but not all types of databases have system tables to record the SQL execution status. For example, the mySQL type database does not have a system table to record the SQL execution status. situation, or implement SQL monitoring through the data connection pool of the data source, which is not suitable for other data sources and is not universal.
发明内容SUMMARY OF THE INVENTION
有鉴于此,本申请提供了一种基于云环境的SQL监控方法及装置,用 以解决现有SQL监控过程中,比如查询oracle数据库本身提供的系统表中,记录SQL执行情况,但是并不是所有类型的数据库有系统表进行记录SQL的执行情况,如mySQL类型数据库没有系统表记录SQL执行情况,或者通过数据源的数据连接池方式实现SQL监控,这种实现方式不适应其它的数据源,不具有通用性的问题。具体方案如下:In view of this, the present application provides a cloud-based SQL monitoring method and device, to solve the problem in the existing SQL monitoring process, such as querying the system table provided by the oracle database itself, recording the SQL execution situation, but not all Type databases have system tables to record SQL execution. For example, mySQL type databases do not have system tables to record SQL execution, or SQL monitoring is implemented through the data connection pool of the data source. This implementation method is not suitable for other data sources. question of generality. The specific plans are as follows:
一种基于云环境的SQL监控方法,包括:A cloud-based SQL monitoring method, including:
当检测到SQL监控触发指令时,基于目标Java数据库连接(Java Database Connectivity,JDBC)对目标数据库中SQL的执行情况进行监听,得到监听数据,其中,所述目标JDBC基于对原始JDBC进行重构并添加监听器得到,所述原始JDBC存在于JDK中;When the SQL monitoring trigger instruction is detected, the execution of SQL in the target database is monitored based on the target Java Database Connectivity (JDBC) to obtain monitoring data, wherein the target JDBC is based on reconstructing the original JDBC and Add the listener to get, the original JDBC exists in the JDK;
将所述监听数据记录到数据库中,以供用户调用。The monitoring data is recorded in the database for the user to call.
上述的方法,可选的,当检测到SQL监控触发指令时,基于目标JDBC对目标数据库中SQL的执行情况进行监听,得到监听数据,包括:In the above method, optionally, when an SQL monitoring trigger instruction is detected, the execution of SQL in the target database is monitored based on the target JDBC to obtain monitoring data, including:
获取所述SQL监控触发指令中的数据标识;Obtain the data identifier in the SQL monitoring trigger instruction;
在各个数据库中依据所述数据标识确定目标数据库;Determine the target database in each database according to the data identification;
基于代理目标JDBC的方式对目标数据库中SQL的执行情况进行监听,得到监听数据。Based on the proxy target JDBC method, the execution of SQL in the target database is monitored, and the monitoring data is obtained.
上述的方法,可选的,基于对原始JDBC进行重构并添加监听器得到所述目标JDBC,包括:The above method, optionally, is based on reconstructing the original JDBC and adding a listener to obtain the target JDBC, including:
获取数据源配置信息,基于所述数据源配置信息创建数据源驱动;Acquire data source configuration information, and create a data source driver based on the data source configuration information;
将所述数据源驱动与JDK中原始JDBC建立连接;establishing a connection between the data source driver and the original JDBC in the JDK;
连接成功后,在所述原始JDBC添加监听器,得到目标JDBC。After the connection is successful, add a listener to the original JDBC to obtain the target JDBC.
上述的方法,可选的,还包括:The above method, optionally, further includes:
监听所述目标数据库的容量和对应服务器的性能指标;Monitor the capacity of the target database and the performance index of the corresponding server;
将所述容量和所述性能指标进行展示。The capacity and the performance indicators are displayed.
上述的方法,可选的,还包括:The above method, optionally, further includes:
将所述监听数据以多数据源形式进行展示。The monitoring data is displayed in the form of multiple data sources.
上述的方法,可选的,还包括:所述目标数据库可以存在与微服务中或者单体系统中。The above method, optionally, further includes: the target database may exist in a microservice or a monolithic system.
一种基于云环境的SQL监控装置,包括:A SQL monitoring device based on a cloud environment, comprising:
监听模块,配置为当检测到SQL监控触发指令时,基于目标JDBC对目标数据库中SQL的执行情况进行监听,得到监听数据,其中,所述目标JDBC基于对原始JDBC进行重构并添加监听器得到,所述原始JDBC存在于JDK中;The monitoring module is configured to monitor the execution of SQL in the target database based on the target JDBC when the SQL monitoring trigger instruction is detected to obtain monitoring data, wherein the target JDBC is obtained by reconstructing the original JDBC and adding a listener. , the original JDBC exists in the JDK;
记录和调用模块,配置为将所述监听数据记录到数据库中,以供用户调用。The recording and calling module is configured to record the monitoring data into the database for the user to call.
上述的装置,可选的,所述监听模块包括:The above device, optionally, the monitoring module includes:
获取单元,配置为获取所述SQL监控触发指令中的数据标识;an acquisition unit, configured to acquire the data identifier in the SQL monitoring trigger instruction;
确定单元,配置为在各个数据库中依据所述数据标识确定目标数据库;a determining unit, configured to determine a target database in each database according to the data identifier;
监听单元,配置为基于代理目标JDBC的方式对目标数据库中SQL的执行情况进行监听,得到监听数据。The monitoring unit is configured to monitor the execution of SQL in the target database based on the proxy target JDBC method to obtain monitoring data.
上述的装置,可选的,所述监听模块中基于对原始JDBC进行重构并添加监听器得到所述目标JDBC,包括:In the above device, optionally, in the monitoring module, the target JDBC is obtained by refactoring the original JDBC and adding a listener, including:
获取和创建单元,配置为获取数据源配置信息,基于所述数据源配置信息创建数据源驱动;an acquiring and creating unit, configured to acquire data source configuration information, and create a data source driver based on the data source configuration information;
连接建立单元,配置为将所述数据源驱动与JDK中原始JDBC建立连接;a connection establishment unit, configured to establish a connection between the data source driver and the original JDBC in the JDK;
添加单元,配置为连接成功后,在所述原始JDBC添加监听器,得到目标JDBC。The adding unit is configured to add a listener to the original JDBC after the connection is successful to obtain the target JDBC.
上述的装置,可选的,还包括:The above-mentioned device, optionally, also includes:
监听模块,配置为监听所述目标数据库的容量和对应服务器的性能指标;a monitoring module, configured to monitor the capacity of the target database and the performance indicators of the corresponding server;
展示模块,配置为将所述容量和所述性能指标进行展示。A display module, configured to display the capacity and the performance index.
与现有技术相比,本申请包括以下优点:Compared with the prior art, the present application includes the following advantages:
本申请公开了一种基于云环境的SQL监控方法及装置,所述方法包括:当检测到SQL监控触发指令时,基于目标JDBC对目标数据库中SQL的执行情况进行监听,得到监听数据,其中,所述目标JDBC基于对原始JDBC进行重构并添加监听器得到,所述原始JDBC存在于JDK中;将所述监听数据记录到数据库中,以供用户调用。上述的监控过程中,基于目标JDBC进行监控,由于JDBC是jdk自带的链接数据库包,是所有java系统的通用方式。JDBC是JDK本身的接口,兼容所有数据库类型和数据源,同时组件已普通jar包方式,不绑定任何平台,兼容各种操作系统,使得监控过程具有通用性。The present application discloses a method and device for SQL monitoring based on a cloud environment. The method includes: when a SQL monitoring trigger instruction is detected, monitoring the execution of SQL in a target database based on target JDBC to obtain monitoring data, wherein: The target JDBC is obtained by reconstructing the original JDBC and adding a listener, and the original JDBC exists in the JDK; the monitoring data is recorded in the database for the user to call. In the above monitoring process, monitoring is performed based on the target JDBC. Since JDBC is a linked database package that comes with JDK, it is a common method for all Java systems. JDBC is the interface of JDK itself, which is compatible with all database types and data sources. At the same time, the components are in the form of ordinary jar packages, not bound to any platform, and compatible with various operating systems, making the monitoring process universal.
附图说明Description of drawings
为了更清楚地说明本申请实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the following briefly introduces the accompanying drawings required for the description of the embodiments or the prior art. Obviously, the drawings in the following description are only These are some embodiments of the present application. For those of ordinary skill in the art, other drawings can also be obtained based on these drawings without any creative effort.
图1为本申请实施例公开的一种基于云环境的SQL监控方法流程图;1 is a flowchart of a cloud-based SQL monitoring method disclosed in an embodiment of the present application;
图2为本申请实施例公开的JDBC重构和添加监听过程示意图;2 is a schematic diagram of a JDBC reconstruction and adding monitoring process disclosed by an embodiment of the present application;
图3为本申请实施例公开的一种基于云环境的SQL监控方法处理流程示意图;3 is a schematic processing flow diagram of a cloud-based SQL monitoring method disclosed in an embodiment of the present application;
图4为本申请实施例公开的一种云环境的微服务系统SQL监控架构组的示意图;4 is a schematic diagram of a SQL monitoring architecture group of a microservice system in a cloud environment disclosed by an embodiment of the present application;
图5为本申请实施例公开的一种传统单体系统SQL监控架构组的示意图;5 is a schematic diagram of a traditional single system SQL monitoring architecture group disclosed in an embodiment of the application;
图6为本申请实施例公开的一种一种基于云环境的SQL监控装置结构框图。FIG. 6 is a structural block diagram of a cloud-based SQL monitoring apparatus disclosed in an embodiment of the present application.
具体实施方式Detailed ways
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, but not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present application.
对所公开的实施例的上述说明,使本领域专业技术人员能够实现或使用本申请。对这些实施例的多种修改对本领域的专业技术人员来说将是显而易见的,本文中所定义的一般原理可以在不脱离本申请的精神或范围的情况下,在其它实施例中实现。因此,本申请将不会被限制于本文所示的这些实施例,而是要符合与本文所公开的原理和新颖特点相一致的最宽的范围。The above description of the disclosed embodiments enables any person skilled in the art to make or use the present application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, this application is not intended to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
本申请公开了一种基于云环境的SQL监控方法及装置,应用在SQL监控过程中,随着互联网技术的不断发展,云平台,分布式服务和分布式数据库等技术已经在各种业务系统中广泛应用,系统也越来越庞大,系统的性能和稳定性是系统成熟的重要指标。由机器学习提供支持的异常检测将变得更加智能,帮助系统找出让应用程序的运行速度变慢的瓶颈。直观的界面将系统中影响性能的各个方面都可视化:SQL语句、执行计划、阻塞、死锁等。针对实时和历史分析实现细致到秒的数据收集,是系统能够查明问题、找到导致性能问题的根本原因。The present application discloses a SQL monitoring method and device based on a cloud environment, which is applied in the SQL monitoring process. With the continuous development of Internet technology, technologies such as cloud platform, distributed service and distributed database have been used in various business systems. It is widely used, and the system is becoming larger and larger. The performance and stability of the system are important indicators of the maturity of the system. Anomaly detection powered by machine learning will become smarter, helping systems find bottlenecks that slow down applications. The intuitive interface visualizes every aspect of the system that affects performance: SQL statements, execution plans, blocking, deadlocks, and more. Second-to-second data collection for real-time and historical analysis enables the system to pinpoint problems and find the root cause of performance issues.
随着业务增长迅速,数据量越来越大,数据的种类也越来越丰富,分 析人员对数据处理的响应延时要求也越来越高,传统的大数据处理工具已经无法满足业务的需求。SQL监控可以有效进行SQL执行情况跟踪,让系统有一个可靠的分析依据。项目在生产环境运行的过程中,偶尔会出现一些数据库中的问题,通常我们定位问题的话只能大范围跟踪代码,效率很低。SQL监控组件为我们记录了SQL执行的情况,让我们可以一目了然的发现哪个操作发生了什么样的错误,从而快速定位解决问题。With the rapid growth of business, the amount of data is getting bigger and bigger, and the types of data are getting richer and richer, and the response delay requirements of analysts for data processing are getting higher and higher. Traditional big data processing tools can no longer meet the needs of business. . SQL monitoring can effectively track the execution of SQL, so that the system has a reliable basis for analysis. In the process of running the project in the production environment, there are occasional problems in the database. Usually, if we locate the problem, we can only track the code in a large range, which is very inefficient. The SQL monitoring component records the execution of SQL for us, so that we can find out what kind of error occurred in which operation at a glance, so as to quickly locate and solve the problem.
现有的SQL监控过程的执行过程主要基于如下方法:The execution process of the existing SQL monitoring process is mainly based on the following methods:
(1)通过数据库的系统表执行SQL监控(1) Execute SQL monitoring through the system table of the database
比如oracle数据库有系统表记录SQL的执行情况,可分析查看SQL的运行的一些指标,如查询量、查询耗时、SQL运行异常记录等信息。For example, the Oracle database has a system table to record the execution of SQL, and you can analyze and view some indicators of the operation of SQL, such as query volume, query time, and abnormal SQL operation records.
例如有些是在业务应用中实现SQL的执行情况记录,这样浸入到业务中,不便迁移,且工作量巨大。For example, some records of the execution of SQL are implemented in business applications, which is immersed in the business, inconvenient to migrate, and the workload is huge.
(2)通过数据源执行SQL监控(2) Execute SQL monitoring through the data source
例如Druid,通过数据源监控SQL的执行情况,只适用本数据源链接方式。当前有多种数据源链接方式如DBCP,C3P0等不能实现SQL执行情况监控。For example, Druid, which monitors the execution of SQL through the data source, is only applicable to this data source linking method. Currently, there are various data source linking methods such as DBCP, C3P0, etc., which cannot implement SQL execution monitoring.
现有的SQL监控过程中,比如查询oracle数据库本身提供的系统表中,记录SQL执行情况,但是并不是所有类型的数据库有系统表进行记录SQL的执行情况,如mySQL类型数据库没有系统表记录SQL执行情况,或者通过数据源的数据连接池方式实现SQL监控,这种实现方式不适应其它的数据源,不具有通用性。In the existing SQL monitoring process, such as querying the system tables provided by the oracle database itself, the SQL execution status is recorded, but not all types of databases have system tables to record the SQL execution status. For example, mySQL type databases do not have system tables to record SQL execution status. Execution, or implement SQL monitoring through the data connection pool of the data source, this implementation method is not suitable for other data sources and has no generality.
本申请主要解决如下技术问题:This application mainly solves the following technical problems:
现有数据库种类繁多,但SQL监控往往根据某企业自身应用系统数据库进行设计,当该应用系统中其他业务、或其他企业的同领域的业务、或是不同领域的应用系统需要其它数据库或数据库连接方式时,就需要重新 设计。这些有针对性的SQL监控则不具备灵活性也不具备普适性。不具备普适性的问题。There are many types of existing databases, but SQL monitoring is often designed based on an enterprise's own application system database. When other businesses in the application system, or other businesses' businesses in the same field, or application systems in different fields require other databases or database connections method, it needs to be redesigned. These targeted SQL monitoring are neither flexible nor universal. Not a general problem.
随着云技术的发展,一个业务系统往往包含多个微服务,每个微服务如何方便快捷的实现SQL运行监控,目前还没有一款基于云环境的系统SQL监控组件。With the development of cloud technology, a business system often includes multiple microservices. How to easily and quickly implement SQL operation monitoring for each microservice? There is currently no system SQL monitoring component based on cloud environment.
因此,本申请实施例提供了一种基于云环境的SQL监控方法,所述监控方法的执行流程如图1所示,包括步骤:Therefore, an embodiment of the present application provides a SQL monitoring method based on a cloud environment, and the execution process of the monitoring method is shown in FIG. 1 , including steps:
S101、当检测到SQL监控触发指令时,基于目标JDBC对目标数据库中SQL的执行情况进行监听,得到监听数据,其中,所述目标JDBC基于对原始JDBC进行重构并添加监听器得到,所述原始JDBC存在于JDK中;S101. When the SQL monitoring trigger instruction is detected, monitor the execution of SQL in the target database based on the target JDBC to obtain monitoring data, wherein the target JDBC is obtained by reconstructing the original JDBC and adding a listener, and the Raw JDBC exists in the JDK;
本申请实施例中,预先将JDK中的JDBC进行重构并添加监听,过程如图2所示,获取数据源配置信息,基于所述数据源配置信息创建数据源驱动,代理原始的JDBC驱动,通过创建driver类,在driver类里创建jdbc的driver对象,并实现jdbc的driver所有方法,并重构了获取数据源的方法,将所述数据源驱动与JDK中原始JDBC建立连接,连接成功后,在所述原始JDBC添加监听器listener,创建监听类,得到目标JDBC,基于所述目标JDBC监听数据源链接对象,操作数据库时,数据源链接对象中的内容都会在监听中获取到,监听SQL的执行情况,得到监听数据,记录到数据库中,得到业务系统的数据源。In the embodiment of the present application, the JDBC in the JDK is refactored in advance and monitoring is added. The process is shown in FIG. 2 , the data source configuration information is obtained, the data source driver is created based on the data source configuration information, and the original JDBC driver is represented. By creating a driver class, creating a jdbc driver object in the driver class, and implementing all the jdbc driver methods, and reconstructing the method of obtaining the data source, the data source driver is connected with the original JDBC in the JDK. After the connection is successful , add a listener listener to the original JDBC, create a listener class, get the target JDBC, monitor the data source link object based on the target JDBC, when operating the database, the content in the data source link object will be obtained in the monitoring, monitoring SQL The implementation of the monitoring data is obtained, recorded in the database, and the data source of the business system is obtained.
以微服务的处理过程为例,在各个微服务的数据源创建的时候,使用所述目标JDBC驱动和数据源的配置信息,进行创建数据源对象。SQL监听通过截获所述目标数据库的执行情况,包括增、删、改、查等SQL执行情况,当检测到SQL监控触发指令时,对基于目标JDBC对目标数据库中SQL的执行情况进行监听,得到监听数据的过程进行说明,其中,所述SQL监控触发指令可以为点击某一按钮或者是输入某一关键词等,本申请实施 例中,对所述SQL监控触发指令的具体存在形式不进行限定,监控采用JDBC驱动的代理方式,避免了不同数据库类型,不同数据源等差异,JDBC是JDK本身的接口,兼容所有数据库类型和数据源。同时组件已普通jar包方式,不绑定任何平台,兼容各种操作系统。具体的SQL监听过程如下:获取所述SQL监控触发指令中包含的数据标识,其中,所述数据标识用于区分不同微服务中不同类型的数据库,优选的,每一个微服务对应一个数据库,针对不同的微服务可以为同一类型的数据库,在各个数据库中依据所述数据标识确定目标数据库,基于代理目标JDBC的方式对目标数据库中SQL的执行情况进行监听,得到监听数据。Taking the processing process of the microservice as an example, when the data source of each microservice is created, the data source object is created by using the configuration information of the target JDBC driver and the data source. SQL monitoring intercepts the execution status of the target database, including SQL execution status such as addition, deletion, modification, and query. When the SQL monitoring trigger instruction is detected, the execution status of SQL in the target database based on the target JDBC is monitored, and the result is obtained. The process of monitoring data is described, wherein the SQL monitoring trigger instruction may be clicking a button or inputting a certain keyword, etc. In the embodiment of the present application, the specific existence form of the SQL monitoring trigger instruction is not limited , Monitoring adopts JDBC-driven proxy mode, which avoids the differences between different database types and different data sources. JDBC is the interface of JDK itself and is compatible with all database types and data sources. At the same time, the components are in the form of ordinary jar packages, not bound to any platform, and compatible with various operating systems. The specific SQL monitoring process is as follows: obtain the data identifier contained in the SQL monitoring trigger instruction, wherein the data identifier is used to distinguish different types of databases in different microservices, preferably, each microservice corresponds to a database, Different microservices can be the same type of database, and in each database, the target database is determined according to the data identifier, and the execution of SQL in the target database is monitored based on the method of proxy target JDBC to obtain monitoring data.
S102、将所述监听数据记录到数据库中,以供用户调用。S102. Record the monitoring data into a database for the user to call.
本申请实施例中,将所述监听数据记录到数据库中,以供用户调用,记所述监听数据包括:执行的开始时间、结束时间、执行间隔、是否慢SQL、返回行数、执行次数、错误数量、SQL信息、错误信息等SQL监控数据,优选的,将所述监听数据以多数据源形式进行展示。In the embodiment of the present application, the monitoring data is recorded in the database for the user to call, and the monitoring data includes: the start time of execution, the end time, the execution interval, whether the SQL is slow, the number of returned rows, the number of executions, SQL monitoring data such as the number of errors, SQL information, and error information, preferably, the monitoring data is displayed in the form of multiple data sources.
进一步的,同时可以监控数据库的容量以及微服务部署的服务器的性能指标,包括服务器的CPU、内存、磁盘空间、剩余空间、JVM空间等接口,共SQL监控的微服务进行展示。Furthermore, at the same time, it can monitor the capacity of the database and the performance indicators of the server deployed by the microservice, including the server's CPU, memory, disk space, remaining space, JVM space and other interfaces, and display the microservices monitored by SQL.
本申请实施例公开了一种基于云环境的SQL监控方法,包括:当检测到SQL监控触发指令时,基于目标JDBC对目标数据库中SQL的执行情况进行监听,得到监听数据,其中,所述目标JDBC基于对原始JDBC进行重构并添加监听器得到,所述原始JDBC存在于JDK中;将所述监听数据记录到数据库中,以供用户调用。上述的监控过程中,基于目标JDBC进行监控,由于JDBC是jdk自带的链接数据库包,是所有java系统的通用方式。JDBC是JDK本身的接口,兼容所有数据库类型和数据源,同时组件已普通jar包方式,不绑定任何平台,兼容各种操作系统,使得监控过程具有通 用性。The embodiment of the present application discloses a SQL monitoring method based on a cloud environment. JDBC is obtained by refactoring the original JDBC and adding a listener, the original JDBC exists in the JDK; the monitoring data is recorded in the database for the user to call. In the above monitoring process, monitoring is performed based on the target JDBC. Since JDBC is a linked database package that comes with JDK, it is a common method for all Java systems. JDBC is the interface of JDK itself, compatible with all database types and data sources. At the same time, the components are in the form of ordinary jar packages, not bound to any platform, and compatible with various operating systems, making the monitoring process universal.
本申请实施例中,基于上述的监控方法的处理流程如图3所示,为了全面兼容不同数据库不同数据源的SQL监控,设计了基于云环境的SQL监控系统,首先监控云环境中无论是SpringBoot的微服务架构还是传统的OSGI的模块架构的单体系统,无论是ORACLE还是mySQL数据库;无论是C3PO还是DBCP或其他数据源,可以使用本系统来实现云环境SQL监控。针对微应用A、微应用B、微应用C和微应用D使用JDBC代理的方式进行SQL监控,数据库代理记录sql监控到的监控数据,将得到的监控数据存储到数据库中,以供用户进行查询、统计和分析等。In the embodiment of the present application, the processing flow based on the above-mentioned monitoring method is shown in FIG. 3 . In order to be fully compatible with the SQL monitoring of different databases and different data sources, a SQL monitoring system based on a cloud environment is designed. The microservice architecture or the traditional OSGI module architecture is a single system, whether it is ORACLE or mySQL database; whether it is C3PO or DBCP or other data sources, you can use this system to implement SQL monitoring in the cloud environment. For micro-application A, micro-application B, micro-application C, and micro-application D, use JDBC proxy to perform SQL monitoring. The database proxy records the monitoring data monitored by SQL, and stores the obtained monitoring data in the database for users to query. , statistics and analysis, etc.
进一步的,云环境的微服务系统SQL监控架构组的示意图如图4所示,其中,集成SQL监控组件的微服务A、集成SQL监控组件的微服务B和集成SQL监控组件的微服务C,通过数据库记录监控数据,依据具体的需求展示,统计、分析SQL监控数据,传统单体系统SQL监控架构组如图5所示,其中,集成SQL监控组件的单体应用,通过数据库记录SQL监控数据,依据具体需求展示、统计、分析SQL监控数据。上述的两种架构中,本身没有变化,根据系统的架构不同,逻辑图不同。单体是一个应用,微服务是多个应用。Further, the schematic diagram of the SQL monitoring architecture group of the microservice system in the cloud environment is shown in Figure 4, wherein the microservice A integrating the SQL monitoring component, the microservice B integrating the SQL monitoring component, and the microservice C integrating the SQL monitoring component, The monitoring data is recorded through the database, and the SQL monitoring data is displayed, counted and analyzed according to specific requirements. The traditional single system SQL monitoring architecture group is shown in Figure 5. Among them, the single application integrating the SQL monitoring component records the SQL monitoring data through the database. , to display, count, and analyze SQL monitoring data according to specific needs. In the above two architectures, there is no change in itself, and the logic diagram is different depending on the architecture of the system. A monolith is one application, and a microservice is multiple applications.
本申请实施例的技术方案在中“轻量级权限”系统中得到全面应用。在使用本申请实施例的技术方案后,系统的SQL执行情况,通过SQL监控组件来记录SQL执行情况,兼容性好,集成方便快捷,极大的满足了系统SQL监控的需要,可以兼容多种数据库类型,数据源,操作系统,系统架构,部署环境等业务系统。The technical solutions of the embodiments of the present application are fully applied in the "lightweight authority" system. After using the technical solution of the embodiment of the present application, the SQL execution status of the system is recorded through the SQL monitoring component, which has good compatibility, convenient and quick integration, greatly meets the needs of system SQL monitoring, and can be compatible with a variety of Database type, data source, operating system, system architecture, deployment environment and other business systems.
进一步的,所述监控方法不局限于特定的业务系统,具有一定的通用性,有SQL监控需要的应用系统都可以考虑使用,只是普通jar包方式,不绑定业务平台,针对实时和历史分析实现细致到秒的数据收集,使系统 能够查明问题、找到导致性能问题的根本原因。Further, the monitoring method is not limited to a specific business system, and has a certain generality. Any application system that needs SQL monitoring can be considered for use. It is only a common jar package method, not bound to a business platform, and is aimed at real-time and historical analysis. Enables data collection down to the second, enabling systems to pinpoint problems and find the root cause of performance issues.
基于上述的一种基于云环境的SQL监控方法,本申请实施例中,还提供了一种基于云环境的SQL监控装置,所述监控装置的结构框图如图6所示,包括:Based on the above-mentioned SQL monitoring method based on a cloud environment, in the embodiment of the present application, a SQL monitoring device based on a cloud environment is also provided. The structural block diagram of the monitoring device is shown in FIG. 6 , including:
监听模块201和记录和调用模块202。 Monitor module 201 and record and call module 202.
其中,in,
所述监听模块201,配置为当检测到SQL监控触发指令时,基于目标JDBC对目标数据库中SQL的执行情况进行监听,得到监听数据,其中,所述目标JDBC基于对原始JDBC进行重构并添加监听器得到,所述原始JDBC存在于JDK中;The monitoring module 201 is configured to monitor the execution of SQL in the target database based on the target JDBC when the SQL monitoring trigger instruction is detected to obtain monitoring data, wherein the target JDBC is based on reconstructing and adding the original JDBC. The listener obtains that the original JDBC exists in the JDK;
所述记录和调用模块202,配置为将所述监听数据记录到数据库中,以供用户调用。The recording and calling module 202 is configured to record the monitoring data into a database for the user to call.
本申请实施例公开了一种基于云环境的SQL监控装置,包括:当检测到SQL监控触发指令时,基于目标JDBC对目标数据库中SQL的执行情况进行监听,得到监听数据,其中,所述目标JDBC基于对原始JDBC进行重构并添加监听器得到,所述原始JDBC存在于JDK中;将所述监听数据记录到数据库中,以供用户调用。上述的监控过程中,基于目标JDBC进行监控,由于JDBC是jdk自带的链接数据库包,是所有java系统的通用方式。JDBC是JDK本身的接口,兼容所有数据库类型和数据源,同时组件已普通jar包方式,不绑定任何平台,兼容各种操作系统,使得监控过程具有通用性。The embodiment of the present application discloses a SQL monitoring device based on a cloud environment, which includes: when a SQL monitoring trigger instruction is detected, monitoring the execution of SQL in a target database based on target JDBC to obtain monitoring data, wherein the target JDBC is obtained by refactoring the original JDBC and adding a listener, the original JDBC exists in the JDK; the monitoring data is recorded in the database for the user to call. In the above monitoring process, monitoring is performed based on the target JDBC. Since JDBC is a linked database package that comes with JDK, it is a common method for all Java systems. JDBC is the interface of JDK itself, which is compatible with all database types and data sources. At the same time, the components are in the form of ordinary jar packages, not bound to any platform, and compatible with various operating systems, making the monitoring process universal.
本申请实施例中,所述监听模块201包括:In this embodiment of the present application, the monitoring module 201 includes:
获取单元、确定单元和监听单元。The acquisition unit, the determination unit and the monitoring unit.
其中,in,
所述获取单元,配置为获取所述SQL监控触发指令中的数据标识;The obtaining unit is configured to obtain the data identifier in the SQL monitoring trigger instruction;
所述确定单元,配置为在各个数据库中依据所述数据标识确定目标数据库;The determining unit is configured to determine a target database in each database according to the data identifier;
所述监听单元,配置为基于代理目标JDBC的方式对目标数据库中SQL的执行情况进行监听,得到监听数据。The monitoring unit is configured to monitor the execution situation of SQL in the target database based on the proxy target JDBC method, and obtain monitoring data.
本申请实施例中,所述监听模块中基于对原始JDBC进行重构并添加监听器得到所述目标JDBC,包括:In the embodiment of the present application, the target JDBC is obtained by refactoring the original JDBC and adding a listener in the monitoring module, including:
获取和创建单元、连接建立单元和添加单元。Get and create units, connect units and add units.
其中,in,
所述获取和创建单元,配置为获取数据源配置信息,基于所述数据源配置信息创建数据源驱动;The acquiring and creating unit is configured to acquire data source configuration information, and create a data source driver based on the data source configuration information;
所述连接建立单元,配置为将所述数据源驱动与JDK中原始JDBC建立连接;The connection establishment unit is configured to establish a connection between the data source driver and the original JDBC in the JDK;
所述添加单元,配置为连接成功后,在所述原始JDBC添加监听器,得到目标JDBC。The adding unit is configured to add a listener to the original JDBC after the connection is successful to obtain the target JDBC.
本申请实施例中,所述监听装置还包括:In the embodiment of the present application, the monitoring device further includes:
监听模块和展示模块。The listening module and the presentation module.
其中,in,
所述监听模块,配置为监听所述目标数据库的容量和对应服务器的性能指标;The monitoring module is configured to monitor the capacity of the target database and the performance index of the corresponding server;
所述展示模块,配置为将所述容量和所述性能指标进行展示。The display module is configured to display the capacity and the performance index.
需要说明的是,本说明书中的各个实施例均采用递进的方式描述,每个实施例重点说明的都是与其他实施例的不同之处,各个实施例之间相同相似的部分互相参见即可。对于装置类实施例而言,由于其与方法实施例基本相似,所以描述的比较简单,相关之处参见方法实施例的部分说明即可。It should be noted that the various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. For the same and similar parts of the various embodiments, refer to each other Can. As for the apparatus type embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant part may refer to the partial description of the method embodiment.
最后,还需要说明的是,在本文中,诸如第一和第二等之类的关系术语仅仅用来将一个实体或者操作与另一个实体或操作区分开来,而不一定要求或者暗示这些实体或操作之间存在任何这种实际的关系或者顺序。而且,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者设备所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括所述要素的过程、方法、物品或者设备中还存在另外的相同要素。Finally, it should also be noted that in this document, relational terms such as first and second are used only to distinguish one entity or operation from another, and do not necessarily require or imply these entities or that there is any such actual relationship or sequence between operations. Moreover, the terms "comprising", "comprising" or any other variation thereof are intended to encompass non-exclusive inclusion such that a process, method, article or device comprising a list of elements includes not only those elements, but also includes not explicitly listed or other elements inherent to such a process, method, article or apparatus. Without further limitation, an element qualified by the phrase "comprising a..." does not preclude the presence of additional identical elements in a process, method, article or apparatus that includes the element.
为了描述的方便,描述以上装置时以功能分为各种单元分别描述。当然,在实施本申请时可以把各单元的功能在同一个或多个软件和/或硬件中实现。For the convenience of description, when describing the above device, the functions are divided into various units and described respectively. Of course, when implementing the present application, the functions of each unit may be implemented in one or more software and/or hardware.
通过以上的实施方式的描述可知,本领域的技术人员可以清楚地了解到本申请可借助软件加必需的通用硬件平台的方式来实现。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品可以存储在存储介质中,如ROM/RAM、磁碟、光盘等,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行本申请各个实施例或者实施例的某些部分所述的方法。From the description of the above embodiments, those skilled in the art can clearly understand that the present application can be implemented by means of software plus a necessary general hardware platform. Based on this understanding, the technical solutions of the present application can be embodied in the form of software products in essence or the parts that make contributions to the prior art, and the computer software products can be stored in storage media, such as ROM/RAM, magnetic disks , CD-ROM, etc., including several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute the methods described in various embodiments or some parts of the embodiments of the present application.
以上对本申请所提供的一种基于云环境的SQL监控方法及装置进行了详细介绍,本文中应用了具体个例对本申请的原理及实施方式进行了阐述,以上实施例的说明只是用于帮助理解本申请的方法及其核心思想;同时,对于本领域的一般技术人员,依据本申请的思想,在具体实施方式及应用范围上均会有改变之处,综上所述,本说明书内容不应理解为对本申请的限制。A cloud-based SQL monitoring method and device provided by the present application have been described in detail above. The principles and implementations of the present application are described with specific examples in this paper. The descriptions of the above embodiments are only used to help understanding The method of the present application and its core idea; at the same time, for those of ordinary skill in the art, according to the idea of the present application, there will be changes in the specific implementation and application scope. In summary, the content of this specification should not be It is construed as a limitation of this application.

Claims (10)

  1. 一种基于云环境的SQL监控方法,包括:A cloud-based SQL monitoring method, including:
    当检测到SQL监控触发指令时,基于目标JDBC对目标数据库中SQL的执行情况进行监听,得到监听数据,其中,所述目标JDBC基于对原始JDBC进行重构并添加监听器得到,所述原始JDBC存在于JDK中;When the SQL monitoring trigger instruction is detected, the execution of SQL in the target database is monitored based on the target JDBC to obtain monitoring data, wherein the target JDBC is obtained by reconstructing the original JDBC and adding a listener. exists in the JDK;
    将所述监听数据记录到数据库中,以供用户调用。The monitoring data is recorded in the database for the user to call.
  2. 根据权利要求1所述的方法,其中,当检测到SQL监控触发指令时,基于目标JDBC对目标数据库中SQL的执行情况进行监听,得到监听数据,包括:The method according to claim 1, wherein, when an SQL monitoring trigger instruction is detected, the execution of SQL in the target database is monitored based on the target JDBC to obtain monitoring data, comprising:
    获取所述SQL监控触发指令中的数据标识;Obtain the data identifier in the SQL monitoring trigger instruction;
    在各个数据库中依据所述数据标识确定目标数据库;Determine the target database in each database according to the data identification;
    基于代理目标JDBC的方式对目标数据库中SQL的执行情况进行监听,得到监听数据。Based on the proxy target JDBC method, the execution of SQL in the target database is monitored, and the monitoring data is obtained.
  3. 根据权利要求1所述的方法,其中,基于对原始JDBC进行重构并添加监听器得到所述目标JDBC,包括:The method according to claim 1, wherein the target JDBC is obtained based on reconstructing the original JDBC and adding a listener, comprising:
    获取数据源配置信息,基于所述数据源配置信息创建数据源驱动;Acquire data source configuration information, and create a data source driver based on the data source configuration information;
    将所述数据源驱动与JDK中原始JDBC建立连接;establishing a connection between the data source driver and the original JDBC in the JDK;
    连接成功后,在所述原始JDBC添加监听器,得到目标JDBC。After the connection is successful, add a listener to the original JDBC to obtain the target JDBC.
  4. 根据权利要求1所述的方法,其中,还包括:The method of claim 1, further comprising:
    监听所述目标数据库的容量和对应服务器的性能指标;Monitor the capacity of the target database and the performance indicators of the corresponding server;
    将所述容量和所述性能指标进行展示。The capacity and the performance indicators are displayed.
  5. 根据权利要求1所述的方法,其中,还包括:The method of claim 1, further comprising:
    将所述监听数据以多数据源形式进行展示。The monitoring data is displayed in the form of multiple data sources.
  6. 根据权利要求1所述的方法,其中,还包括:所述目标数据库可以存在与微服务中或者单体系统中。The method according to claim 1, further comprising: the target database may exist in a microservice or a monolithic system.
  7. 一种基于云环境的SQL监控装置,包括:A SQL monitoring device based on a cloud environment, comprising:
    监听模块,配置为当检测到SQL监控触发指令时,基于目标JDBC对目标数据库中SQL的执行情况进行监听,得到监听数据,其中,所述目标JDBC基于对原始JDBC进行重构并添加监听器得到,所述原始JDBC存在于JDK中;The monitoring module is configured to monitor the execution of SQL in the target database based on the target JDBC when the SQL monitoring trigger instruction is detected to obtain monitoring data, wherein the target JDBC is obtained by reconstructing the original JDBC and adding a listener. , the original JDBC exists in the JDK;
    记录和调用模块,配置为将所述监听数据记录到数据库中,以供用户调用。The recording and calling module is configured to record the monitoring data into the database for the user to call.
  8. 根据权利要求7所述的系统,其中,所述监听模块包括:The system of claim 7, wherein the listening module comprises:
    获取单元,配置为获取所述SQL监控触发指令中的数据标识;an acquisition unit, configured to acquire the data identifier in the SQL monitoring trigger instruction;
    确定单元,配置为在各个数据库中依据所述数据标识确定目标数据库;a determining unit, configured to determine a target database in each database according to the data identifier;
    监听单元,配置为基于代理目标JDBC的方式对目标数据库中SQL的执行情况进行监听,得到监听数据。The monitoring unit is configured to monitor the execution of SQL in the target database based on the proxy target JDBC method to obtain monitoring data.
  9. 根据权利要求7所述的装置,其中,所述监听模块中基于对原始JDBC进行重构并添加监听器得到所述目标JDBC,包括:The apparatus according to claim 7, wherein the target JDBC is obtained in the monitoring module based on reconstructing the original JDBC and adding a listener, comprising:
    获取和创建单元,配置为获取数据源配置信息,基于所述数据源配置信息创建数据源驱动;an acquiring and creating unit, configured to acquire data source configuration information, and create a data source driver based on the data source configuration information;
    连接建立单元,配置为将所述数据源驱动与JDK中原始JDBC建立连接;a connection establishment unit, configured to establish a connection between the data source driver and the original JDBC in the JDK;
    添加单元,配置为连接成功后,在所述原始JDBC添加监听器,得到目标JDBC。Adding a unit is configured to add a listener to the original JDBC after the connection is successful to obtain the target JDBC.
  10. 根据权利要求7所述的装置,其中,还包括:The apparatus of claim 7, further comprising:
    监听模块,配置为监听所述目标数据库的容量和对应服务器的性能指标;a monitoring module, configured to monitor the capacity of the target database and the performance index of the corresponding server;
    展示模块,配置为将所述容量和所述性能指标进行展示。A display module, configured to display the capacity and the performance index.
PCT/CN2020/134071 2020-11-10 2020-12-04 Cloud environment-based sql monitoring method and apparatus WO2022099832A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202011247020.0A CN112231180A (en) 2020-11-10 2020-11-10 SQL monitoring method and device based on cloud environment
CN202011247020.0 2020-11-10

Publications (1)

Publication Number Publication Date
WO2022099832A1 true WO2022099832A1 (en) 2022-05-19

Family

ID=74122325

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2020/134071 WO2022099832A1 (en) 2020-11-10 2020-12-04 Cloud environment-based sql monitoring method and apparatus

Country Status (2)

Country Link
CN (1) CN112231180A (en)
WO (1) WO2022099832A1 (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115599656A (en) * 2022-12-12 2023-01-13 深圳联友科技有限公司(Cn) Monitoring alarm realization method based on Java self-defined SQL
CN116149790A (en) * 2023-02-15 2023-05-23 北京景安云信科技有限公司 Method for starting multiple Springboot items based on JVM process reduction

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115981880B (en) * 2023-03-21 2023-06-23 深圳云豹智能有限公司 Method, device, system, storage medium and chip for avoiding deadlock of host access slave

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101226497A (en) * 2007-12-10 2008-07-23 金蝶软件(中国)有限公司 Application program monitoring system and monitoring method
US20120166483A1 (en) * 2010-12-28 2012-06-28 Akshat Choudhary Systems and Methods for Database Proxy Request Switching
CN103678630A (en) * 2013-12-19 2014-03-26 北京用友政务软件有限公司 Database monitoring method and system
CN109376139A (en) * 2018-08-15 2019-02-22 中国平安人寿保险股份有限公司 Centralized database monitoring method, computer installation and storage medium

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8954387B2 (en) * 2012-06-07 2015-02-10 Vmware, Inc. Tracking changes that affect performance of deployed applications
CN109450693B (en) * 2018-11-23 2021-12-10 金色熊猫有限公司 Hybrid cloud monitoring system and monitoring method using same

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101226497A (en) * 2007-12-10 2008-07-23 金蝶软件(中国)有限公司 Application program monitoring system and monitoring method
US20120166483A1 (en) * 2010-12-28 2012-06-28 Akshat Choudhary Systems and Methods for Database Proxy Request Switching
CN103678630A (en) * 2013-12-19 2014-03-26 北京用友政务软件有限公司 Database monitoring method and system
CN109376139A (en) * 2018-08-15 2019-02-22 中国平安人寿保险股份有限公司 Centralized database monitoring method, computer installation and storage medium

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115599656A (en) * 2022-12-12 2023-01-13 深圳联友科技有限公司(Cn) Monitoring alarm realization method based on Java self-defined SQL
CN116149790A (en) * 2023-02-15 2023-05-23 北京景安云信科技有限公司 Method for starting multiple Springboot items based on JVM process reduction
CN116149790B (en) * 2023-02-15 2023-11-21 北京景安云信科技有限公司 Method for starting multiple Springboot items based on JVM process reduction

Also Published As

Publication number Publication date
CN112231180A (en) 2021-01-15

Similar Documents

Publication Publication Date Title
WO2022099832A1 (en) Cloud environment-based sql monitoring method and apparatus
US11379475B2 (en) Analyzing tags associated with high-latency and error spans for instrumented software
US11240126B2 (en) Distributed tracing for application performance monitoring
US10810074B2 (en) Unified error monitoring, alerting, and debugging of distributed systems
US11468062B2 (en) Order-independent multi-record hash generation and data filtering
US10997180B2 (en) Dynamic query processor for streaming and batch queries
Rupprecht et al. Improving reproducibility of data science pipelines through transparent provenance capture
JP6266630B2 (en) Managing continuous queries with archived relations
US10013439B2 (en) Automatic generation of instantiation rules to determine quality of data migration
US8386466B2 (en) Log visualization tool for a data stream processing server
US20040193612A1 (en) System and method for testing, monitoring, and tracking distributed transactions using a search engine
CA2717673C (en) Detecting and applying database schema changes to reports
US11238045B2 (en) Data arrangement management in a distributed data cluster environment of a shared pool of configurable computing resources
US20080250057A1 (en) Data Table Management System and Methods Useful Therefor
JP2018510413A (en) Database query execution trace and data generation to diagnose execution problems
US11436116B1 (en) Recovering pre-indexed data from a shared storage system following a failed indexer
CN106815353B (en) Data query method and equipment
US11868360B2 (en) Effective correlation of multiple time-series result sets
US11362912B2 (en) Support ticket platform for improving network infrastructures
US11526413B2 (en) Distributed tracing of huge spans for application and dependent application performance monitoring
US10509784B2 (en) Partially typed semantics optimization
CN113886205A (en) Database performance bottleneck positioning analysis method, device and system and storage medium
Wang End-to-end tracing in HDFS
US11829415B1 (en) Mapping buckets and search peers to a bucket map identifier for searching
Ekhlasi et al. DTraComp: Comparing distributed execution traces for understanding intermittent latency sources

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 20961386

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205A DATED 26.10.2023)