1、首先安装软件及环境
yum install httpd dhcp tftp cobbler cobbler-web pykickstart xinetd
2、安装软件完成后可以启动https和cobbler进行检查有哪些环境需要配置
[root@default cobbler]# systemctl start httpd cobbler xinetd
[root@default 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.
#1:cobbler服务需要在/etc/cobbler/settings配置文件中设置服务端ip(384行 server: x.x.x.x);
#2:PXE服务需要在/etc/cobbler/settings配置文件中设置服务端ip(272行 next_server: x.x.x.x);
#3:修改/etc/xinetd.d/tftp配置文件中disable值为no;
#4:运行cobbler get-loaders命令下载相应文件;
#5:开启rsyncd服务;
#6:需要下载debmirror软件包;
#7:修改默认密码,采用加密方式请使用openssl passwd -1 -salt '你的密码' '你的密码'生成加密密码,然后替换到/etc/cobbler/setting中101行default_password_crypted: "$1$cobler$XJnisBweZJlhL651HxAM00"中;
#8:可以使用cman或fence-agents电源管理工具
#配置完重起cobblerd可以运行cobbler sync重启服务
3、配置dhcp(cobbler管理)
3.1在cobbler中开启dhcp功能
[root@default cobbler]# vim /etc/cobbler/setting
#242行 manage_dhcp: 0中的0修改为1
manage_dhcp: 1
3.2修改dhcp配置
[root@default cobbler]# vim /etc/cobbler/dhcp.template
subnet 10.0.0.0 netmask 255.255.255.0 {
option routers 10.0.0.2;
option domain-name-servers 10.0.0.2;
option subnet-mask 255.255.255.0;
range dynamic-bootp 10.0.0.2 10.0.0.254;
default-lease-time 21600;
max-lease-time 43200;
next-server $next_server;
主要修改上述dhcp配置即可,重启cobbler服务
然后执行cobbler sync生成配置文件,启动dhcp服务等
4、导入系统镜像
4.1首先挂在系统进行到本地系统目录(例如mount /dev/cdrom /mnt)
4.2导入需要安装的系统到cobbler中(存放目录为/var/www/cobbler/ks_mirror,其中--path为要导入的镜像目录位置,--name为系统名,--arch为32或64为)
cobbler import --path=/mnt/ --name=CentOS-7-x86_64 --arch=x86_64
4.2查看cobbler配置信息
[root@default /]# cobbler profile report
Name : CentOS-7-x86_64
TFTP Boot Files : {}
Comment :
DHCP Tag : default
Distribution : CentOS-7-x86_64
Enable gPXE? : 0
Enable PXE Menu? : 1
Fetchable Files : {}
Kernel Options : {}
Kernel Options (Post Install) : {}
Kickstart : /var/lib/cobbler/kickstarts/CentOS-7-x86_64.cfg
Kickstart Metadata : {}
Management Classes : []
Management Parameters : <<inherit>>
Name Servers : []
Name Servers Search Path : []
Owners : ['admin']
Parent Profile :
Internal proxy :
Red Hat Management Key : <<inherit>>
Red Hat Management Server : <<inherit>>
Repos : []
Server Override : <<inherit>>
Template Files : {}
Virt Auto Boot : 1
Virt Bridge : xenbr0
Virt CPUs : 1
Virt Disk Driver Type : raw
Virt File Size(GB) : 5
Virt Path :
Virt RAM (MB) : 512
Virt Type : kvm
4.4我们需要自定义kickstart系统安装信息文件需要如下操作(注意--name要和上述NAME保持一致,kickstart文件位置自定义即可)
[root@default /]# cobbler profile edit --name=CentOS-7-x86_64 --kickstart=/var/lib/cobbler/kickstarts/CentOS-7-x86_64.cfg
CentOS-7-x86_64.cfg配置文件如下:
# Kickstart Configurator for cobbler by Helis_Zhangshuai
# platform=x86, AMD64, or Intel EM64T
# System language
lang en_US
# System keyboard
keyboard us
# System timezone
timezone Asia/Shanghai
#Root password
rootpw --iscrypted $default_password_crypted
# Use text mode install
text
# Install OS instead of upgrade
install
# Use network installation media
url --url=$tree
# System bootloader configuration
bootloader --location=mbr
# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart --all --initlabel
# Disk partitioning information
part /boot --fstype xfs --size 200 --ondisk sda
part swap --size 1024 --ondisk sda
part / --fstype xfs --size 1 --grow --ondisk sda
# System authorization information
auth --useshadow --enablemd5
# Network information
$SNIPPET('network_config')
# network --bootproto=dhcp --device=eml --onboot=on
# Reboot after installation
reboot
# Firewall configuration
firewall --disabled
# SELinux configuration
selinux --disabled
# Do not configure the X Window System
skipx
#Package install information
%pre
$SNIPPET('log_ks_pre')
$SNIPPET('kickstart_start')
$SNIPPET('pre_install_network_config')
# Enable installation monitoring
$SNIPPET('pre_anamon')
%end
%packages
@ base
@ core
lrzsz
wget
ntp
rsync
unzip
iotop
sysstat
net-tools
tree
vim
bash-completion
nc
nmap
telnet
bc
lsof
ncurses-devel
openssl-devel
zlib-devel
OpenIPMI-tools
screen
iptraf
python-devel
%end
%post
systemctl disable postfix.service
%end
4.5需要安装系统时修改内核参数(如centos7安装时修改网卡名字为eth0)
cobbler profile edit --name=CentOS-7-x86_64 --kopts='net.ifnames=0 biosdevname=0'
即可修改默认网卡名为eth0
5、测试cobbler是否搭建成功
新建一台虚拟机,注意!注意!注意!内存一定要大于等于2G以上,要不就等着dracut-initqueue[1033或1068或xxxx]报错吧!!!顺利的话你会看到如下界面:选择CentOS-7-x86_64即可安装,可能安装会有点慢,等等就好!
6、客户端需要重新安装
6.1可以先查看cobbler服务中可以重装的系统(需要koan命令)
[root@default cobbler]# yum install -y koan
[root@default cobbler]# koan --server=10.0.0.200 --list=profiles
- looking for Cobbler at http://10.0.0.200:80/cobbler_api
CentOS-7-x86_64
[root@localhost ~]# koan --replace-self --server=10.0.0.200 --profile=CentOS-7-x86_64
- looking for Cobbler at http://10.0.0.200:80/cobbler_api
- reading URL: http://10.0.0.200/cblr/svc/op/ks/profile/CentOS-7-x86_64
install_tree: http://10.0.0.200/cblr/links/CentOS-7-x86_64
downloading initrd initrd.img to /boot/initrd.img_koan
url=http://10.0.0.200/cobbler/images/CentOS-7-x86_64/initrd.img
- reading URL: http://10.0.0.200/cobbler/images/CentOS-7-x86_64/initrd.img
downloading kernel vmlinuz to /boot/vmlinuz_koan
url=http://10.0.0.200/cobbler/images/CentOS-7-x86_64/vmlinuz
- reading URL: http://10.0.0.200/cobbler/images/CentOS-7-x86_64/vmlinuz
- ['/sbin/grubby', '--add-kernel', '/boot/vmlinuz_koan', '--initrd', '/boot/initrd.img_koan', '--args', '"ksdevice=link lang= text net.ifnames=0 ks=http://10.0.0.200/cblr/svc/op/ks/profile/CentOS-7-x86_64 biosdevname=0 kssendmac "', '--copy-default', '--make-default', '--title=kick1561881173']
- ['/sbin/grubby', '--update-kernel', '/boot/vmlinuz_koan', '--remove-args=root']
- reboot to apply changes
#reboot重启就可以进行一键重装系统了!
7、cobbler服务web管理界面
7.1安装环境依赖
Django版本需要较高,这里安装Django==1.8.9,使用python的pip进行安装;
首先安装配置阿里源,安装python-pip和python-devel软件,并升级pip,最后安装Django-1.8.9
[root@default cobbler]# mkdir -p /root/.pip
[root@default cobbler]# cat >~/.pip/pip.conf <<EOF
[global]
index-url = http://mirrors.aliyun.com/pypi/simple/
[install]
trusted-host=mirrors.aliyun.com
EOF
[root@default cobbler]# yum -y install python-pip python-devel
[root@default cobbler]# pip install --upgrade pip
[root@default cobbler]# pip install Django==1.8.9
然后就可以打开cobbler管理界面https://10.0.0.200/cobbler_web/
默认登录账户密码均为cobbler,全英文我相信你的英语水平!
8、修改安装界面提示
[root@default cobbler]# vim /etc/cobbler/pxe/pxedefault.template
DEFAULT menu
PROMPT 0
MENU TITLE Cobbler By Helis_Zhangshuai| https://garba.cn
TIMEOUT 200
TOTALTIMEOUT 6000
ONTIMEOUT $pxe_timeout_profile
LABEL local
MENU LABEL (local)
MENU DEFAULT
LOCALBOOT -1
$pxe_menu_items
MENU end
BTC:3LD8DBk5nZSwmGoF1mvM12Pp5YqNFEvfLA
ETH:0xAD765200e7Feb98a2AF262387A41F078e9F91eAc