mirror of
https://github.com/taigrr/nats.docs
synced 2025-01-18 04:03:23 -08:00
updating docs
This commit is contained in:
@@ -1044,9 +1044,9 @@
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="4.5.1.2.5" data-path="jwt_auth.html">
|
||||
<li class="chapter " data-level="4.5.1.2.5" data-path="accounts.html">
|
||||
|
||||
<a href="jwt_auth.html">
|
||||
<a href="accounts.html">
|
||||
|
||||
|
||||
Accounts
|
||||
@@ -1057,7 +1057,20 @@
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="4.5.1.2.6" data-path="auth_timeout.html">
|
||||
<li class="chapter " data-level="4.5.1.2.6" data-path="jwt_auth.html">
|
||||
|
||||
<a href="jwt_auth.html">
|
||||
|
||||
|
||||
JWTs
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="4.5.1.2.7" data-path="auth_timeout.html">
|
||||
|
||||
<a href="auth_timeout.html">
|
||||
|
||||
@@ -2293,35 +2306,31 @@
|
||||
<p>Note that NATS clustered servers have a forwarding limit of one hop. This means that each <code>nats-server</code> instance will <strong>only</strong> forward messages that it has received <strong>from a client</strong> to the immediately adjacent <code>nats-server</code> instances to which it has routes. Messages received <strong>from</strong> a route will only be distributed to local clients. Therefore a full mesh cluster, or complete graph, is recommended for NATS to function as intended and as described throughout the documentation.</p>
|
||||
<h2 id="cluster-urls"><a name="cluster-urls" class="plugin-anchor" href="#cluster-urls"><i class="fa fa-link" aria-hidden="true"></i></a>Cluster URLs</h2>
|
||||
<p>In addition to a port for listening for clients, <code>nats-server</code> can listen on a "cluster" URL (the <code>-cluster</code> option). Additional <code>nats-server</code> servers can then add that URL to their <code>-routes</code> argument to join the cluster. These options can also be specified in a config file, but only the command-line version is shown in this overview for simplicity.</p>
|
||||
<h3 id="running-with-no-cluster"><a name="running-with-no-cluster" class="plugin-anchor" href="#running-with-no-cluster"><i class="fa fa-link" aria-hidden="true"></i></a>Running with No Cluster</h3>
|
||||
<pre class="language-"><code class="lang-sh">nats-server -p 4222
|
||||
</code></pre>
|
||||
<hr>
|
||||
<h3 id="running-a-simple-cluster"><a name="running-a-simple-cluster" class="plugin-anchor" href="#running-a-simple-cluster"><i class="fa fa-link" aria-hidden="true"></i></a>Running a Simple Cluster</h3>
|
||||
<pre class="language-"><code class="lang-sh"><span class="token comment"># Server A on 10.10.0.1</span>
|
||||
nats-server -p 4222 -cluster nats://10.10.0.1:5222
|
||||
<h2 id="running-a-simple-cluster"><a name="running-a-simple-cluster" class="plugin-anchor" href="#running-a-simple-cluster"><i class="fa fa-link" aria-hidden="true"></i></a>Running a Simple Cluster</h2>
|
||||
<p>Here is a simple cluster running on the same machine:</p>
|
||||
<pre class="language-"><code class="lang-sh"><span class="token comment"># Server A - the 'seed server'</span>
|
||||
<span class="token operator">></span> nats-server -p 4222 -cluster nats://0.0.0.0:5222
|
||||
|
||||
<span class="token comment"># Server B on 10.10.0.2</span>
|
||||
nats-server -p 4222 -cluster nats://10.10.0.2:5222 -routes nats://10.10.0.1:5222
|
||||
</code></pre>
|
||||
<hr>
|
||||
<pre class="language-"><code class="lang-sh"><span class="token comment"># Server A on 10.10.0.1</span>
|
||||
nats-server -p 4222 -cluster nats://10.10.0.1:5222 -routes nats://10.10.0.2:5222
|
||||
<span class="token comment"># Server B</span>
|
||||
<span class="token operator">></span> nats-server -p -1 -cluster nats://0.0.0.0:-1 -routes nats://localhost:5222
|
||||
<span class="token comment"># Check the output of the server for the selected client and route ports.</span>
|
||||
|
||||
<span class="token comment"># Server B on 10.10.0.2</span>
|
||||
nats-server -p 4222 -cluster nats://10.10.0.2:5222 -routes nats://10.10.0.1:5222
|
||||
<span class="token comment"># Server C</span>
|
||||
<span class="token operator">></span> nats-server -p -1 -cluster nats://0.0.0.0:-1 -routes nats://localhost:5222
|
||||
<span class="token comment"># Check the output of the server for the selected client and route ports.</span>
|
||||
</code></pre>
|
||||
<p>Clients connecting to any server in the cluster will remain connected to the cluster even if the server it originally connected to is taken down, as long as at least a single server remains.</p>
|
||||
<p>The <em>seed server</em> simply declares its client and clustering port. All other servers delegate to the nats-server to auto-select a port that is not in use for both clients and cluster connections, and route to the seed server. Because the clustering protocol gossips members of the cluster, all servers are able to discover other server servers in the cluster. When a server is discovered, the discovering server will automatically attempt to connect to it in order to form a <em>full mesh</em>. Typically only one instance of the server will run per machine, so you can reuse the client port (4222) and the cluster port (5222), and simply the route to the host/port of the seed server.</p>
|
||||
<p>Similarly, clients connecting to any server in the cluster will discover other servers in the cluster. If the connection to the server is interrupted, the client will attempt to connect to all other known servers.</p>
|
||||
<h2 id="command-line-options"><a name="command-line-options" class="plugin-anchor" href="#command-line-options"><i class="fa fa-link" aria-hidden="true"></i></a>Command Line Options</h2>
|
||||
<p>The following cluster options are supported:</p>
|
||||
<pre class="language-"><code>--routes [rurl-1, rurl-2] Routes to solicit and connect
|
||||
--cluster nats://host:port Cluster URL for solicited routes
|
||||
</code></pre><p>When a NATS server routes to a specified URL, it will advertise its own cluster URL to all other servers in the route route effectively creating a routing mesh to all other servers. </p>
|
||||
</code></pre><p>When a NATS server routes to a specified URL, it will advertise its own cluster URL to all other servers in the route effectively creating a routing mesh to all other servers. </p>
|
||||
<p><strong>Note:</strong> when using the <code>-routes</code> option, you must also specify a <code>-cluster</code> option.</p>
|
||||
<p>Clustering can also be configured using the server <a href="cluster_config.html">config file</a>.</p>
|
||||
<h2 id="three-server-cluster-example"><a name="three-server-cluster-example" class="plugin-anchor" href="#three-server-cluster-example"><i class="fa fa-link" aria-hidden="true"></i></a>Three Server Cluster Example</h2>
|
||||
<p>The following example demonstrates how to run a cluster of 3 servers on the same host. We will start with the seed server and use the <code>-D</code> command line parameter to produce debug information.</p>
|
||||
<pre class="language-"><code class="lang-sh">nats-server -p 4222 -cluster nats://localhost:4248 -D
|
||||
<pre class="language-"><code class="lang-sh">nats-server -p 4222 -cluster nats://localhost:5222 -D
|
||||
</code></pre>
|
||||
<p>Alternatively, you could use a configuration file, let's call it <code>seed.conf</code>, with a content similar to this:</p>
|
||||
<pre class="language-"><code class="lang-ascii"># Cluster Seed Node
|
||||
@@ -2330,7 +2339,7 @@ listen: 127.0.0.1:4222
|
||||
http: 8222
|
||||
|
||||
cluster {
|
||||
listen: 127.0.0.1:4248
|
||||
listen: 127.0.0.1:5222
|
||||
}
|
||||
</code></pre>
|
||||
<p>And start the server like this:</p>
|
||||
@@ -2342,7 +2351,7 @@ cluster {
|
||||
<span class="token punctuation">[</span>75653<span class="token punctuation">]</span> 2016/04/26 15:14:47.340822 <span class="token punctuation">[</span>DBG<span class="token punctuation">]</span> server <span class="token function">id</span> is xZfu3u7usAPWkuThomoGzM
|
||||
<span class="token punctuation">[</span>75653<span class="token punctuation">]</span> 2016/04/26 15:14:47.340825 <span class="token punctuation">[</span>INF<span class="token punctuation">]</span> server is ready
|
||||
</code></pre>
|
||||
<p>It is also possible to specify the hostname and port independently. At least the port is required. If you leave the hostname off it will bind to all the interfaces ('0.0.0.0').</p>
|
||||
<p>It is also possible to specify the hostname and port independently. At the minimum, the port is required. If you leave the hostname off it will bind to all the interfaces ('0.0.0.0').</p>
|
||||
<pre class="language-"><code class="lang-ascii">cluster {
|
||||
host: 127.0.0.1
|
||||
port: 4248
|
||||
@@ -2407,10 +2416,10 @@ nats-pub -s <span class="token string">"nats://192.168.59.105:7222"</s
|
||||
|
||||
<span class="token punctuation">[</span><span class="token comment">#1] Received on [hello] : 'world'</span>
|
||||
|
||||
<span class="token comment"># GNATSD on Node C logs:</span>
|
||||
<span class="token comment"># nats-server on Node C logs:</span>
|
||||
<span class="token punctuation">[</span>1<span class="token punctuation">]</span> 2015/06/23 05:20:31.100032 <span class="token punctuation">[</span>TRC<span class="token punctuation">]</span> 192.168.59.103:7244 - rid:2 - <span class="token operator"><<</span>- <span class="token punctuation">[</span>MSG hello RSID:8:2 5<span class="token punctuation">]</span>
|
||||
|
||||
<span class="token comment"># GNATSD on Node A logs:</span>
|
||||
<span class="token comment"># nats-server on Node A logs:</span>
|
||||
<span class="token punctuation">[</span>1<span class="token punctuation">]</span> 2015/06/23 05:20:31.100600 <span class="token punctuation">[</span>TRC<span class="token punctuation">]</span> 10.0.2.2:51007 - cid:8 - <span class="token operator"><<</span>- <span class="token punctuation">[</span>MSG hello 2 5<span class="token punctuation">]</span>
|
||||
</code></pre>
|
||||
|
||||
@@ -2456,7 +2465,7 @@ nats-pub -s <span class="token string">"nats://192.168.59.105:7222"</s
|
||||
<script>
|
||||
var gitbook = gitbook || [];
|
||||
gitbook.push(function() {
|
||||
gitbook.page.hasChanged({"page":{"title":"Clustering","level":"4.5.2","depth":2,"next":{"title":"Configuration","level":"4.5.2.1","depth":3,"path":"nats_server/cluster_config.md","ref":"nats_server/cluster_config.md","articles":[]},"previous":{"title":"Authorization","level":"4.5.1.3","depth":3,"path":"nats_server/authorization.md","ref":"nats_server/authorization.md","articles":[]},"dir":"ltr"},"config":{"plugins":["prism","-highlight","include-html","toggle-chapters","anchors"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"prism":{"lang":{"ascii":"markup","text":"markup"}},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"include-html":{},"fontsettings":{"theme":"white","family":"sans","size":2},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false},"anchors":{},"toggle-chapters":{}},"theme":"default","author":"The NATS Maintainers","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"NATS","gitbook":"*","description":"Administrative, developer and conceptual documentation for the NATS messaging system."},"file":{"path":"nats_server/clustering.md","mtime":"2019-05-22T19:29:21.313Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2019-05-24T21:09:44.530Z"},"basePath":"..","book":{"language":""}});
|
||||
gitbook.page.hasChanged({"page":{"title":"Clustering","level":"4.5.2","depth":2,"next":{"title":"Configuration","level":"4.5.2.1","depth":3,"path":"nats_server/cluster_config.md","ref":"nats_server/cluster_config.md","articles":[]},"previous":{"title":"Authorization","level":"4.5.1.3","depth":3,"path":"nats_server/authorization.md","ref":"nats_server/authorization.md","articles":[]},"dir":"ltr"},"config":{"plugins":["prism","-highlight","include-html","toggle-chapters","anchors"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"prism":{"lang":{"ascii":"markup","text":"markup"}},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"include-html":{},"fontsettings":{"theme":"white","family":"sans","size":2},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false},"anchors":{},"toggle-chapters":{}},"theme":"default","author":"The NATS Maintainers","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"NATS","gitbook":"*","description":"Administrative, developer and conceptual documentation for the NATS messaging system."},"file":{"path":"nats_server/clustering.md","mtime":"2019-05-29T16:43:54.847Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2019-05-29T16:45:48.381Z"},"basePath":"..","book":{"language":""}});
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user