四、配置管理Cobbler
4.1 Cobbler命令说明
命令名称
|
命令用途
|
cobbler check
|
检查cobbler配置
|
cobbler list
|
列出所youdecobbler元素
|
cobbler report
|
列出元素de详细信息
|
cobbler distro
|
查看导入de发行版系统信息
|
cobbler system
|
查看添加de系统信息
|
cobbler profile
|
查看配置信息
|
cobbler sync
|
同步Cobbler配置,更改配置最好都要执行下
|
cobbler reposync
|
同步yum仓库
|
命令参考
cobbler --help
cobbler distro --help
cobbler distro add --help
4.2 Cobbler配置文件说明
Cobbler配置文件存放在/etc/cobbler下
配置文件名称
|
作 用
|
/etc/cobbler/settings
|
Cobbler主配置文件
|
/etc/cobbler/users.digest
|
用于web访问de用户名密码配置文件
|
/etc/cobbler/modules.conf
|
模块配置文件
|
/etc/cobbler/users.conf
|
Cobbler WebUI/Web 服务授权配置文件
|
/etc/cobbler/iso/
|
Buildiso 模板配置文件
|
/etc/cobbler/power
|
电源配置文件
|
/etc/cobbler/pxe
|
Pxeprofile配置模板
|
/etc/cobbler
|
此目录也包含rsync、dhcp、dns、pxe、dnsmasq等服务de模板配置文件
|
4.3 系统镜像数据目录/var/www/cobbler
导入de系统发行版,repos镜像和kickstart文件都放置在/var/www/cobbler目录下。确保/var目录you足够de空间来存储这些文件。
目录名称
|
作 用
|
/var/www/cobbler/images/
|
存储所you导入发行版deKernel和initrd镜像用于远程网络启动
|
/var/www/cobbler/ks_mirror/
|
存储导入de发行版系统数据
|
/var/www/cobbler/repo_mirror/
|
仓库存储目录
|
/var/log/cobbler
|
Cobbler日志文件 cobbler.log install.log
|
4.4 Cobbler数据目录/var/lib/cobbler
此目录存储和Cobbler profiles、systems、distros相关de配置。
目录名称
|
作 用
|
/var/lib/cobbler/config/
|
存放distros、repos、systems和profiles等信息配置文件,一般都是json文件
|
/var/lib/cobbler/snippets/
|
存放ks文件可以导入de脚本小片段,值得研究
|
/var/lib/cobbler/triggers
|
存放用户定义decobbler 命令
|
/var/lib/cobbler/kickstarts/
|
存放kickstart配置文件
|
4.5 相关日志文件
web日志存放点
/var/log/httpd/access_log
/var/log/httpd/error_log
/var/log/httpd/ssl_access_log
/var/log/httpd/ssl_error_log
Cobbler日志
/var/log/cobbler/cobbler.log
/var/log/cobbler/install.log
通过Cobbler日志可以获取系统de安装状态
4.6 导入系统镜像
4.6.1 上传ISO镜像至服务器
注意下载deISO文件要核对文件demd5值,确保数据完整性
[root@hxinstall x86_64]# md5sum CentOS-5.8-x86_64-bin-DVD-1of2.iso
8a3bf0030f192022943f83fe6b2cf373 CentOS-5.8-x86_64-bin-DVD-1of2.iso
4.6.2 创建ISO目录
mkdir -p /var/iso/Linux/Centos/x86_64/
mkdir -p /var/os/Linux/Centos/x86_64/Centos5.8/dvd
mkdir -p /var/os/Linux/Centos/x86_64/Centos6.3/dvd
mkdir -p /var/os/Linux/Centos/x86_64/Centos6.4/dvd
4.6.3 挂载ISO镜像
mount -o loop /var/iso/Linux/Centos/x86_64/CentOS-5.8-x86_64-bin-DVD-1of2.iso /var/os/Linux/Centos/x86_64/Centos5.8/dvd
4.6.4 从DVD中导入OS数据
系统版本命名为centos5.8 架构x86_64,这时间长,耐性等待。可查看ls /var/www/cobbler/ks_mirror/centos5.8-x86_64/目录文件生成情况。
cobbler import --path=/var/os/Linux/Centos/x86_64/Centos5.8/dvd --name=centos5.8 --arch=x86_64
task started: 2013-03-12_132624_import
task started (id=Media import, time=Tue Mar 12 13:26:24 2013)
Found a redhat compatible signature: CentOS
adding distros
creating new distro: centos5.8-xen-x86_64
creating new profile: centos5.8-xen-x86_64
creating new distro: centos5.8-x86_64
creating new profile: centos5.8-x86_64
associating repos
traversing distro centos5.8-xen-x86_64
descent into /var/www/cobbler/ks_mirror/centos5.8-x86_64
processing repo at : /var/www/cobbler/ks_mirror/centos5.8-x86_64
need to process repo/comps: /var/www/cobbler/ks_mirror/centos5.8-x86_64
looking for /var/www/cobbler/ks_mirror/centos5.8-x86_64/repodata/*comps*.xml
running: createrepo -c cache -s sha --groupfile /var/www/cobbler/ks_mirror/centos5.8-x86_64/repodata/comps.xml /var/www/cobbler/ks_mirror/centos5.8-x86_64
3496/3496 - CentOS/finger-0.17-33.x86_64.rpm pm6_64.rpm
Saving Primary metadata
Saving file lists metadata
Saving other metadata
received on stderr: This option is deprecated
traversing distro centos5.8-x86_64
descent into /var/www/cobbler/ks_mirror/centos5.8-x86_64
processing repo at : /var/www/cobbler/ks_mirror/centos5.8-x86_64
need to process repo/comps: /var/www/cobbler/ks_mirror/centos5.8-x86_64
looking for /var/www/cobbler/ks_mirror/centos5.8-x86_64/repodata/*comps*.xml
running: createrepo -c cache -s sha --groupfile /var/www/cobbler/ks_mirror/centos5.8-x86_64/repodata/comps.xml /var/www/cobbler/ks_mirror/centos5.8-x86_64
3496/3496 - CentOS/finger-0.17-33.x86_64.rpm pm6_64.rpm
Saving Primary metadata
Saving file lists metadata
Saving other metadata
received on stderr: This option is deprecated
associating kickstarts
*** TASK COMPLETE ***
4.6.5 列出导入后de配置
cobbler list
distros:
centos5.8-x86_64
centos5.8-xen-x86_64
centos6.3-x86_64
centos6.4-x86_64
profiles:
centos5.8-x86_64
centos5.8-xen-x86_64
centos6.3-x86_64
centos6.4-x86_64
systems:
repos:
images:
mgmtclasses:
packages:
files:
列出详细信息可以使用cobbler report
4.6.6 比对大小,确保数据de完整性
du -sh /var/www/cobbler/ks_mirror/centos5.8-x86_64/
4.1G /var/www/cobbler/ks_mirror/centos5.8-x86_64/
du -sh /var/os/Linux/Centos/x86_64/Centos5.8/dvd/
4.3G /var/os/Linux/Centos/x86_64/Centos5.8/dvd/
4.6.7 CentOS6.3、6.4导入过程
CentOS6.3
mount -o loop /var/iso/Linux/Centos/x86_64/CentOS-6.3-x86_64-bin-DVD1.iso /var/os/Linux/Centos/x86_64/Centos6.3/dvd/
cobbler import --path=/var/os/Linux/Centos/x86_64/Centos6.3/dvd/ --name=centos6.3 --arch=x86_64
CentOS6.4
mount -o loop /var/iso/Linux/Centos/x86_64/CentOS-6.4-x86_64-bin-DVD1.iso /var/os/Linux/Centos/x86_64/Centos6.4/dvd/
cobbler import --path=/var/os/Linux/Centos/x86_64/Centos6.4/dvd/ --name=centos6.4 --arch=x86_64
4.7 删除导入de系统
cobbler profile find --distro=centos6.3-x64-x86_64
#
查看配置是否存在
centos6.3-x64-x86_64
cobbler profile remove --name=centos6.3-x64-x86_64
#
删除配置文件
cobbler distro remove --name=centos6.3-x64-x86_64
#
删除distro
cobbler profile find --distro=centos6.3-x64-x86_64
#
再查看配置已无
4.8 自定义ks
更改kickstart文件,可为http等,具体cobbler --help查看,这里采用wo men 自定制ks文件
ks目录位置
/var/lib/cobbler/kickstarts/
默认deks位置
/var/lib/cobbler/kickstarts/sample.ks
更改指定系统版本对应deks配置文件
cobbler profile edit --name=centos5.8-x86_64 --kickstart=/var/lib/cobbler/kickstarts/centos5u8-x64.cfg
cobbler profile edit --name=centos6.3-x86_64 --kickstart=/var/lib/cobbler/kickstarts/centos6u3-x64.cfg
cobbler profile edit --name=centos6.4-x86_64 --kickstart=/var/lib/cobbler/kickstarts/centos6u4-x64.cfg
4.9 配置信息查看
cobbler report
distros:
==========
Name : centos5.8-xen-x86_64
Architecture : x86_64
TFTP Boot Files : {}
Breed : redhat
Comment : rhel5.8
Fetchable Files : {}
Initrd : /var/www/cobbler/ks_mirror/centos5.8-x86_64/images/xen/initrd.img
Kernel : /var/www/cobbler/ks_mirror/centos5.8-x86_64/images/xen/vmlinuz
Kernel Options : {}
Kernel Options (Post Install) : {}
Kickstart Metadata : {'tree': 'http://@@http_server@@/cblr/links/centos5.8-xen-x86_64'}
Management Classes : []
OS Version : rhel5
Owners : ['admin']
Red Hat Management Key : <<inherit>>
Red Hat Management Server : <<inherit>>
Template Files : {}
Name : centos6.4-x86_64
Architecture : x86_64
TFTP Boot Files : {}
Breed : redhat
Comment : rhel6.4
Fetchable Files : {}
Initrd : /var/www/cobbler/ks_mirror/centos6.4-x86_64/images/pxeboot/initrd.img
Kernel : /var/www/cobbler/ks_mirror/centos6.4-x86_64/images/pxeboot/vmlinuz
Kernel Options : {}
Kernel Options (Post Install) : {}
Kickstart Metadata : {'tree': 'http://@@http_server@@/cblr/links/centos6.4-x86_64'}
Management Classes : []
OS Version : rhel6
Owners : ['admin']
Red Hat Management Key : <<inherit>>
Red Hat Management Server : <<inherit>>
Template Files : {}
……略……
systems:
==========
repos:
==========
images:
==========
mgmtclasses:
==========
packages:
==========
files:
==========
4.10 系统版本列表
cobbler distro list
centos5.8-x86_64
centos5.8-xen-x86_64
centos6.3-x86_64
centos6.4-x86_64
4.11 同步Cobbler配置
建议先执行cobbler check进行配置检查再执行cobbler sync,修改cobbler配置后都需要执行此步骤
cobbler check
No configuration problems found. All systems go.
cobbler sync
task started: 2013-03-12_171702_sync
task started (id=Sync, time=Tue Mar 12 17:17:02 2013)
running pre-sync triggers
cleaning trees
……略……
rendering Rsync files
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: Shutting down dhcpd: [ OK ]
Starting dhcpd: [ OK ]
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 ***
4.12 创建PXE菜单密码
增加装机安全设置菜单密码
生成hash密码
支持两种不同类型de密码:
或
openssl passwd -1 -salt sXiKzkus mypassword
我这里选择后者
# openssl passwd -1 -salt sXiKzkus hexun
$1$sXiKzkus$2DoZ6pfTe8rrc0Si60ecB/
编辑配置文件pxedefault,添加如下蓝色部分
vim /etc/cobbler/pxe/pxedefault.template
DEFAULT menu
PROMPT 0
MENU TITLE Cobbler | http://fedorahosted.org/cobbler
MENU MASTER PASSWD $1$sXiKzkus$2DoZ6pfTe8rrc0Si60ecB/
TIMEOUT 200
TOTALTIMEOUT 6000
ONTIMEOUT $pxe_timeout_profile
LABEL local
MENU LABEL (local)
MENU DEFAULT
LOCALBOOT -1
$pxe_menu_items
MENU end
配置pxeprofile,增加蓝色部分
vim /etc/cobbler/pxe/pxeprofile.template
LABEL $profile_name
MENU PASSWD
kernel $kernel_path
$menu_label
$append_line
ipappend 2
修改完毕注意检查、同步配置使其生效
cobbler check
No configuration problems found. All systems go.
cobbler sync
PXE装机时选择装机系统版本,输入装机密码,效果图
4.13 定制PXE菜单TITLE
编辑pxedefault文件,
vim /etc/cobbler/pxe/pxedefault.template
MENU TITLE Cobbler | http://fedorahosted.org/cobbler
将原文上面de内容根据自定义进行修改
MENU TITLE Hexun Automation Install System
修改后de文件
DEFAULT menu
PROMPT 0
MENU TITLE Hexun Automation Install System
MENU MASTER PASSWD $1$sXiKzkus$2DoZ6pfTe8rrc0Si60ecB/
TIMEOUT 200
TOTALTIMEOUT 6000
ONTIMEOUT $pxe_timeout_profile
LABEL local
MENU LABEL (local)
MENU DEFAULT
LOCALBOOT -1
$pxe_menu_items
MENU end
修改完毕执行如下两条命令
cobbler check
cobbler sync
4.14 添加指定客户机系统配置到Cobbler
4.14.1 指定一个网段使用特定de装机配置
cobbler system add --name=network --ip=172.17.188.0/16 --profile=centos5.8-x86_64
4.14.2 添加一个指定服务器de装机配置
指定服务器就是绑定它demac地址,并设置好ip、dns、hostname
定义系统
cobbler system add --name=host-188116 --hostname=host-188116 --mac=00:19:B9:E5:34:FE --interface=eth0 --ip-address=172.17.188.116 --subnet=255.255.0.0 --gateway=172.17.188.1 --static=1 --profile=centos5.8-x86_64
查看定义de系统列表
cobbler system list
host-188116
更多参数见cobbler system add --help
五、Cobbler Web管理
Cobbler web界面是一个很好de前端,非常容易管理Cobbler
可以添加和删除 system distro profile
可以查看、编辑distros, profiles, subprofiles, systems, repos 、 kickstart文件
5.1 安装cobbler_web
yum -y install cobbler-web
5.2 设置用户名密码
为已存在de用户cobbler重置密码
htdigest /etc/cobbler/users.digest "Cobbler" cobbler
添加新用户
htdigest /etc/cobbler/users.digest "Cobbler" your_newname
5.3 配置cobbler web可以登录
sed -i 's/authn_denyall/authn_configfile/g' /etc/cobbler/modules.conf
5.4 重启Cobbler与http
/etc/init.d/cobblerd restart
/etc/init.d/httpd restart
5.5 访问Cobbler Web页面
浏览器访问登录页面https://172.17.10.14/cobbler_web
输入用户名密码
登录后de页面
web管理相对易于使用管理这里这就不再赘述。