1、Cobbler簡介html
Cobbler 是一個系統啓動服務(boot server),能夠經過網絡啓動(PXE)的方式用來快速安裝、重裝物理服務器和虛擬機,支持安裝不一樣的 Linux 發行版和 Windows。該工具使用python開發,小巧輕便(才15k行代碼),使用簡單的命令便可完成PXE網絡安裝環境的配置,同時還能夠管理DHCP,DNS,以及yum包鏡像。node
Cobbler 使用命令行方式管理,也提供了基於 Web 的界面管理工具(cobbler-web),還提供了API接口,能夠方便二次開發使用。
python即多安裝樹的pxe環境,是pxe的高級封裝linux
2、Cobbler提供如下服務集成web
一、PXE服務支持shell
二、DHCP服務管理apache
三、DNS服務管理(可選bind,dnsmasq)vim
四、電源管理windows
五、Kickstart服務支持centos
六、yum倉庫管理
七、TFTP (PXE啓動時須要)
八、Apache(提供kickstart 的安裝源,並提供定製化的kickstart配置)
同時,它和apache作了深度整合。經過 cobbler,能夠實現對RedHat/Centos/Fedora系統的快速部署,同時也支持Suse 和Debian(Ubuntu)系統,經過配置也支持windows。
3、cobbler的組織結構
profile:是核心,由如下三個組件組成
repositories(安裝樹或安裝源),
mirror:鏡像 指向網絡中的安裝源
import:導入
distribution (vmlinuz(內核)+initrd.img(引導映像文件))
cobbler會自動從reporitories抽取出來生成
kickstart file組成的完完整整的系統發行版
cobbler裝機系統是較早前pxe的升級版,優勢比較容易配置,還自帶web界面比較易於管理,不足在於中文資料較少。和pxe不一樣的是,使用cobbler不會由於在局域網中啓動了dhcp而致使有些機器由於默認從pxe啓動在重啓服務器後加載tftp內容致使啓動終止。
經過配置cobbler自動部署DHCP、TFTP、HTTP,在安裝過程當中加載kiskstart無人值守安裝應答文件實現無人值守。從客戶端使用PXE引導啓動安裝。
經常使用架構以下圖:
4、Cobbler的工做流程
Cobbler工做流程:
下面咱們來簡單的說明一下,
Server端:
第一步,啓動Cobbler服務
第二步,進行Cobbler錯誤檢查,執行cobbler check命令
第三步,進行配置同步,執行cobbler sync命令
第四步,複製相關啓動文件文件到TFTP目錄中
第五步,啓動DHCP服務,提供地址分配
第六步,DHCP服務分配IP地址
第七步,TFTP傳輸啓動文件
第八步,Server端接收安裝信息
第九步,Server端發送ISO鏡像與Kickstart文件
Client端:
第一步,客戶端以PXE模式啓動
第二步,客戶端獲取IP地址
第三步,經過TFTP服務器獲取啓動文件
第四步,進入Cobbler安裝選擇界面
第五步,客戶端肯定加載信息
第六步,根據配置信息準備安裝系統
第七步,加載Kickstart文件
第八步,傳輸系統安裝的其它文件
第九步,進行安裝系統
5、Kickstart 概述
6、cobbler安裝
一、環境
1)cobbler服務器和客戶機IP
Cobbler服務器系統:CentOS6.5-x86_64
IP地址:192.168.200.1
須要安裝部署的Linux系統的客戶機IP地址段:192.168.200.21-192.168.200.100
子網掩碼:255.255.255.0
網關:192.168.200.1
DNS:114.114.114.114
全部服務器均支持PXE網絡啓動
實現目的:經過配置Cobbler服務器,全自動批量安裝部署Linux系統
2)關閉防火牆與SELinux
[root@localhost ~]# service iptables stop
iptables: Setting chains to policy ACCEPT: filter [ OK ]
iptables: Flushing firewall rules: [ OK ]
iptables: Unloading modules: [ OK ]
[root@localhost ~]# chkconfig iptables off
[root@localhost ~]# setenforce 0
[root@localhost ~]# sed -i '/SELINUX/s/enforcing/disabled/' /etc/selinux/config
3)yum源配置
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.BAK
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo
yum clean all ; yum makecache all
4)同步系統時間
[root@node2 ~]# yum install -y ntp
[root@localhost yum.repos.d]# ntpdate 202.120.2.101
7 Sep 13:59:53 ntpdate[5475]: adjust time server 202.120.2.101 offset 0.169428 sec
[root@localhost yum.repos.d]# date
Mon Sep 7 13:59:56 CST 2015
[root@node2 ~]# hwclock -w
二、安裝cobbler (epel源)
yum install dhcp tftp-server httpd syslinux cobbler cobbler-web pykickstart debmirror -y
7、配置cobbler
一、設置httpd服務
[root@node2 ~]# vim /etc/httpd/conf/httpd.conf
ServerName localhost:80
[root@node2 ~]# service httpd start
二、配置tftp與rsync
修改 rsync 和 tftp 這兩個服務的 xinetd 配置,只需修改 rsync 和tftp的配置文件,在/etc/xinetd.d/目錄下
將 disable = yes 修改成 disable = no來開啓tftp與rsync服務的開機啓動
也能夠直接使用命令:
chkconfig tftp on
chkconfig rsync on
再啓動xinetd服務:
service xinetd start
三、 配置Cobbler主配置文件
在啓動Cobbler服務以前,你須要修改一些配置文件。在修改每個文件以前最好先備份下當前的文件。
Cobblerd的配置文件爲/etc/cobbler/settings ,這個文件是YAML信息的格式文件。
根據須要修改 cobbler主配置文件: /etc/cobbler/settings
①Server 和 Next_Server
server 選項用於爲cobbler 服務器指定ip地址,請不要使用0.0.0.0,設置一個你但願和cobbler服務器經過http和tftp等協議連接的IP。
# sed -i 's/server: 127.0.0.1/server: 192.168.200.1/g' /etc/cobbler/settings
next_server選項是DHCP/PXE網絡引導文件被下載的TFTP服務器的IP,在本例中它將和server設置爲同一個IP
# sed -i 's/next_server: 127.0.0.1/next_server: 192.168.200.1/g' /etc/cobbler/settings
②防止誤重裝系統
pxe安裝只容許一次,防止誤操做 ( 在正式環境有用。實際測試來看,這個功能能夠屏蔽掉 )
# sed -i 's/pxe_just_once: 0/pxe_just_once: 1/g' /etc/cobbler/settings
③、生成Cobbler安裝系統root初始密碼
(1)這裏生成密鑰和配置默認密鑰。這個設置只針對centos有效。用 openssl 生成一串密碼後加入到 cobbler 的配置文件(/etc/cobbler/settings)裏,替換 default_password_crypted 字段
[root@localhost cobbler]# openssl passwd -1 -salt '123abc' 'www.magedu.com'
$1$123abc$5tYLxoUm1wOxOeGQZI7Lo.
openssl passwd -1 -salt ‘隨機字符’ ‘密碼’ (是數字1 不是字母L)
這個命令的用法,隨機字符能夠隨便寫,這個密碼就是安裝完系統root的密碼了。
(2) 將上面的加密串加入cobbler配置文件中。
# vi /etc/cobbler/settings
# 修改成以下配置(第101行)
default_password_crypted: "$1$123abc$5tYLxoUm1wOxOeGQZI7Lo."
④、Cobbler管理rsync
默認爲0,不對rsync進行管理,能夠修改成1 進行管理
# sed -i 's/manage_rsync: 0/manage_rsync: 1/g' /etc/cobbler/settings
⑤. Cobbler管理dhcp
爲了pxe的啓動,須要一個DHCP服務器地址,並直接引導系統,它能夠在網絡中下載引導文件到TFTP的服務器,cobbler能夠經過manage_dhcp的設置來進行管理
配置dhcp服務
首先修改cobbler配置,讓cobbler來管理dhcp服務,在作自定義配置時,須要修改dhcp相關配置,以配合PXE啓動用,編輯文件/etc/cobbler/settings
manage_dhcp: 1 (注:默認爲0 ,表示不進行管理dhcp服務,能夠修改成1,對其進行管理。此爲使cobbler管理dhcp也就是後面用於同步更新配置信息[cobbler sync])
也可用命令修改:
# sed -i 's/manage_dhcp: 0/manage_dhcp: 1/g' /etc/cobbler/settings
# grep '^manage_dhcp' /etc/cobbler/settings
四、修改cobbler管理DHCP的模板
/etc/cobbler/dhcp.template,此文件是cobbler管理dhcp的模板,確保DHCP分配的地址和Cobbler在同一網段
對於此文件,本例中只須要修改以下部分
# 須要修改192.168.1.0爲本身網段
[root@node2 ~]# vim /etc/cobbler/dhcp.template
subnet 192.168.100.0 netmask 255.255.255.0 {
option routers 192.168.100.1;
option domain-name-servers 8.8.8.8;
option subnet-mask 255.255.255.0;
range dynamic-bootp 192.168.100.100 192.168.18.200;
default-lease-time 21600;
max-lease-time 43200;
next-server $next_server;
其他部分維持默認值便可。
若是是多網卡須要指定DHCP服務的網絡接口
#vi /etc/sysconfig/dhcpd
修改內容以下:
#Command line options here DHCPDARGS=eth0
DHCPDARGS=eth0
# 測試dhcp服務器配置是否正確
# dhcpd # 在執行cobbler sync 以後測試纔有效,由於沒同步以前文件/etc/dhcp/dhcpd.conf尚未被同步修改
五、設置debmirror
註釋掉@dists和@arches的行
sed -i -e 's|@dists=.*|#@dists=|' /etc/debmirror.conf
sed -i -e 's|@arches=.*|#@arches=|' /etc/debmirror.conf
修改配置完成後必定要運行cobbler sync 命令讓配置生效,使dhcp、http被cobbler接管,否則會報錯。
8、Cobbler 子命令介紹並啓動cobbler
一、cobbler子命令介紹
-------------------------------------------------------------------------------------------
cobbler check #檢查cobbler配置 主要用於檢查cobbler配置是否有錯
cobbler sync #同步配置到dhcp pxe和數據目錄 更改某些配置後記得執行一下,同步一下配置。
cobbler list #列出全部的cobbler元素
cobbler import #導入安裝的系統光盤鏡像
cobbler report #列出各元素的詳細信息
cobbler distro #查看導入的發行版系統信息 不但能夠查看導入的發行版系統信息還能夠增長與修改等
cobbler profile #查看配置信息 不但能夠查看Kickstart文件並且還能夠編輯與刪除此文件
cobbler system #查看添加的系統信息
cobbler reposync #同步yum倉庫到本地 同步遠程的yum源到本地
cobbler signature update
cobbler --help #得到cobbler的幫助
cobbler distro --help #得到cobbler子命令的幫助
[root@localhost ~]# cobbler --help usage ===== cobbler <distro|profile|system|repo|p_w_picpath|mgmtclass|package|file> ... [add|edit|copy|getks*|list|remove|rename|report] [options|--help] cobbler <aclsetup|buildiso|import|list|replicate|report|reposync|sync|validateks|version|signature|get-loaders|hardlink> [options|--help] [root@localhost ~]# cobbler list --help Usage: cobbler [options] Options: -h, --help show this help message and exit [root@localhost cobbler]# cobbler profile --help usage ===== cobbler profile add cobbler profile copy cobbler profile dumpvars cobbler profile edit cobbler profile find cobbler profile getks cobbler profile list cobbler profile remove cobbler profile rename cobbler profile report [root@localhost cobbler]# cobbler profile add --help Usage: cobbler [options] Options: -h, --help show this help message and exit --name=NAME Name (Ex: F10-i386-webserver) --uid=UID --owners=OWNERS Owners (Owners list for authz_ownership (space delimited)) --distro=DISTRO Distribution (Parent distribution) --parent=PARENT Parent Profile --enable-gpxe=ENABLE_GPXE Enable gPXE? (Use gPXE instead of PXELINUX for advanced booting options) --enable-menu=ENABLE_MENU Enable PXE Menu? (Show this profile in the PXE menu?) --kickstart=KICKSTART Kickstart (Path to kickstart template) --kopts=KERNEL_OPTIONS Kernel Options (Ex: selinux=permissive) --kopts-post=KERNEL_OPTIONS_POST Kernel Options (Post Install) (Ex: clocksource=pit noapic) --ksmeta=KS_META Kickstart Metadata (Ex: dog=fang agent=86) --proxy=PROXY Internal proxy (Internal proxy URL) --repos=REPOS Repos (Repos to auto-assign to this profile) --comment=COMMENT Comment (Free form text description) --virt-auto-boot=VIRT_AUTO_BOOT Virt Auto Boot (Auto boot this VM?) --virt-cpus=VIRT_CPUS Virt CPUs (integer) --virt-file-size=VIRT_FILE_SIZE Virt File Size(GB) --virt-disk-driver=VIRT_DISK_DRIVER Virt Disk Driver Type (The on-disk format for the virtualization disk) --virt-ram=VIRT_RAM Virt RAM (MB) --depth=DEPTH --virt-type=VIRT_TYPE Virt Type (Virtualization technology to use) (valid options: xenpv,xenfv,qemu,kvm,vmware,openvz,SETTINGS:d efault_virt_type) --virt-path=VIRT_PATH Virt Path (Ex: /directory OR VolGroup00) --virt-bridge=VIRT_BRIDGE Virt Bridge --dhcp-tag=DHCP_TAG DHCP Tag (See manpage or leave blank) --server=SERVER Server Override (See manpage or leave blank) --ctime=CTIME --mtime=MTIME --name-servers=NAME_SERVERS Name Servers (space delimited) --name-servers-search=NAME_SERVERS_SEARCH Name Servers Search Path (space delimited) --mgmt-classes=MGMT_CLASSES Management Classes (For external configuration management) --mgmt-parameters=MGMT_PARAMETERS Management Parameters (Parameters which will be handed to your management application (Must be valid YAML dictionary)) --boot-files=BOOT_FILES TFTP Boot Files (Files copied into tftpboot beyond the kernel/initrd) --fetchable-files=FETCHABLE_FILES Fetchable Files (Templates for tftp or wget/curl) --template-files=TEMPLATE_FILES Template Files (File mappings for built-in config management) --redhat-management-key=REDHAT_MANAGEMENT_KEY Red Hat Management Key (Registration key for RHN, Spacewalk, or Satellite) --redhat-management-server=REDHAT_MANAGEMENT_SERVER Red Hat Management Server (Address of Spacewalk or Satellite Server) --template-remote-kickstarts=TEMPLATE_REMOTE_KICKSTARTS --clobber allow add to overwrite existing objects --in-place edit items in kopts or ksmeta without clearing the other items
二、啓動相關服務並設置開機啓動
cobbler sync
chkconfig cobblerd on
chkconfig dhcpd on
chkconfig httpd on
chkconfig xinetd on
chkconfig tftp on
chkconfig rsync on
/etc/init.d/xinetd restart
/etc/init.d/dhcpd restart
/etc/init.d/httpd restart #這裏若是提示啓動失敗,先cobbler sync同步一下配置就能夠了
啓動cobbler並運行Cobbler檢查命令
[root@localhost ~]# service cobblerd start
[root@localhost ~]# cobbler get-loaders #清除一些無關的報錯
[root@localhost ~]# cobbler check
No configuration problems found. All systems go. #沒有報錯
9、Cobbler的使用
一、導入要安裝的鏡像文件
①、掛載鏡像
[root@localhost ~]# mount /dev/cdrom /mnt
mount: block device /dev/sr0 is write-protected, mounting read-only
[root@localhost ~]# ls /mnt
CentOS_BuildTag isolinux RPM-GPG-KEY-CentOS-Debug-6
EFI Packages RPM-GPG-KEY-CentOS-Security-6
EULA RELEASE-NOTES-en-US.html RPM-GPG-KEY-CentOS-Testing-6
GPL repodata TRANS.TBL
p_w_picpaths RPM-GPG-KEY-CentOS-6
[root@localhost ~]#
②、使用cobbler
import
命令導入鏡像
主要有如下幾個參數--path 指定導入鏡像的路徑,--name 指定導入鏡像的名稱,--arch 指定導入鏡像的架構(32位仍是64位)。還有須要說明的是這裏導入的時間相對較長大概在5-10分鐘左右,請你們耐心等待。
下面是具體的導入過程:
[root@localhost ~]# cobbler import --path=/mnt --name=centos6.7 --arch=x86_64
task started: 2015-09-07_170439_import
task started (id=Media import, time=Mon Sep 7 17:04:39 2015)
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/CentOS6.7-x86_64:
creating new distro: CentOS6.7-x86_64
trying symlink: /var/www/cobbler/ks_mirror/CentOS6.7-x86_64 -> /var/www/cobbler/links/CentOS6.7-x86_64
creating new profile: CentOS6.7-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/CentOS6.7-x86_64 for CentOS6.7-x86_64
processing repo at : /var/www/cobbler/ks_mirror/CentOS6.7-x86_64
need to process repo/comps: /var/www/cobbler/ks_mirror/CentOS6.7-x86_64
looking for /var/www/cobbler/ks_mirror/CentOS6.7-x86_64/repodata/*comps*.xml
Keeping repodata as-is :/var/www/cobbler/ks_mirror/CentOS6.7-x86_64/repodata
*** TASK COMPLETE ***
注意1: 這個安裝源的惟一標示就是根據--name和--arch這兩個參數來定義
本例導入成功後,安裝源的惟一標示就是:CentOS6.7-x86_64,若是重複,系統會提示導入失敗,其它命令可經過cobbler –help來進行查看。若是須要更多的參數定製,也能夠查看官方文檔: man cobbler ,而後查找 import 的配置,可使用另一個命令: cobbler distro。
從上面顯示信息所知:
cobbler會將鏡像中的全部安裝文件拷貝到本地一份,放在/var/www/cobbler/ks_mirrors下的centos6.7-x86_64目錄下。同時會建立一個名字爲centos6.7-x86_64的一個(distro)發佈版本,以及一個名字爲centos6.7-x86_64的profile文件。
注意2:/var/www/cobbler 目錄必須具備足夠容納 Linux安裝文件的空間。若是空間不夠,能夠對/var/www/cobbler目錄進行移動,建軟連接來修改文件存儲位置。
例如:
# ln -s /home/cobbler /var/www
導入時間較長, 請耐心等待!!!在正常導完以後會給出以下提示:
*** TASK COMPLETE ***
有時可能會出現卡住的現象,若是導入時間過長,可經過比對文件大小來肯定是否已經正常導入
比對文件大小的方法
# du -sh /var/www/cobbler/ks_mirror/CentOS-6.7-x86_64/
# du -sh /mnt
若是上述兩個命令執行過顯示的結果出入較大, 則可能文件沒有正常導入
在從新導入以前最好先把以前的內容刪除再導入
cobbler [distro] remove –name=[CentOS-6.7] 方括號中的內容根據本身的狀況來填寫 , 更多命令經過cobbler –help 來查看
剩下其它系統導入方法相似,只是名字和路徑更改下便可。重複上面的操做,把其餘的系統鏡像文件導入到Cobbler導入完成以後,可經過 cobbler list 來查看導入的結果。
[root@localhost kickstarts]# cobbler list
distros:
CentOS6.7-x86_64
profiles:
CentOS6.7-x86_64
systems:
repos:
p_w_picpaths:
mgmtclasses:
packages:
files:
[root@localhost kickstarts]#
③. 建立kickstarts自動安裝腳本(For Centos/RHEL)
注意:這是關鍵步驟之一
因爲須要安裝的操做系統發行廠商不一樣,所以KS文件的寫法要求,也不一而足。
本文只討論 CentOs/RHEL 系列的 KS配置
另外:操做系統 版本不一樣,KS也存在必定的差別,好比CentOS5 ,和CentOS6下就有不一樣,切記!
默認kickstart文件是/var/lib/cobbler/kickstarts/sample_end.ks,須要手動爲每一個發行版單獨指定,或單獨修改。
自定義ks文件:
手動的修改已有的Kickstart文件
用system-config-kickstart工具生成Kickstart文件
下面是我本身定義的一個centos6.6模板
# kickstart template for Fedora 8 and later.
# (includes %end blocks)
# do not use with earlier distros
#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 --service=ssh
# Run the Setup Agent on first boot
firstboot --disable
# System keyboard
keyboard us
# System language
lang en_US
# 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 --utc Asia/Shanghai
# Install OS instead of upgrade
install
# Clear the Master Boot Record
zerombr
# Allow anaconda to partition the system as needed
part /boot --fstype=ext4 --size=200
part / --fstype=ext4 --size=10000
part /data --fstype=ext4 --size=5000
part swap --size=1000
%pre
$SNIPPET('log_ks_pre')
$SNIPPET('kickstart_start')
$SNIPPET('pre_install_network_config')
# Enable installation monitoring
$SNIPPET('pre_anamon')
%end
%packages
@chinese-support
@development
$SNIPPET('func_install_if_enabled')
%end
%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('download_config_files')
$SNIPPET('koan_environment')
$SNIPPET('redhat_register')
$SNIPPET('cobbler_register')
# Enable post-install boot notification
$SNIPPET('post_anamon')
# Start final steps
$SNIPPET('kickstart_done')
# End final steps
%end
注意:kickstarts自動安裝腳本中不容許有中文(註釋有中文也不行),不然會報錯
可使用ksvalidator程序驗證kickstart文件中是否有語法錯誤
# ksvalidator ks.cfg
④、修改profile指定新的KS啓動文件
按照操做系統版本分別關聯繫統鏡像文件和kickstart自動安裝文件
在第一次導入系統鏡像時,cobbler會給安裝鏡像指定一個默認的kickstart自動安裝文件
例如:CentOS-6.7-x86_64版本的kickstart自動安裝文件爲:
/var/lib/cobbler/kickstarts/sample_end.ks
cobbler profile report --name CentOS-6.6-x86_64 #查看profile設置
cobbler distro report --name CentOS-6.6-x86_64 #查看安裝鏡像文件信息
cobbler profile remove --name=CentOS-6.6-x86_64 #移除profile
cobbler profile add --name=CentOS-6.6-x86_64 --distro=CentOS-6.6-x86_64 --kickstart=/var/lib/cobbler/kickstarts/CentOS-6.6-x86_64.ks #添加
cobbler profile edit --name=CentOS-6.6-x86_64 --distro=CentOS-6.6-x86_64 --kickstart=/var/lib/cobbler/kickstarts/CentOS-6.5-x86_64.ks #編輯
命令:cobbler profile add|edit|remove --name=安裝引導名 --distro=系統鏡像名 --kickstart=kickstart自動安裝文件路徑
參數說明:
--name:自定義的安裝引導名,注意不能重複
--distro:系統安裝鏡像名,用cobbler distro list能夠查看
--kickstart:與系統鏡像文件相關聯的kickstart自動安裝文件(此文件必須預先準備好 )
更多命令參數可執行cobbler --help查看
[root@node2 ~]# cobbler profile edit --name=CentOS-6.4-x86_64 --distro=CentOS-6.4-x86_64 --kickstart=/var/lib/cobbler/kickstarts/centos6.ks
[root@node2 ~]# cobbler report
注,部分省略。
profiles:
==========
Name : CentOS-6.4-x86_64
TFTP Boot Files : {}
Comment :
DHCP Tag : default
Distribution : CentOS-6.4-x86_64
Enable gPXE? : 0
Enable PXE Menu? : 1
Fetchable Files : {}
Kernel Options : {}
Kernel Options (Post Install) : {}
Kickstart : /var/lib/cobbler/kickstarts/centos6.ks
⑤、同步一下
[root@node2 ~]# cobbler sync
task started: 2013-11-13_163907_sync
task started (id=Sync, time=Wed Nov 13 16:39:07 2013)
running pre-sync triggers
cleaning trees
removing: /var/www/cobbler/p_w_picpaths/CentOS-6.4-x86_64
removing: /var/lib/tftpboot/pxelinux.cfg/default
removing: /var/lib/tftpboot/grub/grub-x86_64.efi
removing: /var/lib/tftpboot/grub/p_w_picpaths
removing: /var/lib/tftpboot/grub/efidefault
removing: /var/lib/tftpboot/grub/grub-x86.efi
removing: /var/lib/tftpboot/p_w_picpaths/CentOS-6.4-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: CentOS-6.4-x86_64
trying hardlink /var/www/cobbler/ks_mirror/CentOS-6.4-x86_64/p_w_picpaths/pxeboot/vmlinuz -> /var/lib/tftpboot/p_w_picpaths/CentOS-6.4-x86_64/vmlinuz
trying hardlink /var/www/cobbler/ks_mirror/CentOS-6.4-x86_64/p_w_picpaths/pxeboot/initrd.img -> /var/lib/tftpboot/p_w_picpaths/CentOS-6.4-x86_64/initrd.img
copying p_w_picpaths
generating PXE configuration files
generating PXE menu structure
copying files for distro: CentOS-6.4-x86_64
trying hardlink /var/www/cobbler/ks_mirror/CentOS-6.4-x86_64/p_w_picpaths/pxeboot/vmlinuz -> /var/www/cobbler/p_w_picpaths/CentOS-6.4-x86_64/vmlinuz
trying hardlink /var/www/cobbler/ks_mirror/CentOS-6.4-x86_64/p_w_picpaths/pxeboot/initrd.img -> /var/www/cobbler/p_w_picpaths/CentOS-6.4-x86_64/initrd.img
Writing template files for CentOS-6.4-x86_64
rendering DHCP files
generating /etc/dhcp/dhcpd.conf
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: dhcpd -t -q
received on stdout:
received on stderr:
running: service dhcpd restart
received on stdout: 關閉 dhcpd:[肯定]
正在啓動 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 ***
如今就能夠新建客戶機,使用cobbler自動安裝系統了。
10、Cobbler的Web管理界面
能夠配置cobbler的web管理界面
(1)、安裝軟件包
[root@localhost ~]# yum -y install cobbler-web
(2)、設置用戶名密碼
爲已存在的用戶cobbler重置密碼
[root@localhost ~]# htdigest /etc/cobbler/users.digest "Cobbler" cobbler #認證時提示信息 用戶名
添加新用戶
[root@localhost ~]# htdigest /etc/cobbler/users.digest "Cobbler" admin
(3)、配置cobbler web能夠登陸
[root@localhost ~]# sed -i 's/authn_denyall/authn_configfile/g' /etc/cobbler/modules.conf
(4)、重啓Cobbler與http
[root@localhost ~]# /etc/init.d/cobblerd restart
Stopping cobbler daemon: [ OK ]
Starting cobbler daemon: [ OK ]
[root@localhost ~]# /etc/init.d/httpd restart
Stopping httpd: [ OK ]
Starting httpd: [ OK ]
[root@localhost ~]#
(5)訪問Cobbler Web頁面
https://192.168.200.1/cobbler_web
Cobbler配置文件
cobbler有許多的配置文件,可是隻有少部分基本功能須要修改。
Cobbler最主要的setting file就是/etc/cobbler/settings。Cobbler2.4.0開始引入動態修改模式(Dynamic Settings),咱們只需啓動這一模式,便不用再手動修改這個文件了。該文件是YAML格式的,若是直接修改setting文件,則必須重啓cobbler服務纔會生效,但若是是經過CLI命令或者是Web GUI進行修改的話,改動會當即生效,無需重啓服務。
修改allow_dynamic_settings的值爲1
cd /etc/cobbler/
cp settings settings.save
sed -i 's/^[[:space:]]\+/ /' /etc/cobbler/settings
sed -i 's/allow_dynamic_settings: 0/allow_dynamic_settings: 1/g' /etc/cobbler/settings
修改該配置後重啓cobbler服務
/etc/init.d/cobblerd restart
這個時候,你就能夠經過命令行來動態修改cobbler配置
cobbler setting report
cobbler setting report [--name=option]
cobbler setting edit --name=option --value=xxx
Cobbler目錄說明
一、Cobbler配置文件目錄:/etc/cobbler
/etc/cobbler/settings #cobbler主配置文件
/etc/cobbler/dhcp.template #DHCP服務的配置模板
/etc/cobbler/tftpd.template #tftp服務的配置模板
/etc/cobbler/rsync.template #rsync服務的配置模板
/etc/cobbler/iso #iso模板配置文件
/etc/cobbler/pxe #pxe模板文件
/etc/cobbler/power #電源的配置文件
/etc/cobbler/users.conf #Web服務受權配置文件
/etc/cobbler/users.digest #用於web訪問的用戶名密碼配置文件
/etc/cobbler/dnsmasq.template #DNS服務的配置模板
/etc/cobbler/modules.conf #Cobbler模塊配置文件
二、Cobbler數據目錄:/var/lib/cobbler
/var/lib/cobbler/config #配置文件
/var/lib/cobbler/triggers #Cobbler命令
/var/lib/cobbler/kickstarts #默認存放kickstart文件
/var/lib/cobbler/loaders #存放的各類引導程序
三、系統安裝鏡像目錄:/var/www/cobbler
/var/www/cobbler/ks_mirror #導入的系統鏡像列表
/var/www/cobbler/p_w_picpaths #導入的系統鏡像啓動文件
/var/www/cobbler/repo_mirror #yum源存儲目錄
四、日誌目錄:/var/log/cobbler
/var/log/cobbler/install.log #客戶端系統安裝日誌
/var/log/cobbler/cobbler.log #cobbler日誌
Cobbler 經常使用命令彙總
1.導入鏡像文件
命令:cobbler import --path=鏡像路徑 -- name=安裝引導名 --arch=32位或64位
參數:
path 是鏡像所掛載的目錄
name 是導入到cobbler裏面顯示的名字
arch 是32位系統仍是64位系統
2.導入kickstart文件
命令:cobbler profile add --name=list名 --distro=鏡像 --kickstart=路徑
參數:
name是表示添加的ks 的名字,用cobbler report能夠看到這個名字
distro 是用哪一個鏡像,list的distros裏面選擇一個,須要版本相對應
kickstart 是具體的 ks 文件路徑
3.同步DHCP、HTTPD
命令:cobbler sync
注,每次修改完dhcp.template之類的配置文件須要執行一次使其生效。
4.查看Cobbler列表
命令:cobbler list
注,列出Cobbler全部的元素。
5.刪除相關列表
命令:cobbler distro/profile remove --name=要刪除的引導文件名
刪除指定 distro , 也就是鏡像
刪除指定的 profile 文件,也就是 ks
Cobbler 不足
1.問題說明
根據MAC地址來配置主機ip和hostname,根據mac配置ip等相關信息是一些常見需求,有些設備標籤上有mac地址,這一類能夠手動抄下,而後在配置。可是,因爲主機更換主板,或其餘緣由致使mac不對,你還用標籤上的mac地址來配置,這就悲劇了。爲了更好的解決這樣的問題咱們也能夠有解決的辦法。
2.解決方法
根據dhcp請求信息抓取mac地址,而後進行配置。具體方法能夠經過tcpdump或者腳原本分析/var/log/message文件,抓取對目標端口爲67訪問的數據包,而後進行分析。
[root@node6 ~]# tcpdump -i eth0 dst port 67