网络安装服务器套件 Cobbler(补鞋匠)从前,我们一直在做装机民工这份很有前途的职业。自打若干年前 Red Hat 推出了 Kickstart,此后我们顿觉身价倍增。不再需要刻了光盘一台一台地安装 Linux,只要搞定 PXE、DHCP、TFTP,还有那满屏眼花缭乱不知所云的 Kickstart 脚本,我们就可以像哈里波特一样,轻点魔棒,瞬间安装上百台服务器。这一堆花里胡哨的东西可不是一般人都能整明白的,没有大专以上学历,通不过英语四级, 根本别想玩转。总而言之,这是一份多么有前途,多么有技术含量的工作啊。很不幸,Red Hat 最新(Cobbler项目最初在2008年左右发布)发布了网络安装服务器套件 Cobbler(补鞋匠),它已将 Linux 网络安装的技术门槛,从大专以上文化水平,成功降低到初中以下,连补鞋匠都能学会。对于我们这些在装机领域浸淫多年,经验丰富,老骥伏枥,志在千里的民工兄弟们来说,不啻为一个晴天霹雳。
下面演示cobbler的安装
[root@cobbler ~]# yum install cobbler cobbler-web dhcp tftp-server pykickstart httpd -y
重新启动apache
[root@cobbler ~]#/etc/init.d/httpd restart
启动cobbler
[root@cobbler ~]# /etc/init.d/cobblerd start [root@cobbler ~]# /etc/init.d/cobblerd restart
检查安装条件
[root@cobbler ~]#cobbler check
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 : change ‘disable‘ to ‘no‘ in /etc/xinetd.d/rsync 6 : file /etc/xinetd.d/rsync does not exist 7 : debmirror package is not installed, it will be required to manage debian deployments and repositories 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
以上问题基本上需要解决了才能安装
vi /etc/cobbler/settings
server: 10.89.1.15 (修改为你这台安装cobbler的机器)
next_server: 10.89.1.15 (修改为你这台安装cobbler的机器)
manage_dhcp: 1 (“0”修改为“1”)
default_password_crypted: "$1$oldboy$fXF8f078vI9J/q9XyXA8e/"
注意:以上密码是使用下面的命令生成的
[root@cobbler ~]# openssl passwd -1 -salt ‘oldboy‘ ‘oldboy‘ $1$oldboy$fXF8f078vI9J/q9XyXA8e/
[root@cobbler ~]#cobbler get-loaders
vim /etc/xinetd.d/rsync
disable = no
vim /etc/xinetd.d/tftp
disable = no
重新启动一下服务
[root@cobbler ~]# /etc/init.d/xinetd restart Stopping xinetd: [ OK ] Starting xinetd: [ OK ] [root@cobbler ~]# /etc/init.d/cobblerd restart Stopping cobbler daemon: [ OK ] Starting cobbler daemon: [ OK ]
[root@cobbler ~]# vim /etc/cobbler/dhcp.template
此处修改为你的cobbler服务器所在的网段信息
subnet 10.89.1.0 netmask 255.255.255.0 {
option routers 10.89.1.254; (网关地址)
option domain-name-servers 10.7.10.1; (DNS地址)
option subnet-mask 255.255.255.0; (子网掩码)
range dynamic-bootp 10.89.1.100 10.89.1.119;(DHCP自动给机器分配的ip范围)
default-lease-time 21600;
max-lease-time 43200;
next-server $next_server;
[root@cobbler ~]#cobbler check
1.service dhcpd is not running
解决办法
Restart cobblerd and then run ‘cobbler sync‘ to apply changes.
#/etc/init.d/cobblerd restart
#cobbler sync
2.file /etc/xinetd.d/rsync does not exist
这个问题可以不用管,最后在检查一下安装环境
[root@cobbler kickstarts]# cobbler check The following are potential configuration items that you may want to fix: 1 : file /etc/xinetd.d/rsync does not exist 2 : debmirror package is not installed, it will be required to manage debian deployments and repositories 3 : fencing tools were not found, and are required to use the (optional) power management features. install cman or fence-agents to use them
出现上面的信息就可以安装了
以下以安装一台虚拟机为例
本机先挂载镜像包
[root@cobbler ~]#mount /dev/cdrom /mnt
导入镜像包
[root@cobbler ~]#cobbler import --path=/mnt/ --name=CentOS-7.3-x86_64 --arch=x86_64
导入后镜像包位于
[root@cobbler ~]# cd /var/www/cobbler/ks_mirror/ [root@cobbler ks_mirror]# ll total 8 drwxr-xr-x 8 root root 4096 Dec 5 21:20 CentOS-7.3-x86_64 drwxr-xr-x 2 root root 4096 Apr 5 15:20 config配置
KS文件放置位置
[root@cobbler ks_mirror]# cd /var/lib/cobbler/kickstarts/
上传KS配置文件 CentOS-7.3-x86_64.cfg (**文件中的登录用户名:root 密码:oldboy**)
#cat CentOS-7.3-x86_64.cfg
#Kickstart Configurator by Alvin #platform =x86, AMD64, or Inter EM64T #System language lang en_US #System keyboard keyboard us #System timezone timezone Asia/Shanghai #Root password rootpw --iscrypted $default_password_crypted #rootpw --iscrypted $1$ops-node$7hqdpgEmIE7Z0RbtQkxW20 #Use text mode install text #Install OS instead of upgrade install #User NFS installation Media url --url=$tree #url --url=http://192.168.8.22/CentOS-7.1-x86_64 #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 information auth --useshadow --enablemd5 #Network information $SNIPPET(‘network_config‘) #network --bootproto=dhcp --device=eth0 --onboot=on # Reboot after installation reboot #Firewall configuration firewall --disabled #SELinux configuration selinux --disabled #Do not configure XWindows skipx %pre $SNIPPET(‘log_ks_pre‘) $SNIPPET(‘kickstart_start‘) $SNIPPET(‘pre_install_network_config‘) #Enable installation monitoring $SNIPPET(‘pre_anamon‘) %end #Package install information %packages @ base @ core sysstat iptraf ntp lrzsz openssl-devel zlib-devel OpenIPMI-tools nmap screen %end %post systemctl disable postfix.service %end
[root@cobbler kickstarts]# cobbler profile edit --name=CentOS-7.3-x86_64 --kickstart=/var/lib/cobbler/kickstarts/CentOS-7.3-x86_64.cfg [root@cobbler kickstarts]# cobbler profile edit --name=CentOS-7.3-x86_64 --kopts=‘net.ifnames=0 biosdevname=0‘ [root@cobbler ~]# cobbler sync
设置待安装机器的ip,网关,dns 等信息
[root@cobbler ~]# cobbler system add --name=alvin --mac=00:50:56:32:4E:C7 --profile=CentOS-7.3-x86_64 --ip-address=10.89.1.113 --subnet=255.255.255.0 --gateway=10.89.1.254 --interface=eth0 --static=1 --hostname=kk.com --name-servers="8.8.8.8"
注意:网卡地址mac是待安装机器
下面开始安装客户端电脑
待安装的机器开机
进入bios设置待安装的电脑从网卡启动
开始自动安装
本文出自 “知识改变命运” 博客,请务必保留此出处http://ahtornado.blog.51cto.com/4826737/1917522
原文地址:http://ahtornado.blog.51cto.com/4826737/1917522