Tuesday, March 4, 2014

How to change hostname in HP UNIX and Redhat Linux

Hi Friends,


Changing hostname is not a big deal in Redhat Linux and HP UX. But before doing this we have to do proper planning. These Includes :-

HP Unix :-

a. Here we need a downtime to change the hostname as permanent. So be planned about the same, with proper Ignite backups and Binary backups of the DB and the DB backup, if running and installed.

b. Doing it for temporary basis, {I would say dont go for it} until you are pretty much sure about the testing.
c. Yes, in HP UNIX

#hostname amitchopra
#hostname
amitchopra
#

or you keep it like :-

# hostname xyz
#
#hostname
xyz
#

this will make the hostname as amitchopra or xyz for new session also and services may get affected due to it. Services like cluster {cmmcld}, services of oracle running on basis of hostname, applications running on the name of hostname of the server.

so be careful while doing this.

Now here is the game, you have to stop running services on your server after proper downtime, fix the same permanently using below command :-

#set_parms hostname

this command will help in changing the hostname as permanent. It will by itself prompt for rebooting the server. so you can reboot the server. or you can ask your application/DB team to give appropriate downtime for reflecting the hostname permanently.

It seems like a drawback of HP UNIX, if we by mistake run hostname command with any flag to get some information using hostname command then it will keep the flag option as server's hostname. example shown below :-

#hostname -i
#
#hostname
-i
#hostname -a
#
#hostname
-a
#

so this can affect running services also and output of commands like "cmviewcl" or related to service guard cluster will give permission denied error to user. new login user will also see the same hostname like -a or -i or xyz.



and

Redhat Linux gives us this opportunity to keep the hostname temporary and do not affect the running services.

here :-

#hostname amitchopra
#

it will keep the hostname as amitchopra for a terminal session only and other logged in user or will be logging in user will not see this effect. That is the best part.

To make it as permanent fix. we need to keep the entry of new hostname  in /etc/sysconfig/networking file. write the desired hostname there. reload the network services after verifying the /etc/sysconfig/network-scripts/ifcfg-eth0/eth1 file, we should have onboot=yes in that file. check the IP, Port, HW ADDR using ifconfig command. verify and then restart the services of network..


then hostname on redhat linux/linux server will change for permanent. Temporary change in Linux will not affect services or users, where the same can make an affect in HP UNIX.


Love Sharing
Amit Chopra

No comments: