﻿{"id":1344,"date":"2015-08-11T10:58:28","date_gmt":"2015-08-11T02:58:28","guid":{"rendered":"http:\/\/nick.txtcc.com\/?p=1344"},"modified":"2018-08-07T10:33:30","modified_gmt":"2018-08-07T02:33:30","slug":"install-salt-on-ubuntudebain","status":"publish","type":"post","link":"https:\/\/nick.txtcc.com\/index.php\/linux\/1344","title":{"rendered":"install salt on ubuntu\/debain"},"content":{"rendered":"<div id=\"wheezy-stable\" class=\"section\">\n<h2>WHEEZY (STABLE)<i class=\"glyphicon glyphicon-link\" title=\"\" data-container=\"body\" data-toggle=\"tooltip\" data-placement=\"bottom\" data-original-title=\"Link to this location\"><\/i><\/h2>\nFor wheezy, the following line is needed in either <code class=\"docutils literal\">&lt;span class=&quot;pre&quot;&gt;\/etc\/apt\/sources.list&lt;\/span&gt;<\/code> or a file in <code class=\"docutils literal\">&lt;span class=&quot;pre&quot;&gt;\/etc\/apt\/sources.list.d&lt;\/span&gt;<\/code>:\n<div class=\"highlight-bash\">\n<div class=\"highlight\">\n<pre>deb http:\/\/debian.saltstack.com\/debian wheezy-saltstack main\n<\/pre>\n<\/div>\n<\/div>\n<\/div>\n<div id=\"jessie-testing\" class=\"section\"><\/div>\n<div class=\"section\">\n<h2>IMPORT THE REPOSITORY KEY.<\/h2>\nYou will need to import the key used for signing.\n<div class=\"highlight-bash\">\n<div class=\"highlight\">\n<pre>wget -q -O- <span class=\"s2\">\"http:\/\/debian.saltstack.com\/debian-salt-team-joehealy.gpg.key\"<\/span> <span class=\"p\">|<\/span> apt-key add -\n<\/pre>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"admonition note\"><\/div>\n<div class=\"admonition note\">\n<div id=\"update-the-package-database\" class=\"section\">\n<h2>UPDATE THE PACKAGE DATABASE<i class=\"glyphicon glyphicon-link\" title=\"\" data-container=\"body\" data-toggle=\"tooltip\" data-placement=\"bottom\" data-original-title=\"Link to this location\"><\/i><\/h2>\n<div class=\"highlight-bash\">\n<div class=\"highlight\">\n<pre>apt-get update\n<\/pre>\n<\/div>\n<\/div>\n<\/div>\n<div id=\"install-packages\" class=\"section\">\n<h2>INSTALL PACKAGES<i class=\"glyphicon glyphicon-link\" title=\"\" data-container=\"body\" data-toggle=\"tooltip\" data-placement=\"bottom\" data-original-title=\"Link to this location\"><\/i><\/h2>\nInstall the Salt master, minion, or syndic from the repository with the apt-get command. These examples each install one daemon, but more than one package name may be given at a time:\n<div class=\"highlight-bash\">\n<div class=\"highlight\">\n<pre>apt-get install salt-master\n<\/pre>\n<\/div>\n<\/div>\n<div class=\"highlight-bash\">\n<div class=\"highlight\">\n<pre>apt-get install salt-minion\n<\/pre>\n<\/div>\n<\/div>\n<div class=\"highlight-bash\">\n<div class=\"highlight\">\n<pre>apt-get install salt-syndic\n\nsalt -L 'a,b,c' state.sls nginx\n\n<a href=\"http:\/\/www.ituring.com.cn\/article\/42398\" target=\"_blank\">pillar<\/a>\n\n<a href=\"http:\/\/www.oschina.net\/translate\/getting-started-salt-stack-other-configuration-management-system-built-python\" target=\"_blank\">other link<\/a><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div id=\"translate_11984\" class=\"paragraph_chs\">\n<div class=\"box paragraph-container\">\n<div class=\"content\">\n<h2 id=\"content_h2_6_5\">\u914d\u7f6e\u4e3b\u670d\u52a1\u5668\u548c\u4ece\u670d\u52a1\u5668<\/h2>\n\u4e3b\u670d\u52a1\u5668\u548c\u4ece\u670d\u52a1\u5668\u6307\u7684\u662f\u63a7\u5236\u5668\u548c\u88ab\u63a7\u5236\u7684\u670d\u52a1\u5668\uff0c\u8fd9\u4e2a\u4e3b\u670d\u52a1\u5668\u672c\u8d28\u4e0a\u662f\u4e2d\u592e\u534f\u8c03\u4e2d\u5fc3\u5bf9\u6240\u6709\u7684\u4ece\u670d\u52a1\u5668\uff0c\u4ece\u670d\u52a1\u5668\u7c7b\u4f3cclient\/server\u914d\u7f6e\uff0c\u8fd9\u91cc\u7684\u4e3b\u670d\u52a1\u5668\u662fserver\uff0c\u4ece\u670d\u52a1\u5668\u662fclient.\n<h3 id=\"content_h3_6_7\">\u4ece\u670d\u52a1\u5668\u914d\u7f6e<\/h3>\n\u5728\u672c\u6587\u4e2d\uff0c\u6211\u914d\u7f6esalt-master\u548csalt-minion \u547d\u4ee4\u5728\u540c\u4e00\u53f0\u673a\u5668\u4e0a\uff0c\u5047\u5982\u4f60\u5728\u914d\u7f6e\u591a\u53f0\u670d\u52a1\u5668\uff0c\u6311\u9009\u5176\u4e2d\u4e00\u4e2a\u4e3amaster\uff0c\u5269\u4e0b\u7684\u6210\u4e3aminions.\u6839\u636e\u4f60\u7684\u9700\u8981\u6765\u914d\u7f6emaster\u548cminion\uff0c\u63a5\u4e0b\u6765\u7684\u6211\u4f1a\u89e3\u91ca\u5982\u4f55\u914d\u7f6e\u4e00\u53f0\u670d\u52a1\u5668\u4e3amaster\u548c\u53e6\u5916\u7684\u673a\u5668\u4e3aminions.\n\nSalt\u7684\u914d\u7f6e\u6587\u4ef6\u5728\/etc\/salt\u76ee\u5f55\u4e0b\uff0c\u9ed8\u8ba4\uff0c\u8fd9\u4e9b\u6587\u4ef6\u88ab\u547d\u540d\u4e3aminion\u548cmaster\uff0c\u5047\u5982\u4f60\u5728\u540c\u4e00\u53f0\u673a\u5668\u5b89\u88c5\u4e86salt-master\u548csalt-minion\uff0c\u4f60\u4f1a\u770b\u5230\u4e0d\u540c\u7684\u4e24\u4e2a\u6587\u4ef6\uff0cmaster\u548cminion\n\n<\/div>\n<div class=\"translator-info\"><\/div>\n<\/div>\n<\/div>\n<div id=\"translate_11985\" class=\"paragraph_chs\">\n<div class=\"box paragraph-container\">\n<div class=\"content\">\n\n\u9996\u5148\uff0c\u4f60\u9700\u8981\u544a\u8bc9\u4f60\u7684minion\u600e\u6837\u627e\u5230\u5e76\u8fde\u63a5\u4f60\u7684Master\u670d\u52a1\u5668\u3002\u5373\u4f7f\u4f60\u8fd0\u884cminion\u548cMaster\u5728\u540c\u4e00\u53f0\u670d\u52a1\u5668\u4e0a\uff0c\u4f60\u4ecd\u7136\u8981\u544a\u8bc9minion\u4f60\u7684master\u5728\u54ea\u513f\u3002\n\n1\uff0c\u4f7f\u7528\u4f60\u6700\u559c\u6b22\u7684\u6587\u672c\u7f16\u8f91\u5668\uff0c\u6253\u5f00minion\u914d\u7f6e\u6587\u4ef6\n\n2\uff0c\u53d6\u6d88\u6ce8\u91ca\u884c#master\uff0c\u79fb\u9664# \u66ff\u6362\u4e3a\u4f60\u7684Master\u670d\u52a1\u5668\u7684IP\u5730\u5740\uff0c\u5e94\u8be5\u662f\u8fd9\u6837:master:\u4f60\u7684master IP\u5730\u5740\u3002\uff08\u5047\u5982\u4ee5\u4e0a\u64cd\u4f5c\uff0c\u5728\u540c\u4e00\u53f0\u670d\u52a1\u5668\uff0c\u6b64\u65f6\u589e\u52a0 127.0.0.1)\n\n3,\u547d\u540d\u4e00\u4e2a\u6635\u79f0\u7ed9\u4f60\u7684\u670d\u52a1\u5668\uff0c\u67e5\u627e\u5230#id\u884c\uff0c\u518d\u4e00\u6b21\u79fb\u9664#\u53f7\uff0c\u589e\u52a0\u4e00\u4e2anameid\uff1a1st-salt-minion\uff0c\uff08\u8fd9\u4e2a\u540d\u5b57\u53ef\u4ee5\u662f\u4efb\u4f55\u5b57\u7b26\u4e32\u7684\uff09\n\n4\uff0c\u4e3a\u4e86\u91cd\u65b0\u52a0\u8f7d\u65b0\u7684\u914d\u7f6e\uff0c\u4f60\u9700\u8981\u4f7f\u7528sudo \u91cd\u542f\u4f60\u7684salt-minion\u8fdb\u7a0b\uff0c-d \u9009\u9879\uff0c\u542f\u52a8salt-minion\u4e3a\u4e00\u4e2a\u540e\u53f0\u8fdb\u7a0b\uff0c\u8fd9\u6837\u5b50\u7684\u8bdd\uff0c\u4f60\u53ef\u4ee5\u8bbf\u95ee\u60a8\u7684\u547d\u4ee4\u884c\u53d1\u5e03\u66f4\u591a\u7684\u547d\u4ee4\u3002\n\n<\/div>\n<div class=\"translator-info\"><\/div>\n<\/div>\n<\/div>\n<div id=\"translate_11986\" class=\"paragraph_chs\">\n<div class=\"box paragraph-container\">\n<div class=\"content\">\n<h2 id=\"content_h2_8_5\">\u8ba4\u8bc1 Minion Keys<\/h2>\n\u73b0\u5728\u4f60\u7684minion \u5df2\u7ecf\u77e5\u9053\u5230master\u5728\u54ea\u91cc\uff0c\u63a5\u4e0b\u6765\u8ba9\u4ed6\u4eec\u8fdb\u884c\u5f7c\u6b64\u9a8c\u8bc1\uff0cSalt\u4f7f\u7528\u516c\u5171\u5bc6\u94a5\u52a0\u5bc6\u6765\u786e\u4fddmaster\u548cminions\u7684\u5b89\u5168\u901a\u4fe1\u3002\u4f60\u9700\u8981\u901a\u8fc7\u5728master\u7aef\u9a8c\u8bc1minion\u7684\u8bc1\u4e66\u6765\u660e\u786emaster\u548cminion\u4e4b\u95f4\u7684\u662f\u6388\u4fe1\u7684\u3002\n\n\u8ba4\u8bc1minion\u7684\u8bc1\u4e66\u4f7f\u7528salt-key\u547d\u4ee4\uff0cSalt\u81ea\u52a8\u751f\u6210\u8fd9\u4e9b\u8bc1\u4e66\uff0c\u4f60\u9700\u8981\u505a\u7684\u4ec5\u4ec5\u662f\u8ba4\u8bc1\u4f60\u9700\u8981\u7684\u8bc1\u4e66\u3002\n\n1\uff0c\u8f93\u5165salt-key -L \u5217\u51fa\u6240\u4ee5\u6ca1\u6709\u8ba4\u8bc1\uff0c\u8ba4\u8bc1\u8fc7\uff0c\u62d2\u7edd\u8ba4\u8bc1\u7684\u8bc1\u4e66\n\n2\uff0c\u4f60\u5e94\u8be5\u53ef\u4ee5\u770b\u5230\u4e00\u4e2a\u6ca1\u6709\u8ba4\u8bc1\u7684\u8bc1\u4e661st-Salt-Minion\uff08\u6216\u8005\u4f60\u81ea\u5df1\u9009\u62e9\u7684minion\uff09\n\n3,\u8ba4\u8bc1\u8fd9\u4e2a\u8bc1\u4e66\u4f7f\u7528 sudo salt-key -a 1st-salt-minion\n\n<\/div>\n<div class=\"translator-info\"><\/div>\n<\/div>\n<\/div>\n<div id=\"translate_11987\" class=\"paragraph_chs\">\n<div class=\"box paragraph-container\">\n<div class=\"content\">\n<h2 id=\"content_h2_9_5\">\u901a\u4fe1\u6d4b\u8bd5<\/h2>\n\u73b0\u5728\u4f60\u5df2\u7ecf\u6709\u4e86\u4e00\u53f0 salt-master\u548c\u4e00\u53f0salt-minion\uff0c\u5e76\u4e14master\u548cminion\u5df2\u7ecf\u76f8\u4e92\u4fe1\u4efb\uff0c\u4f60\u53ef\u4ee5\u4ecemaster \u4f7f\u7528\u4e00\u4e2atest ping\u7684\u547d\u4ee4\u6765\u6d4b\u8bd5\u4ed6\u4eec\u4e4b\u95f4\u7684\u8fde\u63a5\u3002\u5047\u5982\u4f60\u7684master\u80fd\u591f\u8fde\u63a5\u5230minion\uff0c\u5c06\u4f1a\u8fd4\u56de\u4e00\u4e2a&#8221;return&#8221;.\u8f93\u5165 salt &#8216;*&#8217; test.ping,\u5b83\u5e94\u8be5\u6709\u5982\u4e0b\u8f93\u51fa:\n<pre>>{1st-Salt-Minion: True}<\/pre>\n\u6ce8\u610f\uff0c\u901a\u914d\u7b26 *\u4ee3\u8868\u6240\u6709minion\uff0c\u56e0\u4e3a\u8fd9\u91cc\u4f60\u53ea\u6709\u4e00\u53f0\u670d\u52a1\u5668\uff0c\u7b97\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u6a21\u62df\u6d4b\u8bd5\uff08\u8981\u6bd4salt &#8216;1st-salt-Minion&#8217; test ping \u5feb\u591a\u4e86\uff09\u5047\u5982\u4f60\u6536\u5230\u201cTrue\u201d\uff0c\u8bc1\u660e\u4f60\u5df2\u7ecf\u6210\u529f\u5b89\u88c5\u548c\u914d\u7f6e\u5b8c\u6210salt stack\u3002\n\n\u5982\u679c\u6ca1\u6709\u7684\u8bdd\uff0c\u4f60\u4e5f\u8bb8\u9700\u8981\u91cd\u542f\u4f60\u7684master\u548cminion \u4e0d\u5e26-d\u53c2\u6570\uff0c\u8fd9\u6837\u5b50\u7684\u8bdd\uff0c\u4f60\u80fd\u591f\u83b7\u53d6\u5230\u66f4\u591a\u8f93\u51fa\u4fe1\u606f\uff0c\u66f4\u591a\u7684\u53c2\u8003\u8d44\u6599\uff0c\u8bf7\u67e5\u770bSalt \u5b98\u65b9\u6587\u6863<a href=\"http:\/\/docs.saltstack.org\/en\/latest\/topics\/configuration.html\" rel=\"nofollow\">http:\/\/docs.saltstack.org\/en\/latest\/topics\/configuration.html<\/a>\n\n<\/div>\n<\/div>\n<\/div>\n<div class=\"user clear\"><\/div>\n<div class=\"user clear\"><\/div>\n<div class=\"user clear\"><\/div>\n<div id=\"translate_11988\" class=\"paragraph_chs\">\n<div class=\"box paragraph-container\">\n<div class=\"content\">\n\nSalt\u7684\u8bed\u6cd5\u7ed3\u6784\uff0c\u5305\u62ec\u547d\u4ee4\uff0c\u76ee\u6807\u548c\u52a8\u4f5c\uff0c\u4e3e\u4e2a\u4f8b\u5b50\uff0c* \u6307\u4efb\u4f55\u4e3b\u673a\uff08* \u662f\u4e00\u4e2a\u901a\u914d\u7b26\uff09\uff0ctest.ping \u662f\u52a8\u4f5c\u3002\n\n\u4f60\u53ef\u4ee5\u5728\u5df2\u7ecf\u94fe\u63a5\u548c\u4fe1\u4efb\u7684\u4e3b\u673a\u4e0a\u6267\u884c\u4efb\u4f55\u53ef\u7528\u7684\u547d\u4ee4\uff0c\u5173\u952e\u63d0\u793a:\u8fd9\u4e9b\u9700\u8981\u6267\u884c\u7684\u547d\u4ee4\u5728\u76ee\u6807\u4e3b\u673a\u4e0a\u5fc5\u987b\u53ef\u7528\uff0c\u4f8b\u5982\uff0c\u5982\u4e0b\u547d\u4ee4\uff1a\n<pre>sudo salt '*' cmd.run \"service apache2 restart\"<\/pre>\n\u8fd9\u4e2a\u547d\u4ee4\u53ea\u4f1a\u5728\u5df2\u7ecf\u5b89\u88c5\u4e86apach2e web\u670d\u52a1\u5668\u7684\u4e3b\u673a\u4e0a\u6267\u884c\uff0c\u53e6\u5916\uff0c\u4f60\u4e5f\u53ef\u4ee5\u4f7f\u7528\u8fd9\u6837\u7684\u547d\u4ee4\uff1a\n<pre>sudo salt '*' cmd.run \"service httpd restart\"<\/pre>\n\u53e6\u5916\u4e00\u4e2a\u4f8b\u5b50\uff0c\u4e5f\u8bb8\u4f60\u60f3\u8981\u67e5\u8be2\u4f60\u7684\u4e3b\u673a\u5df2\u7ecf\u8fd0\u884c\u4e86\u591a\u957f\u65f6\u95f4\uff0c\u4f60\u53ef\u4ee5\u8fd9\u6837\u5b50\u505a\uff1a\n<pre>sudo salt '*' cmd.run \"uptime\"<\/pre>\n\u5728\u4e3e\u53e6\u5916\u4e00\u4e2a\u4f8b\u5b50\uff0c\u5047\u5982\u4f60\u7684Apache Bench(\u8bd1\u8005\u6ce8\uff1a\u4e00\u4e2aapche \u5f00\u6e90\u538b\u529b\u6d4b\u8bd5\u5de5\u5177)\u5b89\u88c5\u5728master\u4e0a\u800c\u6ca1\u6709\u5b89\u88c5\u5728minion\u4e0a\uff0c\u4e0b\u9762\u7684\u547d\u4ee4\uff1a\n<pre>sudo salt '*' cmd.run \"ab -n 10 -c 2 http:\/\/www.google.com:80\/index.html\"<\/pre>\n\u5982\u679c\u4f60\u5c1d\u8bd5\u5728minion\u4e0a\u6267\u884c\uff0c\u4f60\u5c06\u4f1a\u5931\u8d25\uff0c\u56e0\u4e3aApache Bench \u6ca1\u6709\u5b89\u88c5\u5728minion\u4e0a\u3002\n\n<\/div>\n<\/div>\n<\/div>","protected":false},"excerpt":{"rendered":"<p>WHEEZY (STABLE) For wheezy, the following line is needed in either <span class=\"pre\"&#038;gt&#46;&#46;&#46;<\/p>","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[427,173,426,7],"class_list":["post-1344","post","type-post","status-publish","format-standard","hentry","category-linux","tag-debain","tag-install","tag-salt","tag-ubuntu"],"_links":{"self":[{"href":"https:\/\/nick.txtcc.com\/index.php\/wp-json\/wp\/v2\/posts\/1344","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nick.txtcc.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nick.txtcc.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nick.txtcc.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nick.txtcc.com\/index.php\/wp-json\/wp\/v2\/comments?post=1344"}],"version-history":[{"count":7,"href":"https:\/\/nick.txtcc.com\/index.php\/wp-json\/wp\/v2\/posts\/1344\/revisions"}],"predecessor-version":[{"id":1743,"href":"https:\/\/nick.txtcc.com\/index.php\/wp-json\/wp\/v2\/posts\/1344\/revisions\/1743"}],"wp:attachment":[{"href":"https:\/\/nick.txtcc.com\/index.php\/wp-json\/wp\/v2\/media?parent=1344"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nick.txtcc.com\/index.php\/wp-json\/wp\/v2\/categories?post=1344"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nick.txtcc.com\/index.php\/wp-json\/wp\/v2\/tags?post=1344"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}