从安装配置到使用cobbler一键部署系统【基础功能】

1、首先安装软件及环境

yum install httpd dhcp tftp cobbler cobbler-web pykickstart xinetd

2、安装软件完成后可以启动https和cobbler进行检查有哪些环境需要配置

[root@default cobbler]# systemctl start httpd cobbler xinetd
[root@default 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.
#1:cobbler服务需要在/etc/cobbler/settings配置文件中设置服务端ip(384行 server: x.x.x.x);
#2:PXE服务需要在/etc/cobbler/settings配置文件中设置服务端ip(272行 next_server: x.x.x.x);
#3:修改/etc/xinetd.d/tftp配置文件中disable值为no;
#4:运行cobbler get-loaders命令下载相应文件;
#5:开启rsyncd服务;
#6:需要下载debmirror软件包;
#7:修改默认密码,采用加密方式请使用openssl passwd -1 -salt '你的密码' '你的密码'生成加密密码,然后替换到/etc/cobbler/setting中101行default_password_crypted: "$1$cobler$XJnisBweZJlhL651HxAM00"中;
#8:可以使用cman或fence-agents电源管理工具
#配置完重起cobblerd可以运行cobbler sync重启服务

3、配置dhcp(cobbler管理)

3.1在cobbler中开启dhcp功能
[root@default cobbler]# vim /etc/cobbler/setting
#242行 manage_dhcp: 0中的0修改为1
manage_dhcp: 1
3.2修改dhcp配置
[root@default cobbler]# vim /etc/cobbler/dhcp.template
subnet 10.0.0.0 netmask 255.255.255.0 {
     option routers             10.0.0.2;
     option domain-name-servers 10.0.0.2;
     option subnet-mask         255.255.255.0;
     range dynamic-bootp        10.0.0.2 10.0.0.254;
     default-lease-time         21600;
     max-lease-time             43200;
     next-server                $next_server;
主要修改上述dhcp配置即可,重启cobbler服务
然后执行cobbler sync生成配置文件,启动dhcp服务等

4、导入系统镜像

4.1首先挂在系统进行到本地系统目录(例如mount /dev/cdrom /mnt)
4.2导入需要安装的系统到cobbler中(存放目录为/var/www/cobbler/ks_mirror,其中--path为要导入的镜像目录位置,--name为系统名,--arch为32或64为)
cobbler import --path=/mnt/ --name=CentOS-7-x86_64 --arch=x86_64
4.2查看cobbler配置信息
[root@default /]# cobbler profile report
Name                           : CentOS-7-x86_64
TFTP Boot Files                : {}
Comment                        : 
DHCP Tag                       : default
Distribution                   : CentOS-7-x86_64
Enable gPXE?                   : 0
Enable PXE Menu?               : 1
Fetchable Files                : {}
Kernel Options                 : {}
Kernel Options (Post Install)  : {}
Kickstart                      : /var/lib/cobbler/kickstarts/CentOS-7-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
4.4我们需要自定义kickstart系统安装信息文件需要如下操作(注意--name要和上述NAME保持一致,kickstart文件位置自定义即可)
[root@default /]# cobbler profile edit --name=CentOS-7-x86_64 --kickstart=/var/lib/cobbler/kickstarts/CentOS-7-x86_64.cfg

CentOS-7-x86_64.cfg配置文件如下:

# Kickstart Configurator for cobbler by Helis_Zhangshuai
# platform=x86, AMD64, or Intel EM64T
# System language
lang en_US
# System keyboard
keyboard us
# System timezone
timezone Asia/Shanghai
#Root password
rootpw --iscrypted $default_password_crypted
# Use text mode install
text
# Install OS instead of upgrade
install
# Use network installation media
url --url=$tree
# System bootloader configuration
bootloader --location=mbr
# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart --all --initlabel
# Disk partitioning information
part /boot --fstype xfs --size 200 --ondisk sda
part swap --size 1024 --ondisk sda
part / --fstype xfs --size 1 --grow --ondisk sda
# System authorization information
auth  --useshadow  --enablemd5
# Network information
$SNIPPET('network_config')
# network --bootproto=dhcp --device=eml --onboot=on
# Reboot after installation
reboot
# Firewall configuration
firewall --disabled
# SELinux configuration
selinux --disabled
# Do not configure the X Window System
skipx
#Package install information
%pre
$SNIPPET('log_ks_pre')
$SNIPPET('kickstart_start')
$SNIPPET('pre_install_network_config')
# Enable installation monitoring
$SNIPPET('pre_anamon')
%end

%packages
@ base
@ core
lrzsz
wget
ntp
rsync
unzip
iotop
sysstat
net-tools
tree
vim
bash-completion
nc
nmap
telnet
bc
lsof
ncurses-devel
openssl-devel
zlib-devel
OpenIPMI-tools
screen
iptraf
python-devel
%end

%post
systemctl disable postfix.service
%end
4.5需要安装系统时修改内核参数(如centos7安装时修改网卡名字为eth0)
cobbler profile edit --name=CentOS-7-x86_64 --kopts='net.ifnames=0 biosdevname=0'
即可修改默认网卡名为eth0

5、测试cobbler是否搭建成功

新建一台虚拟机,注意!注意!注意!内存一定要大于等于2G以上,要不就等着dracut-initqueue[1033或1068或xxxx]报错吧!!!顺利的话你会看到如下界面:
默认安装界面

选择CentOS-7-x86_64即可安装,可能安装会有点慢,等等就好!

6、客户端需要重新安装

6.1可以先查看cobbler服务中可以重装的系统(需要koan命令)
[root@default cobbler]#  yum install -y koan
[root@default cobbler]#  koan --server=10.0.0.200 --list=profiles
- looking for Cobbler at http://10.0.0.200:80/cobbler_api
CentOS-7-x86_64
[root@localhost ~]# koan --replace-self --server=10.0.0.200 --profile=CentOS-7-x86_64
- looking for Cobbler at http://10.0.0.200:80/cobbler_api
- reading URL: http://10.0.0.200/cblr/svc/op/ks/profile/CentOS-7-x86_64
install_tree: http://10.0.0.200/cblr/links/CentOS-7-x86_64
downloading initrd initrd.img to /boot/initrd.img_koan
url=http://10.0.0.200/cobbler/images/CentOS-7-x86_64/initrd.img
- reading URL: http://10.0.0.200/cobbler/images/CentOS-7-x86_64/initrd.img
downloading kernel vmlinuz to /boot/vmlinuz_koan
url=http://10.0.0.200/cobbler/images/CentOS-7-x86_64/vmlinuz
- reading URL: http://10.0.0.200/cobbler/images/CentOS-7-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://10.0.0.200/cblr/svc/op/ks/profile/CentOS-7-x86_64 biosdevname=0 kssendmac "', '--copy-default', '--make-default', '--title=kick1561881173']
- ['/sbin/grubby', '--update-kernel', '/boot/vmlinuz_koan', '--remove-args=root']
- reboot to apply changes
#reboot重启就可以进行一键重装系统了!
重启后默认就是

7、cobbler服务web管理界面

7.1安装环境依赖

Django版本需要较高,这里安装Django==1.8.9,使用python的pip进行安装;
首先安装配置阿里源,安装python-pip和python-devel软件,并升级pip,最后安装Django-1.8.9

[root@default cobbler]#  mkdir -p /root/.pip
[root@default cobbler]#  cat >~/.pip/pip.conf <<EOF
[global]
index-url = http://mirrors.aliyun.com/pypi/simple/
[install]
trusted-host=mirrors.aliyun.com
EOF
[root@default cobbler]#  yum -y install python-pip python-devel
[root@default cobbler]#  pip install --upgrade pip
[root@default cobbler]#  pip install Django==1.8.9
然后就可以打开cobbler管理界面https://10.0.0.200/cobbler_web/
默认登录账户密码均为cobbler,全英文我相信你的英语水平!
cobbler管理界面

8、修改安装界面提示

[root@default cobbler]#  vim /etc/cobbler/pxe/pxedefault.template
DEFAULT menu
PROMPT 0
MENU TITLE Cobbler By Helis_Zhangshuai| https://garba.cn
TIMEOUT 200
TOTALTIMEOUT 6000
ONTIMEOUT $pxe_timeout_profile

LABEL local
        MENU LABEL (local)
        MENU DEFAULT
        LOCALBOOT -1

$pxe_menu_items

MENU end
自定义安装界面

BTC:3LD8DBk5nZSwmGoF1mvM12Pp5YqNFEvfLA
ETH:0xAD765200e7Feb98a2AF262387A41F078e9F91eAc

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