cobbler 系统安装

1.简介

cobbler是一款自动化安装Linux操作系统的软件,自带WEB界面,可以很方便配置和使用。
cobbler在原来PXE的基础上进行了封装,增加了大量的新功能,同时提供了api接口供开发者自定义自己的内容。
集成的服务有:
PXE 服务
DHCP
Rsync
Http
DNS
Kickstart
IPMI 电源管理

2.实践安装cobbler

1,实验环境:
Linux系统版本为Centos7
两台浪潮英信服务器 NF 5180M4
两台机器在相同网段
2,环境准备
关闭selinux

[root@block1 ~]# setenforce 
usage:  setenforce [ Enforcing | Permissive | 1 | 0 ]
[root@block1 ~]# setenforce 0
setenforce: SELinux is disabled
[root@block1 ~]# vim /etc/sysconfig/selinux 
  1 
  2 # This file controls the state of SELinux on the system.
  3 # SELINUX= can take one of these three values:
  4 #     enforcing - SELinux security policy is enforced.
  5 #     permissive - SELinux prints warnings instead of enforcing.
  6 #     disabled - No SELinux policy is loaded.
  7 SELINUX=disabled

关闭防火墙或者打开服务需要的端口号

[root@block1 ~]# systemctl stop firewalld    

3,安装必要软件
1,安装epel源

yum install epel-release -y

2,安装cobbler和相关服务

yum -y install httpd dhcp tftp python-ctypes cobbler  xinetd cobbler-web

3,启动http和cobbler服务

systemctl start httpd.service
systemctl start cobblerd.service

4,检测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.

一个个解决问题

#指定cobbler server
sed -i 's/server: 127.0.0.1/server: 192.168.150.17/' /etc/cobbler/settings
#指定DHCP中的next_server
sed -i 's/next_server: 127.0.0.1/next_server:192.168.150.17 /' /etc/cobbler/settings
#cobbler自己管理DHCP服务
sed -i 's/manage_dhcp: 0/manage_dhcp: 1/' /etc/cobbler/settings
#和ipmi pxe重启有关
sed -i 's/pxe_just_once: 0/pxe_just_once: 1/' /etc/cobbler/settings
#默认的机器root密码
sed -ri "/default_password_crypted/s#(.*: ).*#\1\"`openssl passwd -1 -salt 'oldboy' '123456'`\"#" /etc/cobbler/settings
#启用tftpd服务
sed -i 's#yes#no#' /etc/xinetd.d/tftp

完毕后重启cobbler服务,执行命令

[root@block1 ~]# systemctl restart cobblerd
[root@block1 ~]# cobbler sync
task started: 2018-05-30_232021_sync
task started (id=Sync, time=Wed 
[root@block1 ~]# 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

这个问题暂时不管,只和deb系统有关,忽略即可

5,下载loader文件

[root@block1 ~]# cobbler get-loaders
[root@block1 ~]# ls /var/lib/cobbler/loaders/
COPYING.elilo     COPYING.yaboot  grub-x86_64.efi  menu.c32    README
COPYING.syslinux  elilo-ia64.efi  grub-x86.efi     pxelinux.0  yaboot

6,修改dhcpd文件
只贴修改的部分

vim  /etc/cobbler/dhcp.template 
     subnet 192.168.150.0 netmask 255.255.255.0 {
     option routers             192.168.150.254;
     option domain-name-servers 192.168.150.254;
     option subnet-mask         255.255.255.0;
     range dynamic-bootp        192.168.150.170 192.168.150.180;

7,同步一下配置

cobbler check

重启所有服务

systemctl restart httpd.service
systemctl restart cobblerd.service
systemctl restart dhcpd.service
systemctl restart rsyncd.service
systemctl restart tftp.socket

8,打开游览器输入https://192.168.150.17/cobbler_web
默认账号密码都是cobbler

image.png

点击导入镜像 import DVD
image.png

创建镜像文件
image.png

先选好 Arch,Breed,prefix
Path是机器上iso地址

[root@block1 ~]# ls /mnt/iso/
CentOS_BuildTag  GPL       LiveOS    RPM-GPG-KEY-CentOS-7
EFI              images    Packages  RPM-GPG-KEY-CentOS-Testing-7
EULA             isolinux  repodata  TRANS.TBL
image.png

导入成功


image.png

可以找到导入后文件位置

[root@block1 ~]# ls /var/www/cobbler/ks_mirror/Centos7.3-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

使用远程管理端口初步测试cobbler

ipmitool -I lanplus -H 192.168.150.151 -U admin -P admin chassis power off
ipmitool -I lanplus -H 192.168.150.151 -U admin -P admin chassis bootdev pxe
ipmitool -I lanplus -H 192.168.150.151 -U admin -P admin chassis power on

出现下面图片表示cobbler安装成功


image.png

3.定制化安装系统(以Centos7举例)

1,修改distors
点击版本distors,添加kernel参数net.ifnames=0 biosdevname=0
可以让网卡编程eth0之类的方便管理。
修改完毕后点击保存即可


image.png

2,点击ks文件模板,创建自己的ks文件


image.png

Centos7的ks文件例子:

#version=RHEL7
# System authorization information
auth --enableshadow --passalgo=sha512
# Use CDROM installation media
#cdrom
# Use network installation
url --url="$tree"
# Run the Setup Agent on first boot
firstboot --enable
ignoredisk --only-use=sda
# Keyboard layouts
keyboard --vckeymap=us --xlayouts='cn','us'
# System language
lang zh_CN.UTF-8 --addsupport=en_US.UTF-8
# System services
services --enabled="chronyd"
# Network information
network  --bootproto=static --device=eno1 --gateway=192.168.150.254 --ip=192.168.150.161 --netmask=255.255.255.0 --ipv6=auto --activate
# Root password
rootpw --iscrypted $6$EFToOZFJRxoHKJfk$HI1L8nDFpoXCtnJOgKjjHl9zhxDAlIFmQnaDmKonqU3/iRCtzdSkvMwPqwdLBzJz5n0OvEJZ.hFoZoc2WiL6g0
# System timezone
timezone Asia/Shanghai --isUtc
selinux --disabled
firewall --disabled
# System bootloader configuration
bootloader --location=mbr --boot-drive=sda
# Partition clearing information
clearpart --all --initlabel 
# Disk partitioning information
#part swap --fstype="swap" --ondisk=sda --size=16384
#part biosboot --fstype="biosboot" --ondisk=sda --size=2
#part /boot --fstype="xfs" --ondisk=sda --size=500
#part pv.928 --fstype="lvmpv" --ondisk=sda --size=2840062
#volgroup cl_sf-test-06 --pesize=4096 pv.928
#logvol /  --fstype="xfs" --size=2840060 --name=root --vgname=cl_sf-test-06
autopart --type=lvm
reboot
%packages
chrony
%end
%pre
%end

3,给系统定制额外参数
点击系统,定制额外参数
选定profile和ks文件

image.png

网关,nameserver
image.png

ip配置,在设置完毕mac之后,可以跳过选择local还是Centos7-4-X86_64的页面
image.png

同步一下
image.png

这些ns和ip指定是在dhcpd配置文件中写上生效的。
可以看到如下配置

44 # group for Cobbler DHCP tag: default
 45 group {
 46     host generic1 {
 47         hardware ethernet 6c:92:bf:55:be:7a;
 48         fixed-address 192.168.150.160;
 49         option host-name "test";
 50         option subnet-mask 255.255.255.0;
 51         option routers 192.168.150.254;
 52         filename "/pxelinux.0";
 53         next-server 192.168.150.17;
 54     }
 55 }

再次pxe引导服务器即可实现一键安装,全程无需干扰。

问题1:
如何获取服务器的MAC地址?
浪潮服务器是使用ipmitool命令,其他服务器请自行百度
网卡1:

[root@block1 ~]# ipmitool -I lanplus -H 192.168.150.151 -U admin -P admin raw 0x3a 0x02 0x04 0x00 0x00
 04 00 00 00 00 6c 92 bf 55 be 7a 00 00 00 00

网卡2:

[root@block1 ~]# ipmitool -I lanplus -H 192.168.150.151 -U admin -P admin raw 0x3a 0x02 0x04 0x01 0x01 
 04 01 01 01 00 6c 92 bf 55 be 7b 00 00 00 00

中间结果部分

6c 92 bf 55 be 7a
6c 92 bf 55 be 7b

问题2:
Centos7出现 “error storage configuration”错误,
安装硬盘时候分区错误,由于各个硬盘容量差异较大,可以在ks文件中将设置为自动分区。

autopart --type=lvm

(码字到深夜两点,我也是醉了(•౪• ))

参考文档:
http://cobbler.github.io

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 159,716评论 4 364
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 67,558评论 1 294
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 109,431评论 0 244
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 44,127评论 0 209
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 52,511评论 3 287
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 40,692评论 1 222
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 31,915评论 2 313
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 30,664评论 0 202
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 34,412评论 1 246
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 30,616评论 2 245
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 32,105评论 1 260
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 28,424评论 2 254
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 33,098评论 3 238
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 26,096评论 0 8
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 26,869评论 0 197
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 35,748评论 2 276
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 35,641评论 2 271

推荐阅读更多精彩内容