LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 06-16-2012, 01:01 AM   #1
sanjay87
Member
 
Registered: Oct 2011
Posts: 164

Rep: Reputation: Disabled
how to start mysql server & apache server at startup and then tomcat at last at boot


HI all

I have webserver running following application apache mysql tomcat .I had made chkconfig level enable for httpd mysql tomcat at startup .But i could find apache startup first and then tomcat and then mysql startup third ,So my tomcat application fail to startup due to my mysql it could not connect since it startup at last of boot .How can i set boot priority to make httpd mysql and tomcat to boot at my boot level.


Quote:
How can i set Boot priority in chkconfig in order of Boot apache first second mysql then at last tomcat application








Quote:
** BEGIN NESTED EXCEPTION **


2012-Jun-07 08:53:27:401(MasterDataApplicationScopeListener.java:contextInitialized:75)-contextInitialized(ServletContextEvent) - start
2012-Jun-07 08:53:28:743(JDBCExceptionReporter.java:logExceptions:72)-Communications link failure due to underlying exception:

java.net.SocketException
MESSAGE: java.net.ConnectException: Connection refused

STACKTRACE:

java.net.SocketException: java.net.ConnectException: Connection refused
at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:156)
at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:284)
at com.mysql.jdbc.Connection.createNewIO(Connection.java:2555)
at com.mysql.jdbc.Connection.<init>(Connection.java:1485)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:266)
at java.sql.DriverManager.getConnection(DriverManager.java:582)
at java.sql.DriverManager.getConnection(DriverManager.java:154)
at org.springframework.jdbc.datasource.DriverManagerDataSource.getConnectionFromDriverManager(DriverMan agerDataSource.java:174)
at org.springframework.jdbc.datasource.DriverManagerDataSource.getConnectionFromDriver(DriverManagerDat aSource.java:165)

Last edited by sanjay87; 06-16-2012 at 01:26 AM.
 
Old 06-16-2012, 01:24 AM   #2
centos123
Member
 
Registered: Apr 2011
Posts: 397

Rep: Reputation: 16
just run

chkconfig mysqld on
chkconfig httpd on

whenever you boot your system its services start automatically always....
 
Old 06-16-2012, 01:28 AM   #3
sanjay87
Member
 
Registered: Oct 2011
Posts: 164

Original Poster
Rep: Reputation: Disabled
Yes Wright i had made chkconfig level enabled But apache tomcat startuping up first and then mysql get starting up at boot level .thats my problem ,Since tomcat startup fails Due to mysql startup later after tomcat application start .
 
Old 06-16-2012, 03:39 AM   #4
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,165
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Hi,

You should change the startup order of these services. Check /etc/rc.3.d
Code:
ls -l /etc/rc.3.d
to see the startup order of apache an tomcat and change mysql's order to a minor number, so it starts first.
E.g. in centos
Code:
ls -l /etc/rc3.d/*http*  /etc/rc3.d/*mysql*
lrwxrwxrwx. 1 root root 16 Jun 15 14:20 /etc/rc3.d/S64mysqld -> ../init.d/mysqld
lrwxrwxrwx. 1 root root 15 Jun 14 18:38 /etc/rc3.d/S85httpd -> ../init.d/httpd
So open /etc/init.d/mysqld, find the line
Quote:
# chkconfig: - 64 36
and change it to something like
Code:
# chkconfig: - 50 36
50 is the new starting priority. Must be less from the one of apache (85 in my case, see the above ls output) and the one of tomcat (I don't run it, so I don't know its priority)
After that run
Code:
chkconfig  mysqld resetpriorities
Regards
 
Old 06-16-2012, 04:26 AM   #5
sanjay87
Member
 
Registered: Oct 2011
Posts: 164

Original Poster
Rep: Reputation: Disabled
[root@example rc3.d]# ls -l /etc/rc3.d/*httpd* /etc/rc3.d/*mysql* /etc/rc3.d/*tomcat*
lrwxrwxrwx. 1 root root 16 Jun 15 23:30 /etc/rc3.d/S64mysqld -> ../init.d/mysqld
lrwxrwxrwx. 1 root root 16 Jun 15 23:30 /etc/rc3.d/S73tomcat -> ../init.d/tomcat
lrwxrwxrwx. 1 root root 15 Jun 15 23:30 /etc/rc3.d/S85httpd -> ../init.d/httpd
[root@example rc3.d]# cd
[root@example ~]# vi /etc/init.d/mysqld



Quote:
vi /etc/init.d/mysqld
#!/bin/sh
#
# mysqld This shell script takes care of starting and stopping
# the MySQL subsystem (mysqld).
#
Quote:
chkconfig: - 50 36
# description: MySQL database server.
# processname: mysqld
# config: /etc/my.cnf
# pidfile: /var/run/mysqld/mysqld.pid

# Source function library.
. /etc/rc.d/init.d/functions

# Source networking configuration.
[root@example ~]# service mysqld restart
/etc/init.d/mysqld: line 6: chkconfig:: command not found
Stopping mysqld: [ OK ]
Starting mysqld: [ OK ]
[root@example ~]# vi /etc/init.d/mysqld


tomcat service

Quote:
#!/bin/bash
# chkconfig: - 73 37
#
# processname: tomcat
# pidfile: /var/run/tomcat.pid

CATALINA_PID=/var/run/tomcat.pid

JAVA_OPTS="-server -Xms1024m -Xmx1024m -XX:MaxPermSize=512m"

CATALINA_HOME=/tomcat/apache-tomcat-6.0.16/

CATALINA_BASE=/tomcat/apache-tomcat-6.0.16/


Then too it shows same problem

Last edited by sanjay87; 06-16-2012 at 04:35 AM.
 
Old 06-16-2012, 08:19 AM   #6
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,165
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Quote:
[root@example ~]# service mysqld restart
/etc/init.d/mysqld: line 6: chkconfig:: command not found
What distro are you running? You mentioned in your previous post that you did the chkconfig stuff, so I thought you're running a RHEL based distro.
Anyway, you can rename the /etc/rc3.d/S73tomcat symlink to /etc/rc3.d/S99tomcat, so tomcat starts last (after all other services). You should do the same for the rest of runlevels (e.g in /etc/rc2.d, //etc/rc4.d, etc/rc5.d)

Regards
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] tomcat error -SEVERE: Cannot start server. Server instance is not configured jsaravana87 Linux - Server 1 08-11-2011 11:57 AM
Any problems using Ubuntu desktop as an apache/tomcat/mysql server? glennyboi Ubuntu 2 05-18-2007 01:51 PM
Start Tomcat before Apache on boot Swakoo Linux - Server 3 04-10-2007 02:25 AM
Can't get apache server to automatically start on boot bowie101 Linux - Newbie 11 05-03-2006 11:07 AM
Apache server and MySQL server won't run at startup! dday007 Linux - General 2 02-07-2003 02:51 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 06:30 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration