pxe  +  kickstart 工作概述

1、网卡上的pxe芯片有512字节,存放了DHCP和TFTP的客户端。

2、启动计算机选择网卡启动。

3、pxe上的DHCP客户端会向DHCP服务器,申请IP

4、DHCP服务器分配给它IP地址的同时通过以下字段,告诉pxe,TFTP的地址和它要下载的文件

如:next-server  xxx.xxx.xxx.xxx

filename "pxelinux.0"

5、pxelinux.0告诉pxe要下载的配置文件是pxelinux.cfg目录下面的default

6、pxe下载并依据配置文件的内容下载启动必须的文件,并通过ks.cfg开始系统安装。

----------------------------------------

cobbler功能

使用一个以前定义的模板来配置DHCP服务(如果启用了管理DHCP)

将一个存储库(yum或rsync)建立镜像或者解压缩一个媒介,以注册一个新操作系统

在DHCP配置文件中为需要安装的机器创建一个条目,并 使用你指定的参数(IP和Mac地址)

在TFTP服务目录下创建适当的pxe文件

重新启动DHCP服务以反映更改

重新启动机器以开始安装(如果电源管理已启用)

1、安装yum源

[[email protected] ~]# rpm -ivh http://mirrors.aliyun.com/epel/epel-release-latest-7.noarch.rpm  

2、安装对应的服务

[[email protected] yum.repos.d]# yum -y install ncurses-devel  gcc  gcc-c++

[[email protected] yum.repos.d]# yum install -y httpd dhcp tftp cobbler cobbler-web pykickstart

[[email protected] httpd]# yum install cobbler dhcp xinetd fence-agents pykickstart ed patch perl perl-Compress-Zlib perl-Digest-SHA perl-LockFile-Simple perl-libwww-perl

3、进入目录

[[email protected] yum.repos.d]# cd /etc/httpd/conf.d/

4、启动系统服务

[[email protected] httpd]# systemctl start httpd

[[email protected] httpd]# systemctl start cobblerd

5、查看端口

[[email protected] httpd]# ss -ntlp

6、关闭防火墙

[[email protected] httpd]# iptables -F

[[email protected] httpd]# iptables -t nat -F

[[email protected] httpd]# systemctl stop firewalld

7、去掉提示

[[email protected] httpd]# echo "unset MAILCHECK">> /etc/profile


批量化无人值守安装

8、修改防火墙

批量化无人值守安装

9、执行命令cobbler check

根据提示修改配置文件

[[email protected] httpd]# vi /etc/cobbler/settings



批量化无人值守安装

批量化无人值守安装

vi  小技巧

当前光标删除到行尾 直接大 D

修改第二个配置文件

[[email protected] httpd]# vim /etc/xinetd.d/tftp


启动rsyncd服务

[[email protected] httpd]# systemctl start rsyncd

10、执行命令下载网络安装文件

[[email protected] httpd]# cobbler get-loaders

11、设置密码

[[email protected] httpd]# openssl passwd -1 -salt 'cobler' 'qq******'

会生成一串随机密码                                            



修改配置文件

[[email protected] httpd]# vi /etc/cobbler/settings

将密码替换成随机生成的密码串,替换引号部分,注意随机密码串,生成的全部都是密码

批量化无人值守安装

11、重启服务

[[email protected] httpd]# systemctl restart cobblerd

[[email protected] httpd]# cobbler check

12、修改DHCP参数

[[email protected] httpd]# vi /etc/cobbler/settings

批量化无人值守安装


13、修改dhcp模板配置文件

[[email protected] httpd]# vim /etc/cobbler/dhcp.template


重启服务

[[email protected] httpd]# systemctl restart cobblerd

[[email protected] httpd]# cobbler sync

系统自动生成DHCP


14、执行挂载镜像

[[email protected] httpd]# mount /dev/cdrom /mnt/

mount: /dev/sr0 is write-protected, mounting read-only

15、自动导入镜像

[[email protected] httpd]# cobbler import --path=/mnt/ --name=Centos-7-x86_64 --arch=x86_64

镜像会导入到这个目录下

[[email protected] ~]# cd /var/www/cobbler/ks_mirror/

[[email protected] ks_mirror]# ls

Centos-7-x86_64  config

[[email protected] ks_mirror]#

导入完成


执行卸载,切换镜像,然后在导入一个centos6的系统


查看 cobbler命令

[[email protected] httpd]# cobbler profile

查看镜像列表

[[email protected] httpd]# cobbler profile list


自定义kickstart文件

[[email protected] kickstarts]# cobbler profile edit --name=Centos-7-x86_64 --kickstart=/var/lib/cobbler/kickstarts/centos-7-x86_64.cfg

[[email protected] kickstarts]# vi centos-7-x86_64.cfg  ##配置文件内容

lang en_US

keyboard us

timezone  Asia/Shanghai

rootpw --iscrypted $default_password_crypted

text

install

url --url=$tree

bootloader --location=mbr

zerombr

clearpart --all initlabel

part /boot --fstype xfs --size 1024 --ondisk sda

part swap --size 1024 --ondisk sda

part / --fstype xfs --size 1 --grow --ondisk sda

auth --useshadow --enablemd5

$SNIPPET('network_config')

reboot

firewall --disabled

selinux --disabled

skipx

%pre

$SNIPPET('log_ke_pre')

$SNIPPET('kickstart_start')

$SNIPPET('pre_install_network_config')

$SNIPPET('pre_anamon')

%end

%packages

@ base

@ core

sysstat

iptraf

ntp

lrzsz

ncurses-devel

openssl-devel

zlib-devel

OpenIPMI-tools

mysql

nmap

screen

%end

%post

systemctl disable postfix.service

%end

加上内核参数

[[email protected] kickstarts]# cobbler profile edit --name=Centos-7-x86_64 --kopts='net.ifnames=0 biosdevname=0'

查看加入的内核参数

[[email protected] kickstarts]# cobbler profile report Centos-7-x86_64


执行命令,重新生成文件

更改文件必须执行  cobbler sync

[[email protected] kickstarts]# cobbler sync

启动服务

[[email protected] ks_mirror]# systemctl start xinetd



安装完成


批量化无人值守安装

批量化无人值守安装


详情请见我的有道笔记http://note.youdao.com/noteshare?id=6ec7d30137f325166c75a7094ade473d&sub=CD35A519A1684BC497E66A3B6EDF0DBF

转载于:https://blog.51cto.com/yibeishui/1936897

相关文章: