教育行業(yè)A股IPO第一股(股票代碼 003032)

全國(guó)咨詢/投訴熱線:400-618-4000

puppet是什么?puppet安裝文檔

更新時(shí)間:2019年01月24日17時(shí)00分 來(lái)源:puppet是什么 瀏覽次數(shù):

1)安裝環(huán)境:

兩臺(tái)ubuntu 12.04 的實(shí)例

server(master): ?ip:192.168.254.234 ?host:vm234.com

client: ? ? ? ? ? ? ? ? ip:192.168.254.235 ? host:vm235.com

2)安裝前的準(zhǔn)備:

請(qǐng)務(wù)必先給各自的主機(jī)的/etc/hosts 添加上hostname和ip,在服務(wù)節(jié)點(diǎn),添加自己的hostname和所有client節(jié)點(diǎn)的host和ip;在client節(jié)點(diǎn),只需添加server和自己的hostname和ip;這是因?yàn)樵趕erver的日志記錄里都是以hostname來(lái)區(qū)別不同的節(jié)點(diǎn)。

server是通過(guò)端口8140(由ruby占有)與client通信的,所以請(qǐng)確認(rèn)設(shè)置防火墻,開(kāi)放此端口。

為了各個(gè)節(jié)點(diǎn)能協(xié)同的運(yùn)行服務(wù),必須統(tǒng)一各個(gè)節(jié)點(diǎn)的時(shí)間,請(qǐng)給各個(gè)節(jié)點(diǎn)裝ntp。以server節(jié)點(diǎn)的時(shí)間為標(biāo)準(zhǔn)。

3)安裝:

在server節(jié)點(diǎn)安裝?puppetmaster:

#sudo apt-get install puppetmaster

可通過(guò)腳本?/etc/init.d/puppetmaster 來(lái)控制狀態(tài)(start,restart,stop,status)

在client節(jié)點(diǎn)安裝 puppet:

#sudo apt-get install puppet?

注:如系統(tǒng)未安裝運(yùn)行puppet所需的ruby環(huán)境,上述兩條指令會(huì)自動(dòng)安裝。

然后配置文件 /etc/puppet/puppet.conf。這是puppet的主要配置文件。

在server節(jié)點(diǎn),打開(kāi)/etc/puppet/puppet.conf后,在[master]下添加當(dāng)前機(jī)器的certname

[master]

certname=vm234.com

保存后重啟服務(wù):

#service puppetmaster restart?

在client節(jié)點(diǎn),打開(kāi)/etc/puppet/puppet.conf后,添加:

[agent]

certname=vm235.com

server=vm234.com

report=true

#pluginsync=true

注:當(dāng)有插件需要同步的時(shí)候,再取消pluginsync的注釋。

保存退出后,再打開(kāi)?/etc/default/puppet , 將START=on 改為 START=yes。將puppet設(shè)置為開(kāi)機(jī)默認(rèn)啟動(dòng)項(xiàng)。這是puppet在client端強(qiáng)制要求的。

然后重啟puppet服務(wù)

#service puppet restart

4)服務(wù)連接:

首先在路徑?/etc/puppet/manifests/ 下創(chuàng)建 site.pp

然后是client端向server發(fā)起認(rèn)證的請(qǐng)求:

#puppet agent --server=vm234.com --no-daemonize --verbose

然后在server節(jié)點(diǎn)列出當(dāng)前請(qǐng)求認(rèn)證者的hostname

#puppet cert --list

結(jié)果是:

"vm235.com" (一長(zhǎng)串密鑰的指紋)

然后server接受特定client的請(qǐng)求:

#puppet cert --sign ?vm235.com

或者是接受所有client的請(qǐng)求:

#puppet cert --sign --all?

notice: Signed certificate request for vm235.com

notice: Removing file Puppet::SSL::CertificateRequest vm235.com at '/var/lib/puppet/ssl/ca/requests/vm235.com.pem'

認(rèn)證后,client的公鑰放在文件夾?/var/lib/puppet/ssl/ca/signed/

然后在client端顯示:

info: Caching certificate for vm235.com

notice: Starting Puppet client version 2.7.11

至此認(rèn)證請(qǐng)求完畢,可暫停client的agent ,即按 ctrl + c;也可等它自行結(jié)束,就是時(shí)間可能會(huì)久點(diǎn)。但是一定要出現(xiàn)?notice: Starting Puppet client version 2.7.11 的信息確認(rèn)認(rèn)證成功后才可暫停。

可用下面小段代碼測(cè)試是puppet是否配置成功:

在?/etc/puppet/manifests/site.pp 輸入

node 'vm235.com'{

file{

"/root/helloWorld":

content=>"hello world\n" ,

mode => 0644;

}

}

保存后。在client端輸入

#puppet agent --test

將在后臺(tái)運(yùn)行的 agent 放到終端顯示,顯示的信息如下:

info: Caching catalog for vm235.com

info: Applying configuration version '1374052357'

notice: /Stage[main]//Node[vm235.com]/File[/root/helloWorld]/ensure: defined content as '{md5}6f5902ac237024bdd0c176cb93063dc4'

notice: Finished catalog run in 0.03 seconds

這時(shí),在如在client生成文件?/root/helloWorld,文件的內(nèi)容是hello world,則證明puppet已經(jīng)能正常工作了。

5)常用小技巧:

在server節(jié)點(diǎn)的路徑?/var/lib/puppet/ssl/ca/signed 可查看server目前已經(jīng)接受的client的公鑰

6)常見(jiàn)bug:

?命令 service puppet status 可查看當(dāng)前服務(wù)的狀態(tài),如果遇到錯(cuò)誤:could not access PID file for agent 。這是因?yàn)榉?wù)發(fā)生異常而關(guān)閉了,

請(qǐng)重啟服務(wù)?service puppet restart。

輸入指令puppet agent --server=vm234.com --no-daemonize --verbose,遇到錯(cuò)誤 Could not run: Could not create PID file: /var/run/puppet/agent.pid。這是因?yàn)橐延衟uppet agent 啟動(dòng)了,請(qǐng)刪除之前的進(jìn)程(可用 pgrep和pkill),再重新啟動(dòng)服務(wù)puppet agent --server=……

---------------------

作者:DamonHao

來(lái)源:CSDN

原文:https://blog.csdn.net/damonhao/article/details/11378025

版權(quán)聲明:本文為博主原創(chuàng)文章,轉(zhuǎn)載請(qǐng)附上博文鏈接!
0 分享到:
和我們?cè)诰€交談!