Detailed Description
For the purpose of making the objects, technical solutions and advantages of the embodiments of the present invention more apparent, the embodiments of the present invention will be described in further detail with reference to the accompanying drawings. The exemplary embodiments of the present invention and their descriptions herein are for the purpose of explaining the present invention, but are not to be construed as limiting the invention.
In the description of the present specification, the terms "comprising," "including," "having," "containing," and the like are open-ended terms, meaning including, but not limited to. The description of the reference terms "one embodiment," "a particular embodiment," "some embodiments," "for example," etc., means that a particular feature, structure, or characteristic described in connection with the embodiment or example is included in at least one embodiment or example of the application. In this specification, schematic representations of the above terms do not necessarily refer to the same embodiments or examples. Furthermore, the particular features, structures, or characteristics described may be combined in any suitable manner in any one or more embodiments or examples. The order of steps involved in the embodiments is illustrative of the practice of the application, and is not limited and may be suitably modified as desired.
First, terms involved in the embodiments of the present invention will be explained.
Development environment-environment in which environment deployment and maintenance are performed by developers with respect to a functional test environment, a drilling environment, and a production environment.
Linux file operation authority, namely the Linux file operation authority has current user authority, current user group authority and other user authorities.
Jboss A business version of a web service.
Jboss the buffer memory Jboss stores the buffered temporary directory file, which is auth, vfs, work directory under/standalone/tmp.
FIG. 1 is a flowchart of a Jboss cache cleaning method in an embodiment of the present invention, as shown in FIG. 1, including:
Step 101, acquiring a plurality of idle Jboss services in a Linux system in a first preset time period of each day;
102, stopping Jboss service processes by adopting root user rights of a Linux system for each idle Jboss service;
step 103, modifying the file related to the Jboss service into the authority of Jboss service user by adopting the root user authority;
Step 104, archiving the log in the Jboss service cache to a target server;
Step 105, deleting the log in the Jboss service cache by adopting the root user authority;
And 106, switching the root user to the Jboss user, and starting the Jboss service process.
In the embodiment of the invention, the idle Jboss service is cleaned in the first preset period of each day to realize fluctuation processing, ensure Jboss to continuously provide service, correct wrong file authority, periodically clean and restart Jboss service, ensure Jboss to stably provide service, avoid some problems of long-term operation or wrong file authority, and periodically archive logs to solve the problem of insufficient space of Jboss service.
In step 101, a plurality of idle Jboss services in the Linux system are acquired during a first preset time period of each day.
The first preset period may be at night, for example, 0 to 8 nights, so as to minimize the influence of daytime on Jboss services.
FIG. 2 is a flowchart of acquiring idle Jboss services in an embodiment of the present invention, in one embodiment, acquiring a plurality of idle Jboss services in a Linux system, including:
step 201, jboss services to be cleaned in the same day in a Linux system are obtained;
Step 202, obtaining Jboss services which provide services to the outside currently through the inquiry of an apache connection pool;
In step 203, the Jboss service that is providing the service is deleted from Jboss services to be cleaned, the Jboss service that is providing the service to the outside is deleted from Jboss services to be cleaned on the same day, and a plurality of idle Jboss services are obtained.
In the above embodiment, each Jboss service is typically used once within 2 minutes according to the apache load balancing policy, and thus, jboss service that is currently providing service is available.
In an embodiment, the method further comprises:
And polling every first preset time length to obtain Jboss services which are not cleaned and are free on the same day.
The first preset duration may be 1 hour, which is determined according to practical situations.
In step 102, for each free Jboss service, the root user authority of the Linux system is adopted to stop the Jboss service process.
The root user has higher authority, and can forcedly stop Jboss the service process. In an embodiment, after deleting the log in the Jboss service cache by adopting the root user authority, the method further includes:
and when the current residual space of Jboss services is smaller than a preset threshold value, generating early warning information, wherein the early warning information is used for reminding a developer Jboss that the service space is insufficient.
The preset threshold value can be 5G, and the early warning information can be sent to maintenance and development personnel through mail to manually check the space storage condition, so that manual cleaning is performed.
In step 103, the root user authority is adopted to modify the file related to the Jboss service into the authority of Jboss service user.
The purpose of modifying rights is to restore Jboss the correct rights to the file to which the service relates.
In step 104, the log in the Jboss service cache is archived to the target server.
FIG. 3 is a flowchart of archiving journals in the Jboss service cache to a target server according to one embodiment of the present invention, including:
step 301, checking the current residual space of the target server;
Step 302, determining the number of days of log capable of being archived according to the current residual space;
and step 303, archiving the log of the log days capable of being archived to a target server.
For example, if the current remaining space is 20G or more, a log 7 days ago is archived.
If the current remaining space is less than 20G and greater than or equal to 10G, archiving the log 3 days ago.
If the current remaining space is less than 10G, a log 1 day ago is archived.
And 105, deleting the log in the Jboss service cache by adopting the root user authority.
Specifically, the log in the auth, vfs, work directory under delete/standalone/tmp.
And 106, switching the root user to the Jboss user, and starting the Jboss service process.
In an embodiment, the method further comprises:
After Jboss services to be cleaned are cleaned and started in the same day, inquiring an apache list to obtain all Jboss services, inquiring a management console list to check Jboss services which are communicated normally, polling to send getIP http requests to the apache for Jboss services in the management console list, determining that Jboss services are normal if the IP of Jboss services which exist in the apache list and exist in the management console list is obtained within a second preset time period, otherwise, repeating steps 101-106 of Jboss services which correspond to the IP which do not exist in the management console list or Jboss services which send getIP non-returned IP, and generating a cleaning error report if Jboss services which do not return IP still do not return IP after the repetition number reaches a set number threshold.
The above is a procedure of smoke test, for example, a case of sending once in 5 seconds in 2 minutes, and returning all the IP in 2 minutes, then Jboss services are normally provided. The set number of times threshold may be 3 times, with a clean-up error report for transmission to maintenance personnel.
In an embodiment, the method further comprises:
And sending getIP http requests to the apache every third preset time period in a second preset time period of each day, repeatedly executing steps 101-106 for Jboss service without returning IP if Jboss service without returning IP exists, and generating warning information if Jboss service without returning IP still does not return IP after the repeated times reach a set time threshold.
The second preset period may be daytime, for example, 8:00-18:00, for daily monitoring, and the warning message may indicate the reason, if Jboss is insufficient in service space, the reason indicates "insufficient space", otherwise indicates "start abnormality due to unknown reason".
In an embodiment, the method further comprises:
When a log of a debug level exists in the target server, generating warning information, wherein the warning information is used for reminding a developer to process the log level. If the developer considers the log level is not right, the developer can check Jboss whether the service is abnormal.
In summary, in the method provided by the embodiment of the invention, a plurality of idle Jboss services in a Linux system are acquired in a first preset time period every day, for each idle Jboss service, the Jboss service process is stopped by adopting the root user authority of the Linux system, the file related to the Jboss service is modified into the authority of Jboss service users by adopting the root user authority, the log in the Jboss service cache is archived to a target server, the log in the Jboss service cache is deleted by adopting the root user authority, the root user is switched to the user of Jboss, and the Jboss service process is started. In the process, the idle Jboss service is cleaned in a first preset period of each day to realize fluctuation processing, jboss is guaranteed to continuously provide service, wrong file authority is corrected, jboss service is cleaned and restarted periodically, jboss is guaranteed to stably provide service, problems of long-term operation or wrong file authority are avoided, and the problem of frequent space shortage of Jboss service is solved through periodic log archiving.
The invention also provides Jboss cache cleaning device, the principle of which is the same as that of Jboss cache cleaning method, and the description is omitted here.
Fig. 4 is a schematic diagram of a Jboss cache cleaning device according to an embodiment of the present invention, as shown in fig. 4, including:
An idle service obtaining module 401, configured to obtain a plurality of idle Jboss services in the Linux system in a first preset period of time every day;
a process stopping module 402, configured to stop the Jboss service process for each idle Jboss service by using root user rights of the Linux system;
A file authority modification module 403, configured to modify a file related to the Jboss service into an authority of a Jboss service user by using the root user authority;
a log archiving module 404, configured to archive the log in the Jboss service cache to a target server;
A cleaning module 405, configured to delete the log in the Jboss service cache using the root user permission;
And a process starting module 406, configured to switch the root user to the user Jboss, and start the Jboss service process.
In an embodiment, the idle service obtaining module is specifically configured to:
jboss services to be cleaned in the current day in the Linux system are acquired;
acquiring Jboss services which are currently providing services through a connection test with an apache;
From Jboss services to be cleaned, the Jboss services that are providing the services are deleted, and the idle Jboss services are obtained.
In an embodiment, the idle service acquisition module is further configured to:
And polling every first preset time length to obtain Jboss services which are not cleaned and are free on the same day.
Fig. 5 is a schematic diagram two of a Jboss cache cleaning device according to an embodiment of the present invention, where in an embodiment, the device further includes an anomaly monitoring module 501 configured to:
After Jboss services to be cleaned are cleaned and started in the same day, inquiring an apache list to obtain all Jboss services, inquiring a management console list to check Jboss services which are communicated normally, polling to send getIP http requests to the apache for Jboss services in the management console list, determining that Jboss services are normal if the IP of Jboss services which exist in the apache list and exist in the management console list is obtained within a second preset time period, otherwise, repeatedly executing steps 101-106 for Jboss services which do not exist in the management console list or Jboss services which send getIP and do not return to the IP, and generating a cleaning error report if Jboss services which do not return to the IP still do not return to the IP after the repetition times reach a set time threshold.
In one embodiment, the anomaly monitoring module 501 is further configured to:
And sending getIP http requests to the apache every third preset time period in a second preset time period of each day, repeatedly executing steps 101-106 for Jboss service without returning IP if Jboss service without returning IP exists, and generating warning information if Jboss service without returning IP still does not return IP after the repeated times reach a set time threshold.
In one embodiment, the log archiving module is specifically configured to:
checking the current residual space of the target server;
determining the number of days of the log capable of being archived according to the current residual space;
and archiving the log of the log days capable of being archived to a target server.
In one embodiment, the anomaly monitoring module 501 is further configured to:
and when the current residual space of Jboss services is smaller than a preset threshold value, generating early warning information, wherein the early warning information is used for reminding a developer Jboss that the service space is insufficient.
Fig. 6 is a schematic diagram III of a Jboss cache cleaning device according to an embodiment of the present invention, where in an embodiment, the device further includes a target server monitoring module 601, configured to:
When a log of a debug level exists in the target server, generating warning information, wherein the warning information is used for reminding a developer to process the log level.
In summary, in the method and the device provided by the embodiment of the invention, the idle service obtaining module is used for obtaining a plurality of idle Jboss services in the Linux system in a first preset time period every day, the process stopping module is used for stopping the Jboss service process by adopting root user permission of the Linux system for each idle Jboss service, the file permission correcting module is used for correcting files related to the Jboss service into permissions of Jboss service users by adopting the root user permission, the log archiving module is used for archiving logs in the Jboss service cache to a target server, the cleaning module is used for deleting the logs in the Jboss service cache by adopting the root user permission, and the process starting module is used for switching the root user to a Jboss user and starting the Jboss service process. In the process, the idle Jboss service is cleaned in a first preset period of each day to realize fluctuation processing, jboss is guaranteed to continuously provide service, wrong file authority is corrected, jboss service is cleaned and restarted periodically, jboss is guaranteed to stably provide service, problems of long-term operation or wrong file authority are avoided, and the problem of frequent space shortage of Jboss service is solved through periodic log archiving.
An embodiment of the present invention further provides a computer device, and fig. 7 is a schematic diagram of a computer device in the embodiment of the present invention, where the computer device can implement all steps in the Jboss cache cleaning method in the foregoing embodiment, and the computer device specifically includes the following contents:
a processor (processor) 701, a memory (memory) 702, a communication interface (Communications Interface) 703, and a communication bus 704;
The processor 701, the memory 702 and the communication interface 703 complete communication with each other through the communication bus 704, wherein the communication interface 703 is used for realizing information transmission among related devices such as server-side devices, detection devices and user devices;
the processor 701 is configured to invoke a computer program in the memory 702, where the processor executes the computer program to implement all the steps in the Jboss cache cleaning method in the foregoing embodiment.
Embodiments of the present invention also provide a computer readable storage medium capable of implementing all the steps in the Jboss cache cleaning method in the above embodiments, where the computer readable storage medium stores a computer program, and when the computer program is executed by a processor, implements all the steps in the Jboss cache cleaning method in the above embodiments.
It will be appreciated by those skilled in the art that embodiments of the present invention may be provided as a method, system, or computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems) and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
The foregoing description of the embodiments has been provided for the purpose of illustrating the general principles of the invention, and is not meant to limit the scope of the invention, but to limit the invention to the particular embodiments, and any modifications, equivalents, improvements, etc. that fall within the spirit and principles of the invention are intended to be included within the scope of the invention.