boot with diff. ip and hostname


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting boot with diff. ip and hostname
# 1  
Old 11-23-2004
Question boot with diff. ip and hostname

Hi,
one big question. IŽll like the Sun Fire V480 to boot on two differend modes, using differend Hostnames and differend IP Adresses.
IŽve tried to replace the following files with a script:
/etc/hostname.ce0
/etc/net/ticlts/hosts
/etc/net/ticots/hosts
/etc/net/ticotsord/hosts
/etc/inet/hosts

to change the name from the Server using uname -S name.test.de (for example).
After rebooting this server everything looks like before, what is going wrong. Is there a better way to solve this problem ?

My Problem is that this Server is used as a test and backup System. Everything is the same, but in the failover it is nessesary to use the live ip and hostname. both systems are equal. At failover the live system will be down.
I can change these settings using uname and ifconfig, but i must reboot the backup server, cause i must switch the SAN Luns.
Is there anyway, a script ore something, i can use that runs at the startup and checks the flag for backup or test mode, and changes the ip and the hostname during the boot?

Best regards
Michael
# 2  
Old 11-23-2004
You would want to run a script before shutting down, not while booting. Change any startup scripts from S to s that you don't want to run.

Move a new host table into place (remember to save the original). Change /etc/defaultroute if needed. Change the hostname with /usr/bin/hostname newhostname.

Example of script - I believe you should be able to figure out what the files contain that it reads. You would have two sets of extra files - one for primary and one for secondary.

Code:
#!/bin/csh -f
#
# Created 02/09/00 HOG Script to change this system to SECONDARY oracle
server
#                       O/S side only.
#
# Script checks for files needed - if any changes from certain files 
have
been
#   done without updating other files then this script will exit so a
failure
#   of both primary and secondary servers does not occur.
# ====================================================================
set dtf_change = "Y"
set defdir = "/usr/local/dtf-change"
set thishost = "`hostname`"
set thisip = "`grep $thishost /etc/hosts | grep loghost | awk '{print 
$1}'`"
set primhost = "oracle"
set sechost = "oracle2"
set primip = "172.16.1.14"
set secip = "172.16.1.142"
set tmpfile = "/tmp/dtf-change.tmp"
set allfiles = "$defdir/hosts.primary $defdir/hosts.secondary
$defdir/defaultrou
ter.primary $defdir/defaultrouter.secondary"
# ------------------------------------------------------------
# Check for all files needed to change 
foreach newfile ($allfiles)
        if (-e $newfile ) then
        else
                echo "File $newfile does not exist - no changes made"
                set dtf_change = "N"
        endif
end
if ("$dtf_change" == "Y") echo "All needed files exist."
#
/usr/bin/diff $defdir/hosts.secondary /etc/hosts > $tmpfile
if (-z $tmpfile) then
        echo "This system may already be the secondary Oracle server"
        set dtf_change = "N"
endif
/usr/bin/diff $defdir/hosts.primary /etc/hosts > $tmpfile
if (-z $tmpfile ) then
        echo "This system seems to be the primary Oracle server"
else
        set dtf_change = "N"
endif
/usr/bin/diff $defdir/defaultrouter.secondary /etc/defaultrouter > 
$tmpfile
if (-z $tmpfile != 0) then
        echo "Default router is for secondary."
        set dtf_change = "N"
endif
if ("$thishost" == "$sechost") then
        echo "This is the secondary Oracle host"
        set dtf_change = "N"
endif
if ("$dtf_change" == "N") then
        # something is missing - do not continue
        goto enditall
endif
#
echo "Changing this system from primary to secondary Oracle server."
#
echo "" ; echo -n "Moving Oracle startup..."
cp /etc/rc2.d/S99dbora /etc/rc2.d/s99dbora ; echo "Done."
#  -------- MOVE NEW HOST TABLE ------
echo "" ; echo -n "Moving Host table..."
cp $defdir/hosts.secondary /etc/inet/hosts.new
chmod 444 /etc/inet/hosts ; chgrp sys /etc/hosts ; echo "Done."
#  -------- CHANGE DEFAULT ROUTE FILE ------
echo "" ; echo -n "Moving default route file..."
cp $defdir/defaultrouter.secondary /etc/defaultrouter.new 
chmod 644 /etc/defaultrouter; echo "Done."
#  -------- SET HOST NAME ------
echo ""; echo -n "Setting hostname to $sechost..."
/usr/bin/hostname $sechost ; echo "Done."
#  -------- All done -----------
echo "";echo "This system is ready to be rebooted - enter init 6."
echo "This system ($thishost) will come back up as $sechost."
echo "Remember that Oracle will not start automatically. See your DBA 
for
help"
#
enditall:
exit

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Diff 3 files, but diff only their 2nd column

Guys i have 3 files, but i want to compare and diff only the 2nd column path=`/home/whois/doms` for i in `cat domain.tx` do whois $i| sed -n '/Registry Registrant ID:/,/Registrant Email:/p' > $path/$i.registrant whois $i| sed -n '/Registry Admin ID:/,/Admin Email:/p' > $path/$i.admin... (10 Replies)
Discussion started by: kenshinhimura
10 Replies

2. UNIX for Advanced & Expert Users

Hostname -f hostname: Unknown host

deleted (0 Replies)
Discussion started by: hce
0 Replies

3. Shell Programming and Scripting

serach diff filename in diff location using shell scripting

Hi, I am new to shell scripting. please help me to find out the solution. I need a script where we need to read the text file(consists of all file names) and get the file names one by one and append the date suffix for each file name as 'yyyymmdd' . Then search each file if exists... (1 Reply)
Discussion started by: Lucky123
1 Replies

4. Emergency UNIX and Linux Support

HP UX - ILO Console hostname different than Machine Hostname...

Hi All, So we added a new HP-UX 11.31 machine. Copied OS via Ignite-UX (DVD)over from this machine called machine_a. It was supposed to be named machine_c. And it is when you log in...however when I'm in the ILO console before logging in, it says: It should say: What gives? And how do... (4 Replies)
Discussion started by: zixzix01
4 Replies

5. Shell Programming and Scripting

.procmailrc and uudeview (put attachments from diff senders to diff folders)

Moderator, please, delete this topic (1 Reply)
Discussion started by: optik77
1 Replies

6. Boot Loaders

Reboot and Select Proper Boot device or insert Boot media in select Boot device and press a key

Hello, I have kubuntu on my laptop and now I decided to switch to Windows 7. I made the bios settings properly (first choice is boot from cd\vd) but I see the error " reboot and select proper Boot device or insert Boot media in select Boot device and press a key " I have tried CD and... (0 Replies)
Discussion started by: rpf
0 Replies

7. Shell Programming and Scripting

Simulate SVN diff using plain diff

Hi, svn diff does not work very well with 2 local folders, so I am trying to do this diff using diff locally. since there's a bunch of meta files in an svn directory, I want to do a diff that excludes everything EXCEPT *.java files. there seems to be only an --exclude option, so I'm not sure... (3 Replies)
Discussion started by: ackbarr
3 Replies

8. UNIX for Dummies Questions & Answers

Solaris - unknown hostname - how can I change hostname?

Hello, I am new to Solaris. I am using stand alone Solaris 10.0 for test/study purpose and connecting to internet via an ADSL modem which has DHCP server. My Solaris is working on VMWare within winXP. My WinXP and Solaris connects to internet by the same ADSL modem via its DHCP at the same... (1 Reply)
Discussion started by: XNOR
1 Replies

9. Solaris

solaris boot problem boot error loading interpreter(misc/krtld)

When I installed the SOLARIS 10 OS first time, the desktop would not start up, this was because of network setup. Reinstalled worked. After a week due to some problem I had to reinstall OS, installation went fine and but when i reboot I get this error. cannot find mis/krtld boot error loading... (0 Replies)
Discussion started by: johncy_j
0 Replies

10. Shell Programming and Scripting

diff 2 files; output diff's to 3rd file

Hello, I want to compare two files. All records in file 2 that are not in file 1 should be output to file 3. For example: file 1 123 1234 123456 file 2 123 2345 23456 file 3 should have 2345 23456 I have looked at diff, bdiff, cmp, comm, diff3 without any luck! (2 Replies)
Discussion started by: blt123
2 Replies
Login or Register to Ask a Question