mirror of https://github.com/status-im/consul.git
27 lines
6.8 KiB
HTML
27 lines
6.8 KiB
HTML
<!DOCTYPE html> <html lang=en> <head> <meta charset=utf-8> <meta name=viewport content="width=device-width, initial-scale=1.0"> <meta name=description content=""> <meta name=author content=""> <title>Run the Agent - Serf</title> <link href="/stylesheets/bootstrap.min-82fe1490.css" media=screen rel=stylesheet /><link href="/stylesheets/main-e5014f86.css" media=screen rel=stylesheet /> <!--[if lt IE 9]><script src="/javascripts/html5shiv-310dd184.js"></script> <script src="/javascripts/respond.min-88c91176.js"></script><![endif]--> <script>
|
|
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
|
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
|
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
|
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
|
|
|
|
ga('create', 'UA-45101516-1', 'serfdom.io');
|
|
ga('send', 'pageview');
|
|
|
|
</script> </head> <body class="page-Run the Agent"> <div id=header> <div class=container> <a class="navbar-brand logo" href="/"> <span></span> </a> <a class="navbar-brand text rls-l" href="/">SERF</a> <ul class="buttons nav navbar-nav navbar-right rls-sb"> <li class=first><a href="/downloads.html">Download</a></li> <li><a href="https://github.com/hashicorp/serf">Github</a></li> </ul> <ul class="main-links nav navbar-nav navbar-right rls-sb"> <li><a href="/intro/index.html">Intro</a></li> <li><a href="/docs/index.html">Docs</a></li> <li><a href="/community.html">Community</a></li> </ul> </div> </div> <div class=container> <div class=col-md-4> <div class="docs-sidebar hidden-print affix-top" role=complementary> <ul class="nav docs-sidenav"> <li> <a href="/intro/index.html">What is Serf?</a> </li> <li> <a href="/intro/use-cases.html">Use Cases</a> </li> <li> <a href="/intro/vs-other-sw.html">Serf vs. Other Software</a> <ul class=nav> <li> <a href="/intro/vs-zookeeper.html">ZooKeeper, doozerd, etcd</a> </li> <li> <a href="/intro/vs-chef-puppet.html">Chef, Puppet, etc.</a> </li> <li> <a href="/intro/vs-fabric.html">Fabric</a> </li> <li> <a href="/intro/vs-custom.html">Custom Solutions</a> </li> </ul> </li> <li class=active> <a href="/intro/getting-started/install.html">Getting Started</a> <ul class=nav> <li> <a href="/intro/getting-started/install.html">Install Serf</a> </li> <li class=active> <a href="/intro/getting-started/agent.html">Run the Agent</a> </li> <li> <a href="/intro/getting-started/join.html">Join a Cluster</a> </li> <li> <a href="/intro/getting-started/event-handlers.html">Event Handlers</a> </li> <li> <a href="/intro/getting-started/user-events.html">Custom User Events</a> </li> <li> <a href="/intro/getting-started/next-steps.html">Next Steps</a> </li> </ul> </li> </ul> </div> </div> <div class=col-md-8 role=main> <div class=bs-docs-section> <h1 id=toc_0>Run the Serf Agent</h1> <p>After Serf is installed, the agent must be run. The agent is a lightweight process that runs until told to quit and maintains cluster membership and communication. The agent must be run for every node that will be part of the cluster.</p> <p>It is possible to run multiple agents, and thus participate in multiple Serf clusters. For example, you may want to run a separate Serf cluster to maintain web server membership info for a load balancer from another Serf cluster that manages membership of Memcached nodes, but perhaps the web servers need to be part of the Memcached cluster too so they can be notified when Memcached nodes come online or go offline. Other examples include a Serf cluster within a datacenter, and a seperate cluster used for cross WAN gossip which has more relaxed timing.</p> <h2 id=toc_1>Starting the Agent</h2> <p>For simplicity, we'll run a single Serf agent right now:</p> <pre><code>$ serf agent
|
|
==> Starting Serf agent...
|
|
==> Serf agent running!
|
|
Node name: ''
|
|
Bind addr: '0.0.0.0:7946'
|
|
RPC addr: '127.0.0.1:7373'
|
|
|
|
==> Log data will now stream in as it occurs:
|
|
|
|
2013/10/21 18:57:15 [INFO] Serf agent starting
|
|
2013/10/21 18:57:15 [INFO] serf: EventMemberJoin: mitchellh.local 10.0.1.60
|
|
2013/10/21 18:57:15 [INFO] Serf agent started
|
|
2013/10/21 18:57:15 [INFO] agent: Received event: member-join
|
|
</code></pre> <p>As you can see, the Serf agent has started and has output some log data. From the log data, you can see that a member has joined the cluster. This member is yourself.</p> <h2 id=toc_2>Cluster Members</h2> <p>If you run <code>serf members</code> in another terminal, you can see the members of the Serf cluster. You should only see one member (yourself). We'll cover joining cluters in the next section.</p> <pre><code>$ serf members
|
|
mitchellh.local 10.0.1.60 alive
|
|
</code></pre> <p>This command, along with many others, communicates with a running Serf agent via an internal RPC protocol. When starting the Serf agent, you may have noticed that it tells you the "RPC addr". This is the address that commands such as <code>serf members</code> use to communicate with the agent.</p> <p>By default, RPC listens only on loopback, so it is inaccessible outside of your machine for security reasons.</p> <p>If you're running multiple Serf agents, you'll have to specify an <code>-rpc-addr</code> to both the agent and any commands so that it doesn't collide with other agents.</p> <h2 id=toc_3>Stopping the Agent</h2> <p>You can use <code>Ctrl-C</code> (the interrupt signal) to gracefully halt the agent. After interrupting the agent, you should see it leave the cluster gracefully and shut down.</p> <p>By gracefully leaving, Serf notifies other cluster members that the node <em>left</em>. If you had forcibly killed the agent process, other members of the cluster would have detected that the node <em>failed</em>. This can be a crucial difference depending on what your use case of Serf is. Serf will automatically try to reconnect to <em>failed</em> nodes, which allows it to recover from certain network conditions, while <em>left</em> nodes are no longer contacted.</p> </div> </div> </div> <div id=footer> <div class=container> <div class=footer-links> <ul class="main-links nav navbar-nav rls-sb"> <li><a href="/intro/index.html">Intro</a></li> <li class=active><a href="/docs/index.html">Docs</a></li> <li><a href="/community.html">Community</a></li> </ul> <ul class="buttons nav navbar-nav rls-sb"> <li class=first><a href="/downloads.html">Download</a></li> <li><a href="https://github.com/hashicorp/serf">Github</a></li> </ul> </div> <div class=footer-logo> <span></span> </div> <div class="footer-hashi os"> <span>© 2013. A <a href="//www.hashicorp.com">HashiCorp</a> Project.</span> <a href="//www.hashicorp.com"><img src="/images/hashi-logo-s-3644fe63.png"></a> </div> </div> </div> <script src="javascripts/lib/d3.v3.min.js"></script> <script src="javascripts/app/deploy/site.js"></script> <script>
|
|
Serf.initialize();
|
|
</script> </body> </html> |