1. <ul id="0c1fb"></ul>

      <noscript id="0c1fb"><video id="0c1fb"></video></noscript>
      <noscript id="0c1fb"><listing id="0c1fb"><thead id="0c1fb"></thead></listing></noscript>

      99热在线精品一区二区三区_国产伦精品一区二区三区女破破_亚洲一区二区三区无码_精品国产欧美日韩另类一区

      RELATEED CONSULTING
      相關咨詢
      選擇下列產(chǎn)品馬上在線溝通
      服務時間:8:30-17:00
      你可能遇到了下面的問題
      關閉右側工具欄

      新聞中心

      這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
      puppet集中配置管理

      puppet 是一個配置管理工具, 典型的, puppet 是一個 C/S 結構, 當然,這里的 C 可以有很多,因
      此,也可以說是一個星型結構. 所有的 puppet 客戶端同一個服務器端的 puppet 通訊. 每個
      puppet 客戶端每半小時(可以設置)連接一次服務器端, 下載最新的配置文件,并且嚴格按照配
      置文件來配置服務器. 配置完成以后,puppet 客戶端可以反饋給服務器端一個消息. 如果出錯,
      也會給服務器端反饋一個消息. 下圖展示了一個典型的 puppet 配置的數(shù)據(jù)流動情況.

      創(chuàng)新互聯(lián)專業(yè)為企業(yè)提供沙縣網(wǎng)站建設、沙縣做網(wǎng)站、沙縣網(wǎng)站設計、沙縣網(wǎng)站制作等企業(yè)網(wǎng)站建設、網(wǎng)頁設計與制作、沙縣企業(yè)網(wǎng)站模板建站服務,10年沙縣做網(wǎng)站經(jīng)驗,不只是建網(wǎng)站,更提供有價值的思路和整體網(wǎng)絡服務。

      puppet 的細節(jié)和原理
      puppet 的目的是讓你只集中于你要管理的目標,而忽略實現(xiàn)的細節(jié),例如命令名,參數(shù)或者文件
      格式. puppet 把系統(tǒng)里面的用戶,軟件包,服務看作是"資源", puppet 的作用就是管理這些資源
      以及資源之間的相互聯(lián)系.
      Puppet 采用了非常簡單的 C/S 架構,所有數(shù)據(jù)的交互都通過 SSL 進行,以保證安全。它的工作

      1. 客戶端 Puppetd 向 Master 發(fā)起認證請求,或使用帶簽名的證書。
      2. Master 告訴 Client 你是合法的。
      3. 客戶端 Puppetd 調用 Facter,Facter 探測出主機的一些變量,例如主機名、內存大小、IP 地址
      等。Puppetd 將這些信息通過 SSL 連接發(fā)送到服務器端。
      4. 服務器端的 Puppet Master 檢測客戶端的主機名,然后找到 manifest 對應的 node 配置,并對該
      部分內容進行解析。Facter 送過來的信息可以作為變量處 理,node 牽涉到的代碼才解析,其他
      沒牽涉的代碼不解析。解析分為幾個階段,首先是語法檢查,如果語法錯誤就報錯;如果語法
      沒錯,就繼續(xù)解析,解析的結 果生成一個中間的“偽代碼”(catelog),然后把偽代碼發(fā)給客
      戶端。
      5. 客戶端接收到“偽代碼”,并且執(zhí)行。
      6. 客戶端在執(zhí)行時判斷有沒有 File 文件,如果有,則向 fileserver 發(fā)起請求。
      7. 客戶端判斷有沒有配置 Report,如果已配置,則把執(zhí)行結果發(fā)送給服務器。
      8. 服務器端把客戶端的執(zhí)行結果寫入日志,并發(fā)送給報告系統(tǒng)

      現(xiàn)在我們開始配置:

      環(huán)境:rhel6.3 selinux and iptables disabled

      master:192.168.1.41 cluster1.example.com

      client : 192.168.1.42 cluster2.example.com

      192.168.1.43 cluster3.example.com

      master 與所有的client之間需要解析,以及時間的同步,不然會失敗。 //時間同步大家可以參見我的

      ntp時間同步http://my.oschina.net/zhangxc73912/blog/207197

      master端:

      首先.yum倉庫添加如下:

      [root@cluster1~]#vim/etc/yum.repos.d/rhel-source.repo [puppet] name=puppet baseurl=http://yum.puppetlabs.com/el/6Server/products/x86_64/ gpgcheck=0 [ruby] name=ruby baseurl=http://yum.puppetlabs.com/el/6Server/dependencies/x86_64/ gpgcheck=0 [optioal] name=optional baseurl=ftp://192.168.1.233/pub/puppet/optional gpgcheck=0

      //optional 包大家可以下載我的,包里面有所需要的資源

      http://yunpan.cn/QIf54dLXyJwhB

      安裝puppet-server

      [root@cluster1~]#yuminstallpuppet-server

      配置

      [root@cluster1~]#cd/etc/puppet/manifests/ [root@cluster1manifests]#touchsite.pp//puppet的第一個執(zhí)行的代碼是在/etc/puppet/manifest/site.pp, 因此這個文件必須存在,而且其他的代碼也要通過該文件來調用。也就是說沒有此文件puppetmaster無法啟動,配置后面再定義

      啟動

      [root@cluster1manifests]#/etc/init.d/puppetmasterstart [root@cluster1manifests]#netstat-anltp tcp000.0.0.0:81400.0.0.0:*LISTEN1335/ruby

      clinet端:

      yum配置和master相同

      [root@cluster2~]#yuminstallpuppet-y

      我們首先不要開啟pppute,即讓服務在前端跑,且不要打入后端。

      首先做的是測試,測試成功,再將其打入后端

      [root@cluster2~]#puppetagent--servercluster1.example.com--no-daemonize--verbose Info:CreatinganewSSLkeyforcluster2.example.com Info:Cachingcertificateforca Info:csr_attributesfileloadingfrom/etc/puppet/csr_attributes.yaml Info:CreatinganewSSLcertificaterequestforcluster2.example.com Info:CertificateRequestfingerprint(SHA256): 74:A1:FC:A7:BB:E1:9E:5B:F3:89:BB:0D:41:5B:10:59:76:D3:DF:2D:25:F4:6B:ED:78:14:9F:0C:87:76:02:B7 Info:Cachingcertificateforca

      client 向 master 發(fā)出證書驗證請求,然后等待 master 簽名并返回證書。
      參數(shù)--server 指定了需要連接的 puppet master 的名字或是地址,默認連接名為“puppet”的主機
      如要修改默認連接主機可以修改/etc/sysconfig/puppet 文件中的 PUPPET_SERVER=puppet 選項
      參數(shù)--no-daemonize 是 puppet 客戶端運行在前臺
      參數(shù)--verbose 使客戶端輸出詳細的日志

      在 master端

      [root@cluster1~]#puppetcertlist//顯示等待簽名的證書 "cluster2.example.com"(SHA256)74:A1:FC:A7:BB:E1:9E:5B:F3:89:BB:0D:41:5B:10:59:76:D3:DF:2D:25:F4:6B:ED:78:14:9F:0C:87:76:02:B7 [root@cluster1~]#puppetcertsigncluster2.example.com//簽名證書 Notice:Signedcertificaterequestforcluster2.example.com Notice:RemovingfilePuppet::SSL::CertificateRequestcluster2.example.comat\'/var/lib/puppet/ssl/ca/requests/cluster2.example.com.pem\'

      如果需要同時簽名所有證書,則

      [root@cluster1~]#puppetcertsign--all

      如果要刪除證書則

      [root@cluster1~]#puppetcertcleancluster2.example.com

      在簽署完成之后(等待一段時間)在client端,會有如下輸出:

      Info:Cachingcertificate_revocation_listforca Info:Retrievingplugin Info:Cachingcatalogforcluster2.example.com Info:Applyingconfigurationversion\'1395006768\' Info:Creatingstatefile/var/lib/puppet/state/state.yaml

      當然了,在實際當中,我們則需要它自動簽署:

      master端:

      [root@cluster1~]#vi/etc/puppet/puppet.conf [main] autosign=true//允許所有客戶認證 [root@cluster1~]#touch/etc/puppet/autosign.conf [root@cluster1~]#vi/etc/puppet/autosign.conf .example.com//允許該域的主機,當然我們還可以再添見域,另起一行書寫 [root@cluster1~]#/etc/init.d/puppetmasterreload

      client端:

      [root@cluster3~]#puppetagent--servercluster1.example.com--no-daemonize--verbose//他就會自動被簽署了

      在實際中有時會修改 client 端的主機名,這樣就需要重新生成證書:
      1)在 server 端執(zhí)行:

      [root@cluster1~]#puppetcert--cleancluster2.example.com//刪除原有的client端主機名,ssl Notice:Revokedcertificatewithserial3 Notice:RemovingfilePuppet::SSL::Certificatecluster2.example.comat\'/var/lib/puppet/ssl/ca/signed/cluster2.example.com.pem\' Notice:RemovingfilePuppet::SSL::Certificatecluster2.example.comat\'/var/lib/puppet/ssl/certs/cluster2.example.com.pem\'

      2)在 client 端執(zhí)行:rm -fr /var/lib/puppet/ssl/*

      [root@cluster2~]#rm-rf/var/lib/puppet/ssl/* [root@cluster2~]#puppetagent--servercluster1.example.com--no-daemonize--verbose

      puppet 資源定義
      以下資源均定義在/etc/puppet/manifest/site.pp 文件中,在沒有指定節(jié)點的情況下,對所有
      已經(jīng)經(jīng)過驗證的 client 都生效

      <1-7 摘子講義>

      1. 創(chuàng)建文件

      file{"/var/www/html/index.html":content=>"www.example.com"} mkdir/etc/puppet/files echowww.westos.org>/etc/puppet/files/index.html vi/etc/puppet/fileserver.conf [files] path/etc/puppet/files allow*.example.com servicepuppetmasterreload file{"/var/www/html/index.html": source=>"puppet:///files/index.html", }

      2. 軟件包定義

      package{“httpd”:ensure=>present; “vsftpd”:ensure=>absent }

      3. 服務定義

      service{"httpd":ensure=>running; “vsftpd”:ensure=>stopped }

      4. 組定義

      group{"wxh":gid=>600}

      5. 用戶定義

      user{"wxh": uid=>600, gid=>600, home=>"/home/wxh", shell=>"/bin/bash", password=>westos } file{"/home/wxh": owner=>wxh, group=>wxh, mode=>700, ensure=>directory } file{"/home/wxh/.bash_logout": source=>"/etc/skel/.bash_logout", owner=>wxh, group=>wxh } file{"/home/wxh/.bash_profile": source=>"/etc/skel/.bash_profile", owner=>wxh, group=>wxh } file{"/home/wxh/.bashrc": source=>"/etc/skel/.bashrc", owner=>wxh, group=>wxh } user{"test":uid=>900, home=>"/home/test", shell=>"/bin/bash", provider=>useradd, managehome=>true, ensure=>absent } exec{"echowestos|passwd--stdintest": path=>"/usr/bin:/usr/sbin:/bin", onlyif=>"idtest" }

      6. 文件系統(tǒng)掛載

      file{"/public": ensure=>directory } mount{"/public": device=>"192.168.0.254:/var/ftp/pub", fstype=>"nfs", options=>"defaults", ensure=>mounted }

      7. crontab 任務

      cron{echo: command=>"/bin/echo`/bin/date`>>/tmp/echo", user=>root, hour=>[\'2-4\'], minute=>\'*/10\' }

      下面我舉個例子,(后面我會給大家介紹模塊的思想)

      [root@cluster1puppet]#vi/etc/puppet/fileserver.conf [files] path/etc/puppet/files allow* [root@cluster1puppet]#mkdir/etc/puppet/files [root@cluster1puppet]#/etc/init.d/puppetmasterrestart

      例1:(文件)

      master端:

      [root@cluster1files]#cp/etc/passwd/etc/puppet/files/passwd [root@cluster1files]#vim/etc/puppet/manifests/site.pp file{"/tmp/zhang_1": source=>"puppet:///files/index.html", mode=>600 }

      client端:

      [root@cluster3tmp]#puppetagent--servercluster1.example.com--no-daemonize--verbose [root@cluster3tmp]#cat/tmp/zhang_1//成功建立 zhangxc1

      例2:(安裝服務,卸載服務,啟動服務)

      master端:

      [root@cluster1puppet]#vimanifests/site.pp package{["vim-enhanced","httpd"]: ensure=>present; ["vsftpd"]: ensure=>absent; } service{"httpd": ensure=>"running"http://stopped為停止服務 }

      clientd端:

      [root@cluster3~]#puppetagent--servercluster1.example.com--no-daemonize--verbose ... Notice:/Stage[main]/Main/Service[httpd]/ensure:ensurechanged\'stopped\'to\'running\' ...

      當然在批量部署的時候,我們會選擇主機,進行部署不同的服務:做法如下:(nodes.pp為指定節(jié)點,site.pp為全部節(jié)點)

      master端:

      [root@cluster1manifests]#visite.pp import"nodes.pp" [root@cluster1manifests]#vinodes.pp node\'cluster2.example.com\'{ file{"/tmp/zhangxc-cluster2": source=>"puppet:///files/passwd", mode=>600 } } node\'cluster3.example.com\'{ file{"/tmp/zhangxc-cluster3": source=>"puppet:///files/index.html", mode=>600 } }

      client端:

      [root@cluster2~]#puppetagent--servercluster1.example.com--no-daemonize--verbose [root@cluster2tmp]#ls zhangxc-cluster2 [root@cluster3~]#puppetagent--servercluster1.example.com--no-daemonize--verbose [root@cluster3tmp]#ls zhangxc-cluster3

      當然在生產(chǎn)環(huán)境當中我們不能這樣一步一步做,所以在這里我將經(jīng)給大家介紹模塊,當你需要對一個服務進行操作我們則可做成模塊供各個節(jié)點使用。

      大家可以舉一反三,在這里我以在apache做虛擬主機為例:

      master端:

      [root@cluster1~]#cd/etc/puppet/modules/ [root@cluster1modules]#mkdirhttpd/ [root@cluster1httpd]#mkdirfilesmanifests [root@cluster1httpd]#cdmanifests/ [root@cluster1manifests]#ls config.ppinit.ppinstall.ppservice.pp [root@cluster1manifests]#ls../files/ httpd.conf [root@cluster1manifests]#catinstall.pp classhttpd::install{ package{"httpd": ensure=>present } } [root@cluster1manifests]#catservice.pp classhttpd::service{ service{"httpd": ensure=>running, require=>Class["httpd::install","httpd::config"] } } [root@cluster1manifests]#catconfig.pp classhttpd::config{ file{"/etc/httpd/conf/httpd.conf": ensure=>present, source=>"puppet:///modules/httpd/httpd.conf", require=>Class["httpd::install"], notify=>Class["httpd::service"] } } [root@cluster1manifests]#catinit.pp classhttpd{ includehttpd::install,httpd::config,httpd::service } [root@cluster1manifests]#vi../files/httpd.conf ... ServerName192.168.1.43:80 ... DocumentRoot/www-zhangxc-cluster3 ServerNamecluster3.example.com [root@cluster1manifests]#vi../../../manifests/nodes.pp node\'cluster3.example.com\'{ includehttpd file{["/www-zhangxc-cluster3"]: ensure=>directory; ["/www-zhangxc-cluster3/index.html"]: content=>"zhangxc-192.168.1.43"; } } node\'cluster2.example.com\'{ file{["/www-zhangxc-cluster2"]: ensure=>directory; ["/www-zhangxc-cluster2/index.html"]: content=>"zhangxc-192.168.1.42"; } }

      client端:

      [root@cluster3~]#puppetagent--servercluster1.example.com--no-daemonize--verbose

      當讓我clients端:

      [root@cluster2~]#/etc/init.d/puppetstart//當我們配置沒有問題時,就可以啟動該服務。(注意開頭那些話)

      這樣就ok了,大家可以在這基礎上擴展!


      當前題目:puppet集中配置管理
      地址分享:http://www.ef60e0e.cn/article/cppgeg.html
      99热在线精品一区二区三区_国产伦精品一区二区三区女破破_亚洲一区二区三区无码_精品国产欧美日韩另类一区
      1. <ul id="0c1fb"></ul>

        <noscript id="0c1fb"><video id="0c1fb"></video></noscript>
        <noscript id="0c1fb"><listing id="0c1fb"><thead id="0c1fb"></thead></listing></noscript>

        桑日县| 梨树县| 宜阳县| 炉霍县| 宝应县| 贞丰县| 虞城县| 汉源县| 清苑县| 临沂市| 乃东县| 连城县| 静宁县| 祁阳县| 常山县| 东源县| 增城市| 大安市| 尉氏县| 金寨县| 柳林县| 灵璧县| 花莲县| 泉州市| 曲靖市| 新宾| 澳门| 长海县| 海兴县| 高邑县| 玛多县| 永清县| 沽源县| 甘南县| 彰化市| 麦盖提县| 阿拉善盟| 蒙阴县| 奈曼旗| 彩票| 台东县|