Cobbler内置了一个轻量级配置管理系统,但它也支持和其它配置管理系统集成,如Puppet,暂时不支持SaltStack。
PXE+KICKSTART 参见:https://blog.csdn.net/openbox2008/article/details/80089567
(8)Apache(提供kickstart的安装源,并提供定制化的kickstart配置)
(0)环境准备
1.dell r720 服务器1台
2.vware workstation 10
3.手动安装一台centos7.4做为部署服务器,配置以下各步骤后,再启多个新的虚拟,实现自动安装
虚拟机网卡采用NAT模式,不要使用桥接模式,DHCP服务器,在同一局域网多个DHCP服务会有冲突。
VMware的NAT模式的dhcp服务要关闭,避免干扰。
(1)由于涉及到主机间不同基于不同协议的通信,所以为了避免不必要的麻烦,我们选择关闭防火墙以及selinux。
#systemctl disable firewalld # 关闭防火墙网卡改名eth0,参见:https://blog.csdn.net/openbox2008/article/details/80051259
(4)阿里云的epel源
访问阿里mirrors镜像网址:http://mirrors.aliyun.com ,找到epel下的epel-release-latest-7.noarch.rpm 包,wget下载下来再安装,或直接用rpm安装.
rpm -ivh https://mirrors.aliyun.com/epel/epel-release-latest-7.noarch.rpm
安装完后,会在/etc/yum.repos.d/ 下生成两个文件 : epel.repo , epel-testing.repo
(5)注意事项
虚拟机网卡采用NAT模式,不要使用桥接模式,因为稍后我们会搭建DHCP服务器,在同一局域网多个DHCP服务会有冲突。
VMware的NAT模式的dhcp服务也关闭,避免干扰。
(1)安装HTTP服务
yum -y install httpd
#systemctl enable httpd
#systemctl start httpd # 启动http服务
(2)安装xinetd、tftp-server服务, 配置xinetd,由xinetd管理tftp
# yum install -y xinetd
# yum install -y tftp-server
# vim /etc/xinetd.d/tftp
#---------可用最简配置-------------------
service tftp
{
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/in.tftpd
server_args = -s /var/lib/tftpboot
disable = no #默认disable是yes的,把它改为no即可
per_source = 11
cps = 100 2
flags = IPv4
}
systemctl enable tftp
systemctl enable xinetd
systemctl start tftp
systemctl start xinetd
(3)安装DHCP服务
# yum install dhcp -y
# 在安装cobbler后,修改cobbler中,带的dhcp模版,不要直接修改dhcp本身的配置文件,因为cobbler会覆盖。
# vim /etc/cobbler/dhcp.template ,不用手动复制,通过cobbler sync同步即可
# 仅列出修改过的字段
……
subnet 192.168.128.0 netmask 255.255.255.0 {:
range 192.168.128.10 192.168.128.50; #ip地址
option routers 192.168.128.2; #网关
option domain-name-servers 192.168.128.2; #DNS
}
……
#systemctl start dhcpd
#systemctl enable dhcpd
(4)安装pykickstart
yum -y install pykickstart
# 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日志
#systemctl restart cobblerd
#systemctl enable cobblerd
# systemctl status cobblerd
修改vim /etc/cobbler/settings 文件
#修改以下几项
default_password_crypted: "$1$cobbler$M6SE55xZodWc9.vAKLJs6." #root密码,用openssl passwd -1 -salt 'cobbler' 'cobbler' 生成
manage_dhcp: 1 #由0改为1,表示由cobbler管理dhcp
next_server: 192.168.128.141 #cobbler管理dhcp,指定下一个要访问的服务地址
server: 192.168.128.141 #指定cobbler服务器地址
pxe_just_once: 1 #防止循环安装
# cobbler check #检查cobbler settings的配置
[root@localhost ~]# cobbler check
The following are potential configuration items that you may want to fix:
1 : 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.
2 : enable and start rsyncd.service with systemctl
3 : debmirror package is not installed, it will be required to manage debian deployments and repositories
4 : 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
5 : 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.
#按上述提示,分别去做,然后再检查cobbler settings的配置
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***********************************
用脚本快速修改cobbler/settings文件
# server,Cobbler服务器的IP。(5)自动下载启动文件cobbler get-loaders
#cobbler get-loaders # 会自动从官网下载
# cd /var/lib/cobbler/loaders/ # 下载的内容
(6)xinetd配置
# vim /etc/xinetd.d/rsync
disable = no
# systemctl restart xinetd
(7)使用cobbler sync 进行配置同步
同步最新cobbler配置,它会根据配置自动修改dhcp等服务。
#systemctl restart cobblerd
#cobbler sync
(8)导入centos操作系统镜像
#mount /dev/cdrom /mnt/ # 挂载CentOS7的系统镜像。
在第一次导入系统镜像后,Cobbler会给镜像指定一个默认的kickstart自动安装文件在/var/lib/cobbler/kickstarts下的sample_end.ks。
/var/lib/cobbler/kickstarts/目录中自带许多ks文件模板,将自已的ks文件上传到这个目录
# 编辑profile,修改关联的ks文件
# cobbler profile edit --name=CentOS-7-x86_64 --kickstart=/var/lib/cobbler/kickstarts/myks.cfg
(10)网卡改名eth0
# 修改安装系统的内核参数,在CentOS7系统有一个地方变了,就是网卡名变成eno16777736这种形式,但是为了运维标准化,我们需要将它变成我们常用的eth0,因此使用下面的参数。
但要注意是CentOS7才需要下面的步骤,CentOS6不需要。
# cobbler profile edit --name=CentOS-7-x86_64 --kopts='net.ifnames=0 biosdevname=0'
cobbler system --help 查看命令
usage
=====
cobbler system add
cobbler system copy
cobbler system dumpvars
cobbler system edit
cobbler system find
cobbler system getks
cobbler system list
cobbler system poweroff
cobbler system poweron
cobbler system powerstatus
cobbler system reboot
cobbler system remove
cobbler system rename
cobbler system report
cobbler system add --name=web_centos6.5 --mac=00:0C:29:DE:BB:5B --profile=CentOS-6.5-x86_64 --ip-address=192.168.128.15 --subnet=255.255.255.0 --gateway=192.168.128.2 --interface=eth0 --static=1 --hostname=web1.example.com --name-servers="202.96.128.166 8.8.8.8"
# --name 自定义,但不能重复# --mac 要安装服务器的MAC地址
# --kickstart 指定要使用的kickstart文件,kickstart文件中还可以指定yum源
# 其它是网络参数,可要可不要# cobbler
usage
=====
cobbler |profile|system|repo|image|mgmtclass|package|file> ...
[add|edit|copy|getks*|list|remove|rename|report] [options|--help]
cobbler |buildiso|import|list|replicate|report|reposync|sync|validateks|version|signature|get-loaders|hardlink> [options|--help]
# 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 查看配置信息