0
点赞
收藏
分享

微信扫一扫

pxe与cobbler

boom莎卡拉卡 08-09 06:00 阅读 43

DHCP

把一个主机接入TCP/IP网络,要为配置哪些网络参数:

IP/mask

Gateway

DNS Server

Wins Server, NTP Server

参数配置方式

静态指定

动态分配

bootp: boot protocol

dhcp:引入了"租约"的bootp;也可以实现为特定主机保留某固定地址;

DHCP:动态主机配置协议;

arp: address resolving protocol

IP --> MAC

rarp: reverse arp

MAC -->IP

监听的端口:

Server:67/UDP

Client:68/UDP

工作流程

(1)Client: dhcp discover

(2)Server: dhcp offer (IP/mask, gw, ...)

lease time: 租约期限

(3)Client: dhcp request

(4)Server: dhcp ack

续租:

50%,75%,87.5%

单播给服务:

dhcp request

dhcp ack

dhcp request

dhcp nak

dhep discover:广播

CentOS:

dhcp(ISC, named):

dnsmasq: dhcp & dns

dhcp:

dhcpd: dhcp服务

dhcrelay:中继服务

分配信息库

/var/lib/dhcp/dhcpd.leases~

客户端命令:dhclient

-d:运行在前台;

其它配置选项:

filename:指明引导文件名称;

next-server:指明引导所在的服务主机的IP地址;

filename "pxelinux.0";

next-server 192.168.0.120;

tftp: trivial ftp, udp

pxe

PXE : preboot excution environment, Intel

CentOS :

dhcp (ip/netmask, gw, dns; filename, next-server;)

tftp server (bootloader, kernel, initrd)

yum repository (ftp, http, nfs)

kickstart

tftp server:

监听端口:69/udp

CentOS 6:

chkconfig tftp on

service xinetd restart

CentOS 7:

systemctl start tftp.socket

默认的文件根目录:/var/lib/tftpboot/

dhcp server:

配置文件示例:

option domain-name "xiang.com";
option routers 192.168.0.120;
option domain-name-servers 192.168.0.1;

default-lease-time 43200;
max-lease-time 86400;
log-facility local7;

subnet 192.168.0.0 netmask 255.255.255.0 {
	range 192.168.0.101 192.168.0.130;
	filename "pxelinux 0";
	next-server 192.168.0.120;
}

配置PXE环境:

CentOS 7 :

yum -y install syslinux
cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/
cp /media/cdrom/images/pxeboot/{vmlinuz,initrd.img} /var/lib/tftpboot
cp /usr/share/syslinux/{chain.c32,mboot.c32,menu.c32,memdisk} /var/lib/tftpboot
mkdir /var/lib/tftpboot/pxelinux.cfg/

vim /var/lib/tftpboot/pxelinux.cfg/default
  default menu.c32
  prompt 5
  timeout 30
  MENU TITLE CentOS 7 PXE Menu
  LABEL Linux
  MENU LABEL Install CentOS 7 x86_64
  KERNELvmlinuz
  APPEND initrd=initrd.img inst.repo=http://192.168.0.120/centos/7/x86_64
  LABEL linux autoinst
  MENU LABEL Install Centos 7 x86_64 auto
  KERNEL vmlinuz
  APPEND initrd=initrd.img inst.repo=http:/192.168.0.120/centos/7/x86_64 ks=http://192.168.0.120/kickstarts/centos7.cfg

CentOS 6:

yum -y install syslinux
cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/
cp/media/cdrom/images/pxeboot/{vmlinuz,initrd.img} /var/lib/tftpboot/
cp /media/cdrom/isolinux/{boot.cfg,vesamenu.c32,splash.png; /var/lib/tftpboot
mkdir /var/lib/tftpboot/pxelinux.cfg/

cp /media/cdrom/isolinux/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default

内容如下所示:

display boot.msg
menu background splash.jpg
menu title Welcome to CentOS 6.7 MageEdu!
menu color border 0 #ffffffff #00000000
menu color sel 7 #ffffffff #ff000000
menu color title 0 #ffffffff #00000000
menu color tabmsg 0 #ffffffff #00000000
menu color unsel 0 #ffffffff #00000000
menu color hotsel 0 #ff000000 #ffffffff
menu color hotkey 7 #ffffffff #ff000000
menu color scrollbar 0 #ffffffff #00000000

label autoinst
menu label ^Auto Install CentOS
menu default
kernel vmlinuz
append initrd=initrd.img ks=ftp://192.168.10.16/pub/centos6.cfg
label linux
menu label ^Install or upgrade an existing system
kernel vmlinuz
append initrd=initrd.img
label vesa
menu label Install system with ^basic video driver
kernel vmlinuz
append initrd=initrd.img nomodeset
label rescue
menu label ^Rescue installed system
kernel vmlinuz
append initrd=initrd.img rescue
label local
menu label Boot from ^local drive
localboot 0xffff
label memtest86
menu label ^Memory test
kernel memtest
append -

Cobbler:

pxe的二次封装:python语言开发:

pxe:

dhcp: dhcpd, dnsmasq

tftp: tftp-server

程序包:cobbler(epel)

服务:

Centos 7:

systemctl start cobblerd.service

# cobbler check

主配置文件:/etc/cobbler/settings

server

next_server

default_password_encrpted

概念:

distro, profile,system

distro:表示一个发行版,标记一个发行版的最关键资源是kernel和ramdisk;

# systemctl start cobblerd.service

# cobbler check

# cp /usr/share/syslinux/{pxelinux.0,memu.c32} /var/lib/cobbler/loaders/

# cobbler sync

1.管理distro

cobbler distro {list | add | remove | edit | rename}

使cobbler变得可用的第一步为定义distro,其可以通过为其指定外部的安装引导内核及ramdisk文件的方式实现。而如果已经有完整的系统安装树(如CentOS7的安装镜像)则推荐使用import直接导入的方式进行。

例如,对于已经挂载至/media/cdrom目录的CentOS 7 x86_64的安装镜像,则可以使用类似如下命令进行导入

#cobbler import --name=CentOS-7-x86_64 --path=/media/cdrom

可使用“cobbler distro list ”列出所有的distro.

如果有kickstart文件,也可以使用“--kickstart=/path/to/kickstart_file”进行导入,因此import会自动为导入的distro生成一个profile.

2.管理profile

cobbler  profile {list | add | remove | edit | rename}

cobbler使用profile来为特定的需求类别提供所器要安装配置,即在distro的基础上通过提供kickstart文件来生成一个特定的系统安装配置。distro的profile可以出现在PXE的引导菜单中作为安装的选择之一

因此,如果需要为前面创建的CentOS-7-x86_64这个distro提供一个可引导安装条目,其用到的kickstart文件为/tmp/CentOS-7-x86_64.cfg(只提供了最基本的程序包),则可通过如下命令实现。

#cobbler profile add --name=CentOS-7-x86_64-basic --distro=CentOS-7-x86_64 --kickstart=/tmp/CentOS-7-x86_64.cfg

可使用“cobbler profile list”查看已经创建的profile。

同步:

cobbler sync

cobbler_web

1.配置cobbler_web的认证功能

cobbler_web支持多种认证方式,如authn_configfile、authn_ldap或authn_pam等,默认为authn_denyall,即拒绝所有用户登录。下面说明两种能认证用户登录cobbler_web的方式。

(1)使用authn_pam模块认证cobbler_web用户

首先修改modules中[authentication]段的module参数的值为authn_pam.

接着添加系统用户,用户名和密码按需设定即可,例如下面的命令所示

# useradd cblradmin

# echo 'cblrpass' | passwd --stdin cblradmin

而后将cblnadmin用户添加至cobbler_web的admin组中。修改/etc/cobbler/users.conf文件,将cblradmin用户名添加为admin参数的值即可,如下所示。

[admins]

admin = "cblradmin"

最后重启cobblerd服务,通过http://YOUR_COBBLERD_IP/cobbler_web访问即可

(2)使用authn_configfile模块认证cobbler_web用户

首先修改modules中[authentication]段的module参数的值为authn_configfile.

接着创建其认证文件/etc/cobbler/users..digest,并添加所需的用户即可。需要注意的是,添加第一个用户时,需要为htdigest命令使用“-c”选项,后续添加其他用户时不能再使用:另外,cobbler_web的realm只能为Cobbler。如下所示。

# htdigest -c /etc/cobbler/users.digest Cobbler cblradmin

最后重启cobblerd服务,通过http://YOUR_COBBLERD_IP/cobbler_web访问即可。




















举报

相关推荐

0 条评论