Puppet部署:安裝puppet server、client
puppet與其他手工操作工具有一個***的區(qū)別就是 puppet的配置具有穩(wěn)定性,因此你可以多次執(zhí)行puppet, 一旦你更新了你的配置文件,puppet就會根據(jù)配置文件來更改你的機器配置,通常每30分鐘檢查一次. puppet會讓你的系統(tǒng)狀態(tài)同配置文件所要求的狀態(tài)保持一致. 比如你配置文件里面要求ssh服務必須開啟. 假如不小心ssh服務被關閉了,那么下一次執(zhí)行puppet的時候,puppet會發(fā)現(xiàn)這個異常,然后會開啟 ssh 服務. 以使系統(tǒng)狀態(tài)和配置文件保持一致.puppet就象一個魔術師,會讓你的混亂的系統(tǒng)收斂到puppet配置文件所想要的狀態(tài)。
可以使用puppet管理服務器的整個生命周期,從初始化到退役.不同于傳統(tǒng)的例如sun的Jumpstart或者redhat的Kickstart, puppet可以長年讓服務器保持***狀態(tài).只要一開始就正確的配置他們,然后再也不用去管他們.通常puppet用戶只需要給機器安裝好puppet并讓他們運行,然后剩余的工作都由puppet來完成。
試驗環(huán)境
硬件:兩臺服務器,虛擬服務器或者物理機器都行,ip地址分別是 192.168.10.133 (server)和 192.168.10.207(client) ;下文分別用server和client代替兩個服務器.
軟件:安裝Centos 5X64(server),Ubuntu 12.04(client) 系統(tǒng)
網(wǎng)絡:兩臺機器互相能訪問
在server端配置: 1.設置主機名:
- [root@server ~]# uname -a
- Linux server.puppet.com 2.6.18-238.el5 #1 SMP Thu Jan 13 15:51:15 EST 2011 x86_64 x86_64 x86_64 GNU/Linux
- [root@server ~]# hostname
- server.puppet.com
- [root@server ~]# cat /etc/hosts
- # Do not remove the following line, or various programs
- # that require network functionality will fail.
- 127.0.0.1 redmine localhost.localdomain localhost
- ::1 localhost6.localdomain6 localhost6
- 192.168.10.133 server.puppet.com server
2.配置server端的yum源(因為centos默認沒有puppet 源,因此先配置puppet的源,下面鏈接失效可以參考:https://fedoraproject.org/wiki/EPEL/zh-cn.)
- [root@server ~]# rpm -Uvh http://dl.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm
3.開始安裝puppet server
- [root@server ~]# yum -y install puppet-server facter ruby ruby-libs ruby-shadow
4.yum安裝puppet成功,先啟動服務,查看安裝成功否
- [root@server ~]# service puppetmaster start
- Starting puppetmaster: [ OK ]
- [root@server ~]# ps -ef | grep puppet
- puppet 2937 1 0 11:47 ? 00:00:00 /usr/bin/ruby /usr/sbin/puppetmasterd
- root 2943 2751 0 11:47 pts/1 00:00:00 grep puppet
個人喜歡先用
- [root@server ~]# puppet master --verbose --no-daemonize
- notice: Starting Puppet master version 2.6.17
因為這個可以看到輸出.跟后面的測試有關系,調試完畢.建議用守護進程方式啟動
現(xiàn)在看到server啟動沒有問題.現(xiàn)在可以出安裝 ubuntu client了
1.設置client的hostname
- liming@client:~$ hostname
- client.puppet.com
2.設置server hosts(添加如下)
- liming@client:~$ sudo vim /etc/hosts
- 192.168.10.133 server.puppet.com
3.設置ubuntu apt源
- liming@client:~$ sudo su -
- liming@client:~$ echo -e "deb http://apt.puppetlabs.com/ lucid main\ndeb-src http://apt.puppetlabs.com/ lucid main" >> /etc/apt/sources.list.d/puppet.list
- liming@client:~$ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 4BD6EC30
- liming@client:~$ sudo apt-get update
4.安裝puppet 客戶端
sudo apt-get install puppet
5.測試
- liming@client:~$ sudo puppet agent --server=server.puppet.com --no-daemonize --verbose --onetime
- info: Creating a new SSL key for client.puppet.com
- warning: peer certificate won't be verified in this SSL session
- info: Caching certificate for ca
- warning: peer certificate won't be verified in this SSL session
- warning: peer certificate won't be verified in this SSL session
- info: Creating a new SSL certificate request for client.puppet.com
- info: Certificate Request fingerprint (md5): 54:CC:33:85:ED:4E:97:05:5F:6D:CE:D9:1F:1F:E9:BC
- warning: peer certificate won't be verified in this SSL session
- warning: peer certificate won't be verified in this SSL session
- warning: peer certificate won't be verified in this SSL session
服務器端查看等待請求證書連接的客戶端
- [root@server ~]# puppet cert --list
- "client.puppet.com" (54:CC:33:85:ED:4E:97:05:5F:6D:CE:D9:1F:1F:E9:BC)
現(xiàn)在server和client 端都沒問題.若想吧client 換成Centos Or RHEL 重復server 2.配置puppet的yum源.直接yum install puppet 即可!
出現(xiàn)的問題:
- liming@client:~$ puppetd --server server.puppet.com --test
- err: Could not retrieve catalog from remote server: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed. This is often because the time is out of sync on the server or client
- warning: Not using cache on failed catalog
- err: Could not retrieve catalog; skipping run
- err: Could not send report: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed. This is often because the time is out of sync on the server or client