首页 > 代码库 > puppet练习记录一
puppet练习记录一
安装puppet前准备内容
规范ip,主机名,防火墙,双机互信,域名解析
1、修改ip
master [root@master etc]# cat /etc/sysconfig/network-scripts/ifcfg-eth0 # Advanced Micro Devices [AMD] 79c970 [PCnet32 LANCE] DEVICE=eth0 BOOTPROTO=static ONBOOT=yes HWADDR=00:0c:29:53:d8:5c IPADDR=192.168.1.10 NETWARK=255.255.255 GATWAY=192.168.1.1 DNS=202.96.128.86 agent01 [root@agent01 ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0 # Advanced Micro Devices [AMD] 79c970 [PCnet32 LANCE] DEVICE=eth0 BOOTPROTO=static ONBOOT=yes HWADDR=00:0c:29:20:ea:2d IPADDR=192.168.1.11 NETWORK=255.255.255.255 GATWAY=192.168.1.1 DNS=202.96.128.86 agnet02 [root@agent02 ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0 # Advanced Micro Devices [AMD] 79c970 [PCnet32 LANCE] DEVICE=eth0 BOOTPROTO=static ONBOOT=yes HWADDR=00:0c:29:9e:d5:92 IPADDR=192.168.1.12 NETWORK=255.255.255.0 GATWAY=192.168.1.1 DNS=202.96.128.86
2、修改主机名
master [root@master etc]# cat /etc/sysconfig/network NETWORKING=yes NETWORKING_IPV6=yes #HOSTNAME=localhost.localdomain HOSTNAME=master.puppet GATEWAY=192.168.1.1 agent01 [root@agent01 ~]# cat /etc/sysconfig/network NETWORKING=yes NETWORKING_IPV6=yes #HOSTNAME=localhost.localdomain HOSTNAME=agent01.puppet GATEWAY=192.168.1.1 agnet02 [root@agent02 ~]# cat /etc/sysconfig/network NETWORKING=yes NETWORKING_IPV6=yes #HOSTNAME=localhost.localdomain HOSTNAME=agent02.puppet GATEWAY=192.168.1.1 修改主机名,需重启后生效。
3、为了减少测试环境的复杂程度,直接关闭防火墙
[root@master /]# service iptables stop 清除防火墙规则: [确定] 把 chains 设置为 ACCEPT 策略:filter [确定] 正在卸载 Iiptables 模块: [确定] 设置防火墙开机为关闭 [root@master /]# chkconfig iptables off
4、配置agent机器和master机器互信
在master生成公钥 [root@master ~]# ssh-keygen Generating public/private rsa key pair. Enter file in which to save the key (/root/.ssh/id_rsa): Created directory ‘/root/.ssh‘. Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /root/.ssh/id_rsa. Your public key has been saved in /root/.ssh/id_rsa.pub. The key fingerprint is: 17:61:db:30:21:ce:a2:95:8b:64:ff:65:b3:08:d0:c0 root@master.puppet 复制公钥到agnet机器上 [root@master .ssh]# ssh-copy-id -i ~/.ssh/id_rsa.pub 192.168.1.11 [root@master .ssh]# ssh-copy-id -i ~/.ssh/id_rsa.pub 192.168.1.12
5、配置域名相互解析
使用host文件直接进行解析配置
[root@master /]# cat /etc/hosts # Do not remove the following line, or various programs # that require network functionality will fail. 127.0.0.1 localhost.localdomain localhost ::1 localhost6.localdomain6 localhost6 192.168.1.10 master.puppet 192.168.1.11 agent01.puppet 192.168.1.12 agent02.puppet
将此文件拷贝到其他两台agent机器上
[root@master etc]# for i in {1..2};do scp hosts 192.168.1.1$i:/etc/;done hosts 100% 271 0.3KB/s 00:00 hosts 100% 271 0.3KB/s 00:00
域名解析测试
[root@master etc]# ping master.puppet PING master.puppet (192.168.1.10) 56(84) bytes of data. 64 bytes from master.puppet (192.168.1.10): icmp_seq=1 ttl=64 time=1.35 ms 64 bytes from master.puppet (192.168.1.10): icmp_seq=2 ttl=64 time=0.083 ms 64 bytes from master.puppet (192.168.1.10): icmp_seq=3 ttl=64 time=0.030 ms --- master.puppet ping statistics --- 3 packets transmitted, 3 received, 0% packet loss, time 2029ms rtt min/avg/max/mdev = 0.030/0.488/1.351/0.610 ms [root@master etc]# ping agent01.puppet PING agent01.puppet (192.168.1.11) 56(84) bytes of data. 64 bytes from agent01.puppet (192.168.1.11): icmp_seq=1 ttl=64 time=1.81 ms 64 bytes from agent01.puppet (192.168.1.11): icmp_seq=2 ttl=64 time=0.213 ms 64 bytes from agent01.puppet (192.168.1.11): icmp_seq=3 ttl=64 time=0.245 ms 64 bytes from agent01.puppet (192.168.1.11): icmp_seq=4 ttl=64 time=0.196 ms --- agent01.puppet ping statistics --- 4 packets transmitted, 4 received, 0% packet loss, time 3060ms rtt min/avg/max/mdev = 0.196/0.616/1.813/0.691 ms [root@master etc]# ping agent02.puppet PING agent02.puppet (192.168.1.12) 56(84) bytes of data. 64 bytes from agent02.puppet (192.168.1.12): icmp_seq=1 ttl=64 time=1.97 ms 64 bytes from agent02.puppet (192.168.1.12): icmp_seq=2 ttl=64 time=0.313 ms 64 bytes from agent02.puppet (192.168.1.12): icmp_seq=3 ttl=64 time=0.302 ms
暂时前期工作。
本文出自 “always_yunwei” 博客,请务必保留此出处http://alwaysyunwei.blog.51cto.com/3224143/1406913
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。