open-consul/website/build/docs/agent/basics.html

29 lines
8.5 KiB
HTML
Raw Normal View History

2014-02-08 00:41:03 +00:00
<!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>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-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="/docs/index.html">Documentation Home</a> </li> <li> <a href="/docs/upgrading.html">Upgrading and Compatibility</a> <ul class=nav> <li> <a href="/docs/upgrading.html">Upgrading Serf</a> </li> <li> <a href="/docs/compatibility.html">Compatibility Promise</a> </li> </ul> </li> <li> <a href="/docs/internals/index.html">Serf Internals</a> <ul class=nav> <li> <a href="/docs/internals/gossip.html">Gossip Protocol</a> </li> <li> <a href="/docs/internals/security.html">Security Model</a> </li> <li> <a href="/docs/internals/simulator.html">Convergence Simulator</a> </li> </ul> </li> <li> <a href="/docs/commands/index.html">Serf Commands (CLI)</a> <ul class=nav> <li> <a href="/docs/commands/agent.html">agent</a> </li> <li> <a href="/docs/commands/event.html">event</a> </li> <li> <a href="/docs/commands/force-leave.html">force-leave</a> </li> <li> <a href="/docs/commands/join.html">join</a> </li> <li> <a href="/docs/commands/keygen.html">keygen</a> </li> <li> <a href="/docs/commands/leave.html">leave</a> </li> <li> <a href="/docs/commands/members.html">members</a> </li> <li> <a href="/docs/commands/monitor.html">monitor</a> </li> </ul> </li> <li class=active> <a href="/docs/agent/basics.html">Serf Agent</a> <ul class=nav> <li class=active> <a href="/docs/agent/basics.html">Running and Stopping</a> </li> <li> <a href="/docs/agent/options.html">Configuration</a> </li> <li> <a href="/docs/agent/event-handlers.html">Event Handlers</a> </li> <li> <a href="/docs/agent/encryption.html">Encryption</a> </li> <li> <a href="/docs/agent/rpc.html">RPC Protocol</a> </li> </ul> <li> <a href="/docs/roadmap.html">Roadmap</a> </li> </ul> </div> </div> <div class=col-md-8 role=main> <div class=bs-docs-section> <h1 id=toc_0>Serf Agent</h1> <p>The Serf agent is the core process of Serf. The agent maintains membership information, propagates events, invokes event handlers, detects failures, and more. The agent must run on every node that is part of a Serf cluster.</p> <h2 id=toc_1>Running an Agent</h2> <p>The agent is started with the <code>serf agent</code> command. This command blocks, running forever or until told to quit. The agent command takes a variety of configuration options but the defaults are usually good enough. When running <code>serf agent</code>, you should see output similar to that below:</p> <pre><code>$ serf agent
==&gt; Starting Serf agent...
==&gt; Serf agent running!
Node name: &#39;mitchellh.local&#39;
Bind addr: &#39;0.0.0.0:7946&#39;
RPC addr: &#39;127.0.0.1:7373&#39;
Encrypted: false
Snapshot: false
Profile: lan
==&gt; Log data will now stream in as it occurs:
2013/10/22 10:35:33 [INFO] Serf agent starting
2013/10/22 10:35:33 [INFO] serf: EventMemberJoin: mitchellh.local 127.0.0.1
2013/10/22 10:35:33 [INFO] Serf agent started
2013/10/22 10:35:33 [INFO] agent: Received event: member-join
...
</code></pre> <p>There are six important components that <code>serf agent</code> outputs:</p> <ul> <li><p><strong>Node name</strong>: This is a unique name for the agent. By default this is the hostname of the machine, but you may customize it to whatever you&#39;d like using the <code>-node</code> flag.</p></li> <li><p><strong>Bind addr</strong>: This is the address and port used for communication between Serf agents in a cluster. Every Serf agent in a cluster does not have to use the same port.</p></li> <li><p><strong>RPC addr</strong>: This is the address and port used for RPC communications for other <code>serf</code> commands. Other Serf commands such as <code>serf members</code> connect to a running agent and use RPC to query and control the agent. By default, this binds only to localhost on the default port. If you change this address, you&#39;ll have to specify an <code>-rpc-addr</code> to commands such as <code>serf members</code> so they know how to talk to the agent. This is also the address other applications can use over <a href="/docs/agent/rpc.html">RPC to control Serf</a>.</p></li> <li><p><strong>Encrypted</strong>: This shows if Serf is encrypting all traffic that it sends and expects to receive. It is a good sanity check to avoid sending non-encrypted traffic over any public networks. You can read more about <a href="/docs/agent/encryption.html">encryption here</a>.</p></li> <li><p><strong>Snapshot</strong>: This shows if Serf snapshotting is enabled. The snapshot file enables Serf to automatically re-join a cluster after failure and prevents replay of events that have already been seen. It requires storing state on disk, and <a href="/docs/agent/options.html">must be configured</a> using a CLI flag or in the configuration directory. If it is not provided, other nodes will still attempt to reconnect on recovery, however the node will take longer to join the cluster and will replay old events.</p></li> <li><p><strong>Profile</strong>: The profile controls various timing values which should be appropriate to the environment Serf is running in. It defaults to optimizing for a LAN environment, but can also be set for WAN or local-only communication. The profile can be set in the <a href="/docs/agent/options.html">configuration</a>.</p></li> </ul> <h2 id=toc_2>Stopping an Agent</h2> <p>An agent can be stoped in two ways: gracefully or forcefully. To gracefully halt an agent, send the process an interrupt signal, which is usually <code>Ctrl-C</code> from a terminal. When gracefully exiting, the agent first notifies the cluster it intends to leave the cluster. This way, other cluster members notify the cluster that the node has <em>left</em>.</p> <p>Alternatively, you can force kill the agent by sending it a kill signal. When force killed, the agent ends immediately. The rest of the cluster will eventually (usually within seconds) detect that the node has died and will notify the cluster that the node has <em>failed</em>.</p> <p>The difference between a node <em>failing</em> and a node <em>leaving</em> may not be important for your use case. For example, for a web server and load balancer setup, both result in the same action: remove the web node from the load balancer pool. But for other situations, you may handle each scenario differently.</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> <s
Serf.initialize();
</script> </body> </html>