35、cobbler自动化安装操作系统
35.1、cobbler介绍:
Cobbler是独立的,不需要先安装Kickstart然后再安装Cobbler;
Cobbler是一个Linux服务器安装的服务,可以通过网络启动(PXE)的方式来快速安装、重装物理服务器和虚拟机,同时还可以管理DHCP,DNS等。
Cobbler可以使用命令行方式管理,也提供了基于Web的界面管理工具(cobbler-web),还提供了API接口,可以方便二次开发使用。
Cobbler是较早前的kickstart的升级版,优点是比较容易配置,还自带web界面比较易于管理。
Cobbler内置了一个轻量级配置管理系统,但它也支持和其它配置管理系统集成,如Puppet,暂时不支持SaltStack。
35.2、cobbler的工作原理:
35.3、cobbler集成的服务:
1、pxe服务支持;
2、dhcp服务管理;
3、dns服务管理;
4、电源管理;
5、kickstart服务支持;
6、yum仓库管理;
7、tpfp(pxe启动时需要)
8、apache(提供kickstart的安装源,并提供定制化kickstart配置)
35.4、系统环境准备:
[root@nfs01 ~]# cat /etc/redhat-release
CentOS release 6.70 (Final)
[root@nfs01 ~]# uname -r
2.6.32-754.3.5.el6.x86_64
[root@nfs01 ~]# hostname
nfs01
[root@nfs01 ~]# getenforce
Disabled
[root@nfs01 ~]# /etc/init.d/iptables status
iptables:未运行防火墙。
[root@nfs01 ~]# ifconfig eth0 | awk -F "[ :]+" 'NR==2 {print $4}'
10.0.0.41
[root@nfs01 ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
注意:
因为此处用的是在eth0上做dhcp设置,且后续的访问都在eth0上进行,所以虚拟机eth0网卡的dhcp选项应该去掉,防止有干扰;
35.4、安装cobbler:
1、安装软件包:
[root@nfs01 tools]# yum install dhcp tftp-server pykickstart httpd mod_ssl rsync
[root@nfs01 tools]# yum -y install cobbler
[root@nfs01 tools]# yum -y install cobbler-web
--> 处理依赖关系 Django >= 1.4,它被软件包 cobbler-web-2.6.11-7.git95749a6.el6.noarch 需要
--> 完成依赖关系计算
错误:Package: cobbler-web-2.6.11-7.git95749a6.el6.noarch (epel)
Requires: Django >= 1.4
解决办法:
软件包下载地址:https://kojipkgs.fedoraproject.org//packages/Django14/1.4.8/1.el6/noarch/Django14-1.4.8-1.el6.noarch.rpm
[root@nfs01 tools]# rz -y
rz waiting to receive.
Starting zmodem transfer. Press Ctrl+C to cancel.
Transferring Django14-1.4.8-1.el6.noarch.rpm...
100% 4421 KB 4421 KB/sec 00:00:01 0 Errors
[root@nfs01 tools]# rpm -ivh Django14-1.4.8-1.el6.noarch.rpm
Preparing... ########################################### [100%]
1:Django14 ########################################### [100%]
[root@nfs01 tools]# yum -y install cobbler-web
[root@nfs01 tools]# rpm -qa dhcp tftp-server pykickstart httpd mod_ssl cobbler cobbler-web rsync
tftp-server-0.49-8.el6.x86_64
cobbler-2.6.11-7.git95749a6.el6.x86_64
httpd-2.2.15-69.el6.centos.x86_64
dhcp-4.1.1-63.P1.el6.centos.x86_64
mod_ssl-2.2.15-69.el6.centos.x86_64
cobbler-web-2.6.11-7.git95749a6.el6.noarch
pykickstart-1.74.22-1.el6.noarch
rsync-3.1.2-6.el6_6.1.x86_64
2、关闭开机自启,防止系统安装:
[root@nfs01 tools]# for n in {dhcpd,xinetd,httpd,cobblerd};do chkconfig $n off;done
[root@nfs01 tools]# for n in {dhcpd,xinetd,httpd,cobblerd};do /etc/init.d/$n stop ;done #停止所有的服务,用时再启用
3、cobbler配置文件介绍:
[root@linux-node1 ~]# rpm -ql cobbler #查看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日志
35.5、配置cobbler:
1、开启httpd服务:
因为cobblerd服务必须依赖httpd服务;
[root@nfs01 ~]# vim /etc/httpd/conf/httpd.conf +276
ServerName 127.0.0.1:80
[root@nfs01 ~]# /etc/init.d/httpd start
正在启动 httpd: [确定]
2、启动cobbler:
[root@nfs01 ~]# /etc/init.d/cobblerd start
Starting cobbler daemon: [确定]
3、检查cobbler的配置:
[root@nfs01 ~]# 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 : change 'disable' to 'no' in /etc/xinetd.d/rsync
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:必须将/etc/cobber/settings中的“server”字段设置为localhost以外的其他值,否则kickstarting功能将不起作用。这应该是引导服务器的可解析主机名或IP,所有使用它的机器都可以访问它。
2:要使PXE正常工作,必须将/etc/cobber/settings中的“下一个服务器”字段设置为127.0.0.1以外的值,并且应与PXE网络上启动服务器的IP相匹配。
3:在/etc/xinetd.d/tftp中将'disable'更改为'no'。
4:在/var/lib/cobber/loaders中缺少一些网络引导加载程序,您可以运行“cobber get-loaders”下载它们,或者,如果您只想处理x86/x86_64 netbooting,您可以确保安装了*最新*版本的syslinux包,并且可以完全忽略此消息。如果您希望支持所有体系结构,则此目录中的文件应包括pxelinux.0、menu.c32、elilo.efi和yaboot。“cobber get loaders”命令是解决这些需求的最简单方法。
5:在/etc/xinetd.d/rsync中将“disable”更改为“no”
6:未安装debmirror包,需要管理debian部署和存储库
7:新安装机器的示例模板使用的默认密码(在/etc/cobber/settings中加密的默认密码)仍然设置为“cobber”,应进行更改,请尝试:“openssl passwd -1 -salt”random phrase here“”your password here“”以生成新密码。
8:未找到围栏工具,需要使用(可选)电源管理功能。安装CMAN或围栏代理以使用它们
9、重新启动cobberd,然后运行“cobber sync”以应用更改。
以上错误逐一修改:
[root@nfs01 ~]# cp -av /etc/cobbler/settings{,.bak} #备份cobbler设置;
"/etc/cobbler/settings" -> "/etc/cobbler/settings.bak"
[root@nfs01 ~]# vim /etc/cobbler/settings +247 +292
manage_dhcp: 1 #使用cobbler管理dhcp,方便传送数据;
restart_dhcp: 1
manage_tftpd: 1 #使用cobbler管理tftp服务,方便传送数据;
pxe_just_once: 1 #防止循环装系统,适用于服务器第一启动项是pxe启动;
(1)
[root@nfs01 ~]# vim /etc/cobbler/settings +384 #修改访问cobbler监听的网卡ip;
server: 10.0.0.31
(2)
[root@nfs01 ~]# vim /etc/cobbler/settings +272 #指定下一跳tftp服务器的ip地址;
next_server: 10.0.0.31
(3)
[root@nfs01 ~]# vim /etc/xinetd.d/tftp #修改tftp的配置;
disable = no
[root@nfs01 ~]# /etc/init.d/xinetd start #启动xinetd(tftp)服务;
正在启动 xinetd: [确定]
(4)
[root@nfs01 ~]# cobbler get-loaders #自动从官网进行下载;
[root@nfs01 ~]# ls /var/lib/cobbler/loaders/
COPYING.elilo COPYING.syslinux COPYING.yaboot elilo-ia64.efi grub-x86_64.efi grub-x86.efi menu.c32 pxelinux.0 README yaboot
(5)
[root@nfs01 ~]# vim /etc/xinetd.d/rsync #修改tftp的配置;
disable = no
(6)
和debian系统相关,不需要;
(7) 设置新装系统的默认root密码是123456;
[root@nfs01 ~]# openssl passwd -1 -salt 'root' '123456'
$1$root$j0bp.KLPyr.u9kgQ428D10
[root@nfs01 ~]# vim /etc/cobbler/settings +101
default_password_crypted: "$1$root$j0bp.KLPyr.u9kgQ428D10"
(8)和fence设备相关,不需要;
4、配置dhcp服务:
修改cobbler的dhcp模板,不要直接修改/etc/dhcp/dchpd.conf本身的配置文件,因为cobbler会覆盖;
以下是部分是cobbler中dhcp配置部分修改的内容:
[root@nfs01 ~]# vim /etc/cobbler/dhcp.template
………………………………………
subnet 10.0.0.0 netmask 255.255.255.0 {
# option routers 192.168.1.5;
# option domain-name-servers 192.168.1.1;
option subnet-mask 255.255.255.0;
range dynamic-bootp 10.0.0.100 10.0.0.200;
………………………………………
5、同步cobbler配置:
(1)重启cobblerd服务:
[root@nfs01 ~]# /etc/init.d/cobblerd restart
Stopping cobbler daemon: [确定]
Starting cobbler daemon: [确定]
(2)同步cobbler配置:
[root@nfs01 ~]# cobbler sync
task started: 2019-01-02_151339_sync
task started (id=Sync, time=Wed Jan 2 15:13:39 2019)
running pre-sync triggers
cleaning trees
removing: /var/lib/tftpboot/grub/images
copying bootloaders
trying hardlink /var/lib/cobbler/loaders/pxelinux.0 -> /var/lib/tftpboot/pxelinux.0
trying hardlink /var/lib/cobbler/loaders/menu.c32 -> /var/lib/tftpboot/menu.c32
trying hardlink /var/lib/cobbler/loaders/yaboot -> /var/lib/tftpboot/yaboot
trying hardlink /usr/share/syslinux/memdisk -> /var/lib/tftpboot/memdisk
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 images
generating PXE configuration files
generating PXE menu structure
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:[确定]
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 ***
(3)查看dhcp服务:
[root@nfs01 ~]# /etc/init.d/dhcpd status #刚开始dhcpd服务是停止的,同步后cobbler后自动启动了;
dhcpd (pid 4993) 正在运行...
[root@nfs01 ~]# less /etc/dhcp/dhcpd.conf #dhcp的配置文件被修改了;
# ******************************************************************
# Cobbler managed dhcpd.conf file
# generated from cobbler dhcp.conf template (Wed Jan 2 07:14:32 2019)
# 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)检查cobbler配置:
[root@nfs01 ~]# 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 #debian系统需要的包,这里不需要;
2 : fencing tools were not found, and are required to use the (optional) power management features. install cman or fence-agents to use them #和fence设备相关,不需要;
Restart cobblerd and then run 'cobbler sync' to apply changes.
(5)编写cobbler启动脚本:
[root@nfs01 scripts]# vim /etc/init.d/cobbler
#!/bin/bash
#chkconfig: 345 20 21
#description:cobbler
case $1 in
start)
/etc/init.d/httpd start
/etc/init.d/xinetd start
/etc/init.d/dhcpd start
/etc/init.d/cobblerd start
;;
stop)
/etc/init.d/httpd stop
/etc/init.d/xinetd stop
/etc/init.d/dhcpd stop
/etc/init.d/cobblerd stop
;;
restart)
/etc/init.d/httpd restart
/etc/init.d/xinetd restart
/etc/init.d/dhcpd restart
/etc/init.d/cobblerd restart
;;
status)
/etc/init.d/httpd status
/etc/init.d/xinetd status
/etc/init.d/dhcpd status
/etc/init.d/cobblerd status
;;
sync)
cobbler sync
;;
*)
echo "Input error,please in put 'start|stop|restart|status|sync'!"
exit 2
;;
esac
[root@nfs01 scripts]# chmod u+x /etc/init.d/cobbler
[root@nfs01 scripts]# chkconfig --add /etc/init.d/cobbler
[root@nfs01 ~]# /etc/init.d/cobbler restart
停止 httpd: [确定]
正在启动 httpd: [确定]
停止 xinetd: [确定]
正在启动 xinetd: [确定]
关闭 dhcpd: [确定]
正在启动 dhcpd: [确定]
Stopping cobbler daemon: [确定]
Starting cobbler daemon: [确定]
(6)cobbler命令介绍:
cobbler check #核对当前的设置是否有问题;
cobbler list #列出所有的cobbler元素;
cobbler report #列出元素的所有信息;
cobbler sync #同步配置到数据目录,/etc/cobbler/setting的配置都要执行该操作;
cobbler reposync #同步yum仓库;
cobbler system #查看添加的系统信息;
cobbler profile #查看配置信息;
cobbler import #导入镜像
35.6、导入镜像:
1、挂载centos6.7镜像:
[root@nfs01 ~]# mount /dev/cdrom /mnt
mount: block device /dev/sr0 is write-protected, mounting read-only
2、导入镜像系统:
(1)由于镜像有点大,所以拷贝到/var/www/cobbler/ks_mirror下需要一定的时间:
[root@nfs01 ~]# cobbler import --path=/mnt/ --name=CentOS-6.7-x86_64 --arch=x86_64
task started: 2019-01-02_212202_import
task started (id=Media import, time=Wed Jan 2 21:22:02 2019)
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/CentOS-6.7-x86_64:
creating new distro: CentOS-6.7-x86_64
creating new profile: CentOS-6.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/CentOS-6.7-x86_64 for CentOS-6.7-x86_64
processing repo at : /var/www/cobbler/ks_mirror/CentOS-6.7-x86_64
need to process repo/comps: /var/www/cobbler/ks_mirror/CentOS-6.7-x86_64
looking for /var/www/cobbler/ks_mirror/CentOS-6.7-x86_64/repodata/*comps*.xml
Keeping repodata as-is :/var/www/cobbler/ks_mirror/CentOS-6.7-x86_64/repodata
*** TASK COMPLETE ***
[root@nfs01 ~]# ls /var/www/cobbler/ks_mirror/
CentOS-6.7-x86_64 config
[root@nfs01 ~]# ls /var/www/cobbler/ks_mirror/CentOS-6.7-x86_64/
CentOS_BuildTag EULA images Packages repodata RPM-GPG-KEY-CentOS-Debug-6 RPM-GPG-KEY-CentOS-Testing-6
EFI GPL isolinux RELEASE-NOTES-en-US.html RPM-GPG-KEY-CentOS-6 RPM-GPG-KEY-CentOS-Security-6 TRANS.TBL
(2)参数介绍:
--path #镜像路径;
--name #为安装源定义一个名字,安装源的唯一标识是由name参数来定义的,如果重复,系统会提示导入失败;
--arch #指定安装源是32位、64位、ia64位、目前支持的选项有x86|x86_64|ia64
(3)查看所有元素列表:
[root@nfs01 ~]# cobbler list
distros:
CentOS-6.7-x86_64 #对应的是/var/www/cobbler/ks_mirror/CentOS-6.7-x86_64目录;
profiles:
CentOS-6.7-x86_64 #对应的是/var/www/cobbler/ks_mirror/config/CentOS-6.7-x86_64-0.repo文件
systems:
repos:
images:
mgmtclasses:
packages:
files:
cobbler distro list cobbler profile list #查看所有镜像/配置信息列表
(4)如何移除安装源:
[root@nfs01 ks_mirror]# cobbler distro remove --name=CentOS-6.7-X86_64-x86_64
[root@nfs01 ks_mirror]# cobbler profile remove --name=CentOS-6.7-X86_64-x86_64
(5)同步数据:
[root@nfs01 ~]# cobbler sync
copying distros to tftpboot
copying files for distro: CentOS-6.7-x86_64
trying hardlink /var/www/cobbler/ks_mirror/CentOS-6.7-x86_64/images/pxeboot/vmlinuz -> /var/lib/tftpboot/images/CentOS-6.7-x86_64/vmlinuz
trying hardlink /var/www/cobbler/ks_mirror/CentOS-6.7-x86_64/images/pxeboot/initrd.img -> /var/lib/tftpboot/images/CentOS-6.7-x86_64/initrd.img
copying images
generating PXE configuration files
generating PXE menu structure
copying files for distro: CentOS-6.7-x86_64
trying hardlink /var/www/cobbler/ks_mirror/CentOS-6.7-x86_64/images/pxeboot/vmlinuz -> /var/www/cobbler/images/CentOS-6.7-x86_64/vmlinuz
trying hardlink /var/www/cobbler/ks_mirror/CentOS-6.7-x86_64/images/pxeboot/initrd.img -> /var/www/cobbler/images/CentOS-6.7-x86_64/initrd.img
35.7、指定ks.cfg文件及调整内核参数:
1、[root@nfs01 ~]# cd /var/lib/cobbler/kickstarts/
[root@nfs01 kickstarts]# ls #cobbler自带了很多的ks文件sample_end.ks是默认的;
default.ks esxi5-ks.cfg legacy.ks sample_autoyast.xml sample_esx4.ks sample_esxi5.ks sample_old.seed
esxi4-ks.cfg install_profiles pxerescue.ks sample_end.ks sample_esxi4.ks sample.ks
2、查看指定发行镜像的文件信息:
[root@nfs01 ~]# cobbler distro report --name=CentOS-6.7-x86_64
Name : CentOS-6.7-x86_64
Architecture : x86_64
TFTP Boot Files : {}
Breed : redhat
Comment :
Fetchable Files : {}
Initrd : /var/www/cobbler/ks_mirror/CentOS-6.7-x86_64/images/pxeboot/initrd.img
Kernel : /var/www/cobbler/ks_mirror/CentOS-6.7-x86_64/images/pxeboot/vmlinuz
Kernel Options : {}
Kernel Options (Post Install) : {}
Kickstart Metadata : {'tree': 'http://@@http_server@@/cblr/links/CentOS-6.7-x86_64'}
Management Classes : []
OS Version : rhel6
Owners : ['admin']
Red Hat Management Key : <<inherit>>
Red Hat Management Server : <<inherit>>
Template Files : {}
3、查看指定的发行镜像的配置信息:
[root@nfs01 ~]# cobbler profile report --name=CentOS-6.7-x86_64
Name : CentOS-6.7-x86_64
TFTP Boot Files : {}
Comment :
DHCP Tag : default
Distribution : CentOS-6.7-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文件,默认的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
4、cobbler distro report 、cobbler profile report #查看所有镜像的文件信息/配置信息;
5、使用自己配置的ks文件:
[root@nfs01 ~]# vim /var/lib/cobbler/kickstarts/CentOS-6.7-X86_64.cfg
install
url --url=$tree #$代表引用/etc/cobbler/setting中的配置;
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')
$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
echo 'welcom to lc_linux' >/etc/motd
>/etc/issue
/etc/init.d/postfix off
%end
6、修改默认的ks配置文件:
[root@nfs01 ~]# cobbler profile edit --name=CentOS-6.7-x86_64 --kickstart=/var/lib/cobbler/kickstarts/CentOS-6.7-X86_64.cfg
[root@nfs01 ~]# cobbler profile report --name=CentOS-6.7-x86_64
Name : CentOS-6.7-x86_64
TFTP Boot Files : {}
Comment :
DHCP Tag : default
Distribution : CentOS-6.7-x86_64
Enable gPXE? : 0
Enable PXE Menu? : 1
Fetchable Files : {}
Kernel Options : {}
Kernel Options (Post Install) : {}
Kickstart : /var/lib/cobbler/kickstarts/CentOS-6.7-X86_64.cfg #更改后的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
7、修改cobbler的提示:
[root@nfs01 ~]# vim /etc/cobbler/pxe/pxedefault.template
DEFAULT menu
PROMPT 0
MENU TITLE Cobbler | Install Optimization Linux System By LC
TIMEOUT 200
TOTALTIMEOUT 6000
ONTIMEOUT $pxe_timeout_profile
LABEL local
MENU LABEL (local)
MENU DEFAULT
LOCALBOOT -1
$pxe_menu_items
MENU end
8、同步数据:
[root@nfs01 ~]# cobbler sync
35.7、cobbler的web管理界面的安装与配置:
1、登录:
默认的账号和密码都是cobbler
2、设置cobbler web用户的登录密码:
#web服务授权配置文件,admin用户和cobbler用户;
[root@nfs01 ~]# egrep -v "^$|#" /etc/cobbler/users.conf
[admins]
admin = ""
cobbler = ""
#用于web访问的用户名和密码配置文件;
[root@nfs01 ~]# cat /etc/cobbler/users.digest
cobbler:Cobbler:a2d6bae81669d707b72c0bd9806e01f3
#重置cobbler用户的密码,"Cobbler"代表的是描述,cobbler代表的是用户名;
[root@nfs01 ~]# htdigest /etc/cobbler/users.digest "Cobbler" cobbler
Changing password for user cobbler in realm Cobbler
New password: #123456
Re-type new password: #123456
[root@nfs01 ~]# /etc/init.d/httpd restart #重启cobblerd依赖服务httpd
停止 httpd: [确定]
正在启动 httpd: [确定]
[root@nfs01 ~]# /etc/init.d/cobblerd restart #重启cobblerd服务
Stopping cobbler daemon: [确定]
Starting cobbler daemon: [确定]
[root@nfs01 ~]# cobbler sync #同步数据
3、使用更新密码后的cobbler账号进行登录:
(1)导入镜像:
(2)发行版本:
(3)简介:
(4)同步:
(5)cobbler站点目录:
#httpd的/etc/httpd/conf/httpd.conf配置文件中包含了/etc/httpd/conf.d/配置文件目录;
cat /etc/httpd/conf/httpd.conf | grep conf.d
# Load config files from the config directory "/etc/httpd/conf.d".
Include conf.d/*.conf
#cobbler的网站配置文件;
cat /etc/httpd/conf.d/cobbler_web.conf
#查看到cobbler的url地址;
ls /usr/share/cobbler/web/cobbler_web
35.8、安装操作系统:
1、新建一台虚拟机,稍后安装操作系统,网卡使用eth0,我这里使用的nat指向eth0网卡;
2、启动虚拟机:
35.9、定制化安装linux系统:
1、新建一台虚拟机,稍后安装操作系统,网卡使用eth0,我这里使用的nat指向eth0网卡;
2、如下图所示生成虚拟的mac地址;
3、cobbler配置:
[root@nfs01 ~]# cobbler system add --name=lc --mac=00:50:56:27:40:80 --profile=CentOS-6.7-x86_64 --ip-address=10.0.0.128 \
--subnet=255.255.255.0 --gateway=10.0.0.253 --interface=eth0 --static=1 --hostname=cobbler --name-servers="114.114.114.114 8.8.8.8"
[root@nfs01 ~]# cobbler system list #查看system元素列表;
lc
[root@nfs01 ~]# cobbler system report --name=lc #查看lc的配置属性; cobbler system report #查看所有system信息
Name : lc
Gateway : 10.0.0.253
Hostname : cobbler
Name Servers : ['114.114.114.114', '8.8.8.8']
Profile : CentOS-6.7-x86_64
Status : production
Virt PXE Boot : 0
Interface ===== : eth0
IP Address : 10.0.0.128
MAC Address : 00:50:56:27:40:80
Management Interface : False
Subnet Mask : 255.255.255.0
Static : True
[root@nfs01 ~]# cobbler sync #同步数据;
4、测试:
(1)启动虚拟机:
(2)查看网卡:
5、如何去除添加system元素:
[root@nfs01 ~]# cobbler system remove --name=lc
[root@nfs01 ~]# cobbler system list
[root@nfs01 ~]# cobbler sync
总结:
1、httpd是cobblerd服务的依赖服务,修改httpd配置并启动httpd服务后再启动cobblerd服务,使用cobbler check检查并
修改xinetd、dhcpd 、cobblerd主配置文件后,启动xinetd服务,重启cobblerd服务,cobbler sync 同步配置,此时同步的
是dhcp的/etc/dhcp/dhcpd.conf(打开了dhcpd服务)和/var/lib/tftproot/(pxelinux.0......);
2、在httpd、xinetd、dhcpd,cobblerd启动的情况下,cobbler import导入镜像是到http中,然后使用cobbler sync同步
将操作系统的initrd.img vmlinuz 和优化好的系统isolinux.cfg文件同步到/var/lib/tftproot/下,同理使用cobbler distro/profile
remove/edit 操作也要进行cobbler sync同步操作,如果修改httpd、xinetd、dhcpd,cobblerd的主配置文件都要重启服务;
3、在httpd、xinetd、dhcpd,cobblerd启动下对cobblerd服务配置进行操作,都需要进行cobbler sync操作,如
果修改的是cobblerd服务的主配置文件需要进行重启后再进行cobbler sync操作,httpd、xinetd dhcpd服务如果不是修改
主配置文件不需要重启;httpd服务是cobblerd的依赖服务,启动cobblerd之前必须先启动httpd服务;
5、cobbler的原理和kickstart是一样的,只不过是用cobbler集中管理了(管理tftp-server、dhcpd),简化了配置,可以选择安装多个版本的系统;
6、cobbler profile edit --name=CentOS-7.1-x86_64 --kopts='net.ifnames=0 biosdevname=0' #将centos7中的网卡一改为eth0方便标准化安装;