今天研究了下cobbler,发现挺不错的,可以节省大量的时间,cobbler的内容有点多,也是我研究的自动化的主要部分之一,以后可能会继续总结吧。
为了避免大家安装出现问题,我现在再重新部署一遍
在虚拟机里面做实验,所以我考虑用host-only或vmnet自定义网络,这样没有其他的干扰,这里以host-only为例进行测试
为了简单,我设置cobbler网卡为桥接,ip为108.108.108.75,能上网
1 配置源
[root@localhost ~]# cd /etc/yum.repos.d [root@localhost yum.repos.d]# rename .repo .repo.bak * [root@localhost yum.repos.d]# wget mirrors.aliyun.com/repo/{Centos-6.repo,epel-6.repo}
1 下载cobbler组件
[root@localhost yum.repos.d]# yum -y install cobbler cobbler-web
2 初始化cobbler的配置
[root@localhost yum.repos.d]# 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. 注:这里对应着修改setting的server 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. 注:这里对应着修改setting的next_server(tftp服务器的位置) 3 : change ‘disable‘ to ‘no‘ in /etc/xinetd.d/tftp 注:让tftp可以启动,并被xinetd管理 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. 注:增加一些基本的引导内核的文件用于pxe引导,这一步很关键 5 : change ‘disable‘ to ‘no‘ in /etc/xinetd.d/rsync 注:让rsync可以启动,并被xinetd管理 6 : reposync is not installed, need for cobbler reposync, install/upgrade yum-utils? 注:暂时忽略该错误 7 : debmirror package is not installed, it will be required to manage debian deployments and repositories 注:配置debmirror 8 : ksvalidator was not found, install pykickstart 注:需要安装改组件 9 : 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 注:修改密码 10 : 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.
2.1 2.2 2.9
cd /etc/cobbler [root@localhost cobbler]# sed -i ‘s#^server:.*#server: 108.108.108.75#‘ settings [root@localhost cobbler]# sed -i ‘s#^next_server:.*#next_server: 108.108.108.75#‘ settings [root@localhost cobbler]# sed -i ‘s#pxe_just_once: 0#pxe_just_once: 1#‘ settings [root@localhost cobbler]# openssl passwd -1 -salt ‘random‘ ‘liuliancao‘ $1$random$6Q6tvl/J2PV1qhkZfN3cK/ [root@localhost cobbler]# sed -i ‘s#default_password_crypted:.*#default_password_crypted: "$1$random$6Q6tvl/J2PV1qhkZfN3cK/"#‘ settings
2.3 2.5
[root@localhost cobbler]# sed -i ‘s#disable.*#disable = no#‘ /etc/xinetd.d/tftp [root@localhost cobbler]# sed -i ‘s#disable.*#disable = no#‘ /etc/xinetd.d/rsync
2.4 多次执行如下命令直至成功
[root@localhost cobbler]# cobbler get-loaders
2.8 2.7 2.10
[root@localhost cobbler]# yum -y install pykickstart cman debmirror
好吧,终于差不多了
3 配置外部dhcp
[root@localhost cobbler]# yum -y install dhcp [root@localhost cobbler]# cp /usr/share/doc/dhcp-4.1.1/dhcpd.conf.sample /etc/dhcp/dhcpd.conf cp:是否覆盖"/etc/dhcp/dhcpd.conf"? y [root@localhost cobbler]# cat /etc/dhcp/dhcpd.conf # dhcpd.conf # # Sample configuration file for ISC dhcpd # # option definitions common to all supported networks... option domain-name "liuliancao.com"; option domain-name-servers ns1.liuliancao.com; default-lease-time 600; max-lease-time 7200; # Use this to enble / disable dynamic dns updates globally. #ddns-update-style none; # If this DHCP server is the official DHCP server for the local # network, the authoritative directive should be uncommented. #authoritative; # Use this to send dhcp log messages to a different log file (you also # have to hack syslog.conf to complete the redirection). log-facility local7; subnet 108.108.108.0 netmask 255.255.255.0 { range 108.108.108.76 108.108.108.77; option routers 108.108.108.75; } # 下面重要 next_server="108.108.108.75"; filename="pxelinux.0"; [root@localhost cobbler]# service dhcpd start Starting dhcpd: [ OK ]
4 准备kickstart文件
网上有,自己也可以根据图形化界面定制
[root@localhost cobbler]# cat /var/lib/cobbler/kickstarts/Centos-basic.ks # Kickstart file automatically generated by anaconda. #version=DEVEL install url --url="http://108.108.108.75/cobbler/ks_mirror/Centos-6.4-X86_64" lang en_US.UTF-8 keyboard us network --onboot yes --device eth0 --bootproto static --ip 60.60.60.13 --netmask 255.255.255.0 --gateway 60.60.60.1 --noipv6 --nameserver 202.98.192.67 --hostname cobbler rootpw --iscrypted $default_password_crypted firewall --service=ssh authconfig --enableshadow --passalgo=sha512 selinux --enforcing timezone --utc Asia/Chongqing bootloader --location=mbr --driveorder=sda --append="crashkernel=auto rhgb quiet" # The following is the partition information you requested # Note that any partitions you deleted are not expressed # here so unless you clear all partitions first, this is # not guaranteed to work #clearpart --all --drives=sda --initlabel zerombr clearpart --all --initlabel ignoredisk --only-use=sda part /boot --fstype=ext4 --size=200 part /swap --fstype=ext4 --size=10240 part / --fstype=ext4 --size=38912 #part pv.008002 --grow --size=200 #volgroup vg_cobbler --pesize=4096 pv.008002 #logvol swap --name=LogVol00 --vgname=vg_auto --size=10240 #logvol / --fstype=ext4 --name=LogVol01 --vgname=vg_auto --size=38912 #repo --name="CentOS" --baseurl=cdrom:sr0 --cost=100 %packages @base @console-internet @core @debugging @directory-client @hardware-monitoring @java-platform @large-systems @network-file-system-client @performance @perl-runtime @server-platform @server-policy pax oddjob sgpio device-mapper-persistent-data samba-winbind certmonger pam_krb5 krb5-workstation perl-DBD-SQLite %end 导入内核等,说白了就是放到httpd上供使用,此时也会生成一个基于basicks的profile [root@localhost ~]# service xinetd start [root@localhost ~]# service httpd restart [root@localhost ~]# service cobblerd restart [root@localhost ~]# cobbler import --name=‘Centos-6.4-x86_64‘ --path=/media --kickstart=/var/lib/cobbler/kickstarts/ [root@localhost ~]# cobbler sync
然后可以web界面上看看
用户名密码cobbler/cobbler
最后的测试
vmware新建一个虚拟机,选择等会安装
如果是PXE-not found等
那么首先
1 检查你的新的虚拟机网卡是不是bridge,就是在同一个网段
2 检查你的服务是否真的启动起来了,尤其是tftp,dhcpd
大致是这样,大家可能有很多问题,耐心解决就行了。
本文出自 “启学的学习之路” 博客,请务必保留此出处http://qixue.blog.51cto.com/7213178/1732259
cobbler初探------实现自动安装centos6.4
原文:http://qixue.blog.51cto.com/7213178/1732259