[mythtv-users] Mythfrontend can't ping database host

Michael T. Dean mtdean at thirdcontact.com
Mon Dec 31 14:38:47 UTC 2012


On 12/27/2012 02:17 AM, Bill Meek wrote:
> On 12/26/2012 11:20 PM, Nick Rout wrote:
> ...
>>>>>> Quoting Gabe Rubin:
>>>>>>
>>>>>>> Cannot find (ping) database host 192.168.1.101 on the network
> ...
>> Actually it has everything to do with mysql. It is the details myth 
>> needs
>> in order to log in to mysql, which it has to do pretty well as soon 
>> as it
>> starts.
>
> Hi;
>
> Sorry, it's not an issue with the database.
>
> The diagnostic Gabe posted originally, comes from a simple ping
> to the box that hosts the database. See:
>
>     
> http://code.mythtv.org/cgit/mythtv/tree/mythtv/libs/libmyth/mythcontext.cpp#n630
>
> His error message prints below at line 682. I guessing he's running
> on 0.25 since he references mysql.txt. Not so subtle hint to everyone
> that it's nice to mention the version you're running on.
>
> The test of the connection to the database happens on line 693. He also
> stated that without the ping, the frontend works.
>
> That's why I suggested running the frontend with -v system --loglevel 
> debug.
> It will print what happens when ping() runs the system call. He's already
> said he can ping the machine both from itself, and from a remote host.
>
> So, if the command line ping works, then we need to see what's 
> actually in
> the command being executed.
>
> As to why the ping is even being done at all, I believe it's because
> DBHostName=192.168.1.101, rather than 127.0.0.1, localhost or the
> value returned by the hostname command. Any one of the three would
> prevent the ping.
>

Yes, Bill is exactly correct.  MythTV uses the ping system utility, not 
mysqlping, to test to see if some host exists at the address specified.  
It's a very simple (though not super reliable) test performed since 
MythTV will not run without a valid database, so it can't run if it 
can't talk to the host with the database.

Note, also, that the ping utility is generally something that requires 
root permission in modern Linux systems.  This is generally handled for 
non-root users either by setting the sticky bit (which is ugly--and can 
result in an exploit finding a way to get root access to the system) or 
a capability allowing the process to send arbitrary packets to the 
network.  So, I recommend you check your ping command:

ls -l /bin/ping

and if the sticky bit isn't set, try:

/sbin/getcap /bin/ping

and if it doesn't show:

/bin/ping = cap_net_raw+ep

you should do:

sudo setcap cap_net_raw=ep /bin/ping

and if that doesn't work, you need to get your distro to properly fix 
the ping utility (either by enabling capabilities on the file system or 
whatever they feel is best :).

Note, also, that using a DB address that is not localhost, when on the 
same host, will result in seriously degraded database performance versus 
localhost.  Using Unix sockets (which is done automatically when you 
specify localhost for the MySQL server) is much faster than using TCP/IP 
networking (which is done for routable addresses.

While we say that you cannot have localhost or 127.0.0.1 anywhere in 
your MythTV system configuration when you're using multiple hosts in a 
MythTV system, you can use localhost in your MythTV database 
configuration on the MythTV host that is also the MySQL host--and, 
generally, may want to for a) much better communications performance, 
especially for large results, and b) better reliability (because it no 
longer depends on system networking support--which is especially nice 
for these distros with "managers" that like to pull the plug on all 
networking every time there's a blip in the connection or whatever).

If you have only one system, though--i.e. the database is always at 
localhost because you run your single combined frontend/backend system 
on the same host as your MySQL server--you can just change the 
DBHostName to localhost (or 127.0.0.1) and it will fix the issue and may 
result in much better performance, too.

Mike


More information about the mythtv-users mailing list