首页 > 代码库 > cobbler安装(详细版)
cobbler安装(详细版)
1、系统环境
centos-6.4
ipaddr: 10.240.240.114 gateway:10.240.240.1
2、关闭selinux (关闭完之后最好进行一次重启)
sed -i ‘/SELINUX/s/enforcing/disabled/‘ /etc/selinux/config
关闭防火墙
chkconfig iptables off
3、 配置obbler yum源
rpm -Uvh ‘http://mirrors.ustc.edu.cn/epel/6/i386/epel-release-6-8.noarch.rpm‘
4、安装Cobbler基础包
yum install -y cobbler tftp dhcp httpd cman pykickstart debmirror
5、安装Cobbler依赖包
yum install -y ed patch perl perl-Compress-Zlib perl-Digest-SHA1 perl-LockFile-Simple perl-libwww-perl
6、将基础的服务配置成开机自启动
chkconfig httpd on
chkconfig dhcpd on
chkconfig xinetd on
chkconfig cobblerd on
7、修改httpd配置文件并启动httpd
vim /etc/httpd/conf/httpd.conf
ServerName 127.0.0.1:80
启动httpd进程
service httpd start
查看http进程启动情况
netstat -ntulp | grep :80
8、启动Cobbler服务并执行检查命令
[root@localhost ~]# service cobblerd start
Starting cobbler daemon: [ OK ]
[root@localhost ~]# 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 : 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.
4 : change ‘disable‘ to ‘no‘ in /etc/xinetd.d/rsync
5 : comment out ‘dists‘ on /etc/debmirror.conf for proper debian support
6 : comment out ‘arches‘ on /etc/debmirror.conf for proper debian support
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
Restart cobblerd and then run ‘cobbler sync‘ to apply changes.
修改上面错误的方法如下:
(1).错误1,修改/etc/cobbler/settings 里面的 server 为Cobbler Server的IP地址 ;
[root@localhost ~] vim /etc/cobbler/settings
server: 10.240.240.114
(2).错误2,修改/etc/cobbler/settings 里面的 next_serverw 为本机的 ip;
[root@localhost ~] vim /etc/cobbler/settings
next_server: 10.240.240.114
(3).错误3,据说这个错误可以忽略,有强迫完美运行症的人士可以运行以下命令来解决;
[root@localhost ~]cobbler get-loaders
(4).错误4,修改/etc/xinetd.d/tftp 把‘disable‘ 修改为‘no‘;修改/etc/xinetd.d/rsync 把‘disable‘ 修改为‘no‘;
[root@localhost ~]# vim /etc/xinetd.d/tftp
disable = no
[root@localhost ~]# vim /etc/xinetd.d/rsync
disable = no
再次启动xinetd服务。
[root@localhost ~]# service xinetd start
正在启动 xinetd: [确定]
(5).错误5与错误6,debmmirror有错误;
[root@localhost ~]# vim /etc/debmirror.conf
#注释掉@dists="sid"与@arches="i386即可
#@dists="sid";
#@arches="i386";
(6).错误7,设置默认root密码;
注,刚接触Cobbler的博友会问,这个密码是什么密码。有的博友系统安装好了会问,root密码是什么。这里设置的就是客户端安装好系统的root密码。
注,生成你想要的密码的加密字符串,然后复制运行命令之后的加密代码;
[root@localhost ~]# openssl passwd -1 -salt ‘hahaha‘ ‘jiayuan.com‘
$1$hahaha$hSxFjZSHRoiEn4DYrrGUI.
注,然后替换/etc/cobbler/settings 中选项双引号中的加密代码;
[root@localhost ~]# vim /etc/cobbler/settings
default_password_crypted: "$1$hahaha$hSxFjZSHRoiEn4DYrrGUI."
9.重新启动Cobbler并运行检查命令
[root@localhost ~]# service cobblerd restart
Stopping cobbler daemon: [ OK ]
Starting cobbler daemon: [ OK ]
检查cobbler
[root@localhost ~]# cobbler check
No configuration problems found. All systems go.
10、修改DHCP模板
首先修改cobbler配置,让cobbler来管理dhcp服务,编辑文件/etc/cobbler/settings
manage_dhcp: 1
接下来修改/etc/cobbler/dhcp.template,此文件是cobbler管理dhcp的模板
[root@localhost ~]# vim /etc/cobbler/dhcp.template
subnet 10.240.240.0 netmask 255.255.255.0 {
option routers 10.240.240.1;
option domain-name-servers 10.240.210.98;
option subnet-mask 255.255.255.0;
range dynamic-bootp 10.240.240.220 10.240.240.240;
default-lease-time 21600;
max-lease-time 43200;
next-server $next_server;
11、执行一下同步操作并检查配置文件
[root@localhost ~]# cobbler sync
task started: 2014-05-13_054240_sync
task started (id=Sync, time=Tue May 13 05:42:40 2014)
running pre-sync triggers
cleaning trees
mkdir: /var/lib/tftpboot/pxelinux.cfg
mkdir: /var/lib/tftpboot/grub
mkdir: /var/lib/tftpboot/s390x
mkdir: /var/lib/tftpboot/ppc
mkdir: /var/lib/tftpboot/etc
removing: /var/lib/tftpboot/grub/images
copying bootloaders
trying hardlink /var/lib/cobbler/loaders/pxelinux.0 -> /var/lib/tftpboot/pxelinux.0
trying hardlink /var/lib/cobbler/loaders/menu.c32 -> /var/lib/tftpboot/menu.c32
trying hardlink /var/lib/cobbler/loaders/yaboot -> /var/lib/tftpboot/yaboot
trying hardlink /usr/share/syslinux/memdisk -> /var/lib/tftpboot/memdisk
trying hardlink /var/lib/cobbler/loaders/grub-x86_64.efi -> /var/lib/tftpboot/grub/grub-x86_64.efi
trying hardlink /var/lib/cobbler/loaders/grub-x86.efi -> /var/lib/tftpboot/grub/grub-x86.efi
copying distros to tftpboot
copying images
generating PXE configuration files
generating PXE menu structure
rendering TFTPD files
generating /etc/xinetd.d/tftp
cleaning link caches
running post-sync triggers
running python triggers from /var/lib/cobbler/triggers/sync/post/*
running python trigger cobbler.modules.sync_post_restart_services
running shell triggers from /var/lib/cobbler/triggers/sync/post/*
running python triggers from /var/lib/cobbler/triggers/change/*
running python trigger cobbler.modules.scm_track
running shell triggers from /var/lib/cobbler/triggers/change/*
*** TASK COMPLETE ***
再次检查cobbler没问题发现
[root@localhost ~]# cobbler check
No configuration problems found. All systems go.
12、把镜像挂载的目录
[root@localhost ~]# mkdir /mnt/cdrom
[root@localhost ~]# mount -o loop /dev/sr0 /mnt/cdrom/
[root@localhost ~]# cd /mnt/cdrom/
[root@localhost cdrom]# ls
EFI RELEASE-NOTES-as-IN.html RELEASE-NOTES-kn-IN.html RELEASE-NOTES-te-IN.html
EULA RELEASE-NOTES-bn-IN.html RELEASE-NOTES-ko-KR.html RELEASE-NOTES-zh-CN.html
GPL RELEASE-NOTES-de-DE.html RELEASE-NOTES-ml-IN.html RELEASE-NOTES-zh-TW.html
HighAvailability RELEASE-NOTES-en-US.html RELEASE-NOTES-mr-IN.html repodata
images RELEASE-NOTES-es-ES.html RELEASE-NOTES-or-IN.html ResilientStorage
isolinux RELEASE-NOTES-fr-FR.html RELEASE-NOTES-pa-IN.html RPM-GPG-KEY-redhat-beta
LoadBalancer RELEASE-NOTES-gu-IN.html RELEASE-NOTES-pt-BR.html RPM-GPG-KEY-redhat-release
media.repo RELEASE-NOTES-hi-IN.html RELEASE-NOTES-ru-RU.html ScalableFileSystem
Packages RELEASE-NOTES-it-IT.html RELEASE-NOTES-si-LK.html Server
README RELEASE-NOTES-ja-JP.html RELEASE-NOTES-ta-IN.html TRANS.TBL
13、cobbler导入镜像
[root@localhost ~]# cobbler import --path=/mnt/cdrom --name=Redhat-6.3 --arch=x86_64
task started: 2014-05-13_054601_import
task started (id=Media import, time=Tue May 13 05:46:01 2014)
Found a candidate signature: breed=redhat, version=rhel6
Found a matching signature: breed=redhat, version=rhel6
Adding distros from path /var/www/cobbler/ks_mirror/Redhat-6.3-x86_64:
creating new distro: Redhat-6.3-x86_64
trying symlink: /var/www/cobbler/ks_mirror/Redhat-6.3-x86_64 -> /var/www/cobbler/links/Redhat-6.3-x86_64
creating new profile: Redhat-6.3-x86_64
associating repos
checking for rsync repo(s)
checking for rhn repo(s)
checking for yum repo(s)
starting descent into /var/www/cobbler/ks_mirror/Redhat-6.3-x86_64 for Redhat-6.3-x86_64
processing repo at : /var/www/cobbler/ks_mirror/Redhat-6.3-x86_64
need to process repo/comps: /var/www/cobbler/ks_mirror/Redhat-6.3-x86_64
looking for /var/www/cobbler/ks_mirror/Redhat-6.3-x86_64/repodata/*comps*.xml
Keeping repodata as-is :/var/www/cobbler/ks_mirror/Redhat-6.3-x86_64/repodata
processing repo at : /var/www/cobbler/ks_mirror/Redhat-6.3-x86_64/Server
need to process repo/comps: /var/www/cobbler/ks_mirror/Redhat-6.3-x86_64/Server
looking for /var/www/cobbler/ks_mirror/Redhat-6.3-x86_64/Server/repodata/*comps*.xml
Keeping repodata as-is :/var/www/cobbler/ks_mirror/Redhat-6.3-x86_64/Server/repodata
processing repo at : /var/www/cobbler/ks_mirror/Redhat-6.3-x86_64/HighAvailability
need to process repo/comps: /var/www/cobbler/ks_mirror/Redhat-6.3-x86_64/HighAvailability
looking for /var/www/cobbler/ks_mirror/Redhat-6.3-x86_64/HighAvailability/repodata/*comps*.xml
Keeping repodata as-is :/var/www/cobbler/ks_mirror/Redhat-6.3-x86_64/HighAvailability/repodata
processing repo at : /var/www/cobbler/ks_mirror/Redhat-6.3-x86_64/LoadBalancer
need to process repo/comps: /var/www/cobbler/ks_mirror/Redhat-6.3-x86_64/LoadBalancer
looking for /var/www/cobbler/ks_mirror/Redhat-6.3-x86_64/LoadBalancer/repodata/*comps*.xml
Keeping repodata as-is :/var/www/cobbler/ks_mirror/Redhat-6.3-x86_64/LoadBalancer/repodata
processing repo at : /var/www/cobbler/ks_mirror/Redhat-6.3-x86_64/ResilientStorage
need to process repo/comps: /var/www/cobbler/ks_mirror/Redhat-6.3-x86_64/ResilientStorage
looking for /var/www/cobbler/ks_mirror/Redhat-6.3-x86_64/ResilientStorage/repodata/*comps*.xml
Keeping repodata as-is :/var/www/cobbler/ks_mirror/Redhat-6.3-x86_64/ResilientStorage/repodata
processing repo at : /var/www/cobbler/ks_mirror/Redhat-6.3-x86_64/ScalableFileSystem
need to process repo/comps: /var/www/cobbler/ks_mirror/Redhat-6.3-x86_64/ScalableFileSystem
looking for /var/www/cobbler/ks_mirror/Redhat-6.3-x86_64/ScalableFileSystem/repodata/*comps*.xml
Keeping repodata as-is :/var/www/cobbler/ks_mirror/Redhat-6.3-x86_64/ScalableFileSystem/repodata
*** TASK COMPLETE ***
查看cobbler列表
[root@localhost ~]# cobbler list
distros:
Redhat-6.3-x86_64
profiles:
Redhat-6.3-x86_64
systems:
repos:
images:
mgmtclasses:
packages:
files:
14、查看一下导入镜像的详细信息
[root@localhost ~]# cobbler report
distros:
==========
Name : Redhat-6.3-x86_64
Architecture : x86_64
TFTP Boot Files : {}
Breed : redhat
Comment :
Fetchable Files : {}
Initrd : /var/www/cobbler/ks_mirror/Redhat-6.3-x86_64/images/pxeboot/initrd.img
Kernel : /var/www/cobbler/ks_mirror/Redhat-6.3-x86_64/images/pxeboot/vmlinuz
Kernel Options : {}
Kernel Options (Post Install) : {}
Kickstart Metadata : {‘tree‘: ‘http://@@http_server@@/cblr/links/Redhat-6.3-x86_64‘}
Management Classes : []
OS Version : rhel6
Owners : [‘admin‘]
Red Hat Management Key : <<inherit>>
Red Hat Management Server : <<inherit>>
Template Files : {}
profiles:
==========
Name : Redhat-6.3-x86_64
TFTP Boot Files : {}
Comment :
DHCP Tag : default
Distribution : Redhat-6.3-x86_64
Enable gPXE? : 0
Enable PXE Menu? : 1
Fetchable Files : {}
Kernel Options : {}
Kernel Options (Post Install) : {}
Kickstart : /var/lib/cobbler/kickstarts/sample_end.ks
Kickstart Metadata : {}
Management Classes : []
Management Parameters : <<inherit>>
Name Servers : []
Name Servers Search Path : []
Owners : [‘admin‘]
Parent Profile :
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
systems:
==========
repos:
==========
images:
==========
mgmtclasses:
==========
packages:
==========
files:
==========
15、自定义kickstart文件
[root@localhost ~]# cd /var/lib/cobbler/kickstarts/
[root@localhost kickstarts]# vi redhat-6.3.ks (名字可以自己定义)
install
#nfs --server=10.240.240.210 --dir=/mnt/cdrom
text
key --skip
keyboard us
lang en_US.UTF-8
skipx
network --device eth0 --bootproto dhcp
rootpw root
firewall --disabled
authconfig --enableshadow --enablemd5
selinux --disabled
timezone --utc Asia/Shanghai
url --url=$tree #
$SNIPPET(‘network_config‘) #上面这两部特别重要,网络的安装路径,用变量表示。
bootloader --location=mbr --driveorder=sda
zerombr yes
clearpart --all
part /boot --fstype ext4 --size=200
part / --fstype ext4 --size=20000
part swap --fstype swap --size=8192
part /u01 --fstype ext4 --grow --size=200
reboot
%packages
@base
@core
@server-policy
ipmitool
OpenIPMI
openssh-clients
net-snmp
%post
16、将自定义的kickstart文件与镜像相关联
[root@localhost ~]# cobbler profile edit --name=Redhat-6.3-x86_64 --distro=Redhat-6.3-x86_64 --kickstart=/var/lib/cobbler/kickstarts/redhat-6.3.ks
[root@localhost ~]# cobbler report
17、同步一下cobbler
[root@localhost ~]# cobbler sync
task started: 2014-05-13_082354_sync
task started (id=Sync, time=Tue May 13 08:23:54 2014)
running pre-sync triggers
cleaning trees
removing: /var/www/cobbler/images/Redhat-6.3-x86_64
removing: /var/lib/tftpboot/pxelinux.cfg/default
removing: /var/lib/tftpboot/grub/efidefault
removing: /var/lib/tftpboot/grub/grub-x86_64.efi
removing: /var/lib/tftpboot/grub/images
removing: /var/lib/tftpboot/grub/grub-x86.efi
removing: /var/lib/tftpboot/images/Redhat-6.3-x86_64
removing: /var/lib/tftpboot/s390x/profile_list
copying bootloaders
trying hardlink /var/lib/cobbler/loaders/grub-x86_64.efi -> /var/lib/tftpboot/grub/grub-x86_64.efi
trying hardlink /var/lib/cobbler/loaders/grub-x86.efi -> /var/lib/tftpboot/grub/grub-x86.efi
copying distros to tftpboot
copying files for distro: Redhat-6.3-x86_64
trying hardlink /var/www/cobbler/ks_mirror/Redhat-6.3-x86_64/images/pxeboot/vmlinuz -> /var/lib/tftpboot/images/Redhat-6.3-x86_64/vmlinuz
trying hardlink /var/www/cobbler/ks_mirror/Redhat-6.3-x86_64/images/pxeboot/initrd.img -> /var/lib/tftpboot/images/Redhat-6.3-x86_64/initrd.img
copying images
generating PXE configuration files
generating PXE menu structure
copying files for distro: Redhat-6.3-x86_64
trying hardlink /var/www/cobbler/ks_mirror/Redhat-6.3-x86_64/images/pxeboot/vmlinuz -> /var/www/cobbler/images/Redhat-6.3-x86_64/vmlinuz
trying hardlink /var/www/cobbler/ks_mirror/Redhat-6.3-x86_64/images/pxeboot/initrd.img -> /var/www/cobbler/images/Redhat-6.3-x86_64/initrd.img
Writing template files for Redhat-6.3-x86_64
rendering DHCP files
generating /etc/dhcp/dhcpd.conf
rendering TFTPD files
generating /etc/xinetd.d/tftp
processing boot_files for distro: Redhat-6.3-x86_64
cleaning link caches
running post-sync triggers
running python triggers from /var/lib/cobbler/triggers/sync/post/*
running python trigger cobbler.modules.sync_post_restart_services
running: dhcpd -t -q
received on stdout:
received on stderr:
running: service dhcpd restart
received on stdout: Shutting down dhcpd: [ OK ]
Starting dhcpd: [ OK ] #必须看到dhcpd进行启动才可以
received on stderr:
running shell triggers from /var/lib/cobbler/triggers/sync/post/*
running python triggers from /var/lib/cobbler/triggers/change/*
running python trigger cobbler.modules.scm_track
running shell triggers from /var/lib/cobbler/triggers/change/*
*** TASK COMPLETE ***
[root@localhost ~]#
本文出自 “zhanguo1110” 博客,请务必保留此出处http://zhanguo1110.blog.51cto.com/5750817/1411409