You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by NabiL <el...@gmail.com> on 2009/10/19 23:34:29 UTC

JDBC Master/Slave

Hi,

I try to set up two AMQ 5.3 brokers (deployed on 2 tomcat servers ) to get
some redundancy in
our solution. 

The AMQ documentation describes the JDBC Master/slave as below :
On startup one master grabs an exclusive lock in the broker database and all
other brokers are slaves and pause waiting for the exclusive lock. 
>> This situation occurs only if we use AMQ as standalone (not embedding in
>> server container tomcat)

I configured the 2 AMQ Web-console5.3.war on each Tomcat server to use a
shared DB (Mysql). As a result, the master start successfully and grabs the
lock, the AMQ slave can't start. To resolve this situation i positioned
useDatabaseLock=false.

Questions : 
1 - If i disable database locking.. Do i need to use some other mechanism
to stop the slave broker from becoming active while the master is on-line in
order to avoid data corruption ?

2 - i configured  persistenceAdapter element on each broker as show below :
    <persistenceAdapter>
        <jdbcPersistenceAdapter dataSource="#mysql-ds"
useDatabaseLock="false"/>
     </persistenceAdapter>

<bean id="mysql-ds" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
		<property name="driverClassName" value="com.mysql.jdbc.Driver"/>
		<property name="url"
value="jdbc:mysql://host/activemq?relaxAutoCommit=true"/>
		<property name="username" value="xxx"/>
		<property name="password" value="xxx"/>
		<property name="maxActive" value="200"/>
		<property name="poolPreparedStatements" value="true"/>
   </bean>
 
 As you can see, i did not specify  any data
directory="${activemq.base}/data/ on jdbcPersistenceAdapter element. What is
the difference if specify the data directory on this element ?


Sorry for my bad english. Any help will be appreciated.

Thanks in advance.
NabiLo


-- 
View this message in context: http://www.nabble.com/JDBC-Master-Slave-tp25966078p25966078.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: JDBC Master/Slave

Posted by NabiL <el...@gmail.com>.
Hi Dejan,

Thanks for your reply. If i understand well, i have to set
useDatabaseLock=true. this situation works fine only if tomcat already
started. 

Now If we try to restart tomcat,  it can't start because AMQ attempts to
acquire lock, with this situation all application deployed on this tomcat
server is impacted.

Any help will be appreciated. 

Thanks in advance.
NabiL



Dejan Bosanac wrote:
> 
> Hi Nabil,
> 
> I don't see why database locking would not work in Tomcat environment. You
> need to have database locking in order to have master/slave work
> correctly.
> Also, pure jdbc adapter does not use any files on the filesystem, so
> data-directory shouldn't make any difference.
> 
> Cheers
> --
> Dejan Bosanac - http://twitter.com/dejanb
> 
> Open Source Integration - http://fusesource.com/
> ActiveMQ in Action - http://www.manning.com/snyder/
> Blog - http://www.nighttale.net
> 
> 
> On Mon, Oct 19, 2009 at 11:34 PM, NabiL <el...@gmail.com> wrote:
> 
>>
>> Hi,
>>
>> I try to set up two AMQ 5.3 brokers (deployed on 2 tomcat servers ) to
>> get
>> some redundancy in
>> our solution.
>>
>> The AMQ documentation describes the JDBC Master/slave as below :
>> On startup one master grabs an exclusive lock in the broker database and
>> all
>> other brokers are slaves and pause waiting for the exclusive lock.
>> >> This situation occurs only if we use AMQ as standalone (not embedding
>> in
>> >> server container tomcat)
>>
>> I configured the 2 AMQ Web-console5.3.war on each Tomcat server to use a
>> shared DB (Mysql). As a result, the master start successfully and grabs
>> the
>> lock, the AMQ slave can't start. To resolve this situation i positioned
>> useDatabaseLock=false.
>>
>> Questions :
>> 1 - If i disable database locking.. Do i need to use some other mechanism
>> to stop the slave broker from becoming active while the master is on-line
>> in
>> order to avoid data corruption ?
>>
>> 2 - i configured  persistenceAdapter element on each broker as show below
>> :
>>    <persistenceAdapter>
>>        <jdbcPersistenceAdapter dataSource="#mysql-ds"
>> useDatabaseLock="false"/>
>>     </persistenceAdapter>
>>
>> <bean id="mysql-ds" class="org.apache.commons.dbcp.BasicDataSource"
>> destroy-method="close">
>>                <property name="driverClassName"
>> value="com.mysql.jdbc.Driver"/>
>>                <property name="url"
>> value="jdbc:mysql://host/activemq?relaxAutoCommit=true"/>
>>                <property name="username" value="xxx"/>
>>                <property name="password" value="xxx"/>
>>                <property name="maxActive" value="200"/>
>>                <property name="poolPreparedStatements" value="true"/>
>>   </bean>
>>
>>  As you can see, i did not specify  any data
>> directory="${activemq.base}/data/ on jdbcPersistenceAdapter element. What
>> is
>> the difference if specify the data directory on this element ?
>>
>>
>> Sorry for my bad english. Any help will be appreciated.
>>
>> Thanks in advance.
>> NabiLo
>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/JDBC-Master-Slave-tp25966078p25966078.html
>> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>>
>>
> 
> 
> -----
> Dejan Bosanac
> 
> Open Source Integration - http://fusesource.com/
> ActiveMQ in Action - http://www.manning.com/snyder/
> Blog - http://www.nighttale.net
> 

-- 
View this message in context: http://www.nabble.com/JDBC-Master-Slave-tp25966078p25973452.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: JDBC Master/Slave

Posted by Dejan Bosanac <de...@nighttale.net>.
Hi Nabil,

I don't see why database locking would not work in Tomcat environment. You
need to have database locking in order to have master/slave work correctly.
Also, pure jdbc adapter does not use any files on the filesystem, so
data-directory shouldn't make any difference.

Cheers
--
Dejan Bosanac - http://twitter.com/dejanb

Open Source Integration - http://fusesource.com/
ActiveMQ in Action - http://www.manning.com/snyder/
Blog - http://www.nighttale.net


On Mon, Oct 19, 2009 at 11:34 PM, NabiL <el...@gmail.com> wrote:

>
> Hi,
>
> I try to set up two AMQ 5.3 brokers (deployed on 2 tomcat servers ) to get
> some redundancy in
> our solution.
>
> The AMQ documentation describes the JDBC Master/slave as below :
> On startup one master grabs an exclusive lock in the broker database and
> all
> other brokers are slaves and pause waiting for the exclusive lock.
> >> This situation occurs only if we use AMQ as standalone (not embedding in
> >> server container tomcat)
>
> I configured the 2 AMQ Web-console5.3.war on each Tomcat server to use a
> shared DB (Mysql). As a result, the master start successfully and grabs the
> lock, the AMQ slave can't start. To resolve this situation i positioned
> useDatabaseLock=false.
>
> Questions :
> 1 - If i disable database locking.. Do i need to use some other mechanism
> to stop the slave broker from becoming active while the master is on-line
> in
> order to avoid data corruption ?
>
> 2 - i configured  persistenceAdapter element on each broker as show below :
>    <persistenceAdapter>
>        <jdbcPersistenceAdapter dataSource="#mysql-ds"
> useDatabaseLock="false"/>
>     </persistenceAdapter>
>
> <bean id="mysql-ds" class="org.apache.commons.dbcp.BasicDataSource"
> destroy-method="close">
>                <property name="driverClassName"
> value="com.mysql.jdbc.Driver"/>
>                <property name="url"
> value="jdbc:mysql://host/activemq?relaxAutoCommit=true"/>
>                <property name="username" value="xxx"/>
>                <property name="password" value="xxx"/>
>                <property name="maxActive" value="200"/>
>                <property name="poolPreparedStatements" value="true"/>
>   </bean>
>
>  As you can see, i did not specify  any data
> directory="${activemq.base}/data/ on jdbcPersistenceAdapter element. What
> is
> the difference if specify the data directory on this element ?
>
>
> Sorry for my bad english. Any help will be appreciated.
>
> Thanks in advance.
> NabiLo
>
>
> --
> View this message in context:
> http://www.nabble.com/JDBC-Master-Slave-tp25966078p25966078.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>
>