1.简介
cobbler是一款自动化安装Linux操作系统的软件,自带WEB界面,可以很方便配置和使用。
cobbler在原来PXE的基础上进行了封装,增加了大量的新功能,同时提供了api接口供开发者自定义自己的内容。
集成的服务有:
PXE 服务
DHCP
Rsync
Http
DNS
Kickstart
IPMI 电源管理
2.实践安装cobbler
1,实验环境:
Linux系统版本为Centos7
两台浪潮英信服务器 NF 5180M4
两台机器在相同网段
2,环境准备
关闭selinux
[root@block1 ~]# setenforce
usage: setenforce [ Enforcing | Permissive | 1 | 0 ]
[root@block1 ~]# setenforce 0
setenforce: SELinux is disabled
[root@block1 ~]# vim /etc/sysconfig/selinux
1
2 # This file controls the state of SELinux on the system.
3 # SELINUX= can take one of these three values:
4 # enforcing - SELinux security policy is enforced.
5 # permissive - SELinux prints warnings instead of enforcing.
6 # disabled - No SELinux policy is loaded.
7 SELINUX=disabled
关闭防火墙或者打开服务需要的端口号
[root@block1 ~]# systemctl stop firewalld
3,安装必要软件
1,安装epel源
yum install epel-release -y
2,安装cobbler和相关服务
yum -y install httpd dhcp tftp python-ctypes cobbler xinetd cobbler-web
3,启动http和cobbler服务
systemctl start httpd.service
systemctl start cobblerd.service
4,检测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 : 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.
一个个解决问题
#指定cobbler server
sed -i 's/server: 127.0.0.1/server: 192.168.150.17/' /etc/cobbler/settings
#指定DHCP中的next_server
sed -i 's/next_server: 127.0.0.1/next_server:192.168.150.17 /' /etc/cobbler/settings
#cobbler自己管理DHCP服务
sed -i 's/manage_dhcp: 0/manage_dhcp: 1/' /etc/cobbler/settings
#和ipmi pxe重启有关
sed -i 's/pxe_just_once: 0/pxe_just_once: 1/' /etc/cobbler/settings
#默认的机器root密码
sed -ri "/default_password_crypted/s#(.*: ).*#\1\"`openssl passwd -1 -salt 'oldboy' '123456'`\"#" /etc/cobbler/settings
#启用tftpd服务
sed -i 's#yes#no#' /etc/xinetd.d/tftp
完毕后重启cobbler服务,执行命令
[root@block1 ~]# systemctl restart cobblerd
[root@block1 ~]# cobbler sync
task started: 2018-05-30_232021_sync
task started (id=Sync, time=Wed
[root@block1 ~]# 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
这个问题暂时不管,只和deb系统有关,忽略即可
5,下载loader文件
[root@block1 ~]# cobbler get-loaders
[root@block1 ~]# ls /var/lib/cobbler/loaders/
COPYING.elilo COPYING.yaboot grub-x86_64.efi menu.c32 README
COPYING.syslinux elilo-ia64.efi grub-x86.efi pxelinux.0 yaboot
6,修改dhcpd文件
只贴修改的部分
vim /etc/cobbler/dhcp.template
subnet 192.168.150.0 netmask 255.255.255.0 {
option routers 192.168.150.254;
option domain-name-servers 192.168.150.254;
option subnet-mask 255.255.255.0;
range dynamic-bootp 192.168.150.170 192.168.150.180;
7,同步一下配置
cobbler check
重启所有服务
systemctl restart httpd.service
systemctl restart cobblerd.service
systemctl restart dhcpd.service
systemctl restart rsyncd.service
systemctl restart tftp.socket
8,打开游览器输入https://192.168.150.17/cobbler_web
默认账号密码都是cobbler
点击导入镜像 import DVD
创建镜像文件
先选好 Arch,Breed,prefix
Path是机器上iso地址
[root@block1 ~]# ls /mnt/iso/
CentOS_BuildTag GPL LiveOS RPM-GPG-KEY-CentOS-7
EFI images Packages RPM-GPG-KEY-CentOS-Testing-7
EULA isolinux repodata TRANS.TBL
导入成功
可以找到导入后文件位置
[root@block1 ~]# ls /var/www/cobbler/ks_mirror/Centos7.3-x86_64/
CentOS_BuildTag GPL LiveOS RPM-GPG-KEY-CentOS-7
EFI images Packages RPM-GPG-KEY-CentOS-Testing-7
EULA isolinux repodata TRANS.TBL
使用远程管理端口初步测试cobbler
ipmitool -I lanplus -H 192.168.150.151 -U admin -P admin chassis power off
ipmitool -I lanplus -H 192.168.150.151 -U admin -P admin chassis bootdev pxe
ipmitool -I lanplus -H 192.168.150.151 -U admin -P admin chassis power on
出现下面图片表示cobbler安装成功
3.定制化安装系统(以Centos7举例)
1,修改distors
点击版本distors,添加kernel参数net.ifnames=0 biosdevname=0
可以让网卡编程eth0之类的方便管理。
修改完毕后点击保存即可
2,点击ks文件模板,创建自己的ks文件
Centos7的ks文件例子:
#version=RHEL7
# System authorization information
auth --enableshadow --passalgo=sha512
# Use CDROM installation media
#cdrom
# Use network installation
url --url="$tree"
# Run the Setup Agent on first boot
firstboot --enable
ignoredisk --only-use=sda
# Keyboard layouts
keyboard --vckeymap=us --xlayouts='cn','us'
# System language
lang zh_CN.UTF-8 --addsupport=en_US.UTF-8
# System services
services --enabled="chronyd"
# Network information
network --bootproto=static --device=eno1 --gateway=192.168.150.254 --ip=192.168.150.161 --netmask=255.255.255.0 --ipv6=auto --activate
# Root password
rootpw --iscrypted $6$EFToOZFJRxoHKJfk$HI1L8nDFpoXCtnJOgKjjHl9zhxDAlIFmQnaDmKonqU3/iRCtzdSkvMwPqwdLBzJz5n0OvEJZ.hFoZoc2WiL6g0
# System timezone
timezone Asia/Shanghai --isUtc
selinux --disabled
firewall --disabled
# System bootloader configuration
bootloader --location=mbr --boot-drive=sda
# Partition clearing information
clearpart --all --initlabel
# Disk partitioning information
#part swap --fstype="swap" --ondisk=sda --size=16384
#part biosboot --fstype="biosboot" --ondisk=sda --size=2
#part /boot --fstype="xfs" --ondisk=sda --size=500
#part pv.928 --fstype="lvmpv" --ondisk=sda --size=2840062
#volgroup cl_sf-test-06 --pesize=4096 pv.928
#logvol / --fstype="xfs" --size=2840060 --name=root --vgname=cl_sf-test-06
autopart --type=lvm
reboot
%packages
chrony
%end
%pre
%end
3,给系统定制额外参数
点击系统,定制额外参数
选定profile和ks文件
网关,nameserver
ip配置,在设置完毕mac之后,可以跳过选择local还是Centos7-4-X86_64的页面
同步一下
这些ns和ip指定是在dhcpd配置文件中写上生效的。
可以看到如下配置
44 # group for Cobbler DHCP tag: default
45 group {
46 host generic1 {
47 hardware ethernet 6c:92:bf:55:be:7a;
48 fixed-address 192.168.150.160;
49 option host-name "test";
50 option subnet-mask 255.255.255.0;
51 option routers 192.168.150.254;
52 filename "/pxelinux.0";
53 next-server 192.168.150.17;
54 }
55 }
再次pxe引导服务器即可实现一键安装,全程无需干扰。
问题1:
如何获取服务器的MAC地址?
浪潮服务器是使用ipmitool命令,其他服务器请自行百度
网卡1:
[root@block1 ~]# ipmitool -I lanplus -H 192.168.150.151 -U admin -P admin raw 0x3a 0x02 0x04 0x00 0x00
04 00 00 00 00 6c 92 bf 55 be 7a 00 00 00 00
网卡2:
[root@block1 ~]# ipmitool -I lanplus -H 192.168.150.151 -U admin -P admin raw 0x3a 0x02 0x04 0x01 0x01
04 01 01 01 00 6c 92 bf 55 be 7b 00 00 00 00
中间结果部分
6c 92 bf 55 be 7a
6c 92 bf 55 be 7b
问题2:
Centos7出现 “error storage configuration”错误,
安装硬盘时候分区错误,由于各个硬盘容量差异较大,可以在ks文件中将设置为自动分区。
autopart --type=lvm
(码字到深夜两点,我也是醉了(•౪• ))
参考文档:
http://cobbler.github.io