Home > Archive > MySQL ODBC Connector > February 2006 > bind-address by name under 5.0.18









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author bind-address by name under 5.0.18
James Long

2006-02-25, 9:43 am

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/mysql? unsub...sie.nctu.edu.tw

sheeri kritzer

2006-02-28, 8:28 pm

It doesn't allow to bind to a hostname. According to

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

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

-Sheeri

On 2/22/06, James Long < james_mapson@umpquan
et.com> 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=3Dshortname" 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/mysql? unsub...mail
.com

>
>


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql? unsub...sie.nctu.edu.tw

James Long

2006-02-28, 8:28 pm

> It doesn't allow to bind to a hostname. According to
>
> http://dev.mysql.com/doc/refman/5.0...er-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 < james_mapson@umpquan
et.com> wrote:
>



--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql? unsub...sie.nctu.edu.tw

SGreen@unimin.com

2006-02-28, 8:28 pm

--=_alternative 0075136A85257122_=
Content-Type: text/plain; charset="US-ASCII"

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 < james_mapson@umpquan
et.com> wrote on 02/27/2006 03:59:14 PM:

>
> 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.
>
>
>
>
> --
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe: http://lists.mysql.com/mysql?unsub=sgreen@unimin.com
>


--=_alternative 0075136A85257122_=--
James Long

2006-02-28, 8:28 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 < james_mapson@umpquan
et.com> wrote on 02/27/2006 03:59:14 PM:
>
>
> --=_alternative 0075136A85257122_=
> Content-Type: text/html; charset="US-ASCII"
>
>
> <br><font size=2 face="sans-serif">Yes, there is a very good, not so technical
> reason to only allow binding by IP Address. &nbsp;Have you ever heard of
> "putting the cart before the horse" ?</font>
> <br>
> <br><font size=2 face="sans-serif">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.</font>
> <br>
> <br><font size=2 face="sans-serif">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.</font>
> <br>
> <br><font size=2 face="sans-serif">Did I make sense?</font>
> <br>
> <br><font size=2 face="sans-serif">Shawn Green<br>
> Database Administrator<br>
> Unimin Corporation - Spruce Pine</font>
> <br>
> <br><font size=2><tt>James Long & lt;james_mapson@umpq
uanet.com&gt; wrote
> on 02/27/2006 03:59:14 PM:<br>
> <br>
> &gt; &gt; It doesn't allow to bind to a hostname. &nbsp;According to<br>
> &gt; &gt; <br>
> &gt; &gt; http://dev.mysql.com/doc/refman/5.0...er-options.html<br>
> &gt; &gt; <br>
> &gt; &gt; you have to specify an IP address, not a hostname.<br>
> &gt; &gt; <br>
> &gt; &gt; -Sheeri<br>
> &gt; <br>
> &gt; Thanks for your reply. &nbsp;Yes, I am aware of that, as stated in<br>
> &gt; my question.<br>
> &gt; <br>
> &gt; Wouldn't it be an improvement if it did, though? &nbsp;Currently,
> I<br>
> &gt; have to use an ugly grep/awk hack to grep the address out of<br>
> &gt; /etc/hosts. &nbsp;Are there technical reasons that make it difficult<br>
> &gt; to write the code such that one could specify an IP or a hostname,<br>
> &gt; or a list of IPs and/or hostnames?<br>
> &gt; <br>
> &gt; I'm looking for something similar to PostgreSQL's:<br>
> &gt; <br>
> &gt; -h hostname<br>
> &gt; &nbsp; &nbsp;Specifies the IP host name or address on which the postmaster
> is<br>
> &gt; &nbsp; &nbsp;to &nbsp;listen &nbsp;for TCP/IP connections from client
> applications. The<br>
> &gt; &nbsp; &nbsp;value can also be a space-separated list of addresses,
> or &nbsp;* &nbsp;to<br>
> &gt; &nbsp; &nbsp;specify &nbsp;listening &nbsp;on &nbsp;all available
> interfaces. An empty value<br>
> &gt; &nbsp; &nbsp;specifies not listening on any IP addresses, in which
> case &nbsp;only<br>
> &gt; &nbsp; &nbsp;Unix-domain &nbsp;sockets &nbsp;can &nbsp;be used to
> connect to the postmaster.<br>
> &gt; &nbsp; &nbsp;Defaults to listening only on localhost. &nbsp;Specifying
> this option<br>
> &gt; &nbsp; &nbsp;is &nbsp;equivalent &nbsp;to &nbsp;setting &nbsp;the
> & amp;nbsp;listen_addr
esses configuration<br>
> &gt; &nbsp; &nbsp;parameter.<br>
> &gt; <br>
> &gt; <br>
> &gt; &gt; <br>
> &gt; &gt; On 2/22/06, James Long & lt;james_mapson@umpq
uanet.com&gt; wrote:<br>
> &gt; &gt; &gt; I would like to be able to bind to a host name, rather than<br>
> &gt; &gt; &gt; an IP number. &nbsp;IP numbers come and go, and are beyond
> the<br>
> &gt; &gt; &gt; control of anyone who doesn't have their own direct allocation.<br>
> &gt; &gt; &gt; But since I own my domain, a host name is more permanent.<br>
> &gt; &gt; &gt;<br>
> &gt; &gt; &gt; When the time comes to change IP numbers, I want to just
> edit<br>
> &gt; &gt; &gt; /etc/hosts to show my new IP:<br>
> &gt; &gt; &gt;<br>
> &gt; &gt; &gt; 10.0.0.10 &nbsp; &nbsp; &nbsp; shortname myrealname.example.com<br>
> &gt; &gt; &gt;<br>
> &gt; &gt; &gt; and use "--bind-address=shortname" in my start-up
> script to<br>
> &gt; &gt; &gt; automatically pick up the new IP number.<br>
> &gt; &gt; &gt;<br>
> &gt; &gt; &gt; This eliminates the headache of having to find and fix umpteen<br>
> &gt; &gt; &gt; literal IP numbers hiding in my startup scripts. &nbsp;This
> is much<br>
> &gt; &gt; &gt; the same reason one says '#define BLKSIZ 512' and then uses
> the<br>
> &gt; &gt; &gt; constant 'BLKSIZ' instead of sprinkling literal '512's throughout<br>
> &gt; &gt; &gt; one's code).<br>
> &gt; &gt; &gt;<br>
> &gt; &gt; &gt; Why doesn't bind-address allow this? &nbsp;Or if it does,
> how can I<br>
> &gt; &gt; &gt; accomplish this?<br>
> &gt; &gt; &gt;<br>
> &gt; &gt; &gt;<br>
> &gt; &gt; &gt; Thanks!<br>
> &gt; &gt; &gt;<br>
> &gt; &gt; &gt;<br>
> &gt; &gt; &gt; Jim<br>
> &gt; &gt; &gt;<br>
> &gt; &gt; &gt; --<br>
> &gt; &gt; &gt; MySQL General Mailing List<br>
> &gt; &gt; &gt; For list archives: http://lists.mysql.com/mysql<br>
> &gt; &gt; &gt; To unsubscribe: &nbsp; &nbsp;http://lists.mysql.com/mysql?unsub=awfief@gmail.com<br>
> &gt; &gt; &gt;<br>
> &gt; &gt; &gt;<br>
> &gt; &gt; <br>
> &gt; <br>
> &gt; <br>
> &gt; -- <br>
> &gt; MySQL General Mailing List<br>
> &gt; For list archives: http://lists.mysql.com/mysql<br>
> &gt; To unsubscribe: &nbsp; &nbsp;http://lists.mysql.com/mysql?unsub=sgreen@unimin.com<br>
> &gt; <br>
> </tt></font>
> --=_alternative 0075136A85257122_=--
>



--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql? unsub...sie.nctu.edu.tw

SGreen@unimin.com

2006-02-28, 8:28 pm

--=_alternative 0078008485257122_=
Content-Type: text/plain; charset="US-ASCII"

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 < james_mapson@umpquan
et.com> wrote on 02/27/2006 04:26:37 PM:

> You seem to be unaware of /etc/hosts.
>
binding[color=darkre
d]
horse"[color=darkred]
your[color=darkred]
into[color=darkred]
contact a[color=darkred]
[color=darkred]
server[color=darkred
]
able[color=darkred]
>
> I can't speak for your machine, but on my servers, DNS is up before
> MySQL starts.
>
an[color=darkred]
a[color=darkred]
as[color=darkred]
simple[color=darkred
]
>
> Yes, but none of the information was new.
>
PM:[color=darkred]
throughout[color=dar
kred]
http://lists.mysql.com/mysql?unsub=awfief@gmail.com[color=darkred]
> so technical
of[color=darkred]
allowed,[color=darkr
ed]
that,[color=darkred]

change[color=darkred
]
Without[color=darkre
d]
hostname[color=darkr
ed]
socket[color=darkred
]
contact[color=darkre
d]
communicate[color=da
rkred]
messages[color=darkr
ed]
hostname.</font>[color=darkred]
wrote[color=darkred]

to<br>[color=darkred]
http://dev.mysql.com/doc/refman/5.0...er-options.html<br>[color=darkred]
in<br>[color=darkred]
> difficult<br>
hostname,<br>[color=darkred]
> the postmaster
client[color=darkred
]
addresses,[color=dar
kred]
which[color=darkred]

& amp;nbsp;Specifying[
color=darkred]
> com&gt; wrote:<br>
> rather than<br>
beyond[color=darkred
]
> allocation.<br>
permanent.<br>[color=darkred]
just[color=darkred]
> myrealname.example.com<br>
start-up[color=darkred]
> fix umpteen<br>
& amp;nbsp;This[color=
darkred]
uses[color=darkred]
> '512's throughout<br>
does,[color=darkred]

> com/mysql?unsub=awfief@gmail.com<br>
> unsub=sgreen@unimin.com<br>
>


--=_alternative 0078008485257122_=--
James Long

2006-02-28, 8:28 pm

> 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/mysql? unsub...sie.nctu.edu.tw

Jeremy Cole

2006-02-28, 8:28 pm

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/mysql? unsub...sie.nctu.edu.tw

James Long

2006-02-28, 8:28 pm

> Hi James,
>
>
> 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/mysql? unsub...sie.nctu.edu.tw

Jeremy Cole

2006-02-28, 8:28 pm

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/mysql? unsub...sie.nctu.edu.tw

James Long

2006-02-28, 8:28 pm

> Hi,
>
>
> 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/mysql? unsub...sie.nctu.edu.tw

Jeremy Cole

2006-02-28, 8:28 pm

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:

6733 case (int) OPT_BIND_ADDRESS:
6734 if ((my_bind_addr= (ulong) inet_addr(argument))
== INADDR_NONE)
6735 {
6736 struct hostent *ent;
6737 if (argument[0])
6738 ent=gethostbyname(ar
gument);
6739 else
6740 {
6741 char myhostname[255];
6742 if (gethostname(myhostn
ame,sizeof(myhostnam
e)) < 0)
6743 {
6744 sql_perror("Can't start server: cannot get my own
hostname!");
6745 exit(1);
6746 }
6747 ent=gethostbyname(my
hostname);
6748 }
6749 if (!ent)
6750 {
6751 sql_perror("Can't start server: cannot resolve hostname!");
6752 exit(1);
6753 }
6754 my_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/mysql? unsub...sie.nctu.edu.tw

James Long

2006-02-28, 8:28 pm

> 6752 exit(1);
> 6753 }
> 6754 my_bind_addr = (ulong)
> ((in_addr*)ent->h_addr_list[0])->s_addr;
> 6755 }
> 6756 break;
>
>
>
> 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/mysql? unsub...sie.nctu.edu.tw

Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2009 droptable.com