Linux项目之Cobbler实现

一 主机要求

1.局域网
2.server机必须联网,或者配置server的时候联网,之后在断掉外网也行
3.epel源(可以本地搭建利用http或者ftp就可以实现)

二 环境要求

yum -y install dhcpd
# cobbler自身就已经集成了DHCP服务,我们是借用DHCP服务来实现的
yum install dhcpd{cobbler,tftp,http}
systemctl enable dhcpd{cobbler,tftp,http}
systemctl start dhcpd{cobbler,tftp,httpd}
setenforce 0
iptables -F 
# 或者自己添加rich rule、iptables规则都行,但是一定要打开端口

三 正式开始实现

[root@VinnyWang ~]# cobbler check
The following are potential configuration items that you may want to fix:
1 : The 'server' field in /etc/cobbler/settings must be set to something other than localhost, or kickstarting features will not work.  This should be a resolvable hostname or IP for the boot server as reachable by all machines that will use it.
2 : 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 should match the IP of the boot server on the PXE network.
3 : SELinux is enabled. Please review the following wiki page for details on ensuring cobbler works correctly in your SELinux environment:
    https://github.com/cobbler/cobbler/wiki/Selinux
4 : change 'disable' to 'no' in /etc/xinetd.d/tftp
5 : 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 you have installed a *recent* version of the syslinux package installed and can ignore this message entirely.  Files in this directory, should you want to support all architectures, should include pxelinux.0, menu.c32, elilo.efi, and yaboot. The 'cobbler get-loaders' command is the easiest way to resolve these requirements.
6 : enable and start rsyncd.service with systemctl
7 : debmirror package is not installed, it will be required to manage debian deployments and repositories
8 : The default password used by the sample templates for newly installed machines (default_password_crypted in /etc/cobbler/settings) is still set 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.

看到这里不要害怕,我们只不过是检查下,看看哪里出了错误,我们一下检查出了9条错误,这都是我们需要一一解决的。下面我们逐一解决:

对文件的修改

The 'server' field in /etc/cobbler/settings must be set to something other than localhost, or kickstarting features will not work.  This should be a resolvable hostname or IP for the boot server as reachable by all machines that will use it.

我们通过这段代码知道我们没有更改cobbler的主配置文件,导致了server无法启动,里面还指出我们需要加IP地址boot-server我们就去找到,并修改就可以了。

[root@VinnyWang ~]# cp /etc/cobbler/settings /etc/cobbler/settings.bak
(建议备份此文件,万一自己修改错了就GG,当然你也可以从别的地方在复制过来一份)
[root@VinnyWang ~]# vim  /etc/cobbler/settings

寻找到这个地方修改next_server

# 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.40.100
这个是修改DHCP服务期server的,IP地址必须指向提供DHCP的server

寻找到这个地方修改manage_dhcp

# 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
这个是队上一步骤的补充,cobbler接管本机的DHCP服务,1就是打开,默认为0

寻找到这个地方修改server

# 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.40.100
这个地方指明的是cobbler的服务器,假如有专门的cobbler服务器的那就指向他

寻找到这个地方修改default_password_crypted

# cobbler has various sample kickstart templates stored
# in /var/lib/cobbler/kickstarts/.  This controls
# what install (root) password is set up for those
# systems that reference this variable.  The factory
# default is "cobbler" and cobbler check will warn if
# this is not changed.
# The simplest way to change the password is to run 
# openssl passwd -1
# and put the output between the "" below.
default_password_crypted: "$1$mF86/UHC$WvcIcX2t6crBz2onWxyac."

这个地方是cobbler的密码,默认装机完成之后的密码,默认为cobbler可以自己修改。这里是默认MD5加密的方式,可以自己设置,有很多的加密方式随便哪一种都行,这里只给提供一种方式。

[root@VinnyWang ~]# openssl passwd -1
Password: 
Verifying - Password: 
$1$q2F3i91t$fCzCPstyNyBD0C6SxB676

之后我们保存并退出此文件,里面的东西基本上就修改完毕了
这个地方是修改cobbler接管的DHCP的主配置文件,给上range,routers等等
vim /etc/cobbler/dhcp.template

subnet 192.168.40.100 netmask 255.255.255.0 {
     option subnet-mask         255.255.255.0;
     range dynamic-bootp        192.168.40.1 192.168.40.254;
     default-lease-time         21600;
     max-lease-time             43200;
     next-server                $next_server;

之后保存退出之后

systemctl restart cobblerd
cobbler sync(同步设置到DHCP的原配置文件)
cat /etc/dhcp/dhcpd.conf    # 确认是否需改成功
systemctl restart dhcpd

这个地方需要特别说一下,我们需要安装get-loaders是属于cobbler专门的文件。

cobbler get-loaders(联网情况下才能使用)
cd /var/lib/tftpboot/
cobbler sync

导入源文件并定制kickstart文件

mkdir /media/centos{6,7}
mount /dev/sr0 /media/centos6
mount /dev/sr1 /media/centos7
cobber import --path=/media/centos7 --name=centos7.3
cobber import --path=/media/centos6 --name=centos6.9
[root@VinnyWang tftpboot]# cobbler profile list
   centos6.9-x86_64
   centos7.3-x86_64
system-config-kicks

这里就不多说了,可以点击这个网址直接访问我的另一篇文章,里面有对ks.cfg文件的详细介绍,按照自己的需求定制的,里边有直接的方式:Linux项目之PXE实现不同系统安装
生成kickstart文件之后,请复制到/var/lib/cobbler/kickstarts/这个目录下,这样之后不算完成,还需要导入

cobbler profile list
cobbler profile remove  --name=centos7.3-x86_64
cobbler profile remove  --name=centos6.9-x86_64
# 移除原本的cfg文件,因为原本的是cobbler自带的
cobbler profile add --name=centos7.3-custom --kickstart=/var/lib/cobbler/kickstarts/centos7.cfg --distro=centos7.3-x86_64
cobbler profile add --name=centos6.9-custom --kickstart=/var/lib/cobbler/kickstarts/centos6.cfg --distro=centos6.9-x86_64
# 导入上传的centos{6,7}.cfg文件
cat /var/lib/tftpboot/pxelinux.cfg/default
cobbler sync
systemctl restart cobblerd
systemctl restart dhcpd

这样就大功告成了。
当然这里也提供一个简单的图形界面的调试方法。

yum-y install cobbler-web
# 安装图形工具
htdigest /etc/cobbler/users.digest "Cobbler" cobbler
修改密码或者不用修改账号密码均为`cobbler`
systemctl restart cobblerd
cobbler sync
systemctl restart httpd

登录https://182.168.40.100/cobbler_web 输入账户名密码,就可以操作了。图形的话,小编觉得没什么技术含量,英看的懂就行。里面有详细的提示。所以就不详细介绍了。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 158,736评论 4 362
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 67,167评论 1 291
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 108,442评论 0 243
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 43,902评论 0 204
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 52,302评论 3 287
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 40,573评论 1 216
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 31,847评论 2 312
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 30,562评论 0 197
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 34,260评论 1 241
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 30,531评论 2 245
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 32,021评论 1 258
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 28,367评论 2 253
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 33,016评论 3 235
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 26,068评论 0 8
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 26,827评论 0 194
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 35,610评论 2 274
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 35,514评论 2 269

推荐阅读更多精彩内容