第1章 什么是Cobbler
1.1 物理网卡MAC地址获取方式
1、服务器表壳标签;
2、软件自动扫描网络获取;
1.2 Cobbler介绍
Cobbler是一个Linux系统安装的服务,可以通过网络启动(PXE)的方式来快速安装、重装物理服务器和虚拟机,同时还可以管理DHCP,DNS等。
•Cobbler可以使用命令行方式管理,也提供了基于Web的界面管理工具(cobbler-web),还提供了API接口,可以方便二次开发使用。
•Cobbler是较早前的kickstart的升级版,优点是比较容易配置,还自带web界面比较易于管理。
第2章 Cobbler安装部署
2.1 所使用的软件
yum -y install cobbler cobbler-web dhcp tftp-server pykickstart httpd python-django
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
2.2 启动服务
systemctl start cobblerd.service
systemctl start httpd.service
2.3 检查配置
cobbler check
2.4 修改Cobbler配置
操作前先备份文件
cp /etc/cobbler/settings{,.ori}
vim /etc/cobbler/settings
292 pxe_just_once: 1
242 manage_dhcp: 1
sed -i 's/server: 127.0.0.1/server: 172.16.1.202/' /etc/cobbler/settings
sed -i 's/next_server: 127.0.0.1/next_server: 172.16.1.202/' /etc/cobbler/settings
sed -i 's/manage_dhcp: 0/manage_dhcp: 1/' /etc/cobbler/settings
sed -i 's/pxe_just_once: 0/pxe_just_once: 1/' /etc/cobbler/settings
sed -ri "/default_password_crypted/s#(.*: ).*#\1\"`openssl passwd -1 -salt 'Mikey' '123456'`\"#" /etc/cobbler/settings
2.5 启动服务
systemctl enable tftp.socket
systemctl start tftp.socket
systemctl restart cobblerd.service
2.6 修改DHCP文件
[root@Cobbler ~]# vim /etc/cobbler/dhcp.template
subnet 172.16.1.0 netmask 255.255.255.0 {
option routers 172.16.1.5;
option domain-name-servers 172.16.1.1;
option subnet-mask 255.255.255.0;
range dynamic-bootp 172.16.1.100 172.16.1.254;
default-lease-time 21600;
max-lease-time 43200;
next-server $next_server;
说明:客户端的获取(:%s/192.168/172.16/g) 修改的nohi
2.7 重启服务tftp cobbler
[root@Cobbler ~]# systemctl enable tftp.socket
[root@Cobbler ~]# systemctl start tftp.socket
[root@Cobbler ~]# systemctl restart cobblerd.service
2.8 同步数据信息
[root@Cobbler ~]# cobbler sync
task started: 2018-01-09_094526_sync
task started (id=Sync, time=Tue Jan 9 09:45:26 2018)
running pre-sync triggers
cleaning trees
removing: /var/lib/tftpboot/grub/images
注意:同步后不要修改此目录。
[root@Cobbler ~]# cat /etc/dhcp/dhcpd.conf
# ******************************************************************
# Cobbler managed dhcpd.conf file
# generated from cobbler dhcp.conf template (Tue Jan 9 01:45:27 2018)
# Do NOT make changes to /etc/dhcpd.conf. Instead, make your changes
# in /etc/cobbler/dhcp.template, as /etc/dhcpd.conf will be 修改这个文件
# overwritten.
# ******************************************************************
这样就可以通过web界面操作了
第3章 WEB界面操作
https://10.0.0.202/cobbler_web
登录的密码和账号是cobbler cobbler
3.1 挂载光盘
[root@Cobbler ~]# mount /dev/cdrom /mnt/
mount: /dev/sr0 is write-protected, mounting read-only
[root@Cobbler ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 98G 1.6G 97G 2% /
devtmpfs 903M 0 903M 0% /dev
tmpfs 912M 0 912M 0% /dev/shm
tmpfs 912M 8.8M 903M 1% /run
tmpfs 912M 0 912M 0% /sys/fs/cgroup
/dev/sda1 1014M 135M 880M 14% /boot
tmpfs 183M 0 183M 0% /run/user/0
/dev/sr0 4.3G 4.3G 0 100% /mnt
3.1.1 设置步骤:
Actions----àlmportDVD--à填写镜像的一些信息(下图显示详细信息)
说明:Arch必须选择X86_64(其他的不是很稳定,容易出错)
Path选择的是镜像挂载的路径;(必须确定,出错一直挂载导致磁盘空间浪费)
3.1.2 查看是否在/mnt/目录下挂载的
[root@Cobbler ~]# ps -ef|grep rsync
root 12817 1 0 09:20 ? 00:00:00 /usr/bin/rsync --daemon --no-detach
root 13308 12962 15 09:58 ? 00:00:07 rsync -a /mnt/ /var/www/cobbler/ks_mirror/CentOS7.4-x86_64 --progress
root 13309 13308 0 09:58 ? 00:00:00 rsync -a /mnt/ /var/www/cobbler/ks_mirror/CentOS7.4-x86_64 --progress
root 13310 13309 12 09:58 ? 00:00:05 rsync -a /mnt/ /var/www/cobbler/ks_mirror/CentOS7.4-x86_64 --progress
root 13338 12429 0 09:59 pts/1 00:00:00 grep --color=auto rsync
3.1.3 同步完成后的显示
[root@Cobbler ~]# ps -ef|grep rsync
root 12817 1 0 09:20 ? 00:00:00 /usr/bin/rsync --daemon --no-detach
root 13925 12429 0 10:17 pts/1 00:00:00 grep --color=auto rsync
Distros 镜像
Profiles 配置属性
3.2 客户端安装
/var/lib/tftpboot/pxelinux.cfg/default默认配置文件
只能修改此目录 /etc/cobbler/pxe/pxedefault.template
说明:默认是选择本地的。
3.3 自定义安装系统
修改默认的KS文件
3.4 Create New Kickstart File 配置文件
# Cobbler for Kickstart Configurator for CentOS 7 by Mikey
install
url --url=$tree
text
lang en_US.UTF-8
keyboard us
zerombr
bootloader --location=mbr --driveorder=sda --append="crashkernel=auto rhgb quiet"
#Network information
$SNIPPET('network_config')
#network --bootproto=dhcp --device=eth0 --onboot=yes --noipv6 --hostname=CentOS7
timezone --utc Asia/Shanghai
authconfig --enableshadow --passalgo=sha512
rootpw --iscrypted $default_password_crypted
clearpart --all --initlabel
part /boot --fstype xfs --size 1024
part swap --size 1024
part / --fstype xfs --size 1 --grow
firstboot --disable
selinux --disabled
firewall --disabled
logging --level=info
reboot
%pre
$SNIPPET('log_ks_pre')
$SNIPPET('kickstart_start')
$SNIPPET('pre_install_network_config')
# Enable installation monitoring
$SNIPPET('pre_anamon')
%end
%packages
@^minimal
@compat-libraries
@core
@debugging
@development
bash-completion
chrony
dos2unix
kexec-tools
lrzsz
nmap
sysstat
telnet
tree
vim
wget
%end
%post
systemctl disable postfix.service
%end
3.5 创建安装
第二块网卡设置同上(注意添加网卡的MAC地址)
配置完后同步,客户端开始无人值守安装开始。
3.6 Cent OS 6.9的配置文件
# Cobbler for Kickstart Configurator for CentOS 6.9 by Mikey
install
url --url=$tree
text
lang en_US.UTF-8
keyboard us
zerombr
bootloader --location=mbr --driveorder=sda --append="crashkernel=auto rhgb quiet"
# Network information
$SNIPPET('network_config')
timezone --utc Asia/Shanghai
authconfig --enableshadow --passalgo=sha512
rootpw --iscrypted $default_password_crypted
clearpart --all --initlabel
part /boot --fstype=ext4 --asprimary --size=200
part swap --size=1024
part / --fstype=ext4 --grow --asprimary --size=200
firstboot --disable
selinux --disabled
firewall --disabled
logging --level=info
reboot
%pre
$SNIPPET('log_ks_pre')
$SNIPPET('kickstart_start')
$SNIPPET('pre_install_network_config')
# Enable installation monitoring
$SNIPPET('pre_anamon')
%end
%packages
@base
@compat-libraries
@debugging
@development
tree
nmap
sysstat
lrzsz
dos2unix
telnet
%end
%post
chkconfig postfix off
%end