Summary of the invention
Technical problem to be solved by this invention is: to the automatic acquisition problems of mass data in the Internet of Things; A kind of monitoring and management method of Internet of Things data acquisition server cluster are provided; Monitor in real time and manage so that data are gathered the central server cluster, thereby realize that the data acquisition task is distributed automatically, the cluster load balancing is distributed, the inefficacy task is taken over.
The present invention addresses the above problem the technical scheme that is adopted: a kind of monitoring and management method of Internet of Things data acquisition server cluster may further comprise the steps:
(1), in advance the ID of all Internet of Things acquisition terminals that are connected with acquisition server is stored in the relational database;
(2), utilize distributed collaboration service Zookeeper to set up tree-like storage organization; This tree-like storage organization is set up acquisition server, management server, acquisition tasks tabulation and configuration file four node under root node, be respectively applied for and deposit relevant acquisition server information, management server information, acquisition tasks list information and system configuration information;
(3), start the Zookeeper cooperation with service;
(4), start management server and the be connected task of acquisition server in the cluster, and foundation and be connected the interim node of corresponding son in Zookeeper with the Zookeeper cooperation with service;
(5), the acquisition terminal ID that prestores in the main management server reading database also gives every acquisition server that the service of collection can be provided with acquisition terminal ID mean allocation;
(6), the main management server is monitored the connection from acquisition terminal; When acquisition terminal was connected to the main management server through network, the main management server returned IP and the port of the acquisition server that this acquisition terminal belongs to and is transmitted to acquisition terminal by routing device;
(7), acquisition terminal is connected communication with the acquisition server of main management server appointment;
(8), every acquisition server all regularly writes corresponding nodes among the Zookeeper with the state information of this machine;
(9), the main management server is monitored acquisition server through Zookeeper; When finding the acquisition server overload is arranged; The main management server is in time adjusted the operating load of every acquisition server according to the load state of other acquisition servers in the current cluster; When finding to have acquisition server that service can't be provided, the main management server judges whether subsequent use acquisition server is arranged in the current cluster, if subsequent use acquisition server is arranged, launches subsequent use acquisition server; If there is not subsequent use acquisition server, the acquisition terminal task mean allocation that the main management server is responsible for this acquisition server can provide the acquisition server of the service of collection for interior other of cluster;
(10), after step (9) acquisition terminal task is redistributed; Acquisition terminal possibly failed with being connected of former acquisition server; If acquisition terminal and former acquisition server are attempted connection failure; Acquisition terminal can connect to the main management server requests once more, and the main management server returns the IP and the port of new acquisition server.
Further comprising the steps of:
(11), through Zookeeper the main management server is monitored, if the main management server loses with Zookeeper and is connected, be upgraded to the main management server from management server, management server is upgraded to from management server fully from management server;
(12), be equipped with management server through Zookeeper to monitoring from management server, be connected if be upgraded to the main management server or lose with Zookeeper from management server, be equipped with management server and be upgraded to from management server;
(13), after recovering, the management server that loses connection becomes management server fully.
In Zookeeper, set up described in the step (4) and be connected the interim node of corresponding son and be meant; Every management server with all under the management server node, set up the interim node of a son after Zookeeper is connected, every acquisition server with all the acquisition server node is tabulated node with acquisition tasks under, set up a sub node temporarily after Zookeeper is connected.
Step (5) concrete operations step is:
1., the main management server reads the tabulation of all acquisition terminal ID and acquisition server respectively from database and configuration file;
2., the main management server is given every acquisition server that the service of collection can be provided with the acquisition terminal mean allocation;
3., the acquisition tasks list information after the main management server will be distributed writes in the interim node of corresponding down each acquisition server of acquisition tasks tabulation node;
4., the data that listen in the interim node of the corresponding down son of acquisition tasks tabulation node of each acquisition server change, and from the interim node of each self-corresponding son, read the acquisition tasks list information.
Step (9) concrete operations step is:
(1), the main management server monitors acquisition server through Zookeeper, finds to have the acquisition server overload, management server is in time adjusted the operating load of every acquisition server according to the load state of other acquisition servers in the current cluster;
(2), the main management server monitors acquisition server through Zookeeper, finds that having acquisition server to lose with Zookeeper is connected:
(a), Zookeeper deletes with this acquisition server corresponding nodes automatically and notifies the main management server;
(b), the main management server starts a timer after receiving the notice of Zookeeper, judges whether the acquisition server that loses connection at the appointed time recovers automatically;
(c), if step (b) is judged the acquisition server lose connection to be recovered at the appointed time automatically, the main management server is not taked any operation; Do not recover automatically at the appointed time if step (b) is judged the acquisition server lose connection, the main management server is judged this acquisition server machine of delaying, and the main management server judges whether subsequent use acquisition server is arranged in the current cluster;
(d), if step (c) is judged in the current cluster subsequent use acquisition server is arranged; The main management server is launched subsequent use acquisition server, and the acquisition terminal tabulation that original acquisition server is responsible for is written in the Zookeeper node of the acquisition server correspondence of newly launching; If judging in the current cluster, step (c) do not have standby server; The main management server acquisition terminal task mean allocation that original acquisition server is responsible is given other acquisition server that can provide collection to serve in the cluster, and the new acquisition terminal tabulation that every acquisition server is responsible for is write in the interior node corresponding of Zookeeper;
(e), the acquisition server of the machine of delaying recovers and restart after be included into subsequent use acquisition server tabulation, when subsequent use acquisition server surpassed some, main management server selected part from subsequent use acquisition server tabulation was arranged work.
Compared with prior art, the invention has the advantages that: the first, when increasing new Internet of Things acquisition terminal, can carry out the automatic distribution of acquisition tasks, guarantee that the overall load of cluster server is balanced according to the running status of acquisition server in the cluster; The second, can be complicated through real-time monitoring and adjustment work to the operation state of acquisition server; Three, through setting up mutual back mechanism, when acquisition server can't provide service, automatically with the acquisition server of its task immigration to backup server or other low loads; Four, need not to connect IP and port into Internet of Things acquisition terminal manual allocation; Acquisition terminal can obtain the acquisition server that it need connect automatically through management server; After the instantaneous acquiring server can't connect, acquisition terminal can automatically obtain new connected mode from management server once more.
Embodiment
For ease of control method of the present invention is described,, the monitoring and the management method of Internet of Things data acquisition server cluster of the present invention elaborated below in conjunction with accompanying drawing:
The present invention based on the monitoring and the management system of Internet of Things data acquisition server cluster as shown in Figure 1; Acquisition server links to each other with the Zookeeper server cluster as client with management server; ZooKeeper be one distributed; The distributed application program coordination service of open source code, Zookeeper cluster provide services such as the global monitoring of management server and acquisition server, configuration and management guest machines.The Zookeeper cluster can detect the information such as state, resource utilization and operating load of acquisition server in real time through the heartbeat agreement.When acquisition server is reached the standard grade, from the Zookeeper cluster, download global configuration information, and therefrom read the own acquisition terminal of being responsible for and tabulate, then with this tabulation in acquisition terminal carry out data communication and gather related data.Management server is connected with the Zookeeper cluster, and is responsible for dynamically updating the state of global configuration information and monitoring acquisition server through Zookeeper.That management server comprises is master and slave, be equipped with three, wherein, has only the main management server that service is provided.When finding to have acquisition server to delay machine, management server uses the acquisition server of the current machine of delaying of standby server replacement, and new server is distributed in the acquisition terminal tabulation that the acquisition server of the former machine of delaying is responsible for.Management server is the acquisition terminal information in the Query Database server regularly, and with up-to-date data sync in the Zookeeper cluster.Acquisition server, management server and Zookeeper cluster are in same Intranet; Transmit packet through router between this Intranet and the outer net; Acquisition terminal links to each other with management server through router; Acquisition terminal carries out data communication with acquisition server then to the IP and the port of management server request acquisition server.
The monitoring and the management method of Internet of Things data acquisition server cluster of the present invention may further comprise the steps:
(1), in advance the ID of all Internet of Things acquisition terminals that are connected with acquisition server is stored in the relational database; When new Internet of Things acquisition terminal increases, also ID is stored into relational database, regularly inquire about for management server;
(2), utilize distributed collaboration service Zookeeper to set up tree-like storage organization; As shown in Figure 3, this tree-like storage organization is set up acquisition server (Cserver), management server (Cmaster), acquisition tasks tabulation (ConcentratorList) and configuration file (Configure) four node under root node (Root).Root ZNode is high node.The CServer node is stored all acquisition server relevant informations with interim node mode, comprises all current spare machines that the machine of the service of collection are provided and the service of collection is not provided.CMaster with interim node mode store master and slave, be equipped with three management server information.ConcentratorList stores the acquisition tasks information of all acquisition servers with interim node mode.Configure with permanent node mode store the present invention based on monitoring and all configuration informations of management system of Internet of Things data acquisition server cluster.Deposit three category informations under the Configure node, the first kind is the unified configuration information of acquisition server, leaves under the node of Same by name; Second type is directed against the different different configuration informations of acquisition server setting, leaves in the provisional child node of Distinct by name; The 3rd type of configuration information leaves in the Extension node, is used for later configuration expansion;
(3), start the Zookeeper cooperation with service;
(4), start management server and the be connected task of acquisition server in the cluster, and foundation and be connected the interim node of corresponding son in Zookeeper with the Zookeeper cooperation with service;
(5), the acquisition terminal ID that prestores in the main management server reading database also gives every acquisition server that the service of collection can be provided with acquisition terminal ID mean allocation;
(6), the main management server is monitored the connection from acquisition terminal; When acquisition terminal was connected to the main management server through network, the main management server returned IP and the port of the acquisition server that this acquisition terminal belongs to and is transmitted to acquisition terminal by routing device;
(7), acquisition terminal is connected communication with the acquisition server of main management server appointment; Only if afterwards with this acquisition server connection failure otherwise need not to be connected with the main management server again;
(8), the every son that all Cserver in the Zookeeper structure is corresponding down at a distance from two minutes of every acquisition server temporarily node write load information, state information, CPU usage, memory usage and the IO information etc. of this machine;
(9), the main management server is monitored acquisition server through Zookeeper; When finding the acquisition server overload is arranged; The main management server is in time adjusted the operating load of every acquisition server according to the load state of other acquisition servers in the current cluster; When finding to have acquisition server that service can't be provided, the main management server judges whether subsequent use acquisition server is arranged in the current cluster, if subsequent use acquisition server is arranged, launches subsequent use acquisition server; If there is not subsequent use acquisition server, the acquisition terminal task mean allocation that the main management server is responsible for this acquisition server can provide the acquisition server of the service of collection for interior other of cluster;
(10), after step (9) acquisition terminal task is redistributed; Acquisition terminal possibly failed with being connected of former acquisition server; If acquisition terminal and former acquisition server are attempted connection failure; Acquisition terminal can connect to the main management server requests once more, and the main management server returns the IP and the port of new acquisition server.
Further comprising the steps of:
(11), through Zookeeper the main management server is monitored, if the main management server loses with Zookeeper and is connected, be upgraded to the main management server from management server, management server is upgraded to from management server fully from management server;
(12), be equipped with management server through Zookeeper to monitoring from management server, be connected if be upgraded to the main management server or lose with Zookeeper from management server, be equipped with management server and be upgraded to from management server;
(13), after recovering, the management server that loses connection becomes management server fully.
In Zookeeper, set up described in the step (4) and be connected the interim node of corresponding son and be meant; Every management server with all under management server node (Cmaster), set up the interim node of a son (comprise main M, from M, be equipped with M) after Zookeeper is connected, every acquisition server with all acquisition server node (Cserver) is tabulated node (ConcentratorList) with acquisition tasks under, set up a sub node temporarily after Zookeeper is connected and (comprise the S1 that is based upon under the Cserver node ... Sn be based upon the L1 under the ConcentratorList node ... Ln).
Step (5) concrete operations step is:
1., the main management server reads the tabulation of all acquisition terminal ID and acquisition server respectively from database and configuration file; Main management server acquisition terminal information in the Query Database server regularly still behind all acquisition terminal ID in first time reading database, and with up-to-date data sync in Zookeeper so that the acquisition terminal that increases newly is distributed automatically;
2., the main management server is given every acquisition server that the service of collection can be provided with the acquisition terminal mean allocation; And in internal memory, set up (acquisition server main frame; The acquisition terminal tabulation) the acquisition server Hash table and the acquisition terminal Hash table of (acquisition terminal ID, acquisition server IP:Port);
3., the main management server writes the acquisition server Hash table in the interim node of corresponding down each acquisition server of acquisition tasks tabulation node (ConcentratorList);
4., the data that listen in the interim node of the corresponding down son of acquisition tasks tabulation node (ConcentratorList) of each acquisition server change, and from the interim node of each self-corresponding son, read the acquisition tasks list information.
Step (9) concrete operations step is:
(1), the main management server monitors acquisition server through Zookeeper, finds to have the acquisition server overload, management server is in time adjusted the operating load of every acquisition server according to the load state of other acquisition servers in the current cluster;
(2), the main management server monitors acquisition server through Zookeeper, finds that having acquisition server to lose with Zookeeper is connected:
(a), Zookeeper deletes with this acquisition server corresponding nodes automatically and notifies the main management server;
(b), the main management server starts a timer after receiving the notice of Zookeeper, judges whether the acquisition server that loses connection at the appointed time recovers automatically;
(c), if step (b) is judged the acquisition server lose connection to be recovered at the appointed time automatically, the main management server is not taked any operation; Do not recover automatically at the appointed time if step (b) is judged the acquisition server lose connection, the main management server is judged this acquisition server machine of delaying, and the main management server judges whether subsequent use acquisition server is arranged in the current cluster;
(d), if step (c) is judged in the current cluster subsequent use acquisition server is arranged; The main management server is launched subsequent use acquisition server; And the acquisition terminal that original acquisition server is responsible for tabulation is written in the corresponding Zookeeper node of the acquisition server newly launched, and the acquisition server of promptly newly launching is based upon the son node temporarily ConcentratorList under; If judging in the current cluster, step (c) do not have standby server; The acquisition terminal task mean allocation that the main management server is responsible for original acquisition server is given other acquisition server that can provide collection to serve in the cluster; And the new acquisition terminal tabulation that every acquisition server is responsible for write in the Zookeeper in the node corresponding, promptly every acquisition server is based upon the interim node of each height under the ConcentratorList;
(e), the acquisition server of the machine of delaying recovers and restart after be included into subsequent use acquisition server tabulation, when subsequent use acquisition server surpassed some, main management server selected part from subsequent use acquisition server tabulation was arranged work.
Monitoring described in the above-mentioned steps, monitoring all are the event notification mechanisms that utilized Zookeeper; When after respective nodes is injected watcher (Zookeeper monitor), Zookeeper promptly can give corresponding server with the change notification that this node data takes place.Dotted line among Fig. 3 is represented the distribution of watcher.
Fig. 4 has acquisition terminal, router, management server and four kinds of participants of acquisition server for acquisition terminal sends data to the flow process of acquisition server in this flow process.
Step 1: when acquisition terminal is reached the standard grade, connect to the management server request of sending through router;
Step 2: router is mapped to management server with this connection request;
Step 3: management server is according to the operating duty of current acquisition server cluster and the allocation strategy of acquisition server, for this concentrator distributes an acquisition server;
Step 4: router is transmitted to acquisition terminal with the information in the step 3;
Step 5: after acquisition terminal is received the acquisition server IP and port numbers of connection, be connected with the management server disconnection;
Step 6: management server listens to connect and breaks off, and closes socket;
Step 7: acquisition terminal sends connection request to the acquisition server that receives;
Step 8: router is transmitted the connection request of acquisition terminal;
Step 9: after acquisition server receives the connection request of acquisition terminal, monitor this acquisition terminal ID whether in the acquisition terminal tabulation that it is responsible for, if, then accept the connection request of this acquisition terminal, otherwise refusal;
Step 10: router is transmitted the response frame of step 9;
Step 11: after acquisition terminal is received response frame, send acknowledgement frame;
Step 12: the routing forwarding acknowledgement frame, after acquisition server receives acknowledgement frame, successful connection;
Step 13: be connected if acquisition terminal loses with acquisition server, maximum repeating step 7 twice then is not if still connect then change step 14 over to;
Step 14: if repeat twice all not success of step 7, then repeating step 1.