cobbler
翻译为补鞋匠
- 使用一个模板来配置 dhcp服务
- 讲一个存储库(yum或rsync)建立镜像或解压缩一个媒介,已注册一个新操作系统
- 在dhcp配置文件中为需要安装的机器创建一个条目,并使用您指定的参数(ip和mac地址)
- 在tftp服务目录下创建适当的pxe文件
- 重新启动dhcp服务以反映更改
- 重新启动机器以开始安装(如果电源管理已启用)
具体流程:
ks配置文件
供参考
Centos-6ks文件
Centos-7ks文件
具体流程:
- yum源配置,并下载相关服务
#备份repo
cd /etc/yum.repos.d
mkdir bak
mv *.repo bak/
#下载阿里的repo
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
#安装epel
yum install -y epel-release
#注: 如遇报错:Cannot retrieve metalink for repository: epel/x86_64. Please verify its path and try again
#解决方法将https://mirrors .... 修改为http://mirrors
yum clean all
yum makecache
#安装相关服务
yum install -y httpd dhcp tftp cobbler cobbler-web pykickstart xinetd
- 启动服务,并修改cobbler配置
#启动apache、cobbler服务,并配置开机启动
systemctl start httpd
systemctl start cobblerd
systemctl enable httpd
systemctl enable cobblerd
#cobbler配置检查 、依次根据提示修改、注要先将selinux关闭
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
步骤:
1. vim /etc/cobbler/settings
272行 next_server: 192.168.0.10 #将127.0.0.1改为本机ip
384行 server: 192.168.0.10 #将127.0.0.1改为本机ip
2. vim /etc/xinetd.d/tftp
将disable项 改为no
3. systemctl start rsyncd
systemctl enable rsyncd
4. cobbler get-loaders
#如遇报错: Exception value: [Errno 14] curl#35 - "Peer reports incompatible or unsupported protocol version."
yum update -y nss curl libcurl
systemctl restart cobblerd
5. openssl passwd -1 -salt 'cobbler' 'cobbler'
#将生成的加密字符串复制到/etc/cobbler/settings的第101行101
default_password_crypted: "$1$cobbler$M6SE55xZodWc9.vAKLJs6."
6. cobbler check
[root@localhost ~]# cobbler check
The following are potential configuration items that you may want to fix:
1 : debmirror package is not installed, it will be required to manage debian deployments and repositories
2 : fencing tools were not found, and are required to use the (optional) power management features. install cman or fence-agents to use them
#配置cobbler管理dhcp
1. vim /etc/cobbler/settings
242行 manage_dhcp: 1
2. vim /etc/cobbler/dhcp.template 修改内容
21 subnet 192.168.0.0 netmask 255.255.255.0 {
22 option routers 192.168.0.1;
23 option domain-name-servers 192.168.0.1;
24 option subnet-mask 255.255.255.0;
25 range dynamic-bootp 192.168.0.100 192.168.0.254;
3. systemctl restart cobblerd
4. cobbler sync #自动生成dhcp配置文件,并重启dhcp
- cobbler载入镜像
#载入镜像
mount /dev/cdrom /mnt
cobbler import --path=/mnt/ --name=CentOS-7-x86_64 --arch=x86_64
#导入的镜像会在/var/www/cobbler/ks_mirror 下
umount /mnt
mount /dev/cdrom /mnt #更换为centos6镜像
#再导入Centos6
# cobbler import --path=/mnt/ --name=CentOS-6-x86_64 --arch=x86_64
[root@localhost ~]# cobbler profile list
CentOS-6-x86_64
CentOS-7-x86_64
#查看ks文件对应位置
[root@localhost ~]# cobbler profile report
Name : CentOS-7-x86_64
TFTP Boot Files : {}
Comment :
DHCP Tag : default
Distribution : CentOS-7-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
Name : CentOS-6-x86_64
TFTP Boot Files : {}
Comment :
DHCP Tag : default
Distribution : CentOS-6-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
- 修改cobbler profile ks对应位置,启动服务
#ks文件存放位置
/var/lib/cobbler/kickstarts
#修改对应ks文件
[root@localhost ~]# cobbler profile edit --name=CentOS-7-x86_64 --kickstart=/var/lib/cobbler/kickstarts/CentOS-7-x86_64.cfg
#Centos7 通过修改内核参数修改网卡默认名称
[root@localhost ~]# cobbler profile edit --name=CentOS-7-x86_64 --kopts='net.ifnames=0 biosdevname=0'
#修改ks文件或dhcp文件,需要执行
[root@localhost ~]# cobbler sync
#启动tftp
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# systemctl restart xinetd
[root@localhost ~]# systemctl restart tftp
- 新增一台,以网卡启动,选择需要安装的系统