Re: bind-address by name under 5.0.18

2006-02-28 Thread Jeremy Cole

Hi James,


Sort of.  If I run the command manually, it does.

But my script uses su to run the server as an unprivileged user.

What happens if you:

su -m mysql -c 'sh -c /usr/local/bin/mysqld_safe  
--defaults-extra-file=/var/db/mysql/my.cnf --user=mysql --datadir=/var/db/mysql 
--pid-file=/var/db/mysql/www.example.com.pid --bind-address=localhost  /dev/null '


Hmm, I don't see why it shouldn't work when run inside su... odd.

As far as I know, there are no requirements for superuser in order to 
bind to certain IPs.


I'm also hopeful to get multi-IP support, so that I can have the 
server listen on two NICs or what-have-you, such as:


[mysqld]
bind_address=foo bar localhost


This is a reasonable feature request, and I'll try to do it (I don't see 
why it can't work).  It would require some changes to how the address to 
bind to are passed around (currently a variable called my_bind_addr).


I haven't tried that yet, so perhaps it is already functional as 
well, I'll try to get to testing that soon.


It's not.  Here's the code that handles bind-address from sql/mysqld.cc:

  6733case (int) OPT_BIND_ADDRESS:
  6734  if ((my_bind_addr= (ulong) inet_addr(argument)) == INADDR_NONE)
  6735  {
  6736struct hostent *ent;
  6737if (argument[0])
  6738  ent=gethostbyname(argument);
  6739else
  6740{
  6741  char myhostname[255];
  6742  if (gethostname(myhostname,sizeof(myhostname))  0)
  6743  {
  6744sql_perror(Can't start server: cannot get my own 
hostname!);

  6745exit(1);
  6746  }
  6747  ent=gethostbyname(myhostname);
  6748}
  6749if (!ent)
  6750{
  6751  sql_perror(Can't start server: cannot resolve hostname!);
  6752  exit(1);
  6753}
  6754my_bind_addr = (ulong) 
((in_addr*)ent-h_addr_list[0])-s_addr;

  6755  }
  6756  break;



And with other DBs, I can set 'sql.example.com' to resolve to N
IPs (N=4 in this example):

10.0.0.10
10.0.1.10
10.0.2.10
10.0.3.10

Then I can have N separate hosts share the same start-up script,
because the SQL server binds only to those IPs which are local.  Since
each of the N servers has only one of those IPs locally, each
server automatically binds to the correct IP.  And if the IPs ever
change, I just update DNS, and there's no need to do any maintenance
on the start-up scripts.  These IPs would not necessarily be in the 
same subnet and in fact, are CNAMEs, such as sql.example.com

defined as:

sql.example.com.IN  CNAME dallas-sql.example.com
sql.example.com.IN  CNAME cleveland-sql.example.com
sql.example.com.IN  CNAME portland-sql.example.com
sql.example.com.IN  CNAME sydney-sql.example.com

I am grateful to be making progress.  Thank you for your assistance.


Hmm, I guess you'd expect to at least get warnings for each of these 
that couldn't be bound to?


This seems like a very strange way to configure a machine.  To each, his 
own. :)


Regards,

Jeremy

--
Jeremy Cole
MySQL Geek, Yahoo! Inc.
Desk: 408 349 5104

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Re: bind-address by name under 5.0.18

2006-02-28 Thread James Long
6752  exit(1);
6753}
6754my_bind_addr = (ulong) 
 ((in_addr*)ent-h_addr_list[0])-s_addr;
6755  }
6756  break;
 
 
  And with other DBs, I can set 'sql.example.com' to resolve to N
  IPs (N=4 in this example):
  
  10.0.0.10
  10.0.1.10
  10.0.2.10
  10.0.3.10
  
  Then I can have N separate hosts share the same start-up script,
  because the SQL server binds only to those IPs which are local.  Since
  each of the N servers has only one of those IPs locally, each
  server automatically binds to the correct IP.  And if the IPs ever
  change, I just update DNS, and there's no need to do any maintenance
  on the start-up scripts.  These IPs would not necessarily be in the 
  same subnet and in fact, are CNAMEs, such as sql.example.com
  defined as:
  
  sql.example.com.IN  CNAME dallas-sql.example.com
  sql.example.com.IN  CNAME cleveland-sql.example.com
  sql.example.com.IN  CNAME portland-sql.example.com
  sql.example.com.IN  CNAME sydney-sql.example.com
  
  I am grateful to be making progress.  Thank you for your assistance.
 
 Hmm, I guess you'd expect to at least get warnings for each of these 
 that couldn't be bound to?

A *warning*, yes.  There's certainly no way to bind to an IP that isn't
local.  However, if the IP *is local*, and yet MySQL *still* can't bind to
it, that should be an *error*.

 This seems like a very strange way to configure a machine.  To each, his 
 own. :)

The advantage is that all the machines can have exactly the same configuration
(except for the ifconfig IP).  The sql start-up is exactly the same, and 
thus you only maintain 1 script instead of N.

Another case where this would be handy is on a machine with multiple NICs on
various LANs.  One might set a DNS to resolve to the N different IPs that
machine has, and then tell the SQL server to bind to that DNS name.  The
SQL server could then automatically answer queries on each of the IPs 
specified in DNS.


Jim

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Re: bind-address by name under 5.0.18

2006-02-27 Thread sheeri kritzer
It doesn't allow to bind to a hostname.  According to

http://dev.mysql.com/doc/refman/5.0/en/server-options.html

you have to specify an IP address, not a hostname.

-Sheeri

On 2/22/06, James Long [EMAIL PROTECTED] wrote:
 I would like to be able to bind to a host name, rather than
 an IP number.  IP numbers come and go, and are beyond the
 control of anyone who doesn't have their own direct allocation.
 But since I own my domain, a host name is more permanent.

 When the time comes to change IP numbers, I want to just edit
 /etc/hosts to show my new IP:

 10.0.0.10   shortname myrealname.example.com

 and use --bind-address=shortname in my start-up script to
 automatically pick up the new IP number.

 This eliminates the headache of having to find and fix umpteen
 literal IP numbers hiding in my startup scripts.  This is much
 the same reason one says '#define BLKSIZ 512' and then uses the
 constant 'BLKSIZ' instead of sprinkling literal '512's throughout
 one's code).

 Why doesn't bind-address allow this?  Or if it does, how can I
 accomplish this?


 Thanks!


 Jim

 --
 MySQL General Mailing List
 For list archives: http://lists.mysql.com/mysql
 To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Re: bind-address by name under 5.0.18

2006-02-27 Thread James Long
 It doesn't allow to bind to a hostname.  According to
 
 http://dev.mysql.com/doc/refman/5.0/en/server-options.html
 
 you have to specify an IP address, not a hostname.
 
 -Sheeri

Thanks for your reply.  Yes, I am aware of that, as stated in
my question.

Wouldn't it be an improvement if it did, though?  Currently, I
have to use an ugly grep/awk hack to grep the address out of
/etc/hosts.  Are there technical reasons that make it difficult
to write the code such that one could specify an IP or a hostname,
or a list of IPs and/or hostnames?

I'm looking for something similar to PostgreSQL's:

-h hostname
   Specifies the IP host name or address on which the postmaster is
   to  listen  for TCP/IP connections from client applications. The
   value can also be a space-separated list of addresses, or  *  to
   specify  listening  on  all available interfaces. An empty value
   specifies not listening on any IP addresses, in which case  only
   Unix-domain  sockets  can  be used to connect to the postmaster.
   Defaults to listening only on localhost.  Specifying this option
   is  equivalent  to  setting  the  listen_addresses configuration
   parameter.


 
 On 2/22/06, James Long [EMAIL PROTECTED] wrote:
  I would like to be able to bind to a host name, rather than
  an IP number.  IP numbers come and go, and are beyond the
  control of anyone who doesn't have their own direct allocation.
  But since I own my domain, a host name is more permanent.
 
  When the time comes to change IP numbers, I want to just edit
  /etc/hosts to show my new IP:
 
  10.0.0.10   shortname myrealname.example.com
 
  and use --bind-address=shortname in my start-up script to
  automatically pick up the new IP number.
 
  This eliminates the headache of having to find and fix umpteen
  literal IP numbers hiding in my startup scripts.  This is much
  the same reason one says '#define BLKSIZ 512' and then uses the
  constant 'BLKSIZ' instead of sprinkling literal '512's throughout
  one's code).
 
  Why doesn't bind-address allow this?  Or if it does, how can I
  accomplish this?
 
 
  Thanks!
 
 
  Jim
 
  --
  MySQL General Mailing List
  For list archives: http://lists.mysql.com/mysql
  To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
 
 
 


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Re: bind-address by name under 5.0.18

2006-02-27 Thread SGreen
Yes, there is a very good, not so technical reason to only allow binding 
by IP Address.  Have you ever heard of putting the cart before the horse 
?

If binding by hostname were allowed, that would mean that every time your 
MySQL server started up, it would need to somehow resolve that name into 
an address. In order to do that, it needs a socket it can use to contact a 
DNS server in order to change the hostname back into an address. Where 
does it get the socket? Without a socket, it cannot contact a DNS server 
so it cannot resolve it's hostname to an address and it will not be able 
to bind to a socket.

Binding is the process of giving a socket (an address and a port) to an 
application so that it has a point of contact on the internet. Without a 
socket an application has no way to communicate over TCP/IP or UDP/IP as 
there would be nowhere for the return messages to land. That is the simple 
reason why you cannot bind to a hostname.

Did I make sense?

Shawn Green
Database Administrator
Unimin Corporation - Spruce Pine

James Long [EMAIL PROTECTED] wrote on 02/27/2006 03:59:14 PM:

  It doesn't allow to bind to a hostname.  According to
  
  http://dev.mysql.com/doc/refman/5.0/en/server-options.html
  
  you have to specify an IP address, not a hostname.
  
  -Sheeri
 
 Thanks for your reply.  Yes, I am aware of that, as stated in
 my question.
 
 Wouldn't it be an improvement if it did, though?  Currently, I
 have to use an ugly grep/awk hack to grep the address out of
 /etc/hosts.  Are there technical reasons that make it difficult
 to write the code such that one could specify an IP or a hostname,
 or a list of IPs and/or hostnames?
 
 I'm looking for something similar to PostgreSQL's:
 
 -h hostname
Specifies the IP host name or address on which the postmaster is
to  listen  for TCP/IP connections from client applications. The
value can also be a space-separated list of addresses, or  *  to
specify  listening  on  all available interfaces. An empty value
specifies not listening on any IP addresses, in which case  only
Unix-domain  sockets  can  be used to connect to the postmaster.
Defaults to listening only on localhost.  Specifying this option
is  equivalent  to  setting  the  listen_addresses configuration
parameter.
 
 
  
  On 2/22/06, James Long [EMAIL PROTECTED] wrote:
   I would like to be able to bind to a host name, rather than
   an IP number.  IP numbers come and go, and are beyond the
   control of anyone who doesn't have their own direct allocation.
   But since I own my domain, a host name is more permanent.
  
   When the time comes to change IP numbers, I want to just edit
   /etc/hosts to show my new IP:
  
   10.0.0.10   shortname myrealname.example.com
  
   and use --bind-address=shortname in my start-up script to
   automatically pick up the new IP number.
  
   This eliminates the headache of having to find and fix umpteen
   literal IP numbers hiding in my startup scripts.  This is much
   the same reason one says '#define BLKSIZ 512' and then uses the
   constant 'BLKSIZ' instead of sprinkling literal '512's throughout
   one's code).
  
   Why doesn't bind-address allow this?  Or if it does, how can I
   accomplish this?
  
  
   Thanks!
  
  
   Jim
  
   --
   MySQL General Mailing List
   For list archives: http://lists.mysql.com/mysql
   To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]
  
  
  
 
 
 -- 
 MySQL General Mailing List
 For list archives: http://lists.mysql.com/mysql
 To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
 


Re: bind-address by name under 5.0.18

2006-02-27 Thread James Long
You seem to be unaware of /etc/hosts.

 Yes, there is a very good, not so technical reason to only allow binding 
 by IP Address.  Have you ever heard of putting the cart before the horse 
 ?
 
 If binding by hostname were allowed, that would mean that every time your 
 MySQL server started up, it would need to somehow resolve that name into 
 an address. In order to do that, it needs a socket it can use to contact a 
 DNS server in order to change the hostname back into an address. Where 
 does it get the socket? Without a socket, it cannot contact a DNS server 
 so it cannot resolve it's hostname to an address and it will not be able 
 to bind to a socket.

I can't speak for your machine, but on my servers, DNS is up before 
MySQL starts.

 Binding is the process of giving a socket (an address and a port) to an 
 application so that it has a point of contact on the internet. Without a 
 socket an application has no way to communicate over TCP/IP or UDP/IP as 
 there would be nowhere for the return messages to land. That is the simple 
 reason why you cannot bind to a hostname.
 
 Did I make sense?

Yes, but none of the information was new.

 Shawn Green
 Database Administrator
 Unimin Corporation - Spruce Pine
 
 James Long [EMAIL PROTECTED] wrote on 02/27/2006 03:59:14 PM:
 
   It doesn't allow to bind to a hostname.  According to
   
   http://dev.mysql.com/doc/refman/5.0/en/server-options.html
   
   you have to specify an IP address, not a hostname.
   
   -Sheeri
  
  Thanks for your reply.  Yes, I am aware of that, as stated in
  my question.
  
  Wouldn't it be an improvement if it did, though?  Currently, I
  have to use an ugly grep/awk hack to grep the address out of
  /etc/hosts.  Are there technical reasons that make it difficult
  to write the code such that one could specify an IP or a hostname,
  or a list of IPs and/or hostnames?
  
  I'm looking for something similar to PostgreSQL's:
  
  -h hostname
 Specifies the IP host name or address on which the postmaster is
 to  listen  for TCP/IP connections from client applications. The
 value can also be a space-separated list of addresses, or  *  to
 specify  listening  on  all available interfaces. An empty value
 specifies not listening on any IP addresses, in which case  only
 Unix-domain  sockets  can  be used to connect to the postmaster.
 Defaults to listening only on localhost.  Specifying this option
 is  equivalent  to  setting  the  listen_addresses configuration
 parameter.
  
  
   
   On 2/22/06, James Long [EMAIL PROTECTED] wrote:
I would like to be able to bind to a host name, rather than
an IP number.  IP numbers come and go, and are beyond the
control of anyone who doesn't have their own direct allocation.
But since I own my domain, a host name is more permanent.
   
When the time comes to change IP numbers, I want to just edit
/etc/hosts to show my new IP:
   
10.0.0.10   shortname myrealname.example.com
   
and use --bind-address=shortname in my start-up script to
automatically pick up the new IP number.
   
This eliminates the headache of having to find and fix umpteen
literal IP numbers hiding in my startup scripts.  This is much
the same reason one says '#define BLKSIZ 512' and then uses the
constant 'BLKSIZ' instead of sprinkling literal '512's throughout
one's code).
   
Why doesn't bind-address allow this?  Or if it does, how can I
accomplish this?
   
   
Thanks!
   
   
Jim
   
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]
   
   
   
  
  
  -- 
  MySQL General Mailing List
  For list archives: http://lists.mysql.com/mysql
  To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
  
 
 --=_alternative 0075136A85257122_=
 Content-Type: text/html; charset=US-ASCII
 
 
 brfont size=2 face=sans-serifYes, there is a very good, not so technical
 reason to only allow binding by IP Address. nbsp;Have you ever heard of
 quot;putting the cart before the horsequot; ?/font
 br
 brfont size=2 face=sans-serifIf binding by hostname were allowed,
 that would mean that every time your MySQL server started up, it would
 need to somehow resolve that name into an address. In order to do that,
 it needs a socket it can use to contact a DNS server in order to change
 the hostname back into an address. Where does it get the socket? Without
 a socket, it cannot contact a DNS server so it cannot resolve it's hostname
 to an address and it will not be able to bind to a socket./font
 br
 brfont size=2 face=sans-serifBinding is the process of giving a socket
 (an address and a port) to an application so that it has a point of contact
 on the internet. Without a socket an application has no way to communicate
 over TCP/IP or UDP/IP as there would be nowhere for the return messages
 to land. That is the simple reason why you 

Re: bind-address by name under 5.0.18

2006-02-27 Thread SGreen
Oh, no. I know about etc/hosts (even Windoze boxes has one). It's just 
normally not available for reference until you bind your socket library to 
at least one socket. Again, it's a cart and horse thing. You see, the 
etc/hosts file counts as a local DNS server and the DNS protocol 
requires a socket (

I am not aware of any IP stack that will allow an etc/hosts lookup until 
you have at least one socket established (though I could be wrong).

Shawn Green
Database Administrator
Unimin Corporation - Spruce Pine



James Long [EMAIL PROTECTED] wrote on 02/27/2006 04:26:37 PM:

 You seem to be unaware of /etc/hosts.
 
  Yes, there is a very good, not so technical reason to only allow 
binding 
  by IP Address.  Have you ever heard of putting the cart before the 
horse 
  ?
  
  If binding by hostname were allowed, that would mean that every time 
your 
  MySQL server started up, it would need to somehow resolve that name 
into 
  an address. In order to do that, it needs a socket it can use to 
contact a 
  DNS server in order to change the hostname back into an address. Where 

  does it get the socket? Without a socket, it cannot contact a DNS 
server 
  so it cannot resolve it's hostname to an address and it will not be 
able 
  to bind to a socket.
 
 I can't speak for your machine, but on my servers, DNS is up before 
 MySQL starts.
 
  Binding is the process of giving a socket (an address and a port) to 
an 
  application so that it has a point of contact on the internet. Without 
a 
  socket an application has no way to communicate over TCP/IP or UDP/IP 
as 
  there would be nowhere for the return messages to land. That is the 
simple 
  reason why you cannot bind to a hostname.
  
  Did I make sense?
 
 Yes, but none of the information was new.
 
  Shawn Green
  Database Administrator
  Unimin Corporation - Spruce Pine
  
  James Long [EMAIL PROTECTED] wrote on 02/27/2006 03:59:14 
PM:
  
It doesn't allow to bind to a hostname.  According to

http://dev.mysql.com/doc/refman/5.0/en/server-options.html

you have to specify an IP address, not a hostname.

-Sheeri
   
   Thanks for your reply.  Yes, I am aware of that, as stated in
   my question.
   
   Wouldn't it be an improvement if it did, though?  Currently, I
   have to use an ugly grep/awk hack to grep the address out of
   /etc/hosts.  Are there technical reasons that make it difficult
   to write the code such that one could specify an IP or a hostname,
   or a list of IPs and/or hostnames?
   
   I'm looking for something similar to PostgreSQL's:
   
   -h hostname
  Specifies the IP host name or address on which the postmaster is
  to  listen  for TCP/IP connections from client applications. The
  value can also be a space-separated list of addresses, or  *  to
  specify  listening  on  all available interfaces. An empty value
  specifies not listening on any IP addresses, in which case  only
  Unix-domain  sockets  can  be used to connect to the postmaster.
  Defaults to listening only on localhost.  Specifying this option
  is  equivalent  to  setting  the  listen_addresses configuration
  parameter.
   
   

On 2/22/06, James Long [EMAIL PROTECTED] wrote:
 I would like to be able to bind to a host name, rather than
 an IP number.  IP numbers come and go, and are beyond the
 control of anyone who doesn't have their own direct allocation.
 But since I own my domain, a host name is more permanent.

 When the time comes to change IP numbers, I want to just edit
 /etc/hosts to show my new IP:

 10.0.0.10   shortname myrealname.example.com

 and use --bind-address=shortname in my start-up script to
 automatically pick up the new IP number.

 This eliminates the headache of having to find and fix umpteen
 literal IP numbers hiding in my startup scripts.  This is much
 the same reason one says '#define BLKSIZ 512' and then uses the
 constant 'BLKSIZ' instead of sprinkling literal '512's 
throughout
 one's code).

 Why doesn't bind-address allow this?  Or if it does, how can I
 accomplish this?


 Thanks!


 Jim

 --
 MySQL General Mailing List
 For list archives: http://lists.mysql.com/mysql
 To unsubscribe: 
http://lists.mysql.com/[EMAIL PROTECTED]



   
   
   -- 
   MySQL General Mailing List
   For list archives: http://lists.mysql.com/mysql
   To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]
   
  
  --=_alternative 0075136A85257122_=
  Content-Type: text/html; charset=US-ASCII
  
  
  brfont size=2 face=sans-serifYes, there is a very good, not 
 so technical
  reason to only allow binding by IP Address. nbsp;Have you ever heard 
of
  quot;putting the cart before the horsequot; ?/font
  br
  brfont size=2 face=sans-serifIf binding by hostname were 
allowed,
  that would mean that every time your MySQL server started up, 

Re: bind-address by name under 5.0.18

2006-02-27 Thread James Long
 Oh, no. I know about etc/hosts (even Windoze boxes has one). It's just 
 normally not available for reference until you bind your socket library to 
 at least one socket. Again, it's a cart and horse thing. You see, the 
 etc/hosts file counts as a local DNS server and the DNS protocol 
 requires a socket (

But an *outgoing* socket for DNS lookups is different from 
the listening address the server binds to.

 I am not aware of any IP stack that will allow an etc/hosts lookup until 
 you have at least one socket established (though I could be wrong).

Look, with all due respect to your experience, I can assure
you that none of this is rocket science, nor is it a
chicken-and-egg sort of problem.  It's not impossible to do.
Other databases do it.  IANASE, but I should think a simple
call to gethostbyname(3) should do the trick:

 The structure returned contains either the information 
 obtained from the name server, named(8), broken-out fields 
 from a line in /etc/hosts, or database entries supplied by 
 the yp(8) system.  The order of the lookups is controlled 
 by the `hosts' entry in nsswitch.conf(5).

PostgreSQL's -h option is an example of the functionality
I'm trying to find in MySQL, as I posted in an earlier message
(on which you were not yet cc'ed, and which may not have hit the 
list yet).  It allows the administrator to specify a *list* of
IPs *OR* hostnames that the database server should bind to for
incoming client connections:

-h hostname

Specifies the IP host name or address on which the postmaster is
to  listen  for TCP/IP connections from client applications. The
value can also be a space-separated list of addresses, or  *  to
specify  listening  on  all available interfaces. An empty value
specifies not listening on any IP addresses, in which case  only
Unix-domain  sockets  can  be used to connect to the postmaster.
Defaults to listening only on localhost.  Specifying this option
is  equivalent  to  setting  the  listen_addresses configuration
parameter.

So I could start Postgres with -h localhost priv pub sql.example.com
and bind to those IPs.  Further, if those DNS names resolve to
multiple IPs, then Postgres will bind to as many of them as it
can find on the local machine.

How do I do that with MySQL?

Thanks again for taking the time to answer my questions.

Jim


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Re: bind-address by name under 5.0.18

2006-02-27 Thread Jeremy Cole

Hi James,


I would like to be able to bind to a host name, rather than
an IP number.  IP numbers come and go, and are beyond the
control of anyone who doesn't have their own direct allocation.  
But since I own my domain, a host name is more permanent.


Adding this functionality is fairly trivial, with the caveat that it 
will have to use the first address returned by gethostbyname(), so if 
you have multiple IPs assigned to a hostname (for e.g. round-robin DNS) 
it will be interesting. :)


This is probably a 5-10 line patch, including error checking.

Regards,

Jeremy

--
Jeremy Cole
MySQL Geek, Yahoo! Inc.
Desk: 408 349 5104

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Re: bind-address by name under 5.0.18

2006-02-27 Thread James Long
 Hi James,
 
  I would like to be able to bind to a host name, rather than
  an IP number.  IP numbers come and go, and are beyond the
  control of anyone who doesn't have their own direct allocation.  
  But since I own my domain, a host name is more permanent.
  Adding this functionality is fairly trivial, with the caveat that it 
  will have to use the first address returned by gethostbyname(), so if 
  you have multiple IPs assigned to a hostname (for e.g. round-robin DNS) 
  it will be interesting. :)
  
  Thanks for your reply.  Just for my edification, how come only one IP?
 
 Add another 10 lines and you should be able to make it bind to all IPs 
 returned.  Currently bind-address supports only one IP to bind to.
 
 This is a reasonable request, I'll take a crack at it.
 
 Regards,
 
 Jeremy

Thank you very much!  I'm willing to help test if you can provide me a diff 
of your changes.

Jim

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Re: bind-address by name under 5.0.18

2006-02-27 Thread Jeremy Cole

Hi,

Thank you very much!  I'm willing to help test if you can provide me a diff 
of your changes.


Well, that was easy.  I checked the code, and it turns out that the 
functionality is already there.  I just tested it on my laptop (running 
5.0.13) and it does indeed work.


I did:

* echo 10.0.0.1 foo  /etc/hosts
* ifconfig lo0 alias 10.0.0.1
* add to /etc/my.cnf:
  [mysqld]
  bind-address=foo
* restart mysqld
* mysql -h 10.0.0.1  -- confirm connection or error from mysqld
* mysql -h 127.0.0.1 -- confirm failure to connect at all

I didn't know that this worked.  Learn something new every day.

Are you having a problem with it?  Does it not work for you?

Regards,

Jeremy

--
Jeremy Cole
MySQL Geek, Yahoo! Inc.
Desk: 408 349 5104

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Re: bind-address by name under 5.0.18

2006-02-27 Thread James Long
 Hi,
 
  Thank you very much!  I'm willing to help test if you can provide me a diff 
  of your changes.
 
 Well, that was easy.  I checked the code, and it turns out that the 
 functionality is already there.  I just tested it on my laptop (running 
 5.0.13) and it does indeed work.
 
 I did:
 
 * echo 10.0.0.1 foo  /etc/hosts
 * ifconfig lo0 alias 10.0.0.1
 * add to /etc/my.cnf:
[mysqld]
bind-address=foo
 * restart mysqld
 * mysql -h 10.0.0.1  -- confirm connection or error from mysqld
 * mysql -h 127.0.0.1 -- confirm failure to connect at all
 
 I didn't know that this worked.  Learn something new every day.
 
 Are you having a problem with it?  Does it not work for you?


Sort of.  If I run the command manually, it does.

But my script uses su to run the server as an unprivileged user.

What happens if you:

su -m mysql -c 'sh -c /usr/local/bin/mysqld_safe  
--defaults-extra-file=/var/db/mysql/my.cnf --user=mysql --datadir=/var/db/mysql 
--pid-file=/var/db/mysql/www.example.com.pid --bind-address=localhost  
/dev/null '

I'm also hopeful to get multi-IP support, so that I can have the 
server listen on two NICs or what-have-you, such as:

[mysqld]
bind_address=foo bar localhost

I haven't tried that yet, so perhaps it is already functional as 
well, I'll try to get to testing that soon.

And with other DBs, I can set 'sql.example.com' to resolve to N
IPs (N=4 in this example):

10.0.0.10
10.0.1.10
10.0.2.10
10.0.3.10

Then I can have N separate hosts share the same start-up script,
because the SQL server binds only to those IPs which are local.  Since
each of the N servers has only one of those IPs locally, each
server automatically binds to the correct IP.  And if the IPs ever
change, I just update DNS, and there's no need to do any maintenance
on the start-up scripts.  These IPs would not necessarily be in the 
same subnet and in fact, are CNAMEs, such as sql.example.com
defined as:

sql.example.com.IN  CNAME dallas-sql.example.com
sql.example.com.IN  CNAME cleveland-sql.example.com
sql.example.com.IN  CNAME portland-sql.example.com
sql.example.com.IN  CNAME sydney-sql.example.com



I am grateful to be making progress.  Thank you for your assistance.


Jim


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]