{"id":3920,"date":"2014-06-11T17:26:29","date_gmt":"2014-06-11T09:26:29","guid":{"rendered":"http:\/\/blog.hmouse.tk\/?p=3920"},"modified":"2015-06-07T11:11:30","modified_gmt":"2015-06-07T03:11:30","slug":"mcollective%e7%9a%84%e5%ae%89%e8%a3%85%e4%b8%8e%e4%bd%bf%e7%94%a8","status":"publish","type":"post","link":"https:\/\/www.hmouse.cn\/?p=3920","title":{"rendered":"mcollective\u7684\u5b89\u88c5\u4e0e\u4f7f\u7528"},"content":{"rendered":"<p>mcollective\u5b89\u88c5<\/p>\n<p>\u65b0\u7684\u7248\u672c\u4e0d\u652f\u6301stomp\u534f\u8bae\uff0c\u5751\u6b7b\u6211\u4e86\uff0c\u770b\u7f51\u4e0a\u7684\u5927\u591a\u6570\u90fd\u662f\u7528stomp\u53bb\u8fde\u7684\u3002\u56de\u6765\u6211\u88ab\u903c\u65e0\u5948\uff0c\u53ea\u80fd\u7528activemq\uff0c\u7136\u540e\u901a\u8fc7activemq\u53bb\u8fde<\/p>\n<p>\u53c2\u8003url\uff1a<a title=\"http:\/\/kisspuppet.com\/2013\/11\/10\/mcollective-middleware\/\" href=\"http:\/\/kisspuppet.com\/2013\/11\/10\/mcollective-middleware\/\">http:\/\/kisspuppet.com\/2013\/11\/10\/mcollective-middleware\/<\/a>\u00a0 \uff08\u8fd9\u4e2a\u8bf4\u7684\u6bd4\u8f83\u8be6\u7ec6\uff09<\/p>\n<p>\u8bf4\u8bf4\u539f\u7406\u5427<\/p>\n<p>&nbsp;<\/p>\n<h4>1.3 \u5de5\u4f5c\u539f\u7406\u56fe<\/h4>\n<p><a href=\"http:\/\/kisspuppet.com\/img\/mcollective-1.png\"><img decoding=\"async\" src=\"http:\/\/kisspuppet.com\/img\/mcollective-1.png\" alt=\"mcollective\u89e6\u53d1\u66f4\u65b0\u56fe\" \/><\/a><\/p>\n<p>\u770b\u51fa\u6765\u4e86\u5176\u5b9e\u4e1c\u897f \u5206\u62103\u4e2a\uff0c client + \u4e2d\u95f4\u4ef6+sever<\/p>\n<p>\u4e2d\u95f4\u4ef6\u00a0 activemq\u00a0 \uff08\u5176\u5b9e rabbitmq\u4e5f\u53ef\u4ee5\uff0c\u5f88\u591a\u4e66\u90fd\u4f7f\u7528\u8fd9\u4e2a\uff0c\u4f46\u662f\u6211\u5b89\u88c5\u7684\u7248\u672c\u662f\u5efa\u8bae\u4f7f\u7528activemq\u00a0 \uff09<\/p>\n<p>\u5b89\u88c5<\/p>\n<pre><code> yum install tanukiwrapper activemq activemq-info-provider<\/code><\/pre>\n<p>\u914d\u7f6e\u00a0\u00a0 \uff08\u5176\u5b9e\u9ed8\u8ba4\u7684\u4e0d\u9700\u8981\u4fee\u6539\uff0c\u6700\u4e3b\u8981\u7684\u5c31\u6539\u4e0b\u8d26\u53f7\u540d\u548c\u5bc6\u7801\uff09<\/p>\n<p>\u4e3b\u8981\u914d\u7f6eMCollective\u8fde\u63a5\u7684\u7aef\u53e3\u4ee5\u53ca\u8d26\u53f7\u3001\u5bc6\u7801\u53ca\u6743\u9650<\/p>\n<p><code>[root@puppetserver rpms]# vim \/etc\/activemq\/activemq.xml \u2026 &lt;simpleAuthenticationPlugin&gt; &lt;users&gt; &lt;!-- &lt;authenticationUser username=\"${activemq.username}\" password=\"${activemq.password}\" groups=\"admins,everyone\"\/&gt; --&gt; #\u7981\u7528 &lt;authenticationUser username=\"mcollective\" password=\"secret\" groups=\"mcollective,admins,everyone\"\/&gt; #\u914d\u7f6e\u901a\u4fe1\u7684\u8d26\u53f7\u53ca\u5bc6\u7801 &lt;\/users&gt; &lt;\/simpleAuthenticationPlugin&gt; \u2026 &lt;authorizationPlugin&gt; #\u914d\u7f6e\u6743\u9650\uff0c\u9ed8\u8ba4\u5373\u53ef &lt;map&gt; &lt;authorizationMap&gt; &lt;authorizationEntries&gt; &lt;authorizationEntry queue=\"&gt;\" write=\"admins\" read=\"admins\" admin=\"admins\" \/&gt; &lt;authorizationEntry topic=\"&gt;\" write=\"admins\" read=\"admins\" admin=\"admins\" \/&gt; &lt;authorizationEntry topic=\"mcollective.&gt;\" write=\"mcollective\" read=\"mcollective\" admin=\"mcollective\" \/&gt; &lt;authorizationEntry topic=\"mcollective.&gt;\" write=\"mcollective\" read=\"mcollective\" admin=\"mcollective\" \/&gt; &lt;authorizationEntry topic=\"ActiveMQ.Advisory.&gt;\" read=\"everyone\" write=\"everyone\" admin=\"everyone\"\/&gt; &lt;\/authorizationEntries&gt; &lt;\/authorizationMap&gt; &lt;\/map&gt; &lt;\/authorizationPlugin&gt; \u2026 &lt;transportConnectors&gt; &lt;transportConnector name=\"openwire\" uri=\"tcp:\/\/0.0.0.0:61616\"\/&gt; &lt;transportConnector name=\"stomp+nio\" uri=\"stomp:\/\/0.0.0.0:61613\"\/&gt; #\u914d\u7f6e\u901a\u4fe1\u534f\u8bae\u4e3astomp\uff0c\u76d1\u542c61613\u7aef\u53e3 &lt;\/transportConnectors&gt;<\/code><\/p>\n<p>\u542f\u52a8<\/p>\n<pre><code>[root@puppetserver rpms]# \/etc\/rc.d\/init.d\/activemq start\r\nStarting ActiveMQ Broker...\r\n[root@puppetserver rpms]# chkconfig activemq on\r\n[root@puppetserver rpms]# netstat -nlatp | grep 61613  #\u67e5\u770b\u76d1\u542c\u7aef\u53e3\r\ntcp        0      0 :::61613                    :::*                        LISTEN      33805\/java      <\/code><\/pre>\n<p>\u5b89\u88c5mcollective<\/p>\n<p>mcollective sever<\/p>\n<pre><code>yum install mcollective  mcollective-common<\/code><\/pre>\n<p>\u914d\u7f6e<\/p>\n<p>[root@cobar3 ~]# cat \/etc\/mcollective\/server.cfg<br \/>\nmain_collective = mcollective<br \/>\ncollectives = mcollective<br \/>\nlibdir = \/usr\/libexec\/mcollective<br \/>\nlogfile = \/var\/log\/mcollective.log<br \/>\nloglevel = info<br \/>\ndaemonize = 1<\/p>\n<p># Plugins<br \/>\nsecurityprovider = psk<br \/>\nplugin.psk = 123456\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 #\u8ddf\u5ba2\u6237\u7aef\u4e00\u6837<\/p>\n<p>connector = activemq<br \/>\nplugin.activemq.pool.size = 1<br \/>\nplugin.activemq.pool.1.host = 192.168.3.11\u00a0\u00a0\u00a0 #activemq\u670d\u52a1\u5668ip<br \/>\nplugin.activemq.pool.1.port = 61613<br \/>\nplugin.activemq.pool.1.user = mcollective\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 #\u8d26\u53f7<br \/>\nplugin.activemq.pool.1.password = secret\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 #\u5bc6\u7801<\/p>\n<p>#connector = stomp<br \/>\n#plugin.stomp.host = 192.168.3.11<br \/>\n#plugin.stomp.port = 61613<br \/>\n#plugin.stomp.user = mcollective<br \/>\n#plugin.stomp.password = secret<br \/>\nplugin.puppet.command = puppet agent\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 #\u8fd9\u662fmcollective-puppet-agent\u63a8\u8350\u6dfb\u52a0\u7684\uff0c\u5177\u4f53\u6ca1\u52a0\u6211\u4e5f\u6ca1\u6d4b\uff0c\u6709\u4ec0\u4e48\u95ee\u9898<br \/>\nplugin.puppet.splay = true<br \/>\nplugin.puppet.splaylimit = 30<br \/>\nplugin.puppet.config = \/etc\/puppet\/puppet.conf<br \/>\nplugin.puppet.resource_allow_managed_resources = true<\/p>\n<p>&nbsp;<\/p>\n<p># Facts<br \/>\nfactsource = yaml<br \/>\nplugin.yaml = \/etc\/mcollective\/facts.yaml<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>mcollective client<\/p>\n<p>\u5b89\u88c5<\/p>\n<pre><code>[root@puppetserver rpms]# yum install mcollective-common  mcollective-client<\/code><\/pre>\n<p>\u914d\u7f6e<\/p>\n<p>[root@puppet hostname]# cat \/etc\/mcollective\/client.cfg<br \/>\nmain_collective = mcollective<br \/>\ncollectives = mcollective<br \/>\nlibdir = \/usr\/libexec\/mcollective<br \/>\nlogger_type = console<br \/>\nloglevel = warn<\/p>\n<p># Plugins<br \/>\nsecurityprovider = psk<br \/>\nplugin.psk = 123456<\/p>\n<p>connector = activemq<br \/>\nplugin.activemq.pool.size = 1<br \/>\nplugin.activemq.pool.1.host = 192.168.3.11<br \/>\nplugin.activemq.pool.1.port = 61613<br \/>\nplugin.activemq.pool.1.user = mcollective<br \/>\nplugin.activemq.pool.1.password = secret<br \/>\n#connector = stomp<br \/>\n#plugin.stomp.host = 192.168.3.11<br \/>\n#plugin.stomp.port = 61613<br \/>\n#plugin.stomp.user = mcollective<br \/>\n#plugin.stomp.password = secret<br \/>\nplugin.puppet.command = puppet agent<br \/>\nplugin.puppet.splay = true<br \/>\nplugin.puppet.splaylimit = 30<br \/>\nplugin.puppet.config = \/etc\/puppet\/puppet.conf<br \/>\nplugin.puppet.resource_allow_managed_resources = true<\/p>\n<p># Facts<br \/>\nfactsource = yaml<br \/>\nplugin.yaml = \/etc\/mcollective\/facts.yaml<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>\u5176\u5b9e\u8ddf\u670d\u52a1\u5668\u914d\u7f6e\u4e00\u6837\u5373\u53ef<\/p>\n<p>\u542f\u52a8\u670d\u52a1 \u6d4b\u8bd5Mcollective\u4e0eMiddleware\u901a\u4fe1<\/p>\n<pre><code>[root@puppetserver rpms]# mco ping  #\u68c0\u67e5\u6240\u6709\u5b58\u6d3b\u7684\u8282\u70b9\r\nagent2.kisspuppet.com                       time=119.98 ms\r\nagent1.kisspuppet.com                       time=159.31 ms\r\n---- ping statistics ----\r\n2 replies max: 159.31 min: 119.98 avg: 139.64 \r\n[root@puppetserver rpms]# mco find\r\nagent1.kisspuppet.com\r\nagent2.kisspuppet.com<\/code><\/pre>\n<p>&nbsp;<\/p>\n<h3>Mcollective\u63d2\u4ef6\u7684\u5b89\u88c5\u53ca\u6d4b\u8bd5<\/h3>\n<p><strong>\u56e0\u4e3amcollective \u53ea\u662f\u4e2a\u6846\u67b6\uff0c\u8fd8\u9700\u8981\u5b89\u88c5plugin<\/strong><\/p>\n<p><strong>\u6211\u4e3b\u8981\u8981\u7528 mcollective-puppet-agent\u00a0 \u548c facter<\/strong><\/p>\n<p><strong>\u5148\u8bf4mcollective-puppet-agent\u00a0 <\/strong><\/p>\n<p>\u5b98\u7f51\u6587\u6863\uff1a<a title=\"https:\/\/github.com\/puppetlabs\/mcollective-puppet-agent\" href=\"https:\/\/github.com\/puppetlabs\/mcollective-puppet-agent\">https:\/\/github.com\/puppetlabs\/mcollective-puppet-agent<\/a><\/p>\n<p>mcollective\u5ba2\u6237\u7aef\u548c\u670d\u52a1\u7aef\u8981\u5b89\u88c5<\/p>\n<pre><code>yum install mcollective-puppet-agent mcollective-puppet-common<\/code><\/pre>\n<pre><code> yum install mcollective-puppet-client mcollective-puppet-common<\/code><\/pre>\n<p><strong>\u8f7d\u5165Agent\u63d2\u4ef6<\/strong><\/p>\n<pre><code>[root@puppetserver rpms]# mco  #\u5ba2\u6237\u7aef\u9ed8\u8ba4\u5728\u81ea\u52a8\u8f7d\u5165\r\nThe Marionette Collective version 2.2.4\r\nusage: \/usr\/bin\/mco command &lt;options&gt;\r\nKnown commands:\r\n   completion           facts                find                \r\n   help                 inventory            ping                \r\n   plugin               puppet               rpc                 \r\nType '\/usr\/bin\/mco help' for a detailed list of commands and '\/usr\/bin\/mco help command'\r\nto get detailed help for a command\r\n[root@agent1 ~]# \/etc\/rc.d\/init.d\/mcollective restart\r\nShutting down mcollective:                                 [  OK  ]\r\nStarting mcollective:                                      [  OK  ]<\/code><\/pre>\n<p><strong>\u9a8c\u8bc1Agent\u63d2\u4ef6\u662f\u5426\u88ab\u8f7d\u5165<\/strong><\/p>\n<pre><code>[root@puppetserver rpms]# mco inventory agent1.kisspuppet.com #\u67e5\u770b\u8282\u70b9agent1\u662f\u5426\u5df2\u7ecf\u8f7d\u5165puppet\u63d2\u4ef6\r\nInventory for agent1.kisspuppet.com:\r\n   Server Statistics:\r\n                      Version: 2.2.4\r\n                   Start Time: Thu Oct 03 16:09:03 +0800 2013\r\n                  Config File: \/etc\/mcollective\/server.cfg\r\n                  Collectives: mcollective\r\n              Main Collective: mcollective\r\n                   Process ID: 8902\r\n               Total Messages: 3\r\n      Messages Passed Filters: 3\r\n            Messages Filtered: 0\r\n             Expired Messages: 0\r\n                 Replies Sent: 2\r\n         Total Processor Time: 0.46 seconds\r\n                  System Time: 0.12 seconds\r\n   Agents:\r\n      discovery       puppet          rpcutil        \r\n   Data Plugins:\r\n      agent           fstat           puppet   #\u5df2\u7ecf\u8f7d\u5165puppet\u63d2\u4ef6      \r\n      resource                                       \r\n   Configuration Management Classes:\r\n      No classes applied\r\n   Facts:\r\n      mcollective =&gt; 1<\/code><\/pre>\n<p>&nbsp;<\/p>\n<p><strong>\u8bb0\u5f97\u5982\u679cAgents:\u00a0 \u91cc\u9762\u6ca1\u6709puppet \u4f1a\u62a5\u00a0 No request sent, we did not discover any nodes.<\/strong><\/p>\n<p><a href=\"https:\/\/www.hmouse.cn\/wp-content\/uploads\/2014\/06\/image2.png\"><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px; border-width: 0px;\" title=\"image\" src=\"https:\/\/www.hmouse.cn\/wp-content\/uploads\/2014\/06\/image_thumb2.png\" alt=\"image\" width=\"244\" height=\"149\" border=\"0\" \/><\/a><\/p>\n<p>\u4f1a\u62a5\u9519<\/p>\n<p><a href=\"https:\/\/www.hmouse.cn\/wp-content\/uploads\/2014\/06\/image3.png\"><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px; border-width: 0px;\" title=\"image\" src=\"https:\/\/www.hmouse.cn\/wp-content\/uploads\/2014\/06\/image_thumb3.png\" alt=\"image\" width=\"244\" height=\"37\" border=\"0\" \/><\/a><\/p>\n<p>\u8fd9\u4e2a\u6211\u5728\u6d4b\u8bd5\u7684\u65f6\u5019\uff0c\u89e3\u51b3\u4e86\u5f88\u4e45\u3002<\/p>\n<p>&nbsp;<\/p>\n<p><strong>\u4eceMCollective\u4e2d\u8fd0\u884cPuppet<\/strong><\/p>\n<p>\u5728\u8fd0\u884c\u547d\u4ee4\u4e4b\u524d\uff0c\u53ef\u4ee5\u5728\u8282\u70b9\u67e5\u770bpuppet\u65e5\u5fd7\u548cpuppetd\u670d\u52a1\u7684\u542f\u505c\u6765\u5224\u65ad\u547d\u4ee4\u662f\u5426\u8c03\u7528\u4e86puppetd\u8fdb\u7a0b\u3002<\/p>\n<pre><code>[root@puppetserver ~]# mco puppet  --noop --verbose status #\u67e5\u770b\u8282\u70b9agent\u5b88\u62a4\u8fdb\u7a0b\u72b6\u6001\r\nDiscovering hosts using the mc method for 2 second(s) .... 2\r\n * [ ============================================================&gt; ] 2 \/ 2\r\n   agent2.kisspuppet.com: Currently stopped; last completed run 9 hours 35 minutes 36 seconds ago\r\n   agent1.kisspuppet.com: Currently stopped; last completed run 9 hours 35 minutes 34 seconds ago\r\nSummary of Applying:\r\n   false = 2\r\nSummary of Daemon Running:\r\n   stopped = 2\r\nSummary of Enabled:\r\n   enabled = 2\r\n[root@puppetserver rpms]# mco puppet -v runonce  \r\nDiscovering hosts using the mc method for 2 second(s) .... 2\r\n * [ ============================================================&gt; ] 2 \/ 2\r\nagent1.kisspuppet.com                      : OK\r\n    {:summary=&gt;      \"Started a background Puppet run using the 'puppet agent --onetime --daemonize --color=false --splay --splaylimit 30' command\"}\r\nagent2.kisspuppet.com                      : OK\r\n    {:summary=&gt;      \"Started a background Puppet run using the 'puppet agent --onetime --daemonize --color=false --splay --splaylimit 30' command\"}\r\n---- rpc stats ----\r\n           Nodes: 2 \/ 2\r\n     Pass \/ Fail: 2 \/ 0\r\n      Start Time: Thu Oct 03 16:12:03 +0800 2013\r\n  Discovery Time: 2007.23ms\r\n      Agent Time: 3591.72ms\r\n      Total Time: 5598.94ms<\/code><\/pre>\n<p>&nbsp;<\/p>\n<p><strong>\u5907\u6ce8\uff1a<\/strong>\u5f53\u4f7f\u7528MCollective\u8fd0\u884cPuppet\u65f6\uff0c\u8981\u6c42\u5728\u6240\u6709\u88ab\u7ba1\u7406\u7684\u8282\u70b9\u4e0aPuppet agent\u5b88\u62a4\u8fdb\u7a0b\u90fd\u9700\u8981\u88ab\u5173\u95ed\u3002\u5728\u6bcf\u6b21\u4f7f\u7528<code>mco puppet -v runonce<\/code>\u547d\u4ee4\u8c03\u7528<code>puppetd agent<\/code>\u65f6\uff0cMCollective\u90fd\u4f1a\u4ea7\u751f\u4e00\u4e2a\u65b0\u7684Puppet\u8fdb\u7a0b\u3002\u8fd9\u4e2a\u8fdb\u7a0b\u4f1a\u548c\u4efb\u4f55\u5df2\u7ecf\u8fd0\u884c\u7684Puppet agent\u5b88\u62a4\u8fdb\u7a0b\u4ea7\u751f\u529f\u80fd\u6027\u7684\u91cd\u590d\u3002<\/p>\n<p>\u5f53Puppet\u4f7f\u7528<code>--runonce<\/code>\u53c2\u6570\u8fd0\u884c\u65f6\uff0cagent\u4f1a\u5728\u540e\u53f0\u8fd0\u884c\u3002\u6240\u4ee5\u867d\u7136MCollective\u6210\u529f\u8fd0\u884c\u4e86Puppet\uff0c\u4f46\u5b9e\u9645\u4e0a\u7684Puppet agent\u8fd0\u884c\u53ef\u80fd<a href=\"http:\/\/kisspuppet.com\/2013\/11\/10\/my-fact\/\">http:\/\/kisspuppet.com\/2013\/11\/10\/my-fact\/<\/a>\u5e76\u4e0d\u6210\u529f\u3002\u9700\u8981\u67e5\u770bPuppet\u62a5\u544a\u6765\u786e\u5b9a\u6bcf\u4e00\u4e2aPuppet agent\u8fd0\u884c\u7684\u7ed3\u679c\u3002MCollective\u8fd4\u56de\u7684OK\u503c\u8868\u793aMCollective\u670d\u52a1\u5668\u6210\u529f\u5730\u542f\u52a8\u4e86puppetd\u8fdb\u7a0b\u5e76\u4e14\u6ca1\u6709\u5f97\u5230\u4efb\u4f55\u8f93\u51fa\u3002<\/p>\n<p>&nbsp;<\/p>\n<h4>\u5b89\u88c5facter\u63d2\u4ef6<\/h4>\n<p><code>[root@agent1 ~]# yum install mcollective-facter-facts [root@agent1 rpms]# ll \/usr\/libexec\/mcollective\/mcollective\/facts\/ total 12 -rw-r--r-- 1 root root 422 Feb 21 2013 facter_facts.ddl -rw-r--r-- 1 root root 945 Feb 21 2013 facter_facts.rb -rw-r--r-- 1 root root 1530 May 21 01:34 yaml_facts.rb<\/code><\/p>\n<p>&nbsp;<\/p>\n<p><code>[root@agent1 ~]# vim \/etc\/mcollective\/server.cfg \u2026 # Facts #factsource = yaml #\u6ce8\u91ca\u6389 factsource = facter plugin.yaml = \/etc\/mcollective\/facts.yaml [root@agent1 rpms]# \/etc\/rc.d\/init.d\/mcollective restart Shutting down mcollective: [ OK ] Starting mcollective: [ OK ]<\/code><\/p>\n<p>&nbsp;<\/p>\n<pre><code>[root@puppetserver rpms]# mco inventory agent1.kisspuppet.com #\u67e5\u770b\u8282\u70b9agent1\u662f\u5426\u52a0\u8f7d\u4e86facts\u63d2\u4ef6\r\nInventory for agent1.kisspuppet.com:\r\n   Server Statistics:\r\n                      Version: 2.2.4\r\n                   Start Time: Thu Oct 03 16:31:47 +0800 2013\r\n                  Config File: \/etc\/mcollective\/server.cfg\r\n                  Collectives: mcollective\r\n              Main Collective: mcollective\r\n                   Process ID: 9485\r\n               Total Messages: 37\r\n      Messages Passed Filters: 33\r\n            Messages Filtered: 4\r\n             Expired Messages: 0\r\n                 Replies Sent: 32\r\n         Total Processor Time: 0.74 seconds\r\n                  System Time: 0.21 seconds\r\n   Agents:\r\n      discovery       puppet          rpcutil        \r\n   Data Plugins:\r\n      agent           fstat           puppet         \r\n      resource                                       \r\n   Configuration Management Classes:\r\n      No classes applied\r\n   Facts:  #\u53ef\u4ee5\u770b\u5230\u83b7\u53d6\u7684\u8282\u70b9facter\u4fe1\u606f\uff08\u83b7\u53d6\u4fe1\u606f\u9700\u8981\u4e00\u4e9b\u7b49\u5f85\u65f6\u95f4\uff09\r\n      architecture =&gt; x86_64\r\n      augeasversion =&gt; 0.10.0\r\n      bios_release_date =&gt; 07\/02\/2012\r\n      bios_vendor =&gt; Phoenix Technologies LTD\r\n      bios_version =&gt; 6.00\r\n      blockdevice_fd0_size =&gt; 4096\r\n     \u2026\r\n      uptime_days =&gt; 0\r\n      uptime_hours =&gt; 20\r\n      uptime_seconds =&gt; 74506\r\n      uuid =&gt; 564DFBAB-CADC-FC69-36CA-955BFDB30F43\r\n      virtual =&gt; vmware\r\n<\/code><\/pre>\n<hr \/>\n<pre><code>[root@puppetserver rpms]# mco facts lsbdistdescription -v  #\u4f7f\u7528mco facts\u547d\u4ee4\u5bf9\u64cd\u4f5c\u7cfb\u7edf\u7c7b\u578b\u8fdb\u884c\u663e\u793a\r\nDiscovering hosts using the mc method for 2 second(s) .... 2\r\nReport for fact: lsbdistdescription\r\n        Red Hat Enterprise Linux Server release 5.7 (Tikanga)found 1 times\r\n            agent2.kisspuppet.com\r\n        Red Hat Enterprise Linux Server release 5.8 (Tikanga)found 1 times\r\n            agent1.kisspuppet.com\r\n---- rpc stats ----\r\n           Nodes: 2 \/ 2\r\n     Pass \/ Fail: 2 \/ 0\r\n      Start Time: Thu Oct 03 16:59:04 +0800 2013\r\n  Discovery Time: 2004.83ms\r\n      Agent Time: 67.32ms\r\n      Total Time: 2072.15ms<\/code><\/pre>\n<p>&nbsp;<\/p>\n<p><code>root@puppetserver rpms]# mco facts lsbdistdescription #\u4f7f\u7528mco facts\u547d\u4ee4\u5bf9\u64cd\u4f5c\u7cfb\u7edf\u7c7b\u578b\u8fdb\u884c\u7edf\u8ba1 Report for fact: lsbdistdescription Red Hat Enterprise Linux Server release 5.7 (Tikanga)found 1 times Red Hat Enterprise Linux Server release 5.8 (Tikanga)found 1 times Finished processing 2 \/ 2 hosts in 79.15 ms [root@puppetserver rpms]# mco facts -v --with-fact hostname='agent1' memoryfree #\u67e5\u770b\u4e3b\u673aagent1\u7684\u5269\u4f59\u5185\u5b58 Discovering hosts using the mc method for 2 second(s) .... 1 Report for fact: memoryfree 795.13 MB found 1 times agent1.kisspuppet.com ---- rpc stats ---- Nodes: 1 \/ 1 Pass \/ Fail: 1 \/ 0 Start Time: Thu Oct 03 17:02:13 +0800 2013 Discovery Time: 2005.65ms Agent Time: 49.37ms Total Time: 2055.03ms<\/code><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<h4>\u4f7f\u7528\u5143\u6570\u636e\u5b9a\u4f4d\u4e3b\u673a<\/h4>\n<p><strong>4.3.1 \u4f7f\u7528\u9ed8\u8ba4facter\u5143\u6570\u636e\u5b9a\u4f4d\u4e3b\u673a<\/strong><\/p>\n<p><strong>4.3.1.1 \u89e6\u53d1\u6240\u6709\u7cfb\u7edf\u4e3aRedHat\uff0c\u7248\u672c\u4e3a5.7\u7684\u6240\u6709\u8282\u70b9puppetd\u5b88\u62a4\u8fdb\u7a0b<\/strong><\/p>\n<pre><code>[root@puppetserver rpms]# mco puppet -v runonce   rpc --np -F  operatingsystemrelease='5.7' -F operatingsystem='RedHat'   \r\nDiscovering hosts using the mc method for 2 second(s) .... 1\r\nagent2.kisspuppet.com                      : OK\r\n    {:summary=&gt;      \"Started a background Puppet run using the 'puppet agent --onetime --daemonize --color=false --splay --splaylimit 30' command\"}\r\n---- rpc stats ----\r\n           Nodes: 1 \/ 1\r\n     Pass \/ Fail: 1 \/ 0\r\n      Start Time: Thu Oct 03 17:03:56 +0800 2013\r\n  Discovery Time: 2008.09ms\r\n      Agent Time: 1187.69ms\r\n      Total Time: 3195.78ms\r\n<\/code><\/pre>\n<p><strong>4.3.1.2 \u89e6\u53d1\u6240\u6709\u7cfb\u7edf\u4e3aRedHat\uff0ckernel\u7248\u672c\u4e3a2.6.18\u7684\u6240\u6709\u8282\u70b9puppetd\u5b88\u62a4\u8fdb\u7a0b<\/strong><\/p>\n<pre><code>[root@puppetserver rpms]# mco puppet -v runonce   rpc --np -F  kernelversion='2.6.18'  -F operatingsystem='RedHat'\r\nDiscovering hosts using the mc method for 2 second(s) .... 2\r\nagent2.kisspuppet.com                      : OK\r\n    {:summary=&gt;      \"Started a background Puppet run using the 'puppet agent --onetime --daemonize --color=false --splay --splaylimit 30' command\"}\r\nagent1.kisspuppet.com                      : OK\r\n    {:summary=&gt;      \"Started a background Puppet run using the 'puppet agent --onetime --daemonize --color=false --splay --splaylimit 30' command\"}\r\n---- rpc stats ----\r\n           Nodes: 2 \/ 2\r\n     Pass \/ Fail: 2 \/ 0\r\n      Start Time: Thu Oct 03 17:06:15 +0800 2013\r\n  Discovery Time: 2004.32ms\r\n      Agent Time: 1308.34ms\r\n      Total Time: 3312.66ms\r\n<\/code><\/pre>\n<p><strong>4.3.2 \u4f7f\u7528\u81ea\u5b9a\u4e49facter\u5143\u6570\u636e\u5b9a\u4f4d\u4e3b\u673a<\/strong><\/p>\n<p><strong>\u5907\u6ce8\uff1a<\/strong>\u4f7f\u7528\u81ea\u5b9a\u4e49facter\u5143\u6570\u636e\u53ef\u4ee5\u66f4\u52a0\u7075\u6d3b\u7684\u5b9a\u4f4d\u4e3b\u673a\uff0c\u5982\u4f55\u5b9a\u4e49fact\u53ef\u53c2\u8003\u535a\u6587\u300a<a href=\"http:\/\/kisspuppet.com\/2013\/11\/15\/my-fact\/\">\u901a\u8fc7\u81ea\u5b9a\u4e49fact\u589e\u5f3aMCollective\u63a8\u9001\u66f4\u65b0\u5143\u6570\u636e\u7684\u7075\u6d3b\u6027<\/a>\u300b<\/p>\n<p><strong>4.3.2.1 \u5728agent1\u4e0a\u5b9a\u4e49facter my_apply1\u548cmy_apply2<\/strong><\/p>\n<pre><code>[root@agent1 mcollective]# facter -p | grep my_apply\r\nmy_apply1 =&gt; apache\r\nmy_apply2 =&gt; mysql\r\n<\/code><\/pre>\n<p><strong>4.3.2.2 \u5728agent2\u4e0a\u5b9a\u4e49facter my_apply2\u548cmy_apply3<\/strong><\/p>\n<pre><code>[root@agent2 mcollective]# facter -p | grep my_apply\r\nmy_apply2 =&gt; mysql\r\nmy_apply3 =&gt; php\r\n<\/code><\/pre>\n<p><strong>4.3.2.3 \u5728MCollective\u5ba2\u6237\u7aef\u6d4b\u8bd5\u8282\u70b9\u81ea\u5b9a\u4e49facter\u662f\u5426\u6b63\u786e<\/strong><\/p>\n<pre><code>[root@puppetserver facter]# mco inventory agent1.kisspuppet.com  | grep my_apply\r\n      my_apply1 =&gt; apache\r\n      my_apply2 =&gt; mysql\r\n[root@puppetserver facter]# mco inventory agent2.kisspuppet.com  | grep my_apply\r\n      my_apply2 =&gt; mysql\r\n      my_apply3 =&gt; php\r\n<\/code><\/pre>\n<p><strong>4.3.2.4 \u901a\u8fc7\u81ea\u5b9a\u4e49facter\u5b9a\u4f4d\u4e3b\u673a\u89e6\u53d1\u66f4\u65b0<\/strong><\/p>\n<pre><code>[root@puppetserver facter]# mco puppet -v runonce  mco facts -v --with-fact  my_apply3='php' #\u7b5b\u9009\u8282\u70b9facter\u53d8\u91cfmy_apply3=php\u7684\u4e3b\u673a\u8fdb\u884c\u89e6\u53d1puppetd\u5b88\u62a4\u8fdb\u7a0b\r\nDiscovering hosts using the mc method for 2 second(s) .... 1\r\n * [ ============================================================&gt; ] 1 \/ 1\r\nagent2.kisspuppet.com                      : OK\r\n    {:summary=&gt;      \"Started a background Puppet run using the 'puppet agent --onetime --daemonize --color=false --splay --splaylimit 30' command\"}\r\n---- rpc stats ----\r\n           Nodes: 1 \/ 1\r\n     Pass \/ Fail: 1 \/ 0\r\n      Start Time: Thu Oct 03 23:33:54 +0800 2013\r\n  Discovery Time: 2005.35ms\r\n      Agent Time: 1078.86ms\r\n      Total Time: 3084.21ms<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>mcollective\u5b89\u88c5<\/p>\n<p>\u65b0\u7684\u7248\u672c\u4e0d\u652f\u6301stomp\u534f\u8bae\uff0c\u5751\u6b7b\u6211\u4e86\uff0c\u770b\u7f51\u4e0a\u7684\u5927\u591a\u6570\u90fd\u662f\u7528stomp\u53bb\u8fde\u7684\u3002\u56de\u6765\u6211\u88ab\u903c\u65e0\u5948\uff0c\u53ea\u80fd\u7528activemq\uff0c\u7136\u540e\u901a\u8fc7activemq\u53bb\u8fde<\/p>\n<p>\u53c2\u8003url\uff1a<a title=\"http:\/\/kisspuppet.com\/2013\/11\/10\/mcollective-middleware\/\" href=\"http:\/\/kisspuppet.com\/2013\/11\/10\/mcollective-middleware\/\">http:\/\/kisspuppet.com\/2013\/11\/10\/mcollective-middleware\/<\/a>\u00a0 \uff08\u8fd9\u4e2a\u8bf4\u7684\u6bd4\u8f83\u8be6\u7ec6\uff09<\/p>\n<p>\u8bf4\u8bf4\u539f\u7406\u5427<\/p>\n<p>&nbsp;<\/p>\n<h4>1.3 \u5de5\u4f5c\u539f\u7406\u56fe<\/h4>\n<p><a href=\"http:\/\/kisspuppet.com\/img\/mcollective-1.png\"><img decoding=\"async\" src=\"http:\/\/kisspuppet.com\/img\/mcollective-1.png\" alt=\"mcollective\u89e6\u53d1\u66f4\u65b0\u56fe\" \/><\/a><\/p>\n<p>\u770b\u51fa\u6765\u4e86\u5176\u5b9e\u4e1c\u897f \u5206\u62103\u4e2a\uff0c client + \u4e2d\u95f4\u4ef6+sever<\/p>\n<p>\u4e2d\u95f4\u4ef6\u00a0 activemq\u00a0 \uff08\u5176\u5b9e rabbitmq\u4e5f\u53ef\u4ee5\uff0c\u5f88\u591a\u4e66\u90fd\u4f7f\u7528\u8fd9\u4e2a\uff0c\u4f46\u662f\u6211\u5b89\u88c5\u7684\u7248\u672c\u662f\u5efa\u8bae\u4f7f\u7528activemq\u00a0 \uff09<\/p>\n<p>\u5b89\u88c5<\/p>\n<pre><code> yum install tanukiwrapper activemq activemq-info-provider<\/code><\/pre>\n<p>\u914d\u7f6e\u00a0\u00a0 \uff08\u5176\u5b9e\u9ed8\u8ba4\u7684\u4e0d\u9700\u8981\u4fee\u6539\uff0c\u6700\u4e3b\u8981\u7684\u5c31\u6539\u4e0b\u8d26\u53f7\u540d\u548c\u5bc6\u7801\uff09<\/p>\n<p>\u4e3b\u8981\u914d\u7f6eMCollective\u8fde\u63a5\u7684\u7aef\u53e3\u4ee5\u53ca\u8d26\u53f7\u3001\u5bc6\u7801\u53ca\u6743\u9650<\/p>\n<p><code>[root@puppetserver rpms]# vim \/etc\/activemq\/activemq.xml \u2026 &lt;simpleAuthenticationPlugin&gt; &lt;users&gt; &lt;!-- &lt;authenticationUser username=\"${activemq.username}\" password=\"${activemq.password}\" groups=\"admins,everyone\"\/&gt; --&gt; #\u7981\u7528 &lt;authenticationUser username=\"mcollective\" password=\"secret\" groups=\"mcollective,admins,everyone\"\/&gt; #\u914d\u7f6e\u901a\u4fe1\u7684\u8d26\u53f7\u53ca\u5bc6\u7801 &lt;\/users&gt; &lt;\/simpleAuthenticationPlugin&gt; \u2026 &lt;authorizationPlugin&gt; #\u914d\u7f6e\u6743\u9650\uff0c\u9ed8\u8ba4\u5373\u53ef &lt;map&gt; &lt;authorizationMap&gt; &lt;authorizationEntries&gt; &lt;authorizationEntry queue=\"&gt;\" write=\"admins\" read=\"admins\" admin=\"admins\" \/&gt; &lt;authorizationEntry topic=\"&gt;\" write=\"admins\" read=\"admins\" admin=\"admins\" \/&gt; &lt;authorizationEntry topic=\"mcollective.&gt;\" write=\"mcollective\" read=\"mcollective\" admin=\"mcollective\" \/&gt; &lt;authorizationEntry topic=\"mcollective.&gt;\" write=\"mcollective\" read=\"mcollective\" admin=\"mcollective\" \/&gt; &lt;authorizationEntry topic=\"ActiveMQ.Advisory.&gt;\" read=\"everyone\" write=\"everyone\" admin=\"everyone\"\/&gt; &lt;\/authorizationEntries&gt; &lt;\/authorizationMap&gt; &lt;\/map&gt; &lt;\/authorizationPlugin&gt; \u2026 &lt;transportConnectors&gt; &lt;transportConnector name=\"openwire\" uri=\"tcp:\/\/0.0.0.0:61616\"\/&gt; &lt;transportConnector name=\"stomp+nio\" uri=\"stomp:\/\/0.0.0.0:61613\"\/&gt; #\u914d\u7f6e\u901a\u4fe1\u534f\u8bae\u4e3astomp\uff0c\u76d1\u542c61613\u7aef\u53e3 &lt;\/transportConnectors&gt;<\/code><\/p>\n<p>\u542f\u52a8<\/p>\n<pre><code>[root@puppetserver rpms]# \/etc\/rc.d\/init.d\/activemq start\r\nStarting ActiveMQ Broker...\r\n[root@puppetserver rpms]# chkconfig activemq on\r\n[root@puppetserver rpms]# netstat -nlatp | grep 61613  #\u67e5\u770b\u76d1\u542c\u7aef\u53e3\r\ntcp        0      0 :::61613                    :::*                        LISTEN      33805\/java      <\/code><\/pre>\n<p>\u5b89\u88c5mcollective<\/p>\n<p>mcollective sever<\/p>\n<pre><code>yum install mcollective  mcollective-common<\/code><\/pre>\n<p>\u914d\u7f6e<\/p>\n<p>[root@cobar3 ~]# cat \/etc\/mcollective\/server.cfg<br \/>\nmain_collective = mcollective<br \/>\ncollectives = mcollective<br \/>\nlibdir = \/usr\/libexec\/mcollective<br \/>\nlogfile = \/var\/log\/mcollective.log<br \/>\nloglevel = info<br \/>\ndaemonize = 1<\/p>\n<p># Plugins<br \/>\nsecurityprovider = psk<br \/>\nplugin.psk = 123456\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 #\u8ddf\u5ba2\u6237\u7aef\u4e00\u6837<\/p>\n<p>connector = activemq<br \/>\nplugin.activemq.pool.size = 1<br \/>\nplugin.activemq.pool.1.host = 192.168.3.11\u00a0\u00a0\u00a0 #activemq\u670d\u52a1\u5668ip<br \/>\nplugin.activemq.pool.1.port = 61613<br \/>\nplugin.activemq.pool.1.user = mcollective\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 #\u8d26\u53f7<br \/>\nplugin.activemq.pool.1.password = secret\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 #\u5bc6\u7801<\/p>\n<p>#connector = stomp<br \/>\n#plugin.stomp.host = 192.168.3.11<br \/>\n#plugin.stomp.port = 61613<br \/>\n#plugin.stomp.user = mcollective<br \/>\n#plugin.stomp.password = secret<br \/>\nplugin.puppet.command = puppet agent\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 #\u8fd9\u662fmcollective-puppet-agent\u63a8\u8350\u6dfb\u52a0\u7684\uff0c\u5177\u4f53\u6ca1\u52a0\u6211\u4e5f\u6ca1\u6d4b\uff0c\u6709\u4ec0\u4e48\u95ee\u9898<br \/>\nplugin.puppet.splay = true<br \/>\nplugin.puppet.splaylimit = 30<br \/>\nplugin.puppet.config = \/etc\/puppet\/puppet.conf<br \/>\nplugin.puppet.resource_allow_managed_resources = true<\/p>\n<p>&nbsp;<\/p>\n<p># Facts<br \/>\nfactsource = yaml<br \/>\nplugin.yaml = \/etc\/mcollective\/facts.yaml<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>mcollective client<\/p>\n<p>\u5b89\u88c5<\/p>\n<pre><code>[root@puppetserver rpms]# yum install mcollective-common  mcollective-client<\/code><\/pre>\n<p>\u914d\u7f6e<\/p>\n<p>[root@puppet hostname]# cat \/etc\/mcollective\/client.cfg<br \/>\nmain_collective = mcollective<br \/>\ncollectives = mcollective<br \/>\nlibdir = \/usr\/libexec\/mcollective<br \/>\nlogger_type = console<br \/>\nloglevel = warn<\/p>\n<p># Plugins<br \/>\nsecurityprovider = psk<br \/>\nplugin.psk = 123456<\/p>\n<p>connector = activemq<br \/>\nplugin.activemq.pool.size = 1<br \/>\nplugin.activemq.pool.1.host = 192.168.3.11<br \/>\nplugin.activemq.pool.1.port = 61613<br \/>\nplugin.activemq.pool.1.user = mcollective<br \/>\nplugin.activemq.pool.1.password = secret<br \/>\n#connector = stomp<br \/>\n#plugin.stomp.host = 192.168.3.11<br \/>\n#plugin.stomp.port = 61613<br \/>\n#plugin.stomp.user = mcollective<br \/>\n#plugin.stomp.password = secret<br \/>\nplugin.puppet.command = puppet agent<br \/>\nplugin.puppet.splay = true<br \/>\nplugin.puppet.splaylimit = 30<br \/>\nplugin.puppet.config = \/etc\/puppet\/puppet.conf<br \/>\nplugin.puppet.resource_allow_managed_resources = true<\/p>\n<p># Facts<br \/>\nfactsource = yaml<br \/>\nplugin.yaml = \/etc\/mcollective\/facts.yaml<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>\u5176\u5b9e\u8ddf\u670d\u52a1\u5668\u914d\u7f6e\u4e00\u6837\u5373\u53ef<\/p>\n<p>\u542f\u52a8\u670d\u52a1 \u6d4b\u8bd5Mcollective\u4e0eMiddleware\u901a\u4fe1<\/p>\n<pre><code>[root@puppetserver rpms]# mco ping  #\u68c0\u67e5\u6240\u6709\u5b58\u6d3b\u7684\u8282\u70b9\r\nagent2.kisspuppet.com                       time=119.98 ms\r\nagent1.kisspuppet.com                       time=159.31 ms\r\n---- ping statistics ----\r\n2 replies max: 159.31 min: 119.98 avg: 139.64 \r\n[root@puppetserver rpms]# mco find\r\nagent1.kisspuppet.com\r\nagent2.kisspuppet.com<\/code><\/pre>\n<p>&nbsp;<\/p>\n<h3>Mcollective\u63d2\u4ef6\u7684\u5b89\u88c5\u53ca\u6d4b\u8bd5<\/h3>\n<p><strong>\u56e0\u4e3amcollective \u53ea\u662f\u4e2a\u6846\u67b6\uff0c\u8fd8\u9700\u8981\u5b89\u88c5plugin<\/strong><\/p>\n<p><strong>\u6211\u4e3b\u8981\u8981\u7528 mcollective-puppet-agent\u00a0 \u548c facter<\/strong><\/p>\n<p><strong>\u5148\u8bf4mcollective-puppet-agent\u00a0 <\/strong><\/p>\n<p>\u5b98\u7f51\u6587\u6863\uff1a<a title=\"https:\/\/github.com\/puppetlabs\/mcollective-puppet-agent\" href=\"https:\/\/github.com\/puppetlabs\/mcollective-puppet-agent\">https:\/\/github.com\/puppetlabs\/mcollective-puppet-agent<\/a><\/p>\n<p>mcollective\u5ba2\u6237\u7aef\u548c\u670d\u52a1\u7aef\u8981\u5b89\u88c5<\/p>\n<pre><code>yum install mcollective-puppet-agent mcollective-puppet-common<\/code><\/pre>\n<pre><code> yum install mcollective-puppet-client mcollective-puppet-common<\/code><\/pre>\n<p><strong>\u8f7d\u5165Agent\u63d2\u4ef6<\/strong><\/p>\n<pre><code>[root@puppetserver rpms]# mco  #\u5ba2\u6237\u7aef\u9ed8\u8ba4\u5728\u81ea\u52a8\u8f7d\u5165\r\nThe Marionette Collective version 2.2.4\r\nusage: \/usr\/bin\/mco command &lt;options&gt;\r\nKnown commands:\r\n   completion           facts                find                \r\n   help                 inventory            ping                \r\n   plugin               puppet               rpc                 \r\nType '\/usr\/bin\/mco help' for a detailed list of commands and '\/usr\/bin\/mco help command'\r\nto get detailed help for a command\r\n[root@agent1 ~]# \/etc\/rc.d\/init.d\/mcollective restart\r\nShutting down mcollective:                                 [  OK  ]\r\nStarting mcollective:                                      [  OK  ]<\/code><\/pre>\n<p><strong>\u9a8c\u8bc1Agent\u63d2\u4ef6\u662f\u5426\u88ab\u8f7d\u5165<\/strong><\/p>\n<pre><code>[root@puppetserver rpms]# mco inventory agent1.kisspuppet.com #\u67e5\u770b\u8282\u70b9agent1\u662f\u5426\u5df2\u7ecf\u8f7d\u5165puppet\u63d2\u4ef6\r\nInventory for agent1.kisspuppet.com:\r\n   Server Statistics:\r\n                      Version: 2.2.4\r\n                   Start Time: Thu Oct 03 16:09:03 +0800 2013\r\n                  Config File: \/etc\/mcollective\/server.cfg\r\n                  Collectives: mcollective\r\n              Main Collective: mcollective\r\n                   Process ID: 8902\r\n               Total Messages: 3\r\n      Messages Passed Filters: 3\r\n            Messages Filtered: 0\r\n             Expired Messages: 0\r\n                 Replies Sent: 2\r\n         Total Processor Time: 0.46 seconds\r\n                  System Time: 0.12 seconds\r\n   Agents:\r\n      discovery       puppet          rpcutil        \r\n   Data Plugins:\r\n      agent           fstat           puppet   #\u5df2\u7ecf\u8f7d\u5165puppet\u63d2\u4ef6      \r\n      resource                                       \r\n   Configuration Management Classes:\r\n      No classes applied\r\n   Facts:\r\n      mcollective =&gt; 1<\/code><\/pre>\n<p>&nbsp;<\/p>\n<p><strong>\u8bb0\u5f97\u5982\u679cAgents:\u00a0 \u91cc\u9762\u6ca1\u6709puppet \u4f1a\u62a5\u00a0 No request sent, we did not discover any nodes.<\/strong><\/p>\n<p><a href=\"https:\/\/www.hmouse.cn\/wp-content\/uploads\/2014\/06\/image2.png\"><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px; border-width: 0px;\" title=\"image\" src=\"https:\/\/www.hmouse.cn\/wp-content\/uploads\/2014\/06\/image_thumb2.png\" alt=\"image\" width=\"244\" height=\"149\" border=\"0\" \/><\/a><\/p>\n<p>\u4f1a\u62a5\u9519<\/p>\n<p><a href=\"https:\/\/www.hmouse.cn\/wp-content\/uploads\/2014\/06\/image3.png\"><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px; border-width: 0px;\" title=\"image\" src=\"https:\/\/www.hmouse.cn\/wp-content\/uploads\/2014\/06\/image_thumb3.png\" alt=\"image\" width=\"244\" height=\"37\" border=\"0\" \/><\/a><\/p>\n<p>\u8fd9\u4e2a\u6211\u5728\u6d4b\u8bd5\u7684\u65f6\u5019\uff0c\u89e3\u51b3\u4e86\u5f88\u4e45\u3002<\/p>\n<p>&nbsp;<\/p>\n<p><strong>\u4eceMCollective\u4e2d\u8fd0\u884cPuppet<\/strong><\/p>\n<p>\u5728\u8fd0\u884c\u547d\u4ee4\u4e4b\u524d\uff0c\u53ef\u4ee5\u5728\u8282\u70b9\u67e5\u770bpuppet\u65e5\u5fd7\u548cpuppetd\u670d\u52a1\u7684\u542f\u505c\u6765\u5224\u65ad\u547d\u4ee4\u662f\u5426\u8c03\u7528\u4e86puppetd\u8fdb\u7a0b\u3002<\/p>\n<pre><code>[root@puppetserver ~]# mco puppet  --noop --verbose status #\u67e5\u770b\u8282\u70b9agent\u5b88\u62a4\u8fdb\u7a0b\u72b6\u6001\r\nDiscovering hosts using the mc method for 2 second(s) .... 2\r\n * [ ============================================================&gt; ] 2 \/ 2\r\n   agent2.kisspuppet.com: Currently stopped; last completed run 9 hours 35 minutes 36 seconds ago\r\n   agent1.kisspuppet.com: Currently stopped; last completed run 9 hours 35 minutes 34 seconds ago\r\nSummary of Applying:\r\n   false = 2\r\nSummary of Daemon Running:\r\n   stopped = 2\r\nSummary of Enabled:\r\n   enabled = 2\r\n[root@puppetserver rpms]# mco puppet -v runonce  \r\nDiscovering hosts using the mc method for 2 second(s) .... 2\r\n * [ ============================================================&gt; ] 2 \/ 2\r\nagent1.kisspuppet.com                      : OK\r\n    {:summary=&gt;      \"Started a background Puppet run using the 'puppet agent --onetime --daemonize --color=false --splay --splaylimit 30' command\"}\r\nagent2.kisspuppet.com                      : OK\r\n    {:summary=&gt;      \"Started a background Puppet run using the 'puppet agent --onetime --daemonize --color=false --splay --splaylimit 30' command\"}\r\n---- rpc stats ----\r\n           Nodes: 2 \/ 2\r\n     Pass \/ Fail: 2 \/ 0\r\n      Start Time: Thu Oct 03 16:12:03 +0800 2013\r\n  Discovery Time: 2007.23ms\r\n      Agent Time: 3591.72ms\r\n      Total Time: 5598.94ms<\/code><\/pre>\n<p>&nbsp;<\/p>\n<p><strong>\u5907\u6ce8\uff1a<\/strong>\u5f53\u4f7f\u7528MCollective\u8fd0\u884cPuppet\u65f6\uff0c\u8981\u6c42\u5728\u6240\u6709\u88ab\u7ba1\u7406\u7684\u8282\u70b9\u4e0aPuppet agent\u5b88\u62a4\u8fdb\u7a0b\u90fd\u9700\u8981\u88ab\u5173\u95ed\u3002\u5728\u6bcf\u6b21\u4f7f\u7528<code>mco puppet -v runonce<\/code>\u547d\u4ee4\u8c03\u7528<code>puppetd agent<\/code>\u65f6\uff0cMCollective\u90fd\u4f1a\u4ea7\u751f\u4e00\u4e2a\u65b0\u7684Puppet\u8fdb\u7a0b\u3002\u8fd9\u4e2a\u8fdb\u7a0b\u4f1a\u548c\u4efb\u4f55\u5df2\u7ecf\u8fd0\u884c\u7684Puppet agent\u5b88\u62a4\u8fdb\u7a0b\u4ea7\u751f\u529f\u80fd\u6027\u7684\u91cd\u590d\u3002<\/p>\n<p>\u5f53Puppet\u4f7f\u7528<code>--runonce<\/code>\u53c2\u6570\u8fd0\u884c\u65f6\uff0cagent\u4f1a\u5728\u540e\u53f0\u8fd0\u884c\u3002\u6240\u4ee5\u867d\u7136MCollective\u6210\u529f\u8fd0\u884c\u4e86Puppet\uff0c\u4f46\u5b9e\u9645\u4e0a\u7684Puppet agent\u8fd0\u884c\u53ef\u80fd<a href=\"http:\/\/kisspuppet.com\/2013\/11\/10\/my-fact\/\">http:\/\/kisspuppet.com\/2013\/11\/10\/my-fact\/<\/a>\u5e76\u4e0d\u6210\u529f\u3002\u9700\u8981\u67e5\u770bPuppet\u62a5\u544a\u6765\u786e\u5b9a\u6bcf\u4e00\u4e2aPuppet agent\u8fd0\u884c\u7684\u7ed3\u679c\u3002MCollective\u8fd4\u56de\u7684OK\u503c\u8868\u793aMCollective\u670d\u52a1\u5668\u6210\u529f\u5730\u542f\u52a8\u4e86puppetd\u8fdb\u7a0b\u5e76\u4e14\u6ca1\u6709\u5f97\u5230\u4efb\u4f55\u8f93\u51fa\u3002<\/p>\n<p>&nbsp;<\/p>\n<h4>\u5b89\u88c5facter\u63d2\u4ef6<\/h4>\n<p><code>[root@agent1 ~]# yum install mcollective-facter-facts [root@agent1 rpms]# ll \/usr\/libexec\/mcollective\/mcollective\/facts\/ total 12 -rw-r--r-- 1 root root 422 Feb 21 2013 facter_facts.ddl -rw-r--r-- 1 root root 945 Feb 21 2013 facter_facts.rb -rw-r--r-- 1 root root 1530 May 21 01:34 yaml_facts.rb<\/code><\/p>\n<p>&nbsp;<\/p>\n<p><code>[root@agent1 ~]# vim \/etc\/mcollective\/server.cfg \u2026 # Facts #factsource = yaml #\u6ce8\u91ca\u6389 factsource = facter plugin.yaml = \/etc\/mcollective\/facts.yaml [root@agent1 rpms]# \/etc\/rc.d\/init.d\/mcollective restart Shutting down mcollective: [ OK ] Starting mcollective: [ OK ]<\/code><\/p>\n<p>&nbsp;<\/p>\n<pre><code>[root@puppetserver rpms]# mco inventory agent1.kisspuppet.com #\u67e5\u770b\u8282\u70b9agent1\u662f\u5426\u52a0\u8f7d\u4e86facts\u63d2\u4ef6\r\nInventory for agent1.kisspuppet.com:\r\n   Server Statistics:\r\n                      Version: 2.2.4\r\n                   Start Time: Thu Oct 03 16:31:47 +0800 2013\r\n                  Config File: \/etc\/mcollective\/server.cfg\r\n                  Collectives: mcollective\r\n              Main Collective: mcollective\r\n                   Process ID: 9485\r\n               Total Messages: 37\r\n      Messages Passed Filters: 33\r\n            Messages Filtered: 4\r\n             Expired Messages: 0\r\n                 Replies Sent: 32\r\n         Total Processor Time: 0.74 seconds\r\n                  System Time: 0.21 seconds\r\n   Agents:\r\n      discovery       puppet          rpcutil        \r\n   Data Plugins:\r\n      agent           fstat           puppet         \r\n      resource                                       \r\n   Configuration Management Classes:\r\n      No classes applied\r\n   Facts:  #\u53ef\u4ee5\u770b\u5230\u83b7\u53d6\u7684\u8282\u70b9facter\u4fe1\u606f\uff08\u83b7\u53d6\u4fe1\u606f\u9700\u8981\u4e00\u4e9b\u7b49\u5f85\u65f6\u95f4\uff09\r\n      architecture =&gt; x86_64\r\n      augeasversion =&gt; 0.10.0\r\n      bios_release_date =&gt; 07\/02\/2012\r\n      bios_vendor =&gt; Phoenix Technologies LTD\r\n      bios_version =&gt; 6.00\r\n      blockdevice_fd0_size =&gt; 4096\r\n     \u2026\r\n      uptime_days =&gt; 0\r\n      uptime_hours =&gt; 20\r\n      uptime_seconds =&gt; 74506\r\n      uuid =&gt; 564DFBAB-CADC-FC69-36CA-955BFDB30F43\r\n      virtual =&gt; vmware\r\n<\/code><\/pre>\n<hr \/>\n<pre><code>[root@puppetserver rpms]# mco facts lsbdistdescription -v  #\u4f7f\u7528mco facts\u547d\u4ee4\u5bf9\u64cd\u4f5c\u7cfb\u7edf\u7c7b\u578b\u8fdb\u884c\u663e\u793a\r\nDiscovering hosts using the mc method for 2 second(s) .... 2\r\nReport for fact: lsbdistdescription\r\n        Red Hat Enterprise Linux Server release 5.7 (Tikanga)found 1 times\r\n            agent2.kisspuppet.com\r\n        Red Hat Enterprise Linux Server release 5.8 (Tikanga)found 1 times\r\n            agent1.kisspuppet.com\r\n---- rpc stats ----\r\n           Nodes: 2 \/ 2\r\n     Pass \/ Fail: 2 \/ 0\r\n      Start Time: Thu Oct 03 16:59:04 +0800 2013\r\n  Discovery Time: 2004.83ms\r\n      Agent Time: 67.32ms\r\n      Total Time: 2072.15ms<\/code><\/pre>\n<p>&nbsp;<\/p>\n<p><code>root@puppetserver rpms]# mco facts lsbdistdescription #\u4f7f\u7528mco facts\u547d\u4ee4\u5bf9\u64cd\u4f5c\u7cfb\u7edf\u7c7b\u578b\u8fdb\u884c\u7edf\u8ba1 Report for fact: lsbdistdescription Red Hat Enterprise Linux Server release 5.7 (Tikanga)found 1 times Red Hat Enterprise Linux Server release 5.8 (Tikanga)found 1 times Finished processing 2 \/ 2 hosts in 79.15 ms [root@puppetserver rpms]# mco facts -v --with-fact hostname='agent1' memoryfree #\u67e5\u770b\u4e3b\u673aagent1\u7684\u5269\u4f59\u5185\u5b58 Discovering hosts using the mc method for 2 second(s) .... 1 Report for fact: memoryfree 795.13 MB found 1 times agent1.kisspuppet.com ---- rpc stats ---- Nodes: 1 \/ 1 Pass \/ Fail: 1 \/ 0 Start Time: Thu Oct 03 17:02:13 +0800 2013 Discovery Time: 2005.65ms Agent Time: 49.37ms Total Time: 2055.03ms<\/code><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<h4>\u4f7f\u7528\u5143\u6570\u636e\u5b9a\u4f4d\u4e3b\u673a<\/h4>\n<p><strong>4.3.1 \u4f7f\u7528\u9ed8\u8ba4facter\u5143\u6570\u636e\u5b9a\u4f4d\u4e3b\u673a<\/strong><\/p>\n<p><strong>4.3.1.1 \u89e6\u53d1\u6240\u6709\u7cfb\u7edf\u4e3aRedHat\uff0c\u7248\u672c\u4e3a5.7\u7684\u6240\u6709\u8282\u70b9puppetd\u5b88\u62a4\u8fdb\u7a0b<\/strong><\/p>\n<pre><code>[root@puppetserver rpms]# mco puppet -v runonce   rpc --np -F  operatingsystemrelease='5.7' -F operatingsystem='RedHat'   \r\nDiscovering hosts using the mc method for 2 second(s) .... 1\r\nagent2.kisspuppet.com                      : OK\r\n    {:summary=&gt;      \"Started a background Puppet run using the 'puppet agent --onetime --daemonize --color=false --splay --splaylimit 30' command\"}\r\n---- rpc stats ----\r\n           Nodes: 1 \/ 1\r\n     Pass \/ Fail: 1 \/ 0\r\n      Start Time: Thu Oct 03 17:03:56 +0800 2013\r\n  Discovery Time: 2008.09ms\r\n      Agent Time: 1187.69ms\r\n      Total Time: 3195.78ms\r\n<\/code><\/pre>\n<p><strong>4.3.1.2 \u89e6\u53d1\u6240\u6709\u7cfb\u7edf\u4e3aRedHat\uff0ckernel\u7248\u672c\u4e3a2.6.18\u7684\u6240\u6709\u8282\u70b9puppetd\u5b88\u62a4\u8fdb\u7a0b<\/strong><\/p>\n<pre><code>[root@puppetserver rpms]# mco puppet -v runonce   rpc --np -F  kernelversion='2.6.18'  -F operatingsystem='RedHat'\r\nDiscovering hosts using the mc method for 2 second(s) .... 2\r\nagent2.kisspuppet.com                      : OK\r\n    {:summary=&gt;      \"Started a background Puppet run using the 'puppet agent --onetime --daemonize --color=false --splay --splaylimit 30' command\"}\r\nagent1.kisspuppet.com                      : OK\r\n    {:summary=&gt;      \"Started a background Puppet run using the 'puppet agent --onetime --daemonize --color=false --splay --splaylimit 30' command\"}\r\n---- rpc stats ----\r\n           Nodes: 2 \/ 2\r\n     Pass \/ Fail: 2 \/ 0\r\n      Start Time: Thu Oct 03 17:06:15 +0800 2013\r\n  Discovery Time: 2004.32ms\r\n      Agent Time: 1308.34ms\r\n      Total Time: 3312.66ms\r\n<\/code><\/pre>\n<p><strong>4.3.2 \u4f7f\u7528\u81ea\u5b9a\u4e49facter\u5143\u6570\u636e\u5b9a\u4f4d\u4e3b\u673a<\/strong><\/p>\n<p><strong>\u5907\u6ce8\uff1a<\/strong>\u4f7f\u7528\u81ea\u5b9a\u4e49facter\u5143\u6570\u636e\u53ef\u4ee5\u66f4\u52a0\u7075\u6d3b\u7684\u5b9a\u4f4d\u4e3b\u673a\uff0c\u5982\u4f55\u5b9a\u4e49fact\u53ef\u53c2\u8003\u535a\u6587\u300a<a href=\"http:\/\/kisspuppet.com\/2013\/11\/15\/my-fact\/\">\u901a\u8fc7\u81ea\u5b9a\u4e49fact\u589e\u5f3aMCollective\u63a8\u9001\u66f4\u65b0\u5143\u6570\u636e\u7684\u7075\u6d3b\u6027<\/a>\u300b<\/p>\n<p><strong>4.3.2.1 \u5728agent1\u4e0a\u5b9a\u4e49facter my_apply1\u548cmy_apply2<\/strong><\/p>\n<pre><code>[root@agent1 mcollective]# facter -p | grep my_apply\r\nmy_apply1 =&gt; apache\r\nmy_apply2 =&gt; mysql\r\n<\/code><\/pre>\n<p><strong>4.3.2.2 \u5728agent2\u4e0a\u5b9a\u4e49facter my_apply2\u548cmy_apply3<\/strong><\/p>\n<pre><code>[root@agent2 mcollective]# facter -p | grep my_apply\r\nmy_apply2 =&gt; mysql\r\nmy_apply3 =&gt; php\r\n<\/code><\/pre>\n<p><strong>4.3.2.3 \u5728MCollective\u5ba2\u6237\u7aef\u6d4b\u8bd5\u8282\u70b9\u81ea\u5b9a\u4e49facter\u662f\u5426\u6b63\u786e<\/strong><\/p>\n<pre><code>[root@puppetserver facter]# mco inventory agent1.kisspuppet.com  | grep my_apply\r\n      my_apply1 =&gt; apache\r\n      my_apply2 =&gt; mysql\r\n[root@puppetserver facter]# mco inventory agent2.kisspuppet.com  | grep my_apply\r\n      my_apply2 =&gt; mysql\r\n      my_apply3 =&gt; php\r\n<\/code><\/pre>\n<p><strong>4.3.2.4 \u901a\u8fc7\u81ea\u5b9a\u4e49facter\u5b9a\u4f4d\u4e3b\u673a\u89e6\u53d1\u66f4\u65b0<\/strong><\/p>\n<pre><code>[root@puppetserver facter]# mco puppet -v runonce  mco facts -v --with-fact  my_apply3='php' #\u7b5b\u9009\u8282\u70b9facter\u53d8\u91cfmy_apply3=php\u7684\u4e3b\u673a\u8fdb\u884c\u89e6\u53d1puppetd\u5b88\u62a4\u8fdb\u7a0b\r\nDiscovering hosts using the mc method for 2 second(s) .... 1\r\n * [ ============================================================&gt; ] 1 \/ 1\r\nagent2.kisspuppet.com                      : OK\r\n    {:summary=&gt;      \"Started a background Puppet run using the 'puppet agent --onetime --daemonize --color=false --splay --splaylimit 30' command\"}\r\n---- rpc stats ----\r\n           Nodes: 1 \/ 1\r\n     Pass \/ Fail: 1 \/ 0\r\n      Start Time: Thu Oct 03 23:33:54 +0800 2013\r\n  Discovery Time: 2005.35ms\r\n      Agent Time: 1078.86ms\r\n      Total Time: 3084.21ms<\/code><\/pre>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[114,113],"class_list":["post-3920","post","type-post","status-publish","format-standard","hentry","category-5","tag-mco","tag-mcollective","category-5-id","post-seq-1","post-parity-odd","meta-position-corners","fix"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.hmouse.cn\/index.php?rest_route=\/wp\/v2\/posts\/3920","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hmouse.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hmouse.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hmouse.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hmouse.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3920"}],"version-history":[{"count":3,"href":"https:\/\/www.hmouse.cn\/index.php?rest_route=\/wp\/v2\/posts\/3920\/revisions"}],"predecessor-version":[{"id":4380,"href":"https:\/\/www.hmouse.cn\/index.php?rest_route=\/wp\/v2\/posts\/3920\/revisions\/4380"}],"wp:attachment":[{"href":"https:\/\/www.hmouse.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3920"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hmouse.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3920"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hmouse.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3920"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}