一 主机要求
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
输入账户名密码,就可以操作了。图形的话,小编觉得没什么技术含量,英看的懂就行。里面有详细的提示。所以就不详细介绍了。