99偷拍视频精品区一区二,口述久久久久久久久久久久,国产精品夫妇激情啪发布,成人永久免费网站在线观看,国产精品高清免费在线,青青草在线观看视频观看,久久久久久国产一区,天天婷婷久久18禁,日韩动漫av在线播放直播

puppet集中配置管理

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

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

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

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

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

環(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之間需要解析,以及時(shí)間的同步,不然會(huì)失敗。 //時(shí)間同步大家可以參見(jiàn)我的

ntp時(shí)間同步http://my.oschina.net/zhangxc73912/blog/207197

master端:

首先.yum倉(cāng)庫(kù)添加如下:

[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的第一個(gè)執(zhí)行的代碼是在/etc/puppet/manifest/site.pp, 因此這個(gè)文件必須存在,而且其他的代碼也要通過(guò)該文件來(lái)調(diào)用。也就是說(shuō)沒(méi)有此文件puppetmaster無(wú)法啟動(dòng),配置后面再定義

啟動(dòng)

[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

我們首先不要開(kāi)啟pppute,即讓服務(wù)在前端跑,且不要打入后端。

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

[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ā)出證書(shū)驗(yàn)證請(qǐng)求,然后等待 master 簽名并返回證書(shū)。
參數(shù)--server 指定了需要連接的 puppet master 的名字或是地址,默認(rèn)連接名為“puppet”的主機(jī)
如要修改默認(rèn)連接主機(jī)可以修改/etc/sysconfig/puppet 文件中的 PUPPET_SERVER=puppet 選項(xiàng)
參數(shù)--no-daemonize 是 puppet 客戶(hù)端運(yùn)行在前臺(tái)
參數(shù)--verbose 使客戶(hù)端輸出詳細(xì)的日志

在 master端

[root@cluster1~]#puppetcertlist//顯示等待簽名的證書(shū) "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//簽名證書(shū) Notice:Signedcertificaterequestforcluster2.example.com Notice:RemovingfilePuppet::SSL::CertificateRequestcluster2.example.comat\'/var/lib/puppet/ssl/ca/requests/cluster2.example.com.pem\'

如果需要同時(shí)簽名所有證書(shū),則

[root@cluster1~]#puppetcertsign--all

如果要?jiǎng)h除證書(shū)則

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

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

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

當(dāng)然了,在實(shí)際當(dāng)中,我們則需要它自動(dòng)簽署:

master端:

[root@cluster1~]#vi/etc/puppet/puppet.conf [main] autosign=true//允許所有客戶(hù)認(rèn)證 [root@cluster1~]#touch/etc/puppet/autosign.conf [root@cluster1~]#vi/etc/puppet/autosign.conf .example.com//允許該域的主機(jī),當(dāng)然我們還可以再添見(jiàn)域,另起一行書(shū)寫(xiě) [root@cluster1~]#/etc/init.d/puppetmasterreload

client端:

[root@cluster3~]#puppetagent--servercluster1.example.com--no-daemonize--verbose//他就會(huì)自動(dòng)被簽署了

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

[root@cluster1~]#puppetcert--cleancluster2.example.com//刪除原有的client端主機(jī)名,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 文件中,在沒(méi)有指定節(jié)點(diǎn)的情況下,對(duì)所有
已經(jīng)經(jīng)過(guò)驗(yàn)證的 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. 服務(wù)定義

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

4. 組定義

group{"wxh":gid=>600}

5. 用戶(hù)定義

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 任務(wù)

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

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

[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:(安裝服務(wù),卸載服務(wù),啟動(dòng)服務(wù))

master端:

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

clientd端:

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

當(dāng)然在批量部署的時(shí)候,我們會(huì)選擇主機(jī),進(jìn)行部署不同的服務(wù):做法如下:(nodes.pp為指定節(jié)點(diǎn),site.pp為全部節(jié)點(diǎn))

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

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

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

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 ... <VirtualHost*:80> DocumentRoot/www-zhangxc-cluster3 ServerNamecluster3.example.com </VirtualHost> [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

當(dāng)讓我clients端:

[root@cluster2~]#/etc/init.d/puppetstart//當(dāng)我們配置沒(méi)有問(wèn)題時(shí),就可以啟動(dòng)該服務(wù)。(注意開(kāi)頭那些話)

這樣就ok了,大家可以在這基礎(chǔ)上擴(kuò)展!

網(wǎng)頁(yè)題目:puppet集中配置管理
標(biāo)題URL:http://www.yijiale78.com/article46/cppgeg.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供品牌網(wǎng)站建設(shè)App設(shè)計(jì)自適應(yīng)網(wǎng)站網(wǎng)站內(nèi)鏈Google網(wǎng)站營(yíng)銷(xiāo)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶(hù)投稿、用戶(hù)轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

成都網(wǎng)站建設(shè)