We have a server with a CentOS distribution of Linux. It lost its hostname in the month somehow, since our last reboot. We ran an ETL (extract, transform, load) job last week, and part of that process stops JBoss before moving data to our database, and then restarts JBoss after that automatically. The restart failed.
I solved (with a hack) using this method:
We didn't make any changes to the server in the last month (to any files), so I know /etc/hosts wouldn't have changed. I added that extra line (in the answer above), in the /etc/hosts file so JBoss could start.
How does the "hostname -f" command retrieve the hostname from the DNS, per this question? What is it checking on our DNS? Is there a term I should be using to communicate with our server team?
How do most server administrators handle this, or avoid what happened to me? Do they always set something in the /etc/hosts file to avoid changes to the DNS?
Basically I'm trying to figure out what changed on our network (or DNS) which caused our hostname to go missing. See, the command prompt shows the hostname on the server when I log in. It's strange that I see it there, but not when I call "hostname -f". See "lvs-xyz" below.
[root@lvs-xyz ~]# hostname -f hostname: Unknown host
If you can't answer all of my questions, I'm mainly looking for what the "norm" is to avoid losing a hostname for the administration of Linux. If I put it into /etc/hosts, then it seems like a hack because the command prompt could change if the kernal value changes, and then it would be different from /etc/hosts if that were to happen.
[root@lvs-xyz sysconfig]# cat /etc/sysconfig/network-scripts/ifcfg-eth0 DEVICE=eth0 ONBOOT=yes BOOTPROTO=none NETWORK=22.214.171.124 IPADDR=126.96.36.199 NETMASK=255.255.255.192