Sponsored Content
Operating Systems Linux Red Hat Change hostid to particullar string Post 302759949 by brusell on Wednesday 23rd of January 2013 06:50:35 AM
Old 01-23-2013
Change hostid to particullar string

Hello guys,
currently I'm working on migration services from physical to virtual server (RHEL 6). One form applications is binded to hostid of old server.
I put value of hostid from old server to the /etc/hostid on new server, but output of hostid command is giving nonsenses then.
Code:
[root@oldserver ~]# hostid 
17acc883


Code:
[root@newserver tmp]# hostid 
18ac2644
[root@newserver tmp]# echo 17acc883 > /etc/hostid
[root@newserver tmp]# hostid 
63613731

Can anybody help??

Thanks.

---------- Post updated at 12:50 ---------- Previous update was at 12:37 ----------

So I have found solution.

Code:
#!/usr/bin/python
from struct import pack
hostid = pack("I",int("0x210a2500",16))
filename = "/etc/hostid"
open(filename,"wb").write(hostid)

This User Gave Thanks to brusell For This Post:
 

10 More Discussions You Might Find Interesting

1. Solaris

How to change the HostID?--SunFire880

Hi, Guys I have to change the HostID for my SUNFire880 in lab. Can some body help me? and give the detail procedure? I don't think the command "mkp" can be used in SUNFire880 system. So please help!:cool: (2 Replies)
Discussion started by: surainbow
2 Replies

2. Solaris

procedure to change hostid of Sun server

Hello Everybody I would like to know that I have configure the OS & other application on the SunFire V440 server 1) If suppose no hostid base software install in that v440 server & if some problem comes in the motherboard of that server. If I remove the harddisk ( on which Solaris & other... (4 Replies)
Discussion started by: girish.batra
4 Replies

3. Shell Programming and Scripting

[Perl] Find one string, change another string.

Hi, In principle I am searching for a Perl equivalent for this sed command: sed "/TIM_AM_ARGS=/ s/60/1440/" $EDIT_FILE > $TEMP_FILE cp $TEMP_FILE $EDIT_FILE I was wondering if it needs to be like this, or that there other, shorter, alternatives: open (TIMENVFILE, "<$timenvfile") or die... (5 Replies)
Discussion started by: ejdv
5 Replies

4. Solaris

Solaris 10 - HOSTID changed ???

Hello everybody, please , I need an urgent help. I reinstalled our server Sun X4150. What was changed: our two disks were changed to raid1 and I installed a never version of Solaris 10 (previously the version from 12/2009 was used, now a version from 03/2010). what I'm surprised, the... (3 Replies)
Discussion started by: freeangel
3 Replies

5. Solaris

Change hostid for software install - license issue

Hi all. Solaris 9. After I change the hostid, how can I change it back without rebooting the machine? Thanks (2 Replies)
Discussion started by: jamie_collins
2 Replies

6. Solaris

Change Solaris hostid

Hi, I've searched the UNIX forum looking for a simple procedure how to change\control my Solaris server hostid. I did found few threads but all of them either have broken links to all kinds of scripts or not described simply for some UNIX beginers user like me. Can anyone assist me? I... (21 Replies)
Discussion started by: avisht
21 Replies

7. Solaris

How to find HostID?

Dear All, I am facing a simple problem . I have a x6270 server attached to a M6000 chasis. The server is fresh i:e O/S is not installed in it. Now the customer is asking for the HostID of that server. I have tried every possible way but i am not able to find the HostID .I went through the... (4 Replies)
Discussion started by: sudhansu
4 Replies

8. Solaris

How to change hostid saved in rpool?

Hi, We have a Sun M5000. I am now trying to boot the second system domain by using the boot disk (a mirrored boot disk actually) of the first domain (if succeed then no OS installation is needed for the second domain). I got the following errors: SPARC Enterprise M5000 Server, using Domain... (21 Replies)
Discussion started by: aixlover
21 Replies

9. Solaris

Change hostID of Solaris 10 virtual/guest machine installed by Virtual Box 4.1.12 on Windows-XP host

Trying to set or modify the randomly set hostID of a Solaris 10 virtual/guest machine that I installed on a Windows-XP host machine (using Virtual Box 4.1.12). I was able to set/modify the hostname of the Solaris 10 virtual/guest machine during installation as well as via the Virtual Box... (4 Replies)
Discussion started by: Matt_VB
4 Replies

10. Red Hat

How can I change hostid?

There is no /etc/hostid file. I know that there is no relationship between with MAC address and hostid. There are a lot of scripts on the net but how can I exactly do in my case. :rolleyes: (4 Replies)
Discussion started by: getrue
4 Replies
GETHOSTID(3)						     Linux Programmer's Manual						      GETHOSTID(3)

NAME
gethostid, sethostid - get or set the unique identifier of the current host SYNOPSIS
#include <unistd.h> long gethostid(void); int sethostid(long hostid); Feature Test Macro Requirements for glibc (see feature_test_macros(7)): gethostid(): _BSD_SOURCE || _XOPEN_SOURCE >= 500 sethostid(): Since glibc 2.21: _DEFAULT_SOURCE In glibc 2.19 and 2.20: _DEFAULT_SOURCE || (_XOPEN_SOURCE && _XOPEN_SOURCE < 500) Up to and including glibc 2.19: _BSD_SOURCE || (_XOPEN_SOURCE && _XOPEN_SOURCE < 500) DESCRIPTION
gethostid() and sethostid() respectively get or set a unique 32-bit identifier for the current machine. The 32-bit identifier is intended to be unique among all UNIX systems in existence. This normally resembles the Internet address for the local machine, as returned by geth- ostbyname(3), and thus usually never needs to be set. The sethostid() call is restricted to the superuser. RETURN VALUE
gethostid() returns the 32-bit identifier for the current host as set by sethostid(). On success, sethostid() returns 0; on error, -1 is returned, and errno is set to indicate the error. ERRORS
sethostid() can fail with the following errors: EACCES The caller did not have permission to write to the file used to store the host ID. EPERM The calling process's effective user or group ID is not the same as its corresponding real ID. ATTRIBUTES
For an explanation of the terms used in this section, see attributes(7). +------------+---------------+---------------------------+ |Interface | Attribute | Value | +------------+---------------+---------------------------+ |gethostid() | Thread safety | MT-Safe hostid env locale | +------------+---------------+---------------------------+ |sethostid() | Thread safety | MT-Unsafe const:hostid | +------------+---------------+---------------------------+ CONFORMING TO
4.2BSD; these functions were dropped in 4.4BSD. SVr4 includes gethostid() but not sethostid(). POSIX.1-2001 and POSIX.1-2008 specify gethostid() but not sethostid(). NOTES
In the glibc implementation, the hostid is stored in the file /etc/hostid. (In glibc versions before 2.2, the file /var/adm/hostid was used.) In the glibc implementation, if gethostid() cannot open the file containing the host ID, then it obtains the hostname using gethostname(2), passes that hostname to gethostbyname_r(3) in order to obtain the host's IPv4 address, and returns a value obtained by bit-twiddling the IPv4 address. (This value may not be unique.) BUGS
It is impossible to ensure that the identifier is globally unique. SEE ALSO
hostid(1), gethostbyname(3) COLOPHON
This page is part of release 4.15 of the Linux man-pages project. A description of the project, information about reporting bugs, and the latest version of this page, can be found at https://www.kernel.org/doc/man-pages/. Linux 2017-09-15 GETHOSTID(3)
All times are GMT -4. The time now is 06:26 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy