CN108196982A - A kind of LINUX system restarts the configuration method of service automatically - Google Patents

A kind of LINUX system restarts the configuration method of service automatically Download PDF

Info

Publication number
CN108196982A
CN108196982A CN201711474552.6A CN201711474552A CN108196982A CN 108196982 A CN108196982 A CN 108196982A CN 201711474552 A CN201711474552 A CN 201711474552A CN 108196982 A CN108196982 A CN 108196982A
Authority
CN
China
Prior art keywords
service
server
script
timing
restarting
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
Application number
CN201711474552.6A
Other languages
Chinese (zh)
Other versions
CN108196982B (en
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.)
Beijing Nuo Junan Information Technology Ltd By Share Ltd
Original Assignee
Beijing Nuo Junan Information Technology Ltd By Share 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 Beijing Nuo Junan Information Technology Ltd By Share Ltd filed Critical Beijing Nuo Junan Information Technology Ltd By Share Ltd
Priority to CN201711474552.6A priority Critical patent/CN108196982B/en
Publication of CN108196982A publication Critical patent/CN108196982A/en
Application granted granted Critical
Publication of CN108196982B publication Critical patent/CN108196982B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/14Error detection or correction of the data by redundancy in operation
    • G06F11/1402Saving, restoring, recovering or retrying
    • G06F11/1415Saving, restoring, recovering or retrying at system level
    • G06F11/1438Restarting or rejuvenating

Abstract

The invention discloses the configuration methods that a kind of LINUX system restarts service automatically, include the following steps:It determines to be timed the timing the restarted service of restarting, and changes the store path for periodically restarting service and storage file title;According to the determining timing service of restarting, service script is restarted being set from server;Selected master server sets on master server and restarts calling script, and master server start by set date restarts calling script, restarts and script is called to restart service script progress server resets from server calls by local log-on.This method can restart key service after certain interval of time, improve the efficiency restarted, and avoid reboot operation needs by platform to the situation for login being gone to perform from server.

Description

A kind of LINUX system restarts the configuration method of service automatically
Technical field
Automatic restart the configuration method of service more particularly to a kind of LINUX system restarts clothes automatically the present invention relates to a kind of The configuration method of business, belongs to computer application technology.
Background technology
With the development of science and technology, Computer Applied Technology is widely used every field, and in very great Cheng The fast development of industry-by-industry is promoted on degree.Computer is popularized brings advanced management system to enterprise, each powerful Information management system is all supported by business service, for business service there are many kinds of, as foreground service, timing services, Disparate modules are responsible in synchronous service etc., difference service.For the more service of interactive information, long-play will appear card , service crashes can be caused when serious, cause whole system that can not use.
For avoid it is such happen, certain interval of time is needed to restart server.But since server is more, Restart every time and be required for taking a significant amount of time, expend a large amount of manpower and time.
To solve the above-mentioned problems, one is disclosed in the Chinese invention patent application application No. is 201611107530.1 The automatic method for restarting of kind distributed deployment service processes and device.Wherein, which includes:Work as distributed deployment Multiple server processes in the operation of a certain service processes when, periodic monitor simultaneously obtains the correspondences of all service processes and restarts mark Note;Restart whether marker for judgment service processes need to restart according to service processes are corresponding, and according to judging result, to service into Cheng Zhihang corresponding operatings can alleviate the manpower pressure restarted, improve and restart efficiency to a certain extent.
Invention content
In view of the deficiencies of the prior art, the technical problems to be solved by the invention are to provide a kind of LINUX system automatic Restart the configuration method of service.
For achieving the above object, the present invention uses following technical solutions:
A kind of LINUX system restarts the configuration method of service automatically, includes the following steps:
It determines to be timed the timing the restarted service of restarting, and changes the store path for periodically restarting service and storage text Part title;
According to the determining timing service of restarting, from server setting restart service script, and by this from server Log-on message is saved in restart and call in script;
Selected master server sets on master server and restarts calling script, and master server start by set date restarts calling foot This, restarts and script is called to restart service script progress server resets from server calls by local log-on.
Wherein more preferably, single from server, the store path and storage file of service are restarted in modified timing Title all same.
Wherein more preferably, it is described restart service script include modified timing restart service store path and storage text Part title;
The store path of service is restarted by the modified timing and storage file title finds the timing service of restarting, And the timing service of restarting is restarted.
Wherein more preferably, the store path of service is restarted by the modified timing and storage file title finds and determines Shi Chongqi is serviced, and the timing service of restarting is restarted, and is included the following steps:
From server, the storage file title that service is restarted by modified timing finds this from server The timing service of restarting;
The corresponding service of the storage file title is closed using positive closing mode;
The store path that service is restarted by modified timing finds the included service of the timing service of restarting and is actuated for Restart.
Wherein more preferably, at least one service that timing is needed to restart on the slave server of service script is restarted in setting.
Wherein more preferably, the log-on message from server includes user name, password and IP address.
Wherein more preferably, include in restarting when service script restarts the periodically service of restarting of being set from server End of service order and service reset command;
Wherein, end of service order is terminated service using positive closing mode;
The included service of server resets command calls service is actuated for restarting.
Wherein more preferably, the master server is there is no the management servers for periodically restarting service.
Wherein more preferably, restart call script by local log-on from server calls restart service script carry out service weight It opens, includes the following steps:
Master server restarts all username and passwords from server that script acquisition is called to be locally stored, and carries out this Ground logs in;
After logining successfully, the corresponding IP address of user name from server is obtained;
The slave server that service is restarted comprising timing is found by IP address, calling restarts service script;
Restart service script according to modified timing restart service store path and storage file title to timing weight The service of opening is restarted.
LINUX system provided by the present invention restarts the configuration method of service automatically, is timed what is restarted by determining The timing service of restarting, modifies to the store path and storage file title of periodically restarting service;It will be each from server The timing service of restarting that timing is restarted is needed to be stored under same catalogue, restarts service script being set from server, and will This is saved in restart from the log-on message of server and call in script;When restarting service, script is called in main clothes by restarting Local directly log in from server calls of business device restarts service script progress server resets.This method can be in certain interval of time After restart key service, improve the efficiency restarted, and avoid reboot operation need by platform arrive from server go login hold Capable situation.
Description of the drawings
Fig. 1 is the flow chart for the configuration method that LINUX system provided by the present invention restarts service automatically;
Fig. 2 is the application scenarios schematic diagram for the configuration method that LINUX system provided by the present invention restarts service automatically.
Specific embodiment
Detailed specific description is carried out to the technology contents of the present invention in the following with reference to the drawings and specific embodiments.
As shown in Figure 1, LINUX system provided by the present invention restarts the configuration method of service automatically, include the following steps: First, it determines to need to be timed the timing service of restarting restarted, and change the store path for periodically restarting service and storage File name;Then, according to the determining timing service of restarting, restart service script, and should be from clothes being set from server The log-on message of business device is saved in restart and call in script;Finally, master server is selected, is set on master server and restarts calling Script, master server start by set date restart calling script, restart and script is called to restart clothes from server calls by local log-on Business script carries out server resets.With reference to Fig. 2, this processing procedure is described in detail.
S1 determines the timing service of restarting that timing is needed to restart, and changes the store path for periodically restarting service and deposit Store up file name.
There are many kinds of for business service, such as foreground service, timing services, synchronous service, difference service are responsible for Disparate modules, for the more service of interactive information, long-play will appear interim card, service can be caused to collapse when serious It bursts, causes whole system that can not use.But the service for being not frequently used, it is not necessary to frequently restart, in order to avoid cause resource Waste.
In embodiment provided by the present invention, since business service type is more, it is only necessary to restart key service.So Service need to be distinguished, determine the timing service of restarting that timing is needed to restart.Wherein, it needs to be timed the timing restarted and restart Service the service frequently to be used according to practical business demand.
In the embodiment that this method is provided, by taking the service that the java programming languages under tomcat development environments are realized as an example It illustrates.The service that programming language is realized under other development environments, it is only necessary to according to development environment and programming language in itself The store path of service and storage file title are restarted in feature, modification timing.
In the embodiment that this method is provided, distinguished using whether JDK paths need timing to restart service.It determines The good timing that timing is needed to restart is restarted after service, it would be desirable to which the timing the restarted service of restarting is deposited using individual JDK paths Storage, and JAVA programs are subjected to renaming, such as:JAVA_1, i.e. modification need the JDK paths for the service of restarting and by JAVA programs It is renamed as JAVA1, does not need to the service call JAVA programs restarted in this way, needs the service call JAVA1 restarted, while to certainly It is dynamic that service script offer calling is provided.In a server, modified all timings restart service store path and Storage file title all same, can be quickly found when being convenient for restarting the timing the restarted service of restarting in need, reduce The time of retrieval, and then improve the efficiency restarted.
Wherein, need the embodiment that a specific JDK path of service is restarted in the timing restarted as follows:
[root@test/]#mv/java/jdk1.8/bin/java/java/jdk1.8/bin/java1
S2 according to the determining timing service of restarting, restarts service script, and should be from server being set from server Log-on message be saved in restart call script in.
In embodiment provided by the present invention, using the service server where the service of periodically restarting as from server. At least one service that timing is needed to restart on the slave server of service script is restarted in setting.I.e. service script is restarted in setting There can be a timing service of restarting from server, it is possibility to have the multinomial timing service of restarting.Then, by this from server Log-on message is saved in restart and call in script, wherein, include user name, password and IP address from the log-on message of server. Restart and call script that can be directly invoked from server after server in master server local log-on and restart service script Directly restart to servicing accordingly, reduce the complexity of operation, improve and restart efficiency.
It according to the determining timing service of restarting, writes and restarts service script, in embodiment provided by the present invention, write Restart service script for SHELL scripts, when writing SHELL scripts, the periodically service of restarting is carried out by weight by reset command It opens.Wherein, restart when service script restarts the periodically service of restarting including end of service life what is set from server Enable and service reset command.End of service order is terminated service using positive closing mode, server resets command calls service Included service is actuated for restarting.In embodiment provided by the present invention, the timing restarted will be needed by shutdown command The process ID for restarting service extracts progress KILL as program positive closing, starts order increasing program, will write Restart service script be individually positioned in every in the presence of timing restart on the service server of service, wait for restarting for master server Instruction.Wherein, restart in service script and restart the store path of service and storage file title comprising modified timing.Pass through The store path of service is restarted in modified timing and storage file title can find the timing service of restarting for needing to restart, and It is restarted.
Wherein, needs can be found and restart by restarting the store path of service and storage file title by modified timing The timing service of restarting, and restarted, specifically comprised the following steps:
S21, from server, the storage file title that service is restarted by modified timing finds this from server On the timing service of restarting;
S22 is closed the corresponding service of the storage file title using positive closing mode;
S23, the store path that service is restarted by modified timing find the included service startup of the timing service of restarting Restarted.
In a specific embodiment provided by the present invention, the content for restarting service script write is as follows:
#!/bin/bash
# filters JAVA1 keywords process and kills, and is equivalent to positive closing service
pgrep java1|xargs kill-9
# intervals perform for 5 seconds starts order
sleep 5
# starts service
Sh/ system services start path/start.sh
Wherein, it is to copy the service script of restarting of completion to every business service script is restarted in setting from server The fixation catalogue of server facilitates the calling of expect scripts (restart and call script).
Wherein, set from server restart service script to periodically the service of restarting is restarted when, end of service Order will be serviced end rather than be serviced included stop and closed using positive closing mode, since it is desired that the timing that timing is restarted The service of restarting is the service frequently used in actual use, positive closing can prevent due to service interim card and caused by not Situation about can close.And server resets order is actuated for restarting using the included service of service, can make full use of service certainly The program of body simplifies the compiling procedure for restarting service script, improves treatment effeciency.
S3 selectes master server, is set on master server and restarts calling script, master server start by set date restarts calling Script restarts and script is called to restart service script progress server resets from server calls by local log-on.
Selected master server is there is no the management servers for periodically restarting service.Tune is restarted in setting on master server With script, restart more of service script to being provided with by expect orders (restarting call instruction) and restart from server Instruction distribution finally coordinates timer completion to be timed every from the business service of server and restarts.Wherein, only in main clothes Timer is set in business.By timer, master server completes each login from server and restarts the distribution of call instruction, Completion timing restarts the restarting of service.This method does not need to timing and Servers-all and service is monitored, and only needs Periodically master server is handled, the call instruction of restarting of master server is distributed to each server, is reduced The occupancy resource of system improves the efficiency of system reboot.
Wherein, in a specific embodiment provided by the present invention, the expect scripts of configuration multiserver distribution Content it is as follows:
#!/usr/bin/expect
# sets time-out time
set timeout 10
# configuration variables
set username[lindex$argv 0]
set password[lindex$argv 1]
set hostname[lindex$argv 2]
# remote login services ip and user name
spawn ssh-l root 192.168.11.29
# telnet servers input password
expect"*password:"
send"123Admin\r"
It is performed after # telnet servers and restarts service script accordingly
expect"#"
Send " sh/ remote reboots service script path/restart.sh r "
# exits remote server
expect"#"
send"exit\r"
If being related to the slave server that service is restarted in timing has multiple, need to increase in this expect script multiple long-range Login configurations item.
Master server is provided with timer, in order to which start by set date restarts calling script, completes every timing service of restarting Restarting.In embodiment provided by the present invention, following manner may be used in configuration timer:
[root@test/]#crontab–e
The daily 1:00 AM timings of # perform distribution script
* 1**sh/ distribution expect script paths/* .sh
Timing reach after, restart call script by local log-on from server calls restart service script carry out service weight It opens, local log-on at this time is logged in the local of master server, is not related to from server, is logged in and is completed in master server Later, it directly invokes from server and restarts service script, can complete to restart service again from the batch timing of server Start.In addition to this, all log-on messages from server are all stored in the expect scripts of master server, are effectively kept away Having exempted from reboot operation needs by platform to the situation for login being gone to perform from server.Wherein, restart and script is called to pass through local log-on Restart service script from server calls and carry out server resets, specifically comprise the following steps:
S31, master server restart all username and passwords from server that script acquisition is called to be locally stored, into Row local log-on;
S32 after logining successfully, obtains the corresponding IP address of user name from server;
S33, the slave server that service is restarted comprising timing is found by IP address, and calling restarts service script;
S34, restart service script according to modified timing restart service store path and storage file title to fixed Shi Chongqi services are restarted.
In conclusion LINUX system provided by the present invention restarts the configuration method of service automatically, determined by determining The timing of the Shi Chongqi service of restarting modifies to the store path and storage file title of periodically restarting service;Will each from The timing service of restarting that timing is restarted is needed to be stored under same catalogue on server, restarts service foot being set from server This, and this is saved in restart from the log-on message of server and is called in script;Selected master server, is set on master server Restart calling script, master server start by set date restarts calling script, restarts and calls script by local log-on from server tune Server resets are carried out with service script is restarted.This method can restart key service after certain interval of time, improve and restart Efficiency, and avoid reboot operation need by platform arrive from server go log in execution situation.
The configuration method for restarting service automatically to LINUX system provided by the present invention above is described in detail. For those of ordinary skill in the art, it is done under the premise of without departing substantially from true spirit any aobvious and easy The change seen will all form to infringement of patent right of the present invention, will undertake corresponding legal liabilities.

Claims (9)

1. a kind of LINUX system restarts the configuration method of service automatically, it is characterised in that includes the following steps:
It determines to be timed the timing the restarted service of restarting, and changes the store path for periodically restarting service and storage file name Claim;
According to the determining timing service of restarting, from server setting restart service script, and by the login from server Information is saved in restart and call in script;
Selected master server sets on master server and restarts calling script, and master server start by set date restarts calling script, weight It opens and script is called to restart service script progress server resets from server calls by local log-on.
2. LINUX system as described in claim 1 restarts the configuration method of service automatically, it is characterised in that:
Single from server, the store path of service and storage file title all same are restarted in modified timing.
3. LINUX system as described in claim 1 restarts the configuration method of service automatically, it is characterised in that:
It is described to restart service script and restart the store path of service and storage file title comprising modified timing;
The store path of service is restarted by the modified timing and storage file title finds the timing service of restarting, and will The timing service of restarting is restarted.
4. LINUX system as claimed in claim 3 restarts the configuration method of service automatically, it is characterised in that passes through the modification The store path of service is restarted in timing afterwards and storage file title finds the timing service of restarting, and by the timing service of restarting Restarted, included the following steps:
From server, the storage file title that service is restarted by modified timing finds this from the timing on server The service of restarting;
The corresponding service of the storage file title is closed using positive closing mode;
The store path that service is restarted by modified timing finds the included service of the timing service of restarting and is actuated for restarting.
5. LINUX system as described in claim 1 restarts the configuration method of service automatically, it is characterised in that:
At least one service that timing is needed to restart on the slave server of service script is restarted in setting.
6. LINUX system as described in claim 1 restarts the configuration method of service automatically, it is characterised in that:
The log-on message from server includes user name, password and IP address.
7. LINUX system as described in claim 1 restarts the configuration method of service automatically, it is characterised in that:
Set from server restart when service script restarts the periodically service of restarting include end of service order and Server resets order;
Wherein, end of service order is terminated service using positive closing mode;
The included service of server resets command calls service is actuated for restarting.
8. LINUX system as described in claim 1 restarts the configuration method of service automatically, it is characterised in that:
The master server is there is no the management servers for periodically restarting service.
9. LINUX system as described in claim 1 restarts the configuration method of service automatically, it is characterised in that restarts calling script Service script is restarted from server calls by local log-on and carries out server resets, is included the following steps:
Master server restarts all username and passwords from server that script acquisition is called to be locally stored, and carries out local step on Record;
After logining successfully, the corresponding IP address of user name from server is obtained;
The slave server that service is restarted comprising timing is found by IP address, calling restarts service script;
Restart service script according to modified timing restart service store path and storage file title to periodically restarting clothes Business is restarted.
CN201711474552.6A 2017-12-29 2017-12-29 Configuration method for automatic restart service of LINUX system Active CN108196982B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201711474552.6A CN108196982B (en) 2017-12-29 2017-12-29 Configuration method for automatic restart service of LINUX system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201711474552.6A CN108196982B (en) 2017-12-29 2017-12-29 Configuration method for automatic restart service of LINUX system

Publications (2)

Publication Number Publication Date
CN108196982A true CN108196982A (en) 2018-06-22
CN108196982B CN108196982B (en) 2021-12-07

Family

ID=62586176

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201711474552.6A Active CN108196982B (en) 2017-12-29 2017-12-29 Configuration method for automatic restart service of LINUX system

Country Status (1)

Country Link
CN (1) CN108196982B (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109324834A (en) * 2018-09-19 2019-02-12 郑州云海信息技术有限公司 A kind of system and method that distributed storage server is restarted automatically
CN110134546A (en) * 2019-04-11 2019-08-16 平安科技(深圳)有限公司 Batch restarts windows systems approach, electronic device and storage medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101630262A (en) * 2009-07-17 2010-01-20 北京数帅科技有限公司 Method for monitoring and controlling subprocess based on Linux system
US7805721B2 (en) * 2004-06-14 2010-09-28 Likewise Software, Inc. System and method for automated migration from Windows to Linux
CN102521099A (en) * 2011-11-24 2012-06-27 深圳市同洲视讯传媒有限公司 Process monitoring method and process monitoring system
CN103970660A (en) * 2014-05-19 2014-08-06 浪潮电子信息产业股份有限公司 Total system stability automatic test method based on crontab
US20170132090A1 (en) * 2015-11-05 2017-05-11 International Business Machines Corporation Checkpoint mechanism in a compute embedded object storage infrastructure

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7805721B2 (en) * 2004-06-14 2010-09-28 Likewise Software, Inc. System and method for automated migration from Windows to Linux
CN101630262A (en) * 2009-07-17 2010-01-20 北京数帅科技有限公司 Method for monitoring and controlling subprocess based on Linux system
CN102521099A (en) * 2011-11-24 2012-06-27 深圳市同洲视讯传媒有限公司 Process monitoring method and process monitoring system
CN103970660A (en) * 2014-05-19 2014-08-06 浪潮电子信息产业股份有限公司 Total system stability automatic test method based on crontab
US20170132090A1 (en) * 2015-11-05 2017-05-11 International Business Machines Corporation Checkpoint mechanism in a compute embedded object storage infrastructure

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
夜、、、狼: "linux下根据进程名定时杀死/重启进程", 《HTTP://BLOD.CSDN.NET/U010976445/ARTICLE/DETAILS/50819287》 *
无: "except自动检测并重启另外一台服务器上的程序代码-linux-shell-脚本之家", 《HTTPS://WWW.JB51.NET/ARTICLE/33929.HTM》 *

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109324834A (en) * 2018-09-19 2019-02-12 郑州云海信息技术有限公司 A kind of system and method that distributed storage server is restarted automatically
CN110134546A (en) * 2019-04-11 2019-08-16 平安科技(深圳)有限公司 Batch restarts windows systems approach, electronic device and storage medium

Also Published As

Publication number Publication date
CN108196982B (en) 2021-12-07

Similar Documents

Publication Publication Date Title
US10705880B2 (en) Cluster updating using temporary update-monitor pod
EP2697714B1 (en) Deployment system for multi-node applications
US10275258B2 (en) Systems and methods for enhancing the availability of multi-tier applications on cloud computing platforms
US6871223B2 (en) System and method for agent reporting in to server
CN106484425B (en) A kind of abnormality eliminating method of policy-based configuration
WO2017049912A1 (en) Service processing method adopted by jslee container and system utilizing same
CN110955589A (en) Method, system, device and medium for testing headless mode based on browser
CN110391937A (en) A kind of Internet of Things honeynet system based on SOAP service simulation
US20220083364A1 (en) Reconciler sandboxes for secure kubernetes operators
CN104216776A (en) Quick starting method for Android operating system based on BLCR (Berkeley lab checkpoint restart) technology
CN103942491A (en) Internet malicious code disposal method
CN108196982A (en) A kind of LINUX system restarts the configuration method of service automatically
CN104461563A (en) Method for regularly detecting newly-added file of FTP server under linux
CN104915239A (en) Method and device for carrying out multi-process startup by container
US20050080584A1 (en) Automatic software testing
CN112214227A (en) Edge server mirror image customization and deployment system and method
CN103309668A (en) Method and device for processing uncaught exception of application programs
CN107329738A (en) Component update method and device
CN107623581A (en) Service list generation method, apparatus and system, acquisition, report method and device
US8392469B2 (en) Model based distributed application management
CN114443239A (en) Method and device for filling container
CN109471630B (en) Application processing method and device
CN108804147A (en) Link closedown method, device and client
WO2019143467A1 (en) System and method of a cloud service provider virtual machine recovery
CN112667393B (en) Method and device for building distributed task computing scheduling framework and computer equipment

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
GR01 Patent grant
GR01 Patent grant