为了实验的顺利进行,在所有操作之前我已经把防火墙和selinux禁用
[root@CentOS7 ksfile]# systemctl status firewalld.service
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
Active: inactive (dead) since Sun 2018-05-27 20:01:00 CST; 47min ago
Docs: man:firewalld(1)
Process: 664 ExecStart=/usr/sbin/firewalld --nofork --nopid $FIREWALLD_ARGS (code=exited, status=0/SUCCESS)
Main PID: 664 (code=exited, status=0/SUCCESS)
May 27 19:52:08 CentOS7.miriam systemd[1]: Starting firewalld - dynamic firewall daemon...
May 27 19:52:08 CentOS7.miriam systemd[1]: Started firewalld - dynamic firewall daemon.
May 27 19:52:08 CentOS7.miriam firewalld[664]: WARNING: ICMP type 'beyond-scope' is not supported by the kernel for ipv6.
May 27 19:52:08 CentOS7.miriam firewalld[664]: WARNING: beyond-scope: INVALID_ICMPTYPE: No supported ICMP type., ignoring for run-time.
May 27 19:52:08 CentOS7.miriam firewalld[664]: WARNING: ICMP type 'failed-policy' is not supported by the kernel for ipv6.
May 27 19:52:08 CentOS7.miriam firewalld[664]: WARNING: failed-policy: INVALID_ICMPTYPE: No supported ICMP type., ignoring for run-time.
May 27 19:52:08 CentOS7.miriam firewalld[664]: WARNING: ICMP type 'reject-route' is not supported by the kernel for ipv6.
May 27 19:52:08 CentOS7.miriam firewalld[664]: WARNING: reject-route: INVALID_ICMPTYPE: No supported ICMP type., ignoring for run-time.
May 27 20:01:00 CentOS7.miriam systemd[1]: Stopping firewalld - dynamic firewall daemon...
May 27 20:01:00 CentOS7.miriam systemd[1]: Stopped firewalld - dynamic firewall daemon.
[root@CentOS7 ksfile]# getenforce
Disabled
系统安装工作过程
1)读取MBR:当本地磁盘中没有操作系统,那么当计算机启动时,默认会按照光盘->本地磁盘->NFS->URL的顺序寻找启动盘的MBR,对应启动盘中的 isolinux/boot.cat;
2)读取光盘启动程序 isolinux/isolinux.bin,此阶段类似于操作系统启动中的 grub 的第二阶段;
3)读取配置文件:isolinux/isolinux.cfg,其中包括了要加载的内核。和向内核传递的单数;
4)启动 anaconda 安装向导。
[root@CentOS6 isolinux]# cat isolinux.cfg
default vesamenu.c32 #启动界面样式
#prompt 1
timeout 600 #超时时间,超时后进入默认启动项
#以下都是光盘启动界面参数
display boot.msg
menu background splash.jpg
menu title Welcome to CentOS 6.9!
menu color border 0 #ffffffff #00000000
menu color sel 7 #ffffffff #ff000000
menu color title 0 #ffffffff #00000000
menu color tabmsg 0 #ffffffff #00000000
menu color unsel 0 #ffffffff #00000000
menu color hotsel 0 #ff000000 #ffffffff
menu color hotkey 7 #ffffffff #ff000000
menu color scrollbar 0 #ffffffff #00000000
#以下是光盘启动菜单选项及参数
label linux #菜单的标签
menu label ^Install or upgrade an existing system #菜单的内容
menu default #声明为默认选项
kernel vmlinuz #指定内核文件路径
append initrd=initrd.img #声明内核启动参数
label vesa
menu label Install system with ^basic video driver
kernel vmlinuz
append initrd=initrd.img nomodeset
label rescue
menu label ^Rescue installed system
kernel vmlinuz
append initrd=initrd.img rescue
label local
menu label Boot from ^local drive
localboot 0xffff
label memtest86
menu label ^Memory test
kernel memtest
append -
使用kickstart文件实现单机自动化安装
[root@CentOS6 ~]# cat anaconda-ks.cfg
# Kickstart file automatically generated by anaconda.
#version=DEVEL
install
cdrom #指定启动方式
lang en_US.UTF-8 #语言,文字格式
keyboard us #键盘选项
network --onboot no --device eth0 --bootproto dhcp --noipv6 #网卡设置
rootpw --iscrypted $6$8gvguYGiFoHRO0KJ$obDjRQ0JL... #root口令
firewall --service=ssh #防火墙选项
authconfig --enableshadow --passalgo=sha512 #认证方式选项
selinux --enforcing #selinux选项
timezone Asia/Shanghai #时区设置
bootloader --location=mbr --driveorder=sda --append="crashkernel=auto rhgb quiet" #bootloder安装选项及设置
# The following is the partition information you requested
# Note that any partitions you deleted are not expressed
# here so unless you clear all partitions first, this is
# not guaranteed to work
#clearpart --none #清理分区表,建议再加一条清理MBR“zreombr”
#part /boot --fstype=ext4 --size=1024 #区分信息
#part / --fstype=ext4 --size=51200
#part /data --fstype=ext4 --size=3072
#part swap --size=2048
repo --name="CentOS" --baseurl=cdrom:sr0 --cost=100 #yum源选项,及初始安装的包
%packages
@base
@core
@debugging
@basic-desktop
@desktop-debugging
@desktop-platform
@directory-client
@fonts
@general-desktop
@graphical-admin-tools
@input-methods
@internet-applications
@internet-browser
@java-platform
@legacy-x
@network-file-system-client
@office-suite
@print-client
@remote-desktop-clients
@server-platform
@server-policy
@workstation-policy
@x11
mtools
pax
python-dmidecode
oddjob
wodim
sgpio
genisoimage
device-mapper-persistent-data
abrt-gui
samba-winbind
certmonger
pam_krb5
krb5-workstation
libXmu
%end #后面还可以跟脚本
[root@CentOS6 ~]# cat ks6_mini.cfg
#platform=x86, AMD64, or Intel EM64T
#version=DEVEL
# Firewall configuration
firewall --disabled
# Install OS instead of upgrade
install
# Use network installation
url --url="http://192.168.30.69/centos/6" #通过URL方式安装
# Root password
rootpw --iscrypted $1$YKI6J61k$FhWIpRefQwkBJhBtqu8Y2/
# System authorization information
auth --useshadow --passalgo=sha512
# Use text mode install
text
firstboot --disable
# System keyboard
keyboard us
# System language
lang en_US
# SELinux configuration
selinux --disabled
# Installation logging level
logging --level=info
# Reboot after installation
reboot #安装完成后自动重启
# System timezone
timezone Asia/shanghai
# Network information
network --bootproto=static --device=eth0 --gateway=192.168.30.1 --ip=192.168.30.169 --netmask=255.255.255.0 --onboot=on
# System bootloader configuration
bootloader --location=mbr
# Clear the Master Boot Record
zerombr #清空MBR
# Partition clearing information
clearpart --all --initlabel #清空分区表
# Disk partitioning information
part / --fstype="ext4" --size=51200
part /boot --fstype="ext4" --size=1024
part /data --fstype="ext4" --size=5120
part swap --fstype="swap" --size=2048
%post #安装后脚本
ssh-keygen -f /root/.ssh/id_rsa -P ""
ssh-copy-id 192.168.30.74
%end
%packages
@base
@core
@server-policy
@workstation-policy
%end
担心 kickstart 文件中有错误的话,可以使用 ksvalidator 工具检查 kickstart 文件中的格式错误
[root@CentOS6 cd]# ksvalidator /var/www/html/centos/ksfile/ks6_mini.cfg
File uses a deprecated option or command.
%packages does not end with %end. This syntax has been deprecated. It may be removed from future releases, which will result in a fatal error from kickstart. Please modify your kickstart file to use this updated syntax.
[root@CentOS6 cd]# vim /var/www/html/centos/ksfile/ks6_mini.cfg
[root@CentOS6 cd]# ksvalidator /var/www/html/centos/ksfile/ks6_mini.cfg
[root@CentOS6 cd]#
一、将安装光盘中的文件存放进预先设定的 http 服务器,同时也将 kickstart 文件存放进 http 服务器
[root@CentOS6 html]# tree -L 3
.
└── centos
├── 6
│ ├── CentOS_BuildTag
│ ├── EFI
│ ├── EULA
│ ├── GPL
│ ├── images
│ ├── isolinux
│ ├── Packages
│ ├── RELEASE-NOTES-en-US.html
│ ├── repodata
│ ├── RPM-GPG-KEY-CentOS-6
│ ├── RPM-GPG-KEY-CentOS-Debug-6
│ ├── RPM-GPG-KEY-CentOS-Security-6
│ ├── RPM-GPG-KEY-CentOS-Testing-6
│ └── TRANS.TBL
└── ksfile
└── ks6_mini.cfg
8 directories, 10 files
![](https://i-blog.csdnimg.cn/blog_migrate/e82caf11e2ea6c62ee3367350ff0e837.png)
二、开始使用 kickstart 文件进行自动安装
1)使用光盘启动安装程序,摁 ESC 键进入配置安装界面,设置 ip 地址与 kickstart 文件存放路径
2)回车之后就开始自动安装了
但是在启动安装程序的时候还是需要光盘引导,下面需要做的是实现无盘启动,通过网络来引导安装程序。
创建启动盘文件
将安装光盘中 isolinux 中的文件连同目录一起复制到一个文件夹里,并且再创建一个文件夹用来存放 kickstart 文件
[root@CentOS6 LinuxISO]#⮀tree
.
├── isolinux
│ ├── boot.cat
│ ├── boot.msg
│ ├── grub.conf
│ ├── initrd.img
│ ├── isolinux.bin
│ ├── isolinux.cfg
│ ├── memtest
│ ├── menu.c32 #这里我换用了一个目录样式,无关紧要
│ ├── splash.jpg
│ ├── TRANS.TBL
│ └── vmlinuz
└── ksfile
├── ks6_desktop.cfg
└── ks6_mini.cfg
2 directories, 13 files
修改 isolinux.cfg 文件
[root@CentOS6 LinuxISO]# cat isolinux/isolinux.cfg
default menu.c32 #这里声明使用menu.c32目录样式
#prompt 1
timeout 600
menu title Auto Install CentOS
label desktop
menu label Install ^desktop linux system
kernel vmlinuz
append initrd=initrd.img ks=cdrom:/ksfile/ks6_desktop.cfg
label mini
menu label Install ^mini linux system
kernel vmlinuz
append initrd=initrd.img ks-cdrom:/ksfile/ks6_mini.cfg
label local
menu default
menu label Boot from ^local drive
localboot 0xffffc
创建 centos6 安装启动盘
[root@CentOS6 data]# mkisofs -R -J -T -v --no-emul-boot --boot-load-size 4 --boot-info-table -V "CentOS 6.9 x86_64 boot" -b isolinux/isolinux.bin -c isolinux/boot.cat -o /data/bootcentos6.iso /data/LinuxISO/
I: -input-charset not specified, using utf-8 (detected in locale settings)
genisoimage 1.1.9 (Linux)
Scanning /data/LinuxISO/
Scanning /data/LinuxISO/isolinux
Excluded: /data/LinuxISO/isolinux/TRANS.TBL
Excluded by match: /data/LinuxISO/isolinux/boot.cat
Scanning /data/LinuxISO/ksfile
Writing: Initial Padblock Start Block 0
Done with: Initial Padblock Block(s) 16
Writing: Primary Volume Descriptor Start Block 16
Done with: Primary Volume Descriptor Block(s) 1
Writing: Eltorito Volume Descriptor Start Block 17
Size of boot image is 4 sectors -> No emulation
Done with: Eltorito Volume Descriptor Block(s) 1
Writing: Joliet Volume Descriptor Start Block 18
Done with: Joliet Volume Descriptor Block(s) 1
Writing: End Volume Descriptor Start Block 19
Done with: End Volume Descriptor Block(s) 1
Writing: Version block Start Block 20
Done with: Version block Block(s) 1
Writing: Path table Start Block 21
Done with: Path table Block(s) 4
Writing: Joliet path table Start Block 25
Done with: Joliet path table Block(s) 4
Writing: Directory tree Start Block 29
Done with: Directory tree Block(s) 3
Writing: Joliet directory tree Start Block 32
Done with: Joliet directory tree Block(s) 3
Writing: Directory tree cleanup Start Block 35
Done with: Directory tree cleanup Block(s) 0
Writing: Extension record Start Block 35
Done with: Extension record Block(s) 1
Writing: The File(s) Start Block 36
21.98% done, estimate finish Sat May 26 15:46:19 2018
43.88% done, estimate finish Sat May 26 15:46:19 2018
65.85% done, estimate finish Sat May 26 15:46:19 2018
87.74% done, estimate finish Sat May 26 15:46:19 2018
Total translation table size: 5148
Total rockridge attributes bytes: 1820
Total directory bytes: 4096
Path table size(bytes): 40
Done with: The File(s) Block(s) 22612
Writing: Ending Padblock Start Block 22648
Done with: Ending Padblock Block(s) 150
Max brk space used 1b000
22798 extents written (44 MB)
[root@CentOS6 data]# ll bootcentos6.iso
-rw-r--r-- 1 root root 46690304 May 26 15:46 bootcentos6.iso
创建 iso 文件的命令是 :
mkisofs -R -J -T -v --no-emul-boot --boot-load-size 4 --boot-info-table -V "CentOS 6.9 x86_64 boot" -b isolinux/isolinux.bin -c isolinux/boot.cat -o /data/bootcentos6.iso /data/LinuxISO/
创建出来的 iso 文件可以用于作为光盘启动安装
DHCP服务
DHCP(Dynamic Host Configuration Protocol,动态主机配置协议)是一个局域网的网络协议,使用UDP协议工作。
主要有两个用途:
给内部网络或网络服务供应商自动分配IP地址;给用户或者内部网络管理员作为对所有计算机作中央管理的手段。
DHCP工作原理
1、DHCP Client以广播的方式发出DHCP Discover报文。2、所有的DHCP Server都能够接收到DHCP Client发送的DHCP Discover报文,所有的DHCP Server都会给出响应,向DHCP Client发送一个DHCP Offer报文。
DHCP Offer报文中“Your(Client) IP Address”字段就是DHCP Server能够提供给DHCP Client使用的IP地址,且DHCP Server会将自己的IP地址放在“option”字段中以便DHCP Client区分不同的DHCP Server。DHCP Server在发出此报文后会存在一个已分配IP地址的纪录。
3、DHCP Client只能处理其中的一个DHCP Offer报文,一般的原则是DHCP Client处理最先收到的DHCP Offer报文。
DHCP Client会发出一个广播的DHCP Request报文,在选项字段中会加入选中的DHCP Server的IP地址和需要的IP地址。
4、DHCP Server收到DHCP Request报文后,判断选项字段中的IP地址是否与自己的地址相同。如果不相同,DHCP Server不做任何处理只清除相应IP地址分配记录;如果相同,DHCP Server就会向DHCP Client响应一个DHCP ACK报文,并在选项字段中增加IP地址的使用租期信息。
5、DHCP Client接收到DHCP ACK报文后,检查DHCP Server分配的IP地址是否能够使用。如果可以使用,则DHCP Client成功获得IP地址并根据IP地址使用租期自动启动续延过程;如果DHCP Client发现分配的IP地址已经被使用,则DHCP Client向DHCPServer发出DHCP Decline报文,通知DHCP Server禁用这个IP地址,然后DHCP Client开始新的地址申请过程。
6、DHCP Client在成功获取IP地址后,随时可以通过发送DHCP Release报文释放自己的IP地址,DHCP Server收到DHCP Release报文后,会回收相应的IP地址并重新分配。
在使用租期超过50%时刻处,DHCP Client会以单播形式向DHCP Server发送DHCPRequest报文来续租IP地址。如果DHCP Client成功收到DHCP Server发送的DHCP ACK报文,则按相应时间延长IP地址租期;如果没有收到DHCP Server发送的DHCP ACK报文,则DHCP Client继续使用这个IP地址。在使用租期超过87.5%时刻处,DHCP Client会以广播形式向DHCP Server发送DHCPRequest报文来续租IP地址。如果DHCP Client成功收到DHCP Server发送的DHCP ACK报文,则按相应时间延长IP地址租期;如果没有收到DHCP Server发送的DHCP ACK报文,则DHCP Client继续使用这个IP地址,直到IP地址使用租期到期时,DHCP Client才会向DHCP Server发送DHCP Release报文来释放这个IP地址,并开始新的IP地址申请过程。
需要说明的是:DHCP客户端可以接收到多个DHCP服务器的DHCPOFFER数据包,然后可能接受任何一个DHCPOFFER数据包,但客户端通常只接受收到的第一个DHCPOFFER数据包。另外,DHCP服务器DHCPOFFER中指定的地址不一定为最终分配的地址,通常情况下,DHCP服务器会保留该地址直到客户端发出正式请求。
正式请求DHCP服务器分配地址DHCPREQUEST采用广播包,是为了让其它所有发送DHCPOFFER数据包的DHCP服务器也能够接收到该数据包,然后释放已经OFFER(预分配)给客户端的IP地址。
如果发送给DHCP客户端的地址已经被其他DHCP客户端使用,客户端会向服务器发送DHCPDECLINE信息包拒绝接受已经分配的地址信息。
在协商过程中,如果DHCP客户端发送的REQUEST消息中的地址信息不正确,如客户端已经迁移到新的子网或者租约已经过期,DHCP服务器会发送DHCPNAK消息给DHCP客户 端,让客户端重新发起地址请求过程。
PXE自动化安装系统
安装原理
1、Client向PXE Server上的DHCP发送IP地址请求消息,DHCP检测Client是否合法(主要是检测Client的网卡MAC地址),如果合法则返回Client的IP地址,同时将启动文件pxelinux.0的位置信息一并传送给Client
2、Client向PXE Server上的TFTP发送获取pxelinux.0请求消息,TFTP接收到消息之后再向Client发送pxelinux.0大小信息,试探Client是否满意,当TFTP收到Client发回的同意大小信息之后,正式向Client发送pxelinux.03、Client执行接收到的pxelinux.0文件
4、Client向TFTP Server发送针对本机的配置信息文件(在TFTP 服务的pxelinux.cfg目录下),TFTP将配置文件发回Client,继而Client根据配置文件执行后续操作。
5、Client向TFTP发送Linux内核请求信息,TFTP接收到消息之后将内核文件发送给Client
6、Client向TFTP发送根文件请求信息,TFTP接收到消息之后返回Linux根文件系统
7、Client启动Linux内核
8、Client下载安装源文件,读取自动化安装脚本
安装环境部署
1)安装 tftp 服务器,并开启服务
[root@CentOS6 ksfile]# yum install tftp-server.x86_64
[root@CentOS6 ksfile]# chkconfig tftp on; service xinetd start #centos6上启动tftp服务
[root@CentOS7 ksfile]# systemctl start tftp.socket #centos7上启动tftp服务
2)配置 tftp 文件目录
[root@CentOS7 ksfile]# tree /var/lib/tftpboot/
/var/lib/tftpboot/
├── centos6.9
│ ├── initrd.img #对应系统光盘中isolinux目录下的文件
│ └── vmlinuz
├── centos7.4
│ ├── initrd.img
│ └── vmlinuz
├── menu.c32 #目录样式
├── pxelinux.0 #从/usr/share/syslinux/pxelinux.0复制
└── pxelinux.cfg
└── default #由isolinux。cfg文件修改
3 directories, 7 files
查看 default 文件
[root@CentOS7 ksfile]# cat /var/lib/tftpboot/pxelinux.cfg/default
default menu.c32
#prompt 1
timeout 600
menu title Auto Install CentOS
label desktop
menu label Install desktop centos6.9 system
kernel centos6.9/vmlinuz
append initrd=centos6.9/initrd.img ks=http://192.168.30.74/centos/ksfile/ks6_desktop.cfg
label mini
menu label Install mini centos6.9 system
kernel centos6.9/vmlinuz
append initrd=centos6.9/initrd.img ks=http://192.168.30.74/centos/ksfile/ks6_mini.cfg
label desktop
menu label Install desktop centos7.4 system
kernel centos7.4/vmlinuz
append initrd=centos7.4/initrd.img ks=http://192.168.30.74/centos/ksfile/ks7_desktop.cfg
label mini
menu label Install mini centos7.4 system
kernel centos7.4/vmlinuz
append initrd=centos7.4/initrd.img ks=http://192.168.30.74/centos/ksfile/ks7_mini.cfg
label local
menu default
menu label Boot from ^local drive
localboot 0xffff
3)配置 DHCP 服务
在子网配置里添加next-server 192.168.30.74; filename "pxelinux.0";
subnet 192.168.30.0 netmask 255.255.255.0 {
range 192.168.30.10 192.168.30.100;
option routers 192.168.30.1;
option domain-name-servers 233.5.5.5, 233.6.6.6;
next-server 192.168.30.74; #添加的内容
filename "pxelinux.0"; #这里与/var/lib/tftpboot/下的pxelinux.0对应,可修改文件名
}
4)配置 HTTP 文件
[root@CentOS7 ksfile]# tree -L 3 /var/www/html/
/var/www/html/
└── centos
├── 6 #centos7.4的光盘挂载点
│ ├── CentOS_BuildTag
│ ├── EFI
│ ├── EULA
│ ├── GPL
│ ├── images
│ ├── isolinux
│ ├── LiveOS
│ ├── Packages
│ ├── repodata
│ ├── RPM-GPG-KEY-CentOS-7
│ ├── RPM-GPG-KEY-CentOS-Testing-7
│ └── TRANS.TBL
├── 7 #centos7.4的光盘挂载点
│ ├── CentOS_BuildTag
│ ├── EFI
│ ├── EULA
│ ├── GPL
│ ├── images
│ ├── isolinux
│ ├── Packages
│ ├── RELEASE-NOTES-en-US.html
│ ├── repodata
│ ├── RPM-GPG-KEY-CentOS-6
│ ├── RPM-GPG-KEY-CentOS-Debug-6
│ ├── RPM-GPG-KEY-CentOS-Security-6
│ ├── RPM-GPG-KEY-CentOS-Testing-6
│ └── TRANS.TBL
└── ksfile #kicstart文件
├── ks6_desktop.cfg
├── ks6_mini.cfg
├── ks7_desktop.cfg
└── ks7_mini.cfg
15 directories, 19 files
以上配置好就可以开始自动安装了
cobbler 工具
cobbler 工具是强大的快速网络安装linux操作系统的服务,支持众多的Linux发行版:Red Hat、Fedora、CentOS、Debian、Ubuntu和SuSE,也可以支持网络安装windows,由python开发,所以二次开发潜力巨大。
cobbler 工作流程
1、client裸机配置了从网络启动后,开机后会广播包请求DHCP服务器(cobbler server)发送其分配好的一个IP
2、DHCP服务器(cobbler server)收到请求后发送responese,包括其ip地址
3、client裸机拿到ip后再向cobbler server发送请求OS引导文件的请求4、cobbler server告诉裸机OS引导文件的名字和TFTP server的ip和port
5、client裸机通过上面告知的TFTP server地址通信,下载引导文件
6、client裸机执行执行该引导文件,确定加载信息,选择要安装的os,期间会再向cobbler server请求kickstart文件和os image
7、cobbler server发送请求的kickstart和os iamge
8、client裸机加载kickstart文件
9、client裸机接收os image,安装该os image
使用cobbler 工具无人值守部署系统
1)安装 cobbler 工具,并检查环境
[root@CentOS7 ksfile]# yum install cobbler #包在epel源中
[root@CentOS7 tftpboot]# cobbler check #使用cobbler check检查当前环境时,这时需要关闭selinux并且重启httpd
httpd does not appear to be running and proxying cobbler, or SELinux is in the way. Original traceback:
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/cobbler/cli.py", line 251, in check_setup
s.ping()
File "/usr/lib64/python2.7/xmlrpclib.py", line 1233, in __call__
return self.__send(self.__name, args)
File "/usr/lib64/python2.7/xmlrpclib.py", line 1587, in __request
verbose=self.__verbose
File "/usr/lib64/python2.7/xmlrpclib.py", line 1273, in request
return self.single_request(host, handler, request_body, verbose)
File "/usr/lib64/python2.7/xmlrpclib.py", line 1321, in single_request
response.msg,
ProtocolError: <ProtocolError for 127.0.0.1:80/cobbler_api: 404 Not Found>
再次检查 cobbler 环境
[root@CentOS7 tftpboot]# 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 : change 'disable' to 'no' in /etc/xinetd.d/tftp
4 : 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.
5 : enable and start rsyncd.service with systemctl
6 : debmirror package is not installed, it will be required to manage debian deployments and repositories
7 : 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
8 : 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.
2)解决环境问题
1:在 /etc/cobbler/settings 文件按的第384行修改 cobbler 服务器的 ip 地址
378 # this is the address of the cobbler server -- as it is used
379 # by systems during the install process, it must be the address
380 # or hostname of the system as those systems can see the server.
381 # if you have a server that appears differently to different subnets
382 # (dual homed, etc), you need to read the --server-override section
383 # of the manpage for how that works.
384 server: 192.168.30.74 378 # this is the address of the cobbler server -- as it is used
379 # by systems during the install process, it must be the address
380 # or hostname of the system as those systems can see the server.
381 # if you have a server that appears differently to different subnets
382 # (dual homed, etc), you need to read the --server-override section
383 # of the manpage for how that works.
384 server: 192.168.30.74 #修改为cobbler服务器的地址
2:在
/etc/cobbler/settings 文件按的第272行修改 tftp 服务器的 ip 地址
269 # if using cobbler with manage_dhcp, put the IP address
270 # of the cobbler server here so that PXE booting guests can find it
271 # if you do not set this correctly, this will be manifested in TFTP open timeouts.
272 next_server: 192.168.30.74
14 disable = no
4:使用
cobbler get-loaders 命令下载必要文件,并使用
cobbler get-loaders 同步至
/var/lib/tftpboot
[root@CentOS7 ~]# cobbler get-loaders
task started: 2018-05-27_212446_get_loaders
task started (id=Download Bootloader Content, time=Sun May 27 21:24:46 2018)
downloading https://cobbler.github.io/loaders/README to /var/lib/cobbler/loaders/README
downloading https://cobbler.github.io/loaders/COPYING.elilo to /var/lib/cobbler/loaders/COPYING.elilo
downloading https://cobbler.github.io/loaders/COPYING.yaboot to /var/lib/cobbler/loaders/COPYING.yaboot
downloading https://cobbler.github.io/loaders/COPYING.syslinux to /var/lib/cobbler/loaders/COPYING.syslinux
downloading https://cobbler.github.io/loaders/elilo-3.8-ia64.efi to /var/lib/cobbler/loaders/elilo-ia64.efi
downloading https://cobbler.github.io/loaders/yaboot-1.3.17 to /var/lib/cobbler/loaders/yaboot
downloading https://cobbler.github.io/loaders/pxelinux.0-3.86 to /var/lib/cobbler/loaders/pxelinux.0
downloading https://cobbler.github.io/loaders/menu.c32-3.86 to /var/lib/cobbler/loaders/menu.c32
downloading https://cobbler.github.io/loaders/grub-0.97-x86.efi to /var/lib/cobbler/loaders/grub-x86.efi
downloading https://cobbler.github.io/loaders/grub-0.97-x86_64.efi to /var/lib/cobbler/loaders/grub-x86_64.efi
*** TASK COMPLETE ***
[root@CentOS7 ~]# cobbler sync
task started: 2018-05-27_212630_sync
task started (id=Sync, time=Sun May 27 21:26:30 2018)
running pre-sync triggers
cleaning trees
removing: /var/lib/tftpboot/pxelinux.cfg/default
removing: /var/lib/tftpboot/grub/images
copying bootloaders
trying hardlink /var/lib/cobbler/loaders/pxelinux.0 -> /var/lib/tftpboot/pxelinux.0
copying: /var/lib/cobbler/loaders/pxelinux.0 -> /var/lib/tftpboot/pxelinux.0
trying hardlink /var/lib/cobbler/loaders/menu.c32 -> /var/lib/tftpboot/menu.c32
copying: /var/lib/cobbler/loaders/menu.c32 -> /var/lib/tftpboot/menu.c32
trying hardlink /var/lib/cobbler/loaders/yaboot -> /var/lib/tftpboot/yaboot
trying hardlink /usr/share/syslinux/memdisk -> /var/lib/tftpboot/memdisk
trying hardlink /var/lib/cobbler/loaders/grub-x86.efi -> /var/lib/tftpboot/grub/grub-x86.efi
trying hardlink /var/lib/cobbler/loaders/grub-x86_64.efi -> /var/lib/tftpboot/grub/grub-x86_64.efi
copying distros to tftpboot
copying images
generating PXE configuration files
generating PXE menu structure
rendering TFTPD files
generating /etc/xinetd.d/tftp
cleaning link caches
running post-sync triggers
running python triggers from /var/lib/cobbler/triggers/sync/post/*
running python trigger cobbler.modules.sync_post_restart_services
running shell triggers from /var/lib/cobbler/triggers/sync/post/*
running python triggers from /var/lib/cobbler/triggers/change/*
running python trigger cobbler.modules.scm_track
running shell triggers from /var/lib/cobbler/triggers/change/*
*** TASK COMPLETE ***
查看
/var/lib/tftpboot
[root@CentOS7 ~]#⮀tree /var/lib/tftpboot/
/var/lib/tftpboot/
├── boot
│ └── grub
│ └── menu.lst
├── etc
├── grub
│ ├── efidefault
│ ├── grub-x86_64.efi
│ ├── grub-x86.efi
│ └── images -> ../images
├── images
│ └── CentOS-6.9-x86_64
│ ├── initrd.img
│ └── vmlinuz
├── images2
├── memdisk
├── menu.c32
├── ppc
├── pxelinux.0
├── pxelinux.cfg
│ └── default
├── s390x
│ └── profile_list
└── yaboot
11 directories, 12 files
7:修改系统默认密码,使用 openssl passwd -1 命令生成斌替换 /etc/cobbler/settings 的第101行
[root@CentOS7 ~]# openssl passwd -1
Password:
Verifying - Password:
$1$o19uxuwb$vbVj38jsOQsdQaLe9xuhU1
8:暂时忽略
3)可以使用 cobbler 替我们生成 DHCP 服务配置,也可以自己设置
启用 cobbler 生成 DCHP 配置文件需要修改 etc/cobbler/settings 中第242行
242 manage_dhcp: 1242 manage_dhcp: 1 #修改为1
再修改 DHCP 服务配置文件模板
[root@CentOS7 tftpboot]#⮀cat /etc/cobbler/dhcp.template
# ******************************************************************
# Cobbler managed dhcpd.conf file
#
# generated from cobbler dhcp.conf template ($date)
# Do NOT make changes to /etc/dhcpd.conf. Instead, make your changes
# in /etc/cobbler/dhcp.template, as /etc/dhcpd.conf will be
# overwritten.
#
# ******************************************************************
ddns-update-style interim;
allow booting;
allow bootp;
ignore client-updates;
set vendorclass = option vendor-class-identifier;
option pxe-system-type code 93 = unsigned integer 16;
subnet 192.168.30.0 netmask 255.255.255.0 {
option routers 192.168.30.1;
option domain-name-servers 8.8.8.8;
option subnet-mask 255.255.255.0;
range dynamic-bootp 192.168.30.10 192.168.30.200;
default-lease-time 21600;
max-lease-time 43200;
next-server $next_server;
class "pxeclients" {
match if substring (option vendor-class-identifier, 0, 9) = "PXEClient";
if option pxe-system-type = 00:02 {
filename "ia64/elilo.efi";
} else if option pxe-system-type = 00:06 {
filename "grub/grub-x86.efi";
} else if option pxe-system-type = 00:07 {
filename "grub/grub-x86_64.efi";
} else if option pxe-system-type = 00:09 {
filename "grub/grub-x86_64.efi";
} else {
filename "pxelinux.0";
}
}
}......
最后重启 cobbler 服务再使用 cobbler sync 命令同步,所有配置就完成了
4)导入系统安装文件
[root@CentOS7 ~]# cobbler import --path=/var/www/html/centos/6 --name=CentOS-6.9-x86_64 --arch=x86_64
task started: 2018-05-27_215121_import
task started (id=Media import, time=Sun May 27 21:51:21 2018)
Found a candidate signature: breed=redhat, version=rhel6
Found a candidate signature: breed=redhat, version=rhel7
Found a matching signature: breed=redhat, version=rhel7
Adding distros from path /var/www/cobbler/ks_mirror/CentOS-6.9-x86_64:
creating new distro: CentOS-6.9-x86_64
trying symlink: /var/www/cobbler/ks_mirror/CentOS-6.9-x86_64 -> /var/www/cobbler/links/CentOS-6.9-x86_64
creating new profile: CentOS-6.9-x86_64
associating repos
checking for rsync repo(s)
checking for rhn repo(s)
checking for yum repo(s)
starting descent into /var/www/cobbler/ks_mirror/CentOS-6.9-x86_64 for CentOS-6.9-x86_64
processing repo at : /var/www/cobbler/ks_mirror/CentOS-6.9-x86_64
need to process repo/comps: /var/www/cobbler/ks_mirror/CentOS-6.9-x86_64
looking for /var/www/cobbler/ks_mirror/CentOS-6.9-x86_64/repodata/*comps*.xml
Keeping repodata as-is :/var/www/cobbler/ks_mirror/CentOS-6.9-x86_64/repodata
*** TASK COMPLETE ***
完成后 cobbler 会自动在 /var/www/cobbler 下生成所有安装系统需要的文件
[root@CentOS7 cobbler]# tree -L 2
.
├── images
│ └── CentOS-6.9-x86_64
├── ks_mirror
│ ├── CentOS-6.9-x86_64
│ └── config
├── links
│ └── CentOS-6.9-x86_64 -> /var/www/cobbler/ks_mirror/CentOS-6.9-x86_64
├── localmirror
├── misc
│ ├── anamon
│ └── anamon.init
├── pub
├── rendered
├── repo_mirror
└── svc
├── services.py
├── services.pyc
└── services.pyo
13 directories, 5 files
使用 cobbler profile 查看当前生效的 kicstart 文件列表
[root@CentOS7 ~]# cobbler profile list #查看kicstart文件列表
CentOS-6.9-x86_64
[root@CentOS7 ~]# cobbler profile report --name=CentOS-6.9-x86_64 #查看kicstart文件信息
Name : CentOS-6.9-x86_64
TFTP Boot Files : {}
Comment :
DHCP Tag : default
Distribution : CentOS-6.9-x86_64
Enable gPXE? : 0
Enable PXE Menu? : 1
Fetchable Files : {}
Kernel Options : {}
Kernel Options (Post Install) : {}
Kickstart : /var/lib/cobbler/kickstarts/sample_end.ks
Kickstart Metadata : {}
Management Classes : []
Management Parameters : <<inherit>>
Name Servers : []
Name Servers Search Path : []
Owners : ['admin']
Parent Profile :
Internal proxy :
Red Hat Management Key : <<inherit>>
Red Hat Management Server : <<inherit>>
Repos : []
Server Override : <<inherit>>
Template Files : {}
Virt Auto Boot : 1
Virt Bridge : xenbr0
Virt CPUs : 1
Virt Disk Driver Type : raw
Virt File Size(GB) : 5
Virt Path :
Virt RAM (MB) : 512
Virt Type : kvm
使用 --help 可以查看 cobbler 和其子命令的选项帮助
[root@CentOS7 ~]# cobbler profile --help
usage
=====
cobbler profile add
cobbler profile copy
cobbler profile dumpvars
cobbler profile edit
cobbler profile find
cobbler profile getks
cobbler profile list
cobbler profile remove
cobbler profile rename
cobbler profile report
5)之后就和 PXE 一样,能够自动安装了
cobbler web 工具
cobbler 还有基于 web 页面的管理工具,可以通过 web 页面进行系统的部署和配置。
1)安装 cobbler-web 包( epel 源中),并重启 cobbler 服务。
[root@CentOS7 ~]# yum install cobbler-web
[root@CentOS7 ~]# systemctl restart httpd.service
[root@CentOS7 ~]#⮀cat /etc/cobbler/modules.conf
# cobbler module configuration file
# =================================
# authentication:
# what users can log into the WebUI and Read-Write XMLRPC?
# choices: #所有登陆cobbler_web页面的认证方式
# authn_denyall -- no one (default)
# authn_configfile -- use /etc/cobbler/users.digest (for basic setups)
# authn_passthru -- ask Apache to handle it (used for kerberos)
# authn_ldap -- authenticate against LDAP
# authn_spacewalk -- ask Spacewalk/Satellite (experimental)
# authn_pam -- use PAM facilities
# authn_testing -- username/password is always testing/testing (debug)
# (user supplied) -- you may write your own module
# WARNING: this is a security setting, do not choose an option blindly.
# for more information:
# https://github.com/cobbler/cobbler/wiki/Cobbler-web-interface
# https://github.com/cobbler/cobbler/wiki/Security-overview
# https://github.com/cobbler/cobbler/wiki/Kerberos
# https://github.com/cobbler/cobbler/wiki/Ldap
[authentication]
module = authn_configfile #当前使用的认证方式
...
在
/etc/cobbler/users.digest 文件中通过
htdigest 命令添加用户、密码
[root@CentOS7 ~]# htdigest -c /etc/cobbler/users.digest Cobbler jiangbowen #创建用户、密码
Adding password for jiangbowen in realm Cobbler.
New password:
Re-type new password:
[root@CentOS7 ~]# cat /etc/cobbler/users.digest
jiangbowen:Cobbler:eae015f6102a12efa5c23613d191b7be
![](https://i-blog.csdnimg.cn/blog_migrate/95e75560ca2eac871d14c8fcb3a8405d.png)
根据选项就可以创建和管理 cobbler 了。