System Table with Node Hostname

Moderator: NorbertKrupa

User avatar
Julie
Master
Master
Posts: 221
Joined: Thu Apr 19, 2012 9:29 pm

System Table with Node Hostname

Post by Julie » Tue Aug 13, 2013 8:23 pm

Hi guys,

Is there a way in Vertica to determine a node's host name? I know the V_CATALOG.NODES table has the NODE_ADDRESS column, but that seems to bet he IP address.
Thanks,
Juliette

User avatar
nnani
Master
Master
Posts: 302
Joined: Fri Apr 13, 2012 6:28 am
Contact:

Re: System Table with Node Hostname

Post by nnani » Wed Aug 14, 2013 7:16 am

Hello Julie

How about using the v_catalog.nodes table and retrieving the node name

Code: Select all

nnani=> select node_name,node_address from nodes;
    node_name     | node_address
------------------+--------------
 nnani_01 | xxx.xx.xx.xx

I thing Vertica derives the node names from the hosts file that we configure before installation.

Hope this helps..
nnani........
Long way to go

You can check out my blogs at vertica-howto

User avatar
nnani
Master
Master
Posts: 302
Joined: Fri Apr 13, 2012 6:28 am
Contact:

Re: System Table with Node Hostname

Post by nnani » Wed Aug 14, 2013 7:53 am

Hello Juile,

I did not get your question at first, :) but You might be interested this one.
This one gives you the hostname of the node you are connected to.

Open the vsqlrc file and set the variables like this

Code: Select all

-----------------------------------------------------------------------------------------------
--setting the variables in vertica to retrieve the hostname
-----------------------------------------------------------------------------------------------

\set hname `uname -n`

\set hostname ''''`uname -n''''
Now that the variables are set you can restart the session and try this

Code: Select all

\echo :hname
host_01

select :hostname from dual;
host_01
Hope this helps..
nnani........
Long way to go

You can check out my blogs at vertica-howto

id10t
GURU
GURU
Posts: 732
Joined: Mon Apr 16, 2012 2:44 pm

Re: System Table with Node Hostname

Post by id10t » Wed Aug 14, 2013 8:32 am

Hi!

@nnani
Too much complex ;)

Code: Select all

vsql=> \! hostname
synapse
vsql=> 
PS
The problem of your solution (as mine too) that `hostname` or `uname` executed on host where vsql is running and not on Vertica host, so it's a OS solution and not as Julie asked - that Vertica will determine a host name.

User avatar
Julie
Master
Master
Posts: 221
Joined: Thu Apr 19, 2012 9:29 pm

Re: System Table with Node Hostname

Post by Julie » Wed Aug 14, 2013 12:56 pm

Hey, thanks for the great responses! I figured the database must keep either the hostname or the IP address of the server depending on how the nodes are specified in the -s option of the install_vertica script. I know I used the IP address, hence I can only see the IP address in the catalog data. Oh well.

So, what would you guys suggest? When installing Vertica, is it better to use host names or IP addresses? Probably hostname, right? It has less of a chance of changing :roll:
Thanks,
Juliette

id10t
GURU
GURU
Posts: 732
Joined: Mon Apr 16, 2012 2:44 pm

Re: System Table with Node Hostname

Post by id10t » Wed Aug 14, 2013 3:38 pm

Hi!

Vertica always will use in IP (doesn't matter what are install options), because hostname - it's internal system info (Vertica resolves hostnames via /etc/hosts)

FYI: you can change a hotname while Vertica is running, so hostname its for humans only, Vertica always will use in IP ;)
That's why Vertica don't use in hostnames.

Code: Select all

daniel=> \! hostname
synapse
daniel=> \! sudo hostname romeojuliet
[sudo] password for daniel: 
daniel=> \! hostname
romeojuliet
daniel=> 
\q
daniel@synapse:~$ hostname
romeojuliet
daniel@synapse:~$ 
daniel@synapse:~$ vsql
Welcome to vsql, the Vertica Analytic Database interactive terminal.

Type:  \h or \? for help with vsql commands
       \g or terminate with semicolon to execute query
       \q to quit

daniel=> \! hostname
romeojuliet
>> When installing Vertica, is it better to use host names or IP addresses? Probably hostname, right?
Doesn't matter. As I already pointed - Vertica will use in IP anyway. Personally, I prefer IPs, but if you use in DHCP - so hostnames, because, as you pointed, IPs can change with reboot(that should never occur on prod database, so IPs should never change even with DHCP, but... )
If you don't use in DHCP, so IPs. (If your SysAdmin is a good, so he will not use in DHCP for cluster, but if he do - so change your SysAdmin on next reboot ;))) )

PS
I don't know how to do what you asked - only by storing it in some table.

User avatar
Julie
Master
Master
Posts: 221
Joined: Thu Apr 19, 2012 9:29 pm

Re: System Table with Node Hostname

Post by Julie » Wed Aug 14, 2013 4:02 pm

#sKwa,

I was just curious if we could get the host name from one of the system tables. According to the SQL documentation the HOST_RESOURCES table has a column called HOST_NAME, where the description for this column is "The host name for which information is listed.". But when I query the table I get an IP address and not a host name. No big deal...
If your SysAdmin is a good, so he will not use in DHCP for cluster, but if he do - so change your SysAdmin on next reboot
That is hilarious :lol:
Thanks,
Juliette

Post Reply

Return to “Vertica Database Administration”