Solved

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

Posted on 2008-10-10
8
4,143 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
  • 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
AWS Central Authentication 1 87
awk sed variable in file 3 73
How to mount nfs share on this CentOS server? 6 42
Samba 4, Users Permission, 5 46
FreeBSD on EC2 FreeBSD (https://www.freebsd.org) is a robust Unix-like operating system that has been around for many years. FreeBSD is available on Amazon EC2 through Amazon Machine Images (AMIs) provided by FreeBSD developer and security office…
Google Drive is extremely cheap offsite storage, and it's even possible to get extra storage for free for two years.  You can use the free account 15GB, and if you have an Android device..when you install Google Drive for the first time it will give…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
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.

839 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