Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 942
  • Last Modified:

MySQL bind-address Help

HI experts,

Can you please help me understand the error below? I set the bind-address to 127.0.0.1. In my tomcat startup log i see the error (Java.net.BindException: Address already in use). Where have i gone wrong?

My goal is to allow local access only. Here is the relevant part of my.cnf file. If you need rest of file please advise.

Thank you.

[client]
port = 3306
socket = /tmp/mysql.sock

[mysqld]
port = 3306
bind-address = 127.0.0.1

socket = /tmp/mysql.sock
skip-external-locking
#skip-bdb

#...truncated

Open in new window



Aug 29, 2012 8:01:42 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 1405 ms
Aug 29, 2012 8:01:42 PM org.apache.catalina.core.StandardServer await
SEVERE: StandardServer.await: create[localhost:8005]:
java.net.BindException: Address already in use
  at java.net.PlainSocketImpl.socketBind(Native Method)
  at java.net.AbstractPlainSocketImpl.bind(AbstractPlainSocketImpl.java:376)
  at java.net.ServerSocket.bind(ServerSocket.java:376)
  at java.net.ServerSocket.<init>(ServerSocket.java:237)
  at org.apache.catalina.core.StandardServer.await(StandardServer.java:427)
  at org.apache.catalina.startup.Catalina.await(Catalina.java:757)
  at org.apache.catalina.startup.Catalina.start(Catalina.java:703)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.lang.reflect.Method.invoke(Method.java:601)
  at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:322)
  at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:451)

Open in new window

0
Gregg
Asked:
Gregg
  • 6
  • 5
2 Solutions
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
2 mysql servers, for example ...
at least, that is the usual issue.
maybe you try to run mysql "manually" (from command line), and it's still/already running in service/deamon mode, using the same config.

check this output (I presume you are on *nix world)
ps -eaf | grep mysql
0
 
CEHJCommented:
You're trying to create > 1 instance of Tomcat on the same port (8005) Nothing to do with MySQL


SEVERE: StandardServer.await: create[localhost:8005]:
java.net.BindException: Address already in use

Open in new window

0
 
GreggAuthor Commented:
Thanks for quick responses,

angelIII, I ran the command with the following output:
$ ps -eaf | grep mysql
   mysql 27659 27112   0 19:45:11 ?           0:02 /opt/local/sbin/mysqld --user=mysql --basedir=/opt/local --datadir=/var/mysql -
   admin 13213 13203   0 21:36:54 pts/3       0:00 grep mysql
$

Open in new window


Doesnt this show only one process running for mysql?

CEHJ, Is it possible you are able to explain more about error? I have no idea where I might have made a change that caused that. Ill keep searching in the meantime.

I appreciate the assistance. Thanks.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
CEHJCommented:
CEHJ, Is it possible you are able to explain more about error?

I don't know what more i can say other than for some reason you're either

a. trying to start Tomcat twice on the same port
b. trying to start Tomcat when something already is running on 8005
0
 
GreggAuthor Commented:
Yeah...I understand. I thought it might be worth asking to find a starting point.

Im poking around in all log files. I hope to solve myself. If I'm unable to figure it out - ill post more.

Thanks. :)
0
 
CEHJCommented:
How and when are you starting Tomcat?
0
 
GreggAuthor Commented:
I had set up an entry in Solaris SMF.

Here is the SMF Log:
[ Aug 29 22:02:25 Stopping because service disabled. ]
[ Aug 29 22:02:25 Executing stop method ("/opt/local/java/tomcat7/bin/shutdown.sh"). ]
[ Aug 29 22:02:25 Method "stop" exited with status 0. ]
[ Aug 29 22:02:39 Enabled. ]
[ Aug 29 22:02:39 Executing start method ("/opt/local/java/tomcat7/bin/startup.sh"). ]
[ Aug 29 22:02:40 Method "start" exited with status 0. ]
[ Aug 29 22:10:11 Stopping because service disabled. ]
[ Aug 29 22:10:11 Executing stop method ("/opt/local/java/tomcat7/bin/shutdown.sh"). ]
[ Aug 29 22:10:12 Method "stop" exited with status 0. ]
[ Aug 29 22:10:25 Enabled. ]
[ Aug 29 22:10:25 Executing start method ("/opt/local/java/tomcat7/bin/startup.sh"). ]
[ Aug 29 22:10:25 Method "start" exited with status 0. ]
[ Aug 29 22:14:34 Stopping because service disabled. ]
[ Aug 29 22:14:34 Executing stop method ("/opt/local/java/tomcat7/bin/shutdown.sh"). ]
[ Aug 29 22:14:35 Method "stop" exited with status 0. ]
[ Aug 29 22:14:51 Enabled. ]
[ Aug 29 22:14:51 Executing start method ("/opt/local/java/tomcat7/bin/startup.sh"). ]
[ Aug 29 22:14:51 Method "start" exited with status 0. ]

Open in new window


My SMF Manifest File:
<?xml version="1.0" ?>
    <!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml dtd/service_bundle.dtd.1">
    <service_bundle type='manifest' name='Tomcat7'>
    <service name='application/servers/tomcat' type='service' version='1'>
    <create_default_instance enabled='false' />
    <single_instance/>
    <exec_method type='method' name='start'
    exec='/opt/local/java/tomcat7/bin/startup.sh'
    timeout_seconds='30' >
    <method_context>
    <method_credential user='tomcat' group='tomcat' privileges='basic,net_privaddr' />
    <method_environment>
    <envvar name="CATALINA_BASE" value="/opt/local/java/tomcat7" />
    <envvar name="CATALINA_HOME" value="/opt/local/java/tomcat7" />
    <envvar name="CATALINA_TMPDIR" value="/opt/local/java/tomcat7/temp" />
    <envvar name="JAVA_HOME" value="/opt/local/java/jdk7" />
    </method_environment>
    </method_context>
    </exec_method>
    <exec_method type='method' name='stop'
    exec='/opt/local/java/tomcat7/bin/shutdown.sh'
    timeout_seconds='60' >
    <method_context>
    <method_credential user='tomcat' group='tomcat' />
    <method_environment>
    <envvar name="CATALINA_BASE" value="/opt/local/java/tomcat7" />
    <envvar name="CATALINA_HOME" value="/opt/local/java/tomcat7" />
    <envvar name="CATALINA_TMPDIR" value="/opt/local/java/tomcat7/temp" />
    <envvar name="JAVA_HOME" value="/opt/local/java/jdk7" />
    </method_environment>
    </method_context>
    </exec_method>
    <stability value='Unstable' />
    <template>
    <common_name>
    <loctext xml:lang='C'> Tomcat </loctext>
    </common_name>
    </template>
    </service>
    </service_bundle>

Open in new window

0
 
CEHJCommented:
I don't know Solaris, so can't say whether that looks normal or not. I would get this question added to the Solaris TA if you can (or nearest if that doesn't exist)

I doubt that is causing a problem, as it has

<single_instance/>

Open in new window


which would prevent the problem i alluded to. So i would say that either

a. something/someone ELSE is trying to start Tomcat
b. there's a lingering socket on 8005 preventing restart
0
 
GreggAuthor Commented:
Thank you both. I decided to just reprovision the machine. Its good practice (...from the installation perspective). Ill save trouble shooting practice for another day. :)
0
 
CEHJCommented:
:)
0
 
GreggAuthor Commented:
So I reprovisioned my server. Im sure most would say, "what an idiot."... Im okay with that - this is more of a hobby.

After reformatting my server, I came across the same issue. This time it was for port 8080. java.net.BindException: Address already in use:8080

Clearly I did the same thing again. I am confident it has to do with stopping and starting Tomcat over and over and over... Originally I thought this had to do with mySQL. Thanks to CEHJ I learned it has nothing to do with mySQL. I just happened to be working with the /etc/my.cfg configuration file at the time.

I wanted to post that I found these two articles to be useful in my situation. Thanks to Kees Jan at Java-Monitor Forums for posting a great explanation on what is going on.

He points out "rebooting a machine is the computing equivalent of carpet bombing", in my case, reformatting my machine is exponentially more ignorant (is my ignorance really quantifiable?). He provides an easy to understand solution by finding the process ID and killing it.

Its funny, I remember my eyes glazing over when we covered process ids in my linux class. Now I am paying for overlooking the importance of processes.

The second resource I found useful was a simple shell script to find the PID number on solaris. I do not have lsof tool installed on my server so I opted for the shell script.

Putting the two together I was able to find my process ID and kill it. This is a great eye opener to the importance of the process ID. I have so much to learn still and I hope this might help someone down the road.
0
 
CEHJCommented:
He points out "rebooting a machine is the computing equivalent of carpet bombing"
I suspect you're more used to using Windows ;) There the usual tech support approach is "have you tried turning it off and then on again?" In the Unix world you should really be measuring months between reboots (for a server).
That's not to say that Windows doesn't have process ids btw - see taskkill
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 6
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now