cobblers 部署

Cobbler

一、基礎知識

Cobbler的作用:

運維自動化安裝方面,早期一般使用人工配置pxe+dhcp+tftp配合kickstart使用可

以實現運維的自動化安裝,但是它有一個很大的侷限性就是安裝系統沒得選擇,只可

以同時安裝一種版本的系統,而cobbler實現了可以同時在線安裝不同版本的系統,

可以實現多版本的選擇。使得運維自動化更加人性化。個人覺得Cobbler是對pxe+dhcp

+tftp的擴展。

1、傳統pxe的工作方式原理圖

wps_clip_image-4210

2、cobbler工作原理圖

wps_clip_image-10121

3、cobbler部署內部工作原理邏輯圖

wps_clip_image-9519

二、實驗Cobbler的部署

Node1 centos6.5 172.16.11.143

Node2 沒裝系統的新建虛擬機

1、配置安裝yum源
http://download.fedoraproject.org/pub/epel/6/x86/epel-release-6-5.noarch.rpm
Yum  install cobbler*  -y
注意要配置epel源才能安裝cobbler
2、cobbler 的安裝配置
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 : 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
Restart cobblerd and then run 'cobbler sync' to apply changes.
1、編輯/etc/cobbler/settings文件,找到 server選項,修改爲適當的ip地址,本實例配置ip爲:server: 172.16.11.143
2、編輯/etc/cobbler/settings文件,找到 next_server選項,修改爲適當的ip地址,本實例配置ip爲:next_server: 172.16.11.143
3、SELinux的設置。如果上面已經關閉了SELinux就不用管了
4、執行 cobbler get-loaders,系統將自動下載loader程序,完成提示4的修復工作。
cobbler get-loaders
其實這裏我下載它不給下載你可以手動複製過去就可以啦、
cp /usr/share/syslinux /var/lib/cobbler/loaders
5、編輯/etc/xinetd.d/tftp文件,將文件中的disable字段的配置由yes改爲no
6、編輯/etc/xinetd.d/rsync文件,將文件中的disable字段的配置由yes改爲no
7、在iptables中將69,80,25151端口打開。如果僅僅只是在內部環境中使用,建議直接將防火牆關掉
8、提示說debmirror沒安裝。如果不是安裝 debian之類的系統,此提示可以忽略,如果需要安裝,下載地址爲:
http://rpmfind.net/linux/rpm2html/search.php?query=debmirror
9、修改cobbler用戶的默認密碼,可以使用如下命令生成密碼,並使用生成後的密碼替換/etc/cobbler/settings中的密碼。生成密碼命令:
[root@node1 ~]# openssl passwd -1 -salt 'openssl rand -hex 4'
Password:
$1$openssl $UYENzYDpAJVXUZI4rUWuL1
default_password_crypted: "$1$openssl $UYENzYDpAJVXUZI4rUWuL1"
10、可能還會要求安裝httpd,並能正常啓動,我就配置了一下,它提示域名解析不一致、這個很簡單自己解決
11、安裝軟件syslinux.x86_64或者其他的軟件具體看情況
就這樣把包的錯都解決掉,中途你可以cobbler sync  或者 service cobblerd restart
最後我的處理的結果是
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
Restart cobblerd and then run 'cobbler sync' to apply changes.

2、安裝配置dhcp

Yum  install  dhcp -y
Cp /usr/share/doc/dhcp-4.1.1/dhcp.conf.sample /etc/dhcp/dhcpd.conf
Vim /etc/dhcp/dhcpd.conf
option domain-name "org.com";
option domain-name-servers 172.16.0.1;
default-lease-time 43200;
max-lease-time 86400;
log-facility local7;
subnet 172.16.0.0 netmask 255.255.0.0 {
  range 172.16.11.101 172.16.11.120;
  option routers 172.16.11.143;
}
next-server 172.16.11.143;
filename="pxelinux.0";
Service dhcpd  restart

3、配置cobbler的模板

先要下載要安裝發行版本的系統(就是映像光盤)

這裏是虛擬機你就掛載光盤就可以啦,真實環境的話不管你用什麼方法要提供一個原始系統

Mount /dev/cdrom /mnt -r

製作一個模板

Cobbler import --path=/mnt --name=centos-6.5-x86_64

Ls /var/lib/cobbler/kickstarts/

Ls /var/www/cobbler/ks_mirror/centos-6.5-x86_64

提供kickstart 文件

ksvalidator centos6.x86_64.cfg #測試kickstart的語法、如果保錯一定要解決,不然後面它也不給安裝

#####################################################################################

#platform=x86, AMD64, or Intel EM64T
#version=DEVEL
# Firewall configuration
firewall --disabled
# Install OS instead of upgrade
install
# Use network installation
url --url="http://172.16.11.143/cobbler/ks_mirror/centos-6.5-x86_64/" #此處慎重填寫
# Use text mode install
text
firstboot --disable
# System keyboard
keyboard us
# System language
lang en_US
# SELinux configuration
selinux --disabled
# Installation logging level
logging --level=info --host=172.16.0.1
# Reboot after installation
reboot
# System timezone
timezone  Asia/Shanghai
# System bootloader configuration
bootloader --append="rhgb crashkernel=auto quiet" --location=mbr --driveorder="sda"
# Clear the Master Boot Record
part /boot --fstype="ext4" --size=200
part pv.008 --size=61440
volgroup vg0 --pesize=8192 pv.008
logvol / --fstype=ext4 --name=root --vgname=vg0 --size=20480
logvol swap --name=swap --vgname=vg0 --size=2048
logvol /usr --fstype=ext4 --name=usr --vgname=vg0 --size=10240
logvol /var --fstype=ext4 --name=var --vgname=vg0 --size=20480
repo --name="Fedora EPEL"  --baseurl=http://172.16.11.143/cobbler/ks_mirror/centos-6.5-x86_64/ --cost=1000  #此處慎重填寫
%post
#vim syntax on 
sed -i "8 s/^/alias vi='vim'/" /root/.bashrc 2>/dev/null 
echo 'syntax on' > /root/.vimrc 2>/dev/null
# file descriptors 
ulimit -HSn 65535 
echo -ne " 
* soft nofile 65536 
* hard nofile 65536 
" >>/etc/security/limits.conf 
# Set the hostname
ClientName=`ifconfig eth0 | awk '/inet addr:/{print $2}' | awk -F. '{print $NF}'`
sed -i "s@HOSTNAME=.*@HOSTNAME=client$ClientName.org.com@g" /etc/sysconfig/networks
# set puppet agent
sed -i '/\[main\]/a server=server.org.com' /etc/puppet/puppet.conf
/sbin/chkconfig puppet off
# set hosts
echo '172.16.0.1  server.org.com server' >> /etc/hosts
%end
%packages
@base
@basic-desktop
@chinese-support
@client-mgmt-tools
@core
@desktop-platform
@fonts
@general-desktop
@graphical-admin-tools
@legacy-x
@network-file-system-client
@perl-runtime
@remote-desktop-clients
@x11
#func
lftp
ibus-table-cangjie
ibus-table-erbi
ibus-table-wubi
#puppet
%end
###################################################################################

4、爲cobbler提供profile 文件

cobbler profile add --name=centos-6.5-x86_64-basic --distro=centos-6.5-x86_64 --kickstart=/tmp/centos6.x86_64.cfg #kickstart文件放置位置
cobbler profile add --help
--name=NAME           Name (Ex: F10-i386-webserver)
--distro=DISTRO       Distribution (Parent distribution)
vim /var/lib/tftpboot/pxelinux.cfg/default #查看生成的profile是否有誤

5、啓動tftp

/etc/init.d/xinetd restart
chkconfig tftp on
Ss -tunl
67、69、837是否監聽

6、設置node2網卡開機啓動測試

wps_clip_image-12330

選擇安裝系統

wps_clip_image-23904

自動化安裝系統安裝軟件階段

wps_clip_image-7546

其實cobbler還有個cobbler-web的軟件是個圖形部署cobbler的工具,前提是搭建起cobbler來,這裏就不做演示啦,大家就自行研究啦,

對於cobbler不明白的可以私下討論。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章