Solved

hostid command outputs 0, how to generate hostid on Redhat Linux 4.6

Posted on 2008-10-10
8
4,311 Views
Last Modified: 2013-12-06
We have a Redhat Linux 4.6 OS on HP DL585 G5 , hostid command outputs 0,
How to generate the hostid, or what should be done in this case, to have hostid setup.

Thanks in advance.
0
Comment
Question by:solven3
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
8 Comments
 
LVL 40

Accepted Solution

by:
omarfarid earned 168 total points
ID: 22687439
I am not sure how hostid get generated, but I have seen some comments on this on the Internet where it says that it is related to host ip address. What is the ip address of your system?

http://osdir.com/ml/user-groups.linux.madurai.general/2005-04/msg00023.html

Other page says it is related to the mac address:

http://www.mathworks.com/support/solutions/data/1-171PI.html?solution=1-171PI
0
 
LVL 19

Assisted Solution

by:jools
jools earned 166 total points
ID: 22687491
running strace seems to indicate /etc/hosts is used, I just moved my /etc/hosts out the way and got this;

# hostid
00000000

moving it back and tunning it again;
# mv /etc/hosts.old /etc/hosts
# hostid
007f0100



0
 
LVL 40

Expert Comment

by:omarfarid
ID: 22687519
So it is related to IP address and may be entry in /etc/hosts file
0
 
LVL 19

Expert Comment

by:jools
ID: 22687564
May also be something in the dns, mine just looked at the order in the hosts.conf and other files.

List of files ripped from the strace log are;

open("/etc/ld.so.cache", O_RDONLY)      = 3
open("/lib/libc.so.6", O_RDONLY)        = 3
open("/usr/lib/locale/locale-archive", O_RDONLY|O_LARGEFILE) = 3
open("/etc/hostid", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or directory)
open("/etc/resolv.conf", O_RDONLY)      = 3
open("/etc/nsswitch.conf", O_RDONLY)    = 3
open("/etc/ld.so.cache", O_RDONLY)      = 3
open("/lib/libnss_files.so.2", O_RDONLY) = 3
open("/etc/host.conf", O_RDONLY)        = 3
open("/etc/hosts", O_RDONLY)            = 3
0
 
LVL 23

Assisted Solution

by:Mysidia
Mysidia earned 166 total points
ID: 22691705
It appears to me that hostid does the following:

1. calls gethostname() [i.e. takes the hostname given by the output of the 'hostname' command in the shell]

2. Finds the entry in /etc/hosts that corresponds to the ip address of the hostname.

3. Copies octets from the ip address and prints them as a hex number:
AA.BB.CC.DD ==> 0x[BB][AA][DD][CC]

for example, if my hostname is 'foobar.example'

and my entry in /etc/hosts says

127.0.0.1 foobar.example

Then the hostid command prints '007f0100'



So to make 'hostid' not print zero... type the 'hostname' command after boot

Make sure there is an entry in /etc/hosts for that name.

Make sure that entry corresponds to a good ip address.

If you want the output to be unique, don't use 127.0.0.1



0

Featured Post

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In my business, I use the LTS (Long Term Support) versions of Linux. My workstations do real work, and so I rarely have the patience to deal with silly problems caused by an upgraded kernel that had experimental software on it to begin with from a r…
Fine Tune your automatic Updates for Ubuntu / Debian
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
Suggested Courses

737 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question