点关注不迷路
目录
cobbler批量部署系统
一、cobbler介绍
由RedHat公司基于python语言开发
作用:快速批量部署Linux系统
1、cobbler特性:
- 部署简单
- 默认适用http共享系统安装文件
- 支持系统定制
- 提供API接口
- 提供web管理界面
二、cobbler服务安装部署
1、关闭防火墙、SELinux;确保正常访问互联网
2、安装cobbler相关软件
[root@cobbler ~]# wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
[root@cobbler ~]# yum install -y cobbler cobbler-web dhcp tftp-server xinetd httpd
[root@cobbler ~]# systemctl start cobblerd.service httpd
[root@cobbler ~]# systemctl enable cobblerd.service httpd
3、配置cobbler参数
[root@cobbler ~]# 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 : ksvalidator was not found, install pykickstart
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.
cobbler get-loaders失败解决方案:
# yum install -y syslinux
# cp /usr/share/syslinux/pxelinux.0 /var/lib/cobbler/loaders/
# cp /usr/share/syslinux/menu.c32 /var/lib/cobbler/loaders/
4、配置DHCP服务
[root@cobbler ~]# vim /etc/cobbler/settings
manage_dhcp: 1
[root@cobbler ~]# vim /etc/cobbler/dhcp.template
subnet 192.168.183.0 netmask 255.255.255.0 {
option routers 192.168.183.2;
option domain-name-servers 114.114.114.114,202.106.0.20;
range dynamic-bootp 192.168.183.100 192.168.183.200;
default-lease-time 21600;
max-lease-time 43200;
next-server $next_server;
[root@cobbler ~]# systemctl restart cobblerd
[root@cobbler ~]# cobbler sync
[root@cobbler ~]# netstat -anup | grep dhcp
udp 0 0 0.0.0.0:67 0.0.0.0:* 2065/dhcpd
[root@cobbler ~]#
5、启动tftp服务
[root@cobbler ~]# systemctl restart xinetd
[root@cobbler ~]# systemctl enable xinetd
[root@cobbler ~]#
[root@cobbler ~]# netstat -anup | grep 69
udp 0 0 0.0.0.0:69 0.0.0.0:* 2076/xinetd
[root@cobbler ~]#
6、导入centos76镜像
[root@cobbler ~]# mount /dev/sr0 /mnt/
[root@cobbler ~]# cobbler import --path=/mnt --name=CentOS74 --arch=x86_64
[root@cobbler ~]# cobbler profile list
CentOS74-x86_64
[root@cobbler ~]# cobbler profile report --name=CentOS7.6-x86_64
Name : CentOS7.6-x86_64
TFTP Boot Files : {}
Comment :
DHCP Tag : default
Distribution : CentOS7.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
7、测试centos7安装正常
8、添加centos66安装源
替换centos6安装光盘
[root@cobbler ~]# mount /dev/sr0 /mnt/
[root@cobbler ~]# cobbler import --path=/mnt --name=CentOS66 --arch=x86_64
三、系统绑定
[root@cobbler ~]# cobbler system add --name=vm01_centos7 --profile=CentOS74-x86_64 --mac-address=00:50:56:21:AD:B1 --interface=eth0
[root@cobbler ~]# cobbler system list
vm01_centos7