Redirecting Users to New Server


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Redirecting Users to New Server
# 1  
Old 09-20-2013
HP Redirecting Users to New Server

I am new to shell scripting. I urgently need a script on a backup server that will ping the main server to check if the server is up. If the main server is down- the script should transfer the IP of the main server to the backup server. Once the main server is up again the backup server will release the IP so that traffic will go back to the main server. The script should run as a background daemon.
# 2  
Old 09-20-2013
Quote:
the script should transfer the IP of the main server to the backup server.
and reboot the backup server just after?...
What about your hostnames and DNS?
You are looking to do some HA and there are softwares for that, making a poor man's cluster why not, but you have to think seriously how its done
# 3  
Old 09-20-2013
Yes. I am already using Crontab and SCP to automate the back up. I want to use a simple script to automate the failover. I dont want to use any apps.
# 4  
Old 09-20-2013
do you use any user control panel like directadmin or cpanel ?
# 5  
Old 09-20-2013
The point is you cant automate such a system:
It will necessarily mean that at main server not responding, you would have to run a script that changes network configuration files of backup server and after reboot the server, then other way round you cannot let the main server boot while the other is running since it has the server's name and IP...
You could bypass some issues by configuring a second lan interface with another IP and "server name" known also to the DNS where configured correctly, all users land on prod server and backup server has the same but not active ( ifconfig down...)
# 6  
Old 09-20-2013
That said maybe if you gave us more information on your environment we could suggest wiser solutions... all we know so far is 2 servers... (connected to a disk bay? seen bothe sides? OS? etc...)
Update---
And what application you are mentionning for I you may have more obvious solutions ( e.g. if its Web stuff ...) my concern was more about heavy stuff like applicaion running oracle with oracle RDBMS etc

Last edited by vbe; 09-20-2013 at 11:54 AM.. Reason: Update--
# 7  
Old 09-20-2013
No something simple. The backup server always on no need to reboot. 2 fedora boxes. The backup is an email backup server exactly like d main server. The script should just change IP address on d fly. The main server has a public and local IP. Both servers are connected via local interface. The backup server also have a public ip. The public ip of the backup is configured with a higher priority on d mx records. So external users can access the backup if the main server is down. But for local users pointing to the main server ip there is an issue.
The script running on the backup server should ping d main server public ip and configure the local ip of d backup server to take up d local ip of the main server and release the ip when the main server comes back online when the main server public ip become available.

---------- Post updated 09-21-13 at 12:54 AM ---------- Previous update was 09-20-13 at 11:22 PM ----------

Code:
16.	# add ip / hostname separated by white space 
17.	HOSTS="PublicIP"
18.	 
19.	# no ping request
20.	COUNT=1
21.	 
22.	# email report when 
23.	SUBJECT="Ping failed"
24.	EMAILID="me@mydomain.com"
25.	for myHost in $HOSTS
26.	do
27.	  count=$(ping -c $COUNT $myHost | grep 'received' | awk -F',' '{ print $2 }' | awk '{ print $1 }')
28.	  if [ $count -eq 0 ]; 
29.	
30.	  then
31.	    # 100% failed 
32.	    echo "Host : $myHost is down (ping failed) at $(date)" | mail -s "$SUBJECT" $EMAILID
33.	    /sbin/ip addr add 155.128.89.55/24 dev eth1
34.	 
35.	  else
36.	    Echo “Host is up and running”
37.	    /sbin/ip addr del 155.128.89.55/24 dev eth1
38.	  fi
39.	Done

will something like this work? I put this together from many sources.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Ssh fails for one of two users on the same server.

I have two users on dest_host server viz wlsadm & wasadm. From src_host server with root user I m able to passwordless login to wlsadm@dest_host however, the same fails for wasadm@dest_host Below is the debug for both first the working ssh and then the non-working ssh. Works: ... (6 Replies)
Discussion started by: mohtashims
6 Replies

2. Red Hat

How to add a new users in proftpd server?

Hi, I have installed proftpd server in my amazon instance and how to enable a new user to access the proftpd. 1. How to add or delete a users 2. how to enable a particular user to access particular folder Regards Paulwintech (5 Replies)
Discussion started by: Paulwintech
5 Replies

3. UNIX for Advanced & Expert Users

Sending Messeges To Users on a Server

I am in the process of doing testing on a backup script that will backup everyones home directories. When I run a "who" I can see the users that are logged on. How can I send these users, let say an instant message other then email to alert them that I am about ready to kick of a test backup? I... (3 Replies)
Discussion started by: metallica1973
3 Replies

4. Linux

users can't sftp into my server

I am running a fedora core 13 server and I am having trouble with sftp. My users can connect to the server using SSH both using public key and password authentication. For some reason they are not able to connect using sftp. I'l not sure what's going on. I ran sshd in debug mode and here's... (6 Replies)
Discussion started by: emildiego
6 Replies

5. Web Development

Apache - redirecting authenticated users to other sites

Hi everyone. Im really new here, so please have patience with me if i act out of order in any way. I do have some unix experience, but i would not call it extensive. The problem i am about to describe probably have a easy solution, but i have been unable to find it while speaking to Mr.Google... (4 Replies)
Discussion started by: antiw2k3
4 Replies

6. Red Hat

when users ftp to server the timezone reflected is UTC but the server is set to TZ in localtime

Guys, Need your help coz my server runs in local time GMT +8, but when client use ftp and login, the resulting timestamp seen in each file is in UTC format. We need to set that the time should be the same as GMT +8 when in ftp session. I am using RHEL 5.3. root@]# ll total 1740... (2 Replies)
Discussion started by: shtobias
2 Replies

7. UNIX for Advanced & Expert Users

2 users on the same server (rexec)

Hi, all. Could some one help me please with one problem? In one process (on aix) I should run some remote scripts on other server via rexec. Some scripts should be run on server1 under useridA, and some scripts should be run on the same server under useridB. I specified in .netrc... (10 Replies)
Discussion started by: Anta
10 Replies

8. UNIX for Dummies Questions & Answers

Users locked out of Server

hiya all, I have Fedora core 3 installed - as a server - onto an old PC. Root u/n and psw lets me in However, all the other accounts no longer worked. They use to work until yesterday... I now get the error at the login screen: "AUTHENTICATIONFAILED" I hope this is a common... (12 Replies)
Discussion started by: marty 600
12 Replies

9. UNIX for Dummies Questions & Answers

Redirecting output file to a different server.

Hi, I hope this is problem makes sense and that someone can offer some advice. Basically i have a perl script which accesses a database and outputs the information to a file. Is it possible to use a 'system' command to embeb some Unix command which moves that file to another directory... (3 Replies)
Discussion started by: Stormrider
3 Replies

10. UNIX for Advanced & Expert Users

Migrating all users from one linux server to another...

Hello, I've been tasked with migrating users from one linux server to another new linux server. This is how I was thinking of doing it: 1.) Open up an NFS connection between the two servers, cp -Rp /home/ to the new server and then append the old /etc/group & /etc/passwd to the existing... (2 Replies)
Discussion started by: vancouver_joe
2 Replies
Login or Register to Ask a Question