一、 cobbler可以自动安装系统,免去了手工安装的重复性工作。
cobbler安装主要分为3个步骤:
1、cobbler的安装,包括http、tftp、dhcp、rsync、xinetd、kickstart服务的安装
2、cobbler 对镜像进行repository、部署核心组件
3、配置kickstart,并将应答文件和配置文件相关联。
二 cobbler 安装
[root@localhost ~]# cat /etc/redhat-release #CentOS Linux release 7.3.1611 (Core) 检查系统版本
[root@localhost ~]# uname -r3.10.0-514.el7.x86_64 # 检查内核版本
[root@localhost ~]# yum install vim wget -y # yum 安装 wget 、vim
[root@localhost ~]# vim /etc/selinux/config 将SELINUX=disabled
[root@cobbler-node1 ~]# systemctl stop firewalld #关闭防火墙
[root@cobbler-node1 ~]# wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo #cobbler安装必须使用到epel源
[root@localhost ~]# ifconfig # 查看IP地址
提示:虚拟机网卡采用NAT模式,因为我们会搭建DHCP服务器,在同一局域网多个DHCP服务会有冲突,并且导致实践失败。
[root@cobbler-node1 ~]# yum install cobbler cobbler-web pykickstart debmirror -y
[root@localhost ~]# yum install dhcp tftp-server httpd syslinux
启动 httpd 、cobblerd服务
[root@localhost ~]#systemctl start httpd.servce
[root@localhost ~]#systemctl enable httpd
[root@localhost ~]#systemctl start cobblerd.servce
[root@localhost ~]#systemctl enable cobblerd
检查 cobblerd 需要配置的东西
[root@localhost ~] cobblerd 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 : comment out 'dists' on /etc/debmirror.conf for proper debian support
7 : comment out 'arches' on /etc/debmirror.conf for proper debian support
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 themRestart cobblerd and then run 'cobbler sync' to apply changes.
上述问题解决方案(6、7、9的错误可以不用管)
1.修改/etc/cobbler/settings文件中的server参数的值为提供cobbler服务的主机相应的IP地址或主机名,如server:10.0.0.101;[root@cobbler-node1 ~]# sed -i 's/server: 127.0.0.1/server: 10.0.0.7/' /etc/cobbler/settings
2.修改/etc/cobbler/settings文件中的next_server参数的值为提供PXE服务的主机相应的IP地址,如next_server:10.0.0.101;[root@cobbler-node1 ~]# sed -i 's/next_server: 127.0.0.1/next_server: 10.0.0.7/' /etc/cobbler/settings
3.修改/etc/xinetd.d/tftp文件中的disable参数修改为disable = no
4.执行cobbler get-loaders命令即可;否则,需要安装syslinux程序包,而后复制/usr/share/syslinux/{pxelinux.0,memu.c32}等文件至/var/lib/cobbler/loaders/目录中;
5.执行systemctl enable rsyncd命令即可;
6.如果有强迫症可以选择yum –y install debmirror然后根据错误进行解决,一般错误如下。## 注释/etc/dedmirror.conf文件中的@dists=”sid”;@arches=”i386”;
7.[root@cobbler-node1 ~]# openssl passwd -1 -salt '$(openssl rand -hex 4)' 'EC' $1$$(openss$yWzTjLjGmjQJUbnsOQnx8/ [root@cobbler-node1 ~]# grep "default_password_crypted" /etc/cobbler/settings #替换/etc/cobbler/setting内的default_password_crypteddefault_password_crypted:"$1$$(openss$yWzTjLjGmjQJUbnsOQnx8/"
8.yum –y install cman fence-agentssystemctl restart cobblerd#最后重启Cobbler
配置DHCP
[root@cobbler-node1 ~]# vim /etc/cobbler/dhcp.template
subnet 172.29.0.0 netmask 255.255.224.0 {
option routers 172.29.0.1;
option domain-name-servers 172.29.10.20;
option subnet-mask 255.255.224.0;
range dynamic-bootp 172.29.29.170 172.29.29.254;
default-lease-time 21600;
max-lease-time 43200;
next-server $next_server;
[root@localhost ~]# vim /etc/cobbler/settings #manage_dhcp: 1 将0 改为1
[root@localhost ~]# yum install xinetd #安装进程守护
[root@cobbler-node1 ~]# systemctl restart xinetd
[root@cobbler-node1 ~]# cobbler sync # 配置文件同步
三、 管理Cobbler和配置、将应答文件和配置文件相关联
管理distro(发行版)
[root@localhost ~]# mount /dev/cdrom /mnt/ #挂载光驱centos7.iso
[root@localhost ~]# cobbler import --path=/mnt/ --name=centos-7-x86_64-distro --arch=x86_64 # 将iso i mport进distro
[root@cobbler-node1 ~]# cobbler distro list
管理profile
[root@localhost ~]# cobbler profile edit --name=centos-7-distro-x86_64 --kopts='net.ifnames=0 biosdevname=0'
[root@localhost ~]# cobbler repo add --name=centos-7-base --mirror=http://mirrors.aliyun.com/centos/7/os/x86_64/Packages/ --arch=x86_64 --breed=yum
root@localhost ~]# systemctl restart cobblerd.service
[root@localhost ~]# cobbler sync