Hot Standby is required in recent projects.
1. Two monitoring hosts, one master and one slave
2. The system is Windows Server 2008 environment. net4.0
3. The two monitoring hosts have the same monitoring software (C # development), but only one software is running and the other software is not started.
4. What I want to achieve is that after the host monitoring software is disabled, the slave can automatically detect and determine that the host monitoring software has been disabled. The slave monitoring software starts running.
5. After the same backup host monitoring software is started, the host monitoring software can also automatically detect and switch between the master and backup hosts.
6. Storage data is stored in the form of files and how to back up each other
I have been searching for it on the internet for a long time and found that many dual-machine Hot Standby software under windows need money to buy, but there is open source software under liunx,
The dual-machine Hot Standby software under window has open source, so you can leave a comment...
Since I don't want to pay for it and want to implement it again, let me talk about my own ideas. Please criticize and correct me:
1. Since the master and slave servers need to check whether software is running on each other, the socket must be used. My idea is to create
Window service program, constantly sending heartbeat packets to check if the software on the other computer is started
2. Set three IP addresses. One IP address on the master node and one IP address on the slave Node also need a public IP address. When two hosts switch to the slave node, clear the public IP address on the master node.
(Virtual IP address) create a public IP address (virtual IP address) on the slave machine, which does not affect communication.
3. Interaction between the monitoring software and the window service program
4. How do I back up data stored on two computers?
The above is my idea. Please give me some tips ....
Thank you !!!
The code for creating the window service program is as follows:
Protected override void onstart (string [] ARGs)
{
Timer1 = new system. Timers. Timer ();
Timer1.interval = 3000; // sets the timer event interval.
Timer1.elapsed + = new system. Timers. elapsedeventhandler (timer1_elapsed );
Timer1.enabled = true;
}
Protected override void onstop ()
{
This. timer1.enabled = false;
}
Public static system. Threading. Thread m_netsendthread; // data sending thread
Private void timerincluelapsed (Object sender, system. Timers. elapsedeventargs E)
{
// Open the data sending thread
M_netsendthread = new system. Threading. Thread (new system. Threading. threadstart (netsendthread ));
M_netsendthread.priority = threadpriority. Lowest;
M_netsendthread.start ();
}
// Double-click the monitoring sending thread
Private Static void netsendthread ()
{
Int Port = 23701;
String IP = "172.16.62.34", localip = "172.16.62.34 ";
Bool bsjrb, bzbj, bstart; // double-click hot backup, Master/backup
Int tick = system. environment. tickcount;
Byte [] sendbuf = new byte [4];
Udpclient udpsend; // The sender UDP
Sendbuf [0] = 0x7e;
Try
{
Bsjrb = true;
Udpsend = new udpclient (New ipendpoint (IPaddress. parse (localip), Port ));
Ipendpoint groupep = new ipendpoint (IPaddress. parse (IP), Port );
While (true)
{
Try
{
# Region use double-click Hot Standby to send a running status broadcast to the outside
If (bsjrb)
{
Sendbuf [2] = 0x1;
Try
{
Udpsend. Send (sendbuf, sendbuf. length, groupep );
}
Catch (system. Exception ex)
{
}
}
# Endregion
}
Catch (system. Exception ex1)
{
}
Thread. Sleep (1000 );
}
}
Catch (system. Exception ex)
{
}
}
Install the window service program
After the installation is successful, right-click the computer and choose "View service" -- winservice1 exists and the service has been started.
The installation is successful.
Step 2: The monitoring software receives window service program data to determine whether the program is disconnected
Listener = new udpclient (New ipendpoint (IPaddress. parse (localip), Port); // The local listening Host IP address and Communication Port
Ipendpoint groupep = new ipendpoint (IPaddress. parse (srcip), Port); // Remote Host IP address and Communication Port
If (bzbj)
Lb_title.text = "the host monitoring center station is closed, and the backup center station is about to start .....";
Enable the host monitoring software to automatically open the standby host monitoring software.
Next, continue to enable the standby host monitoring software to automatically enable the host monitoring software.
Step 3 there is no idea to solve the problem of backing up data stored on the master and slave servers!