Cobbler简介
Cobbler是一个快速网络安装linux的服务,而且在经过调整也可以支持网络安装windows。该工具使用python开发,小巧轻便(才15k行python代码),使用简单的命令即可完成PXE网络安装环境的配置,同时还可以管理DHCP、DNS、TFTP、RSYNC以及yum仓库、构造系统ISO镜像。 Cobbler支持命令行管理,web界面管理,还提供了API接口,可以方便二次开发使用。 Cobbler客户端Koan支持虚拟机安装和操作系统重新安装,同时支持服务器的电源管理,使重装系统更便捷。更多内容可以查看cobbler官方网站!
cobbler官方网站:http://cobbler.github.io/
本人使用CentOS7安装,版本如下:
[root@cobbler ~]# cat /etc/redhat-release
CentOS Linux release 7.6.1810 (Core)
[root@cobbler ~]# uname -r
3.10.0-957.5.1.el7.x86_64
[root@cobbler ~]#
1.安装epel源
[root@cobbler ~]# rpm -ivh http://mirrors.aliyun.com/epel/epel-release-latest-7.noarch.rpm
2.yum安装cobbler
[root@cobbler ~]# yum install -y httpd dhcp tftp cobbler cobbler-web pykickstart
可能由于网络原因。有部分依赖无法一次性下载,多试几次
cobbler是通过Apache来提供服务的
3.启动apache
systemctl start httpd
systemctl enable httptd
systemctl start cobblerd
systemctl enable cobblerd
4.检查需要进行的配置
[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 kick▽tarting 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)修改/etc/cobbler/settings文件中的server参数的值为提供cobbler服务的主机相应的IP地址或主机名;
sed -i 's/server: 127.0.0.1/server: 10.0.0.16/' /etc/cobbler/settings;
sed -i 's/next_server: 127.0.0.1/next_server: 10.0.0.16/' /etc/cobbler/settings
2)修改/etc/xinetd.d/tftp文件中的disable参数修改为 disable = no
3)执行 cobbler get-loaders 命令即可;否则,需要安装syslinux程序包,而后复制/usr/share/syslinux/{pxelinux.0,memu.c32}等文件至/var/lib/cobbler/loaders/目录中;
4)执行 systemctl enable rsyncd命令即可;
5)执行yum -y install debmirror,然后注释/etc/dedmirror.conf文件中的 @dists=”sid”; @arches=”i386”;
6)生成登录密码
[root@cobbler ~]# openssl passwd -1 -salt 'oldboy' '123456'
$1$oldboy$Npg9Pt9k98Mlg0ZeqHAuN1
替换/etc/cobbler/setting内的default_password_crypted
7)执行yum -y install fence-agents,然后重启systemctl restart cobblerd
5.然后在执行cobbler check看有没有要操作的任务
[root@cobbler ~]# cobbler check
No configuration problems found. All systems go.
提示没有可进行的配置啦!到此cobbler完成
6.接下来要让cobbler管理DHCP
[root@cobbler ~]# vim /etc/cobbler/settings
242行 manage_dhcp: 1 #将dhcp 0修改为1表示管理dhcp
7.修改DHCP模板文件(可以根据自己的虚拟机配置来配)
只列出修改的部分
subnet 10.0.0.0 netmask 255.255.255.0 {
option routers 10.0.0.1; 网关
option domain-name-servers 10.0.0.1; DNS配置
option subnet-mask 255.255.255.0; 子网掩码
range dynamic-bootp 10.0.0.100 10.0.0.200; 分配的ip区间
default-lease-time 21600;
max-lease-time 43200;
next-server $next_server;
8.修改完之后,重启服务
systemctl restart cobblerd
使用cobbler sync 生成dhcp模板,自动帮我们重启dhcp
cobbler sync 表示刷新,其实就是删除原来的文件,从新进行加载
10.挂载镜像
[root@cobbler ~]# mount /dev/cdrom /mnt/
mount: /dev/sr0 is write-protected, mounting read-only
11.制作镜像,用于安装操作系统,使cobbler导入镜像
cobbler import --path=/mnt/ --name=CentOS-7-x86_64 --arch=x86_64
12.使用cobbler profile list查看当前有几个镜像
13.上传cfg文件(上传到/var/lib/cobbler/kickstartsxia下),这里我已经上传,内容如下:
cat CentOS-7-x86_64.cfg
#Kickstart Configurator for cobbler by Jason Zhao
#platform=x86, AMD64, or Intel EM64T
#System language
lang en_US
#System keyboard
keyboard us
#Sytem timezone
timezone Asia/Shanghai
#Root password
rootpw --iscrypted $default_password_crypted
#Use text mode install
text
#Install OS instead of upgrade
install
#Use NFS 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 1024 --ondisk sda
part swap --size 16384 --ondisk sda
part / --fstype xfs --size 1 --grow --ondisk sda
#System authorization infomation
auth --useshadow --enablemd5
#Network information
$SNIPPET('network_config')
#network --bootproto=dhcp --device=em1 --onboot=on
# Reboot after installation
reboot
#Firewall configuration
firewall --disabled
#SELinux configuration
selinux --disabled
#Do not configure XWindows
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
sysstat
iptraf
ntp
lrzsz
ncurses-devel
openssl-devel
zlib-devel
OpenIPMI-tools
mysql
nmap
screen
%end
%post
systemctl disable postfix.service
%end
14.执行命令,修改kickstarts
cobbler profile edit --name=CentOS-7-x86_64 --kickstart=/var/lib/cobbler/kickstarts/CentOS-7-x86_64.cfg
15.因为Centos7 默认的网卡不在/etc/init.d/network
所以我们需要修改内核
cobbler profile edit --name=CentOS-7-x86_64 --kopts='net.ifnames=0 biosdevname=0'
16.查看kickstart
cobbler profile report
17.执行cobbler sync会删除原来的文件,相当于从新进行加载
18.安装xinted
yum install xinetd -y
systemctl start xinetd
systemctl enable xinetd
19.然后新建虚拟机(记得要把httpd,dhcpd,tftp,cobblerd等服务开启,要不会获取不到IP地址等错误)
内存一定要比服务端的内存大,要不安装的时候会报错内存溢出!!!
这里选择------否
接下下就可以看到镜像了!!!
然后选择,就可以进行安装啦~~~过程有点长^-^
转载于:https://blog.51cto.com/14219014/2399057