CN105574195A - Method and device for judging whether to perform offline recycling on database or not - Google Patents
Method and device for judging whether to perform offline recycling on database or not Download PDFInfo
- Publication number
- CN105574195A CN105574195A CN201510997513.9A CN201510997513A CN105574195A CN 105574195 A CN105574195 A CN 105574195A CN 201510997513 A CN201510997513 A CN 201510997513A CN 105574195 A CN105574195 A CN 105574195A
- Authority
- CN
- China
- Prior art keywords
- database
- judging
- offline
- business
- meets
- Prior art date
- Legal status (The legal status 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 status listed.)
- Granted
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/28—Databases characterised by their database models, e.g. relational or object models
- G06F16/284—Relational databases
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/21—Design, administration or maintenance of databases
Landscapes
- Engineering & Computer Science (AREA)
- Databases & Information Systems (AREA)
- Theoretical Computer Science (AREA)
- Data Mining & Analysis (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
本发明提供了一种判断数据库是否应下线回收的方法及装置,上述方法包括:获取作为判断对象的数据库的类型;判断数据库的类型是否为关系型;若是,则获取数据库的运行状态信息;基于运行状态信息,根据对应的预定策略判断数据库是否符合下线回收条件。本发明提供的技术方案会自动获取各个关系型数据库的运行状态信息,并自动判断一个关系型数据库是否需要下线回收,从而不需要用户进行任何人工操作,就可以及时地回收资源,大大提高了资源的利用率。
The present invention provides a method and device for judging whether a database should be offline and recycled. The method includes: obtaining the type of the database as a judging object; judging whether the type of the database is a relational type; if so, obtaining the operation status information of the database; Based on the running status information, it is judged according to the corresponding predetermined policy whether the database meets the offline recovery conditions. The technical solution provided by the present invention can automatically obtain the operation status information of each relational database, and automatically judge whether a relational database needs to be recycled offline, so that resources can be recovered in time without any manual operation by the user, which greatly improves the resource utilization.
Description
技术领域technical field
本发明涉及计算机技术领域,特别是涉及一种判断数据库是否应下线回收的方法及装置。The invention relates to the technical field of computers, in particular to a method and a device for judging whether a database should be recovered offline.
背景技术Background technique
在现代计算机技术中,数据库的应用是一项十分重要的技术,在目前的互联时代中,数据库的应用更是越发的广泛,不论是各种网站、平台还是各种应用软件都需要设置各种各样的数据库。In modern computer technology, the application of database is a very important technology. In the current Internet era, the application of database is more and more extensive. Whether it is various websites, platforms or various application software, it is necessary to set up various various databases.
广义的来讲,数据库可以分为关系型数据库和非关系型数据库。数据库的资源是有限的,需要对其进行重复循环的使用,目前在判断是否要对某一个数据库进行下线回收时,都是需要人工进行的,这样会导致资源回收不及时,同时人工回收也会给用户带来很大的工作量。Broadly speaking, databases can be divided into relational databases and non-relational databases. The resources of the database are limited, and they need to be used repeatedly. At present, when judging whether to recycle a certain database offline, it needs to be done manually. This will lead to untimely resource recovery. It will bring a lot of workload to the user.
发明内容Contents of the invention
本发明提出了一种判断数据库是否应下线回收的方法及装置以克服上述问题或者至少部分地解决上述问题。The present invention proposes a method and device for judging whether a database should be taken offline for recovery to overcome the above problems or at least partly solve the above problems.
根据本发明的一个方面,提供了一种判断数据库是否应下线回收的方法,包括:According to one aspect of the present invention, there is provided a method for judging whether the database should be recovered offline, including:
获取作为判断对象的数据库的类型;Obtain the type of the database as the judgment object;
判断所述数据库的类型是否为关系型;Determine whether the type of the database is relational;
若是,则获取所述数据库的运行状态信息;If so, obtain the running status information of the database;
基于所述运行状态信息,根据对应的预定策略判断所述数据库是否符合下线回收条件。Based on the running state information, it is judged according to a corresponding predetermined policy whether the database meets the offline recovery condition.
可选地,所述运行状态信息包括下列至少之一:Optionally, the running status information includes at least one of the following:
所述数据库的进程的运行状态;The running state of the process of the database;
所述数据库的实例的连通状态;the connectivity status of the instance of the database;
所述数据库的实例的启动时间;The startup time of the instance of the database;
所述数据库的实例中是否存在业务库,所述业务库中是否存在业务表;Whether there is a business library in the instance of the database, and whether there is a business table in the business library;
所述数据库的实例中业务表的最后数据修改时间;The last data modification time of the business table in the instance of the database;
所述数据库使用的代理服务器是否挂载在Linux虚拟服务器下。Whether the proxy server used by the database is mounted under the Linux virtual server.
可选地,根据对应的预定策略判断所述数据库是否符合下线回收条件包括下列至少之一:Optionally, judging whether the database meets the offline recovery condition according to a corresponding predetermined strategy includes at least one of the following:
判断所述数据库是否在业务云平台上不存在记录,但是在服务器本地存在数据目录或者其实例已启动,如果是,则判断所述数据库符合下线回收条件;Judging whether the database does not have a record on the business cloud platform, but there is a data directory locally on the server or its instance has been started, if so, then judging that the database meets the offline recovery conditions;
判断所述数据库的进程是否处于运行状态,如果否,则判断所述数据库符合下线回收条件;Judging whether the process of the database is in a running state, if not, judging that the database meets the conditions for offline recovery;
判断所述数据库使用的代理服务器是否挂载在Linux虚拟服务器下,如果否,则判断所述数据库符合下线回收条件;Judging whether the proxy server used by the database is mounted under the Linux virtual server, if not, then judging that the database meets the off-line recovery condition;
判断所述数据库是否启动超过第一时间阈值,但是没有建立业务库或业务表,如果是,则判断所述数据库符合下线回收条件;Judging whether the database starts exceeding the first time threshold, but does not establish a business library or business table, if so, then judging that the database meets the off-line recovery condition;
判断所述数据库是否启动超过所述第一时间阈值、建立了业务库和业务表且所述业务表的最后数据修改时间超过了第二时间阈值,如果是,则判断所述数据库在预定时长内是否有语句访问,如果否,则判断所述数据库符合下线回收条件。Judging whether the database starts exceeding the first time threshold, establishes a business library and a business table, and the last data modification time of the business table exceeds a second time threshold, if so, then judges that the database is within a predetermined time period Whether there is a statement access, if not, it is judged that the database meets the offline recovery condition.
可选地,所述获取所述数据库的运行状态信息包括:Optionally, the acquiring the running status information of the database includes:
定时执行用于获取所述数据库的运行状态信息的脚本,获取并保存所述数据库的运行状态信息。The script for obtaining the running state information of the database is executed regularly, and the running state information of the database is obtained and saved.
可选地,若判断所述数据库符合下线回收条件,所述还包括:Optionally, if it is judged that the database meets the conditions for offline recovery, the description also includes:
依据预设联络方式,向所述数据库的管理员发送下线回收提示,其中所述下线回收提示包含所述数据库的标识以及符合下线回收条件的运行状态信息。Sending an offline recovery prompt to the administrator of the database according to a preset contact method, wherein the offline recovery prompt includes the database identifier and operation status information meeting the offline recovery conditions.
可选地,所述关系型数据库包括:MySQL数据库。Optionally, the relational database includes: MySQL database.
根据本发明的另一个方面,还提供了一种判断数据库是否应下线回收的装置,包括:According to another aspect of the present invention, there is also provided a device for judging whether the database should be recovered offline, including:
类型获取模块,用于获取作为判断对象的数据库的类型;A type acquisition module, configured to acquire the type of the database as the judgment object;
类型判断模块,用于判断所述数据库的类型是否为关系型;A type judging module, configured to judge whether the type of the database is relational;
信息获取模块,用于在所述类型判断模块的判断结果为是时,获取所述数据库的运行状态信息;An information acquisition module, configured to acquire the operation status information of the database when the judgment result of the type judgment module is yes;
回收判断模块,用于基于所述运行状态信息,根据对应的预定策略判断所述数据库是否符合下线回收条件。The recycling judging module is configured to judge whether the database meets the off-line recycling condition according to the corresponding predetermined strategy based on the running state information.
可选地,所述运行状态信息包括下列至少之一:Optionally, the running status information includes at least one of the following:
所述数据库的进程的运行状态;The running state of the process of the database;
所述数据库的实例的连通状态;the connectivity status of the instance of the database;
所述数据库的实例的启动时间;The startup time of the instance of the database;
所述数据库的实例中是否存在业务库,所述业务库中是否存在业务表;Whether there is a business library in the instance of the database, and whether there is a business table in the business library;
所述数据库的实例中业务表的最后数据修改时间;The last data modification time of the business table in the instance of the database;
所述数据库使用的代理服务器是否挂载在Linux虚拟服务器下。Whether the proxy server used by the database is mounted under the Linux virtual server.
可选地,所述回收判断模块包括:Optionally, the recycling judgment module includes:
第一判断单元,用于判断所述数据库是否在业务云平台上不存在记录,但是在服务器本地存在数据目录或者其实例已启动,如果是,则判断所述数据库符合下线回收条件;The first judging unit is used to judge whether the database does not have a record on the business cloud platform, but there is a data directory locally on the server or its instance has been started, and if so, judging that the database meets the off-line recovery condition;
第二判断单元,用于判断所述数据库的进程是否处于运行状态,如果否,则判断所述数据库符合下线回收条件;The second judging unit is used for judging whether the process of the database is running, if not, judging that the database meets the off-line recovery condition;
第三判断单元,用于判断所述数据库使用的代理服务器是否挂载在Linux虚拟服务器下,如果否,则判断所述数据库符合下线回收条件;The third judging unit is used for judging whether the proxy server used by the database is mounted under the Linux virtual server, if not, judging that the database meets the off-line recycling condition;
第四判断单元,用于判断所述数据库是否启动超过第一时间阈值,但是没有建立业务库或业务表,如果是,则判断所述数据库符合下线回收条件;和/或The fourth judging unit is used to judge whether the database has been activated for more than the first time threshold, but no business database or business table has been established, and if so, judging that the database meets the conditions for offline recovery; and/or
第五判断单元,用于判断所述数据库是否启动超过所述第一时间阈值、建立了业务库和业务表且所述业务表的最后数据修改时间超过了第二时间阈值,如果是,则判断所述数据库在预定时长内是否有语句访问,如果否,则判断所述数据库符合下线回收条件。The fifth judging unit is used for judging whether the database starts exceeding the first time threshold, the business database and the business table are established, and the last data modification time of the business table exceeds the second time threshold, and if so, judging Whether the database is accessed by a statement within a predetermined period of time, and if not, it is judged that the database meets the offline recovery condition.
可选地,所述信息获取模块包括:Optionally, the information acquisition module includes:
定时获取单元,用于定时执行用于获取所述数据库运行状态信息的脚本,获取并保存所述数据库运行状态信息。The timing acquisition unit is configured to regularly execute the script for acquiring the database operation status information, acquire and store the database operation status information.
可选地,上述装置还包括:Optionally, the above-mentioned device also includes:
回收提示模块,用于在所述回收判断模块判断所述数据库符合下线回收条件时,依据预设联络方式,向所述数据库的管理员发送下线回收提示,其中所述下线回收提示包含所述数据库的标识以及符合下线回收条件的运行状态信息。The recovery prompt module is used to send an offline recovery prompt to the administrator of the database according to the preset contact method when the recovery judging module judges that the database meets the conditions for offline recovery, wherein the offline recovery prompt includes The identification of the database and the running status information meeting the offline recycling conditions.
可选地,所述关系型数据库包括:MySQL数据库。Optionally, the relational database includes: MySQL database.
本发明提供的技术方案会自动获取各个关系型数据库的运行状态信息,并自动判断一个关系型数据库是否需要下线回收,从而不需要用户进行任何人工操作,就可以及时地回收资源,大大提高了资源的利用率。The technical solution provided by the invention can automatically obtain the running status information of each relational database, and automatically judge whether a relational database needs to be recycled offline, so that resources can be recovered in time without any manual operation by the user, which greatly improves the resource utilization.
上述说明仅是本发明技术方案的概述,为了能够更清楚了解本发明的技术手段,而可依照说明书的内容予以实施,并且为了让本发明的上述和其它目的、特征和优点能够更明显易懂,以下特举本发明的具体实施方式。The above description is only an overview of the technical solution of the present invention. In order to better understand the technical means of the present invention, it can be implemented according to the contents of the description, and in order to make the above and other purposes, features and advantages of the present invention more obvious and understandable , the specific embodiments of the present invention are enumerated below.
根据下文结合附图对本发明具体实施例的详细描述,本领域技术人员将会更加明了本发明的上述以及其他目的、优点和特征。Those skilled in the art will be more aware of the above and other objects, advantages and features of the present invention according to the following detailed description of specific embodiments of the present invention in conjunction with the accompanying drawings.
附图说明Description of drawings
通过阅读下文优选实施方式的详细描述,各种其他的优点和益处对于本领域普通技术人员将变得清楚明了。附图仅用于示出优选实施方式的目的,而并不认为是对本发明的限制。而且在整个附图中,用相同的参考符号表示相同的部件。在附图中:Various other advantages and benefits will become apparent to those of ordinary skill in the art upon reading the following detailed description of the preferred embodiment. The drawings are only for the purpose of illustrating a preferred embodiment and are not to be considered as limiting the invention. Also throughout the drawings, the same reference numerals are used to designate the same components. In the attached picture:
图1是根据本发明一个实施例的判断数据库是否应下线回收的方法的流程示意图;Fig. 1 is a schematic flow chart of a method for judging whether a database should be offline and recovered according to an embodiment of the present invention;
图2是根据本发明另一个实施例的判断数据库是否应下线回收的方法的流程示意图;Fig. 2 is a schematic flow chart of a method for judging whether a database should be offline and recovered according to another embodiment of the present invention;
图3是根据本发明再一个实施例的判断数据库是否应下线回收的方法的流程示意图Fig. 3 is a schematic flowchart of a method for judging whether a database should be offline and recovered according to yet another embodiment of the present invention
图4是根据本发明一个实施例的判断数据库是否应下线回收的装置的结构框图;Fig. 4 is a structural block diagram of a device for judging whether a database should be offline and recycled according to an embodiment of the present invention;
图5是根据本发明另一个实施例的判断数据库是否应下线回收的装置的结构框图。Fig. 5 is a structural block diagram of an apparatus for judging whether a database should be taken offline for recovery according to another embodiment of the present invention.
具体实施方式detailed description
下面将参照附图更详细地描述本公开的示例性实施例。虽然附图中显示了本公开的示例性实施例,然而应当理解,可以以各种形式实现本公开而不应被这里阐述的实施例所限制。相反,提供这些实施例是为了能够更透彻地理解本公开,并且能够将本公开的范围完整的传达给本领域的技术人员。需要说明的是,在不冲突的前提下,本发明实施例和实施例中的技术特征可以相互结合。Exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure may be embodied in various forms and should not be limited by the embodiments set forth herein. Rather, these embodiments are provided for more thorough understanding of the present disclosure and to fully convey the scope of the present disclosure to those skilled in the art. It should be noted that, on the premise of no conflict, the embodiments of the present invention and the technical features in the embodiments may be combined with each other.
图1是根据本发明一个实施例的判断数据库是否应下线回收的方法的流程示意图。如图1所示,上述方法可以包括:FIG. 1 is a schematic flowchart of a method for judging whether a database should be taken offline for recovery according to an embodiment of the present invention. As shown in Figure 1, the above methods may include:
步骤S102,获取作为判断对象的数据库的类型;Step S102, acquiring the type of the database to be judged;
步骤S104,判断数据库的类型是否为关系型;Step S104, judging whether the type of the database is relational;
步骤S106,若是,则获取数据库的运行状态信息;Step S106, if yes, obtain the running status information of the database;
步骤S108,基于运行状态信息,根据对应的预定策略判断数据库是否符合下线回收条件。Step S108, based on the running status information, judge whether the database meets the condition for offline recycling according to the corresponding predetermined strategy.
本实施例提供的方法会自动获取各个关系型数据库的运行状态信息,并自动判断一个关系型数据库是否需要下线回收,从而不需要用户进行任何人工操作,就可以及时地回收资源,大大提高了资源的利用率。The method provided in this embodiment will automatically obtain the running status information of each relational database, and automatically judge whether a relational database needs to be recycled offline, so that resources can be recovered in a timely manner without any manual operation by the user, which greatly improves the resource utilization.
在本实施例提供的方法中,为了更高效、准确地判断一个关系型数据库是否可以下线回收了,需要合理的设置需要获取数据的哪些运行状态信息以及根据这些运行状态信息判断数据库是否可以下线回收的策略。在本发明的一个实施例中,上述运行状态信息可以包括:In the method provided in this embodiment, in order to more efficiently and accurately judge whether a relational database can be recycled offline, it is necessary to reasonably set which running status information of the data needs to be obtained and judge whether the database can be offline based on the running status information. Strategies for line recycling. In an embodiment of the present invention, the above-mentioned running status information may include:
数据库的进程的运行状态;The running status of the database process;
数据库的实例的连通状态;The connectivity status of the instance of the database;
数据库的实例的启动时间;The startup time of the database instance;
数据库的实例中是否存在业务库,业务库中是否存在业务表;Whether there is a business library in the database instance, and whether there is a business table in the business library;
数据库的实例中业务表的最后数据修改时间;The last data modification time of the business table in the database instance;
数据库使用的代理服务器是否挂载在Linux虚拟服务器下。Whether the proxy server used by the database is mounted under the Linux virtual server.
本实施例中列举了几种最为典型的可用来判断一个关系型数据库是否可以下线回收的运行状态信息,基于这些运行状态信息基本上可以覆盖到所有典型的需要下线回收的关系型数据库的运行状态。当然,在具体实施时,可以根据不同的需要选择获取其中的一个或多个运行状态信息,或添加新的运行状态信息,本发明不做具体限定。This embodiment lists some of the most typical running status information that can be used to judge whether a relational database can be recycled offline. Based on these running status information, it can basically cover all typical relational databases that need to be recycled offline. Operating status. Of course, during specific implementation, one or more pieces of running state information may be selected to be acquired or new running state information may be added according to different needs, which is not specifically limited in the present invention.
在本发明的一个实施例中,对应于上述的运行状态信息,上述步骤S108可以包括:In an embodiment of the present invention, corresponding to the above running status information, the above step S108 may include:
1、判断数据库是否在业务云平台上不存在记录,但是在服务器本地存在数据目录或者其实例已启动,如果是,则判断数据库符合下线回收条件;1. Determine whether the database does not have records on the business cloud platform, but there is a data directory locally on the server or its instance has been started. If so, determine that the database meets the conditions for offline recovery;
2、判断数据库的进程是否处于运行状态,如果否,则判断数据库符合下线回收条件;2. Determine whether the process of the database is running, if not, determine that the database meets the conditions for offline recovery;
3、判断数据库使用的代理服务器是否挂载在Linux虚拟服务器下,如果否,则判断数据库符合下线回收条件;3. Determine whether the proxy server used by the database is mounted under the Linux virtual server, if not, determine that the database meets the conditions for offline recovery;
4、判断数据库是否启动超过第一时间阈值,但是没有建立业务库或业务表,如果是,则判断数据库符合下线回收条件;4. Judging whether the database startup exceeds the threshold for the first time, but no business database or business table has been established. If so, it is judged that the database meets the offline recovery conditions;
5、判断数据库是否启动超过第一时间阈值、建立了业务库和业务表且业务表的最后数据修改时间超过了第二时间阈值,如果是,则判断数据库在预定时长内是否有语句访问,如果否,则判断数据库符合下线回收条件。5. Judging whether the database startup exceeds the first time threshold, the business library and business table are established, and the last data modification time of the business table exceeds the second time threshold. If so, judge whether the database has statement access within the predetermined time period. If If not, it is judged that the database meets the offline recovery condition.
在本实施例中,数据库在业务云平台上查不到记录,但是在服务器本地有数据目录或者实例已启动的,表明数据库并没有被实际使用,需要删除,即下线回收;数据库的进程不处于运行状态说明实例已经不用,但是有遗留文件,因此需要删除;如果数据库使用了代理服务器(proxy,也可以称为代理、网络代理),但是没有挂载在Linux虚拟服务器(LinuxVirtualServer,简称为lvs)下,说明没有提供线上服务,需要删除;如果数据库启动超过第一时间阈值,例如60天,但是还是没有业务库/表的,属于超期未被使用,需要删除;如果数据库启动超过第一时间阈值(60天)、有业务库/表、并且最后数据修改时间超过第二时间阈值,例如60天(可调整),那么需要抓取其当前是否有语句访问,或者说在一定时间段内是否有语句访问,如果没有则表明其实用率很低,可以考虑删除,在这种情况下,为了保证不会错误回收,还可以和业务人员二次确认,如果确认已经不用,则可以删除。上述策略对应于上述的运行状态信息,基于这些策略即可高效、准确地判断出一个关系型数据库是否可以回收。In this embodiment, if the database cannot be found on the business cloud platform, but there is a data directory locally on the server or the instance has been started, it indicates that the database has not been actually used and needs to be deleted, that is, offline and recycled; the process of the database is not In the running state, the instance is no longer used, but there are legacy files, so it needs to be deleted; if the database uses a proxy server (proxy, also known as proxy, network proxy), but it is not mounted on the Linux virtual server (LinuxVirtualServer, referred to as lvs ), it means that no online service is provided and needs to be deleted; if the database startup exceeds the first time threshold, for example, 60 days, but there is still no business library/table, it is overdue and unused and needs to be deleted; if the database startup exceeds the first time threshold Time threshold (60 days), there is a business library/table, and the last data modification time exceeds the second time threshold, such as 60 days (adjustable), then it is necessary to capture whether it currently has statement access, or within a certain period of time Whether there is statement access, if not, it indicates that its utility rate is very low, you can consider deleting it, in this case, in order to ensure that it will not be recycled by mistake, you can also confirm with the business personnel again, if it is confirmed that it is no longer used, you can delete it. The above-mentioned policies correspond to the above-mentioned running status information, and based on these policies, it can be efficiently and accurately judged whether a relational database can be recycled.
对于关系型数据,在获取其运行状态信息时,可以采用很多手段,本发明中优选采用执行专用脚本的方式。在本发明的一个实施例中,上述步骤S104可以包括:定时执行用于获取数据库的运行状态信息的脚本,获取并保存数据库的运行状态信息。For relational data, many methods can be used to obtain the running state information, and the method of executing a special script is preferred in the present invention. In an embodiment of the present invention, the above step S104 may include: periodically executing a script for acquiring the running status information of the database, and acquiring and saving the running status information of the database.
采用专用脚本获取数据库的运行状态信息,实现简单,占用的资源较少,执行的效率也比较高,是一种优选的方案。Using a dedicated script to obtain the running status information of the database is simple to implement, occupies less resources, and has relatively high execution efficiency, which is an optimal solution.
在本发明的一个实施例中,如图2所示,在判断数据库符合下线回收条件时,上述方法还可以包括:In one embodiment of the present invention, as shown in Figure 2, when judging that the database meets the off-line recycling conditions, the above method may also include:
步骤S110,依据预设联络方式,向数据库的管理员发送下线回收提示,其中下线回收提示包含数据库的标识以及符合下线回收条件的运行状态信息。Step S110 , according to the preset contact method, send an offline recovery prompt to the administrator of the database, wherein the offline recovery prompt includes the identification of the database and the operation status information meeting the offline recovery conditions.
基于本实施例提供的方案,可以为数据库管理员提供完全的知情权,使管理员可以实时地了解数据库自动下线回收的执行情况。同时,也使管理员可以及时地进行人工干预,因为在现实中,很可能会出现某个数据库符合下线回收条件,但管理员出于一些特殊的考虑,依然不对其进行下线回收的情况,本实施例提供的方案为管理员提供了很大自主权力。Based on the solution provided in this embodiment, the database administrator can be provided with complete right to know, so that the administrator can know the execution status of the automatic offline recovery of the database in real time. At the same time, it also enables the administrator to perform manual intervention in a timely manner, because in reality, it is very likely that a certain database meets the conditions for offline recovery, but the administrator still does not perform offline recovery for some special considerations , the solution provided by this embodiment provides a lot of autonomy for the administrator.
MySQL是一种典型的关系型数据库管理系统,由瑞典MySQLAB公司开发,目前属于Oracle旗下公司。MySQL最流行的关系型数据库管理系统,在WEB应用方面MySQL是最好的RDBMS(RelationalDatabaseManagementSystem,关系数据库管理系统)应用软件之一。MySQL是一种关联数据库管理系统,关联数据库将数据保存在不同的表中,而不是将所有数据放在一个大仓库内,这样就增加了速度并提高了灵活性。MySQL所使用的SQL语言是用于访问数据库的最常用标准化语言。MySQL软件采用了双授权政策,它分为社区版和商业版,由于其体积小、速度快、总体拥有成本低,尤其是开放源码这一特点,一般中小型网站的开发都选择MySQL作为网站数据库。MySQL is a typical relational database management system, developed by the Swedish MySQLAB company, which currently belongs to Oracle. MySQL is the most popular relational database management system. In terms of WEB applications, MySQL is one of the best RDBMS (Relational Database Management System, relational database management system) application software. MySQL is a relational database management system. Relational databases store data in different tables instead of putting all the data in one big warehouse, which increases speed and improves flexibility. The SQL language used by MySQL is the most commonly used standardized language for accessing databases. MySQL software adopts a dual authorization policy. It is divided into community edition and commercial edition. Due to its small size, fast speed, low overall cost of ownership, especially the open source feature, MySQL is generally chosen as the website database for the development of small and medium-sized websites. .
MySQL数据库使用SQL(StructuredQueryLanguage,结构化查询语言),其是一种特殊目的的编程语言,是一种数据库查询和程序设计语言,用于存取数据以及查询、更新和管理关系数据库系统;同时也是数据库脚本文件的扩展名。The MySQL database uses SQL (Structured Query Language, Structured Query Language), which is a special-purpose programming language, a database query and programming language for accessing data and querying, updating and managing relational database systems; it is also The extension for database script files.
结构化查询语言是高级的非过程化编程语言,允许用户在高层数据结构上工作。它不要求用户指定对数据的存放方法,也不需要用户了解具体的数据存放方式,所以具有完全不同底层结构的不同数据库系统,可以使用相同的结构化查询语言作为数据输入与管理的接口。结构化查询语言语句可以嵌套,这使它具有极大的灵活性和强大的功能。Structured Query Language is a high-level non-procedural programming language that allows users to work on high-level data structures. It does not require the user to specify the data storage method, nor does it require the user to understand the specific data storage method, so different database systems with completely different underlying structures can use the same structured query language as the interface for data input and management. Structured query language statements can be nested, which makes it extremely flexible and powerful.
本发明上述各实施例提供的技术方案可以很好应用于MySQL数据库,上述各实施例涉及的语句主要包括SQL语句。The technical solutions provided by the above-mentioned embodiments of the present invention can be well applied to MySQL databases, and the statements involved in the above-mentioned embodiments mainly include SQL statements.
下面通过一个具体实施例对上述方案进行说明,图3是根据本发明再一个实施例的判断数据库是否应下线回收的方法的流程示意图,如图3所示,该方法可以包括:The above scheme is described below through a specific embodiment. FIG. 3 is a schematic flow diagram of a method for judging whether the database should be offline and recovered according to another embodiment of the present invention. As shown in FIG. 3 , the method may include:
步骤S302,确定作为判断对象的MySQL数据库,获取MySQL数据库的类型,其为关系型数据库;Step S302, determine the MySQL database as the judgment object, and obtain the type of the MySQL database, which is a relational database;
步骤S304,判断作为判断对象的MySQL数据库的类型是否为关系型,判断结果为是;Step S304, judging whether the type of the MySQL database as the judging object is a relational type, and the judging result is yes;
步骤S306,定时执行用于获取MySQL数据库的运行状态信息的脚本,获取并保存所述数据库的运行状态信息,包括:MySQL数据库的进程的运行状态;MySQL数据库的实例的连通状态;MySQL数据库的实例的启动时间;MySQL数据库的实例中是否存在业务库,业务库中是否存在业务表;MySQL数据库的实例中业务表的最后数据修改时间;MySQL数据库使用的代理服务器是否挂载在Linux虚拟服务器下;Step S306, regularly execute the script for obtaining the running state information of the MySQL database, obtain and save the running state information of the database, including: the running state of the process of the MySQL database; the connection state of the instance of the MySQL database; the instance of the MySQL database The startup time; whether there is a business library in the MySQL database instance, whether there is a business table in the business library; the last data modification time of the business table in the MySQL database instance; whether the proxy server used by the MySQL database is mounted under the Linux virtual server;
步骤S308,判断MySQL数据库是否在业务云平台上不存在记录,但是在服务器本地存在数据目录或者其实例已启动,如果是,则执行步骤S318,如果否,则执行步骤S310;Step S308, judging whether the MySQL database does not have records on the business cloud platform, but there is a data directory locally on the server or its instance has been started, if yes, then execute step S318, if no, then execute step S310;
步骤S310,判断MySQL数据库的进程是否处于运行状态,如果否,则执行步骤S318,如果是,则执行步骤S312;Step S310, judge whether the process of MySQL database is in running state, if not, then execute step S318, if yes, then execute step S312;
步骤S312,判断MySQL数据库的proxy是否挂载在lvs下,如果否,则执行步骤S318,如果是,则执行步骤S314;Step S312, judging whether the proxy of the MySQL database is mounted under lvs, if not, then execute step S318, if yes, then execute step S314;
步骤S314,判断MySQL数据库是否启动超过60天,但是没有建立业务库或业务表,如果是,则执行步骤S318,如果否则执行步骤S316;Step S314, judging whether the MySQL database has been started for more than 60 days, but no business storehouse or business table has been established, if so, then execute step S318, if otherwise execute step S316;
步骤S316,判断MySQL数据库是否启动超过60天、建立了业务库和业务表且业务表的最后数据修改时间超过了60天,如果是,则进一步判断MySQL数据库在预定时长内是否有SQL语句访问,如果否,则执行步骤S318,如果是,则返回步骤S302;Step S316, judging whether the MySQL database has been started for more than 60 days, the business database and the business table have been set up and the last data modification time of the business table has exceeded 60 days, if yes, then further judge whether the MySQL database has SQL statement access within the predetermined time period, If no, then execute step S318, if yes, then return to step S302;
步骤S318,确定MySQL数据库符合下线回收条件;Step S318, determining that the MySQL database meets the conditions for offline recycling;
步骤S320,通过短信、邮件或其他类似的方式,向MySQL数据库的管理员发送下线回收提示,其中下线回收提示包含MySQL数据库的标识以及符合下线回收条件的运行状态信息;Step S320, sending an offline recycling reminder to the administrator of the MySQL database by text message, email or other similar means, wherein the offline recycling reminder includes the logo of the MySQL database and the running status information meeting the offline recycling conditions;
步骤S322,在管理员没有下达不允许回收的命令的前提下,下线回收MySQL数据库。Step S322, on the premise that the administrator does not issue a command not to allow recovery, the MySQL database is recovered offline.
在具体实施本实施例提供的方案时,服务器可以本地每周日上午定时执行脚本,对本机上所有数据库端口实例进行自动分析,将分析结果记录到本地文件。管理机上可以每周日下午定时执行脚本,对数据库管理员(DatabaseAdministrator,简称DBA)管理的所有数据库实例轮询访问获取分析结果,然后录入特定数据库。DBA通过登录特定网页,后台会自动执行特定SQL进行分析结果展示,整个分析过程无需人工接入。When specifically implementing the solution provided by this embodiment, the server can locally execute the script at regular intervals every Sunday morning to automatically analyze all database port instances on the local machine, and record the analysis results to a local file. The script can be executed regularly on the management machine every Sunday afternoon, polling and accessing all the database instances managed by the database administrator (Database Administrator, referred to as DBA) to obtain the analysis results, and then enter the specific database. By logging in to a specific web page, the DBA will automatically execute specific SQL in the background to display the analysis results, and the entire analysis process does not require manual access.
对应于上述各实施例提供的方法,本发明实施例还提供了一种对应的判断数据库是否应下线回收的装置。图4是根据本发明一个实施例的判断数据库是否应下线回收的装置的结构框图。如图4所示,该装置可以包括:Corresponding to the methods provided in the foregoing embodiments, the embodiment of the present invention also provides a corresponding device for judging whether the database should be taken offline for recovery. Fig. 4 is a structural block diagram of an apparatus for judging whether a database should be taken offline for recovery according to an embodiment of the present invention. As shown in Figure 4, the device may include:
类型获取模块10,用于获取作为判断对象的数据库的类型;The type acquisition module 10 is used to acquire the type of the database as the judgment object;
类型判断模块20,用于判断数据库的类型是否为关系型;Type judging module 20, for judging whether the type of database is relational;
信息获取模块30,用于在类型判断模块20的判断结果为是时,获取数据库的运行状态信息;The information acquisition module 30 is used to obtain the running status information of the database when the judgment result of the type judgment module 20 is yes;
回收判断模块40,用于基于运行状态信息,根据对应的预定策略判断数据库是否符合下线回收条件。The recycling judging module 40 is configured to judge whether the database meets the off-line recycling condition according to the corresponding predetermined strategy based on the running state information.
本实施例提供的装置会自动获取各个关系型数据库的运行状态信息,并自动判断一个关系型数据库是否需要下线回收,从而不需要用户进行任何人工操作,就可以及时地回收资源,大大提高了资源的利用率。The device provided in this embodiment will automatically obtain the running status information of each relational database, and automatically judge whether a relational database needs to be recycled offline, so that resources can be recovered in a timely manner without any manual operation by the user, which greatly improves the resource utilization.
在本发明的一个实施例中,运行状态信息可以包括下列至少之一:In an embodiment of the present invention, the running status information may include at least one of the following:
数据库的进程的运行状态;The running status of the database process;
数据库的实例的连通状态;The connectivity status of the instance of the database;
数据库的实例的启动时间;The startup time of the database instance;
数据库的实例中是否存在业务库,业务库中是否存在业务表;Whether there is a business library in the database instance, and whether there is a business table in the business library;
数据库的实例中业务表的最后数据修改时间;The last data modification time of the business table in the database instance;
数据库使用的代理服务器是否挂载在Linux虚拟服务器下。Whether the proxy server used by the database is mounted under the Linux virtual server.
本实施例中列举了几种最为典型的可用来判断一个关系型数据库是否可以下线回收的运行状态信息,基于这些运行状态信息基本上可以覆盖到所有典型的需要下线回收的关系型数据库的运行状态。当然,在具体实施时,可以根据不同的需要选择获取其中的一个或多个运行状态信息,或添加新的运行状态信息,本发明不做具体限定。This embodiment lists some of the most typical running status information that can be used to judge whether a relational database can be recycled offline. Based on these running status information, it can basically cover all typical relational databases that need to be recycled offline. Operating status. Of course, during specific implementation, one or more pieces of running state information may be selected to be acquired or new running state information may be added according to different needs, which is not specifically limited in the present invention.
在本发明的一个实施例中,如图5所示,回收判断模块40可以包括:In one embodiment of the present invention, as shown in FIG. 5, the recovery judging module 40 may include:
第一判断单元41,用于判断数据库是否在业务云平台上不存在记录,但是在服务器本地存在数据目录或者其实例已启动,如果是,则判断数据库符合下线回收条件;The first judging unit 41 is used to judge whether the database does not have a record on the business cloud platform, but there is a data directory locally on the server or its instance has been started, and if so, it is judged that the database meets the off-line recovery condition;
第二判断单元42,用于判断数据库的进程是否处于运行状态,如果否,则判断数据库符合下线回收条件;The second judging unit 42 is used to judge whether the process of the database is in the running state, if not, then judging that the database meets the off-line recovery condition;
第三判断单元43,用于判断数据库使用的代理服务器是否挂载在Linux虚拟服务器下,如果否,则判断数据库符合下线回收条件;The third judging unit 43 is used to judge whether the proxy server used by the database is mounted under the Linux virtual server, if not, then judging that the database meets the off-line recovery condition;
第四判断单元44,用于判断数据库是否启动超过第一时间阈值,但是没有建立业务库或业务表,如果是,则判断数据库符合下线回收条件;和/或The fourth judging unit 44 is used to judge whether the database starts exceeding the first time threshold, but no business library or business table is established, if so, judging that the database meets the off-line recovery condition; and/or
第五判断单元45,用于判断数据库是否启动超过第一时间阈值、建立了业务库和业务表且业务表的最后数据修改时间超过了第二时间阈值,如果是,则判断数据库在预定时长内是否有语句访问,如果否,则判断数据库符合下线回收条件。The fifth judging unit 45 is used to judge whether the database has been started beyond the first time threshold, the business database and the business table have been established and the last data modification time of the business table has exceeded the second time threshold, if so, then judge that the database is within the predetermined time length Whether there is statement access, if not, it is judged that the database meets the conditions for offline recycling.
对应于上述典型的运行状态信息,基于本实施例提供的回收判断模块40的各个单元即可高效、准确地判断出一个关系型数据库是否可以回收。Corresponding to the above-mentioned typical running state information, based on each unit of the recycling judging module 40 provided in this embodiment, it is possible to efficiently and accurately judge whether a relational database can be recycled.
在本发明的一个实施例中,如图5所示,信息获取模块30可以包括:In one embodiment of the present invention, as shown in Figure 5, the information acquisition module 30 may include:
定时获取单元31,用于定时执行用于获取数据库运行状态信息的脚本,获取并保存数据库运行状态信息。The timing acquisition unit 31 is configured to regularly execute a script for acquiring database operation status information, and acquire and save the database operation status information.
在本实施例提供的方案中,属于信息获取模块30的定时获取单元31采用专用脚本获取数据库的运行状态信息,实现简单,占用的资源较少,执行的效率也比较高。In the solution provided in this embodiment, the timing acquisition unit 31 belonging to the information acquisition module 30 acquires the running status information of the database using a dedicated script, which is simple to implement, occupies less resources, and has relatively high execution efficiency.
在本发明的一个实施例中,如图5所示,上述装置还可以包括:In one embodiment of the present invention, as shown in FIG. 5, the above-mentioned device may further include:
回收提示模块50,用于在回收判断模块40判断数据库符合下线回收条件时,依据预设联络方式,向数据库的管理员发送下线回收提示,其中下线回收提示包含数据库的标识以及符合下线回收条件的运行状态信息。The recycling reminder module 50 is used to send an offline recycling reminder to the administrator of the database according to the preset contact method when the recycling judging module 40 judges that the database meets the offline recycling conditions, wherein the offline recycling reminder includes the identification of the database and meets the following requirements. Running status information for the line recycling condition.
在本实施例提供的方案中,回收提示模块50为数据库管理员提供了完全的知情权,使管理员可以实时地了解数据库自动下线回收的执行情况。同时,也使管理员可以及时地进行人工干预,因为在现实中,很可能会出现某个数据库符合下线回收条件,但管理员出于一些特殊的考虑,依然不对其进行下线回收的情况,本实施例提供的方案为管理员提供了很大的自主权力。In the solution provided in this embodiment, the recovery prompt module 50 provides the database administrator with complete right to know, so that the administrator can know the execution status of the automatic offline recovery of the database in real time. At the same time, it also enables the administrator to perform manual intervention in a timely manner, because in reality, it is very likely that a certain database meets the conditions for offline recovery, but the administrator still does not perform offline recovery for some special considerations , the solution provided by this embodiment provides a great autonomy for the administrator.
优选地,在上述各个实施例中,设计的关系型数据库可以是MySQL数据库,涉及的语句可以是SQL语句。Preferably, in each of the above embodiments, the designed relational database may be a MySQL database, and the statements involved may be SQL statements.
本发明实施例提供的方案会自动获取各个关系型数据库的运行状态信息,并自动判断一个关系型数据库是否需要下线回收,同时,判断的结果会通过预订的方式及时地发送给数据库管理员,从而不需要用户进行任何人工操作,就可以及时地回收资源,大大提高了资源的利用率。在特殊的情况下,数据库管理员也可以阻止对某个特定的数据库的下线回收操作,为管理员提供了很大的自主权力。The solution provided by the embodiment of the present invention will automatically obtain the operation status information of each relational database, and automatically judge whether a relational database needs to be taken offline for recycling. At the same time, the judgment result will be sent to the database administrator in a timely manner by reservation. Therefore, resources can be recovered in a timely manner without any manual operation by the user, which greatly improves the utilization rate of resources. Under special circumstances, the database administrator can also prevent the offline recovery operation of a specific database, providing administrators with great autonomy.
在此处所提供的说明书中,说明了大量具体细节。然而,能够理解,本发明的实施例可以在没有这些具体细节的情况下实践。在一些实例中,并未详细示出公知的方法、结构和技术,以便不模糊对本说明书的理解。In the description provided herein, numerous specific details are set forth. However, it is understood that embodiments of the invention may be practiced without these specific details. In some instances, well-known methods, structures and techniques have not been shown in detail in order not to obscure the understanding of this description.
类似地,应当理解,为了精简本公开并帮助理解各个发明方面中的一个或多个,在上面对本发明的示例性实施例的描述中,本发明的各个特征有时被一起分组到单个实施例、图、或者对其的描述中。然而,并不应将该公开的方法解释成反映如下意图:即所要求保护的本发明要求比在每个权利要求中所明确记载的特征更多的特征。更确切地说,如下面的权利要求书所反映的那样,发明方面在于少于前面公开的单个实施例的所有特征。因此,遵循具体实施方式的权利要求书由此明确地并入该具体实施方式,其中每个权利要求本身都作为本发明的单独实施例。Similarly, it should be appreciated that in the foregoing description of exemplary embodiments of the invention, in order to streamline this disclosure and to facilitate an understanding of one or more of the various inventive aspects, various features of the invention are sometimes grouped together in a single embodiment, figure, or its description. This method of disclosure, however, is not to be interpreted as reflecting an intention that the claimed invention requires more features than are expressly recited in each claim. Rather, as the following claims reflect, inventive aspects lie in less than all features of a single foregoing disclosed embodiment. Thus, the claims following the Detailed Description are hereby expressly incorporated into this Detailed Description, with each claim standing on its own as a separate embodiment of this invention.
本领域那些技术人员可以理解,可以对实施例中的设备中的模块进行自适应性地改变并且把它们设置在与该实施例不同的一个或多个设备中。可以把实施例中的模块或单元或组件组合成一个模块或单元或组件,以及此外可以把它们分成多个子模块或子单元或子组件。除了这样的特征和/或过程或者单元中的至少一些是相互排斥之外,可以采用任何组合对本说明书(包括伴随的权利要求、摘要和附图)中公开的所有特征以及如此公开的任何方法或者设备的所有过程或单元进行组合。除非另外明确陈述,本说明书(包括伴随的权利要求、摘要和附图)中公开的每个特征可以由提供相同、等同或相似目的的替代特征来代替。Those skilled in the art can understand that the modules in the device in the embodiment can be adaptively changed and arranged in one or more devices different from the embodiment. Modules or units or components in the embodiments may be combined into one module or unit or component, and furthermore may be divided into a plurality of sub-modules or sub-units or sub-assemblies. All features disclosed in this specification (including accompanying claims, abstract and drawings) and any method or method so disclosed may be used in any combination, except that at least some of such features and/or processes or units are mutually exclusive. All processes or units of equipment are combined. Each feature disclosed in this specification (including accompanying claims, abstract and drawings) may be replaced by alternative features serving the same, equivalent or similar purpose, unless expressly stated otherwise.
此外,本领域的技术人员能够理解,尽管在此所述的一些实施例包括其它实施例中所包括的某些特征而不是其它特征,但是不同实施例的特征的组合意味着处于本发明的范围之内并且形成不同的实施例。例如,在权利要求书中,所要求保护的实施例的任意之一都可以以任意的组合方式来使用。Furthermore, those skilled in the art will understand that although some embodiments described herein include some features included in other embodiments but not others, combinations of features from different embodiments are meant to be within the scope of the invention. and form different embodiments. For example, in the claims, any one of the claimed embodiments can be used in any combination.
本发明的各个部件实施例可以以硬件实现,或者以在一个或者多个处理器上运行的软件模块实现,或者以它们的组合实现。本领域的技术人员应当理解,可以在实践中使用微处理器或者数字信号处理器(DSP)来实现根据本发明实施例的判断数据库是否应下线回收的装置中的一些或者全部部件的一些或者全部功能。本发明还可以实现为用于执行这里所描述的方法的一部分或者全部的设备或者装置程序(例如,计算机程序和计算机程序产品)。这样的实现本发明的程序可以存储在计算机可读介质上,或者可以具有一个或者多个信号的形式。这样的信号可以从因特网网站上下载得到,或者在载体信号上提供,或者以任何其他形式提供。The various component embodiments of the present invention may be implemented in hardware, or in software modules running on one or more processors, or in a combination thereof. Those skilled in the art should understand that a microprocessor or a digital signal processor (DSP) can be used in practice to implement some or all of the components in the device for judging whether the database should be offline for recycling according to an embodiment of the present invention. Full functionality. The present invention can also be implemented as an apparatus or an apparatus program (for example, a computer program and a computer program product) for performing a part or all of the methods described herein. Such a program for realizing the present invention may be stored on a computer-readable medium, or may be in the form of one or more signals. Such a signal may be downloaded from an Internet site, or provided on a carrier signal, or provided in any other form.
应该注意的是上述实施例对本发明进行说明而不是对本发明进行限制,并且本领域技术人员在不脱离所附权利要求的范围的情况下可设计出替换实施例。在权利要求中,不应将位于括号之间的任何参考符号构造成对权利要求的限制。单词“包含”不排除存在未列在权利要求中的元件或步骤。位于元件之前的单词“一”或“一个”不排除存在多个这样的元件。本发明可以借助于包括有若干不同元件的硬件以及借助于适当编程的计算机来实现。在列举了若干装置的单元权利要求中,这些装置中的若干个可以是通过同一个硬件项来具体体现。单词第一、第二、以及第三等的使用不表示任何顺序。可将这些单词解释为名称。It should be noted that the above-mentioned embodiments illustrate rather than limit the invention, and that those skilled in the art will be able to design alternative embodiments without departing from the scope of the appended claims. In the claims, any reference signs placed between parentheses shall not be construed as limiting the claim. The word "comprising" does not exclude the presence of elements or steps not listed in a claim. The word "a" or "an" preceding an element does not exclude the presence of a plurality of such elements. The invention can be implemented by means of hardware comprising several distinct elements, and by means of a suitably programmed computer. In a unit claim enumerating several means, several of these means can be embodied by one and the same item of hardware. The use of the words first, second, and third, etc. does not indicate any order. These words can be interpreted as names.
至此,本领域技术人员应认识到,虽然本文已详尽示出和描述了本发明的多个示例性实施例,但是,在不脱离本发明精神和范围的情况下,仍可根据本发明公开的内容直接确定或推导出符合本发明原理的许多其他变型或修改。因此,本发明的范围应被理解和认定为覆盖了所有这些其他变型或修改。So far, those skilled in the art should appreciate that, although a number of exemplary embodiments of the present invention have been shown and described in detail herein, without departing from the spirit and scope of the present invention, the disclosed embodiments of the present invention can still be used. Many other variations or modifications consistent with the principles of the invention are directly identified or derived from the content. Accordingly, the scope of the present invention should be understood and deemed to cover all such other variations or modifications.
根据本发明的一个方面,提供了A1.一种判断数据库是否应下线回收的方法,包括:According to one aspect of the present invention, there is provided A1. A method for judging whether the database should be recovered offline, including:
获取作为判断对象的数据库的类型;Obtain the type of the database as the judgment object;
判断所述数据库的类型是否为关系型;Determine whether the type of the database is relational;
若是,则获取所述数据库的运行状态信息;If so, obtain the running status information of the database;
基于所述运行状态信息,根据对应的预定策略判断所述数据库是否符合下线回收条件。Based on the running state information, it is judged according to a corresponding predetermined policy whether the database meets the offline recovery condition.
A2.根据A1所述的方法,其中,所述运行状态信息包括下列至少之一:A2. The method according to A1, wherein the running status information includes at least one of the following:
所述数据库的进程的运行状态;The running state of the process of the database;
所述数据库的实例的连通状态;the connectivity status of the instance of the database;
所述数据库的实例的启动时间;The startup time of the instance of the database;
所述数据库的实例中是否存在业务库,所述业务库中是否存在业务表;Whether there is a business library in the instance of the database, and whether there is a business table in the business library;
所述数据库的实例中业务表的最后数据修改时间;The last data modification time of the business table in the instance of the database;
所述数据库使用的代理服务器是否挂载在Linux虚拟服务器下。Whether the proxy server used by the database is mounted under the Linux virtual server.
A3.根据A2所述的方法,其中,所述基于所述运行状态信息,根据对应的预定策略判断所述数据库是否符合下线回收条件包括下列至少之一:A3. The method according to A2, wherein, based on the operation state information, judging whether the database meets the offline recovery condition according to the corresponding predetermined strategy includes at least one of the following:
判断所述数据库是否在业务云平台上不存在记录,但是在服务器本地存在数据目录或者其实例已启动,如果是,则判断所述数据库符合下线回收条件;Judging whether the database does not have a record on the business cloud platform, but there is a data directory locally on the server or its instance has been started, if so, then judging that the database meets the offline recovery conditions;
判断所述数据库的进程是否处于运行状态,如果否,则判断所述数据库符合下线回收条件;Judging whether the process of the database is in a running state, if not, judging that the database meets the conditions for offline recovery;
判断所述数据库使用的代理服务器是否挂载在Linux虚拟服务器下,如果否,则判断所述数据库符合下线回收条件;Judging whether the proxy server used by the database is mounted under the Linux virtual server, if not, then judging that the database meets the off-line recovery condition;
判断所述数据库是否启动超过第一时间阈值,但是没有建立业务库或业务表,如果是,则判断所述数据库符合下线回收条件;Judging whether the database starts exceeding the first time threshold, but does not establish a business library or business table, if so, then judging that the database meets the off-line recovery condition;
判断所述数据库是否启动超过所述第一时间阈值、建立了业务库和业务表且所述业务表的最后数据修改时间超过了第二时间阈值,如果是,则判断所述数据库在预定时长内是否有语句访问,如果否,则判断所述数据库符合下线回收条件。Judging whether the database starts exceeding the first time threshold, establishes a business library and a business table, and the last data modification time of the business table exceeds a second time threshold, if so, then judges that the database is within a predetermined time period Whether there is a statement access, if not, it is judged that the database meets the offline recovery condition.
A4.根据A1所述的方法,其中,所述获取所述数据库的运行状态信息包括:A4. The method according to A1, wherein said obtaining the running status information of said database comprises:
定时执行用于获取所述数据库的运行状态信息的脚本,获取并保存所述数据库的运行状态信息。The script for obtaining the running state information of the database is executed regularly, and the running state information of the database is obtained and saved.
A5.根据A1-A4任一项所述的方法,其中,若判断所述数据库符合下线回收条件,所述方法还包括:A5. The method according to any one of A1-A4, wherein, if it is judged that the database meets the conditions for offline recovery, the method further includes:
依据预设联络方式,向所述数据库的管理员发送下线回收提示,其中所述下线回收提示包含所述数据库的标识以及符合下线回收条件的运行状态信息。Sending an offline recovery prompt to the administrator of the database according to a preset contact method, wherein the offline recovery prompt includes the database identifier and operation status information meeting the offline recovery conditions.
A6.根据A1-A4任一项所述的方法,其中,所述关系型数据库包括:MySQL数据库。A6. The method according to any one of A1-A4, wherein the relational database comprises: a MySQL database.
根据本发明的另一个方面,还提供了B7.一种判断数据库是否应下线回收的装置,包括:According to another aspect of the present invention, there is also provided B7. A device for judging whether the database should be recovered offline, including:
类型获取模块,用于获取作为判断对象的数据库的类型;A type acquisition module, configured to acquire the type of the database as the judgment object;
类型判断模块,用于判断所述数据库的类型是否为关系型;A type judging module, configured to judge whether the type of the database is relational;
信息获取模块,用于在所述类型判断模块的判断结果为是时,获取所述数据库的运行状态信息;An information acquisition module, configured to acquire the operation status information of the database when the judgment result of the type judgment module is yes;
回收判断模块,用于基于所述运行状态信息,根据对应的预定策略判断所述数据库是否符合下线回收条件。The recycling judging module is configured to judge whether the database meets the off-line recycling condition according to the corresponding predetermined strategy based on the running status information.
B8.根据B7所述的装置,其中,所述运行状态信息包括下列至少之一:B8. The device according to B7, wherein the operating status information includes at least one of the following:
所述数据库的进程的运行状态;The running state of the process of the database;
所述数据库的实例的连通状态;the connectivity status of the instance of the database;
所述数据库的实例的启动时间;The startup time of the instance of the database;
所述数据库的实例中是否存在业务库,所述业务库中是否存在业务表;Whether there is a business library in the instance of the database, and whether there is a business table in the business library;
所述数据库的实例中业务表的最后数据修改时间;The last data modification time of the business table in the instance of the database;
所述数据库使用的代理服务器是否挂载在Linux虚拟服务器下。Whether the proxy server used by the database is mounted under the Linux virtual server.
B9.根据B8所述的装置,其中,所述回收判断模块包括:B9. The device according to B8, wherein the recovery judgment module includes:
第一判断单元,用于判断所述数据库是否在业务云平台上不存在记录,但是在服务器本地存在数据目录或者其实例已启动,如果是,则判断所述数据库符合下线回收条件;The first judging unit is used to judge whether the database does not have a record on the business cloud platform, but there is a data directory locally on the server or its instance has been started, and if so, judging that the database meets the off-line recovery condition;
第二判断单元,用于判断所述数据库的进程是否处于运行状态,如果否,则判断所述数据库符合下线回收条件;The second judging unit is used for judging whether the process of the database is running, if not, judging that the database meets the off-line recovery condition;
第三判断单元,用于判断所述数据库使用的代理服务器是否挂载在Linux虚拟服务器下,如果否,则判断所述数据库符合下线回收条件;The third judging unit is used for judging whether the proxy server used by the database is mounted under the Linux virtual server, if not, judging that the database meets the off-line recycling condition;
第四判断单元,用于判断所述数据库是否启动超过第一时间阈值,但是没有建立业务库或业务表,如果是,则判断所述数据库符合下线回收条件;和/或The fourth judging unit is used to judge whether the database has been activated for more than the first time threshold, but no business database or business table has been established, and if so, judging that the database meets the conditions for offline recovery; and/or
第五判断单元,用于判断所述数据库是否启动超过所述第一时间阈值、建立了业务库和业务表且所述业务表的最后数据修改时间超过了第二时间阈值,如果是,则判断所述数据库在预定时长内是否有语句访问,如果否,则判断所述数据库符合下线回收条件。The fifth judging unit is used for judging whether the database starts exceeding the first time threshold, the business database and the business table are established, and the last data modification time of the business table exceeds the second time threshold, and if so, judging Whether the database is accessed by a statement within a predetermined period of time, and if not, it is judged that the database meets the offline recovery condition.
B10.根据B7所述的装置,其中,所述信息获取模块包括:B10. The device according to B7, wherein the information acquisition module includes:
定时获取单元,用于定时执行用于获取所述数据库运行状态信息的脚本,获取并保存所述数据库运行状态信息。The timing acquisition unit is configured to regularly execute the script for acquiring the database operation status information, acquire and store the database operation status information.
B11.根据B7-B10任一项所述的装置,其中,还包括:B11. The device according to any one of B7-B10, further comprising:
回收提示模块,用于在所述回收判断模块判断所述数据库符合下线回收条件时,依据预设联络方式,向所述数据库的管理员发送下线回收提示,其中所述下线回收提示包含所述数据库的标识以及符合下线回收条件的运行状态信息。The recovery prompt module is used to send an offline recovery prompt to the administrator of the database according to the preset contact method when the recovery judging module judges that the database meets the conditions for offline recovery, wherein the offline recovery prompt includes The identification of the database and the running status information meeting the offline recycling conditions.
B12.根据B7-B10任一项所述的装置,其中,所述关系型数据库包括:MySQL数据库。B12. The device according to any one of B7-B10, wherein the relational database comprises: a MySQL database.
Claims (10)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201510997513.9A CN105574195B (en) | 2015-12-25 | 2015-12-25 | Judge whether database answers the method and device of offline recycling |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201510997513.9A CN105574195B (en) | 2015-12-25 | 2015-12-25 | Judge whether database answers the method and device of offline recycling |
Publications (2)
Publication Number | Publication Date |
---|---|
CN105574195A true CN105574195A (en) | 2016-05-11 |
CN105574195B CN105574195B (en) | 2019-07-23 |
Family
ID=55884326
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201510997513.9A Active CN105574195B (en) | 2015-12-25 | 2015-12-25 | Judge whether database answers the method and device of offline recycling |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN105574195B (en) |
Cited By (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN108460160A (en) * | 2018-03-29 | 2018-08-28 | 武汉斗鱼网络科技有限公司 | Inserting method, device, terminal and the storage medium of database instance |
CN111752695A (en) * | 2020-06-28 | 2020-10-09 | 北京百度网讯科技有限公司 | Offline method, apparatus, device and storage medium |
CN116627929A (en) * | 2022-02-14 | 2023-08-22 | 网联清算有限公司 | Database offline method and device, electronic equipment and computer readable storage medium |
CN118708595A (en) * | 2024-08-29 | 2024-09-27 | 智者四海(北京)技术有限公司 | Backtracking database table recovery management method, device, equipment and medium |
Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US6209062B1 (en) * | 1997-11-24 | 2001-03-27 | Intel Corporation | Method for holding cache pages that are not invalidated within normal time duration for a second access or that are likely to be accessed again soon |
US20060074956A1 (en) * | 2004-10-05 | 2006-04-06 | Oracle International Corporation | Method and system for time-based reclamation of objects from a recycle bin in a database |
CN101539878A (en) * | 2008-03-18 | 2009-09-23 | 环达电脑(上海)有限公司 | Method for accelerating oracle process to monitor recycled resources under operating system |
CN102567531A (en) * | 2011-12-30 | 2012-07-11 | 互动在线(北京)科技有限公司 | General method for monitoring status of light database |
CN103365929A (en) * | 2012-04-10 | 2013-10-23 | 阿里巴巴集团控股有限公司 | Management method and management system of database connection |
CN104486155A (en) * | 2014-12-15 | 2015-04-01 | 北京趣拿软件科技有限公司 | Database cluster monitoring method and system |
CN104809247A (en) * | 2015-05-18 | 2015-07-29 | 北京京东尚科信息技术有限公司 | Allocation and recovery method of database connections |
-
2015
- 2015-12-25 CN CN201510997513.9A patent/CN105574195B/en active Active
Patent Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US6209062B1 (en) * | 1997-11-24 | 2001-03-27 | Intel Corporation | Method for holding cache pages that are not invalidated within normal time duration for a second access or that are likely to be accessed again soon |
US20060074956A1 (en) * | 2004-10-05 | 2006-04-06 | Oracle International Corporation | Method and system for time-based reclamation of objects from a recycle bin in a database |
CN101539878A (en) * | 2008-03-18 | 2009-09-23 | 环达电脑(上海)有限公司 | Method for accelerating oracle process to monitor recycled resources under operating system |
CN102567531A (en) * | 2011-12-30 | 2012-07-11 | 互动在线(北京)科技有限公司 | General method for monitoring status of light database |
CN103365929A (en) * | 2012-04-10 | 2013-10-23 | 阿里巴巴集团控股有限公司 | Management method and management system of database connection |
CN104486155A (en) * | 2014-12-15 | 2015-04-01 | 北京趣拿软件科技有限公司 | Database cluster monitoring method and system |
CN104809247A (en) * | 2015-05-18 | 2015-07-29 | 北京京东尚科信息技术有限公司 | Allocation and recovery method of database connections |
Non-Patent Citations (1)
Title |
---|
FEI LIU: "A Method of Design and Optimization of Database Connection Pool", 《2012 4TH INTERNATIONAL CONFERENCE ON INTELLIGENT HUMAN-MACHINE SYSTEMS AND CYBERNETICS》 * |
Cited By (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN108460160A (en) * | 2018-03-29 | 2018-08-28 | 武汉斗鱼网络科技有限公司 | Inserting method, device, terminal and the storage medium of database instance |
CN108460160B (en) * | 2018-03-29 | 2021-03-12 | 武汉斗鱼网络科技有限公司 | Off-line method, device, terminal and storage medium of database instance |
CN111752695A (en) * | 2020-06-28 | 2020-10-09 | 北京百度网讯科技有限公司 | Offline method, apparatus, device and storage medium |
CN116627929A (en) * | 2022-02-14 | 2023-08-22 | 网联清算有限公司 | Database offline method and device, electronic equipment and computer readable storage medium |
CN118708595A (en) * | 2024-08-29 | 2024-09-27 | 智者四海(北京)技术有限公司 | Backtracking database table recovery management method, device, equipment and medium |
CN118708595B (en) * | 2024-08-29 | 2024-11-22 | 智者四海(北京)技术有限公司 | Backtracking database table recovery management method, device, equipment and medium |
Also Published As
Publication number | Publication date |
---|---|
CN105574195B (en) | 2019-07-23 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US10275355B2 (en) | Method and apparatus for cleaning files in a mobile terminal and associated mobile terminal | |
CN108536761B (en) | Report data query method and server | |
CN105426544B (en) | Method and device for monitoring database status | |
WO2013143391A1 (en) | Method and system for cleaning up files on device | |
CN110287696B (en) | A detection method, device and equipment for reverse shell process | |
CN104169914A (en) | Data storage method, data processing method, device and mobile terminal | |
CN110989937A (en) | Data storage method, device and equipment and computer readable storage medium | |
US11200201B2 (en) | Metadata storage method, device and server | |
CN111339171A (en) | Data query method, device and device | |
CN105574195B (en) | Judge whether database answers the method and device of offline recycling | |
CN108897859A (en) | A kind of metadata retrieval method, apparatus, equipment and computer readable storage medium | |
CN112148477A (en) | Service process processing method, electronic device and storage medium | |
US11294866B2 (en) | Lazy optimistic concurrency control | |
CN105786843A (en) | Multi-language implementation method for applications and multi-language information query method and device | |
CN105893152A (en) | Memory management method and device and mobile terminal | |
CN109063061B (en) | Cross-distributed system data processing method, device, equipment and storage medium | |
CN107562568B (en) | File backup method and device | |
CN1963821A (en) | Method, system and apparatus to realize accessing to database | |
CN106649584B (en) | Index processing method and device in master-slave database system | |
CN114385733A (en) | Method and device for unified creation of data model in ETL process | |
CN102375888A (en) | Method for deleting big files in distributed file system efficiently | |
CN107341105A (en) | Information processing method, terminal and server | |
CN111552956A (en) | Role authority control method and device for background management | |
EP3082050A1 (en) | Mass data fusion storage method and system | |
CN110019448B (en) | Data interaction method and device |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant | ||
TR01 | Transfer of patent right |
Effective date of registration: 20220718 Address after: Room 801, 8th floor, No. 104, floors 1-19, building 2, yard 6, Jiuxianqiao Road, Chaoyang District, Beijing 100015 Patentee after: BEIJING QIHOO TECHNOLOGY Co.,Ltd. Address before: 100088 room 112, block D, 28 new street, new street, Xicheng District, Beijing (Desheng Park) Patentee before: BEIJING QIHOO TECHNOLOGY Co.,Ltd. Patentee before: Qizhi software (Beijing) Co.,Ltd. |
|
TR01 | Transfer of patent right |