安装前工作:
1、主机名解析:
每一个node必须有唯一的hostname,并且通过DNS服务器能解析每个hostname,如果没有DNS服务器,可以编辑/etc/hosts文件。然后把此文件同步到各节点。
[root@node1 ~]# cat /etc/hosts 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 192.168.10.11 node1.syt.com node1 192.168.10.12 node2.syt.com node2 192.168.10.13 node3.syt.com node3 192.168.10.14 node4.syt.com node4 192.168.10.15 node5.syt.com node5 192.168.10.16 node6.syt.com node6 192.168.10.17 node7.syt.com node7
[root@node1 ~]# for i in {1..7};do scp /etc/hosts 192.168.10.1$i:/etc/ ;done
2、各个node之间配置双机互信
node1上执行:
[root@node1 ~]# ssh-keygen -t rsa [root@node1 ~]# for i in {1..7};do ssh-copy-id -i node$i ;done
同上一次在node2....node7上面执行上述两条命令。
3、关闭防火墙和SELinux。
[root@node1 ~]# for i in {1..7};do ssh node$i "chkconfig iptables off && service iptables stop && setenforce 0";done
Note:master也可以不关闭防火墙
Firewalls: The puppet master server must allow incoming connections on port 8140, and agent nodes must be able to connect to the master on that port
4、要保证各节点时间同步。
[root@node1 ~]# for i in {1..7};do ssh node$i "ntpdate node1";done
安装puppet:
1、在各节点上面安装官方yum源RPM包。
[root@node1 ~]# for i in {1..7};do ssh node$i "rpm -ivh http://yum.puppetlabs.com/puppetlabs-release-el-6.noarch.rpm";done [root@node1 ~]# for i in {1..7};do ssh node$i "rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-*";done
puppet的安装依赖ruby,首先安装ruby依赖软件包(要求ruby的版本要>=1.87):
#yum install ruby ruby-libs ruby-shadow
在所有节点上面安装puppet官方yum源:
For Red Hat Enterprise Linux and Derivatives
Note that RHEL 5 requires an updated Ruby ≥ 1.8.7 from our yum repo.
Enterprise Linux 7
$ sudo rpm -ivh http://yum.puppetlabs.com/puppetlabs-release-el-7.noarch.rpm
Enterprise Linux 6
$ sudo rpm -ivh http://yum.puppetlabs.com/puppetlabs-release-el-6.noarch.rpm
Enterprise Linux 5
$ sudo rpm -ivh http://yum.puppetlabs.com/puppetlabs-release-el-5.noarch.rpm
After installing the repos, open your /etc/yum.repos.d/puppetlabs.repo file for editing. Locate the [puppetlabs-devel] stanza, and change the value of the enabled key from 0 to 1:
[puppetlabs-devel]
name=Puppet Labs Devel <%= @dist.capitalize -%> <%= @version -%> - $basearch
baseurl=http://yum.puppetlabs.com/<%= @dist.downcase -%>/<%= @codename -%>/devel/$basearch
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-puppetlabs
enabled=1
gpgcheck=1
[root@node1 ~]# for i in {1..7};do ssh node$i "sed -i 's/enabled=0/enabled=1/g' /etc/yum.repos.d/puppetlabs.repo";done
Step 1: Install Puppet on the Puppet Master Server
#yum install puppet-server
Step 2: Install Puppet on Agent Nodes
# yum install puppet facter
Step 3:Configure a Puppet Master Server
master的主配置文件/etc/puppet/puppet.conf,这个配置文件在puppet安装时被创建,如果没有,可以使用
下面命令来创建一个简单的配置文件:
[root@node4 ~]# puppet master --genconfig > /etc/puppet/puppet.conf.bak
用此命令重新生成的puppet.conf文件比默认的配置文件内容详细很多。
此配置文件分为三部分:
[main]段用于存放全局配置
[master]段用于配置puppet master
[agent]段用于配置puppet agent
注意:这个里面配置了两个certname名称,其中[master]中配置的certname是为所有节点认证用的master名称,
[agent]中配置的certname是他本身agent的名称,当然不配置默认是和master的名称是一样的。
转载于:https://blog.51cto.com/sunyongtaolinux/1424817