歡迎您光臨本站 註冊首頁

cobbler無人值守安裝操作系統

←手機掃碼閱讀     火星人 @ 2014-03-03 , reply:0

cobbler無人值守安裝操作系統

操作系統環境 : CentOS 5.5 i386

軟體環境 : cobbler-2.0.11-2.el5

centos要安裝cobbler 需要安裝一個軟體包 epel

偶這裡把用到的幾個文件上傳到網盤了 方便自己和朋友們下載 http://www.uudisc.com/user/txwsqk/files/4193306

(裡面包含一個epel,一個kickstart配置文件,還有cobbler get-loaders下載的哪些文件)

下面開始具體的步驟了:

先配置源

找不到好源的看這裡 http://mirrors.163.com/.help/

centos的系統  
?
cd /etc/yum.repos.d/
wget http://mirrors.163.com/.help/CentOS5-Base-163.repo
#別忘了rpm -ivh epel-release-5-4.noarch.rpm
?
yum makecache

開始安裝軟體
?
yum install cobbler dhcp cman debmirror

修改配置文件

vi /etc/cobbler/dhcp.template
?
subnet 192.168.0.0 netmask 255.255.255.0 {
     option routers             192.168.0.100;
#   option domain-name-servers 192.168.1.1;
     option subnet-mask         255.255.255.0;
     range dynamic-bootp        192.168.0.110 192.168.0.200;

注: 不要修改/etc/dhcpd.conf 這個文件,過會我們會配置讓cobbler接管啟動dhcpd的任務,cobbler會把你修改的dhcp.template拷貝到/etc/dhcpd.conf

vi /etc/cobbler/settings   (只寫出需要修改的地方)
?
default_password_crypted: "$1$icifbsa$GlSk4KZPpIscQsOpLkZh0/"                #過會你運行 cobbler check時 會提示你修改密碼 ,這個密碼就是你安裝系統后的root密碼,我在這裡先說明而已. 用這個命令實現 "openssl passwd -1 -salt '任意字母' '你的密碼' "
manage_dhcp: 1
next_server: 192.168.0.100
server: 192.168.0.100

vi /etc/debmirror.conf (只寫出需要修改的地方)
?
#@dists="sid";
#@arches="i386";  #這兩個地方註釋掉即可,不然過會 cobbler check 會報錯

過會cobbler check 時 還會要求你執行一個命令
?
cobbler get-loaders

這是下載引導操作系統的必須文件,我在上面的網盤已經提供了 loaders.tar.gz,解壓到  /var/lib/cobbler/loaders/,當然你也可以運行上面的命令下載

再修改2個文件
?
/etc/xinetd.d/tftp
/etc/xinetd.d/rsync

把這2個文件裡面的

disable                 = no

捎帶提一句 別忘了關閉防火牆和SELINUX (有時這2個東西很誤事 :)  

這時候我們啟動 httpd  (如果不啟動httpd , 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 : you need to set some SELinux content  rules to ensure cobbler works correctly in your SELinux environment, run the  following: /usr/sbin/semanage fcontext -a -t public_content_t "/tftpboot/.*"  && \ /usr/sbin/semanage fcontext -a -t public_content_t  "/var/www/cobbler/images/.*"
   
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/tftp
   
6 : change 'disable' to 'no' in  /etc/xinetd.d/rsync
   
7 : since iptables may be running, ensure  69, 80, and 25151 are unblocked
   
8 : debmirror package is not installed,  it will be required to manage debian deployments and repositories
   
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

文章有點倒敘了 哈哈 根據報錯信息和偶上面修改的地方改改, 改完后執行  cobbler check
?
# cobbler check
cobblerd does not appear to be running/accessible

好了 沒有報錯信息了,cobbler 配置好了。

開始導入操作系統的ISO鏡像文件
?
#先mount  iso文件
mount -o loop /path/centos-5.5-i386.iso /mnt
#導入 . --name=名字任意,--path=剛才你mount的路徑
cobbler import --path=/mnt --name=centos-5.5-i386

同步所有配置
?
cobbler sync

啟動所有服務
?
/etc/init.d/xinetd restart
/etc/init.d/httpd restart
/etc/init.d/cobblerd restart

ps: cobbler sync時會自動啟動dhcpd的服務。

  偶修改完配置時,都是執行 cobbler sync ,  /etc/init.d/cobblerd restart 這兩個命令(為了保險)^_^ 

  重要:用cobbler安裝操作系統時,cobbler真正執行的kickstart文件其實不是 /var/lib/cobbler/kickstarts/default.ks,而是 /var/lib/cobbler/kickstarts/sample.ks

       學習cobbler配置,最好把kickstart的配置文件也搞懂,默認sample.ks文件會清空硬碟所有分區資料。

下面貼出偶的 sample.ks

?
#platform=x86, AMD64, or Intel EM64T
# System authorization information
auth  --useshadow  --enablemd5
# System bootloader configuration
bootloader --location=mbr
# Partition clearing information
#clearpart --all --initlabel
# Use text mode install
text
# Firewall configuration
firewall --enabled
# Run the Setup Agent on first boot
firstboot --enable
# System keyboard
keyboard us
# System language
lang en_US.UTF-8
# Use network installation
url --url=$tree
# If any cobbler repo definitions were referenced in the kickstart profile, include them here.
$yum_repo_stanza
# Network information
$SNIPPET('network_config')
# Reboot after installation
reboot

#Root password
#rootpw --iscrypted $default_password_crypted
# SELinux configuration
selinux --disabled
# Do not configure the X Window System
skipx
# System timezone
timezone  Asia/Shanghai
# Install OS instead of upgrade
install
# Clear the Master Boot Record
#zerombr
# Allow anaconda to partition the system as needed
#autopart


%pre
$SNIPPET('log_ks_pre')
$kickstart_start
$SNIPPET('pre_install_network_config')
# Enable installation monitoring
$SNIPPET('pre_anamon')

%packages
#$SNIPPET('func_install_if_enabled')
#$SNIPPET('puppet_install_if_enabled')
@base
@core
@development-libs
@development-tools
@editors
@text-internet
keyutils
trousers
fipscheck
device-mapper-multipath
imake
lrzsz

%post
$SNIPPET('log_ks_post')
# Start yum configuration
$yum_config_stanza
# End yum configuration
$SNIPPET('post_install_kernel_options')
$SNIPPET('post_install_network_config')
$SNIPPET('func_register_if_enabled')
$SNIPPET('puppet_register_if_enabled')
$SNIPPET('download_config_files')
$SNIPPET('koan_environment')
$SNIPPET('redhat_register')
$SNIPPET('cobbler_register')
# Enable post-install boot notification
$SNIPPET('post_anamon')
# Start final steps
$kickstart_done
# End final steps

這是屬於cobbler調用的特殊ks文件,想看真正配置好吧,方法是打開瀏覽器
?
http://192.168.0.100/cblr/svc/op/ks/profile/CentOS-5.5-i386
?
# 192.168.0.100不用解釋了吧
?
#後面的 CentOS-5.5-i386 就是你 cobbler import時指定的 --name

偶是用虛擬機完成此次實驗的,本來是在fedora15下用的virtualbox,但是那個網路環境真難搞,一直也不能讓另一個虛擬機獲得到cobbler所在虛擬機的dhcp分配的ip,無奈回到windows用

vmware,使用hostonly模式輕鬆搞定。這裡再捎帶提以下修改vmware bios啟動的方法,因為vmware啟動界面一閃而過,想按F2進入bios灰常難,方法就是修改虛擬機的開機等待時間

進入到你虛擬機的目錄,不是軟體安裝目錄,是你保存虛擬機的目錄,裡面有個vmx文件,添加一行
?
bios.bootdelay=5000

讓開機畫面停留5000毫秒。

大功告成 !  

http://www.cnblogs.com/txwsqk/archive/2011/08/09/2132803.html
《解決方案》

呵呵,不錯,值得收藏

[火星人 ] cobbler無人值守安裝操作系統已經有582次圍觀

http://coctec.com/docs/service/show-post-803.html