设为首页 收藏本站
查看: 166|回复: 0

[经验分享] pxe 简介以及 cobbler安装配置自动化

[复制链接]
累计签到:2 天
连续签到:1 天
发表于 2016-1-11 08:27:51 | 显示全部楼层 |阅读模式
PXE(CentOS 6.7):准备环境:

pxe简介:
PXE(preboot execute environment,预启动执行环境)是由Intel公司开发的最新技术,工作于Client/Server的网络模式,支持工作站通过网络从远端服务器下载映像,并由此支持通过网络启动操作系统,在启动过程中,终端要求服务器分配IP地址,再用TFTP(trivial file transfer protocol)或MTFTP(multicast trivial file transfer protocol)协议下载一个启动软件包到本机内存中执行,由这个启动软件包完成终端(客户?)基本软件设置,从而引导预先安装在服务器中的终端操作系统。PXE可以引导多种操作系统,如:Windows95/98/2000/windows2003/windows2008/winXP/win7/win8,linux等。

1.dhcp主机安装服务:

1.安装后默认dhcpd.conf没有配置信息,所以之际复制一份模板:
安装dhcp:yum -y install dhcp
cp /usr/share/doc/dhcp-4.1.1/dhcpd.conf.sample /etc/dhcp/dhcpd.conf

首先修改配置文件:

wKiom1aSlMvAtjuNAABMUpSLJVg060.jpg

range ip:地址池配置范围
option routers:路由网关
next-server:告诉dhcp,tftp服务器地址
filename:请求获取的文件


2.准备镜像资源,本机直接挂载光盘资源。
mount -r /dev/cdrom /mnt
wKiom1aSlMzQ-FffAABca9An2B8086.jpg
在images和isolinux目录里面复制以下文件:

复制:
1
2
[iyunv@localhost pxeboot]# cp vmlinuz initrd.img /var/lib/tftpboot/
[iyunv@localhost isolinux]# cp isolinux.cfg vesamenu.c32 splash.jpg boot.msg /var/lib/tftpboot/




创建文件:
1
2
[iyunv@localhost isolinux]# mkdir /var/lib/tftpboot/pxelinux.cfg
[iyunv@localhost isolinux]# cp isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default



至此基本配置完成。

2.新建虚拟机
wKioL1aSlPqgNjLMAAETCkalMoM353.jpg
网络模式为dhcp主机地址段:ok完成pxe

3.创建文件树
1
[iyunv@localhost ~]# mkdir /var/www/html/centos6




将光盘文件卸载,并挂载到
1
[iyunv@localhost ~]# mount -r /dev/cdrom /var/www/html/centos6/





wKioL1aSlPuhprCEAABkBwQG5wg176.jpg

wKiom1aSlM7DfMjnAABv51jmKbQ052.jpg
地址填写为:http://10.0.10.1/centos6  也就是管盘文件挂载的地方
至此已经完成。可以安装了。

wKiom1aSlM6SRvsCAABvA-yCIVQ491.jpg


2.cobbler

1.Cobbler 概述
Cobbler由python语言开发,是对PXE和Kickstart以及DHCP的封装。融合很多特性,提供了CLI和Web的管理形式。更加方便的实行网络安装。同时,Cobbler也提供了API接口,使用其它语言也很容易做扩展。它不紧可以安装物理机,同时也支持kvm、xen虚拟化、Guest OS的安装。更多的是它还能结合Puppet等集中化管理软件,实现自动化的管理。

QQ截图20160111082738.jpg
下面我们来简单的说明一下,
Server端:
  • 第一步,启动Cobbler服务
  • 第二步,进行Cobbler错误检查,执行cobbler check命令
  • 第三步,进行配置同步,执行cobbler sync命令
  • 第四步,复制相关启动文件文件到TFTP目录中
  • 第五步,启动DHCP服务,提供地址分配
  • 第六步,DHCP服务分配IP地址
  • 第七步,TFTP传输启动文件
  • 第八步,Server端接收安装信息
  • 第九步,Server端发送ISO镜像与Kickstart文件

Client端:
  • 第一步,客户端以PXE模式启动
  • 第二步,客户端获取IP地址
  • 第三步,通过TFTP服务器获取启动文件
  • 第四步,进入Cobbler安装选择界面
  • 第五步,客户端确定加载信息
  • 第六步,根据配置信息准备安装系统
  • 第七步,加载Kickstart文件
  • 第八步,传输系统安装的其它文件
  • 第九步,进行安装系统



支持多安装树的pxe。
            PXE:yum repository, (vmlinuz+initrd.img) Distribution
                  单个系统安装:
                        特定系统:(pxeboot) vmlinuz, initrd.img
                        特定系统安装源:yum repository

三个核心组件:
      1.repository:
               mirror
               import
       2.    distribution
       3.   profile

1.安装cobbler
需要安装epel源:wget http://mirrors.aliyun.com/epel/6 ... ease-6-8.noarch.rpm

yum安装软件:
1
2
[iyunv@localhost ~]# yum install cobblercobbler-web pykickstart debmirror httpdsyslinux
[iyunv@localhost ~]# yum install dhcptftp-server




启动cobbler,httpd,tftp,dhcp等程序。

tftp,httpd,dhcp,还包括DNS这些服务都可以由cobbler代为管理,也可以独立管理。这里都将这些服务设置为单独管理。



配置cobbler
1
2
3
4
5
6
7
8
9
[iyunv@localhost tftpboot]# vim/etc/cobbler/settings

#this is the address of the cobbler server -- as it is used
# bysystems during the install process, it must be the address
# orhostname of the system as those systems can see the server.
# ifyou have a server that appears differently to different subnets
#(dual homed, etc), you need to read the --server-override section
# ofthe manpage for how that works.
server:10.0.10.1





启动cobbler服务,运行cobbler check:
1
servicecobbler start




运行check后出现如下一堆问题,下面逐个解决:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
[iyunv@localhost tftpboot]# cobbler check
The following are potential configuration items that you maywant to fix:

1 : For PXE to be functional, the 'next_server' field in/etc/cobbler/settings must be set to something other than 127.0.0.1, and shouldmatch the IP of the boot server on the PXE network.
2 : SELinux is enabled. Please review the following wiki pagefor details on ensuring cobbler works correctly in your SELinux environment:
    https://github.com/cobbler/cobbler/wiki/Selinux
3 : some network boot-loaders are missing from/var/lib/cobbler/loaders, you may run 'cobbler get-loaders' to download them,or, if you only want to handle x86/x86_64 netbooting, you may ensure that youhave installed a *recent* version of the syslinux package installed and canignore this message entirely.  Files in this directory, should you want tosupport all architectures, should include pxelinux.0, menu.c32, elilo.efi, andyaboot. The 'cobbler get-loaders' command is the easiest way to resolve theserequirements.
4 : change 'disable' to 'no' in /etc/xinetd.d/rsync
5 : reposync is not installed, need for cobbler reposync,install/upgrade yum-utils?
6 : comment out 'dists' on /etc/debmirror.conf for properdebian support
7 : comment out 'arches' on /etc/debmirror.conf for properdebian support
8 : The default password used by the sample templates for newlyinstalled machines (default_password_crypted in /etc/cobbler/settings) is stillset to 'cobbler' and should be changed, try: "openssl passwd -1 -salt'random-phrase-here' 'your-password-here'" to generate new one
9 : fencing tools were not found, and are required to use the(optional) power management features. install cman or fence-agents to use them

Restart cobblerd and then run 'cobbler sync' to apply changes.





1)修改next server
1
2
3
4
# ifusing cobbler with manage_dhcp, put the IP address
# ofthe cobbler server here so that PXE booting guests can find it
# ifyou do not set this correctly, this will be manifested in TFTP open timeouts.
next_server:10.0.10.1




2)若仅为x86/x86_64架构的服务器提供服务,安装syslinux即可
1
#yum install syslinux




3)修改rsync的选项为启用:
1
[iyunv@localhost tftpboot]# chkconfig rsync on





5)安装ksvalidator
1
# yum install -y pykickstart





6,7)注释掉一下两行/etc/debmirror.conf
1
2
#@dists="sid";
#@arches="i386";




8)添加修改一个新的密码:
1
2
3
4
5
6
7
[iyunv@localhost ~]# vim /etc/cobbler/settings
[iyunv@localhost tftpboot]# openssl passwd -1 -salt 'opensslrand -hex 4'
Password:
$1$openssl $yjM9zoJu5exGoBYrfY.9C.
[iyunv@localhost tftpboot]#

default_password_crypted: "$1$openssl$yjM9zoJu5exGoBYrfY.9C."




配置完成后
1
2
cobbler sync
service cobbler restart




检查目录已经生成:
1
2
3
4
[iyunv@localhost tftpboot]# cd /var/lib/tftpboot/
[iyunv@localhost tftpboot]# ls
boot  etc  grub  images  memdisk menu.c32  ppc  pxelinux.0  pxelinux.cfg  s390x
[iyunv@localhost tftpboot]#




挂载光盘:
1
2
[iyunv@localhost ~]# umount /dev/cdrom
[iyunv@localhost ~]# mount /dev/cdrom /media/ -r




cobbler import 加载光盘自动生成distro,时间比较长
1
[iyunv@localhost ~]# cobbler import --path=/media/--name=centos6.7-x86_64




查看已经生成:
1
2
3
[iyunv@localhost ~]# cd /var/www/cobbler
[iyunv@localhost cobbler]# ls
aux  images  ks_mirror  links  localmirror pub  rendered  repo_mirror  svc





制作ks.cfg文件
首先安装system-config-kickstart。
1
yum install system-config-kickstart




执行system-config-kickstart启用图形界面进行配置
1
system-config-kickstart



wKioL1aSlq7RhG0xAAEmgUcogGA928.jpg

将制作好的文件保存在本机上

将文件导入到以下地方并且添加profile:
1
2
3
4
[iyunv@localhost ~]# cp ks.cfg /var/lib/cobbler/kickstarts/
cp: overwrite `/var/lib/cobbler/kickstarts/ks.cfg'? y
[iyunv@localhost ~]# cobbler distro list
   centos6.7-x86_64




即为某个distro提供kickstart文件来生成一个特定的系统安装配置。
1
2
[iyunv@localhost ~]# cobbler profile add--name="centos6.-x86_64-web" --distro=centos6.7-x86_64--kickstart=/var/lib/cobbler/kickstarts/ks.cfg
[iyunv@localhost ~]#




查看一下:
1
2
3
4
5
6
[iyunv@localhost ~]# cobbler profile list
   centos6.6-x86_64-web
   centos6.7-x86_64
[iyunv@localhost ~]#

[iyunv@localhost ~]# cobbler sync   ####注意每一次修改配置都要执行一下sync



wKiom1aSltKxXVxVAAAezHKn0zM133.jpg
测试完成,已经可以自动化安装了。

3.cobbler web界面
wKioL1aSlymTUgO0AAB-Z4-7_1w126.jpg
cobbler_web支持多种认证方式,如authn_configfile、authn_ldap或authn_pam等,这里使用authn_pam模块实现认证。
1
2
3
4

[iyunv@node1 ~]# vim/etc/cobbler/modules.conf
[authentication]
module = authn_pam




添加系统用户:
1
2
3
4
[iyunv@node1 ~]# useradd baby
[iyunv@node1 ~]# echo"baby" | passwd --stdin baby
Changing password for user baby.
passwd: all authentication tokensupdated successfully.




添加该系统用户至/etc/cobbler/users.conf文件

1
2
3
[iyunv@node1 ~]# vim/etc/cobbler/users.conf
[admins]
admin = "baby"




配置完成重启cobbler服务:

1
2
3
[iyunv@node1 ~]# service cobblerdrestart
Stopping cobblerdaemon:                                  [  OK  ]
Starting cobblerdaemon:                                  [  OK  ]




如果用默认验证方式:
需要[iyunv@localhost cobbler]#  htdigest/etc/cobbler/users.digest "Cobbler" cobbler
1
2
3
Adding user cobbler in realm cobbler
New password:
Re-type new password:



[iyunv@localhost kickstarts]# 创建digest文件:

查看已经文件已经生成:users.digest

wKioL1aSl6_AMTc4AABjSD-Pj9w380.jpg
1
2
3
[iyunv@localhost cobbler]# cobbler sync
[iyunv@localhost cobbler]# service httpd restart
[iyunv@localhost cobbler]# service cobblerd restart




测试已经可以登录了:

创建一个:
wKiom1aSl6ySKOFCAAHPG84ISa0853.jpg


执行cobbler sync:发现已经成功:
wKioL1aSl__ywnQXAAAlukuXY1M354.jpg

注意:
                  (1)dhcp服务定义filename
                        filename"pxelinux.0"

                  (2)/etc/cobbler/settings
                        manage_dhcp:0
                        manage_tftpd:0

                  (3)使用cobbler import可直接导致光盘中安装树,会自动生成相应的distro及profile
                        生成的profile会使用默认的ks文件/var/lib/cobbler/kickstarts/default.ks文件

                  (4)可自定义kicsktart文件,而后新建profile

                  (5)cobbler_web 2.6中使用htdigest的认证方式,添加用户
                        htdigest/etc/cobbler/users.digest "Cobbler" cobbler



运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.iyunv.com/thread-162766-1-1.html 上篇帖子: redhat5.9安装filezilla3.7报错 下篇帖子: find查找后 xargs 复制文件
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表