Sunday, August 22, 2010

An Error of S1000 GetNodeName When using TimesTen

This article was originally posted in my csdn.net blog on 2 Feb,2009.


Today I encountered a problem of not be able to connect TimesTen service on machine (B for short) from an HP-UX machine (A for short) in our test environment. But it’s ok originally.

First checked on B, there was no problem for local connection on B. And then checked the TimesTen connection configuration on A. It’s also ok. But when I tried to start ttisqlcs, such as:
$ttisqlcs ds1

Then an error as follows always occurred:
connect "DSN=ds1";
S1000: GetNodeName: nodename nor servname provided, or not known
The command failed.

When I inspected the error log file tterrors.log in the directory info, I found some information like ‘gethostbyname() failed’. So I thought it should be because of problem in host name resolution. Actually when I checked the file /etc/host, I did find something wrong. There were three IP addresses mapping with the host name of B. But after I removed two incorrect lines, the problem still persisted.

Later I tried to restart the TimesTen server( actually I thought this was not useful, but it just a try). Unfortunately there were no any Timesten services when issuing ttstatus command:
No TimesTen server running
No TimesTen webserver running

Checked tterrors.log again, I found the error information:
11:35:43.02 Warn: : 27070: TimesTen Daemon Release 7.0.4.0.0.tt70 started.
2009-02-02 11:35:43.11 Err : SRV: 27075: EventID=33 Server is exiting. gethostbyname() failed. ListenAddr: test1; System error: 1

At this moment, I got an error same with before if I issue command ‘ttisqlcs ds1’. There was no any difference because of no service of TimesTen. This indicated there was no relation with whether the local TimesTen services are running or not.

To confirm if there was a problem regarding with gethostbyname, I wrote a small program for test.

#include <stdio.h>
#include <errno.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <unistd.h>
#include <string.h>
#include <sys/types.h>
#include <arpa/nameser.h>
#include <resolv.h>

int main()
{
char sHostName[255];
memset(sHostName, 0x00, sizeof(sHostName));

if (-1 == gethostname(sHostName, sizeof(sHostName)))
{
printf("gethostname error\n");
return -1;
}
printf("hostname=%s\n",sHostName);

struct hostent *hp = gethostbyname(sHostName);
if (NULL == hp)
{
printf("herror=%d\n", h_errno);
herror("gethostbyname");
return -2;
}

return 0;
}

Save the file as a.c, then make and run it.
$cc -o a a.c
$./a
hostname=test1
herror=1
gethostbyname: Unknown host

The error was the same with that in tterrors.log file. System error code was 1, and host name could not be resolved.

Goolged error information "S1000: GetNodeName: nodename nor servname provided, or not known", there was no any result。And two articles returned when googling "S1000: GetNodeName". But there were no solutions in both articles.

And later I found it also failed to ping the host name. This indicated the information in /etc/hosts was not used for host name resolution. So I thought there should be some options in system configuration.

Started sam (or smh), selected the option of Networking and Communications, and then Network Services Configuration. There are many things. But I thought only following things were related:
DNS (BIND)
Hosts
NIS
Name Service Switch

For DNS configuration, it’s correctly configured company’s dns server. In Hosts section, the same with file /etc/hosts. And NIS was not in use。In the section of Name Service Switch there were also many things.

Type of First Second Third Fourth
Information Source Source Source Source

aliases /etc/aliases NIS
automount Local Files NIS
group /etc/group NIS
hosts DNS NIS /etc/hosts
netgroup NIS /etc/netgroup
networks NIS /etc/networks
passwd /etc/passwd NIS
protocols NIS /etc/protocols
publickey NIS /etc/publickey
rpc NIS /etc/rpc
services NIS /etc/services
ipnodes DNS /etc/hosts

Checked that line for hosts. Yes, it is. Because the search order for host name can be configured here.

Search Order:
1. [ DNS ->]

If Information is Not Found: [ Stop Searching ->]
If Source is Not Configured: [ Try Next Source ->]
If Source is Not Responding: [ Stop Searching ->]

2. [ NIS ->]

If Information is Not Found: [ Stop Searching ->]
If Source is Not Configured: [ Try Next Source ->]

3. [ /etc/hosts ->]

4. [ none ->]

Modified the option of Stop Searching to Try Next Source, and then restarted the machine. After about 10 minutes, the machine finished startup. It succeeded to ping the machine itself. And when issuing the command ttisqlcs ds1, it also successfully connected. So the problems was finally solved.

After that when I inspected /etc directory, I found nsswitch.conf was changed.

nsswitch.conf:
hosts: dns [NOTFOUND=continue UNAVAIL=continue TRYAGAIN=continue] nis [NOTFOUND=continue UNAVAIL=continue TRYAGAIN=continue] files

nsswitch.conf.old:
hosts: dns [NOTFOUND=return UNAVAIL=continue TRYAGAIN=return] nis [NOTFOUND=return UNAVAIL=continue TRYAGAIN=continue] files

So actually we can modify the configuration file if we know that.

No comments:

Post a Comment