Linux自动化安装cobbler
1介绍
1.1 PXE
PXE技术与RPL技术不同之处为RPL是静态路由,PXE是动态路由。RPL是根据网卡上的ID号加上其他记录组成的一个Frame(帧)向服务器发出请求。而服务器中已有这个ID数据,匹配成功则进行远程启动。PXE则是根据服务器端收到的工件站MAC地址,使用DHCP服务为这个MAC地址指定个IP地址。每次启动可能同一台工作站有与上次启动有不同的IP,即动态分配地址。下以客户端引导过程说明PXE的原理:
客户端开机后,PXE BootROM(自启动芯片)获得控制权之前执行自我测试,然后以广播形式发出一个请求FIND帧。如果服务器收到客户端所送出的要求,就会送回DHCP回应,包括用户端的IP地址、预设通信通道,以及开机映像文件;否则服务器会忽略这个要求。
客户端收到服务器发回的响应后则会回应一个帧,以请求传送启动所需文件,并把自己的MAC地址写到服务器端的Netnames.db文件中。将有更多的消息在客户端与服务器之间应答,用于决定启动参数。
BootROM由TFTP通信协议从服务器下载开机映像文档。
客户端使用TFTP协议接收启动文件后,将控制权转交启动块以引导操作系统,完成远程启动。
1.2 KickStart
KickStart是一种无人职守安装方式。KickStart的工作原理是通过记录典型的安装过程中所需人工干预填写的各种参数,并生成一个名为ks.cfg的文件;在其后的安装过程中(不只局限于生成KickStart安装文件的机器)当出现要求填写参数的情况时,安装程序会首先去查找KickStart生成的文件,当找到合适的参数时,就采用找到的参数,当没有找到合适的参数时,才需要安装者手工干预。这样,如果KickStart文件涵盖了安装过程中出现的所有需要填写的参数时,安装者完全可以只告诉安装程序从何处取ks.cfg文件,然后去忙自己的事情。等安装完毕,安装程序会根据ks.cfg中设置的重启选项来重启系统,并结束安装。

1.3 Cobbler
Cobbler是一个快速网络安装linux的服务,而且在经过调整也可以支持网络安装windows。该工具使用python开发,小巧轻便(才15k行python代码),使用简单的命令即可完成PXE网络安装环境的配置,同时还可以管理DHCP、DNS、以及yum仓库、构造系统ISO镜像。
Cobbler支持命令行管理,web界面管理,还提供了API接口,可以方便二次开发使用。
Cobbler客户端Koan支持虚拟机安装和操作系统重新安装,使重装系统更便捷。
Cobbler提供以下服务集成:
* PXE服务支持
* DHCP服务管理
* DNS服务管理
* 电源管理
* Kickstart服务支持
* yum仓库管理
2 安装部署
2.1相关文件
1.Cobbler配置文件目录:/etc/cobbler
/etc/cobbler/settings #cobbler主配置文件
/etc/cobbler/dhcp.template #DHCP服务的配置模板
/etc/cobbler/tftpd.template #tftp服务的配置模板
/etc/cobbler/rsync.template #rsync服务的配置模板
/etc/cobbler/iso #iso模板配置文件
/etc/cobbler/pxe #pxe模板文件
/etc/cobbler/power #电源的配置文件
/etc/cobbler/users.conf #Web服务授权配置文件
/etc/cobbler/users.digest #用于web访问的用户名密码配置文件
/etc/cobbler/dnsmasq.template #DNS服务的配置模板
/etc/cobbler/modules.conf #Cobbler模块配置文件
2.Cobbler数据目录:/var/lib/cobbler
/var/lib/cobbler/config #配置文件
/var/lib/cobbler/triggers #Cobbler命令
/var/lib/cobbler/kickstarts #默认存放kickstart文件
/var/lib/cobbler/loaders #存放的各种引导程序
3.系统安装镜像目录:/var/www/cobbler
/var/www/cobbler/ks_mirror #导入的系统镜像列表
/var/www/cobbler/images #导入的系统镜像启动文件
/var/www/cobbler/repo_mirror #yum源存储目录
4.日志目录:/var/log/cobbler
/var/log/cobbler/install.log #客户端系统安装日志
/var/log/cobbler/cobbler.log #cobbler日志
2.2 Cobbler安装
2.2.1安装EPEL源
yum install epel-release
2.2.2安装cobbler
yum install cobbler httpd rsync tftp-server xinetd dhcp python-ctypes cman pykickstart –y
2.2.3配置cobbler
vim /etc/cobbler/settings #Cobbler主配置文件
sed -i 's/manage_dhcp: 0/manage_dhcp: 1/g' /etc/cobbler/settings
sed -i 's/manage_rsync: 0/manage_rsync: 1/g' /etc/cobbler/settings
# set to 1 to enable Cobbler's DHCP management features.
# the choice of DHCP management engine is in /etc/cobbler/modules.conf
manage_dhcp: 1
# set to 1 to enable Cobbler's RSYNC management features.
manage_rsync: 1
# if using cobbler with manage_dhcp, put the IP address
# of the cobbler server here so that PXE booting guests can find it
# if you do not set this correctly, this will be manifested in TFTP open timeouts.
next_server: 192.168.56.6
# this is the address of the cobbler server -- as it is used
# by systems during the install process, it must be the address
# or hostname of the system as those systems can see the server.
# if you have a server that appears differently to different subnets
# (dual homed, etc), you need to read the --server-override section
# of the manpage for how that works.
server: 192.168.56.6
2.2.4关闭SELinux、iptables
getsebool
service iptables stop
chkconfig iptables off
2.2.5配置tftp、rsync
设置 'disable' 为 'no'
sed -i '/disable/c\\tdisable\t\t\t= no' /etc/xinetd.d/tftp
sed -i 's/\=\ yes/\=\ no/g' /etc/xinetd.d/rsync
2.2.6启用wsgi模块
sed -i 's@#LoadModule@LoadModule@g' /etc/httpd/conf.d/wsgi.conf
2.2.7生成密码
这里生成密钥和配置默认密钥,ks文件引用
openssl passwd -1 -salt 'random-phrase-here' 'wq'
$1$random-p$29HCOY0msGT.4xVuIl6Gp.
加入cobbler配置
vim /etc/cobbler/settings
grep default_password_crypted /etc/cobbler/settings#修改为如下配置
default_password_crypted: "$1$random-p$29HCOY0msGT.4xVuIl6Gp."
2.2.8配置DHCP
vim /etc/cobbler/dhcp.template
allow booting;
allow bootp;
ddns-update-style interim;
ignore client-updates;
subnet 192.168.56.0 netmask 255.255.255.0 {
range dynamic-bootp 192.168.56.100 192.168.56.254;
option domain-name-servers 192.168.0.1;
option routers 192.168.56.1;
option subnet-mask 255.255.255.0;
default-lease-time 1800;
max-lease-time 3600;
next-server 192.168.56.6;
filename "pxelinux.0";
}
2.2.9配置服务
/sbin/service httpd start
/sbin/service dhcpd start
/sbin/service xinetd start
/sbin/service cobblerd start
/sbin/chkconfig httpd on
/sbin/chkconfig dhcpd on
/sbin/chkconfig xinetd on
/sbin/chkconfig tftp on
/sbin/chkconfig cobblerd on
2.2.10引导系统文件
cobbler get-loaders
2.2.11配置debmiror(可选)
yum -y install debmirror
修改 /etc/debmirror.conf 配置文件,注释掉 @dists 和 @arches 两行
sed -i 's|@dists=.*|#@dists=|' /etc/debmirror.conf
sed -i 's|@arches=.*|#@arches=|' /etc/debmirror.conf
2.2.12检查配置
cobbler check
The following are potential configuration items that you may want to fix:无需处理
1 : reposync is not installed, need for cobbler reposync, install/upgrade yum-utils?
2 : debmirror package is not installed, it will be required to manage debian deployments and repositories
Restart cobblerd and then run 'cobbler sync' to apply changes.
2.2.13同步配置
cobbler sync
2.3 Cobbler管理
2.3.1命令说明

命令参考
cobbler --help
cobbler distro --help
cobbler distro add --help
2.3.2配置文件说明
Cobbler配置文件存放在/etc/cobbler下

2.3.3镜像数据目录
导入的系统发行版,repos镜像和kickstart文件都放置在/var/www/cobbler
目录下。确保/var目录有足够的空间来存储这些文件。

2.3.4数据目录
此目录存储和Cobbler profiles、systems、distros相关的配置。

2.3.5日志文件
web日志存放点:
/var/log/httpd/access_log
/var/log/httpd/error_log
/var/log/httpd/ssl_access_log
/var/log/httpd/ssl_error_log
Cobbler日志:
/var/log/cobbler/cobbler.log
/var/log/cobbler/install.log
通过Cobbler日志可以获取系统的安装状态
2.3.6导入镜像
1. 注意下载的ISO文件要核对文件的md5值,确保数据完整性
md5sum xx.iso
2.创建目录
mkdir -p /var/os/Linux/Centos/x86_64/Centos6.7/dvd
3.挂载
mount -o loop/var/iso/Linux/Centos/x86_64/xx.iso
/var/os/Linux/Centos/x86_64/Centos6.7/dvd
2.3.7导入数据
cobbler import --path=/xx --name=centos6.7 --arch=x86_64
cobbler list 列出配置
cobbler report 详细
cobbler profile find --distro=centos6.7-x86_64 #查看配置是否存在
cobbler profile remove --name=centos6.7-x86_64 #删除配置文件
cobbler distro remove --name=centos6.7-x86_64 #删除distro
cobbler profile find --distro=centos6.7-x86_64 #再查看配置已无
2.3.8自定义ks
ks目录位置
/var/lib/cobbler/kickstarts/
默认的ks位置
/var/lib/cobbler/kickstarts/sample.ks
更改指定系统版本对应的ks配置文件
cp /var/lib/cobbler/kickstarts/ sample.ks centos6.7-x86_64.ks
cobbler profile add --name=centos6.7 --distro= centos6.7-x86_64 --kickstart=/var/lib/cobbler/kickstarts/centos6.7-x86_64.ks
cobbler check
cobbler sync
KS示例:
#platform=x86, AMD64, or Intel EM64T
# Firewall configuration
firewall --disabled
# Install OS instead of upgrade
install
# Use network installation
url --url=$tree
#Root password
rootpw root
# System authorization information
auth --useshadow--enablemd5
# Use graphical mode install
graphical
# Run the Setup Agent on first boot
firstboot --disable
# System keyboard
keyboard us
# System language
lang en_US
# SELinux configuration
selinux --disabled
# Installation logging level
logging --level=info
# System timezone
timezone Asia/Shanghai
# Network information
network --bootproto=static --device=eth0 --gateway=192.168.56.1 --ip=192.168.56.99 --nameserver=192.168.56.99 --netmask=255.255.255.0 --hostname=host99 --onboot=on
# System bootloader configuration
bootloader --location=mbr
# Partition clearing information
clearpart --all --initlabel
# Disk partitioning information
part / --fstype="ext4" --ondisk=sda --size=8000
part /boot --fstype="ext4" --ondisk=sda --size=200
part swap --fstype="swap" --size=1000
# Reboot after installation
reboot
# Clear the Master Boot Record
zerombr
%packages
@ X Window System
@ Desktop
@ Development tools
gcc*
%end

3 Web管理
Cobbler web界面是一个很好的前端,非常容易管理Cobbler。可以添加和删除system、distro、profile,可以查看、编辑distros、profiles、subprofiles、systems、repos、kickstart文件。
3.1cobbler web管理
3.1.1安装
yum -y install cobbler-web
3.1.2设置用户密码
为已存在的用户cobbler重置密码:
htdigest /etc/cobbler/users.digest "Cobbler" cobbler
添加新用户:
htdigest /etc/cobbler/users.digest "Cobbler" newname
3.1.3配置登录
sed -i 's/authn_denyall/authn_configfile/g'
/etc/cobbler/modules.conf
/etc/init.d/cobblerd restart
/etc/init.d/httpd restart
3.1.4访问web
浏览器访问登录页面https://192.168.xx.xx/cobbler_web

3.1.5登录web
3.1.6管理web
cobbler system add --name=xx --hostname=xx --mac=xx
--interface=ethx --ip-address=xx --subnet=xx --gateway=xx
--static=1 --profile=xx
yum install cman ipmitool -y 电源管理(需要硬件支持)



Linux自动化安装cobbler的更多相关文章
- Linux自动化之Cobbler补鞋匠安装
cobbler介绍: 快速网络安装linux操作系统的服务,支持众多的Linux发行版:Red Hat. Fedora.CentOS.Debian.Ubuntu和SuSE,也可以支持网络安装w ...
- linux 自动化安装系统 -KS文件
# Kickstart file automatically generated by anaconda. installharddrive --partition=sdb2 --dir=lang e ...
- Cobbler自动化安装
# Cobbler自动化安装 [Cobbler官网](http://cobbler.github.io) :Linux下安装jenkins
jenkins是一个Java开发的开源持续集成工具,广泛用于项目开发,具有自动化构建.测试和部署等功能,它的运行需要Java环境. 上篇博客介绍了Linux下安装JDK的步骤,这篇博客,介绍下Linu ...
- cobbler实现系统自动化安装centos
cobbler [epel] cobbler服务集成 PXE DHCP rsync Http DNS Kickstart IPMI[电源管理] 1.软件安装 yum install cobbler d ...
随机推荐
- svn 批量更新 bat脚本
由于有多个程序放在svn上管理,每天都要进入相应的目录进行svn 更新操作,现在写了一个简单的脚本进行批量自动更新. Code@echo off @echo ********************* ...
- Codeforces Round #364 (Div. 2) Cells Not Under Attack
Cells Not Under Attack 题意: 给出n*n的地图,有给你m个坐标,是棋子,一个棋子可以把一行一列都攻击到,在根据下面的图,就可以看出让你求阴影(即没有被攻击)的方块个数 题解: ...
- CF 500D New Year Santa Network tree 期望 好题
New Year is coming in Tree World! In this world, as the name implies, there are n cities connected b ...
- iis7设置404页面不生效的原因
打开web.config <httpErrors errorMode="Custom" existingResponse="PassThrough"> ...
- c#程序中使用"like“查询access数据库语句的问题
在写使用access数据库的c#程序过程中,遇到各种莫名奇妙的问题.例如使用"like"进行模糊查询,在access查询视图中要使用"*"做模糊匹配(sql中是 ...
- Spring切入点表达式常用写法
自从使用AspectJ风格切面配置,使得Spring的切面配置大大简化,但是AspectJ是另外一个开源项目,其规则表达式的语法也稍稍有些怪异. 下面给出一些常见示例的写法: 比如,下面是一个 ...
- 【在线】Actionbar Style Generator:ActionBar风格生成器
这个ActionBar风格生成器可以让你轻松地创建一个简洁.有吸引力且无漏洞的自定义actionbar.它会生成所有9种必须的patch assets以及相关XML的drawables和styles文 ...
- .NET 请求被挂起,前端轮询,委托
起因:因项目需要监控方法中计算进度,故而想通过AJAX调用,返回前端显示进度,结果开发中遇到第二个AJAX请求被挂起,需要等到第一个请求(计算)完成后,才会被处理到. 百度种种,知其原因是在Sessi ...
- C++学习13 类class和结构体struct的区别
C++保留了C语言的 struct,并且加以扩充.在C语言中,struct 只能包含数据成员,不能包含成员函数.而在C++中,struct 类似于 class,既可以包含数据成员,又可以包含成员函数. ...
- CRM plugin 激活 停用 事件
需要注册 SetState 和 SetStateDynamecEntity