百度中cobbler的简介:
从前,我们一直在做装机民工这份很有前途的职业。自打若干年前 Red Hat 推出了 Kickstart,此后我们顿觉身价倍增。不再需要刻了光盘一台一台地安装 Linux,只要搞定 PXE、DHCP、TFTP,还有那满屏眼花缭乱不知所云的 Kickstart 脚本,我们就可以像哈里波特一样,轻点魔棒,瞬间安装上百台服务器。这一堆花里胡哨的东西可不是一般人都能整明白的,没有大专以上学历,通不过英语四级, 根本别想玩转。总而言之,这是一份多么有前途,多么有技术含量的工作啊。很不幸,Red Hat 最新(Cobbler项目最初在2008年左右发布)发布了网络安装服务器套件 Cobbler(补鞋匠),它已将 Linux 网络安装的技术门槛,从大专以上文化水平,成功降低到初中以下,连补鞋匠都能学会。对于我们这些在装机领域浸淫多年,经验丰富,老骥伏枥,志在千里的民工兄弟们来说,不啻为一个晴天霹雳。
对于没有大专以上学历,没有英语四级的,从事着IT民工的我来说,有必要去学一学cobbler,或许对以后能从事Linux相关工作很有帮助。由于没有相应的条件,以下操作步骤只在VM虚拟环境下实现。
测试环境:CentOS 5.5 x86_64 关闭iptables、selinux
软件: cobbler.noarch 0:2.0.11-2.el5
一、 安装相关软件:
[root@cobbler ~]# rpm -ivh http://dl.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm
[root@cobbler ~]# yum -y install cobbler dhcp httpd xinetd tftp-server
[root@cobbler ~]# chkconfig xinetd on
[root@cobbler ~]# chkconfig httpd on
[root@cobbler ~]# chkconfig cobblerd on
[root@cobbler ~]# chkconfig dhcpd on
二、修改配置文件
DHCP配置
[root@cobbler ~]# vim /etc/cobbler/dhcp.template
- subnet 192.168.209.0 netmask 255.255.255.0 {
- option routers 192.168.209.128;
- option domain-name-servers 192.168.209.128;
- option subnet-mask 255.255.255.0;
- range dynamic-bootp 192.168.209.200 192.168.209.254;
- filename "/pxelinux.0";
- default-lease-time 21600;
- max-lease-time 43200;
- next-server $next_server;
- }
修改DHCP分配的信息,这里不需要修改/etc/dhcpd.conf,因为DHCP会由cobbler接管。
cobbler配置,修改/etc/cobbler/settings
找到:
manage_dhcp: 0
next_server: 127.0.0.1
server: 127.0.0.1
修改为:
- manage_dhcp: 1
- next_server: 192.168.209.129
- server: 192.168.209.129
server和next_server修改为本服务器的IP 地址,manage_dhcp 设为 1,接管DHCP
tftp配置
[root@cobbler ~]# vim /etc/xinetd.d/tftp
- service tftp
- {
- socket_type = dgram
- protocol = udp
- wait = yes
- user = root
- server = /usr/sbin/in.tftpd
- server_args = -s /tftpboot
- disable = no
- per_source = 11
- cps = 100 2
- flags = IPv4
- }
rsync配置
[root@cobbler ~]# vim /etc/xinetd.d/rsync
- service rsync
- {
- disable = no
- socket_type = stream
- wait = no
- user = root
- server = /usr/bin/rsync
- server_args = --daemon
- log_on_failure += USERID
- }
将tftp和tftp的配置文件中的disable = yes改成disable = no
三、启动相关服务,检查错误并解决问题
[root@cobbler ~]# /etc/init.d/xinetd start
[root@cobbler ~]# /etc/init.d/httpd start
[root@cobbler ~]# /etc/init.d/cobblerd start
[root@cobbler ~]# cobbler sync
[root@cobbler ~]# cobbler check
The following are potential configuration items that you may want to fix:
1 : 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.
2 : debmirror package is not installed, it will be required to manage debian deployments and repositories
3 : 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
4 : 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.提示缺少网络引导操作系统的必须文件
[root@cobbler ~]# cobbler get-loaders
2.安装debian仓库,可忽略
[root@cobbler ~]# yum -y install debmirror
注释/etc/debmirror.conf 两行
#@dists="sid";
#@arches="i386";
3.默认的cobbler用户密码简单,需要更改密码
[root@cobbler ~]# openssl passwd -1 -salt 'afdafdsafsf' '2edhaT1#abc'
$1$afdafdsa$JGwxphdqy7Omr3aU0W5Kz0
生成密码,命令格式:openssl passwd -1 -salt '任意字母' '你的密码'
[root@cobbler ~]# vim /etc/cobbler/settings
default_password_crypted: "$1$afdafdsa$JGwxphdqy7Omr3aU0W5Kz0"
用生成的密码修改/etc/cobbler/settings中的默认密码
4.电源管理功能
[root@cobbler ~]# yum -y install cman
修复完成以上问题后,同步信息再检查
[root@cobbler ~]# cobbler sync
[root@cobbler ~]# /etc/init.d/cobblerd restart
[root@cobbler ~]# cobbler check
No configuration problems found. All systems go.
四、导入操作系统的ISO镜像文件(导入后/var/www/cobbler/ks_mirror/)
[root@cobbler ~]# mount -o loop /var/ftp/upload/CentOS.iso /media/
[root@cobbler ~]# cobbler import --path=/media --name=CentOS-5.5-x86_64
参数:--path=挂载ios的路径,--name名称(可随意)
查看
[root@cobbler ~]# cobbler distro list
CentOS-5.5-x86_64
CentOS-5.5-xen-x86_64
五、 Kickstart 配置模板,可通过安装图形界面的kickstart生成
[root@cobbler ~]# cd /var/lib/cobbler/kickstarts/
[root@cobbler kickstarts]# mv sample.ks sample.ks.bak
[root@cobbler kickstarts]# vim sample.ks
- #platform=x86, AMD64, or Intel EM64T
- # System authorization information
- auth --useshadow --enablemd5
- # System bootloader configuration
- bootloader --location=mbr
- # Clear the Master Boot Record
- zerombr
- # Partition clearing information
- clearpart --all --initlabel
- # Use text mode install
- text
- # Firewall configuration
- firewall --disabled
- # Run the Setup Agent on first boot
- firstboot --disable
- # System keyboard
- keyboard us
- # System language
- lang en_US
- # Installation logging level
- logging --level=info
- # Use network installation
- url --url=http://192.168.209.129/cobbler/ks_mirror/CentOS-5.5-x86_64
- # Network information
- network --bootproto=dhcp --device=eth0 --onboot=on
- # Reboot after installation
- reboot
- #Root password
- rootpw --iscrypted $1$36bsCbH1$UDJ6eCqPi2Nm1KsgajvHs1
-
- # SELinux configuration
- selinux --disabled
- # Do not configure the X Window System
- skipx
- # System timezone
- timezone --isUtc Asia/Shanghai
- # Install OS instead of upgrade
- install
- # Disk partitioning information
- part / --bytes-per-inode=4096 --fstype="ext3" --size=10000
- part swap --bytes-per-inode=4096 --size=2048
- part /data --bytes-per-inode=4096 --fstype="ext3" --grow --size=1
- part /boot --bytes-per-inode=4096 --fstype="ext3" --size=100
-
- %packages
- @base
- @development-libs
- @development-tools
- @core
- @text-internet
- @editors
- keyutils
- trousers
- fipscheck
- device-mapper-multipath
- imake
- ntp
可以通过使用浏览器查看ks的配置信息:http://192.168.209.129/cblr/svc/op/ks/profile/CentOS-5.5-x86_64
默认情况下cobbler安装操作系统时使用的kickstart文件是var/lib/cobbler/kickstarts/sample.ks
可以使用以下命令修改指定使用指定的kickstart文本
cobbler profile edit --name=centos5.5 --distro=CentOS-5.5-test-x86_64 --kickstart=/var/lib/cobbler/kickstarts/centos.ks
六、测试