CN108920489A - Dispositions method, device and the equipment of database - Google Patents

Dispositions method, device and the equipment of database Download PDF

Info

Publication number
CN108920489A
CN108920489A CN201810455988.9A CN201810455988A CN108920489A CN 108920489 A CN108920489 A CN 108920489A CN 201810455988 A CN201810455988 A CN 201810455988A CN 108920489 A CN108920489 A CN 108920489A
Authority
CN
China
Prior art keywords
mongodb
node
computer room
database
copy set
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
CN201810455988.9A
Other languages
Chinese (zh)
Other versions
CN108920489B (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 Chen Sen Century Polytron Technologies Inc
Original Assignee
Beijing Chen Sen Century Polytron Technologies Inc
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 Chen Sen Century Polytron Technologies Inc filed Critical Beijing Chen Sen Century Polytron Technologies Inc
Priority to CN201810455988.9A priority Critical patent/CN108920489B/en
Publication of CN108920489A publication Critical patent/CN108920489A/en
Application granted granted Critical
Publication of CN108920489B publication Critical patent/CN108920489B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Abstract

This application discloses a kind of dispositions method of database, device and equipment, are related to database technical field, create each computer room MongoDB server interconnecting channels using OpenVPN tool, can save the cost for disposing each computer room MongoDB database.Wherein method includes:Obtain the server info for needing to dispose each computer room of MongoDB database;According to the server info, OpenVPN communication connection is built between each computer room;MongoDB database is disposed respectively in each computer room;It is communicated to connect using the OpenVPN, the MongoDB database of each computer room deployment is initialized to obtain MongoDB copy set, wherein, the mutual data of the MongoDB database for each computer room MongoDB node for including in the MongoDB copy set are synchronous.The application is suitable for the deployment of database.

Description

Dispositions method, device and the equipment of database
Technical field
This application involves database technical fields, particularly with regard to the dispositions method, device and equipment of a kind of database.
Background technique
In order to keep development rapid and flexible, many companies use MongoDB database, and by some important data It is stored in MongoDB database.Wherein MongoDB is the database based on distributed document storage, is compiled by C Plus Plus It writes, it is intended to provide expansible high-performance data storage solution for WWW (World Wide Web, WEB) application.
Currently, accessing the speed of MongoDB database in order to improve different geographical user, reducing delay and guarantee that data are pacified Quan Xing, traditional mode are and to rent Virtual Private Network (Virtual Private in each areal setting computer room Network, VPN) special line gets through each computer room inter-connection links, and MongoDB database then is disposed in each computer room and utilizes VPN special line So that each MongoDB database in phase.User can access the MongoDB database data of nearest computer room in this way.
However, expensive due to VPN special line, above-mentioned rental VPN special line carries out disposing each computer room MongoDB database Mode may require that larger cost, and if the computer room used is more and more with business development, renting VPN special line will It is a bigger expenditure.
Summary of the invention
In view of this, main purpose is to solve this application provides a kind of dispositions method of database, device and equipment Expensive VPN special line is rented at present dispose the problem of mode of each computer room MongoDB database may require that larger cost.
According to the one aspect of the application, a kind of dispositions method of database is provided, this method includes:
Obtain the server info for needing to dispose each computer room of MongoDB database;
According to the server info, OpenVPN communication connection is built between each computer room;
MongoDB database is disposed respectively in each computer room;
It is communicated to connect using the OpenVPN, the MongoDB database of each computer room deployment is initialized to obtain MongoDB copy set, wherein the MongoDB number for each computer room MongoDB node for including in the MongoDB copy set It is synchronous according to the mutual data in library.
Preferably, according to the server info, OpenVPN communication connection is built between each computer room, it is specific to wrap It includes:
According to the server info, the destination server in each computer room is determined respectively;
Build OpenVPN server-side and/or OpenVPN client respectively in the destination server of each computer room, and So that across that can be communicated with each other between the computer room OpenVPN server-side built and OpenVPN client.
Preferably, according to the server info, the destination server in each computer room is determined respectively, is specifically included:
The load state information of each server in machine room is obtained from the server info;
Referring to the load state information, determine that load pressure in each computer room meets the service of preset range respectively Device, so as to the destination server respectively as place computer room.
Preferably, it is communicated to connect using the OpenVPN, the MongoDB database of each computer room deployment is carried out just After beginningization obtains MongoDB copy set, the method also includes:
Corresponding node priority is respectively configured for each MongoDB node in the MongoDB copy set, wherein The node priority highest of the MongoDB copy set host node belongs to the backup node of same computer room with the host node Node priority is greater than the node priority of other computer room backup nodes;
When the host node of the MongoDB copy set breaks down, by the non-faulting node of the MongoDB copy set Described in the highest MongoDB node of node priority, be determined as the new host node of the MongoDB copy set.
Preferably, when the host node of the MongoDB copy set breaks down, the method also includes:
Whether the host node that timing detection is broken down restores normal;
If the host node of the failure restores normal, the host node of the failure is downgraded to backup node And synchronize the MongoDB database data of other MongoDB nodes;
After the host node of the failure synchronous MongoDB database data, asked by re-initiating election It asks and the new host node of the MongoDB copy set is downgraded to backup node, and restore the host node of the failure as institute State the host node of MongoDB copy set.
Preferably, the highest MongoDB of node priority described in the non-faulting node of the MongoDB copy set is saved Point is determined as the new host node of the MongoDB copy set, specifically includes:
Detecting the number of remaining non-faulting node in the MongoDB copy set, whether to meet default MongoDB most Number principle;
If the number meets the most of principles of default MongoDB, by the non-faulting of the MongoDB copy set The highest MongoDB node of node priority described in node is determined as the new host node of the MongoDB copy set;
If the number is unsatisfactory for the most of principles of default MongoDB, it is determined that MongoDB copy set is in failure State, and maintenance warning information is sent to maintenance module.
Preferably, the method also includes:
In the MongoDB database in phase of across computer room carry out MongoDB node, by closing Journal log And use In-Memory storage engines, realize MongoDB database data across the direct simultaneously operating of computer room;
When same computer room carries out the MongoDB database in phase of MongoDB node, by opening Journal log And WiredTiger storage engines are used, realize the MongoDB database data that update is first saved in Journal log, then The same computer room simultaneously operating of the MongoDB database data of the update is read from the Journal log.
According to the another aspect of the application, a kind of deployment device of database is provided, which includes:
Acquiring unit needs to dispose the server info of each computer room of MongoDB database for obtaining;
Unit is built, the server info for obtaining according to the acquiring unit is built between each computer room OpenVPN communication connection;
Deployment unit, for disposing MongoDB database respectively in each computer room;
Initialization unit, the OpenVPN communication connection built for building unit described in utilizing, to described in each computer room The MongoDB database of deployment unit deployment is initialized to obtain MongoDB copy set, wherein the MongoDB copy set In include each computer room MongoDB node the mutual data of MongoDB database it is synchronous.
Preferably, unit is built, is specifically used for determining the target in each computer room respectively according to the server info Server;
Build OpenVPN server-side and/or OpenVPN client respectively in the destination server of each computer room, and So that across that can be communicated with each other between the computer room OpenVPN server-side built and OpenVPN client.
Preferably, unit is built, is specifically also used to obtain the negative of each server in machine room from the server info Carry status information;
Referring to the load state information, determine that load pressure in each computer room meets the service of preset range respectively Device, so as to the destination server respectively as place computer room.
Preferably, described device further includes:
Configuration unit is also used to that corresponding section is respectively configured for MongoDB node each in the MongoDB copy set Point priority, wherein the node priority highest of the MongoDB copy set host node belongs to same machine with the host node The node priority of the backup node in room is greater than the node priority of other computer room backup nodes;
Determination unit, for when the MongoDB copy set host node failure when, by the MongoDB copy The highest MongoDB node of node priority described in the non-faulting node of collection is determined as the new master of the MongoDB copy set Node.
Preferably, described device further includes:
Unit is retried, for when the failure of the host node of the MongoDB copy set, timing detection to be broken down Whether host node restores normal;
If the host node of the failure restores normal, the host node of the failure is downgraded to backup node And synchronize the MongoDB database data of other MongoDB nodes;
After the host node of the failure synchronous MongoDB database data, asked by re-initiating election It asks and the new host node of the MongoDB copy set is downgraded to backup node, and restore the host node of the failure as institute State the host node of MongoDB copy set.
Preferably, the determination unit, specifically for detecting remaining non-faulting node in the MongoDB copy set Whether number meets the most of principles of default MongoDB;
If the number meets the most of principles of default MongoDB, by the non-faulting of the MongoDB copy set The highest MongoDB node of node priority described in node is determined as the new host node of the MongoDB copy set;
If the number is unsatisfactory for the most of principles of default MongoDB, it is determined that MongoDB copy set is in failure State, and maintenance warning information is sent to maintenance module.
Preferably, described device further includes:
Data synchronisation unit, for leading in the MongoDB database in phase of across computer room carry out MongoDB node It crosses closing Journal log and uses In-Memory storage engines, realize the directly same across computer room of MongoDB database data Step operation;
When same computer room carries out the MongoDB database in phase of MongoDB node, by opening Journal log And WiredTiger storage engines are used, realize the MongoDB database data that update is first saved in Journal log, then The same computer room simultaneously operating of the MongoDB database data of the update is read from the Journal log.
According to the application another aspect, a kind of storage medium is provided, computer program, described program are stored thereon with The dispositions method of above-mentioned database is realized when being executed by processor.
According to the application another aspect, a kind of entity device of database deployment, including storage medium, processing are provided Device and storage on a storage medium and the computer program that can run on a processor, the reality when processor executes described program The dispositions method of existing above-mentioned database.
By above-mentioned technical proposal, a kind of dispositions method of database, device and equipment provided by the present application are rented with current It is compared with the mode that expensive VPN special line dispose each computer room MongoDB database, the application believes according to the server of each computer room Breath builds OpenVPN communication connection between each computer room, to be communicated to connect using the OpenVPN, to the deployment of each computer room MongoDB database is initialized to obtain MongoDB copy set, each computer room for wherein including in the MongoDB copy set The mutual data of the MongoDB database of MongoDB node are synchronous, and then use OpenVPN tool instead and create each computer room MongoDB clothes Business device interconnecting channels, without renting expensive VPN special line, so that it may realize each computer room MongoDB database in phase, thus with Family, which accesses nearest computer room, just can be obtained newest MongoDB database data, save the cost of MongoDB database deployment, And as the computer room used is more and more, carrying out disposing each computer room MongoDB database using the scheme of the application can be saved Save biggish expenditure.
Above description is only the general introduction of technical scheme, in order to better understand the technological means of the application, And it can be implemented in accordance with the contents of the specification, and in order to allow above and other objects, features and advantages of the application can It is clearer and more comprehensible, below the special specific embodiment for lifting the application.
Detailed description of the invention
The drawings described herein are used to provide a further understanding of the present application, constitutes part of this application, this Shen Illustrative embodiments and their description please are not constituted an undue limitation on the present application for explaining the application.In the accompanying drawings:
Fig. 1 shows a kind of flow diagram of the dispositions method of database provided by the embodiments of the present application;
Fig. 2 shows the example schematics that each computer room provided by the embodiments of the present application builds OpenVPN communication connection;
Fig. 3 shows the example schematic of configuration each node priority of MongoDB copy set provided by the embodiments of the present application;
Fig. 4 shows the example signal that new host node is re-elected when host node provided by the embodiments of the present application breaks down Figure;
New host node is re-elected when link breaks down where Fig. 5 shows host node provided by the embodiments of the present application Example schematic;
The example of processing strategie is shown when link breaks down where Fig. 6 shows non-master provided by the embodiments of the present application It is intended to;
Fig. 7 shows a kind of structural schematic diagram of the deployment device of database provided by the embodiments of the present application;
Fig. 8 shows the structural schematic diagram of the deployment device of another database provided by the embodiments of the present application.
Specific embodiment
The application is described in detail below with reference to attached drawing and in conjunction with the embodiments.It should be noted that not conflicting In the case of, the features in the embodiments and the embodiments of the present application can be combined with each other.
Currently in order to improving the speed of different geographical access MongoDB database, need to buy the progress of VPN special line The deployment of MongoDB database cross computer room, but VPN special line is expensive, it may be desirable to larger cost, in response to this problem, the application Embodiment provides a kind of dispositions method of database, creates each mutual connection of computer room MongoDB server using OpenVPN tool Road can save the cost for disposing each computer room MongoDB database, as shown in Figure 1, this method includes:
101, the server info for needing to dispose each computer room of MongoDB database is obtained.
Wherein, server info may include the model of server in machine room, quantity (available and non-available), hardware case, Load pressure etc..
It can be the processing unit or equipment of across computer room deployment MongoDB database for the executing subject of the present embodiment, Predefining which computer room needs to dispose MongoDB database, and the mutual data of these MongoDB databases are synchronous, then Corresponding database Disposition Instructions are inputted, so that the device or equipment execute process shown in step 101 to step 104.
102, according to the server info of each computer room, OpenVPN communication connection is built between each computer room.
Wherein, VPN literal translation be exactly virtual private channel, be available between enterprise or individual and company between safe number According to the tunnel of transmission;OpenVPN is the software of open source VPN under Linux, provides good performance and friendly user interface.
There can be multiple servers in each computer room, wherein selecting any platform or which platform server as across computer room The medium server of OpenVPN communication can be determined according to the server info of each server of computer room.For example, according to current Model, configuring condition of available server etc. select the relatively stronger server of processing capacity logical as across computer room OpenVPN The medium server of letter, to improve the quality of OpenVPN communication connection;Then it builds the medium server is above-mentioned OpenVPN similarly selects suitable medium server to build OpenVPN, finally uses in other computer rooms in this manner The OpenVPN built gets through each computer room interoperable links, and then realizes the OpenVPN communication connection between each computer room.
103, MongoDB database is disposed respectively in each computer room.
For the present embodiment, which server disposition can be selected according to practical business demand in each computer room MongoDB database.In the detailed process of deployment MongoDB database, MongoDB database first can be downloaded or copied Then installation file is installed on the server for needing to dispose MongoDB database, finally carry out MongoDB database Configuration, and then realize that each computer room disposes MongoDB database respectively.
104, it is communicated to connect using the OpenVPN built, the MongoDB database of each computer room deployment initialize To MongoDB copy set.
Wherein, the mutual data of MongoDB database for each computer room MongoDB node for including in MongoDB copy set are same Step.In the present embodiment, the MongoDB copy set initialized may be considered one group of MongoDB server, wherein having one A primary server (Primary, host node), for handling client request;There are also multiple backup servers (Secondary, it is standby Part node), for saving the data copy of primary server.If primary server collapses, backup server can automatically will wherein One backup server upgrades to new primary server.Choosing for primary server can processing capacity according to server and user Depending on the delay situation for accessing data, it is specifically referred to newness degree, the model, device configuration situation, load pressure of server The comprehensive judgements such as power situation, network speed.
For example, it is assumed that wherein computer room A possesses the server of 4 deployment MongoDB databases, computer room B there are four computer rooms Possess the server of 3 deployment MongoDB databases, computer room C and computer room D respectively possess 2 deployment MongoDB databases Server, and OpenVPN communication connection has been built respectively between this four computer rooms;Utilize the OpenVPN communication link built It connects, the MongoDB database of this four computer rooms deployment is initialized to obtain MongoDB copy set, the MongoDB copy set In include 11 (4+3+2+2) a nodes, 1 active node is only existed in this 11 nodes, for handling client request;These The MongoDB database data that node saves is identical, and when the MongoDB database data of host node updates, other several The MongoDB database data of node also synchronized update therewith;In this way when user needs to access MongoDB database data, The computer room that can be closer according to the nearest link position of IP address of the user, and then access and obtain MongoDB database Since communication distance is closer the delay of data access can be effectively reduced, and then improve the usage experience of user in data.
It should be noted that creating each computer room MongoDB server interconnecting channels using OpenVPN tool in addition to above-mentioned Other than mode, this process also is realized using other similar VPN tools, the present embodiment does not limit to this.By this reality The dispositions method for applying the above-mentioned database of example offer carries out disposing each computer room MongoDB data with current valuableness VPN special line of renting The mode in library is compared, and the present embodiment is without renting expensive VPN special line, so that it may realize that each computer room MongoDB database data is same Step saves the cost of MongoDB database deployment.And it does not need through the direct-connected each computer room MongoDB of public network IP address yet Node will not make MongoDB database data be exposed to public network, it is ensured that the safety of MongoDB database data.
Further, it as the refinement and extension of above-described embodiment specific embodiment, is built in order to illustrate in step 102 The specific implementation process of OpenVPN communication connection, step 102 can specifically include as a preferred method,:Portion as needed The server info for affixing one's name to each computer room of MongoDB database, determines the destination server in each computer room respectively;In the mesh of each computer room OpenVPN server-side and/or OpenVPN client are built respectively in mark server, and the OpenVPN built across computer room is taken It can be communicated with each other between business end and OpenVPN client.
Wherein, destination server may be considered the medium server of across computer room OpenVPN communication, in the destination server On build OpenVPN server-side and/or OpenVPN client.It, can be with according to the server info of computer room for the present embodiment Judge the operation conditions of server in machine room, and then OpenVPN can be carried out using the server of operational excellence as destination server Communication is built, and thereby may be ensured that the quality of OpenVPN communication connection, avoids the influence that Caton is run by server.
For example, as shown in Fig. 2, if there is 3 computer rooms, respectively IDC-A, IDC-B, IDC-C;According to each in IDC-A The operation conditions of platform server selects the server of a wherein operational excellence as destination server, and in the destination service It is built on device OpenVPN server-side (OpenVPN server), and opens the system data packet forwarding capability of OpenVPN;Equally Select the server of an operational excellence as the destination server of respective computer room respectively in IDC-B and IDC-C, and in mesh OpenVPN client (OpenVPN client) is built on mark server, enables the OpenVPN client and IDC-A of IDC-B OpenVPN server-side between realize connection, and the OpenVPN client of IDC-C also can be with the OpenVPN server-side of IDC-A Between realize connection;
OpenVPN communication connection and the IDC-A and IDC-C between IDC-A and IDC-B can be achieved by above-mentioned configuration Between OpenVPN communication connection;Then in order to realize that the OpenVPN between IDC-B and IDC-C is communicated to connect, Ke Yi OpenVPN server-side is built on the server of an operational excellence of IDC-C, and opens the system data packet turn of OpenVPN Function is sent out, OpenVPN client is built on the server of an operational excellence of IDC-B and (is taken before also can be used here The OpenVPN client built is added communication connection setting), the client of IDC-B and the OpenVPN of IDC-C are taken It is engaged in realizing connection between end;After these three computer rooms are built and finish OpenVPN server-side and/or OpenVPN client, this three A each OpenVPN node of computer room (server for building OpenVPN server-side and/or OpenVPN client) configuration routing, makes Net interconnecting in these three computer rooms is obtained, i.e., one of computer room OpenVPN node can be found by another computer room OpenVPN node Third computer room OpenVPN node, and OpenVPN communication is carried out therewith;It is all taken in these three computer rooms OpenVPN communication connection After building, when there is a computer room to break down, it can still be communicated with each other there are two computer room in three computer rooms.
It should be noted that the process of the destination server in above-mentioned each computer room of determination can also be according to practical business demand Selected, such as randomly choose or selected according to server newness degree etc., further, in order to guarantee that OpenVPN is communicated It not will receive the influence of server own load pressure factor, alternatively, the target in above-mentioned each computer room of determination The process of server can specifically include:The load state information of each server in machine room is obtained from each server in machine room information; Referring next to the load state information, determine that load pressure in each computer room meets the server of preset range, respectively so as to respectively Destination server as place computer room.
It wherein, include the load pressure situation of server in load state information;Preset range can be according to actual needs It is configured in advance, can be determined that whether the load pressure of server is relatively small by preset range.For example, if computer room A It needs to build OpenVPN client, according to the load pressure situation of each server of computer room A, load value is in load pressure water A server in lower range is put down as destination server, OpenVPN client is built on the destination server;If Computer room A also needs to build OpenVPN server-side, at this moment it is also an option that this destination server is built, or is loading OpenVPN clothes are built on another server (i.e. another destination server) that value is in the horizontal lower range of load pressure Business end.
By above-mentioned this preferred embodiment, can normally transport guaranteeing OpenVPN communication quality and do not influence server Under the premise of row, meet the requirement for building OpenVPN communication.
In the present embodiment, it can be realized and built using each computer room as overall architecture by process described above MongoDB copy set, when the node in the MongoDB copy set breaks down, in order to guarantee that MongoDB copy set continues to mention For High Availabitity service, as a preferred method, after step 104, can also include:It is each in MongoDB copy set Corresponding node priority is respectively configured in MongoDB node, wherein the node priority of MongoDB copy set host node Highest, the node for being greater than other computer room backup nodes with the node priority that host node belongs to the backup node of same computer room are preferential Grade;When the host node of MongoDB copy set breaks down, by the non-faulting node interior joint priority of MongoDB copy set Highest MongoDB node is determined as the new host node of MongoDB copy set.
It can be MongoDB copy according to the minimum principle in face is influenced when there is node failure for above-mentioned preferred embodiment Concentrate each MongoDB node that corresponding node priority is respectively configured.The node priority can be determined to be occurred in node When failure, by which node as new host node.It will receive the failure of other backup nodes to guarantee former host node not Influence, the node priority of former host node is configurable to highest;And the backup section for belonging to same computer room with host node Point, in order to enable being changed without the node of other computer rooms as new host node, to guarantee influence face when host node breaks down It is minimum, its node priority can be greater than to the node priority of other computer room backup nodes.
For example, most user belongs to Beijing user, therefore there are Beijing, Shanghai, three, Guangzhou computer room in order to reduce Data access delay, Beijing computer room is provided with host node, and its node priority is maximum;And the backup node of Beijing computer room Node priority is greater than the node priority of other computer room backup nodes;Mode with this configuration, if MongoDB copy set In a backup node break down, work on then the host node of Beijing computer room will not be affected;If main section Point breaks down, can be in north since the backup node of Beijing computer room is greater than the node priority of other computer room backup nodes Continue that the highest backup node of node priority is selected to work as new host node in the computer room of capital, in this way in big Most Beijing users can continue to access the MongoDB database data of Beijing computer room, and data access is delayed situation will not It is affected, the face of will affect is accomplished minimum.
It should be noted that above-mentioned foundation occurs influencing the minimum principle in face when node failure, the section of each node is configured Point priority mode it is not unique, can according to the actual situation depending on.For this preferred embodiment, may be implemented when MongoDB pair When the node of this concentration breaks down, guarantee that MongoDB copy set continues to provide High Availabitity service.
For example, as shown in figure 3, respectively IDC-A, IDC-B, IDC-C, each computer room are deposited respectively if there is 3 computer rooms In 2 nodes, and then the MongoDB copy set that this 3 computer rooms are built includes a host node (Primary), 4 backup nodes (Secondary) and 1 delay backup node (Delay Secondary);Wherein delay backup node may be configured as delay two Hour duplication is that host node goes over two hours " data snapshot ", commonly used to be used as data backup, if the wrong behaviour of host node Make and delete data, data can be restored by delay backup node;Then node priority is carried out to this 6 nodes to match It sets, priority limit 0-100, number is bigger, and node priority is higher, and the node that node priority is 0 will not be in election For host node;As shown in figure 3, the host node priority of IDC-A is 5, backup node priority is 3;A backup of IDC-B saves Point priority is 2, another backup node priority is 1;The backup node priority of IDC-C is 1, and delay backup node is preferential Grade is 0.
It is interconnected in a manner of encrypting in three computer rooms shown in Fig. 3 using OpenVPN, under normal condition, in IDC-A Host node the write operation of MongoDB database data is provided, 4 backup nodes of three computer rooms provide MongoDB database Data read operation;Other 5 node votes if the host node in IDC-A breaks down, in MongoDB copy set It lifts, since the backup node priority in IDC-A is higher, preferentially becomes new host node, it is specific as shown in Figure 4.
Further, it in order to illustrate the process for determining the new host node of MongoDB copy set in above-mentioned preferred embodiment, is protecting Under the premise of card MongoDB copy set can operate normally, it is capable of providing High Availabitity service, alternatively, the mistake Journey can specifically include:Whether the number of remaining non-faulting node it is big meet default MongoDB in detection MongoDB copy set Majority principle;If the number of remaining non-faulting node meets the default most of principles of MongoDB, by MongoDB copy set Non-faulting node interior joint highest priority MongoDB node, be determined as the new host node of MongoDB copy set;If surplus The number of remaining non-faulting node is unsatisfactory for the default most of principles of MongoDB, it is determined that MongoDB copy set is in failure shape State, and maintenance warning information is sent to maintenance module.
Wherein, maintenance module can carry out the functional module of Breakdown Maintenance for load to MongoDB copy set;Maintenance alarm Information can be text alert information, picture warning information, audible alarm information, visual alarm information, vibrating alert information, lamp Light warning information etc.;The default most of principles of MongoDB can be preset according to principles most of in MongoDB mechanism.Example Such as, it for there are the MongoDB copy sets of 5 nodes, breaks down if there is 3 nodes, then remaining 2 nodes are not Meet the default most of principles of MongoDB, can determine that the MongoDB copy set is in malfunction, is sent to maintenance module The text and audible alarm information of maintenance, and then the failure problems for handling MongoDB copy set in time can be helped;If there is 2 nodes break down, then remaining 3 nodes meet the default most of principles of MongoDB, by initiating poll Mode selects host node referring to node priority and backup node continues work.
When the host node of MongoDB copy set breaks down, maintenance module will do it timely maintenance or host node is logical It crosses itself adjustment and is restored to normal condition, in this scenario, in order to restore the operation shape of MongoDB copy set script in time State, as a preferred method, this method can also include:Whether the host node that timing detection is broken down restores normal;If The host node of failure restores normal, then the host node of failure is downgraded to backup node and synchronizes other MongoDB The MongoDB database data of node;After the host node of failure synchronous MongoDB database data, pass through weight It is new to initiate to elect request that the new host node of MongoDB copy set is downgraded to backup node, and restore the host node to break down For the host node of MongoDB copy set.
For example, based on the example in Fig. 3, if IDC-A breaks down, i.e., when there is link failure in IDC-A, IDC-B with 4 nodes in IDC-C meet the default most of principles of MongoDB, meeting vote by ballot again, and IDC-B interior joint priority is 2 Node can preferentially become new host node, it is specific as shown in Figure 5;Whether the former host node of extended meeting timing detection IDC-A is extensive afterwards It is multiple normal, if the former host node of IDC-A restores normal, first it is downgraded to backup node automatically and synchronizes other MongoDB nodes MongoDB database data, then after the former host node of IDC-A synchronous MongoDB database data, by again Initiating the former host node that host node new in IDC-B is downgraded to backup node, and restores IDC-A by election request is MongoDB The host node of copy set.
For another example based on the example in Fig. 3, if IDC-B breaks down, i.e., when there is link failure in IDC-B, IDC-A Meet the default most of principles of MongoDB with 4 nodes in IDC-C, so entire MongoDB copy set is still in normal work Make state, at this moment since the host node of IDC-A is not affected, so each node state is constant in IDC-A and IDC-C, tool Body is referring to shown in Fig. 6, and in the present embodiment, in the case where any one computer room breaks down, MongoDB copy set is still It is capable of providing service, and then can guarantee that entire MongoDB copy set provides High Availabitity service.
Further, MongoDB database is carried out using database portion arranging method provided in this embodiment to dispose to obtain After MongoDB copy set, in order to improve the synchronous efficiency of across computer room data, this method can be with as a preferred method, Including:In the MongoDB database in phase of across computer room carry out MongoDB node, by closing Journal log and making With In-Memory storage engines, realize MongoDB database data across the direct simultaneously operating of computer room;It is carried out in same computer room When the MongoDB database in phase of MongoDB node, by opening Journal log and being stored using WiredTiger Engine is realized and first saves the MongoDB database data of update in Journal log, then reads more from Journal log The same computer room simultaneously operating of new MongoDB database data.
Usually between each node of MongoDB copy set in data synchronization process, can first it be written more in Journal log New data, then to carry out data synchronous for reading update data from the Journal log again, the purpose for the arrangement is that in order to It, still can be in the case where restoring electric power, from Journal log if situations such as encountering power-off in data synchronization process Reading update data carries out data synchronization, can prevent loss of data in this way, but when the synchronization of across computer room data, such as Fruit also uses the mode of Journal log buffer, will affect the synchronous efficiency of data, therefore can be by closing Journal days Will simultaneously uses In-Memory storage engines, realize MongoDB database data across the direct simultaneously operating of computer room, and then improve The synchronous efficiency of across the computer room data of MongoDB database data.And the MongoDB number of MongoDB node is carried out in same computer room When synchronous according to library data, by opening Journal log and using WiredTiger storage engines, the anti-number before still continuing to use According to the mechanism of loss, the MongoDB database data of update is first saved in Journal log, then is read from Journal log Take the same computer room simultaneously operating of the MongoDB database data of update.
It may be implemented to improve the synchronous efficiency of data when across the computer room data of MongoDB copy set are synchronous through the above way; And it can guarantee that data are not lost when same computer room data are synchronous.
Further, the specific implementation as Fig. 1 method, the embodiment of the present application provide a kind of deployment dress of database It sets, as shown in fig. 7, the device includes:Acquiring unit 21 builds unit 22, deployment unit 23, initialization unit 24.
Acquiring unit 21 can be used for obtaining the server info for each computer room for needing to dispose MongoDB database;It obtains Unit 21 is the main functional modules that server in machine room information is obtained in the present apparatus, after acquiring server info, touching Hair builds unit 22 and works.
Unit 22 is built, can be used for the server info obtained according to acquiring unit 21, built between each computer room OpenVPN communication connection;Building unit 22 is that the major function mould that OpenVPN is communicated to connect between each computer room is built in the present apparatus Block.
Deployment unit 23 can be used for disposing MongoDB database respectively in each computer room;Deployment unit 23 is in the present apparatus In the main functional modules of server in machine room deployment MongoDB database.
Initialization unit 24 can be used for the OpenVPN communication connection built using unit 23 is built, dispose to each computer room The MongoDB database that unit 23 is disposed is initialized to obtain MongoDB copy set, wherein includes in MongoDB copy set Each computer room MongoDB node the mutual data of MongoDB database it is synchronous.
In specific application scenarios, unit 22 is built, specifically can be used for determining each machine respectively according to server info Destination server in room;Build OpenVPN server-side and/or OpenVPN client respectively in the destination server of each computer room End, and to communicate with each other between the OpenVPN server-side built across computer room and OpenVPN client.For this implementation Example, according to the server info of computer room, it can be determined that the operation conditions of server in machine room, and then can be by the service of operational excellence Device carries out building for OpenVPN communication as destination server, thereby may be ensured that the quality of OpenVPN communication connection, avoids It is influenced by server operation Caton.
In specific application scenarios, unit 22 is built, specifically can be also used for obtaining each computer room from server info The load state information of server;Referring to load state information, determine that load pressure meets preset range in each computer room respectively Server, so as to the destination server respectively as place computer room.And then it can guarantee OpenVPN communication quality and not shadow Under the premise of ringing server normal operation, meet the requirement for building OpenVPN communication.
In specific application scenarios, when the node in the MongoDB copy set breaks down, in order to guarantee MongoDB copy set continues to provide High Availabitity service, as shown in figure 8, the present apparatus may also include:Configuration unit 25, determination unit 26;
Configuration unit 25 can be also used for being respectively configured for MongoDB node each in MongoDB copy set corresponding Node priority, wherein the node priority highest of MongoDB copy set host node belongs to the standby of same computer room with host node The node priority of part node is greater than the node priority of other computer room backup nodes;
Determination unit 26 can be used for when the host node of MongoDB copy set breaks down, by MongoDB copy set Non-faulting node interior joint highest priority MongoDB node, be determined as the new host node of MongoDB copy set.
In specific application scenarios, when MongoDB copy set host node break down when, maintenance module will do it and When safeguard or host node by itself adjustment and be restored to normal condition, in this scenario, in order to restore MongoDB in time The operating status of copy set script, as shown in figure 8, the present apparatus further includes:Retry unit 27;
Unit 27 is retried, can be used for when the host node of MongoDB copy set breaks down, timing detection is broken down Host node whether restore normal;If the host node to break down restores normal, the host node of failure is downgraded to standby Part node and the MongoDB database data for synchronizing other MongoDB nodes;In the synchronous MongoDB of the host node of failure After database data, the new host node of MongoDB copy set is downgraded to backup node by re-electing mode, and extensive The host node to break down again is the host node of MongoDB copy set.
In specific application scenarios, under the premise of guaranteeing that MongoDB copy set can operate normally, it is capable of providing height Available service, as shown in figure 8, determination unit 26, specifically can be used for detecting remaining non-faulting node in MongoDB copy set Number whether meet the most of principles of default MongoDB;It, will if number meets the default most of principles of MongoDB The MongoDB node of the non-faulting node interior joint highest priority of MongoDB copy set, it is new to be determined as MongoDB copy set Host node;If number is unsatisfactory for the default most of principles of MongoDB, it is determined that MongoDB copy set is in malfunction, and It sends a warning message to maintenance module.
In specific application scenarios, as shown in figure 8, the present apparatus further includes:Data synchronisation unit 28;
Data synchronisation unit 28 can be used for the MongoDB database in phase in across computer room carry out MongoDB node When, by closing Journal log and using In-Memory storage engines, realize the straight across computer room of MongoDB database data Connect simultaneously operating;When same computer room carries out the MongoDB database in phase of MongoDB node, by opening Journal days Will simultaneously uses WiredTiger storage engines, realizes the MongoDB database data that update is first saved in Journal log, The same computer room simultaneously operating of the MongoDB database data of update is read from Journal log again.Pass through data synchronisation unit 28 may be implemented to improve the synchronous efficiency of data when across the computer room data of MongoDB copy set are synchronous;And it is same in same computer room data It can guarantee that data are not lost when step.
It should be noted that each functional unit involved by a kind of deployment device of database provided by the embodiments of the present application Other corresponding descriptions, can be with reference to the corresponding description in Fig. 1, and details are not described herein.
Based on above-mentioned method as shown in Figure 1, correspondingly, being deposited thereon the embodiment of the present application also provides a kind of storage medium Computer program is contained, which realizes the dispositions method of above-mentioned database as shown in Figure 1 when being executed by processor.
Based on this understanding, the technical solution of the application can be embodied in the form of software products, which produces Product can store in a non-volatile memory medium (can be CD-ROM, USB flash disk, mobile hard disk etc.), including some instructions With so that computer equipment (can be personal computer, server or the network equipment an etc.) execution the application is each Method described in implement scene.
It is above-mentioned in order to realize based on above-mentioned method and Fig. 7 as shown in Figure 1, virtual bench embodiment shown in Fig. 8 Purpose, the embodiment of the present application also provides a kind of entity devices of database deployment, are specifically as follows computer, server, or Person's network equipment etc., the entity device include storage medium and processor;Storage medium, for storing computer program;Processing Device realizes the dispositions method of above-mentioned database as shown in Figure 1 for executing computer program.
Optionally, which can also include user interface, network interface, camera, radio frequency (Radio Frequency, RF) circuit, sensor, voicefrequency circuit, WI-FI module etc..User interface may include display screen (Display), input unit such as keyboard (Keyboard) etc., optional user interface can also connect including USB interface, card reader Mouthful etc..Network interface optionally may include standard wireline interface and wireless interface (such as WI-FI interface).
It will be understood by those skilled in the art that a kind of entity device structure of database deployment provided in this embodiment is not The restriction to the entity device is constituted, may include more or fewer components, perhaps combines certain components or different portions Part arrangement.
It can also include operating system, network communication module in storage medium.Operating system is the above-mentioned database portion of management The program of the entity device hardware and software resource of administration supports the operation of message handling program and other softwares and/or program. Network communication module for realizing the communication between each component in storage medium inside, and with it is other in information processing entities equipment It is communicated between hardware and software.
Through the above description of the embodiments, those skilled in the art can be understood that the application can borrow It helps software that the mode of necessary general hardware platform is added to realize, hardware realization can also be passed through.Pass through the skill of application the application Art scheme, without renting expensive VPN special line, so that it may realize each computer room MongoDB database in phase, save The cost of MongoDB database deployment.And it does not need through the direct-connected each computer room MongoDB node of public network IP address yet, it will not So that MongoDB database data is exposed to public network, it is ensured that the safety of MongoDB database data.
It will be appreciated by those skilled in the art that the accompanying drawings are only schematic diagrams of a preferred implementation scenario, module in attached drawing or Process is not necessarily implemented necessary to the application.It will be appreciated by those skilled in the art that the mould in device in implement scene Block can according to implement scene describe be distributed in the device of implement scene, can also carry out corresponding change be located at be different from In one or more devices of this implement scene.The module of above-mentioned implement scene can be merged into a module, can also be into one Step splits into multiple submodule.
Above-mentioned the application serial number is for illustration only, does not represent the superiority and inferiority of implement scene.Disclosed above is only the application Several specific implementation scenes, still, the application is not limited to this, and the changes that any person skilled in the art can think of is all The protection scope of the application should be fallen into.

Claims (10)

1. a kind of dispositions method of database, which is characterized in that including:
Obtain the server info for needing to dispose each computer room of MongoDB database;
According to the server info, OpenVPN communication connection is built between each computer room;
MongoDB database is disposed respectively in each computer room;
It is communicated to connect using the OpenVPN, the MongoDB database of each computer room deployment is initialized to obtain MongoDB copy set, wherein the MongoDB number for each computer room MongoDB node for including in the MongoDB copy set It is synchronous according to the mutual data in library.
2. the method according to claim 1, wherein according to the server info, between each computer room OpenVPN communication connection is built, is specifically included:
According to the server info, the destination server in each computer room is determined respectively;
It builds OpenVPN server-side and/or OpenVPN client respectively in the destination server of each computer room, and makes Across can be communicated with each other between the computer room OpenVPN server-side built and OpenVPN client.
3. according to the method described in claim 2, it is characterized in that, determining each machine respectively according to the server info Destination server in room, specifically includes:
The load state information of each server in machine room is obtained from the server info;
Referring to the load state information, determine that load pressure in each computer room meets the server of preset range respectively, with Just respectively as the destination server of place computer room.
4. the method according to claim 1, wherein being communicated to connect using the OpenVPN, to each computer room The MongoDB database of deployment is initialized after obtaining MongoDB copy set, the method also includes:
Corresponding node priority is respectively configured for each MongoDB node in the MongoDB copy set, wherein described The node priority highest of MongoDB copy set host node, the node of the backup node of same computer room is belonged to the host node Priority is greater than the node priority of other computer room backup nodes;
When the host node of the MongoDB copy set breaks down, by institute in the non-faulting node of the MongoDB copy set The highest MongoDB node of node priority is stated, the new host node of the MongoDB copy set is determined as.
5. according to the method described in claim 4, it is characterized in that, the host node when the MongoDB copy set breaks down When, the method also includes:
Whether the host node that timing detection is broken down restores normal;
If the host node of the failure restores normal, the host node of the failure is downgraded to backup node and same Walk the MongoDB database data of other MongoDB nodes;
It, will by re-initiating election request after the host node of the failure synchronous MongoDB database data The host node that the new host node of the MongoDB copy set is downgraded to backup node, and restores the failure is described The host node of MongoDB copy set.
6. according to the method described in claim 4, it is characterized in that, by institute in the non-faulting node of the MongoDB copy set The highest MongoDB node of node priority is stated, is determined as the new host node of the MongoDB copy set, specifically includes:
Whether the number for detecting remaining non-faulting node in the MongoDB copy set meets the most of originals of default MongoDB Then;
If the number meets the most of principles of default MongoDB, by the non-faulting node of the MongoDB copy set Described in the highest MongoDB node of node priority, be determined as the new host node of the MongoDB copy set;
If the number is unsatisfactory for the most of principles of default MongoDB, it is determined that MongoDB copy set is in failure shape State, and maintenance warning information is sent to maintenance module.
7. method according to any one of claim 1 to 6, which is characterized in that the method also includes:
In the MongoDB database in phase of across computer room carry out MongoDB node, by closing Journal log and making With In-Memory storage engines, realize MongoDB database data across the direct simultaneously operating of computer room;
When same computer room carries out the MongoDB database in phase of MongoDB node, by opening Journal log and making With WiredTiger storage engines, the MongoDB database data that update is first saved in Journal log is realized, then from institute State the same computer room simultaneously operating for the MongoDB database data that the update is read in Journal log.
8. a kind of deployment device of database, which is characterized in that including:
Acquiring unit needs to dispose the server info of each computer room of MongoDB database for obtaining;
Unit is built, the server info for obtaining according to the acquiring unit builds OpenVPN between each computer room Communication connection;
Deployment unit, for disposing MongoDB database respectively in each computer room;
Initialization unit, the OpenVPN communication connection built for building unit described in utilizing, is disposed to described in each computer room The MongoDB database of unit deployment is initialized to obtain MongoDB copy set, wherein is wrapped in the MongoDB copy set The mutual data of the MongoDB database of each computer room MongoDB node contained are synchronous.
9. a kind of storage medium, is stored thereon with computer program, which is characterized in that realization when described program is executed by processor The dispositions method of database described in any one of claims 1 to 7.
10. a kind of deployment facility of database, including storage medium, processor and storage are on a storage medium and can be in processor The computer program of upper operation, which is characterized in that the processor is realized any in claim 1 to 7 when executing described program The dispositions method of database described in.
CN201810455988.9A 2018-05-14 2018-05-14 Method, device and equipment for deploying database Active CN108920489B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810455988.9A CN108920489B (en) 2018-05-14 2018-05-14 Method, device and equipment for deploying database

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810455988.9A CN108920489B (en) 2018-05-14 2018-05-14 Method, device and equipment for deploying database

Publications (2)

Publication Number Publication Date
CN108920489A true CN108920489A (en) 2018-11-30
CN108920489B CN108920489B (en) 2021-03-16

Family

ID=64403375

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810455988.9A Active CN108920489B (en) 2018-05-14 2018-05-14 Method, device and equipment for deploying database

Country Status (1)

Country Link
CN (1) CN108920489B (en)

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109871374A (en) * 2019-03-20 2019-06-11 浪潮商用机器有限公司 A kind of database automatic deployment device and method
CN110704382A (en) * 2019-09-25 2020-01-17 深圳市网心科技有限公司 File deployment method, device, server and storage medium
CN111083204A (en) * 2019-11-29 2020-04-28 广州市百果园信息技术有限公司 File transmission method, device and storage medium
CN111614733A (en) * 2020-04-29 2020-09-01 厦门市美亚柏科信息股份有限公司 Deployment method, device and storage medium of distributed multi-fragmentation cluster
CN112667698A (en) * 2021-01-04 2021-04-16 山西云媒体发展有限公司 MongoDB data synchronization method based on converged media platform
CN113485869A (en) * 2021-06-08 2021-10-08 上海众言网络科技有限公司 Database upgrading method and device

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103634320A (en) * 2013-12-05 2014-03-12 青岛海尔软件有限公司 Novel remote access system
CN105630630A (en) * 2015-12-23 2016-06-01 北京奇虎科技有限公司 Data hot backup method and system
CN106789845A (en) * 2015-11-23 2017-05-31 天津九洲云物联科技有限公司 A kind of method of network data security transmission

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103634320A (en) * 2013-12-05 2014-03-12 青岛海尔软件有限公司 Novel remote access system
CN106789845A (en) * 2015-11-23 2017-05-31 天津九洲云物联科技有限公司 A kind of method of network data security transmission
CN105630630A (en) * 2015-12-23 2016-06-01 北京奇虎科技有限公司 Data hot backup method and system

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
ADS2ALPHA: "如何在Ubuntu16.04上使用OpenVPN和Docker运行安全的MongoDB服务器", 《HTTPS://WWW.DIGITALOCEAN.COM/COMMUNITY/TUTORIALS/HOW-TO-RUN-A-SECURE-MONGODB-SERVER-WITH-OPENVPN-AND-DOCKER-ON-UBUNTU-16-04》 *
张友东(/USERS/YSXIUY5NUC24C): "MongoDB复制集原理", 《HTTPS://YQ.ALIYUN.COM/ARTICLES/64》 *

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109871374A (en) * 2019-03-20 2019-06-11 浪潮商用机器有限公司 A kind of database automatic deployment device and method
CN110704382A (en) * 2019-09-25 2020-01-17 深圳市网心科技有限公司 File deployment method, device, server and storage medium
CN111083204A (en) * 2019-11-29 2020-04-28 广州市百果园信息技术有限公司 File transmission method, device and storage medium
CN111614733A (en) * 2020-04-29 2020-09-01 厦门市美亚柏科信息股份有限公司 Deployment method, device and storage medium of distributed multi-fragmentation cluster
CN111614733B (en) * 2020-04-29 2022-08-02 厦门市美亚柏科信息股份有限公司 Deployment method, device and storage medium of distributed multi-fragmentation cluster
CN112667698A (en) * 2021-01-04 2021-04-16 山西云媒体发展有限公司 MongoDB data synchronization method based on converged media platform
CN113485869A (en) * 2021-06-08 2021-10-08 上海众言网络科技有限公司 Database upgrading method and device

Also Published As

Publication number Publication date
CN108920489B (en) 2021-03-16

Similar Documents

Publication Publication Date Title
CN108920489A (en) Dispositions method, device and the equipment of database
CN107526626B (en) Docker container thermal migration method and system based on CRIU
US10735509B2 (en) Systems and methods for synchronizing microservice data stores
US11848817B2 (en) Techniques for updating edge devices
CN105187464B (en) Method of data synchronization, apparatus and system in a kind of distributed memory system
CN102214128B (en) Repurposable recovery environment
CN103946844A (en) Synchronizing updates across cluster filesystems
CN111211930A (en) Block chain service disaster-tolerant backup containerized deployment method
CN106407214A (en) Distributed storage method and system
CN114079615B (en) Application synchronization method, system, medium and electronic equipment in multi-cluster environment
CN111104069A (en) Multi-region data processing method and device of distributed storage system and electronic equipment
CN110348826A (en) Strange land disaster recovery method, system, equipment and readable storage medium storing program for executing mostly living
CN106612314A (en) System for realizing software-defined storage based on virtual machine
CN113778615B (en) Rapid and stable network shooting range virtual machine construction system
CN111147312B (en) Resource allocation management method and device, resource allocation cache management method and device, and allocation management system
US20240039825A1 (en) Network switching method and apparatus, electronic device, and storage medium
CN113407382B (en) Dynamic regulation and control method and system for service fault
CN115129676A (en) Data synchronization method, device, equipment and medium
CN114880717A (en) Data archiving method and device
EP3884648B1 (en) Geo-replicated iot hub
CN114281600A (en) Disaster recovery backup and recovery method, device, equipment and storage medium
CN114020279A (en) Application software distributed deployment method, system, terminal and storage medium
CN107590032A (en) The method and storage cluster system of storage cluster failure transfer
CN113050983A (en) Method and system for designing middleware, electronic device and readable storage medium
CN104270449A (en) Method and device for achieving time synchronizing among server nodes

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