Cobbler介绍:
Cobbler是一个Linux服务器快速网络安装的服务,而且在经过调整也可以支持网络安装windows。 该工具使用python开发,小巧轻便(才15k行python代码),可以通过网络启动(PXE)的方式来快速安装、重装物理服务器和虚拟机,同时还可以管理DHCP,DNS,TFTP、RSYNC以及yum仓库、构造系统ISO镜像。 Cobbler可以使用命令行方式管理,也提供了基于Web的界面管理工具(cobbler-web),还提供了API接口,可以方便二次开发使用。 Cobbler是较早前的kickstart的升级版,优点是比较容易配置,还自带web界面比较易于管理。 Cobbler内置了一个轻量级配置管理系统,但它也支持和其它配置管理系统集成,如Puppet,暂时不支持SaltStack。 Cobbler客户端Koan支持虚拟机安装和操作系统重新安装,使重装系统更便捷。
Cobbler可以干啥:
使用Cobbler,您无需进行人工干预即可安装机器。Cobbler设置一个PXE引导环境(它还可以使用yaboot支持PowerPC),并 控制与安装相关的所有方面,比如网络引导服务(DHCP和TFTP)与存储库镜像。当希望安装一台新机器时,Cobbler可以: 1)使用一个以前定义的模板来配置DHCP服务(如果启用了管理DHCP) 2)将一个存储库(yum或rsync)建立镜像或解压缩一个媒介,以注册一个新操作系统 3)在DHCP配置文件中为需要安装的机器创建一个条目,并使用指定的参数(IP和MAC) 4)在TFTP服务目录下创建适当的PXE文件 5)重新启动DHCP服务来反应新的更改 6)重新启动机器以开始安装(如果电源管理已启动)
Cobbler支持的系统和功能:
Cobbler支持众多的发行版:RedHat、Fedora、CentOS、Debian、Ubuntu和SUSE。当添加一个操作系统(通常通过使用ISO文件)时,Cobbler知道如何解压缩合适的文件并调整网络服务,以正确引导机器。
Cobbler可以使用kickstart模板。基于Red Hat或 Fedora的系统使用kickstart文件来自动化安装流程。通过使用模板,就会拥有基本的kickstart模板,然后定义如何针对一种配置文件或 机器配置而替换其中的变量。
例如,一个模板可能包含两个变量$domain和$machine_name.在Cobbler配置中,一个配置文件指定 domain=mydomain.com,并且每台使用该配置文件的机器在machine_name变量中指定其名称。该配置文件的所有机器都使用相同的 kickstart安装且针对domain=mydomain.com进行配置,但每台机器拥有其自己的机器名称。您仍然可以使用kickstart模板 在不同的域中安装其他机器并使用不同的机器名称。
为了协助管理系统,Cobbler可通过fence scripts连接到各个电源管理环境。Cobbler支持apc_snmp、bladecenter、bullpap、drac、 ether_wake、ilo、integrity、ipmilan、ipmitool、lpar、rsa、virsh和wti。要重新安装一台机器,可 运行reboot system foo命令,而且Cobbler会使用必要的 和信息来为您运行恰当的fence scripts(比如机器插槽数)。
除了这些特性,还可以使用一个配置管理系统(CMS)。你有两种选择:该工具内的一个内部系统,或者现成的外部CMS,比如Chef或 Puppet。借助内部系统,你可以指定文件模板,这些模板会依据配置参数进行处理(与kickstart模板的处理方式一样),然后复制到你指定的位 置。如果必须自动将配置文件部署到特定机器,那么此功能很有用 使用koan客户端,Cobbler可从客户端配置虚拟机并重新安装系统。
主要目的配置网络接口: Cobbler的配置结构基于一组注册的对象。每个对象表示一个与另一个实体相关联的实体(该对象指向另一个对象,或者另一个对象指向该对象)。当一个对象指向另一个对象时,它就继承了被指向对象的数据,并可覆盖或添加更多特定信息。以下对象类型的定义 Distros(发行版):表示一个操作系统,它承载了内核和initrd的信息,以及内核参数等其他数据 Profile(配置文件):包含一个发行版、一个kickstart文件以及可能的存储库,还包含更多特定的内核参数等其他数据 Systems(系统):表示要配给的额机器。它包含一个配置文件或一个景象,还包含IP和MAC地址、电源管理(地址、凭据、类型)、(网卡绑定、设置valn等) Repository(镜像):保存一个yum或rsync存储库的镜像信息 Image(存储库):可替换一个包含不属于此类比的额文件的发行版对象(例如,无法分为内核和initrd的对象)。 基于注册的对象以及各个对象之间的关联,Cobbler知道如何更改文件系统以反应具体配置。因为系统配置的内部是抽象的,所以您可以仅关注想要执行的操作。
1、基础环境准备
centos6系列:
[root@cobbler ~]# cat /etc/redhat-release #系统版本
CentOS release 6.5 (Final)
[root@cobbler ~]# uname -r #内核版本
2.6.32-431.el6.x86_64
[root@cobbler ~]# getenforce #检测selinux是否关闭(必须关闭)
Disabled
[root@cobbler ~]# /etc/init.d/iptables status #检测防火墙是否关闭(必须关闭)
iptables: Firewall is not running.
[root@cobbler ~]# ifconfig eth0|awk -F '[ :]+' 'NR==2 {print $4}' #查看IP地址
10.0.0.71
[root@cobbler ~]# hostname #查看主机名
cobbler
[root@cobbler ~]# wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo
--2016-05-23 21:10:51-- http://mirrors.aliyun.com/repo/epel-6.repo
Resolving mirrors.aliyun.com... 115.28.122.210, 112.124.140.210
Connecting to mirrors.aliyun.com|115.28.122.210|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1083 (1.1K) [application/octet-stream]
Saving to: “/etc/yum.repos.d/epel.repo” #cobbler安装必须使用到epel源
100%[====================================================================================>] 1,083 --.-K/s in 0s
centos7系列:
[root@cobbler02 ~]# cat /etc/redhat-release #系统版本
CentOS Linux release 7.2.1511 (Core)
[root@cobbler02 ~]# uname -r #内核版本
3.10.0-327.18.2.el7.x86_64
[root@cobbler02 ~]# getenforce #检测selinux是否关闭(必须关闭)
Disabled
[root@cobbler02 ~]# systemctl status firewalld #检测防火墙是否关闭(必须关闭)
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
Active: inactive (dead)
[root@cobbler02 ~]# ifconfig eth0|awk -F '[ :]+' 'NR==2{print $3}'
192.168.31.73
[root@cobbler02 ~]# hostname
cobbler02
[root@cobbler02 ~]# wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
--2016-05-30 07:55:52-- http://mirrors.aliyun.com/repo/epel-7.repo
Resolving mirrors.aliyun.com (mirrors.aliyun.com)... 112.124.140.210, 115.28.122.210
Connecting to mirrors.aliyun.com (mirrors.aliyun.com)|112.124.140.210|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1084 (1.1K) [application/octet-stream]
Saving to: ‘/etc/yum.repos.d/epel.repo’
100%[===============================================================================================>] 1,084 --.-K/s in 0s
2016-05-30 07:55:52 (270 MB/s) - ‘/etc/yum.repos.d/epel.repo’ saved [1084/1084]
注意: 虚拟机网卡采用桥接模式,不使用NAT模式,我们会搭建DHCP服务器,在同一局域网多个DHCP服务会有冲突,所以最好把路由器的DHCP服务关闭t_0015.gif我搭建服务只喜欢用桥接模式
2.安装Cobbler
centos6系列:
[root@cobbler ~]# yum install cobbler cobbler-web pykickstart httpd dhcp tftp-server-y
cobbler #cobbler程序包
cobbler-web #cobbler的web服务包
pykickstart #cobbler检查kickstart语法错误
httpd #Apache web服务
dhcp #dhcp服务
tftp-server #tftp服务
[root@cobbler ~]# 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日志
centos7系列:
[root@cobbler02 ~]# yum install cobbler cobbler-web pykickstart httpd dhcp tftp-server -y
cobbler #cobbler程序包
cobbler-web #cobbler的web服务包
pykickstart #cobbler检查kickstart语法错误
httpd #Apache web服务
dhcp #dhcp服务
tftp-server #tftp服务
3. 检测Cobbler
cobbler的运行依赖于dhcp、tftp、rsync及dns服务,其中dhcp可由dhcpd(isc)提供,也可由dnsmasq提供;tftp可由tftp-server程序包提供,也可由cobbler功能提供,rsync有rsync程序包提供,dns可由bind提供,也可由dnsmasq提供
cobbler可自行管理这些服务中的部分甚至是全部,但需要配置文件/etc/cobbler/settings中的“manange_dhcp”、“manager_tftpd”、“manager_rsync”、“manager_dns”分别来进行定义,另外,由于各种服务都有着不同的实现方式,如若需要进行自定义,需要通过修改/etc/cobbler/modules.conf配置文件中各服务的模块参数的值来实现。
centos6系列:
[root@cobbler cobbler]# /etc/init.d/httpd restart #启动apache服务
Stopping httpd: [ OK ]
Starting httpd: httpd: apr_sockaddr_info_get() failed for cobbler
httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
#遇见报错需要修改apache的配置文件,添加一行
[root@cobbler cobbler]# vim /etc/httpd/conf/httpd.conf
ServerName localhost:80
#再重启服务发现没有报错了
[root@cobbler cobbler]# /etc/init.d/httpd restart
Stopping httpd: [ OK ]
Starting httpd: [ OK ] [ OK ]
[root@cobbler cobbler]# /etc/init.d/cobblerd restart #启动cobbler服务
Stopping cobbler daemon: [ OK ]
Starting cobbler daemon:
centos7系列:
[root@cobbler02 ~]# systemctl start httpd
[root@cobbler02 ~]# systemctl status httpd #查看httpd的状态,看有没有起来
● httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
Active: active (running) since Mon 2016-05-30 08:06:08 CST; 9s ago
Docs: man:httpd(8)
man:apachectl(8)
Main PID: 2317 (httpd)
Status: "Total requests: 0; Current requests/sec: 0; Current traffic: 0 B/sec"
CGroup: /system.slice/httpd.service
├─2317 /usr/sbin/httpd -DFOREGROUND
├─2318 (wsgi:cobbler_w -DFOREGROUND
├─2319 /usr/sbin/httpd -DFOREGROUND
├─2320 /usr/sbin/httpd -DFOREGROUND
├─2321 /usr/sbin/httpd -DFOREGROUND
├─2322 /usr/sbin/httpd -DFOREGROUND
└─2323 /usr/sbin/httpd -DFOREGROUND
May 30 08:06:08 cobbler02 systemd[1]: Starting The Apache HTTP Server...
May 30 08:06:08 cobbler02 httpd[2317]: AH00558: httpd: Could not reliably determine the server's fully qualified domain name, u...message
May 30 08:06:08 cobbler02 systemd[1]: Started The Apache HTTP Server.
Hint: Some lines were ellipsized, use -l to show in full.
[root@cobbler02 ~]# systemctl status cobblerd #查看cobblerd的状态,看有没有起来
● cobblerd.service - Cobbler Helper Daemon
Loaded: loaded (/usr/lib/systemd/system/cobblerd.service; disabled; vendor preset: disabled)
Active: inactive (dead)
[root@cobbler02 ~]# systemctl start cobblerd #开启cobblerd服务
[root@cobbler02 ~]# systemctl status cobblerd #再检查一下,发现确实起来了
● cobblerd.service - Cobbler Helper Daemon
Loaded: loaded (/usr/lib/systemd/system/cobblerd.service; disabled; vendor preset: disabled)
Active: active (running) since Mon 2016-05-30 08:06:39 CST; 1s ago
Process: 2349 ExecStartPost=/usr/bin/touch /usr/share/cobbler/web/cobbler.wsgi (code=exited, status=0/SUCCESS)
Main PID: 2348 (cobblerd)
CGroup: /system.slice/cobblerd.service
└─2348 /usr/bin/python2 /usr/bin/cobblerd -F
May 30 08:06:39 cobbler02 systemd[1]: Starting Cobbler Helper Daemon...
May 30 08:06:39 cobbler02 systemd[1]: Started Cobbler Helper Daemon.
4、检查配置文件,需要在cobblerd和httpd启动的情况下检查
centos6系列:
[root@cobbler cobbler]# cobbler check #检查cobbler配置存在的问题,逐一解决
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 : file /etc/xinetd.d/rsync does not exist
7 : debmirror package is not installed, it will be required to manage debian deployments and repositories
8 : 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
9 : 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/cobbler/settings文件中的server参数的值为提供cobbler服务的主机相应的IP地址或主机名
如server: 192.168.31.71;
#备份原文件
[root@cobbler cobbler]# cp /etc/cobbler/settings{,.ori}
# server,Cobbler服务器的IP,修改384行server: 127.0.0.1
[root@cobbler cobbler]# sed -i 's/server: 127.0.0.1/server: 192.168.31.71/' /etc/cobbler/settings
2、修改/etc/cobbler/settings文件中的next_server参数的值为提供PXE服务的主机相应的IP地址
如next_server: 192.168.31.71;
# server,pxe服务器的IP,由于这里使用的是同一台机器,所以填Cobbler服务器的IP,修改272行next_server: 127.0.0.1
[root@cobbler cobbler]# sed -i 's/next_server: 127.0.0.1/next_server: 192.168.31.71/' /etc/cobbler/settings
#由于sed的匹配规则的原因,上一步就已经把这里给修改了,检查下
[root@cobbler cobbler]# grep "server: 192.168.31.71" settings
next_server: 192.168.31.71
server: 192.168.31.71
3、修改/etc/xinetd.d/tftp文件中的disable参数修改为 disable = no
#备份原文件
[root@cobbler cobbler]# cp /etc/xinetd.d/tftp{,.ori}
#修改替换
[root@cobbler cobbler]# sed -i 's/disable.*= yes/disable = no/g' /etc/xinetd.d/tftp
4、执行 cobbler get-loaders 命令即可;否则,需要安装syslinux程序包,而后复制/usr/share/syslinux/{pxelinux.0,memu.c32}等文件至/var/lib/cobbler/loaders/目录中
[root@cobbler cobbler]# cobbler get-loaders
task started: 2016-05-23_230908_get_loaders
task started (id=Download Bootloader Content, time=Mon May 23 23:09:08 2016)
downloading http://cobbler.github.io/loaders/README to /var/lib/cobbler/loaders/README
downloading http://cobbler.github.io/loaders/COPYING.elilo to /var/lib/cobbler/loaders/COPYING.elilo
downloading http://cobbler.github.io/loaders/COPYING.yaboot to /var/lib/cobbler/loaders/COPYING.yaboot
downloading http://cobbler.github.io/loaders/COPYING.syslinux to /var/lib/cobbler/loaders/COPYING.syslinux
downloading http://cobbler.github.io/loaders/elilo-3.8-ia64.efi to /var/lib/cobbler/loaders/elilo-ia64.efi
downloading http://cobbler.github.io/loaders/yaboot-1.3.17 to /var/lib/cobbler/loaders/yaboot
downloading http://cobbler.github.io/loaders/pxelinux.0-3.86 to /var/lib/cobbler/loaders/pxelinux.0
downloading http://cobbler.github.io/loaders/menu.c32-3.86 to /var/lib/cobbler/loaders/menu.c32
downloading http://cobbler.github.io/loaders/grub-0.97-x86.efi to /var/lib/cobbler/loaders/grub-x86.efi
downloading http://cobbler.github.io/loaders/grub-0.97-x86_64.efi to /var/lib/cobbler/loaders/grub-x86_64.efi
5、修改rsync配置文件
[root@cobbler xinetd.d]# sed -i s/"disable.*= yes"/"disable = no"/g /etc/xinetd.d/rsync
[root@cobbler xinetd.d]# cat /etc/xinetd.d/rsync
# default: off
# description: The rsync server is a good addition to an ftp server, as it \
# allows crc checksumming etc.
service rsync
{
disable = no
flags = IPv6
socket_type = stream
wait = no
user = root
server = /usr/bin/rsync
server_args = --daemon
log_on_failure += USERID
}
6、安装debmirror
[root@cobbler cobbler]# yum install -y debmirror
#安装后再check下会报如下错误
3 : comment out 'dists' on /etc/debmirror.conf for proper debian support4 : comment out 'arches' on /etc/debmirror.conf for proper debian support
#修改配置文件来征服报错,其实不碍事,但是报错有碍眼睛,遂除之
[root@cobbler cobbler]# vim /etc/debmirror.conf
28 #@dists="sid"; 30 #@arches="i386";
注释掉这两行,重新check后没有报错了
7、生成密码来取代默认的密码,更安全
#try: "openssl passwd -1 -salt 'random-phrase-here' 'your-password-here'" to generate new one
#根据提示your-password-here,这里是自己的密码,random-phrase-here,这里是随机的干扰码
[root@cobbler cobbler]# openssl passwd -1 -salt 'renjunjie' '123456'
$1$renjunji$G7LpR5255qFguHrw7E0KP/
[root@cobbler cobbler]# sed -i s/'default_password_crypted:.*'/'default_password_crypted: "$1$renjunji$G7LpR5255qFguHrw7E0KP\/"'/g /etc/cobbler/settings
[root@cobbler cobbler]# grep -n default_pass /etc/cobbler/settings
101:default_password_crypted: "$1$renjunji$G7LpR5255qFguHrw7E0KP/"
8、安装cman fence-agents
[root@cobbler cobbler]# yum install -y cman ence-agents
9、其他一些没有提示报错的小修改
# 用cobbler管理DHCP,修改242行manage_dhcp: 0
[root@cobbler cobbler]# sed -i 's/manage_dhcp: 0/manage_dhcp: 1/g' /etc/cobbler/settings
# 防止循环装系统,适用于服务器第一启动项是PXE启动,修改292行pxe_just_once: 0
[root@cobbler cobbler]# sed -i 's/pxe_just_once: 0/pxe_just_once: 1/' /etc/cobbler/settings
修改完后重启服务再进行一次检测,发现剩下这两个报错,请往下走
[root@cobbler cobbler]# /etc/init.d/httpd restart
Stopping httpd: [ OK ]
Starting httpd: [ OK ]
[root@cobbler cobbler]# /etc/init.d/xinetd restart
Stopping xinetd: [ OK ]
Starting xinetd: [ OK ]
[root@cobbler cobbler]# /etc/init.d/cobblerd restart
Stopping cobbler daemon: [ OK ]
Starting cobbler daemon: [ OK ]
[root@cobbler cobbler]# check
checkmodule checkpolicy
[root@cobbler cobbler]# cobbler check
The following are potential configuration items that you may want to fix:
1 : service dhcpd is not running
2 : file /etc/xinetd.d/rsync does not exist
Restart cobblerd and then run 'cobbler sync' to apply changes.
centos7系列:
[root@cobbler02 ~]# cobbler check #检查cobbler配置存在的问题,逐一解决
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、修改/etc/cobbler/settings文件中的server参数的值为提供cobbler服务的主机相应的IP地址或主机名
如server: 192.168.31.73;
#备份原文件
[root@cobbler02 ~]# cp /etc/cobbler/settings{,.ori}
# server,Cobbler服务器的IP,修改384行server: 127.0.0.1
[root@cobbler02 ~]# sed -i 's/server: 127.0.0.1/server: 192.168.31.73/' /etc/cobbler/settings
2、修改/etc/cobbler/settings文件中的next_server参数的值为提供PXE服务的主机相应的IP地址
如next_server: 192.168.31.73;
# server,pxe服务器的IP,由于这里使用的是同一台机器,所以填Cobbler服务器的IP,修改272行next_server: 127.0.0.1
[root@cobbler02 ~]# sed -i 's/next_server: 127.0.0.1/next_server: 192.168.31.73/' /etc/cobbler/settings
#由于sed的匹配规则的原因,上一步就已经把这里给修改了,检查下
[root@cobbler02 ~]# grep "server: 192.168.31.73" settings
next_server: 192.168.31.713
server: 192.168.31.73
3、修改/etc/xinetd.d/tftp文件中的disable参数修改为 disable = no
#备份原文件
[root@cobbler02 ~]# cp /etc/xinetd.d/tftp{,.ori}
#修改替换
[root@cobbler02 ~r]# sed -i 's/disable.*= yes/disable = no/g' /etc/xinetd.d/tftp
4、执行 cobbler get-loaders 命令即可;否则,需要安装syslinux程序包,而后复制/usr/share/syslinux/{pxelinux.0,memu.c32}等文件至/var/lib/cobbler/loaders/目录中
[root@cobbler02 ~]# cobbler get-loaders
task started: 2016-05-30_082337_get_loaders
task started (id=Download Bootloader Content, time=Mon May 30 08:23:37 2016)
downloading http://cobbler.github.io/loaders/README to /var/lib/cobbler/loaders/README
downloading http://cobbler.github.io/loaders/COPYING.elilo to /var/lib/cobbler/loaders/COPYING.elilo
downloading http://cobbler.github.io/loaders/COPYING.yaboot to /var/lib/cobbler/loaders/COPYING.yaboot
downloading http://cobbler.github.io/loaders/COPYING.syslinux to /var/lib/cobbler/loaders/COPYING.syslinux
downloading http://cobbler.github.io/loaders/elilo-3.8-ia64.efi to /var/lib/cobbler/loaders/elilo-ia64.efi
downloading http://cobbler.github.io/loaders/yaboot-1.3.17 to /var/lib/cobbler/loaders/yaboot
downloading http://cobbler.github.io/loaders/pxelinux.0-3.86 to /var/lib/cobbler/loaders/pxelinux.0
downloading http://cobbler.github.io/loaders/menu.c32-3.86 to /var/lib/cobbler/loaders/menu.c32
downloading http://cobbler.github.io/loaders/grub-0.97-x86.efi to /var/lib/cobbler/loaders/grub-x86.efi
downloading http://cobbler.github.io/loaders/grub-0.97-x86_64.efi to /var/lib/cobbler/loaders/grub-x86_64.efi
*** TASK COMPLETE ***
5、启动rsyncd服务
[root@cobbler02 ~]# systemctl status rsyncd #检查rsyncd服务的状态,发现是关闭的
● rsyncd.service - fast remote file copy program daemon
Loaded: loaded (/usr/lib/systemd/system/rsyncd.service; disabled; vendor preset: disabled)
Active: inactive (dead)
[root@cobbler02 ~]# systemctl enable rsyncd #开启rsync的服务开机自启动
Created symlink from /etc/systemd/system/multi-user.target.wants/rsyncd.service to /usr/lib/systemd/system/rsyncd.service.
[root@cobbler02 ~]# systemctl status rsyncd #检查rsyncd服务的状态
● rsyncd.service - fast remote file copy program daemon
Loaded: loaded (/usr/lib/systemd/system/rsyncd.service; enabled; vendor preset: disabled)
Active: inactive (dead)
[root@cobbler02 ~]# systemctl start rsyncd #开启rsync的服务
[root@cobbler02 ~]# systemctl status rsyncd #再次检查rsyncd服务的状态
● rsyncd.service - fast remote file copy program daemon
Loaded: loaded (/usr/lib/systemd/system/rsyncd.service; enabled; vendor preset: disabled)
Active: active (running) since Mon 2016-05-30 08:27:12 CST; 3s ago
Main PID: 2455 (rsync)
CGroup: /system.slice/rsyncd.service
└─2455 /usr/bin/rsync --daemon --no-detach
May 30 08:27:12 cobbler02 systemd[1]: Started fast remote file copy program daemon.
May 30 08:27:12 cobbler02 systemd[1]: Starting fast remote file copy program daemon...
May 30 08:27:12 cobbler02 rsyncd[2455]: rsyncd version 3.0.9 starting, listening on port 873
6、安装debmirror
[root@cobbler02 ~]# yum install debmirror
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* epel: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
No package debmirror available.
Error: Nothing to do
#这个是提供给debian的管理用的,centos7我没有这个包
7、生成密码来取代默认的密码,更安全
#try: "openssl passwd -1 -salt 'random-phrase-here' 'your-password-here'" to generate new one
#根据提示your-password-here,这里是自己的密码,random-phrase-here,这里是随机的干扰码
[root@cobbler02 ~]# openssl passwd -1 -salt 'renjunjie' '123456'
$1$renjunji$G7LpR5255qFguHrw7E0KP/
[root@cobbler02 ~]# sed -i s/'default_password_crypted:.*'/'default_password_crypted: "$1$renjunji$G7LpR5255qFguHrw7E0KP\/"'/g /etc/cobbler/settings
[root@cobbler02 ~]# grep -n default_pass /etc/cobbler/settings
101:default_password_crypted: "$1$renjunji$G7LpR5255qFguHrw7E0KP/"
8、安装cman fence-agents
[root@cobbler02 ~]# yum install -y cman fence-agents
9、其他一些没有提示报错的小修改
# 用cobbler管理DHCP,修改242行manage_dhcp: 0
[root@cobbler02 ~]# sed -i 's/manage_dhcp: 0/manage_dhcp: 1/g' /etc/cobbler/settings
[root@cobbler02 ~]# grep -n manage_dhcp /etc/cobbler/settings
242:manage_dhcp: 1
269:# if using cobbler with manage_dhcp, put the IP address
355:# Note that if manage_dhcp and manage_dns are disabled, the respective
# 防止循环装系统,适用于服务器第一启动项是PXE启动,修改292行pxe_just_once: 0
[root@cobbler02 ~]# sed -i 's/pxe_just_once: 0/pxe_just_once: 1/' /etc/cobbler/settings
[root@cobbler02 ~]# grep -n pxe_just_once /etc/cobbler/settings
292:pxe_just_once: 1
[root@cobbler02 ~]#
#修改完后重启服务再进行一次检测,发现这个报错,请往下走
[root@cobbler02 ~]# systemctl restart cobblerd.service
[root@cobbler02 ~]# 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
Restart cobblerd and then run 'cobbler sync' to apply changes.
[root@cobbler02 ~]# yum install -y debmirror #再次安装centos7就是没得,求适用于centos7的rpm包或者适用于centos7的编译源码包
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* epel: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
No package debmirror available.
Error: Nothing to do
5、配置DHCP
centos6系列:
# 修改cobbler的dhcp模版,这个模板会覆盖dhcp本身的配置文件。
[root@linux-node1 ~]# vim /etc/cobbler/dhcp.template
#添加如下
subnet 192.168.31.0 netmask 255.255.255.0 {
option domain-name-servers 223.5.5.5;
option routers 192.168.31.1;
range dynamic-bootp 192.168.31.100 192.168.31.250;
option subnet-mask 255.255.255.0;
next-server 192.168.31.71;
filename "/data/sys/kickstart/ks.cfg";
next-server 192.168.31.71;
filename "pxelinux.0";
}
#同步cobbler的配置,可以看到同步干了哪些事
[root@cobbler cobbler]# cobbler sync
task started: 2016-05-27_145749_sync
task started (id=Sync, time=Fri May 27 14:57:49 2016)
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.efi -> /var/lib/tftpboot/grub/grub-x86.efi
trying hardlink /var/lib/cobbler/loaders/grub-x86_64.efi -> /var/lib/tftpboot/grub/grub-x86_64.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: 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 ***
重新检测下发现,只剩下这一个报错,实际上这个文件是有的,无视这个错误
[root@cobbler cobbler]# cobbler check
The following are potential configuration items that you may want to fix:
1 : file /etc/xinetd.d/rsync does not exist
Restart cobblerd and then run 'cobbler sync' to apply changes.
centos7系列:
# 修改cobbler的dhcp模版,这个模板会覆盖dhcp本身的配置文件。
[root@cobbler02 ~]# vim /etc/cobbler/dhcp.template
#添加如下
subnet 192.168.31.0 netmask 255.255.255.0 {
option domain-name-servers 223.5.5.5;
option routers 192.168.31.1;
range dynamic-bootp 192.168.31.100 192.168.31.250;
option subnet-mask 255.255.255.0;
next-server $next_server;
default-lease-time 43200;
max-lease-time 86400;
}
#同步cobbler的配置,可以看到同步干了哪些事
[root@cobbler02 ~]# cobbler sync
task started: 2016-05-30_092640_sync
task started (id=Sync, time=Mon May 30 09:26:40 2016)
running pre-sync triggers
cleaning trees
removing: /var/lib/tftpboot/pxelinux.cfg/default
removing: /var/lib/tftpboot/grub/images
removing: /var/lib/tftpboot/grub/grub-x86.efi
removing: /var/lib/tftpboot/grub/grub-x86_64.efi
removing: /var/lib/tftpboot/grub/efidefault
removing: /var/lib/tftpboot/s390x/profile_list
copying bootloaders
trying hardlink /var/lib/cobbler/loaders/grub-x86.efi -> /var/lib/tftpboot/grub/grub-x86.efi
trying hardlink /var/lib/cobbler/loaders/grub-x86_64.efi -> /var/lib/tftpboot/grub/grub-x86_64.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:
received on stderr: Redirecting to /bin/systemctl restart dhcpd.service
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 ***
6、设置开机自启动
centos6系列:
方法1:全部写到rc.local
[root@cobbler cobbler]# echo "/etc/init.d/httpd restart" >>/etc/rc.local
[root@cobbler cobbler]# echo "/etc/init.d/xinetd restart" >>/etc/rc.local
[root@cobbler cobbler]# echo "/etc/init.d/cobblerd restart" >>/etc/rc.local
[root@cobbler cobbler]# echo "/etc/init.d/dhcpd restart" >>/etc/rc.local
方法2:写一个专门的cobbler开机脚本
cat >>/etc/init.d/cobbler<<EOF
#!/bin/bash
# chkconfig: 345 80 90
# 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
EOF
centos7系列:
#设置开机自动启动,避免白辛苦一场
[root@cobbler02 multi-user.target.wants]# systemctl enable dhcpd.service
[root@cobbler02 multi-user.target.wants]# systemctl enable rsyncd.service
[root@cobbler02 multi-user.target.wants]# systemctl enable tftp.service
[root@cobbler02 multi-user.target.wants]# systemctl enable httpd.service
[root@cobbler02 multi-user.target.wants]# systemctl enable cobblerd.service
#将所有的服务重启一遍,避免有服务忘了开启
[root@cobbler02 multi-user.target.wants]# systemctl restart dhcpd.service
[root@cobbler02 multi-user.target.wants]# systemctl restart rsyncd.service
[root@cobbler02 multi-user.target.wants]# systemctl restart tftp.service
[root@cobbler02 multi-user.target.wants]# systemctl restart httpd.service
[root@cobbler02 multi-user.target.wants]# systemctl restart cobblerd.service
7、Cobbler的命令行管理(6和7的命令是一致的)
[root@cobbler ~]# 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]
cobbler check 核对当前设置是否有问题
cobbler list 列出所有的cobbler元素cobbler
report 列出元素的详细信息
cobbler sync 同步配置到数据目录,更改配置最好都要执行下
cobbler reposync 同步yum仓库
cobbler distro 查看导入的发行版系统信息
cobbler system 查看添加的系统信息cobbler
profile 查看配置信息
8、导入镜像
#挂载centos光盘镜像
[root@cobbler ~]# mount /dev/cdrom /mnt/
mount: block device /dev/sr0 is write-protected, mounting read-only
#导入镜像
[root@cobbler ~]# cobbler import --path=/mnt/ --name=CentOS-6.6-x86_64 --arch=x86_64
task started: 2016-05-27_153110_import
task started (id=Media import, time=Fri May 27 15:31:10 2016)
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.6-x86_64:
creating new distro: CentOS-6.6-x86_64
trying symlink: /var/www/cobbler/ks_mirror/CentOS-6.6-x86_64 -> /var/www/cobbler/links/CentOS-6.6-x86_64
creating new profile: CentOS-6.6-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.6-x86_64 for CentOS-6.6-x86_64
processing repo at : /var/www/cobbler/ks_mirror/CentOS-6.6-x86_64
need to process repo/comps: /var/www/cobbler/ks_mirror/CentOS-6.6-x86_64
looking for /var/www/cobbler/ks_mirror/CentOS-6.6-x86_64/repodata/*comps*.xml
Keeping repodata as-is :/var/www/cobbler/ks_mirror/CentOS-6.6-x86_64/repodata
*** TASK COMPLETE ***
# --path 镜像路径
# --name 为安装源定义一个名字
# --arch 指定安装源是32位、64位、ia64, 目前支持的选项有: x86│x86_64│ia64
# 安装源的唯一标示就是根据name参数来定义,本例导入成功后,安装源的唯一标示就是:CentOS-6.6-x86_64,如果重复,系统会提示导入失败。
#查看镜像列表
[root@cobbler ~]# cobbler distro list
CentOS-6.6-x86_64
## 镜像存放目录,cobbler会将镜像中的所有安装文件拷贝到本地一份,放在/var/www/cobbler/ks_mirror下的CentOS-6.6-x86_64目录下。因此/var/www/cobbler目录必须具有足够容纳安装文件的空间
[root@cobbler ~]# cd /var/www/cobbler/ks_mirror/
[root@cobbler ks_mirror]# ls
CentOS-6.6-x86_64 config
[root@cobbler ks_mirror]# ls CentOS-6.6-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
9、配置ks.cfg(使用centos7的镜像的时候,注意下方的ks.cfg要在安装包那里删除掉@server-policy,这玩意在7没有)
[root@cobbler ks_mirror]# cd /var/lib/cobbler/kickstarts/
[root@cobbler kickstarts]# ls
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(默认使用的ks文件)
sample_esxi4.ks sample.ks sample.seed
[root@cobbler kickstarts]# vim CentOS-6.6-x86_64.cfg
#修改成以下内容
[root@cobbler kickstarts]# cat CentOS-6.6-x86_64.cfg
# 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
authconfig --enableshadow --passalgo=sha512
# System bootloader configuration
bootloader --location=mbr --driveorder=sda --append="nomodeset crashkernel=auto rhgb quiet"
# Partition clearing information
clearpart --all --initlabel
# Use text mode install
text
# Firewall configuration
firewall --disabled
# 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
logging --level=info
#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
#autopart
part /boot --fstype=ext4 --asprimary --size=200
part swap --asprimary --size=1024
part / --fstype=ext4 --grow --asprimary --size=200
%pre
$SNIPPET('log_ks_pre')
$SNIPPET('kickstart_start')
$SNIPPET('pre_install_network_config')
# Enable installation monitoring
$SNIPPET('pre_anamon')
%end
%packages
@base
@compat-libraries
@core
@debugging
@development
@dial-up
@hardware-monitoring
@performance
@server-policy
sgpio
device-mapper-persistent-data
systemtap-client
tree
lrzsz
telnet
nmap
dos2unix
%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
在第一次导入系统镜像后,Cobbler会给镜像指定一个默认的kickstart自动安装文件在/var/lib/cobbler/kickstarts下的sample_end.ks
[root@cobbler kickstarts]# cobbler list
distros:
CentOS-6.6-x86_64
profiles:
CentOS-6.6-x86_64
systems:
repos:
images:
mgmtclasses:
packages:
files
:
查看安装镜像文件信息
[root@cobbler kickstarts]# cobbler distro report --name=CentOS-6.6-x86_64
Name : CentOS-6.6-x86_64
Architecture : x86_64
TFTP Boot Files : {}
Breed : redhat
Comment :
Fetchable Files : {}
Initrd : /var/www/cobbler/ks_mirror/CentOS-6.6-x86_64/images/pxeboot/initrd.img
Kernel : /var/www/cobbler/ks_mirror/CentOS-6.6-x86_64/images/pxeboot/vmlinuz
Kernel Options : {}
Kernel Options (Post Install) : {}
Kickstart Metadata : {'tree': 'http://@@http_server@@/cblr/links/CentOS-6.6-x86_64'}
Management Classes : []
OS Version : rhel6
Owners : ['admin']
Red Hat Management Key : <<inherit>>
Red Hat Management Server : <<inherit>>
Template Files : {}
查看所有的profile设置
cobbler profile report
查看指定的profile设置
cobbler profile report --name=CentOS-6.6-x86_64
[root@cobbler kickstarts]# cobbler profile report
Name : CentOS-6.6-x86_64
TFTP Boot Files : {}
Comment :
DHCP Tag : default
Distribution : CentOS-6.6-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
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@cobbler kickstarts]# cobbler profile edit --name=CentOS-6.6-x86_64 --kickstart=/var/lib/cobbler/kickstarts/CentOS-6.6-x86_64.cfg
修改安装系统的内核参数,在CentOS7系统有一个地方变了,就是网卡名变成eno*****这种形式,但是为了运维标准化,我们需要将它变成我们常用的eth0,因此使用下面的参数。但要注意是CentOS7才需要下面的步骤,CentOS6不需要。
#下次做centos7版本的cobbler的时候再续写
cobbler profile edit --name=CentOS-7.0-x86_64 --kopts='net.ifnames=0 biosdevname=0'
#可以看到下面Kickstart那里的配置cfg文件地址被改变了
[root@cobbler kickstarts]# cobbler profile report --name=CentOS-6.6-x86_64
Name : CentOS-6.6-x86_64
TFTP Boot Files : {}
Comment :
DHCP Tag : default
Distribution : CentOS-6.6-x86_64
Enable gPXE? : 0
Enable PXE Menu? : 1
Fetchable Files : {}
Kernel Options : {}
Kernel Options (Post Install) : {}
Kickstart : /var/lib/cobbler/kickstarts/CentOS-6.6-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
#同步下cobbler数据,每次修改完都要镜像同步
[root@cobbler kickstarts]# cobbler sync
task started: 2016-05-27_162048_sync
task started (id=Sync, time=Fri May 27 16:20:48 2016)
running pre-sync triggers
cleaning trees
#修改这里,开机画面显示,有问题自己去查看之前的操作文本解决
[root@cobbler kickstarts]# vim /etc/cobbler/pxe/pxedefault.template
MENU TITLE Cobbler | QQ:315420700
[root@cobbler kickstarts]# cobbler sync # 修改配置都要同步
这里是如果方向键不选择第二项就无法装机,不算自动化,我们需要进行手动指定才可以完全自动化
定制化安装
kickstart实现某台服务器使用指定ks文件可能比较复杂,但是Cobbler就很简单了,区分一台服务器的最简单的方法就是物理MAC地址。
VMware查看物理MAC地址
[root@cobbler kickstarts]# cobbler system add --name=ren --mac=00:0C:29:4E:73:7F --profile=CentOS-6.6-x86_64 --ip-address=192.168.31.120 --subnet=255.255.255.0 --gateway=192.168.31.1 --interface=eth0 --static=1 --hostname=linux_node --name-servers="223.5.5.5"
[root@cobbler kickstarts]# cobbler system list
ren
[root@cobbler kickstarts]# cobbler sync
###特此说明下
如果你有几块网卡的话,只自定义第二块网卡为外网,第一块网卡不一起配置,就会还是出现在那个选择界面。
[root@cobbler kickstarts]# cobbler system add --name=ren --mac=00:0C:29:4E:73:7F --profile=CentOS-6.6-x86_64 --ip-address=192.168.31.120 --subnet=255.255.255.0 --gateway=192.168.31.1 --interface=eth0 --static=1 --hostname=linux_node --name-servers="223.5.5.5"
[root@cobbler kickstarts]# cobbler system list
ren
[root@cobbler kickstarts]# cobbler sync
###特此说明下
如果你有几块网卡的话,只自定义第二块网卡为外网,第一块网卡不一起配置,就会还是出现在那个选择界面。
#补充!多网卡像这样指定IP和网卡
[root@cobbler02 cobbler]# cobbler system add --name=zabbix02 --mac=00:0C:29:3E:E6:FF --profile=CentOS-7.2-x86_64 --ip-address=10.0.0.82 --subnet=255.255.255.0 --interface=eth0 --static=1
[root@cobbler02 cobbler]# cobbler system edit --name=zabbix02 --mac=00:0C:29:3E:E6:09 --profile=CentOS-7.2-x86_64 --ip-address=192.168.31.82 --subnet=255.255.255.0 --gateway=192.168.31.1 --interface=eth1 --static=1 --hostname=zabbix --name-servers="223.5.5.5"
Cobbler的Web管理界面的安装与配置 新版 Cobbler 的 Web 界面使用的是 https
登录URL: https://192.168.31.71/cobbler_web
默认用户名:cobbler 默认密码 :cobbler /etc/cobbler/users.conf # Web服务授权配置文件 /etc/cobbler/users.digest # 用于web访问的用户名密码配置文件 #在Cobbler组添加ren用户,提示输入2遍密码确认
[root@cobbler kickstarts]# htdigest /etc/cobbler/users.digest "Cobbler" ren
Adding user ren in realm Cobbler
New password:
Re-type new password:
同步下
[root@cobbler kickstarts]# cobbler sync
附录:添加repos源
1.添加repo源
#举个例子,centos7.2版本的openstack的repo源
[root@cobbler02 ~]# cobbler repo add --name=centos7.2-openstack-mitaka --mirror=http://mirrors.aliyun.com/centos/7.2.1511/cloud/x86_64/openstack-mitaka/ --arch=x86_64 --breed=yum
#添加repo源,举个栗子,centos7版本的epel源
[root@cobbler02 ~]# cobbler repo add --name=centos7-x86_64-epel --mirror=http://mirrors.aliyun.com/epel/7/x86_64/ --arch=x86_64 --breed=yum
2.同步repo
[root@cobbler02 ~]# cobbler reposync
3.添加repo到对应的profile
cobbler profile edit --name=Centos-7-x86_64 --repos=
4.修改kickstart文件。添加。(些到%post %end中间)
%post
systemctl disable postfix.service
$yum_config_stanza
%end
5.添加定时任务,定期同步repo
客户机重装系统教程:
centos7系列:
1)不指定详细system模板,让cobbler自己装一台centos7的镜像
#注意上面如果没有指定epel源的是无法装koan包的
#执行这个命令:wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
[root@zabbix ~]# yum install -y koan
#指定cobbler的服务器
[root@zabbix ~]# koan --server=192.168.31.73 --list=profiles
- looking for Cobbler at http://192.168.31.73:80/cobbler_api
CentOS-7.2-x86_64
#指定从哪个镜像进行安装
[root@zabbix ~]# koan --replace-self --server=192.168.31.73 --profile=CentOS-7.2-x86_64
- looking for Cobbler at http://192.168.31.73:80/cobbler_api
- reading URL: http://192.168.31.73/cblr/svc/op/ks/profile/CentOS-7.2-x86_64
install_tree: http://192.168.31.73/cblr/links/CentOS-7.2-x86_64
downloading initrd initrd.img to /boot/initrd.img_koan
url=http://192.168.31.73/cobbler/images/CentOS-7.2-x86_64/initrd.img
- reading URL: http://192.168.31.73/cobbler/images/CentOS-7.2-x86_64/initrd.img
downloading kernel vmlinuz to /boot/vmlinuz_koan
url=http://192.168.31.73/cobbler/images/CentOS-7.2-x86_64/vmlinuz
- reading URL: http://192.168.31.73/cobbler/images/CentOS-7.2-x86_64/vmlinuz
- ['/sbin/grubby', '--add-kernel', '/boot/vmlinuz_koan', '--initrd', '/boot/initrd.img_koan', '--args', '"ksdevice=link lang= text net.ifnames=0 ks=http://192.168.31.73/cblr/svc/op/ks/profile/CentOS-7.2-x86_64 biosdevname=0 kssendmac "', '--copy-default', '--make-default', '--title=kick1464687061']
- ['/sbin/grubby', '--update-kernel', '/boot/vmlinuz_koan', '--remove-args=root']
- reboot to apply changes
#重启系统
[root@zabbix ~]# reboot
2)指定设定好的系统配置,让系统生成一个指定的mac地址绑定的ip和其他你指定的东西
[root@zabbix ~]# yum install -y koan
#指定cobbler的服务器选择system模板
[root@MiWiFi-R2D-srv ~]# koan --server=192.168.31.73 --list=system
- looking for Cobbler at http://192.168.31.73:80/cobbler_api
koan does not know how
[root@MiWiFi-R2D-srv ~]# koan --replace-self --server=192.168.31.73 --system=zabbix02
- looking for Cobbler at http://192.168.31.73:80/cobbler_api
- reading URL: http://192.168.31.73/cblr/svc/op/ks/system/zabbix02
install_tree: http://192.168.31.73/cblr/links/CentOS-7.2-x86_64
downloading initrd initrd.img to /boot/initrd.img_koan
url=http://192.168.31.73/cobbler/images/CentOS-7.2-x86_64/initrd.img
- reading URL: http://192.168.31.73/cobbler/images/CentOS-7.2-x86_64/initrd.img
downloading kernel vmlinuz to /boot/vmlinuz_koan
url=http://192.168.31.73/cobbler/images/CentOS-7.2-x86_64/vmlinuz
- reading URL: http://192.168.31.73/cobbler/images/CentOS-7.2-x86_64/vmlinuz
- ['/sbin/grubby', '--add-kernel', '/boot/vmlinuz_koan', '--initrd', '/boot/initrd.img_koan', '--args', '"ksdevice=link lang= text net.ifnames=0 ks=http://192.168.31.73/cblr/svc/op/ks/system/zabbix02 biosdevname=0 kssendmac "', '--copy-default', '--make-default', '--title=kick1464688081']
- ['/sbin/grubby', '--update-kernel', '/boot/vmlinuz_koan', '--remove-args=root']
- reboot to apply changes to list that
[root@MiWiFi-R2D-srv ~]# reboot
配置就是这样,前路漫漫,多学多练!