CN105141665A - Method and device for realizing data mirroring and server cluster system - Google Patents
Method and device for realizing data mirroring and server cluster system Download PDFInfo
- Publication number
- CN105141665A CN105141665A CN201510453871.3A CN201510453871A CN105141665A CN 105141665 A CN105141665 A CN 105141665A CN 201510453871 A CN201510453871 A CN 201510453871A CN 105141665 A CN105141665 A CN 105141665A
- Authority
- CN
- China
- Prior art keywords
- server
- standby
- main
- key data
- name
- 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
Links
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/01—Protocols
- H04L67/10—Protocols in which an application is distributed across nodes in the network
- H04L67/1095—Replication or mirroring of data, e.g. scheduling or transport for data synchronisation between network nodes
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L63/00—Network architectures or network communication protocols for network security
- H04L63/08—Network architectures or network communication protocols for network security for authentication of entities
Landscapes
- Engineering & Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Computer Hardware Design (AREA)
- Computer Security & Cryptography (AREA)
- Computing Systems (AREA)
- General Engineering & Computer Science (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
本发明提供一种实现数据镜像的方法、装置及系统,应用于服务器集群系统,该方法包括:通过设置认证秘钥的类型,并互相设置为授权用户,创建主服务器与备用服务器之间的信任关系;每隔一个设定时间,检测当前处于运行状态的服务器的名称;判断所述服务器名称是否与所述主服务器的名称相同;根据所述信任关系,如果是,通过脚本资源将所述主服务器上的关键数据复制到所述备用服务器上,否则通过脚本资源将所述备用服务器上的关键数据复制到所述主服务器上。该装置包括:创建单元、检测单元、判断单元及镜像单元。该系统包括:主服务器、备用服务器及本发明提供的实现数据镜像的装置。本方案能够提高对服务器集群系统进行配置的效率。
The invention provides a method, device and system for realizing data mirroring, which is applied to a server cluster system. The method includes: setting the type of the authentication key and setting each other as authorized users to create trust between the main server and the backup server relationship; every set time, detect the name of the server currently in running state; judge whether the name of the server is the same as the name of the master server; according to the trust relationship, if so, use the script resource to The key data on the server is copied to the standby server, otherwise the key data on the standby server is copied to the main server through a script resource. The device includes: creating unit, detecting unit, judging unit and mirroring unit. The system includes: a main server, a backup server and the device for realizing data mirroring provided by the invention. The solution can improve the configuration efficiency of the server cluster system.
Description
技术领域 technical field
本发明涉及计算机安全领域,特别涉及一种实现数据镜像的方法、装置及服务器集群系统。 The invention relates to the field of computer security, in particular to a method, device and server cluster system for realizing data mirroring.
背景技术 Background technique
随着计算机技术的不断发展,服务器得到广泛的应用,各企事业单位的很多业务都运行在服务器上,如果服务器发生宕机故障或应用停运,将给企事业单位带来巨大的损失。为了保证关键业务的持续不间断运行,一般将关键业务运行在具有冗余机制的服务器集群中,通常情况下业务运行在主服务器上,当主服务器发生故障不能为该业务提供运行环境时,服务器集群系统自动将该业务转移至备用服务器上继续运行,保证业务的不间断运行,这就要求主备服务器之间数据及业务进度的同步性,需要实时将主服务器上的数据及业务进度镜像到备用服务器上。 With the continuous development of computer technology, servers are widely used, and many businesses of enterprises and institutions run on servers. If the server fails or the application is out of service, it will bring huge losses to enterprises and institutions. In order to ensure the continuous and uninterrupted operation of key businesses, key businesses are generally run in server clusters with redundancy mechanisms. Usually, the business runs on the main server. When the main server fails and cannot provide an operating environment for the business, the server cluster The system automatically transfers the business to the standby server to continue running to ensure the uninterrupted operation of the business. This requires the synchronization of data and business progress between the main server and the backup server. It is necessary to mirror the data and business progress on the main server to the standby server in real time. on the server.
目前,在服务器集群中,通常都是通过第三方软件来实现不同服务器之间数据的同步,实时将运行中的服务器上的数据和业务进度镜像到备用服务器上。 At present, in server clusters, third-party software is usually used to synchronize data between different servers, and mirror the data and business progress on the running server to the standby server in real time.
针对现有技术实现不同服务器之间数据同步的方法,安装第三方软件时需要对现有软件的结构进行修改,对现有软件的结构进行修改需要大量的时间,因而,对服务器集群系统进行配置的效率较低。 Aiming at the method of realizing data synchronization between different servers in the prior art, the structure of the existing software needs to be modified when the third-party software is installed, and it takes a lot of time to modify the structure of the existing software. Therefore, the configuration of the server cluster system is less efficient.
发明内容 Contents of the invention
本发明提供一种实现数据镜像的方法、装置及服务器集群系统,能够提高对服务器集群系统进行配置的效率。 The invention provides a method and device for realizing data mirroring and a server cluster system, which can improve the configuration efficiency of the server cluster system.
本发明实施例提供了一种实现数据镜像的方法,应用于服务器集群系统,包括:通过设置认证秘钥的类型,并互相设置为授权用户,创建主服务器与备用服务器之间的信任关系; The embodiment of the present invention provides a method for implementing data mirroring, which is applied to a server cluster system, including: establishing a trust relationship between the main server and the backup server by setting the type of the authentication key and setting each other as authorized users;
每隔一个设定时间,检测当前处于运行状态的服务器的服务器名称; Every set time, detect the server name of the server currently running;
判断所述服务器名称是否与所述主服务器的名称相同; judging whether the name of the server is the same as the name of the primary server;
根据所述信任关系,如果是,通过脚本资源将所述主服务器上的关键数据复制到所述备用服务器上,否则通过脚本资源将所述备用服务器上的关键数据复制到所述主服务器上。 According to the trust relationship, if yes, copy the key data on the primary server to the standby server through the script resource, otherwise copy the key data on the standby server to the primary server through the script resource.
优选地,所述通过设置认证秘钥的类型,并互相设置为授权用户包括: Preferably, said setting the type of the authentication key and setting each other as authorized users includes:
在主服务器上运行#ssh-keygen-trsa,将主服务器上的id_rsa.pub文件拷贝到备用服务器上的root用户主目录下的.ssh目录下,并且改名为authorized_keys; Run #ssh-keygen-trsa on the primary server, copy the id_rsa.pub file on the primary server to the .ssh directory under the root user’s home directory on the standby server, and rename it to authorized_keys;
在备用服务器上运行#ssh-keygen-trsa,将备用服务器上的id_rsa.pub文件拷贝到主服务器上的root用户主目录下的.ssh目录下,并且改名为authorized_keys。 Run #ssh-keygen-trsa on the standby server, copy the id_rsa.pub file on the standby server to the .ssh directory under the root user's home directory on the primary server, and rename it to authorized_keys.
优选地,所述检测当前处于运行状态的服务器的服务器名称包括: Preferably, said detecting the server name of the server currently running includes:
通过hostname-命令检测所述服务器集群系统的hostname值,通过hostname值获取当前处于运行状态的服务器的服务器名称。 The hostname value of the server cluster system is detected through the hostname-command, and the server name of the server currently running is obtained through the hostname value.
优选地,所述通过脚本资源将所述主服务器上的关键数据复制到所述备用服务器上包括: Preferably, said copying key data on said master server to said standby server through script resource comprises:
通过scp命令,将主服务器上的关键数据镜像复制到备用服务器上相应的目录下。 Use the scp command to copy the key data image on the primary server to the corresponding directory on the standby server.
优选地,所述通过脚本资源将所述备用服务器上的关键数据复制到所述主服务器上包括:通过scp命令,将备用服务器上的关键数据镜像复制到主服务器上相应的目录下。 Preferably, said copying the key data on the standby server to the main server through the script resource includes: mirror copying the key data on the standby server to the corresponding directory on the main server through scp command.
本发明实施例还提供了一种实现数据镜像的装置,应用于服务器集群系统,包括: The embodiment of the present invention also provides a device for implementing data mirroring, which is applied to a server cluster system, including:
创建单元,用于通过设置认证秘钥的类型,并互相设置为授权用户,创建主服务器与备用服务器之间的信任关系; Create a unit for creating a trust relationship between the primary server and the standby server by setting the type of the authentication key and setting each other as authorized users;
检测单元,用于每隔一个设定时间,检测当前处于运行状态的服务器的服务器名称; The detection unit is used to detect the server name of the server currently in running state at intervals of a set time;
判断单元,用于判断所述检测单元检测到的服务器名称是否与所述主服务器的名称相同; A judging unit, configured to judge whether the server name detected by the detection unit is the same as the name of the main server;
镜像单元,用于根据所述判断单元的判断结果及所述创建单元创建的信任关系,如果是,通过脚本资源将所述主服务器上的关键数据复制到所述备用服务器上,如果否,则通过脚本资源将所述备用服务器上的关键数据复制到所述主服务器上。 The mirroring unit is configured to, according to the judgment result of the judging unit and the trust relationship created by the creating unit, if yes, copy the key data on the primary server to the backup server through the script resource, if not, then The key data on the standby server is copied to the main server through the script resource.
优选地,所述创建单元,用于在主服务器上运行#ssh-keygen-trsa,将主服务器上的id_rsa.pub文件拷贝到备用服务器上的root用户主目录下的.ssh目录下,并且改名为authorized_keys; Preferably, the creation unit is used to run #ssh-keygen-trsa on the main server, copy the id_rsa.pub file on the main server to the .ssh directory under the root user home directory on the standby server, and rename for authorized_keys;
且, and,
所述创建单元,将备用服务器上运行#ssh-keygen-trsa,然后把备用服务器上的id_rsa.pub文件拷贝到主服务器上的root用户主目录下的.ssh目录下,并且改名为authorized_keys。 The creation unit is to run #ssh-keygen-trsa on the standby server, then copy the id_rsa.pub file on the standby server to the .ssh directory under the root user's home directory on the main server, and rename it to authorized_keys.
优选地,所述检测单元,用于通过hostname-命令检测所述服务器集群系统的hostname值,通过所述hostname值获取当前处于运行状态的服务器的服务器名称。 Preferably, the detection unit is configured to detect the hostname value of the server cluster system through the hostname-command, and obtain the server name of the server currently running through the hostname value.
优选地,所述镜像单元,用于通过scp命令,将主服务器上的关键数据镜像复制到备用服务器上相应的目录下; Preferably, the mirroring unit is used to mirror the key data on the primary server to the corresponding directory on the standby server through the scp command;
或, or,
所述镜像单元,用于通过scp命令,将备用服务器上的关键数据镜像复制到主服务器上相应的目录下。 The mirroring unit is used to mirror the key data on the backup server to the corresponding directory on the master server through the scp command.
本发明实施例还提供了一种服务器集群系统,包括:主服务、备用服务器及本发明实施例所提供的任意一种实现数据镜像的装置; The embodiment of the present invention also provides a server cluster system, including: a main server, a standby server, and any device for implementing data mirroring provided by the embodiments of the present invention;
所述主服务器与所述实现数据镜像的装置相连,用于存储关键数据,正常运行业务或在所述备用服务器发生故障时继续运行业务; The main server is connected to the device for realizing data mirroring, and is used for storing key data, running business normally or continuing to run business when the backup server fails;
所述备用服务器与所述实现数据镜像的装置相连,用于存储关键数据,正常运行业务或在所述主服务器发生故障时继续运行业务。 The backup server is connected to the device for realizing data mirroring, and is used for storing key data, running business normally or continuing to run business when the main server fails.
优选地,该系统进一步包括:共享存储器及业务持续性保护装置; Preferably, the system further includes: shared memory and business continuity protection device;
所述共享存储器分别与所述主服务器与备用服务器相连,用于存储一般数据; The shared memory is respectively connected to the main server and the standby server for storing general data;
所述业务持续性保护装置分别与所述主服务器与备用服务器相连,用于在其中一个服务器发生故障时,将其运行的业务转移到另一个服务器上; The business continuity protection device is respectively connected to the main server and the standby server, and is used to transfer the running business of one of the servers to another server when a failure occurs on one of the servers;
优选地,所述主服务器与所述备用服务器均包括两个网卡,通过公网和私网搭建双心跳连接,其中所述主服务器上的一个网卡通过私网与所述备用服务器上的一个网卡相连,所述主服务器上的另一个网卡及所述备用服务器上的另一个网卡均与公网相连。 Preferably, the main server and the backup server both include two network cards, and a double heartbeat connection is established through a public network and a private network, wherein one network card on the main server is connected to a network card on the backup server through a private network The other network card on the main server and the other network card on the standby server are both connected to the public network.
本发明实施例提供了一种实现数据镜像的方法、装置及服务器集群系统,通过设置主服务器与备用服务器的认证密钥类型,并分别将主服务器与备用服务器设置为互相授权的用户,从而建立主服务器与备用服务器之间的信任关系,每经过一个设定时间,检测当前处于运行状态的服务器的服务器名称,并判断该服务器名称是否与主服务器的名称相同,如果相同,根据建立的信任关系,通过脚本资源将主服务器上的关键数据复制到备用服务器上,如果不同,则根据建立的信任关系,通过脚本资源将备用服务器上的关键数据复制到主服务器上,这样,只需通过脚本资源即可实现服务器集群内关键数据的镜像,无需安装第三方软件,节省了对现有软件结构进行修改的时间,从而提高了对服务器集群系统进行配置的效率。 The embodiment of the present invention provides a method, device, and server cluster system for realizing data mirroring. By setting the authentication key types of the main server and the backup server, and respectively setting the main server and the backup server as mutually authorized users, thereby establishing The trust relationship between the main server and the backup server, every time a set time passes, detect the server name of the server currently running, and judge whether the server name is the same as the name of the main server, if they are the same, according to the established trust relationship , copy the key data on the primary server to the standby server through the script resource, if they are different, according to the established trust relationship, copy the key data on the standby server to the primary server through the script resource, in this way, only need to pass the script resource The mirror image of key data in the server cluster can be realized without installing third-party software, which saves the time for modifying the existing software structure, thereby improving the efficiency of configuring the server cluster system.
附图说明 Description of drawings
图1是本发明一个实施例提供的一种实现数据镜像的方法流程图; FIG. 1 is a flowchart of a method for implementing data mirroring provided by an embodiment of the present invention;
图2是本发明另一个实施例提供的一种实现数据镜像的方法流程图; FIG. 2 is a flow chart of a method for implementing data mirroring provided by another embodiment of the present invention;
图3是本发明一个实施例提供的一种实现数据镜像的装置示意图; FIG. 3 is a schematic diagram of an apparatus for implementing data mirroring provided by an embodiment of the present invention;
图4是本发明一个实施例提供的一种服务器集群系统的结构示意图; Fig. 4 is a schematic structural diagram of a server cluster system provided by an embodiment of the present invention;
图5上本发明另一个实施例提供的一种服务器集群系统的结构示意图。 FIG. 5 is a schematic structural diagram of a server cluster system provided by another embodiment of the present invention.
具体实施方式 Detailed ways
下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述。显然,所描述的实施例仅是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。 The following will clearly and completely describe the technical solutions in the embodiments of the present invention with reference to the drawings in the embodiments of the present invention. Apparently, the described embodiments are only some of the embodiments of the present invention, but not all of them. Based on the embodiments of the present invention, all other embodiments obtained by persons of ordinary skill in the art without making creative efforts belong to the protection scope of the present invention.
如图1所示,本发明一个实施例提供了一种实现数据镜像的方法,包括: As shown in Figure 1, an embodiment of the present invention provides a method for implementing data mirroring, including:
步骤101:通过设置认证秘钥的类型,并互相设置为授权用户,创建主服务器与备用服务器之间的信任关系; Step 101: Create a trust relationship between the primary server and the standby server by setting the type of the authentication key and setting each other as authorized users;
步骤102:每隔一个设定时间,检测当前处于运行状态的服务器的服务器名称; Step 102: every set time, detect the server name of the server currently running;
步骤103:判断所述服务器名称是否与所述主服务器的名称相同,如果是,执行步骤104,否则执行步骤105; Step 103: judging whether the name of the server is the same as the name of the main server, if yes, execute step 104, otherwise execute step 105;
步骤104:根据所述信任关系,通过脚本资源将所述主服务器上的关键数据复制到所述备用服务器上,并结束当前流程; Step 104: According to the trust relationship, copy the key data on the primary server to the standby server through script resources, and end the current process;
步骤105:根据所述信任关系,通过脚本资源将所述备用服务器上的关键数据复制到所述主服务器上。 Step 105: According to the trust relationship, copy the key data on the standby server to the primary server through a script resource.
本发明实施例提供了一种实现数据镜像的方法,通过设置主服务器与备用服务器的认证密钥类型,并分别将主服务器与备用服务器设置为互相授权的用户,从而建立主服务器与备用服务器之间的信任关系,每经过一个设定时间,检测当前处于运行状态的服务器的服务器名称,并判断该服务器名称是否与主服务器的名称相同,如果相同,根据建立的信任关系,通过脚本资源将主服务器上的关键数据复制到备用服务器上,如果不同,则根据建立的信任关系,通过脚本资源将备用服务器上的关键数据复制到主服务器上,这样,只需通过脚本资源即可实现服务器集群内关键数据的镜像,无需安装第三方软件,节省了对现有软件结构进行修改的时间,从而提高了对服务器集群系统进行配置的效率。 The embodiment of the present invention provides a method for implementing data mirroring. By setting the authentication key types of the main server and the backup server, and respectively setting the main server and the backup server as mutually authorized users, the relationship between the main server and the backup server is established. Each time a set time passes, the server name of the server currently running is detected, and it is judged whether the server name is the same as the name of the main server. If they are the same, according to the established trust relationship, the main The key data on the server is copied to the standby server. If they are different, according to the established trust relationship, the key data on the standby server is copied to the primary server through script resources. The mirror image of key data does not need to install third-party software, which saves the time for modifying the existing software structure, thereby improving the efficiency of configuring the server cluster system.
在本发明一个实施例中,通过在主服务器上运行#ssh-keygen-trsa,将主服务器上的id_rsa.pub文件拷贝到备用服务器上的root用户主目录下的.ssh目录下,并且改名为authorized_keys,使主服务器具有对备用服务器进行访问权限,同理在备用服务器上运行#ssh-keygen-trsa,将备用服务器上的id_rsa.pub文件拷贝到主服务器上的root用户主目录下的.ssh目录下,并且改名为authorized_keys,使备用服务器具有对主服务器进行访问的权限,这样建立主服务器与备用服务器之间的信任关系,保证在脚本资源在进行数据传输时无需进行身份验证,实现主服务器与备用服务器之间关键数据的传输。 In one embodiment of the present invention, by running #ssh-keygen-trsa on the primary server, the id_rsa.pub file on the primary server is copied to the .ssh directory under the root user's home directory on the standby server, and renamed to authorized_keys, so that the main server has access to the standby server. Similarly, run #ssh-keygen-trsa on the standby server, and copy the id_rsa.pub file on the standby server to .ssh under the root user's home directory on the main server directory, and renamed to authorized_keys, so that the standby server has access to the main server, so as to establish a trust relationship between the main server and the standby server, to ensure that the script resources do not need to be authenticated during data transmission, and the main server can be realized Transfer of critical data to and from a backup server.
在本发明一个实施例中,在检测当前处于运行状态的服务器名称是,通过hostname-命令检测当前服务器集群系统的hostname值,通过hostname值获取当前处于运行状态的服务器的服务器名称,通过服务器名称可以准确的判断当前处于运行状态的是主服务还是备用服务器,从而确定主服务器与备用服务器之间关键数据的拷贝顺序,保证主服务器与备用服务器之间关键数据的同步性。 In one embodiment of the present invention, when detecting the server name currently in the running state, the hostname value of the current server cluster system is detected by the hostname-command, and the server name of the server currently in the running state is obtained by the hostname value, and the server name can be used Accurately judge whether the current running state is the main service or the standby server, so as to determine the copy sequence of key data between the main server and the standby server, and ensure the synchronization of key data between the main server and the standby server.
在本发明一个实施例中,在主服务器与备用服务器之间进行关键数据拷贝时,通过scp命令,将主服务器上的关键数据复制到备用服务器的相应目录下,或将备用服务器上的关键数据复制到主服务器的相应目录下,在关键数据传输过程中,关键数据处于加密状态,避免关键数据被窃取,提高关键数据的安全性。 In one embodiment of the present invention, when key data is copied between the main server and the standby server, the key data on the main server is copied to the corresponding directory of the standby server through the scp command, or the key data on the standby server Copy it to the corresponding directory of the main server. During the transmission of key data, the key data is in an encrypted state to prevent key data from being stolen and improve the security of key data.
为使本发明的目的、技术方案和优点更加清楚,下面结合附图及具体实施例对本发明作进一步地详细描述。 In order to make the purpose, technical solution and advantages of the present invention clearer, the present invention will be further described in detail below in conjunction with the accompanying drawings and specific embodiments.
如图2所示,本发明一个实施例提供了一种实现数据镜像的方法,应用于双机集群系统,包括: As shown in Figure 2, an embodiment of the present invention provides a method for implementing data mirroring, which is applied to a dual-machine cluster system, including:
步骤201:设置主服务器与备用服务器的认证密钥类型。 Step 201: Set the authentication key types of the main server and the standby server.
在本发明一个实施例中,双机集群系统包括两个服务器,其中一个为主服务器,另一个为备用服务器,两个服务器处于同等地位,分别在主服务器及备用服务器上运行#ssh-keygen-trsa,将主服务器与备用服务器的认证密钥均设置为rsa的加密方式,保证服务器与备用服务器能够互相认证。 In an embodiment of the present invention, the dual-machine cluster system includes two servers, one of which is the main server and the other is the backup server. The two servers are in the same position and run on the main server and the backup server respectively. #ssh-keygen- trsa, set the authentication keys of both the primary server and the standby server to rsa encryption to ensure that the server and the standby server can authenticate each other.
步骤202:将主服务器与备用服务器互相设置成为对方的授权用户。 Step 202: Set the main server and the standby server as authorized users of each other.
在本发明一个实施例中,通过将主服务器上的id_rsa.pub文件拷贝到备用服务器上的root用户主目录下的.ssh目录下,并且改名为authorized_keys,并将备用服务器上的id_rsa.pub文件拷贝到主服务器上的root用户主目录下的.ssh目录下,并且改名为authorized_keys,这样将主服务设置成为备用服务器的授权用户,同时也将备用服务器设置成为主服务器的授权用户,建立起主服务器与备用服务器之间的信任关系,以保证在主服务器与备用服务器之间进行数据传输时不需要进行身份的验证。 In one embodiment of the present invention, by copying the id_rsa.pub file on the main server to the .ssh directory under the root user's home directory on the standby server, and renaming it to authorized_keys, and copying the id_rsa.pub file on the standby server Copy it to the .ssh directory under the root user's home directory on the main server, and rename it to authorized_keys, so that the main service is set as the authorized user of the standby server, and the standby server is also set as the authorized user of the main server, and the main server is established. The trust relationship between the server and the standby server ensures that identity verification is not required for data transmission between the primary server and the standby server.
步骤203:设定进行数据镜像的间隔时间。 Step 203: Set the interval time for data mirroring.
在本发明一个实施例中,根据双机集群系统运算数据量的大小,确定主服务器与备用服务器之间进行数据镜像的间隔时间。例如,设定数据镜像的间隔时间为5min。 In one embodiment of the present invention, the interval time for data mirroring between the primary server and the standby server is determined according to the amount of computing data in the dual-machine cluster system. For example, set the data mirroring interval to 5 minutes.
步骤204:每隔一个所述间隔时间,检测一次双机集群系统中当前处于运行状态的服务器的名称。 Step 204: Detect the name of the server currently running in the dual-machine cluster system at each interval.
在本发明一个实施例中,每经过一个所述间隔时间,通过hostname-命令检测双机集群系统的hostname值,通过hostname值获取当前处于运行状态的服务器的服务器名称。例如,每经过5min,检测一次双机集群系统的hostname值,获得当前处于运行状态的服务器的名称。 In one embodiment of the present invention, every time the interval time passes, the hostname value of the dual-machine cluster system is detected through the hostname-command, and the server name of the server currently running is obtained through the hostname value. For example, every 5 minutes, check the hostname value of the dual-machine cluster system to obtain the name of the server currently running.
步骤205:判断当前处于运行状态的服务器的名称是否与主服务器的名称相同,如果是,执行步骤206,否则执行步骤207。 Step 205: Judging whether the name of the currently running server is the same as the name of the master server, if yes, go to step 206, otherwise go to step 207.
在本发明一个实施例中,通过将获取到的当前处于运行状态的服务器的服务器名称与主服务器的名称进行对比,判断当前处于运行状态的服务器是否为主服务器,如果当前处于运行状态的服务器的名称与主服务器的名称相同,说明当前处于运行状态的服务器为主服务器,需要将主服务器中的关键数据镜像到备用服务器中,执行步骤206,如果当前处于运行状态的服务器的名称与主服务器的名称不同,则说明当前处于运行状态的服务器为备用服务器,需要将备用服务器上的关键数据镜像到主服务器中,执行步骤207。 In one embodiment of the present invention, by comparing the obtained server name of the currently running server with the name of the master server, it is judged whether the server currently in the running state is the master server. The name is the same as the name of the primary server, indicating that the currently running server is the primary server, and the key data in the primary server needs to be mirrored to the standby server. Go to step 206. If the name of the currently running server is the same as that of the primary server If the names are different, it means that the server currently running is a standby server, and the key data on the standby server needs to be mirrored to the primary server, and step 207 is performed.
步骤206:通过脚本资源,将主服务器上的关键数据复制到备用服务器上,并继续执行步骤204。 Step 206: Copy the key data on the primary server to the standby server through the script resource, and continue to execute step 204.
在本发明一个实施例中,通过scp命令,对主服务器上的关键数据进行加密,并将加密后的关键数据复制到备用服务器上相应的目录下,之后继续执行步骤204,保证备用服务器上的关键数据与主服务器上的关键数据保持一致。 In one embodiment of the present invention, the key data on the primary server is encrypted by the scp command, and the encrypted key data is copied to the corresponding directory on the standby server, and then step 204 is continued to ensure that the key data on the standby server The key data is consistent with the key data on the master server.
步骤207:通过脚本资源,将备用服务器上的关键数据复制到主服务器上,并继续执行步骤204。 Step 207: copy the key data on the standby server to the primary server through the script resource, and continue to execute step 204.
在本发明一个实施例中,通过scp命令,对备用服务器上的关键数据进行加密,并将加密后的关键数据复制到主服务器上相应的目录下,之后继续执行步骤204,保证主服务器上的关键数据与备用服务器上的关键数据保持一致。 In one embodiment of the present invention, the key data on the standby server is encrypted by the scp command, and the encrypted key data is copied to the corresponding directory on the main server, and then step 204 is continued to ensure that the key data on the main server The critical data is consistent with the critical data on the standby server.
如图3所示,本发明一个实施例提供了一种实现数据镜像的装置,包括:检测单元301、判断单元302、镜像单元303及创建单元304; As shown in Figure 3, an embodiment of the present invention provides a device for implementing data mirroring, including: a detection unit 301, a judgment unit 302, a mirroring unit 303, and a creation unit 304;
所述创建单元304,用于通过设置认证秘钥的类型,并互相设置为授权用户,创建主服务器与备用服务器之间的信任关系; The creating unit 304 is configured to create a trust relationship between the main server and the standby server by setting the type of the authentication key and setting each other as authorized users;
所述检测单元301,用于每隔一个设定时间,检测当前处于运行状态的服务器的服务器名称; The detection unit 301 is configured to detect the server name of the server currently in the running state at intervals of a set time;
所述判断单元302,用于判断所述检测单元301检测到的服务器名称是否与所述主服务器的名称相同; The judging unit 302 is configured to judge whether the server name detected by the detecting unit 301 is the same as the name of the main server;
所述镜像单元303,用于根据所述判断单元302的判断结果及所述创建单元304创建的信任关系,如果是,通过脚本资源将所述主服务器上的关键数据复制到所述备用服务器上,如果否,则通过脚本资源将所述备用服务器上的关键数据复制到所述主服务器上。 The mirroring unit 303 is configured to, according to the judgment result of the judging unit 302 and the trust relationship created by the creating unit 304, if yes, copy the key data on the primary server to the standby server through a script resource , if not, copy the key data on the standby server to the primary server through the script resource.
在本发明一个实施例中, In one embodiment of the invention,
所述创建单元304,用于在主服务器上运行#ssh-keygen-trsa,将主服务器上的id_rsa.pub文件拷贝到备用服务器上的root用户主目录下的.ssh目录下,并且改名为authorized_keys,并在备用服务器上运行#ssh-keygen-trsa,将备用服务器上的id_rsa.pub文件拷贝到主服务器上的root用户主目录下的.ssh目录下,并且改名为authorized_keys; The creation unit 304 is used to run #ssh-keygen-trsa on the primary server, copy the id_rsa.pub file on the primary server to the .ssh directory under the root user's home directory on the standby server, and rename it to authorized_keys , and run #ssh-keygen-trsa on the standby server, copy the id_rsa.pub file on the standby server to the .ssh directory under the root user’s home directory on the primary server, and rename it to authorized_keys;
通过将主服务与备用服务器的的认证密钥均设置为rsa的形式,使得主服务器与备用服务器能够互相得到认证,同时将主服务器与备用服务器的ID文件复制到对方的授权用户名单中,使主服务器与备用服务器互相成为授权用户,建立主服务器与备用服务器之间的信任关系,保证在进行数据传输过程中不必进行身份验证。 By setting the authentication keys of the main server and the standby server in the form of rsa, the main server and the standby server can be mutually authenticated, and at the same time copy the ID files of the main server and the standby server to the authorized user list of the other party, so that The primary server and the standby server become authorized users of each other, and a trust relationship between the primary server and the standby server is established to ensure that identity verification is not necessary during data transmission.
在本发明一个实施例中, In one embodiment of the invention,
所述检测单元301,用于通过hostname-命令检测所述服务器集群系统的hostname值,通过所述hostname值获取当前处于运行状态的服务器的服务器名称; The detection unit 301 is configured to detect the hostname value of the server cluster system through the hostname-command, and obtain the server name of the server currently in the running state through the hostname value;
通过hostname值可以确定当前是主服务器处于运行状态还是备用服务器处于运行状态,根据处于运行状态的服务器的不同,确定是将主服务器中的关键数据复制到备用服务器上,还是将备用服务器上的关键数据复制到主服务器上。 Through the hostname value, it can be determined whether the main server is running or the standby server is running. Depending on the running server, it is determined whether to copy the key data in the main server to the standby server or to copy the key data on the standby server. Data is replicated to the master server.
在本发明一个实施例中, In one embodiment of the invention,
所述镜像单元303,用于通过scp命令,将主服务器上的关键数据镜像复制到备用服务器上相应的目录下;或者通过scp命令,将备用服务器上的关键数据镜像复制到主服务器上相应的目录下。 The mirroring unit 303 is used to copy the key data image on the master server to the corresponding directory on the standby server through the scp command; or copy the key data mirror image on the standby server to the corresponding directory on the master server through the scp command. Under contents.
需要说明的是,在本发明实施例中,根据服务器集群系统的运行情况,设定一个设定时间,每经过一个设定时间,检测一次服务器集群系统中处于运行状态的服务器,相应的进行数据的复制,保证主服务器与备用服务器上关键数据的一致性。 It should be noted that, in the embodiment of the present invention, a set time is set according to the operation status of the server cluster system, and each time a set time passes, the server in the running state in the server cluster system is detected, and the data is processed accordingly. Replication to ensure the consistency of key data on the primary server and the standby server.
如图4所示,本发明一个实施例提供了一种服务器集群系统,包括:主服务器401、备用服务器402及上述发明实施例提供的任意一种实现数据镜像的装置403; As shown in FIG. 4, an embodiment of the present invention provides a server cluster system, including: a main server 401, a backup server 402, and any device 403 for implementing data mirroring provided by the above-mentioned embodiments of the invention;
所述主服务器401与所述实现数据镜像的装置403相连,用于存储关键数据,正常运行业务或在所述备用服务器402发生故障时继续运行业务; The main server 401 is connected to the device 403 for realizing data mirroring, and is used for storing key data, running the business normally or continuing to run the business when the backup server 402 fails;
所述备用服务器402与所述实现数据镜像的装置403相连,用于存储关键数据,正常运行业务或在所述主服务器401发生故障时继续运行业务。 The standby server 402 is connected to the device 403 for realizing data mirroring, and is used for storing key data, running business normally or continuing to run business when the main server 401 fails.
在本发明一个实施例中,如图5所示,该系统进一步包括:共享存储器501及业务持续性保护装置502; In one embodiment of the present invention, as shown in FIG. 5 , the system further includes: a shared memory 501 and a service continuity protection device 502;
所述共享存储器501分别与所述主服务器401与备用服务器402相连,用于存储一般数据,以节约主服务器401与备用服务器402上磁盘的空间; The shared memory 501 is connected to the main server 401 and the backup server 402 respectively, and is used for storing general data, so as to save disk space on the main server 401 and the backup server 402;
所述业务持续性保护装置502分别与所述主服务器401与备用服务器402相连,用于在其中一个服务器发生故障时,将其运行的业务转移到另一个服务器上,一实现服务器集群系统给的冗余机制。 The business continuity protection device 502 is respectively connected to the main server 401 and the standby server 402, and is used to transfer the running business of the server to another server when one of the servers fails, so as to realize the server cluster system. Redundancy mechanism.
在本发明一个实施例中,主服务器及备用服务器上均包括两个网卡,通过公网和私网搭建双心跳连接,其中所述主服务器上的一个网卡通过私网与所述备用服务器上的一个网卡相连,所述主服务器上的另一个网卡及所述备用服务器上的另一个网卡均与公网相连,保证主服务器与备用服务器之间数据传输的速度和数据的安全性。 In one embodiment of the present invention, both the main server and the standby server include two network cards, and a double heartbeat connection is established through the public network and the private network, wherein one network card on the main server communicates with the network card on the standby server through the private network. One network card is connected, and the other network card on the main server and the other network card on the backup server are both connected to the public network, so as to ensure the speed of data transmission and the security of data between the main server and the backup server.
根据上述方案,本发明的实施例所提供的一种实现数据镜像的方法、装置及服务器集群系统,至少具有如下有益效果: According to the above solution, a method, device and server cluster system for realizing data mirroring provided by the embodiments of the present invention have at least the following beneficial effects:
1、本发明实施例中,通过设置主服务器与备用服务器的认证密钥类型,并分别将主服务器与备用服务器设置为互相授权的用户,从而建立主服务器与备用服务器之间的信任关系,每经过一个设定时间,检测当前处于运行状态的服务器的服务器名称,并判断该服务器名称是否与主服务器的名称相同,如果相同,根据建立的信任关系,通过脚本资源将主服务器上的关键数据复制到备用服务器上,如果不同,则根据建立的信任关系,通过脚本资源将备用服务器上的关键数据复制到主服务器上,这样,只需通过脚本资源即可实现服务器集群内关键数据的镜像,无需安装第三方软件,节省了对现有软件结构进行修改的时间,从而提高了对服务器集群系统进行配置的效率。 1. In the embodiment of the present invention, by setting the authentication key types of the main server and the backup server, and respectively setting the main server and the backup server as mutually authorized users, thereby establishing a trust relationship between the main server and the backup server, each After a set time, detect the server name of the server that is currently running, and judge whether the server name is the same as the name of the main server. If they are the same, copy the key data on the main server through script resources according to the established trust relationship to the standby server, if they are different, then according to the established trust relationship, the key data on the standby server will be copied to the primary server through the script resource, so that the mirror image of the key data in the server cluster can be realized only through the script resource, without Installing third-party software saves the time for modifying the existing software structure, thereby improving the efficiency of configuring the server cluster system.
2、本发明实施例中,无需使用第三方软件,就可以实现服务器集群系统的数据镜像功能,避免对现有软件的结构进行修改,一方面提升了服务器集群系统的稳定性,另一方面节省系统配置的工作量,节约服务器集群系统配置的成本。 2. In the embodiment of the present invention, the data mirroring function of the server cluster system can be realized without using third-party software, which avoids modifying the structure of the existing software, improves the stability of the server cluster system on the one hand, and saves on the other hand The workload of system configuration is reduced, and the cost of server cluster system configuration is saved.
3、本发明实施例中,通过scp命令实现关键数据在主服务器与备用服务器之间的传输,在关键数据进行传输之前,首先对关键数据进行加密,保证关键数据在传输过程中处于加密状态,防止在数据传输过程中造成数据的泄露,提高关键数据的安全性。 3. In the embodiment of the present invention, the scp command is used to realize the transmission of key data between the primary server and the backup server. Before the key data is transmitted, the key data is first encrypted to ensure that the key data is in an encrypted state during transmission. Prevent data leakage during data transmission and improve the security of key data.
4、本发明实施例中,在主服务器和备用服务器上运行#ssh-keygen-trsa,并分别将对方的ID文件复制到自身的授权名单中,从而建立其主服务器与备用服务器之间的信任关系,保证主服务器与备用服务器之间进行数据传输时不需要进行身份验证,以便关键数据复制过程的顺利进行。 4. In the embodiment of the present invention, #ssh-keygen-trsa is run on the main server and the backup server, and the ID file of the other party is copied to its own authorization list, thereby establishing the trust between the main server and the backup server The relationship ensures that no authentication is required for data transmission between the primary server and the standby server, so that the key data replication process can proceed smoothly.
5、本发明实施例中,主服务器与备用服务器均包括两个网卡,每个服务器上的两个网卡中的其中一个网卡与公网相连,另一个网卡与私网相连,主服务器与备用服务器之间进行数据传输时通过私网进行,一方面可以保证数据的传输速度,另一方面还能够提高关键数据的安全性。 5. In the embodiment of the present invention, the main server and the backup server both include two network cards, one of the two network cards on each server is connected to the public network, the other network card is connected to the private network, and the main server and the backup server The data transmission between them is carried out through the private network, on the one hand, it can guarantee the data transmission speed, and on the other hand, it can also improve the security of key data.
上述设备内的各单元之间的信息交互、执行过程等内容,由于与本发明方法实施例基于同一构思,具体内容可参见本发明方法实施例中的叙述,此处不再赘述。 The information exchange and execution process among the units in the above-mentioned equipment are based on the same concept as the method embodiment of the present invention, and the specific content can refer to the description in the method embodiment of the present invention, and will not be repeated here.
需要说明的是,在本文中,诸如第一和第二之类的关系术语仅仅用来将一个实体或者操作与另一个实体或操作区分开来,而不一定要求或者暗示这些实体或操作之间存在任何这种实际的关系或者顺序。而且,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者设备所固有的要素。在没有更多限制的情况下,由语句“包括一个······”限定的要素,并不排除在包括所述要素的过程、方法、物品或者设备中还存在另外的相同因素。 It should be noted that in this article, relational terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply that there is a relationship between these entities or operations. There is no such actual relationship or sequence. Furthermore, the term "comprises", "comprises" or any other variation thereof is intended to cover a non-exclusive inclusion such that a process, method, article or apparatus comprising a set of elements includes not only those elements, but also includes elements not expressly listed. other elements of or also include elements inherent in such a process, method, article, or device. Without further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of additional same elements in the process, method, article or apparatus comprising said element.
本领域普通技术人员可以理解:实现上述方法实施例的全部或部分步骤可以通过程序指令相关的硬件来完成,前述的程序可以存储在计算机可读取的存储介质中,该程序在执行时,执行包括上述方法实施例的步骤;而前述的存储介质包括:ROM、RAM、磁碟或者光盘等各种可以存储程序代码的介质中。 Those of ordinary skill in the art can understand that all or part of the steps to realize the above method embodiments can be completed by program instructions related hardware, and the aforementioned programs can be stored in a computer-readable storage medium. When the program is executed, the It includes the steps of the above method embodiments; and the aforementioned storage medium includes: ROM, RAM, magnetic disk or optical disk and other various media that can store program codes.
最后需要说明的是:以上所述仅为本发明的较佳实施例,仅用于说明本发明的技术方案,并非用于限定本发明的保护范围。凡在本发明的精神和原则之内所做的任何修改、等同替换、改进等,均包含在本发明的保护范围内。 Finally, it should be noted that the above descriptions are only preferred embodiments of the present invention, and are only used to illustrate the technical solution of the present invention, and are not used to limit the protection scope of the present invention. Any modification, equivalent replacement, improvement, etc. made within the spirit and principles of the present invention are included in the protection scope of the present invention.
Claims (10)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201510453871.3A CN105141665A (en) | 2015-07-29 | 2015-07-29 | Method and device for realizing data mirroring and server cluster system |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201510453871.3A CN105141665A (en) | 2015-07-29 | 2015-07-29 | Method and device for realizing data mirroring and server cluster system |
Publications (1)
Publication Number | Publication Date |
---|---|
CN105141665A true CN105141665A (en) | 2015-12-09 |
Family
ID=54726869
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201510453871.3A Pending CN105141665A (en) | 2015-07-29 | 2015-07-29 | Method and device for realizing data mirroring and server cluster system |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN105141665A (en) |
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN106452864A (en) * | 2016-09-30 | 2017-02-22 | 北京悦畅科技有限公司 | Parking lot fault protection method, apparatus and system thereof |
CN109995522A (en) * | 2019-03-08 | 2019-07-09 | 东南大学 | A secure data mirroring method with key agreement function |
CN114205219A (en) * | 2021-10-26 | 2022-03-18 | 深圳市潮流网络技术有限公司 | SRTP protocol-based disaster tolerance processing method for encrypted stream and related equipment |
Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103200036A (en) * | 2013-04-08 | 2013-07-10 | 国电南瑞科技股份有限公司 | Automated configuration method of electrical power system cloud computing platform |
CN103475734A (en) * | 2013-09-25 | 2013-12-25 | 浪潮电子信息产业股份有限公司 | Linux cluster user backup migration method |
-
2015
- 2015-07-29 CN CN201510453871.3A patent/CN105141665A/en active Pending
Patent Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103200036A (en) * | 2013-04-08 | 2013-07-10 | 国电南瑞科技股份有限公司 | Automated configuration method of electrical power system cloud computing platform |
CN103475734A (en) * | 2013-09-25 | 2013-12-25 | 浪潮电子信息产业股份有限公司 | Linux cluster user backup migration method |
Non-Patent Citations (3)
Title |
---|
LUROU: ""SUSE Linux HA双机搭建"", 《红黑联盟》 * |
有心故我在: ""Linux下通过脚本实现远程自动备份"", 《博客园》 * |
运维成就梦想: ""Linux系统Hostname命令详解"", 《博客园》 * |
Cited By (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN106452864A (en) * | 2016-09-30 | 2017-02-22 | 北京悦畅科技有限公司 | Parking lot fault protection method, apparatus and system thereof |
CN109995522A (en) * | 2019-03-08 | 2019-07-09 | 东南大学 | A secure data mirroring method with key agreement function |
CN109995522B (en) * | 2019-03-08 | 2022-01-04 | 东南大学 | Secure data mirroring method with key agreement function |
CN114205219A (en) * | 2021-10-26 | 2022-03-18 | 深圳市潮流网络技术有限公司 | SRTP protocol-based disaster tolerance processing method for encrypted stream and related equipment |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US11907254B2 (en) | Provisioning and managing replicated data instances | |
US10338946B1 (en) | Composable machine image | |
US10944740B2 (en) | Cluster claim | |
CN107408064B (en) | Method for executing commands in virtual machine instances and system for implementing the method | |
US10922303B1 (en) | Early detection of corrupt data partition exports | |
CN102170440B (en) | Method suitable for safely migrating data between storage clouds | |
US11144405B2 (en) | Optimizing database migration in high availability and disaster recovery computing environments | |
CN106339278A (en) | Data backup and recovery method of network file system | |
US10860226B2 (en) | Systems and methods of synchronizing configuration information in a clustered storage environment | |
US20240248810A1 (en) | Systems and methods for cross-regional back up of distributed databases on a cloud service | |
CN108337106A (en) | Construction method, platform and the computer equipment of Internet of Things micro services system architecture | |
CN109995522A (en) | A secure data mirroring method with key agreement function | |
CN107659542A (en) | A kind of method for authenticating and server | |
CN105760271A (en) | Method for monitoring credible state of computing node in cluster mode | |
US20230305886A1 (en) | Automatic update management in a computing infrastructure | |
CN109672752A (en) | The synchronous method of data and node | |
CN108846053A (en) | Data copy management method, device, equipment, system and readable storage medium storing program for executing | |
CN105389231A (en) | Database dual-computer backup method and system | |
CN105141665A (en) | Method and device for realizing data mirroring and server cluster system | |
US20130191828A1 (en) | Domain controller safety-features and cloning | |
WO2023005804A1 (en) | Data rotation method and apparatus, device, and system | |
CN114065183A (en) | Authority control method and device, electronic equipment and storage medium | |
CN102520880B (en) | System raid management module design method | |
EP3349416B1 (en) | Relationship chain processing method and system, and storage medium | |
CN106649744B (en) | Log recording method and device |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
WD01 | Invention patent application deemed withdrawn after publication |
Application publication date: 20151209 |
|
WD01 | Invention patent application deemed withdrawn after publication |