歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux管理 >> Linux配置 >> 運維自動化之Cobbler安裝配置

運維自動化之Cobbler安裝配置

日期:2017/2/27 14:58:01   编辑:Linux配置
Cobbler是一個快速網絡安裝linux的服務,而且在經過調整也可以支持網絡安裝windows。該工具使用python開發,小巧輕便(才15k行代碼),使用簡單的命令即可完成PXE網絡安裝環境的配置,同時還可以管理DHCP,DNS,以及yum包鏡像。
Cobbler支持命令行管理,web界面管理,還提供了API接口,可以方便二次開發使用。
和Kickstart不同的是,使用cobbler不會因為在局域網中啟動了dhcp而導致有些機器因為默認從pxe啟動在重啟服務器後加載tftp內容導致啟動終止。

cobbler的安裝部署配置
環境准備:
1、安裝epel
rpm -Uvh 'http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm'
2、安裝dhcp服務
yum -y install dhcp
3、其他服務的安裝
額外需要的服務還有tftp,rsync,xinetd,httpd。所以如果安裝系統的時候如果這幾個包沒裝上,請手動安裝。
4、關閉selinux
sed -i '/SELINUX/s/enforcing/disabled/' /etc/selinux/config
關閉後最好重啟一下,讓selinux的設置生效
cobbler安裝配置
1、cobbler安裝
yum -y install cobbler
2、cobbler的配置
啟動cobbler
# /etc/init.d/cobblerd start
啟動httpd服務
# /etc/init.d/httpd start
檢查配置,執行
cobbler check
檢查後會出現類似於這樣的日志

主要的修改:
1,編輯/etc/cobbler/settings文件,找到 server選項,修改為適當的ip地址,本實例配置ip為:192.168.10.1
2,編輯/etc/cobbler/settings文件,找到 next_server選項,修改為適當的ip地址,本實例配置ip為:192.168.10.1
3,SELinux的設置。如果上面已經關閉了SELinux就不用管了
4,執行 cobbler get-loaders,系統將自動下載loader程序,完成提示4的修復工作。
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=debmirrorCentOS 6使用RHEL 5的包就可以。
9,修改cobbler用戶的默認密碼,可以使用如下命令生成密碼,並使用生成後的密碼替換/etc/cobbler/settings中的密碼。生成密碼命令:openssl passwd -1 -salt 'random-phrase-here' 'your-password-here'其中“random-phrase-here”為干擾碼

所有提示全部fix之後,執行
/etc/init.d/cobblerd restart

cobbler的使用
1、導入系統鏡像
cobbler import --path=/mnt --name=rhel6.1_x86_64
cobbler會將鏡像中的拷貝到本地一份,放在/var/www/cobbler/ks_mirrors下的rhel6.1_x86_64目錄下。同時會創建一個名字為rhel6.1_x86_64的一個發布版本,以及一個名字為rhel6.1_x86_64的profile文件,次路徑可以作為今後的yum源使用
2、配置dhcp
首先修改cobbler配置,讓cobbler來管理dhcp服務,編輯文件/etc/cobbler/settings
manage_dhcp: 1
接下來修改/etc/cobbler/dhcp.template,此文件是cobbler管理dhcp的模板
對於此文件,本例中只需要修改如下部分
subnet 192.168.10.0 netmask 255.255.255.0 {
option routers 192.168.10.1;
option domain-name-servers 8.8.8.8;
option subnet-mask 255.255.255.0;
range dynamic-bootp 192.168.10.100 192.168.10.254;
filename "/pxelinux.0";
default-lease-time 21600;
max-lease-time 43200;
next-server $next_server;
}
其余部分維持默認值即可。
到目前為止,全部的准備工作已經就算全部完成,接下來要做的就是啟動服務了。在之前的調試過程中,很多服務已經啟動過了,這裡只需要啟動xinetd服務即可:
/etc/init.d/xinetd start
同步cobbler配置
執行
cobbler sync
cobbler會自動進行初始化工作,移除已經存在的啟動項,然後根據模板拷貝loader文件。之後再生成pxe的配置文件,生成dhcp的配置文件,最後再重啟dhcp服務。
3、設置profile
profile可以理解為按角色進行分類。
cobbler profile add --name=webserver --distro= rhel6.1_x86_64 kickstart=/var/lib/cobbler/kickstarts/webserver.ks
cobbler的ks 文件默認都放在/var/lib/cobbler/kickstarts/下面 可以根據不同的需求定制ks文件

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 --disable
# System keyboard
keyboard us
# System language
lang en_US
# Use network installation
url --url=$tree
# 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
clearpart --all --initlabel
part /boot --fstype=ext4 --size=256
part swap --size=1024
part / --fstype=ext4 --size=10240
part /data --fstype=ext4 --grow --size=200
%packages
@base
@core
%end
%post
mkdir /data/sh
mkdir /data/applogs
mkdir /data/appbak
與kickstart的ks文件不太一致,可以根據不同的業務需求編寫不同的ks文件,以便快速的部署應用到服務器

到此就可以安裝系統了
與kickstart不同的是可以選擇所需的操作系統安裝可以多制定一些profile
Copyright © Linux教程網 All Rights Reserved