Puppet安装部署入门版(2)

Puppet 要求所有机器有完整的域名(FQDN),如果没有 DNS 服务器提供域名的话,可以在两台机器上设置主机名(注意要先设置主机名再安装 Puppet,因安装 Puppet 时会把主机名写入证书,客户端和服务端通信需要这个证书):

 

[root@lianglab soft]# echo "10.13.89.185 lianglab4.com" >>/etc/hosts

[root@lianglab soft]# hostname

lianglab.com

[root@lianglab soft]# cat /etc/sysconfig/network

NETWORKING=yes

NETWORKING_IPV6=no

HOSTNAME=lianglab.com

[root@lianglab soft]#

 

[root@lianglab soft]# cat /etc/resolv.conf

; generated by /sbin/dhclient-script

search taobao.ali.com

nameserver 10.13.2.6

nameserver 10.1.23.6

[root@lianglab soft]#

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

安装ruby

 

由于puppet是由ruby语言编写,所以要安装ruby环境及库文件,命令帮助文件

[root@lianglab soft]# yum install ruby ruby-libs ruby-rdoc

安装facter

 

puppet资源下载点

 

facter是一个系统盘点工具,收集主机的一些资料,比如CPU,主机IP等,它收集到值发送给puppet服务器端,服务器端就可以根据不同的条件来对不同的节点机器生成不同的puppet配置文件

 

安装puppet之前必须先安装facter

 

[root@lianglab soft]# wget

--2013-06-15 12:15:55--

正在解析主机 downloads.puppetlabs.com... 96.126.116.126, 2600:3c00::f03c:91ff:fe93:711a

Connecting to downloads.puppetlabs.com|96.126.116.126|:80... 已连接。

已发出 HTTP 请求,正在等待回应... 200 OK

长度:119323 (117K) [application/x-gzip]

Saving to: `facter-1.6.8.tar.gz'

 

100%[===================================================>] 119,323 152K/s in 0.8s

 

2013-06-15 12:15:57 (152 KB/s) - `facter-1.6.8.tar.gz' saved [119323/119323]

 

[root@lianglab soft]#

[root@lianglab soft]#

[root@lianglab soft]# tar -zxvf facter-1.6.8.tar.gz

------省略--------

facter-1.6.8/conf/osx/PackageInfo.plist

facter-1.6.8/conf/osx/preflight

facter-1.6.8/bin/facter

[root@lianglab soft]# cd facter-1.6.8

[root@lianglab facter-1.6.8]# ruby install.rb

facter-1.6.8/conf/osx/PackageInfo.plist

facter-1.6.8/conf/osx/preflight

facter-1.6.8/bin/facter

[root@lianglab soft]# cd facter-1.6.8

[root@lianglab facter-1.6.8]# ruby install.rb

which: no rst2man.py in (/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin)

install -c -p -m 0755 /tmp/facter-binfile.27543.0 /usr/bin/facter

mkdir -p -m 755 /usr/lib/ruby/site_ruby/1.8

-------------省略-------------------

install -c -p -m 0644 lib/facter/util/plist/generator.rb /usr/lib/ruby/site_ruby/1.8/facter/util/plist/generator.rb

Loaded suite install

Started

 

Finished in 0.000588 seconds.

 

0 tests, 0 assertions, 0 failures, 0 errors

[root@lianglab facter-1.6.8]#

 

安装puppet

[root@lianglab facter-1.6.8]# cd ..

[root@lianglab soft]# wget

--2013-06-15 12:21:13--

正在解析主机 downloads.puppetlabs.com... 96.126.116.126, 2600:3c00::f03c:91ff:fe93:711a

Connecting to downloads.puppetlabs.com|96.126.116.126|:80... 已连接。

已发出 HTTP 请求,正在等待回应... 200 OK

长度:1898410 (1.8M) [application/x-gzip]

Saving to: `puppet-2.7.14.tar.gz'

 

100%[===================================================>] 1,898,410 474K/s in 4.4s

 

2013-06-15 12:21:18 (422 KB/s) - `puppet-2.7.14.tar.gz' saved [1898410/1898410]

 

[root@lianglab soft]#

 

[root@lianglab soft]# tar -zxvf puppet-2.7.14.tar.gz

[root@lianglab soft]# cd puppet-2.7.14

[root@lianglab puppet-2.7.14]# ruby install.rb

--------------省略-------------------

man/man8/puppet-doc.8 -> /usr/share/man/man8/puppet-doc.8

chmod 0644 /usr/share/man/man8/puppet-doc.8

man/man8/pi.8 -> /usr/share/man/man8/pi.8

chmod 0644 /usr/share/man/man8/pi.8

man/man8/puppet-describe.8 -> /usr/share/man/man8/puppet-describe.8

chmod 0644 /usr/share/man/man8/puppet-describe.8

man/man8/puppet-device.8 -> /usr/share/man/man8/puppet-device.8

chmod 0644 /usr/share/man/man8/puppet-device.8

man/man8/puppet-man.8 -> /usr/share/man/man8/puppet-man.8

chmod 0644 /usr/share/man/man8/puppet-man.8

man/man8/puppetca.8 -> /usr/share/man/man8/puppetca.8

chmod 0644 /usr/share/man/man8/puppetca.8

man/man5/puppet.conf.5 -> /usr/share/man/man5/puppet.conf.5

chmod 0644 /usr/share/man/man5/puppet.conf.5

[root@lianglab puppet-2.7.14]#

 

复制配置文件

[root@lianglab puppet-2.7.14]# cp conf/RedHat/fileserver.conf /etc/puppet/

[root@lianglab puppet-2.7.14]# cp conf/redhat/puppet.conf /etc/puppet/

[root@lianglab puppet-2.7.14]# cp conf/redhat/server.init /etc/init.d/puppetmaster

[root@lianglab puppet-2.7.14]#

 

 

添加puppet用户

[root@lianglab puppet-2.7.14]# groupadd puppet

[root@lianglab puppet-2.7.14]# useradd -g puppet -s /bin/false -M puppet

[root@lianglab puppet-2.7.14]#

 

 

验证一下安装是否成功

[root@lianglab puppet-2.7.14]# puppet master

[root@lianglab puppet-2.7.14]# ps -ef | grep puppet | grep -v grep

puppet 27781 1 0 12:30 ? 00:00:00 /usr/bin/ruby /usr/bin/puppet master

[root@lianglab puppet-2.7.14]#

[root@lianglab puppet-2.7.14]# kill 27781

[root@lianglab puppet-2.7.14]# ps -ef | grep puppet | grep -v grep

[root@lianglab puppet-2.7.14]#

 

 

 

 

 

设置puppetmaster为服务,并自动启动,确认puppetmaster是否有执行权限

将puppetmaster服务脚本添加为服务,并在3、5级别启动。

[root@lianglab puppet-2.7.14]# chmod 755 /etc/init.d/puppetmaster

[root@lianglab puppet-2.7.14]# chkconfig --add puppetmaster

[root@lianglab puppet-2.7.14]# chkconfig --level 35 puppetmaster on

[root@lianglab puppet-2.7.14]#

[root@lianglab puppet-2.7.14]# /etc/init.d/puppetmaster restart

停止 puppetmaster:[失败]

启动 puppetmaster:[确定]

[root@lianglab puppet-2.7.14]#

[root@lianglab puppet-2.7.14]# ps -ef | grep puppet | grep -v grep

puppet 27883 1 0 12:48 ? 00:00:00 /usr/bin/ruby /usr/sbin/puppetmasterd

[root@lianglab puppet-2.7.14]#

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/67a8e0ed633a14e54886d2c2afd17958.html