blob: 5339e343df0fecdd604f7c600c6d81956f5007ae [file] [log] [blame]
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>ActiveMQ</title>
<link rel="icon" type="image/png" href="/assets/img/favicon.png">
<link rel="stylesheet" href="/css/main.css">
<script defer src="https://use.fontawesome.com/releases/v5.0.8/js/all.js" integrity="sha384-SlE991lGASHoBfWbelyBPLsUlwY1GwNDJo3jSJO04KZ33K2bwfV9YBauFfnzvynJ" crossorigin="anonymous"></script>
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-light fixed-top">
<div class="container">
<!-- <a class="navbar-brand mr-auto" href="#"><img style="height: 50px" src="assets/img/apache-feather.png" /></a> -->
<a class="navbar-brand mr-auto" href="/"><img src="/assets/img/activemq_logo_black_small.png" style="height: 50px"/></a>
<button class="navbar-toggler ml-auto" type="button" data-toggle="collapse" data-target="#navbarContent" aria-controls="navbarContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="ml-auto collapse navbar-collapse" id="navbarContent">
<ul class="navbar-nav ml-auto">
<li class="nav-item">
<a class="nav-link active" href="/index.html">Home</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link" id="navbarDropdownComponents" data-target="#" href="" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Components</a>
<ul class="dropdown-menu dropdown-menu-center" aria-labelledby="navbarDropdownComponents">
<div class="row">
<div class="col-12">
<ul class="multi-column-dropdown">
<li class="nav-item"><a class="dropdown-item" href="/components/classic">ActiveMQ 5</a></li>
<li class="nav-item"><a class="dropdown-item" href="/components/artemis/">ActiveMQ Artemis</a></li>
<li class="nav-item"><a class="dropdown-item" href="/components/nms">NMS Clients</a></li>
<li class="nav-item"><a class="dropdown-item" href="/components/cms">CMS Client</a></li>
</ul>
</div>
</div>
</ul>
</li>
<li class="nav-item dropdown">
<a class="nav-link" id="navbarDropdownCommunity" data-target="#" href="" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Contact</a>
<ul class="dropdown-menu dropdown-menu-center multi-column columns-1" aria-labelledby="navbarDropdownCommunity">
<div class="row">
<div class="col-12">
<ul class="multi-column-dropdown">
<li class="nav-item"><a class="dropdown-item" href="/contact#mailing">Mailing Lists</a></li>
<li class="nav-item"><a class="dropdown-item" href="/contact#chat">Chat</a></li>
<li class="nav-item"><a class="dropdown-item" href="/contact#issues">Report Issues</a></li>
<li class="nav-item"><a class="dropdown-item" href="/contact#contributing">Contributing</a></li>
<li class="nav-item"><a class="dropdown-item" href="/security-advisories.html">Security</a></li>
</ul>
</div>
</div>
</ul>
</li>
<li class="nav-item dropdown">
<a class="nav-link" id="navbarDropdownTeam" data-target="#" href="" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Apache</a>
<ul class="dropdown-menu dropdown-menu-center multi-column columns-1" aria-labelledby="navbarDropdownTeam">
<div class="row">
<div class="col-sm-12">
<ul class="multi-column-dropdown">
<li class="nav-item"><a class="dropdown-item" href="https://www.apache.org">The Apache Software Foundation</a></li>
<li class="nav-item"><a class="dropdown-item" href="https://www.apache.org/licenses/">License</a></li>
<li class="nav-item"><a class="dropdown-item" href="https://www.apache.org/foundation/sponsorship.html">Sponsorship</a></li>
<li class="nav-item"><a class="dropdown-item" href="https://www.apache.org/foundation/thanks.html">Thanks</a></li>
<li class="nav-item"><a class="dropdown-item" href="/security-advisories.html">Security</a></li>
<li class="nav-item"><a class="dropdown-item" href="https://www.apache.org/events/current-event">Events</a></li>
<li class="nav-item"><a class="dropdown-item" href="https://people.apache.org/phonebook.html?pmc=activemq">PMC & Committers</a></li>
<li class="nav-item"><a class="dropdown-item" href="/team/reports">Board Reports</a></li>
</ul>
</div>
</div>
</ul>
</li>
</ul>
</div>
</div>
</nav>
<div class="content">
<div class="page-title-activemq5">
<div class="container">
<h1>Pure Master Slave</h1>
</div>
</div>
<div class="container" >
<div class="row" style="margin-top: 30px">
<div class="col-12 activemq5">
<p><a href="features">Features</a> &gt; <a href="clustering">Clustering</a> &gt; <a href="masterslave">MasterSlave</a> &gt; <a href="pure-master-slave">Pure Master Slave</a></p>
<h3 id="pure-master-slave">Pure Master Slave</h3>
<blockquote>
<p>This feature has been deprecated and will be removed in version 5.8</p>
<p>This feature will be removed in 5.8 as it has not evolved to be production ready. You are advised to use <a href="masterslave">shared storage master/slave</a> or the <a href="replicated-leveldb-store">Replicated LevelDB Store</a>. See <a href="https://issues.apache.org/jira/browse/AMQ-4165">AMQ-4165</a></p>
</blockquote>
<p>A Pure Master Slave configuration provides a basic shared nothing, fully replicated topology which does not depend on a shared file system or shared database.</p>
<h3 id="how-pure-master-slave-works">How Pure Master Slave works</h3>
<ul>
<li>
<p>A slave of a master broker consumes all message states from the master - messages, acknowledgments and transactional states.<br />
Whilst a Slave is actively connected to the Master - it does not allow or start any network or transport connectors, it’s sole purpose is to duplicate the state of the master.</p>
</li>
<li>
<p>The master broker will only respond to a client when a message exchange has been successfully passed to the slave. For example, a commit<br />
in a clients transaction will not complete until the master and the slave have processed the commit.</p>
</li>
<li>In the event the master fails (e.g. hardware failure) the slave has optionally two modes of operation
<ol>
<li>starts all it’s network and transport connectors - allowing clients connected to the master to resume on the slave.</li>
<li>or can be configured to close down. In this mode, the slave is simply used to duplicate state for the master.</li>
</ol>
</li>
<li>clients should use a failover transport for connecting to the master broker first and then the slave. e.g. using a URL such as
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>failover://(tcp://masterhost:61616,tcp://slavehost:61616)?randomize=false
</code></pre></div> </div>
<p>The <strong>randomize</strong> property just disables randomness so that the transport will always try the master first, then the slave if it can’t connect to that. Note that the slave does not accept connections until it becomes the master</p>
</li>
</ul>
<h3 id="limitations-of-pure-master-slave">Limitations of Pure Master Slave</h3>
<ul>
<li>Only one slave can be connected to the Master</li>
<li>A failed master cannot be re-introduced without shutting down the the slave broker (no automatic failback)</li>
<li>There is no automatic synchronization between brokers. This is a manual process.</li>
</ul>
<h3 id="recovering-a-pure-master-slave-topology">Recovering a Pure Master Slave topology</h3>
<p>This is a manual process - once a master has failed, the only sure way to ensure that the toplogy is synchronized again is manually:</p>
<ul>
<li>shutdown the slave broker (The clients do not need to be shutdown - they will wait until the topology is re-established if they are failover clients</li>
<li>copy the data directory from the slave over the data directory of the master broker</li>
<li>re-start the master and the slave</li>
</ul>
<h3 id="configuring-pure-master-slave">Configuring Pure Master Slave</h3>
<p>You should not configure a connection between the master and a slave. The connection is automatically established with the slave’s configuration. If you explicitly configure a network connection, you may encounter race conditions when the master broker is under heavy load.</p>
<p>A master broker doesn’t need any special configuration - it’s a normal broker until a slave broker attaches itself.<br />
To identify a broker as a slave - there is just one property to set (see below) as this <a href="http://svn.apache.org/repos/asf/activemq/trunk/activemq-core/src/test/resources/org/apache/activemq/broker/ft/slave2.xml">example shows</a> - so configuration is nice and easy:</p>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>&lt;broker masterConnectorURI="tcp://masterhost:62001" shutdownOnMasterFailure="false"&gt;
&lt;persistenceAdapter&gt;
&lt;journaledJDBC journalLogFiles="5" dataDirectory="${activemq.base}/data/broker2" /&gt;
&lt;/persistenceAdapter&gt;
&lt;transportConnectors&gt;
&lt;transportConnector uri="tcp://slavehost:61616"/&gt;
&lt;/transportConnectors&gt;
&lt;/broker&gt;
</code></pre></div></div>
<p>Broker Property|default|Description
—|—|—
masterConnectorURI|null|URI to the master broker e.g. <code class="highlighter-rouge">tcp://masterhost:62001</code>
shutdownOnMasterFailure|false|if true, the slave will shut down if the master fails otherwise the slave will take over as being the new master. The slave ensures that there is a separate copy of each message and acknowledgement on another machine which can protect against catastrophic hardware failure. If the master fails you might want the slave to shut down as well as you may always want to duplicate messages to 2 physical locations to prevent message loss on catastrophic data centre or hardware failure. If you would rather the system keep on running after a master failure then leave this flag as false.
waitForSlave|false|version 5.2+, if true, a master will wait till a slave has attached before completing its startup sequence
shutdownOnSlaveFailure|false|version 5.2+, if true, a master will shutdown if the slave connection is lost, ensuring that the master will not become out of sync with the slave.</p>
<h3 id="configuring-the-authentication-of-the-slave">Configuring the authentication of the Slave</h3>
<p>In ActiveMQ 4.1 or later you can use a <code class="highlighter-rouge">&lt;masterConnector/&gt;</code> element as an alternative XML configuration mechanism as shown in the following <a href="http://svn.apache.org/repos/asf/activemq/trunk/activemq-core/src/test/resources/org/apache/activemq/broker/ft/slave2.xml">example</a> to configure the user and password that the slave will use to connect to the master</p>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>&lt;broker brokerName="slave" useJmx="false" deleteAllMessagesOnStartup="true" xmlns="http://activemq.apache.org/schema/core"&gt;
&lt;services&gt;
&lt;masterConnector remoteURI= "tcp://localhost:62001" userName="James" password="Cheese"/&gt;
&lt;/services&gt;
&lt;transportConnectors&gt;
&lt;transportConnector uri="tcp://localhost:62002"/&gt;
&lt;/transportConnectors&gt;
&lt;/broker&gt;
</code></pre></div></div>
</div>
</div>
</div>
</div>
<div class="row sitemap">
<div class="col-sm-12">
<div class="container">
<div class="row">
<div class="col-sm-12">
<div class="row">
<div class="col-sm-3">
<div >
<img class="float-left" style="max-height: 100px" src="/assets/img/activemq_logo_white_vertical_small.png"/>
</div>
</div>
<div style="text-align: center; margin-bottom: 0px; margin-top: 30px; font-size: 65%" class="col-sm-6">
<p>Apache ActiveMQ, ActiveMQ, ActiveMQ Artemis, Apache, the Apache feather logo, and the Apache ActiveMQ project logo are trademarks of The Apache Software Foundation. Copyright &copy; 2019, The Apache Software Foundation. Licensed under <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License 2.0</a>.</p>
</div>
<div class="col-sm-3">
<div >
<a href="https://www.apache.org"><img class="float-right" style="margin-top: 10px; max-height: 80px" src="/assets/img/apache-logo-small.png"/></a>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>