Cobbler自动化安装部署操作系统

Cobbler是快速网络安装linux操作系统的服务,支持众多的Linux发行版:Red HatFedoraCentOS、Debian、UbuntuSUSE,也可以支持网络安装windows。

一、配置yum源

cobbler所在的源是epel源所以先配置yum源

[root@centos7 ~]# vim /etc/yum.repos.d/base.repo [base] name=base baseurl=file:///mnt gpgcheck=0 [epel] name=epel baseurl=http://mirrors.sohu.com/fedora-epel/7/x86_64 gpgcheck=0 二、安装cobbler和dhcp服务 [root@centos7 ~]# yum install cobbler dhcp -y 三、启动相关服务并设置为开机启动 [root@centos7 ~]# systemctl enable rsyncd httpd tftp cobblerd dhcpd [root@centos7 ~]# systemctl start rsyncd httpd tftp cobblerd 四、配置cobbler

1.使用cobbler check查看所需配置的内容

root@centos7 ~]# 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 : debmirror package is not installed, it will be required to manage debian deployments and repositories 6 : 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 7 : 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.在/etc/cobbler/setting文件中查找到以下几项并进行修改

server: 192.168.73.120 #cobbler的服务器地址 next_server: 192.168.73.120 #tftp服务器地址 default_password_crypted: "$1$JZoCUmJG$PaPdl.tq3OW6KEXZbUaBP." #修改默认密码 manage_dhcp: 1 #dhcpg管理设置为1

3.下载boot-loaders

[root@centos7 ~]# cobbler get-loaders

4.修改cobbler的dhcp模板文件

[root@centos7 ~]# vim /etc/cobbler/dhcp.template ...上面省略... subnet 192.168.73.0 netmask 255.255.255.0 { #修改网段 option routers 192.168.73.254; #指定网关 option domain-name-servers 1.1.1.1; #指定dns option subnet-mask 255.255.255.0; #指定子网掩码 range dynamic-bootp 192.168.73.1 192.168.73.100; #指定地址池 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"; } } } ...下面省略...

5.将cobbler的DHCP文件进行同步

[root@centos7 ~]# cobbler sync

6.重启cobbler服务以及DHCP服务

[root@centos7 ~]# systemctl restart cobblerd [root@centos7 ~]# systemctl start dhcpd 五、为cobbler配置系统镜像文件

1.将光盘挂载至一个空目录

[root@centos7 ~]# mount /dev/sr0 /mnt

2.将光盘内文件复制入cobbler,此步骤是将光盘的的文件复制至/var/www/cobbler/ks_mirror/目录下

[root@centos7 ~]# cobbler import --path=/mnt --name=Centos-6.10 --arch=x86_64

由于cobbler自带了KS文件,所以现在已经能够实现自动化安装系统了,若要实现使用自己定制的KS文件,来实现自动化安装看下面的补充。

补充

在实际生产环境中可能需要安装各种不同的定制化的系统,此时就需要准备各种不同的ks文件,并将文件与相对应的系统关联起来。

一、准备ks文件

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/12018.html