Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Redundant Web Server 1

Status
Not open for further replies.

Hungster

IS-IT--Management
Mar 6, 2001
830
CA
hi,

what would be the best way to setup a reduntant web server, currently running at one location, at time, the line goes down, i afraid that it might not come back up again one day

i like to setup another the same web server running centOS based on redhat ?

thanks
Hungster
 
It depends on the web server (Apache?) and the type of content. Is it mostly static pages or mostly database driven?

In the past, I've worked with groups that simply rsync static pages between servers at set intervals or when they are updated. Database connections present a little different type of problem because you still need connectivity to the database.

I would probably take the path of setting up a web farm whereby each server maintains a copy of the necessary static files and ensure there is a link any databases from each server (possibly including replicating database transactions). With the right load balancer the web servers can be geographically distributed.

The key to any replication strategy though, is understanding the question: "How up to date does the replica have to be?" If it's a transactional system like online ordering you may need to commit transactions in both databases before considering the transaction complete. If it's mostly static web pages, can they be 1 minute old, 1 day old, 1 hour old?
 
hi Bluecrack,

thanks for the response, these are mostly php code driven database, having rsync setup and everything works well

then the next question is, how to setup in a way that if the line on the main server goes down, then who ever trying to hit the main server automatically direct to the backup server, then if line goes back up again, it will go back to main server ?

 
sounds like load balancing to me? there are hardware solution or software solution to this problem.
 
sorry, not load balancing, but as a backup to the main one in case it goes down, main server gets update all the time, and rsync to the 2nd server, if main server line goes down, it will point all the traffic to 2nd server till main one comes back, then the traffic should be direct back to main one
 
The trick is where you say "... if main server line goes down ..." This implies an offsite backup with a separate Internet connection.

You might look into something like Akamai, or decide that round-robin DNS is sufficient.


 
My poor-man's trick to this was to have a third low-end (Pentium-100) webserver acting as a failover cum redirector. I had a simple script that pings our main server once every 5 seconds and if the server doesn't respond after 30 seconds, this machine will assume its IP address and serve a redirector page which points to a secondary, off-site server.

--== Anything can go wrong. It's just a matter of how far wrong it will go till people think its right. ==--
 
hi Zeland, exactly what i am looking for at a different location and different IP all together, how do i go about it

 
You can use something like this.
Code:
#!/bin/bash
contactFailed=0
while(true)
do
 ping -c 1 192.168.0.5
 if [[ $(echo $?) -ne 0 ]]; then
  contactFailed=$(expr $contactFailed + 1)
  if [[ $contactFailed -eq 6 ]]; then
   ifconfig eth0 192.168.0.5 netmask 255.255.255.0
   break
  fi
 else
  contactFailed=0
 fi
 sleep 5s
done

The script will ping 192.168.0.5 every 5 seconds. After 6 consecutive failures (around 30 seconds), it will automatically assume the target machine is dead and will assume its IP address.

--== Anything can go wrong. It's just a matter of how far wrong it will go till people think its right. ==--
 
thanks for the scripts, how do you setup the other side as well as the DNS at the register ?

 
plus how do i reverse it after the line of the main server comes back up again ?
 
Overlooking the part about the line being down, I may have erred in giving advice. My solution assumes only the server being down but not the line. This was a solution given where a company and its sister company wanted to cut down on the cost of purchasing redundant web servers. They mutually agreed to host each others website as a backup in the event of failure. So, if company A's server died, the redirector would redirect visitors to company B's backup website.

Now if you are talking about a line being down, then you have to go with a DNS option. If you host your own DNS, then you'll have to have 1 DNS server in each location. Configure your A record for each DNS server to point to their respective webserver's IP. Register both your DNS servers with your ISP. In the event you primary line is down, your primary DNS server will not be contactable thus queries will be sent to your secondary DNS which will reply with your offsite address.

--== Anything can go wrong. It's just a matter of how far wrong it will go till people think its right. ==--
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top