CN110704376A - Log file saving method and device - Google Patents

Log file saving method and device Download PDF

Info

Publication number
CN110704376A
CN110704376A CN201910831743.6A CN201910831743A CN110704376A CN 110704376 A CN110704376 A CN 110704376A CN 201910831743 A CN201910831743 A CN 201910831743A CN 110704376 A CN110704376 A CN 110704376A
Authority
CN
China
Prior art keywords
pod
host
storage path
path
log file
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.)
Pending
Application number
CN201910831743.6A
Other languages
Chinese (zh)
Inventor
王文潇
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Guangdong Inspur Smart Computing Technology Co Ltd
Original Assignee
Guangdong Inspur Big Data Research Co Ltd
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 Guangdong Inspur Big Data Research Co Ltd filed Critical Guangdong Inspur Big Data Research Co Ltd
Priority to CN201910831743.6A priority Critical patent/CN110704376A/en
Publication of CN110704376A publication Critical patent/CN110704376A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/14Details of searching files based on file metadata
    • G06F16/148File search processing
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/16File or folder operations, e.g. details of user interfaces specifically adapted to file systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/17Details of further file system functions
    • G06F16/1734Details of monitoring file system events, e.g. by the use of hooks, filter drivers, logs

Abstract

The invention relates to the technical field of computers, in particular to a log file saving method and a log file saving device, wherein the method comprises the following steps: when the kurbernets starts each pod, determining a storage path corresponding to each pod; acquiring each host path of a host, and setting a corresponding relation between a storage path and the host path so as to mount the storage path under the host path; and saving the log file generated by each pod into a storage path, and synchronously saving the log file in the storage path into a host according to the corresponding relation between the storage path and the host path so that a user can search the log file through the host. By applying the method provided by the invention, the log file generated by the pod can be stored in the host machine, and the user can quickly find the required log file according to the host machine path in the host machine, thereby simplifying the process of inquiring the log file by the user and improving the inquiring experience of the user.

Description

Log file saving method and device
Technical Field
The invention relates to the technical field of computers, in particular to a log file saving method and device.
Background
In a container cluster management system (kurbernets, K8S), there are multiple resource type groups pod, each pod corresponding to a respective host process. The user can inquire the log file output corresponding to each pod in Kurbernets and know the execution state of the main process corresponding to each pod, so that the user can manage and monitor each pod in Kurbernets.
In kubernets in the prior art, a log collection system fluent is generally used for outputting log files generated by each pod, and each output log file is persisted. However, the fluent is a log plug-in with a relatively large volume, is complex to deploy, is not suitable for development of some simple background systems, and cannot perform differentiation processing on the log file names among the pods in the process of storing the log files corresponding to each pod. When a user needs to query the log file corresponding to each pod in the kurbernets, a series of query instructions need to be input after the user enters the kurbernets, the log files required by the user can be obtained, and because each log file is not processed in a differentiation mode, the user is required to search and contrast one by one in the process of obtaining the log files, and poor experience is brought to the user.
Disclosure of Invention
The technical problem to be solved by the invention is to provide a log file storage method, by which log files generated by each pod in Kurbernets can be stored in a host machine, and a user can quickly find the required log files according to a host machine path in the host machine.
The invention also provides a log file storage device used for ensuring the realization and the application of the method in practice.
A log file saving method comprises the following steps:
when a container cluster management system Kurbernets starts each resource type group pod, determining a storage path corresponding to each pod in the Kurbernets;
acquiring each host path of a preset host, and setting the corresponding relation between each storage path and each host path so as to mount each storage path under the host path corresponding to the storage path;
and storing the log file generated by each pod into a corresponding storage path, and synchronously storing the log file in each storage path into the host according to the corresponding relation between each storage path and each host path so that a user searches the log file corresponding to each pod through the host.
Optionally, the determining a storage path corresponding to each pod in the kurbernets includes:
determining the resource type of each pod in the Kurbernets;
creating a pod set corresponding to each resource type, and respectively storing each pod into the corresponding pod set according to the resource type to which each pod belongs;
and setting a storage path corresponding to each pod set in the Kurbernets, and determining the storage path corresponding to each pod in the Kurbernets according to the storage path corresponding to each pod set.
Optionally, the setting of the correspondence between each storage path and each host path includes:
acquiring a parameter command corresponding to each storage path;
and setting a redirection symbol corresponding to each host path, respectively inserting each redirection symbol into the parameter command of each storage path, and determining the corresponding relation between each storage path and each host path according to the redirection symbol in each parameter command.
The above method, optionally, further includes:
acquiring a host name corresponding to each pod, and converting each host name into a name field corresponding to the host name;
acquiring a starting command and a parameter command of each storage path according to the storage path corresponding to each pod, wherein the starting command is used for starting and storing the log files generated by each pod, and the parameter command is used for performing parameter configuration on each log file;
and embedding the name field corresponding to each pod into the starting command and the parameter command of the storage path corresponding to the pod, so that when each pod stores the log file into the storage path corresponding to the pod, the file name corresponding to each log file is generated.
The above method, optionally, further includes:
when a log query request sent to the host by the user is received, acquiring file information corresponding to the log query request, and determining a log file to be queried corresponding to the log query request;
determining a target pod to which the log file to be queried belongs according to the file information;
and determining a target host path corresponding to the target pod, searching the log file to be inquired in the target host path according to the file information, obtaining a target log file, and feeding the target log file back to the user.
A log file saving apparatus comprising:
a determining unit, configured to determine, when a container cluster management system kurbernets starts each resource type group pod, a storage path corresponding to each pod in the kurbernets;
the device comprises a setting unit, a storage unit and a processing unit, wherein the setting unit is used for acquiring each host path of a preset host, and setting the corresponding relation between each storage path and each host path so as to mount each storage path under the host path corresponding to the storage path;
and the storage unit is used for storing the log file generated by each pod into the corresponding storage path, and synchronously storing the log file in each storage path into the host according to the corresponding relation between each storage path and each host path so that a user can search the log file corresponding to each pod through the host.
The above apparatus, optionally, the determining unit includes:
a first determining subunit, configured to determine a resource type to which each pod in the kurbernets belongs;
a creating subunit, configured to create a pod set corresponding to each resource type, and store each pod into its corresponding pod set according to the resource type to which each pod belongs;
and a second determining subunit, configured to set a storage path corresponding to each pod set in the kurbernets, and determine, according to the storage path corresponding to each pod set, a storage path corresponding to each pod in the kurbernets.
The above apparatus, optionally, the setting unit includes:
the first acquisition subunit is used for acquiring the parameter command corresponding to each storage path;
and the setting subunit is configured to set a redirection symbol corresponding to each host path, insert each redirection symbol into the parameter command of each storage path, and determine, according to the redirection symbol in each parameter command, a correspondence between each storage path and each host path.
The above apparatus, optionally, further comprises:
the conversion unit is used for acquiring the host name corresponding to each pod and converting each host name into a name field corresponding to the host name;
a first obtaining unit, configured to obtain, according to a storage path corresponding to each pod, a start command and a parameter command of each storage path, where the start command is used to start storing a log file generated by each pod, and the parameter command is used to perform parameter configuration on each log file;
and the embedding unit is used for embedding the name field corresponding to each pod into the starting command and the parameter command of the storage path corresponding to the pod, so that when each pod stores the log file into the storage path corresponding to the pod, the file name corresponding to each log file is generated.
The above apparatus, optionally, further comprises:
the searching unit is used for acquiring file information corresponding to the log query request and determining a log file to be queried corresponding to the log query request when the log query request sent to the host by the user is received; determining a target pod to which the log file to be queried belongs according to the file information; and determining a target host path corresponding to the target pod, searching the log file to be inquired in the target host path according to the file information, obtaining a target log file, and feeding the target log file back to the user.
A storage medium comprises stored instructions, wherein when the instructions are executed, the storage medium is controlled to execute the log file saving method on a device.
An electronic device comprising a memory, and one or more instructions, wherein the one or more instructions are stored in the memory and configured to be executed by one or more processors to perform the log file saving method.
Compared with the prior art, the invention has the following advantages:
the invention provides a log file saving method, which comprises the following steps: when a container cluster management system Kurbernets is started, determining a storage path corresponding to each resource type group pod in the Kurbernets; acquiring each host path of a preset host, and setting the corresponding relation between each storage path and each host path so as to mount each storage path under the host path corresponding to the storage path; and starting each pod, storing the log file generated by each pod into a corresponding storage path, and synchronously storing the log files in each storage path into the host according to the corresponding relation between each storage path and each host path so that a user searches the log file corresponding to each pod through the host. By applying the method provided by the invention, the log files generated by each pod in the Kurbernets can be stored in the host, and the user can quickly find the required log files according to the host path in the host, so that the user does not need to query the log files through the Kurbernets, the process of querying the log files by the user is simplified, and the query experience of the user is improved.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the provided drawings without creative efforts.
Fig. 1 is a flowchart of a method for saving a log file according to an embodiment of the present invention;
fig. 2 is a flowchart of another method of a log file saving method according to an embodiment of the present invention;
fig. 3 is a flowchart of another method of a log file saving method according to an embodiment of the present invention;
fig. 4 is a diagram illustrating an apparatus structure of a log file saving apparatus according to an embodiment of the present invention;
fig. 5 is a schematic structural diagram of an electronic device according to an embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
In this application, relational terms such as first and second, and the like are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions, and the terms "comprises", "comprising", or any other variation thereof are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
The invention is operational with numerous general purpose or special purpose computing device environments or configurations. For example: personal computers, server computers, hand-held or portable devices, tablet-type devices, multi-processor apparatus, distributed computing environments that include any of the above devices or equipment, and the like.
The embodiment of the invention provides a log file saving method, which can be applied to a plurality of system platforms, wherein an execution main body of the method can be a computer terminal or a processor of various mobile devices, and a flow chart of the method is shown in fig. 1 and specifically comprises the following steps:
s101: when a container cluster management system Kurbernets starts each resource type group pod, determining a storage path corresponding to each pod in the Kurbernets;
in the method provided by the embodiment of the invention, when kurbernets starts each pod therein, a storage path corresponding to each resource type group pod in the kurbernets is determined.
Note that the storage path is a storage path that is stored in the kurbernets for each pod. If a log file is generated during the execution of each pod, the log file generated by each pod is stored in the corresponding storage path in kurbernets.
It should be further noted that each storage path does not necessarily store only one log file generated by a pod, and each storage path may store a plurality of log files generated by pods.
S102: acquiring each host path of a preset host, and setting the corresponding relation between each storage path and each host path so as to mount each storage path under the host path corresponding to the storage path;
in the method provided by the embodiment of the invention, the preset host paths of the hosts are obtained in order to enable a user to more conveniently search the log files of each pod in the Kurbernets. In particular, the number of paths of the host path may be greater than or equal to the number of paths of the storage path. In order to enable log files generated by each pod in the kurbernets to be stored in the host, each storage path is in a corresponding relation with each host path set value, wherein the corresponding relation is a one-to-one corresponding relation, and the storage path in one kurbernets corresponds to the host path in one host. After the corresponding relationship between each storage path and the host path is set, each storage path is mounted under the host path corresponding to the storage path. For example: the host path in the host is "/local/machine/dir", the storage path corresponding to the pod in kurbernets is "/pod/dir", and after the corresponding relation between the storage path and the host path is set, the storage path can be mounted under the host path, namely, the path "/pod/dir" exists in the path "/local/machine/dir".
It should be noted that the host may specifically be a computer, a host of a terminal device, and the like. The storage path under the host path may be a file mount, that is, the storage path is mounted in a file under the host path, and the file is a yaml file.
S103: and storing the log file generated by each pod into a corresponding storage path, and synchronously storing the log file in each storage path into the host according to the corresponding relation between each storage path and each host path so that a user searches the log file corresponding to each pod through the host.
In the method provided by the embodiment of the present invention, after the correspondence between each storage path and each host path is set, the log file generated after each pod is started is stored in kurbernets, and is specifically stored in the storage path corresponding to each pod. Because the corresponding relation between each storage path and each host path is set and each storage path is mounted under the host path corresponding to the storage path, after the log file generated by the pod is saved in the storage path, the log file in the storage path is also synchronously saved in the host path of the host.
Optionally, after synchronously saving the respective log files to the host, each log file is specifically saved in the host path corresponding to each storage path. For example, since the storage path "/pod/dir" is mounted on the host path "/local/machine/dir" after the pod1 generates the log file 1 and stores the log file 1 therein, the log file 1 is also synchronously stored on the host path "/local/machine/dir" after the log file 1 is stored on the storage path "/pod/dir".
It should be noted that the log files saved under each host path are all persisted.
The embodiment of the invention provides a log file saving method. When the kurbernets starts each pod, the storage path corresponding to each pod in the kurbernets is determined. Wherein, each storage path is a storage path in Kurbernets, and after the pod generates the log file, the log file is stored in the storage path of Kurbernets. After each pod is started by Kurbernets, each host path preset in the host is obtained, and the corresponding relation between each host path and the storage path is set. Wherein, each host path and each storage path are in one-to-one correspondence. That is, each host path is mapped into its corresponding storage path such that each storage path is mounted into its corresponding host path. When the respective pod generates the log file, the log file generated by each pod is saved into the storage path corresponding to the pod, and the log file in the storage path is also synchronously saved in the host machine, namely into the host machine path corresponding to each storage path because the storage path is mounted in the host machine path.
It should be noted that the pod generated log file is generated in real time, each pod correspondingly executes a process of an application program, and when the process corresponding to the pod is in the process of executing, the pod generates the log file, and the log file records information such as the execution state and the execution time of the process corresponding to the pod. Each po can generate a plurality of log files, and each time a log file is generated, the corresponding storage path and host path also update the new log file for storage.
It should be further noted that, because the host path adopts a persistent log file storage manner, when the log file in the storage path is deleted, the log file will not be deleted by each host path in the host.
By applying the method provided by the embodiment of the invention, the corresponding relation between each storage path and each host path is set, so that the storage paths can be stored in the host paths when the storage paths mount the host paths and the log files are generated by the pod, and a user can inquire each log file in the host, so that the user does not need to inquire the log files through Kurbernets, the process of inquiring the log files by the user is simplified, and the inquiry experience of the user is improved.
In the method provided in the embodiment of the present invention, when a pod is started by kurbernets, a storage path corresponding to each pod in the kurbernets needs to be determined, and a process of determining the storage path is shown in fig. 2, and specifically includes:
s201: determining the resource type of each pod in the Kurbernets;
in the method provided in the embodiment of the present invention, before determining the storage path corresponding to each pod, a resource type to which each pod belongs is determined in the kurbernets, where the resource type may be one job, and in order to implement an execution process of the job, the resource type may need to be applied to multiple pods, and thus each resource type may include multiple pods.
S202: creating a pod set corresponding to each resource type, and respectively storing each pod into the corresponding pod set according to the resource type to which each pod belongs;
in the method provided by the embodiment of the invention, a pod set corresponding to each resource type is created according to each resource type, and each pod is correspondingly stored in the pod set.
S203: and setting a storage path corresponding to each pod set in the Kurbernets, and determining the storage path corresponding to each pod in the Kurbernets according to the storage path corresponding to each pod set.
In the method provided by the embodiment of the present invention, after each pod is saved in the pod set corresponding to the pod, the storage path corresponding to each pod set is set, so as to determine the storage path corresponding to each pod. That is, the log file saved under each storage path is a log file belonging to the same resource type.
In the log file saving method provided by the embodiment of the invention, the resource type to which each pod belongs is determined, the pod set is created according to each resource type, and each pod is saved in the corresponding pod set. And setting a storage path corresponding to each pod set in Kurbernets to determine the storage path corresponding to each pod set. Each storage path is used for saving log files generated by each pod in the pod set corresponding to the storage path.
By applying the method provided by the embodiment of the invention, the pod sets are created, the storage path corresponding to each pod set is set, and the storage path corresponding to each pod is determined according to the storage path corresponding to each pod set, so that after each pod generates the log file, the log file can be stored in the host according to the corresponding relation between the storage path and the host path, and the user can inquire each log file in the host, so that the user does not need to inquire the log file through Kurbernets, the process of inquiring the log file by the user is simplified, and the inquiry experience of the user is improved.
In the method provided in the embodiment of the present invention, a process of setting a corresponding relationship between each storage path and each host path is shown in fig. 3, and specifically includes:
s301: acquiring a parameter command corresponding to each storage path;
in the method provided by the embodiment of the invention, each kurbernets storage path corresponds to a parameter command, and the parameter command is specifically an args parameter command.
S302: setting a redirection symbol corresponding to each host path, inserting each redirection symbol into the parameter command of each storage path, and determining the corresponding relation between each storage path and each host path according to the redirection symbol in each parameter command.
In the method provided by the embodiment of the invention, a redirection symbol is set for each host path, and the redirection symbol can mount the storage path to the host path. The redirection symbol of the host path is inserted into the parameter command of the storage path corresponding to the host path, for example, the parameter command corresponding to the storage path is args: [ …/pod/dir/$ hostname.txt ], the redirection symbol is ">", and after the redirection symbol is inserted into the parameter command, the parameter command is args: [ … >/pod/dir/$ hostname.txt ]. The parameter command is a command for saving each log file to execute parameter configuration, that is, the parameter command is subjected to parameter configuration for redirection after a redirection symbol is inserted. And determining the corresponding relation between each host path and the storage path according to the redirection symbol in the parameter command.
In the log file saving method provided by the embodiment of the invention, the parameter command corresponding to each storage path is obtained, a redirection symbol is set for each host path, each redirection symbol is respectively inserted into each storage path, and the corresponding relation between the host path and the storage path can be determined according to the redirection symbol in each storage path.
By applying the method provided by the embodiment of the invention, the redirection symbol of the host route is inserted into the parameter command of the storage route, so that when the log file is stored in the storage route, the log file can be redirected and stored in the host route, and a user can inquire each log file in the host, so that the user does not need to inquire the log file through Kurbernets, the process of inquiring the log file by the user is simplified, and the inquiry experience of the user is improved.
In the method provided in the embodiment of the present invention, in order to reflect the differentiation between the log files generated by each pod, the method specifically further includes:
acquiring a host name corresponding to each pod, and converting each host name into a name field corresponding to the host name;
acquiring a starting command and a parameter command of each storage path according to the storage path corresponding to each pod, wherein the starting command is used for starting and storing the log files generated by each pod, and the parameter command is used for performing parameter configuration on each log file;
and embedding the name field corresponding to each pod into the starting command and the parameter command of the storage path corresponding to the pod, so that when each pod stores the log file into the storage path corresponding to the pod, the file name corresponding to each log file is generated.
In the log file saving method provided by the embodiment of the present invention, each pod corresponds to one host name, and after kurbernets is started, the host name of each pod is converted into a name field, for example, the host name of pod1 is hostname, and the converted name field is $ hostname. And acquiring a starting command and a parameter command of the storage path corresponding to each pod, wherein the starting command is a command, the parameter command is an args command, and the command is used for starting the command for storing each log file. The name field is embedded in the startup command and the parameter command so that when the pod generates the log file, the file name is consistent with the host name corresponding to the name field.
It should be noted that the host name of a pod is the host name in the pod environment variable, and because the host name corresponding to each pod is different due to the difference of the pod environment variable, the generated name fields are also different, and the file names of the pods are different when the log file is saved. And each pod not only generates one log file, but also reflects the differentiation among the files according to the generated sequence when the pod generates a plurality of log files. Pod1, for example, generates a persistent log file as follows:
and $ hostname 1.txt, $ hostname 2.txt, …, $ hostname n. txt, where n is a positive integer. The log files generated by the same pod may reflect the differences between each log file with a number as a suffix.
Optionally, after the host name is converted into the name field, only the name field may be embedded in the parameter command, and the name field does not need to be embedded in the start command, and when the pod generates the log file and stores the log file to the storage path, the name of the output log file is configured by the parameter command according to the embedded name field.
By applying the method provided by the embodiment of the invention, the corresponding differentiation of each log file is embodied by using the host name corresponding to each pod, so that when a user inquires the log file, the log file required by the user can be quickly searched by inquiring the file name of the log file, and the experience of the user is improved.
In the method provided in the embodiment of the present invention, after synchronously saving the log files generated by each pod to the host path of the host, the method specifically further includes:
when a log query request sent to the host by the user is received, acquiring file information corresponding to the log query request, and determining a log file to be queried corresponding to the log query request;
determining a target pod to which the log file to be queried belongs according to the file information;
and determining a target host path corresponding to the target pod, searching the log file to be inquired in the target host path according to the file information, obtaining a target log file, and feeding the target log file back to the user.
In the file saving method provided by the embodiment of the invention, when a user needs to query a log file of any pod in Kurbernets, a log query request can be sent to the host, and when a log query instruction sent to the host by the user is received, file information carried in the log query request is acquired, wherein the file information is file information of the log file which the user needs to query. The file information may include a file name, a pod name corresponding to the log file to be queried, a currently stored host path, and the like. And determining the log file to be inquired, which is required to be inquired by the user, according to the log inquiry request. And determining a target pod to which the log file to be queried belongs according to the file information, namely determining which pod generates the log file to be queried. And determining a target host path corresponding to the target pod, searching a target log file corresponding to the file information in the target host path, and feeding back the target log file to the user.
By applying the method provided by the embodiment of the invention, when a user needs to inquire any log file, the user only needs to send the log inquiry request to the host machine to obtain the required log file, and does not need to input various instructions to Kurbernets for inquiry, so that the process of inquiring the log file by the user is simplified, and the experience of inquiring the log file by the user is improved.
The specific implementation procedures and derivatives thereof of the above embodiments are within the scope of the present invention.
Corresponding to the method described in fig. 1, an embodiment of the present invention further provides a log file saving apparatus, which is used for implementing the method in fig. 1 specifically, and the log file saving apparatus provided in the embodiment of the present invention may be applied to a computer terminal or various mobile devices, and a schematic structural diagram of the log file saving apparatus is shown in fig. 4, and specifically includes:
a determining unit 401, configured to determine, when a container cluster management system kurbernets starts each resource type group pod, a storage path corresponding to each pod in the kurbernets;
a setting unit 402, configured to obtain each host path of a preset host, and set a corresponding relationship between each storage path and each host path, so that each storage path is mounted under the host path corresponding to the storage path;
a saving unit 403, configured to save the log file generated by each pod into a storage path corresponding to the pod, and synchronously save the log file in each storage path into the host according to a correspondence between each storage path and each host path, so that a user searches for the log file corresponding to each pod through the host.
In the apparatus provided in an embodiment of the present invention, the determining unit includes:
a first determining subunit, configured to determine a resource type to which each pod in the kurbernets belongs;
a creating subunit, configured to create a pod set corresponding to each resource type, and store each pod into its corresponding pod set according to the resource type to which each pod belongs;
and a second determining subunit, configured to set a storage path corresponding to each pod set in the kurbernets, and determine, according to the storage path corresponding to each pod set, a storage path corresponding to each pod in the kurbernets.
In the apparatus provided in the embodiment of the present invention, the setting unit includes:
the first acquisition subunit is used for acquiring the parameter command corresponding to each storage path;
and the setting subunit is configured to set a redirection symbol corresponding to each host path, insert each redirection symbol into the parameter command of each storage path, and determine, according to the redirection symbol in each parameter command, a correspondence between each storage path and each host path.
The device provided by the embodiment of the invention further comprises:
the conversion unit is used for acquiring the host name corresponding to each pod and converting each host name into a name field corresponding to the host name;
a first obtaining unit, configured to obtain, according to a storage path corresponding to each pod, a start command and a parameter command of each storage path, where the start command is used to start storing a log file generated by each pod, and the parameter command is used to perform parameter configuration on each log file;
and the embedding unit is used for embedding the name field corresponding to each pod into the starting command and the parameter command of the storage path corresponding to the pod, so that when each pod stores the log file into the storage path corresponding to the pod, the file name corresponding to each log file is generated.
The device provided by the embodiment of the invention further comprises:
the searching unit is used for acquiring file information corresponding to the log query request and determining a log file to be queried corresponding to the log query request when the log query request sent to the host by the user is received; determining a target pod to which the log file to be queried belongs according to the file information; and determining a target host path corresponding to the target pod, searching the log file to be inquired in the target host path according to the file information, obtaining a target log file, and feeding the target log file back to the user.
The specific working processes of the determining unit 401, the setting unit 402 and the saving unit 403 in the log file saving device disclosed in the embodiment of the present invention may refer to corresponding contents in the log file saving method disclosed in the embodiment of the present invention, and are not described herein again.
The embodiment of the invention also provides a storage medium, which comprises a stored instruction, wherein when the instruction runs, the device where the storage medium is located is controlled to execute the log file saving method.
An electronic device is provided in an embodiment of the present invention, and the structural diagram of the electronic device is shown in fig. 5, which specifically includes a memory 501 and one or more instructions 502, where the one or more instructions 502 are stored in the memory 501, and are configured to be executed by one or more processors 503 to perform the following operations according to the one or more instructions 502:
when a container cluster management system Kurbernets starts each resource type group pod, determining a storage path corresponding to each pod in the Kurbernets;
acquiring each host path of a preset host, and setting the corresponding relation between each storage path and each host path so as to mount each storage path under the host path corresponding to the storage path;
and storing the log file generated by each pod into a corresponding storage path, and synchronously storing the log file in each storage path into the host according to the corresponding relation between each storage path and each host path so that a user searches the log file corresponding to each pod through the host.
The embodiments in the present specification are described in a progressive manner, and the same and similar parts among the embodiments are referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, the system or system embodiments are substantially similar to the method embodiments and therefore are described in a relatively simple manner, and reference may be made to some of the descriptions of the method embodiments for related points. The above-described system and system embodiments are only illustrative, wherein the units described as separate parts may or may not be physically separate, and the parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment. One of ordinary skill in the art can understand and implement it without inventive effort.
Those of skill would further appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, computer software, or combinations of both.
To clearly illustrate this interchangeability of hardware and software, various illustrative components and steps have been described above generally in terms of their functionality. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present invention.
The previous description of the disclosed embodiments is provided to enable any person skilled in the art to make or use the present invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the invention. Thus, the present invention 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.

Claims (10)

1. A log file saving method is characterized by comprising the following steps:
when a container cluster management system Kurbernets starts each resource type group pod, determining a storage path corresponding to each pod in the Kurbernets;
acquiring each host path of a preset host, and setting the corresponding relation between each storage path and each host path so as to mount each storage path under the host path corresponding to the storage path;
and storing the log file generated by each pod into a corresponding storage path, and synchronously storing the log file in each storage path into the host according to the corresponding relation between each storage path and each host path so that a user searches the log file corresponding to each pod through the host.
2. The method of claim 1, wherein the determining the storage path in the kurbernets corresponding to each pod comprises:
determining the resource type of each pod in the Kurbernets;
creating a pod set corresponding to each resource type, and respectively storing each pod into the corresponding pod set according to the resource type to which each pod belongs;
and setting a storage path corresponding to each pod set in the Kurbernets, and determining the storage path corresponding to each pod in the Kurbernets according to the storage path corresponding to each pod set.
3. The method according to claim 1, wherein the setting of the correspondence relationship between each storage path and each host path comprises:
acquiring a parameter command corresponding to each storage path;
and setting a redirection symbol corresponding to each host path, respectively inserting each redirection symbol into the parameter command of each storage path, and determining the corresponding relation between each storage path and each host path according to the redirection symbol in each parameter command.
4. The method of claim 1, further comprising:
acquiring a host name corresponding to each pod, and converting each host name into a name field corresponding to the host name;
acquiring a starting command and a parameter command of each storage path according to the storage path corresponding to each pod, wherein the starting command is used for starting and storing the log files generated by each pod, and the parameter command is used for performing parameter configuration on each log file;
and embedding the name field corresponding to each pod into the starting command and the parameter command of the storage path corresponding to the pod, so that when each pod stores the log file into the storage path corresponding to the pod, the file name corresponding to each log file is generated.
5. The method of claim 1, further comprising:
when a log query request sent to the host by the user is received, acquiring file information corresponding to the log query request, and determining a log file to be queried corresponding to the log query request;
determining a target pod to which the log file to be queried belongs according to the file information;
and determining a target host path corresponding to the target pod, searching the log file to be inquired in the target host path according to the file information, obtaining a target log file, and feeding the target log file back to the user.
6. A log file saving apparatus, comprising:
a determining unit, configured to determine, when a container cluster management system kurbernets starts each resource type group pod, a storage path corresponding to each pod in the kurbernets;
the device comprises a setting unit, a storage unit and a processing unit, wherein the setting unit is used for acquiring each host path of a preset host, and setting the corresponding relation between each storage path and each host path so as to mount each storage path under the host path corresponding to the storage path;
and the storage unit is used for storing the log file generated by each pod into the corresponding storage path, and synchronously storing the log file in each storage path into the host according to the corresponding relation between each storage path and each host path so that a user can search the log file corresponding to each pod through the host.
7. The apparatus of claim 6, wherein the determining unit comprises:
a first determining subunit, configured to determine a resource type to which each pod in the kurbernets belongs;
a creating subunit, configured to create a pod set corresponding to each resource type, and store each pod into its corresponding pod set according to the resource type to which each pod belongs;
and a second determining subunit, configured to set a storage path corresponding to each pod set in the kurbernets, and determine, according to the storage path corresponding to each pod set, a storage path corresponding to each pod in the kurbernets.
8. The apparatus of claim 6, wherein the setting unit comprises:
the first acquisition subunit is used for acquiring the parameter command corresponding to each storage path;
and the setting subunit is configured to set a redirection symbol corresponding to each host path, insert each redirection symbol into the parameter command of each storage path, and determine, according to the redirection symbol in each parameter command, a correspondence between each storage path and each host path.
9. The apparatus of claim 6, further comprising:
the conversion unit is used for acquiring the host name corresponding to each pod and converting each host name into a name field corresponding to the host name;
a first obtaining unit, configured to obtain, according to a storage path corresponding to each pod, a start command and a parameter command of each storage path, where the start command is used to start storing a log file generated by each pod, and the parameter command is used to perform parameter configuration on each log file;
and the embedding unit is used for embedding the name field corresponding to each pod into the starting command and the parameter command of the storage path corresponding to the pod, so that when each pod stores the log file into the storage path corresponding to the pod, the file name corresponding to each log file is generated.
10. The apparatus of claim 1, further comprising:
the searching unit is used for acquiring file information corresponding to the log query request and determining a log file to be queried corresponding to the log query request when the log query request sent to the host by the user is received; determining a target pod to which the log file to be queried belongs according to the file information; and determining a target host path corresponding to the target pod, searching the log file to be inquired in the target host path according to the file information, obtaining a target log file, and feeding the target log file back to the user.
CN201910831743.6A 2019-09-04 2019-09-04 Log file saving method and device Pending CN110704376A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910831743.6A CN110704376A (en) 2019-09-04 2019-09-04 Log file saving method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910831743.6A CN110704376A (en) 2019-09-04 2019-09-04 Log file saving method and device

Publications (1)

Publication Number Publication Date
CN110704376A true CN110704376A (en) 2020-01-17

Family

ID=69194107

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910831743.6A Pending CN110704376A (en) 2019-09-04 2019-09-04 Log file saving method and device

Country Status (1)

Country Link
CN (1) CN110704376A (en)

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111898122A (en) * 2020-07-27 2020-11-06 平安证券股份有限公司 Log collection method, device, medium and electronic equipment for application in container
CN112905537A (en) * 2021-02-20 2021-06-04 北京百度网讯科技有限公司 File processing method and device, electronic equipment and storage medium
CN113326004A (en) * 2021-06-10 2021-08-31 深圳市移卡科技有限公司 Efficient log centralization method and device in cloud computing environment
JP2023518136A (en) * 2021-02-20 2023-04-28 ベイジン バイドゥ ネットコム サイエンス テクノロジー カンパニー リミテッド FILE PROCESSING METHOD, APPARATUS, ELECTRONIC DEVICE, STORAGE MEDIUM, AND PROGRAM
US20240054107A1 (en) * 2021-02-20 2024-02-15 Beijing Baidu Netcom Science And Technology Co., Ltd. File processing method, electronic device, and storage medium

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106383852A (en) * 2016-08-30 2017-02-08 中国民生银行股份有限公司 Docker container-based log acquisition method and apparatus
CN107707688A (en) * 2017-10-19 2018-02-16 杭州数梦工场科技有限公司 A kind of method and device of kubernetes clusters parsing host host name
CN108153649A (en) * 2018-01-23 2018-06-12 北京粉笔蓝天科技有限公司 Using the acquisition of daily record and inspection method and its device in docker containers
CN108845917A (en) * 2018-04-09 2018-11-20 东峡大通(北京)管理咨询有限公司 File journalization carry module, system and method in container
CN109491859A (en) * 2018-10-16 2019-03-19 华南理工大学 For the collection method of container log in Kubernetes cluster
US20190095253A1 (en) * 2017-09-22 2019-03-28 Vmware, Inc. Cluster updating using temporary update-monitor pod

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106383852A (en) * 2016-08-30 2017-02-08 中国民生银行股份有限公司 Docker container-based log acquisition method and apparatus
US20190095253A1 (en) * 2017-09-22 2019-03-28 Vmware, Inc. Cluster updating using temporary update-monitor pod
CN107707688A (en) * 2017-10-19 2018-02-16 杭州数梦工场科技有限公司 A kind of method and device of kubernetes clusters parsing host host name
CN108153649A (en) * 2018-01-23 2018-06-12 北京粉笔蓝天科技有限公司 Using the acquisition of daily record and inspection method and its device in docker containers
CN108845917A (en) * 2018-04-09 2018-11-20 东峡大通(北京)管理咨询有限公司 File journalization carry module, system and method in container
CN109491859A (en) * 2018-10-16 2019-03-19 华南理工大学 For the collection method of container log in Kubernetes cluster

Cited By (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111898122A (en) * 2020-07-27 2020-11-06 平安证券股份有限公司 Log collection method, device, medium and electronic equipment for application in container
CN111898122B (en) * 2020-07-27 2023-11-17 平安证券股份有限公司 Log acquisition method and device for application in container, medium and electronic equipment
CN112905537A (en) * 2021-02-20 2021-06-04 北京百度网讯科技有限公司 File processing method and device, electronic equipment and storage medium
WO2022174553A1 (en) * 2021-02-20 2022-08-25 北京百度网讯科技有限公司 File processing method and apparatus, electronic device, and storage medium
JP2023518136A (en) * 2021-02-20 2023-04-28 ベイジン バイドゥ ネットコム サイエンス テクノロジー カンパニー リミテッド FILE PROCESSING METHOD, APPARATUS, ELECTRONIC DEVICE, STORAGE MEDIUM, AND PROGRAM
US20240054107A1 (en) * 2021-02-20 2024-02-15 Beijing Baidu Netcom Science And Technology Co., Ltd. File processing method, electronic device, and storage medium
CN113326004A (en) * 2021-06-10 2021-08-31 深圳市移卡科技有限公司 Efficient log centralization method and device in cloud computing environment
CN113326004B (en) * 2021-06-10 2023-03-03 深圳市移卡科技有限公司 Efficient log centralization method and device in cloud computing environment

Similar Documents

Publication Publication Date Title
CN110704376A (en) Log file saving method and device
JP5705869B2 (en) Apparatus and method for loading and updating code of a cluster-based JAVA application system
CN107277029B (en) Remote procedure call method and device and computer equipment
CN109547570A (en) Service registration method, apparatus, registration center's management equipment and storage medium
CN108121511B (en) Data processing method, device and equipment in distributed edge storage system
CN110968331B (en) Method and device for running application program
CN111897638A (en) Distributed task scheduling method and system
CN109933585B (en) Data query method and data query system
CN110413845B (en) Resource storage method and device based on Internet of things operating system
CN111885216B (en) DNS query method, device, equipment and storage medium
CN109857723B (en) Dynamic data migration method based on expandable database cluster and related equipment
CN103136342A (en) Searching method, system and searching server of application programs (APP)
CN103095758A (en) Distributed file system and file data processing method thereof
CN109388351A (en) A kind of method and relevant apparatus of Distributed Storage
CN102664922A (en) High-speed network starting method based on Linux system
CN103312489A (en) Method and device for synchronizing terminal and server
CN110890987A (en) Method, device, equipment and system for automatically creating cluster
CN111124437A (en) Bare computer resource configuration information acquisition method, system and equipment based on OpenStack
CN114461503A (en) Log collection method and device based on Kubernets cluster, electronic equipment and storage medium
CN107479985B (en) Remote procedure call method and device and computer equipment
CN106850600B (en) Multimedia information pushing method and device
CN110798358B (en) Distributed service identification method and device, computer readable medium and electronic equipment
TWI517045B (en) JAVA cluster application system code loading and upgrading devices and methods
CN108833147B (en) Configuration information updating method and device
CN108446144B (en) Application program starting method and device, terminal and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication

Application publication date: 20200117

RJ01 Rejection of invention patent application after publication