1.1 cobbler簡介
Cobbler是一個Linux服務器安裝的服務,能夠經過網絡啓動(PXE)的方式來快速安裝、重裝物理服務器和虛擬機,同時還能夠管理DHCP,DNS等。html
Cobbler可使用命令行方式管理,也提供了基於Web的界面管理工具(cobbler-web),還提供了API接口,能夠方便二次開發使用。node
Cobbler是較早前的kickstart的升級版,優勢是比較容易配置,還自帶web界面比較易於管理。python
Cobbler內置了一個輕量級配置管理系統,但它也支持和其它配置管理系統集成,如Puppet,暫時不支持SaltStack。linux
Cobbler官網http://cobbler.github.ioios
在使用cobbler以前須要瞭解kickstart的使用: http://www.cnblogs.com/clsn/p/7833333.htmlgit
1.1.1 cobbler集成的服務
PXE服務支持github
DHCP服務管理web
DNS服務管理(可選bind,dnsmasq)django
電源管理vim
Kickstart服務支持
YUM倉庫管理
TFTP(PXE啓動時須要)
Apache(提供kickstart的安裝源,並提供定製化的kickstart配置)
注意:
- 虛擬機網卡採用NAT模式,不要使用橋接模式,由於稍後咱們會搭建DHCP服務器,在同一局域網多個DHCP服務會有衝突。
- VMware的NAT模式的dhcp服務也關閉,避免干擾。
1.2 安裝cobbler
1.2.1 環境說明
[root@Cobbler ~]# cat /etc/redhat-release
CentOS Linux release 7.4.1708 (Core)
[root@Cobbler ~]# uname -r
3.10.0-693.el7.x86_64
[root@Cobbler ~]# getenforce
Disabled
[root@Cobbler ~]# systemctl status firewalld.service
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
Active: inactive (dead)
Docs: man:firewalld(1)
[root@Cobbler ~]# hostname -I
192.168.1.230
阿里雲yum源說明:
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
1.2.2 使用yum安裝cobbler
yum -y install cobbler cobbler-web dhcp tftp-server pykickstart httpd
cobbler:核心程序不用多解釋
dhcp:負責分配客戶端IP,由於客戶端沒有IP,因此須要dhcp服務
tftp(Trivial File Transfer Protocol,簡單文件傳輸協議):是TCP/IP協議族中的一個用來在客戶機與服務器之間進行簡單文件傳輸的協議,提供不復雜、開銷不大的文件傳輸服務。端口號爲69。
xinetd:xinetd已經取代了inetd,而且提供了訪問控制、增強的日誌和資源管理功能,已經成了Red Hat 7 和 Mandrake 7.2的Internet標準超級守護進程
syslinux:syslinux是一個功能強大的引導加載程序,並且兼容各類介質。它的目的是簡化首次安裝Linux的時間,並創建修護或其它特殊用途的啓動盤。它提供pxelinux這個文件,pxelinux.0引導文件引導vmlinux和initrd兩個啓動文件
httpd:可使別的主機能夠從服務端獲取鏡像包
[root@linux-node1 ~]# rpm -ql cobbler # 查看安裝的文件,下面列出部分。
/etc/cobbler # 配置文件目錄
/etc/cobbler/settings # cobbler主配置文件,這個文件是YAML格式,Cobbler是python寫的程序。
/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模塊配置文件
/var/lib/cobbler # Cobbler數據目錄
/var/lib/cobbler/config # 配置文件
/var/lib/cobbler/kickstarts # 默認存放kickstart文件
/var/lib/cobbler/loaders # 存放的各類引導程序
/var/www/cobbler # 系統安裝鏡像目錄
/var/www/cobbler/ks_mirror # 導入的系統鏡像列表
/var/www/cobbler/images # 導入的系統鏡像啓動文件
/var/www/cobbler/repo_mirror # yum源存儲目錄
/var/log/cobbler # 日誌目錄
/var/log/cobbler/install.log # 客戶端系統安裝日誌
/var/log/cobbler/cobbler.log # cobbler日誌
說明:cobbler是依賴與epel源下載
1.2.3 cobbler語法檢查前先啓動http與cobbler
systemctl start httpd.service
systemctl start cobblerd.service
cobbler check # 檢查Cobbler的配置
1.2.4 進行語法檢查
[root@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 : change 'disable' to 'no' in /etc/xinetd.d/tftp
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 : enable and start rsyncd.service with systemctl
6 : debmirror package is not installed, it will be required to manage debian deployments and repositories
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
8 : fencing tools were not found, and are required to use the (optional) power management features. install cman or fence-agents to use them
Restart cobblerd and then run 'cobbler sync' to apply changes.
1.2.5 解決當中的報錯
命令集
sed -i 's/server: 127.0.0.1/server: 192.168.1.230/' /etc/cobbler/settings
sed -i 's/next_server: 127.0.0.1/next_server: 192.168.1.230/' /etc/cobbler/settings
sed -i 's/manage_dhcp: 0/manage_dhcp: 1/' /etc/cobbler/settings
sed -i 's/pxe_just_once: 0/pxe_just_once: 1/' /etc/cobbler/settings
sed -ri "/default_password_crypted/s#(.*: ).*#\1\"`openssl passwd -1 -salt 'xue' '123456'`\"#" /etc/cobbler/settings
sed -i 's#yes#no#' /etc/xinetd.d/tftp
systemctl start rsyncd
systemctl enable rsyncd
systemctl enable tftp.socket
systemctl start tftp.socket
systemctl restart cobblerd.service
.3 配置DHCP
# 修改cobbler的dhcp模版,不要直接修改dhcp自己的配置文件,由於cobbler會覆蓋。
[root@linux-node1 ~]# vim /etc/cobbler/dhcp.template
# 僅列出修改過的字段
……
subnet 192.168.1.0 netmask 255.255.255.0 {
option routers 192.168.1.1;
option domain-name-servers 192.168.1.1;
option subnet-mask 255.255.255.0;
range dynamic-bootp 192.168.1.240 192.168.1.245;
……
cobbler sync #同步最新cobbler配置,它會根據配置自動修改dhcp等服務。
# 再看一下dhcp的配置文件。
[root@linux-node1 ~]# less /etc/dhcp/dhcpd.conf
# ******************************************************************
# Cobbler managed dhcpd.conf file
# generated from cobbler dhcp.conf template (Thu Dec 3 12:48:23 2015)
# Do NOT make changes to /etc/dhcpd.conf. Instead, make your changes
# in /etc/cobbler/dhcp.template, as /etc/dhcpd.conf will be
# overwritten.
# ******************************************************************
ddns-update-style interim;
4下載包所需的軟件包
[root@Cobbler ~]# cobbler get-loaders
[root@Cobbler ~]# ls /var/lib/cobbler/loaders
COPYING.elilo elilo-ia64.efi menu.c32 yaboot
COPYING.syslinux grub-x86_64.efi pxelinux.0
COPYING.yaboot grub-x86.efi README
5啓動rsync服務
[root@Cobbler ~]# systemctl start rsyncd.service
[root@Cobbler ~]# systemctl enable rsyncd.service
6 debian相關無需修改
7、修改安裝完成後的root密碼,設置新裝系統的默認root密碼123456。下面的命令來源於提示6。random-phrase-here爲干擾碼,能夠自行設定設置新裝系統的默認root密碼123456。下面的命令來源於提示6。random-phrase-here爲干擾碼,能夠自行設定
openssl passwd -1 -salt 'random-phrase-here' 'your-password-here'
random-phrase-here 隨機字符串
your-password-here 密碼
示例
[root@Cobbler ~]# openssl passwd -1 -salt 'xue' '123456'
$1$CLSN$LpJk4x1cplibx3q/O4O/K/
管理dhcp,用Cobbler管理DHCP
sed -i 's/manage_dhcp: 0/manage_dhcp: 1/' /etc/cobbler/settings
防止重裝,防止循環裝系統,適用於服務器第一啓動項是PXE啓動。
sed -i 's/pxe_just_once: 0/pxe_just_once: 1/' /etc/cobbler/settings
修改dhcp模板
sed -i.ori 's#192.168.1#172.16.1#g;22d;23d' /etc/cobbler/dhcp.template
cobbler組配置文件位置
注意:修改完成以後要使用cobbler sync 進行同步,不然不生效。
1.2.6 修改以後
再次檢查語法:
[root@Cobbler ~]# cobbler check
The following are potential configuration items that you may want to fix:
1 : debmirror package is not installed, it will be required to manage debian deployments and repositories
2 : fencing tools were not found, and are required to use the (optional) power management features. install cman or fence-agents to use them
Restart cobblerd and then run 'cobbler sync' to apply changes.
重啓全部服務
systemctl restart httpd.service
systemctl restart cobblerd.service
systemctl restart dhcpd.service
systemctl restart rsyncd.service
systemctl restart tftp.socket
3. Cobbler的命令行管理
3.1 查看命令幫助
[root@linux-node1 ~]# cobbler
usage
=====
cobbler <distro|profile|system|repo|image|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@linux-node1 ~]# cobbler import --help # 導入鏡像
Usage: cobbler [options]
Options:
-h, --help show this help message and exit
--arch=ARCH OS architecture being imported
--breed=BREED the breed being imported
--os-version=OS_VERSION
the version being imported
--path=PATH local path or rsync location
--name=NAME name, ex 'RHEL-5'
--available-as=AVAILABLE_AS
tree is here, don't mirror
--kickstart=KICKSTART_FILE
assign this kickstart file
--rsync-flags=RSYNC_FLAGS
pass additional flags to rsync
cobbler check 覈對當前設置是否有問題
cobbler list 列出全部的cobbler元素
cobbler report 列出元素的詳細信息
cobbler sync 同步配置到數據目錄,更改配置最好都要執行下
cobbler reposync 同步yum倉庫
cobbler distro 查看導入的發行版系統信息
cobbler system 查看添加的系統信息
cobbler profile 查看配置信息
經查看日誌
[root@localhost /]# rpm -qa | grep "python2-django" python2-django-1.11.13-4.el7.noarch Django 的版本問題 TEMPLATE_CONTEXT_PROCESSORS was deprecated in Django 1.8 and removed in Django 1.10. It's not possible to import it anymore. 解決方法 一、rpm -e
3.2 導入鏡像
[root@linux-node1 ~]# mount /dev/cdrom /mnt/ # 掛載CentOS7的系統鏡像。
# 導入系統鏡像
[root@linux-node1 ~]# cobbler import --path=/mnt/ --name=CentOS-7.1-x86_64 --arch=x86_64
# --path 鏡像路徑
# --name 爲安裝源定義一個名字
# --arch 指定安裝源是32位、64位、ia64, 目前支持的選項有: x86│x86_64│ia64
# 安裝源的惟一標示就是根據name參數來定義,本例導入成功後,安裝源的惟一標示就是:CentOS-7.1-x86_64,若是重複,系統會提示導入失敗。
[root@linux-node1 ~]# cobbler distro list # 查看鏡像列表
CentOS-7.1-x86_64
# 鏡像存放目錄,cobbler會將鏡像中的全部安裝文件拷貝到本地一份,放在/var/www/cobbler/ks_mirror下的CentOS-7.1-x86_64目錄下。所以/var/www/cobbler目錄必須具備足夠容納安裝文件的空間。
[root@linux-node1 ~]# cd /var/www/cobbler/ks_mirror/
[root@linux-node1 ks_mirror]# ls
CentOS-7.1-x86_64 config
[root@linux-node1 ks_mirror]# ls CentOS-7.1-x86_64/
CentOS_BuildTag GPL LiveOS RPM-GPG-KEY-CentOS-7
EFI images Packages RPM-GPG-KEY-CentOS-Testing-7
EULA isolinux repodata TRANS.TBL
3.3 指定ks.cfg文件及調整內核參數
# Cobbler的ks.cfg文件存放位置
[root@linux-node1 ks_mirror]# cd /var/lib/cobbler/kickstarts/
[root@linux-node1 kickstarts]# ls # 自帶不少
default.ks install_profiles sample_autoyast.xml sample_esxi4.ks sample_old.seed
esxi4-ks.cfg legacy.ks sample_end.ks(默認使用的ks文件) sample_esxi5.ks sample.seed
esxi5-ks.cfg pxerescue.ks sample_esx4.ks sample.ks
[root@linux-node1 kickstarts]# rz # 上傳準備好的ks文件
rz waiting to receive.
Starting zmodem transfer. Press Ctrl+C to cancel.
Transferring Cobbler-CentOS-7.1-x86_64.cfg...
100% 1 KB 1 KB/sec 00:00:01 0 Errors
[root@linux-node1 kickstarts]# mv Cobbler-CentOS-7.1-x86_64.cfg CentOS-7.1-x86_64.cfg
# 在第一次導入系統鏡像後,Cobbler會給鏡像指定一個默認的kickstart自動安裝文件在/var/lib/cobbler/kickstarts下的sample_end.ks。
[root@linux-node1 ~]# cobbler list
distros:
CentOS-7.1-x86_64
profiles:
CentOS-7.1-x86_64
systems:
repos:
images:
mgmtclasses:
packages:
files:
# 查看安裝鏡像文件信息
[root@linux-node1 ~]# cobbler distro report --name=CentOS-7.1-x86_64
Name : CentOS-7.1-x86_64
Architecture : x86_64
TFTP Boot Files : {}
Breed : redhat
Comment :
Fetchable Files : {}
Initrd : /var/www/cobbler/ks_mirror/CentOS-7.1-x86_64/images/pxeboot/initrd.img
Kernel : /var/www/cobbler/ks_mirror/CentOS-7.1-x86_64/images/pxeboot/vmlinuz
Kernel Options : {}
Kernel Options (Post Install) : {}
Kickstart Metadata : {'tree': 'http://@@http_server@@/cblr/links/CentOS-7.1-x86_64'}
Management Classes : []
OS Version : rhel7
Owners : ['admin']
Red Hat Management Key : <<inherit>>
Red Hat Management Server : <<inherit>>
Template Files : {}
# 查看全部的profile設置
[root@linux-node1 ~]# cobbler profile report
# 查看指定的profile設置
[root@linux-node1 ~]# cobbler profile report --name=CentOS-7.1-x86_64
Name : CentOS-7.1-x86_64
TFTP Boot Files : {}
Comment :
DHCP Tag : default
Distribution : CentOS-7.1-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 -->默認ks文件
Kickstart Metadata : {}
Management Classes : []
Management Parameters : <<inherit>>
Name Servers : []
Name Servers Search Path : []
Owners : ['admin']
Parent Profile :
Internal 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
# 編輯profile,修改關聯的ks文件
[root@linux-node1 ~]# cobbler profile edit --name=CentOS-7.1-x86_64 --kickstart=/var/lib/cobbler/kickstarts/CentOS-7.1-x86_64.cfg
# 修改安裝系統的內核參數,在CentOS7系統有一個地方變了,就是網卡名變成eno16777736這種形式,可是爲了運維標準化,咱們須要將它變成咱們經常使用的eth0,所以使用下面的參數。但要注意是CentOS7才須要下面的步驟,CentOS6不須要。
[root@linux-node1 ~]# cobbler profile edit --name=CentOS-7.1-x86_64 --kopts='net.ifnames=0 biosdevname=0'
[root@linux-node1 ~]# cobbler profile report CentOS-7.1-x86_64
Name : CentOS-7.1-x86_64
TFTP Boot Files : {}
Comment :
DHCP Tag : default
Distribution : CentOS-7.1-x86_64
Enable gPXE? : 0
Enable PXE Menu? : 1
Fetchable Files : {}
Kernel Options : {'biosdevname': '0', 'net.ifnames': '0'}
Kernel Options (Post Install) : {}
Kickstart : /var/lib/cobbler/kickstarts/CentOS-7.1-x86_64.cfg
Kickstart Metadata : {}
Management Classes : []
Management Parameters : <<inherit>>
Name Servers : []
Name Servers Search Path : []
Owners : ['admin']
Parent Profile :
Internal 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
# 每次修改完都要同步一次
[root@linux-node1 ~]# cobbler sync
3.4 安裝系統
能夠很愉快的告訴你到這裏就能夠安裝系統了!
新建一臺虛擬機,不解釋,開機就能夠看到下面的圖片了!
** 有沒有發現不美觀的地方?**
網址不是個人!改!
#修改Cobbler提示
[root@linux-node1 ~]# vim /etc/cobbler/pxe/pxedefault.template
MENU TITLE Cobbler | http://www.zyops.com
[root@linux-node1 ~]# cobbler sync # 修改配置都要同步
OK,如今好看多了。選擇第二項就能夠繼續裝機了。你可讓系統飛着,而後接着看下文!!
4. ks.cfg文件簡析
文件大部分參數含義見kickstart文章,此處只講一些不一樣的地方。同時能夠參考模板文件。
[root@linux-node1 kickstarts]# cat CentOS-7.1-x86_64.cfg
# Cobbler for Kickstart Configurator for CentOS 7.1 by yao zhang
install
url --url=$tree # 這些$開頭的變量都是調用配置文件裏的值。
text
lang en_US.UTF-8
keyboard us
zerombr
bootloader --location=mbr --driveorder=sda --append="crashkernel=auto rhgb quiet"
# Network information
$SNIPPET('network_config')
timezone --utc Asia/Shanghai
authconfig --enableshadow --passalgo=sha512
rootpw --iscrypted $default_password_crypted
clearpart --all --initlabel
part /boot --fstype xfs --size 1024 # CentOS7系統磁盤默認格式xfs
part swap --size 1024
part / --fstype xfs --size 1 --grow
firstboot --disable
selinux --disabled
firewall --disabled
logging --level=info
reboot
%pre
$SNIPPET('log_ks_pre')
$SNIPPET('kickstart_start')
$SNIPPET('pre_install_network_config')
# Enable installation monitoring
$SNIPPET('pre_anamon')
%end
%packages
@base
@compat-libraries
@debugging
@development
tree
nmap
sysstat
lrzsz
dos2unix
telnet
iptraf
ncurses-devel
openssl-devel
zlib-devel
OpenIPMI-tools
screen
%end
%post
systemctl disable postfix.service
%end
5. 定製化安裝
可能從學習kickstart開始就有人想怎樣可以指定某臺服務器使用指定ks文件,kickstart實現這功能可能比較複雜,可是Cobbler就很簡單了。
區分一臺服務器的最簡單的方法就是物理MAC地址。
物理服務器的MAC地址在服務器上的標籤上寫了。
虛擬機的MAC查看
cobbler system add --name=oldboy --mac=00:0C:29:7F:2F:A1 --profile=CentOS-7.1-x86_64 --ip-address=10.0.0.111 --subnet=255.255.255.0 --gateway=10.0.0.2 --interface=eth0 --static=1 --hostname=oldboy.example.com --name-servers="114.114.114.114 8.8.8.8"
# --name 自定義,但不能重複
# 查看定義的列表
[root@linux-node1 ~]# cobbler system list
oldboy
[root@linux-node1 ~]# cobbler sync
再次開機安裝就再也不詢問選擇了,直接安裝。
6. Cobbler的Web管理界面的安裝與配置
已經安裝cobbler-web軟件。
訪問網址:http://10.0.0.7/cobbler_web
和https://10.0.0.7/cobbler_web
默認用戶名:cobbler
默認密碼 :cobbler
到此cobbler就安裝完成,下面進行web界面的操做。
1.3 cobbler的web及界面操做
瀏覽器訪問https://10.0.0.202/cobbler_web
注意CentOS7中cobbler只支持https訪問。
帳號密碼默認均爲cobbler
1.3.1 操做說明--導入鏡像
1)在虛擬機上添加上鏡像
2)掛載上鏡像
[root@Cobbler ~]# mount /dev/cdrom /mnt/
mount: /dev/sr0 is write-protected, mounting read-only
[root@Cobbler ~]# df -h |grep mnt
/dev/sr0 4.3G 4.3G 0 100% /mnt
3)進行導入鏡像
選擇Import DVD 輸入Prefix(文件前綴),Arch(版本),Breed(品牌),Path(要從什麼地方導入)
在導入鏡像的時候要注意路徑,防止循環導入。
信息配置好後,點擊run,便可進行導入。
導入過程使用rsync進行導入,三個進程消失表示導入完畢
[root@Cobbler mnt]# ps -ef |grep rsync
root 12026 1 0 19:04 ? 00:00:00 /usr/bin/rsync --daemon --no-detach
root 13554 11778 12 19:51 ? 00:00:06 rsync -a /mnt/ /var/www/cobbler/ks_mirror/CentOS7.4-x86_64 --progress
root 13555 13554 0 19:51 ? 00:00:00 rsync -a /mnt/ /var/www/cobbler/ks_mirror/CentOS7.4-x86_64 --progress
root 13556 13555 33 19:51 ? 00:00:17 rsync -a /mnt/ /var/www/cobbler/ks_mirror/CentOS7.4-x86_64 --progress
root 13590 10759 0 19:52 pts/1 00:00:00 grep --color=auto rsync
查看日誌能夠發現右running進程
日誌位於 Events
導入完成後生成的文件夾
[root@Cobbler ks_mirror]# pwd
/var/www/cobbler/ks_mirror
[root@Cobbler ks_mirror]# ls
CentOS7.4-x86_64 config
1.3.2 建立一臺空白虛擬機,進行測試網路安裝
注意:虛擬機的內存不能小於2G,網卡的配置要保證網絡互通
啓動虛擬機
啓動虛擬機便可發現會有cobbler的選擇界面
選擇CentOS7.4便可進行安裝,安裝過程與光盤安裝一致,這裏就不在複述。
1.4 定製化安裝操做系統
1.4.1 添加內核參數
1)查看導入的鏡像,點擊edit
2)在內核參數中添加net.ifnames=0 biosdevname=0
可以讓顯示的網卡變爲eth0 ,而不是CentOS7中的ens33
修改完成後點擊保存
1.4.2 查看鏡像屬性
1.4.3 編寫ks文件
1)建立新的ks文件
2)添加ks文件,並配置文件名
建立完成後點擊Save進行保存
CentOS7 ks配置文件參考
1 # Cobbler for Kickstart Configurator for CentOS 7 by clsn
2 install
3 url --url=$tree
4 text
5 lang en_US.UTF-8
6 keyboard us
7 zerombr
8 bootloader --location=mbr --driveorder=sda --append="crashkernel=auto rhgb quiet"
9 #Network information
10 $SNIPPET('network_config')
11 #network --bootproto=dhcp --device=eth0 --onboot=yes --noipv6 --hostname=CentOS7
12 timezone --utc Asia/Shanghai
13 authconfig --enableshadow --passalgo=sha512
14 rootpw --iscrypted $default_password_crypted
15 clearpart --all --initlabel
16 part /boot --fstype xfs --size 1024
17 part swap --size 1024
18 part / --fstype xfs --size 1 --grow
19 firstboot --disable
20 selinux --disabled
21 firewall --disabled
22 logging --level=info
23 reboot
24
25 %pre
26 $SNIPPET('log_ks_pre')
27 $SNIPPET('kickstart_start')
28 $SNIPPET('pre_install_network_config')
29 # Enable installation monitoring
30 $SNIPPET('pre_anamon')
31 %end
32
33 %packages
34 @^minimal
35 @compat-libraries
36 @core
37 @debugging
38 @development
39 bash-completion
40 chrony
41 dos2unix
42 kexec-tools
43 lrzsz
44 nmap
45 sysstat
46 telnet
47 tree
48 vim
49 wget
50 %end
51
52 %post
53 systemctl disable postfix.service
54 %end
1.4.4 自定義安裝系統
1)選擇systems 建立一個新的系統
2)定義系統信息
3)配置全局網絡信息
主機名、網關、DNS
4)配置網卡信息,eth0,eth1
須要注意,選擇static靜態,
以上的全部配置完成後,點擊Save進行保存
附錄:
VMware workstation中查看虛擬機mac地址的方法。在虛擬機設置中。
cobbler web 界面說明
1.5 安裝虛擬機
1.5.1 開啓虛擬機
若是以前的設置就顯示安裝進度
1.5.2 安裝完成進行檢查
1.6 cobbler使用常見錯誤
1.6.1 cobbler check報錯
[root@Cobbler ~]# cobbler sync
Traceback (most recent call last):
File "/usr/bin/cobbler", line 36, in <module>
sys.exit(app.main())
File "/usr/lib/python2.7/site-packages/cobbler/cli.py", line 662, in main
rc = cli.run(sys.argv)
File "/usr/lib/python2.7/site-packages/cobbler/cli.py", line 269, in run
self.token = self.remote.login("", self.shared_secret)
File "/usr/lib64/python2.7/xmlrpclib.py", line 1233, in __call__
return self.__send(self.__name, args)
File "/usr/lib64/python2.7/xmlrpclib.py", line 1587, in __request
verbose=self.__verbose
File "/usr/lib64/python2.7/xmlrpclib.py", line 1273, in request
return self.single_request(host, handler, request_body, verbose)
File "/usr/lib64/python2.7/xmlrpclib.py", line 1306, in single_request
return self.parse_response(response)
File "/usr/lib64/python2.7/xmlrpclib.py", line 1482, in parse_response
return u.close()
File "/usr/lib64/python2.7/xmlrpclib.py", line 794, in close
raise Fault(**self._stack[0])
xmlrpclib.Fault: <Fault 1: "<class 'cobbler.cexceptions.CX'>:'login failed'">
解決辦法
systemctl restart httpd.service
systemctl restart cobblerd.service
cobbler check
1.6.2 No space left on device
出現這個錯誤的緣由是虛擬機的內存不足2G,
將內存調爲2G便可(這個錯誤只會出如今CentOS7.3之上)
1.7 附錄cobbler_CentOS6.x_ks配置文件
# Cobbler for Kickstart Configurator for CentOS 6 by clsn
install
url --url=$tree
text
lang en_US.UTF-8
keyboard us
zerombr
bootloader --location=mbr --driveorder=sda --append="crashkernel=auto rhgb quiet"
$SNIPPET('network_config')
timezone --utc Asia/Shanghai
authconfig --enableshadow --passalgo=sha512
rootpw --iscrypted $default_password_crypted
clearpart --all --initlabel
part /boot --fstype=ext4 --asprimary --size=200
part swap --size=1024
part / --fstype=ext4 --grow --asprimary --size=200
firstboot --disable
selinux --disabled
firewall --disabled
logging --level=info
reboot
%pre
$SNIPPET('log_ks_pre')
$SNIPPET('kickstart_start')
$SNIPPET('pre_install_network_config')
# Enable installation monitoring
$SNIPPET('pre_anamon')
%end
%packages
@base
@compat-libraries
@debugging
@development
tree
nmap
sysstat
lrzsz
dos2unix
telnet
%end
%post --nochroot
$SNIPPET('log_ks_post_nochroot')
%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
1.8 參考文檔
http://blog.oldboyedu.com/autoinstall-cobbler/
http://www.zyops.com/autoinstall-cobbler