{"id":34404,"date":"2023-01-05T22:18:43","date_gmt":"2023-09-03T05:48:35","guid":{"rendered":"https:\/\/www.silicloud.com\/zh\/blog\/%e4%bd%bf%e7%94%a8ansible%e5%ae%89%e8%a3%85memcache%e7%9a%84playbook%e5%a4%87%e5%bf%98%e5%bd%95%e3%80%82\/"},"modified":"2024-01-15T08:16:50","modified_gmt":"2024-01-15T00:16:50","slug":"%e4%bd%bf%e7%94%a8ansible%e5%ae%89%e8%a3%85memcache%e7%9a%84playbook%e5%a4%87%e5%bf%98%e5%bd%95%e3%80%82","status":"publish","type":"post","link":"https:\/\/www.silicloud.com\/zh\/blog\/%e4%bd%bf%e7%94%a8ansible%e5%ae%89%e8%a3%85memcache%e7%9a%84playbook%e5%a4%87%e5%bf%98%e5%bd%95%e3%80%82\/","title":{"rendered":"\u4f7f\u7528Ansible\u5b89\u88c5Memcache\u7684Playbook\u5907\u5fd8\u5f55"},"content":{"rendered":"<p>\u56e0\u4e3a\u6211\u662fAnsible\u7684\u521d\u5b66\u8005\uff0c\u5982\u679c\u6709\u6539\u8fdb\u7684\u5730\u65b9\uff0c\u8bf7\u544a\u8bc9\u6211\u3002<\/p>\n<pre class=\"post-pre\"><code>- hosts: [web-server]\r\n  vars:\r\n    src_dir: '\/usr\/local\/src'\r\n\r\n    libevent_src_dir: \"$src_dir\/libevent\"\r\n    libevent_version: \"2.0.21\"\r\n    libevent_src_url: \"https:\/\/github.com\/downloads\/libevent\/libevent\/libevent-$libevent_version-stable.tar.gz\"\r\n    libevent_dir: \"libevent-$libevent_version-stable\"\r\n\r\n    memcached_src_dir: \"$src_dir\/memcached\"\r\n    memcached_version: \"1.4.15\"\r\n    memcached_src_url: \"http:\/\/memcached.googlecode.com\/files\/memcached-$memcached_version.tar.gz\"\r\n    memcached_dir: \"memcached-$memcached_version\"\r\n\r\n    memcached_inifile_path: \"\/root\/ansible\/memcached\"\r\n\r\n  tasks:\r\n    - name: \"create libevent src dir\"\r\n      file: dest=$libevent_src_dir state=directory\r\n\r\n    - name: \"download libevent src\"\r\n      get_url: url=$libevent_src_url dest=$libevent_src_dir\r\n\r\n    - name: \"extract src file\"\r\n      command: tar zxvf libevent-$libevent_version-stable.tar.gz chdir=$libevent_src_dir\r\n\r\n    - name: \"mkdir libevent dir\"\r\n      file: dest=\/usr\/local\/libevent-$libevent_version-stable state=directory\r\n\r\n    - name: \"create synbolic link\"\r\n      file: src=\/usr\/local\/libevent-$libevent_version-stable dest=\"\/usr\/local\/libevent\" state=link\r\n\r\n    - name: \"configure\"\r\n      command: chdir=$libevent_src_dir\/$libevent_dir .\/configure --prefix=\/usr\/local\/libevent\r\n\r\n    - name: \"make\"\r\n      command: chdir=$libevent_src_dir\/$libevent_dir make\r\n\r\n    - name: \"make install\"\r\n      command: chdir=$libevent_src_dir\/$libevent_dir make install\r\n\r\n    - name: \"create memcached src dir\"\r\n      file: dest=$memcached_src_dir state=directory\r\n\r\n    - name: \"download memcached src\"\r\n      get_url: url=$memcached_src_url dest=$memcached_src_dir\r\n\r\n    - name: \"extract src file\"\r\n      command: tar zxvf memcached-$memcached_version.tar.gz chdir=$memcached_src_dir\r\n\r\n    - name: \"mkdir memcached dir\"\r\n      file: dest=\/usr\/local\/memcached-$memcached_version state=directory\r\n\r\n    - name: \"create synbolic link\"\r\n      file: src=\/usr\/local\/memcached-$memcached_version dest=\"\/usr\/local\/memcached\" state=link\r\n\r\n    - name: \"configure\"\r\n      command: chdir=$memcached_src_dir\/$memcached_dir .\/configure --prefix=\/usr\/local\/memcached --with-libevent=\/usr\/local\/libevent\r\n\r\n    - name: \"make\"\r\n      command: chdir=$memcached_src_dir\/$memcached_dir make\r\n\r\n    - name: \"make install\"\r\n      command: chdir=$memcached_src_dir\/$memcached_dir make install\r\n\r\n    - name: \"copy script\"\r\n      copy: mode=755 src=$memcached_src_dir\/$memcached_dir\/scripts\/memcached.sysv dest=\/etc\/init.d\/memcached\r\n\r\n    - name: \"copy start-memcached\"\r\n      copy: mode=755 src=$memcached_src_dir\/$memcached_dir\/scripts\/start-memcached dest=\/usr\/local\/memcached\/bin\/start-memcached \r\n\r\n    - name: \"copy memcached-tool\"\r\n      copy: mode=755 src=$memcached_src_dir\/$memcached_dir\/scripts\/memcached-tool dest=\/usr\/local\/memcached\/bin\/memcached-tool\r\n\r\n    - name: \"copy ini file\"\r\n      copy: src=$memcached_inifile_path dest=\/etc\/sysconfig\/memcached\r\n\r\n    - name: \"create \/var\/run\/memcached\"\r\n      file: dest=\/var\/run\/memcached state=directory\r\n\r\n    - name: \"start memcached\"\r\n      command: \/etc\/init.d\/memcached start\r\n\r\n    - name: \"chkconfig on\"\r\n      action: service name=memcached state=started enabled=yes\r\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u56e0\u4e3a\u6211\u662fAnsible\u7684\u521d\u5b66\u8005\uff0c\u5982\u679c\u6709\u6539\u8fdb\u7684\u5730\u65b9\uff0c\u8bf7\u544a\u8bc9\u6211\u3002 &#8211; hosts: [web-server] va [&hellip;]<\/p>\n","protected":false},"author":10,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-34404","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v21.5 (Yoast SEO v21.5) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u4f7f\u7528Ansible\u5b89\u88c5Memcache\u7684Playbook\u5907\u5fd8\u5f55 - Blog - Silicon Cloud<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.silicloud.com\/zh\/blog\/\u4f7f\u7528ansible\u5b89\u88c5memcache\u7684playbook\u5907\u5fd8\u5f55\u3002\/\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u4f7f\u7528Ansible\u5b89\u88c5Memcache\u7684Playbook\u5907\u5fd8\u5f55\" \/>\n<meta property=\"og:description\" content=\"\u56e0\u4e3a\u6211\u662fAnsible\u7684\u521d\u5b66\u8005\uff0c\u5982\u679c\u6709\u6539\u8fdb\u7684\u5730\u65b9\uff0c\u8bf7\u544a\u8bc9\u6211\u3002 - hosts: [web-server] va [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.silicloud.com\/zh\/blog\/\u4f7f\u7528ansible\u5b89\u88c5memcache\u7684playbook\u5907\u5fd8\u5f55\u3002\/\" \/>\n<meta property=\"og:site_name\" content=\"Blog - Silicon Cloud\" \/>\n<meta property=\"article:published_time\" content=\"2023-09-03T05:48:35+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-01-15T00:16:50+00:00\" \/>\n<meta name=\"author\" content=\"\u5b87, \u534e\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"\u5b87, \u534e\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e4%bd%bf%e7%94%a8ansible%e5%ae%89%e8%a3%85memcache%e7%9a%84playbook%e5%a4%87%e5%bf%98%e5%bd%95%e3%80%82\/\",\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e4%bd%bf%e7%94%a8ansible%e5%ae%89%e8%a3%85memcache%e7%9a%84playbook%e5%a4%87%e5%bf%98%e5%bd%95%e3%80%82\/\",\"name\":\"\u4f7f\u7528Ansible\u5b89\u88c5Memcache\u7684Playbook\u5907\u5fd8\u5f55 - Blog - Silicon Cloud\",\"isPartOf\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#website\"},\"datePublished\":\"2023-09-03T05:48:35+00:00\",\"dateModified\":\"2024-01-15T00:16:50+00:00\",\"author\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/513018e4e121d3add1b7c5de8be21458\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e4%bd%bf%e7%94%a8ansible%e5%ae%89%e8%a3%85memcache%e7%9a%84playbook%e5%a4%87%e5%bf%98%e5%bd%95%e3%80%82\/#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.silicloud.com\/zh\/blog\/%e4%bd%bf%e7%94%a8ansible%e5%ae%89%e8%a3%85memcache%e7%9a%84playbook%e5%a4%87%e5%bf%98%e5%bd%95%e3%80%82\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e4%bd%bf%e7%94%a8ansible%e5%ae%89%e8%a3%85memcache%e7%9a%84playbook%e5%a4%87%e5%bf%98%e5%bd%95%e3%80%82\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.silicloud.com\/zh\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u4f7f\u7528Ansible\u5b89\u88c5Memcache\u7684Playbook\u5907\u5fd8\u5f55\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#website\",\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/\",\"name\":\"Blog - Silicon Cloud\",\"description\":\"\",\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/513018e4e121d3add1b7c5de8be21458\",\"name\":\"\u5b87, \u534e\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/63cd45cbc05a35fc4ff7637a163c83c4962ef58d27472726c3a3e0c9c5194f0f?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/63cd45cbc05a35fc4ff7637a163c83c4962ef58d27472726c3a3e0c9c5194f0f?s=96&d=mm&r=g\",\"caption\":\"\u5b87, \u534e\"},\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/author\/yuhua\/\"},{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e4%bd%bf%e7%94%a8ansible%e5%ae%89%e8%a3%85memcache%e7%9a%84playbook%e5%a4%87%e5%bf%98%e5%bd%95%e3%80%82\/#local-main-organization-logo\",\"url\":\"\",\"contentUrl\":\"\",\"caption\":\"Blog - Silicon Cloud\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"\u4f7f\u7528Ansible\u5b89\u88c5Memcache\u7684Playbook\u5907\u5fd8\u5f55 - Blog - Silicon Cloud","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.silicloud.com\/zh\/blog\/\u4f7f\u7528ansible\u5b89\u88c5memcache\u7684playbook\u5907\u5fd8\u5f55\u3002\/","og_locale":"zh_CN","og_type":"article","og_title":"\u4f7f\u7528Ansible\u5b89\u88c5Memcache\u7684Playbook\u5907\u5fd8\u5f55","og_description":"\u56e0\u4e3a\u6211\u662fAnsible\u7684\u521d\u5b66\u8005\uff0c\u5982\u679c\u6709\u6539\u8fdb\u7684\u5730\u65b9\uff0c\u8bf7\u544a\u8bc9\u6211\u3002 - hosts: [web-server] va [&hellip;]","og_url":"https:\/\/www.silicloud.com\/zh\/blog\/\u4f7f\u7528ansible\u5b89\u88c5memcache\u7684playbook\u5907\u5fd8\u5f55\u3002\/","og_site_name":"Blog - Silicon Cloud","article_published_time":"2023-09-03T05:48:35+00:00","article_modified_time":"2024-01-15T00:16:50+00:00","author":"\u5b87, \u534e","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"\u5b87, \u534e","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"2 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e4%bd%bf%e7%94%a8ansible%e5%ae%89%e8%a3%85memcache%e7%9a%84playbook%e5%a4%87%e5%bf%98%e5%bd%95%e3%80%82\/","url":"https:\/\/www.silicloud.com\/zh\/blog\/%e4%bd%bf%e7%94%a8ansible%e5%ae%89%e8%a3%85memcache%e7%9a%84playbook%e5%a4%87%e5%bf%98%e5%bd%95%e3%80%82\/","name":"\u4f7f\u7528Ansible\u5b89\u88c5Memcache\u7684Playbook\u5907\u5fd8\u5f55 - Blog - Silicon Cloud","isPartOf":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/#website"},"datePublished":"2023-09-03T05:48:35+00:00","dateModified":"2024-01-15T00:16:50+00:00","author":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/513018e4e121d3add1b7c5de8be21458"},"breadcrumb":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e4%bd%bf%e7%94%a8ansible%e5%ae%89%e8%a3%85memcache%e7%9a%84playbook%e5%a4%87%e5%bf%98%e5%bd%95%e3%80%82\/#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.silicloud.com\/zh\/blog\/%e4%bd%bf%e7%94%a8ansible%e5%ae%89%e8%a3%85memcache%e7%9a%84playbook%e5%a4%87%e5%bf%98%e5%bd%95%e3%80%82\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e4%bd%bf%e7%94%a8ansible%e5%ae%89%e8%a3%85memcache%e7%9a%84playbook%e5%a4%87%e5%bf%98%e5%bd%95%e3%80%82\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.silicloud.com\/zh\/blog\/"},{"@type":"ListItem","position":2,"name":"\u4f7f\u7528Ansible\u5b89\u88c5Memcache\u7684Playbook\u5907\u5fd8\u5f55"}]},{"@type":"WebSite","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#website","url":"https:\/\/www.silicloud.com\/zh\/blog\/","name":"Blog - Silicon Cloud","description":"","inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/513018e4e121d3add1b7c5de8be21458","name":"\u5b87, \u534e","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/63cd45cbc05a35fc4ff7637a163c83c4962ef58d27472726c3a3e0c9c5194f0f?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/63cd45cbc05a35fc4ff7637a163c83c4962ef58d27472726c3a3e0c9c5194f0f?s=96&d=mm&r=g","caption":"\u5b87, \u534e"},"url":"https:\/\/www.silicloud.com\/zh\/blog\/author\/yuhua\/"},{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e4%bd%bf%e7%94%a8ansible%e5%ae%89%e8%a3%85memcache%e7%9a%84playbook%e5%a4%87%e5%bf%98%e5%bd%95%e3%80%82\/#local-main-organization-logo","url":"","contentUrl":"","caption":"Blog - Silicon Cloud"}]}},"_links":{"self":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/34404","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/users\/10"}],"replies":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/comments?post=34404"}],"version-history":[{"count":2,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/34404\/revisions"}],"predecessor-version":[{"id":57703,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/34404\/revisions\/57703"}],"wp:attachment":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/media?parent=34404"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/categories?post=34404"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/tags?post=34404"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}