測試框架html
mirrors.redking.com 192.168.188.10 master.redking.com 192.168.188.20 agent.redking.com 192.168.188.30
Puppet 要求全部機器有完整的域名(FQDN),若是沒有 DNS 服務器提供域名的話,能夠在兩臺機器上設置主機名(注意要先設置主機名再安裝 Puppet,由於安裝 Puppet 時會把主機名寫入證書,客戶端和服務端通訊須要這個證書),由於我配置了DNS,因此就不用改hosts了,若是沒有就須要改hosts文件指定。前端
1.關閉selinux,iptables,並設置ntp
採用CentOS-6.6-x86_64.iso進行minimal最小化安裝node
關閉selinuxlinux
[root@master ~]# cat /etc/selinux/config # This file controls the state of SELinux on the system. # SELINUX= can take one of these three values: # enforcing - SELinux security policy is enforced. # permissive - SELinux prints warnings instead of enforcing. # disabled - No SELinux policy is loaded. SELINUX=enforcing # SELINUXTYPE= can take one of these two values: # targeted - Targeted processes are protected, # mls - Multi Level Security protection. SELINUXTYPE=targeted [root@master ~]# sed -i '/SELINUX/ s/enforcing/disabled/g' /etc/selinux/config [root@master ~]# cat /etc/selinux/config # This file controls the state of SELinux on the system. # SELINUX= can take one of these three values: # enforcing - SELinux security policy is enforced. # permissive - SELinux prints warnings instead of enforcing. # disabled - No SELinux policy is loaded. SELINUX=disabled # SELINUXTYPE= can take one of these two values: # targeted - Targeted processes are protected, # mls - Multi Level Security protection. SELINUXTYPE=targeted [root@master ~]# setenforce 0
中止iptablesnginx
[root@node1 ~]# chkconfig --list |grep tables ip6tables 0:off 1:off 2:on 3:on 4:on 5:on 6:off iptables 0:off 1:off 2:on 3:on 4:on 5:on 6:off [root@node1 ~]# chkconfig ip6tables off [root@node1 ~]# chkconfig iptables off [root@node1 ~]# service ip6tables stop ip6tables: Setting chains to policy ACCEPT: filter [ OK ] ip6tables: Flushing firewall rules: [ OK ] ip6tables: Unloading modules: [ OK ] [root@node1 ~]# service iptables stop iptables: Setting chains to policy ACCEPT: filter [ OK ] iptables: Flushing firewall rules: [ OK ] iptables: Unloading modules: [ OK ] [root@node1 ~]#
設置ntpvim
[root@master ~]# ntpdate pool.ntp.org [root@master ~]# chkconfig --list|grep ntp ntpd 0:off 1:off 2:off 3:off 4:off 5:off 6:off ntpdate 0:off 1:off 2:off 3:off 4:off 5:off 6:off [root@master ~]# chkconfig ntpd on [root@master ~]# service ntpd start Starting ntpd: [ OK ] [root@master ~]#
建立軟件倉庫centos
1.在mirrors.redking.com軟件倉庫服務器上安裝EPEL源及yum-downloadonly和createrepo軟件包bash
[root@mirrors ~]# rpm -ivh http://mirrors.sohu.com/fedora-epel/6Server/x86_64/epel-release-6-8.noarch.rpm Retrieving http://mirrors.sohu.com/fedora-epel/6Server/x86_64/epel-release-6-8.noarch.rpm warning: /var/tmp/rpm-tmp.2hQx2e: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEY Preparing... ########################################### [100%] 1:epel-release ########################################### [100%] [root@mirrors ~]# yum -y install yum-downloadonly createrepo
2.建立軟件倉庫地址,選擇/data/mirrors目錄做爲軟件倉庫目錄服務器
[root@mirrors ~]# mkdir -pv /data/mirrors/centos/6/{os,updates}/x86_64/RPMS mkdir: created directory `/data' mkdir: created directory `/data/mirrors' mkdir: created directory `/data/mirrors/centos' mkdir: created directory `/data/mirrors/centos/6' mkdir: created directory `/data/mirrors/centos/6/os' mkdir: created directory `/data/mirrors/centos/6/os/x86_64' mkdir: created directory `/data/mirrors/centos/6/os/x86_64/RPMS' mkdir: created directory `/data/mirrors/centos/6/updates' mkdir: created directory `/data/mirrors/centos/6/updates/x86_64' mkdir: created directory `/data/mirrors/centos/6/updates/x86_64/RPMS'
3.將Nginx、Puppet軟件包存放到軟件倉庫,採用downloadonly的方式進行更新框架
puppet不在CentOS的基本源中,須要加入 PuppetLabs 提供的官方源
[root@mirrors ~]# rpm -ivh http://yum.puppetlabs.com/el/6/products/x86_64/puppetlabs-release-6-7.noarch.rpm [root@mirrors ~]# yum install nginx puppet-server puppet -y --downloadonly --downloaddir=/data/mirrors/centos/6/updates/x86_64/RPMS/
4.採用createrepo建立倉庫文件,若是軟件包比較多時能夠經過--update參數進行更新
[root@mirrors ~]# createrepo /data/mirrors/centos/6/os/x86_64/ [root@mirrors ~]# createrepo /data/mirrors/centos/6/updates/x86_64/
5.在軟件倉庫服務器前端安裝配置Nginx Web來處理安裝包請求
[root@mirrors ~]yum install -y nginx [root@mirrors ~]# service nginx start [root@mirrors ~]# chkconfig nginx on
6.爲軟件倉庫配置mirrors.redking.com虛擬機
[root@mirrors ~]# vim /etc/nginx/conf.d/mirrors.redking.com.conf server { listen 80; server_name mirrors.redking.com; root /data/mirrors; index index.html; } [root@mirrors ~]# service nginx restart
經過上面6步就成功搭建本地軟件倉庫,在客戶端只須要配置repo文件就能夠安裝此軟件倉庫中的軟件包。
配置YUM本地源
客戶端配置mirrors.repo文件,咱們也能夠使用Puppet的yumrepo資源來指定yum源
[root@master ~]# vim /etc/yum.repos.d/mirrors.repo [base] name=CentOS-$releasever - Base baseurl=http://mirrors.redking.com/centos/$releasever/os/$basearch/ enabled=1 gpgcheck=0 #released updates [updates] name=CentOS-$releasever - Updates baseurl=http://mirrors.redking.com/centos/$releasever/updates/$basearch/ enabled=1 gpgcheck=0
[root@master ~]# cd /etc/yum.repos.d/ [root@master yum.repos.d]# mv CentOS-Base.repo CentOS-Base.repo.bak [root@master yum.repos.d]# yum clean all
安裝Puppet
1.Puppet Master服務器端安裝puppet-server,自動匹配安裝Facter等相關依賴包
[root@master ~]# yum install -y puppet-server [root@master ~]# chkconfig puppetmaster on [root@master ~]# service puppetmaster start
2.Puppet agent客戶端安裝puppet
[root@agent yum.repos.d]# yum install -y puppet [root@agent yum.repos.d]# chkconfig puppet on [root@agent yum.repos.d]# service puppet start
=============================END=====================================