Host name not being resolved properly in CentOS - linux

I am running CentOS on a virtual machine. My /etc/hosts file is as follows:
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.50.17 192-168-50-17.openstacklocal 192-168-50-17
192.168.50.13 slave5
/etc/resolv.conf:
; generated by /sbin/dhclient-script
search openstacklocal
nameserver 192.168.50.3
nameserver 8.8.8.8
nameserver 8.8.4.4
All pings are working properly. However, when I am trying to run the following command -
/usr/lib64/lustre/tests/llmount.sh, this is what I am getting:
Loading modules from /usr/lib64/lustre/tests/..
detected 1 online CPUs by sysfs
libcfs will create CPU partition based on online CPUs
debug=vfstrace rpctrace dlmtrace neterror ha config ioctl super lfsck
subsystem_debug=all -lnet -lnd -pinger
Formatting mgs, mds, osts
Format mds1: /tmp/lustre-mdt1
Format ost1: /tmp/lustre-ost1
mkfs.lustre: Cannot resolve hostname '192-168-50-17#tcp'.
mkfs.lustre: exiting with 1 (Operation not permitted)
I am running it as the root user. Any help on fixing this would be appreciated. Thanks!

Why does your /etc/hosts file have what looks like an IP address with dashes (-) instead of dots (.)? You probably just need to delete these lines from the (or the entire) /etc/hosts file.

Related

localhost defaults to ipv6 address instead of ipv4 on fedora linux. Can't connect to mongodb from nodejs

After a system update on Fedora 36 Linux, Localhost alias now uses the ipv6 address by default which has broken a lot of my code.
For instance:
// Connecting to MongoDB using mongoose on express (nodejs)
mongoose.connect('mongodb://localhost:27017/farmStand')
.then(()=>{
console.log('Connected to Mongo');
})
Does not work and throws this error:
MongooseServerSelectionError: connect ECONNREFUSED ::1:27017
I've done some research and found multiple workarounds such as replacing localhost with 127.0.0.1, localhost4 or even removing the following line,
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
from from /etc/hosts,
# Loopback entries; do not change.
# For historical reasons, localhost precedes localhost.localdomain:
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
# See hosts(5) for proper format and other examples:
# 192.168.1.10 foo.mydomain.org foo
# 192.168.1.13 bar.mydomain.org bar
However since this the former forces me to change a lot of code and the later is not recommended by the hosts file itself,
How do i return localhost to its former state or bind mongodb to ipv6?
Start your MongoDB with this settings:
net:
bindIpAll: true
ipv6: true
Then it should work

gpinitsystem unknown host mdw

I am sure that there are no extra spaces before or after your hostname(S) in the host file, and using ssh mdw can connect to mdw.
The /etc/hosts is like this:
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
The error log:
20161209:21:01:14:030310 gpinitsystem:mdw:gpadmin-[INFO]:-Checking configuration parameters, please wait...
20161209:21:01:14:030310 gpinitsystem:mdw:gpadmin-[INFO]:-Reading Greenplum configuration file /home/gpadmin/gpconfigs/gpinitsystem_config
20161209:21:01:14:030310 gpinitsystem:mdw:gpadmin-[INFO]:-Locale has not been set in /home/gpadmin/gpconfigs/gpinitsystem_config, will set to default value
20161209:21:01:14:030310 gpinitsystem:mdw:gpadmin-[INFO]:-Locale set to en_US.utf8
20161209:21:01:15:030310 gpinitsystem:mdw:gpadmin-[INFO]:-MASTER_MAX_CONNECT not set, will set to default value 250
20161209:21:01:15:030310 gpinitsystem:mdw:gpadmin-[INFO]:-Checking configuration parameters, Completed
20161209:21:01:15:030310 gpinitsystem:mdw:gpadmin-[INFO]:-Commencing multi-home checks, please wait...
.20161209:21:01:17:gpinitsystem:mdw:gpadmin-[FATAL]:-Unknown host mdw Script Exiting!
please.
How many hosts there are in your greenplum. Your /etc/hosts doesn't contain any information about mdw and sdw.
Assume you have two hosts named mdw and sdw1 in your greenplum, both of the /etc/hosts files should be like this:
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
172.31.25.24 mdw
172.31.16.170 sdw1
Replace the ip and host name with your own. Before try gpinitsystem again, you'd make sure you have performed gpssh-exkeys succesfully.
UPDATE:
I helped him with this issue using Skype. The answer is that his gpadmin account had no privilege to call ping utility, cause gpinitsystem calls ping to ensure any host in the DBMS exists.

DB2 instance creation failed while running db2icrt

I have installed DB2 10.5 server in my centos 7 VM.
I am trying to create a DB2 instance via running db2icrt
./db2icrt -u db2fenc1 db2inst1
But the command fails by issuing this :
Operating system information: Linux 3.10.0-229.el7.x86_64.#1 SMP Fri Mar 6 11:36:42 UTC 2015 x86_64
ERROR: The host name "vm65x148.acg.ips" is invalid. Specify a valid host name.
ERROR: The "db2icrt" command failed. Ensure the command parameters are valid,
that errors reported in the log file are fixed, then rerun the command.
The entry in my /etc/hosts file is this
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
I assume that vm65x148.acg.ips is the hostname of your machine. Make sure that this hostname can be resolved on the OS level, then try creating the instance again.
for more detail, see http://www-01.ibm.com/support/docview.wss?uid=swg21615752
As pointed out in the post by Peter Schuetze ,my /etc/hosts file was missing the entry of my VM id . So I tried to fix the issue by editing my /etc/hosts files
This is the initial entry in my /etc/hosts file
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
This is how it looked after editing
127.0.0.1 vm65x148.acg.ips localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
After that I restarted the daemon like this :
/etc/rc.d/init.d/network restart
Then I tried to create the DB2 instanceand this time it worked
Hope this helps someone else

What is the correct /etc/hosts format?

Recently I am started having issue with /etc/hosts file on hadoop nodes. Each host has private & public IP.
Some of the previous setup was with the following format
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
10.0.3.62 client01.dev.abc.com client01
and new hosts with following format
127.0.0.1 client01.dev.abc.com localhost.localdomain localhost
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
I am still confuse with it. Any help ?
Thanks
just do
nano /etc/hosts
and then add these below the lines which are already present,
192.168.1.15 hadoop-master
192.168.1.16 hadoop-slave-1
192.168.1.17 hadoop-slave-2
These IP addresses should be local/Private addresses.

Unable to restart apache on centos

I have a centos VM and httpd -v gives me following output
Server version: Apache/2.2.15 (Unix)
Server built: Oct 16 2014 14:48:21
I shut down the server by using command:
sudo /etc/init.d/httpd stop
Now when I try to start the server, I get following error:
Starting httpd: httpd: apr_sockaddr_info_get() failed for bslm-022.corp.day.com
httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
no listening sockets available, shutting down
Unable to open logs
[FAILED]
What I have read online here is that I should add ServerName localhost in /etc/apache2/httpd.conf file. But there is no directory named /etc/apache2 on my VM.
The content of /etc/hosts file are:
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
The result of $hostname command is:
bslm-022.corp.day.com
I want the apache server to run on localhost for me.
Make sure in your httpd.conf has "Listen 80" or in any of your conf files in /etc/httpd/conf.d/*
If it does then look at netstat to see what's listening
netstat -tunlp

Resources