1. 自动安装操作系统

http://blog.oldboyedu.com/autoinstall-kickstart/
 
自动安装操作系统的解决方案:kickstart、cobbler(披着web外皮的kickstart)
                       inotify sersync

2.kickstart自动安装操作系统的原理

 
anaconda自动安装系统程序从一个文件中读取安装过程所需的所有操作,然后可以自动的安装操作系统。这个文件就叫自动应答文件(ks文件)
 

3.kickstart的架构

cobbler(kickstart)服务组成:dhcp,tftp,http
 

4.安装kickstart

4.0 环境

[root@m01 ~]# cat /etc/redhat-release
CentOS release 6.9 (Final)
[root@m01 ~]# uname -r
2.6.-.el6.x86_64
[root@m01 ~]# getenforce
Disabled
[root@m01 ~]# /etc/init.d/iptables status
iptables: Firewall is not running.
[root@m01 ~]# hostname -I
10.0.0.21 172.16.1.21

4.1 安装DHCP

yum -y install dhcp
cat >>/etc/dhcp/dhcpd.conf<<EOF
subnet 172.16.1.0 netmask 255.255.255.0 {
range 172.16.1.100 172.16.1.200;
option subnet-mask 255.255.255.0;
default-lease-time ;
max-lease-time ;
next-server 172.16.1.21;
filename "/pxelinux.0";
}
EOF 100个IP同时安装50台 --> 初始化了两次网络 【第一次dhcp,第五次应答文件】 range 172.16.1.100 172.16.1.200; # 可分配的起始IP-结束IP
option subnet-mask 255.255.255.0; # 设定netmask
default-lease-time ; # 设置默认的IP租用期限
max-lease-time ; # 设置最大的IP租用期限
next-server 172.16.1.21; # 告知客户端TFTP服务器的ip
filename "/pxelinux.0"; # 告知客户端从TFTP根目录下载pxelinux.0文件 一千台机器装系统 一次装23台【24口交换机性价比最高】 一台安装服务器
查看日志
  • tailf /var/log/messages

启动
  • /etc/init.d/dhcpd start

4.2 安装TFTP

yum -y install tftp-server

# 配置
sed -i.ori '14s#yes#no#' /etc/xinetd.d/tftp # 启动
/etc/init.d/xinetd start # 寻找pxelinux.0启动文件
yum -y install syslinux
cp /usr/share/syslinux/pxelinux. /var/lib/tftpboot/ # 找配置文件
mkdir -p /var/www/html/CentOS6.
mount /dev/cdrom /var/www/html/CentOS6.
cp -a /var/www/html/CentOS6./isolinux/* /var/lib/tftpboot/ mkdir -p /var/lib/tftpboot/pxelinux.cfg # 配置文件default
\cp /var/www/html/CentOS6.9/isolinux/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default

4.3 安装HTTP

yum -y install httpd
/etc/init.d/httpd start

----
curl http://172.16.1.21/CentOS6.9/ http://172.16.1.21/CentOS6.9/

4.4 配置自动化安装的default

cat>/var/lib/tftpboot/pxelinux.cfg/default<<EOF
default ks
prompt label ks
kernel vmlinuz
append initrd=initrd.img ks=http://172.16.1.21/ks_config/CentOS-6.9-ks.cfg ksdevice=eth1
EOF

4.5 自动应答文件

/var/lib/tftpboot/pxelinux.cfg/default
/var/www/html/ks_config/CentOS-6.9-ks.cfg
/var/www/html/ks_config/optimization.sh
 
同一个局域网最好只有一个DHCP服务器
ks文件 自动应答文件 给系统安装程序提供它所需要的所有必要的安装信息
  生成ks文件的方法:

./root/anaconda-ks.cfg 这是安装程序自动生成的,
作用1:告诉我们系统安装的信息;
作用2:可以直接用(模仿)这个文件再次装系统
.Centos提供了一个图形化的kickstart配置工具。
.根据ks文件语法编辑一个ks文件
ks文件分为3段
命令段
包组段
脚本段
 ks文件

# Kickstart Configurator for CentOS 6.7 by lewen
install
url --url="http://172.16.1.21/CentOS6.9/"
text
lang en_US.UTF-
keyboard us
zerombr
bootloader --location=mbr --driveorder=sda --append="crashkernel=auto rhgb quiet"
network --bootproto=dhcp --device=eth1 --onboot=yes --noipv6 --hostname=lewen-kick
network --bootproto=dhcp --device=eth0 --onboot=yes --noipv6
timezone --utc Asia/Shanghai
authconfig --enableshadow --passalgo=sha512
rootpw --iscrypted $$X20eRtuZhkHznTb4$dK0BJByOSAWSDD8jccLVFz0CscijS9ldMWwpoCw/ZEjYw2BTQYGWlgKsn945fFTjRC658UXjuocwJbAjVI5D6/
clearpart --all --initlabel
part /boot --fstype=ext4 --asprimary --size=
part swap --size=
part / --fstype=ext4 --grow --asprimary --size=
firstboot --disable
selinux --disabled
firewall --disabled
logging --level=info
reboot

%packages
@base
@compat-libraries
@debugging
@development
tree
nmap
sysstat
lrzsz
dos2unix
telnet

%post
wget -O /tmp/optimization.sh http://172.16.1.21/ks_config/optimization.sh &>/dev/null
/bin/sh /tmp/optimization.sh
%end
vim /var/www/html/ks_config/optimization.sh
#!/bin/bash

. /etc/init.d/functions
Ip=172.16.1.21
Port=
ConfigDir=ks_config
# Judge Http server is ok?
PortNum=`nmap $Ip -p $Port >/dev/null|grep open|wc -l`
[ $PortNum -lt ] && {
echo "Http server is bad!"
exit
}
# Defined result function
function Msg(){
if [ $? -eq ];then
action "$1" /bin/true
else
action "$1" /bin/false
fi
}
# Defined IP function
function ConfigIP(){
Suffix=`ifconfig eth0|awk -F "[ .]+" 'NR==2 {print $6}'`
cat >/etc/sysconfig/network-scripts/ifcfg-eth0 <<-END
DEVICE=eth0
TYPE=Ethernet
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=none
IPADDR=10.0..$Suffix
PREFIX=
GATEWAY=10.0.0.254
DNS1=8.8.8.8
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME="System eth0"
END
Msg "config eth0"
}
# Defined Yum source Functions
function yum(){
YumDir=/etc/yum.repos.d
[ -f "$YumDir/CentOS-Base.repo" ] && cp $YumDir/CentOS-Base.repo{,.ori}
wget -O $YumDir/CentOS-Base.repo http://$Ip:$Port/$ConfigDir/CentOS-Base.repo &>/dev/null &&\
wget -O $YumDir/epel.repo http://$Ip:$Port/$ConfigDir/epel.repo &>/dev/null &&\
Msg "YUM source"
}
# Defined Hide the system version number Functions
function HideVersion(){
[ -f "/etc/issue" ] && >/etc/issue
Msg "Hide issue"
[ -f "/etc/issue.net" ] && > /etc/issue.net
Msg "Hide issue.net"
}
# Defined OPEN FILES Functions
function openfiles(){
[ -f "/etc/security/limits.conf" ] && {
echo '* - nofile 65535' >> /etc/security/limits.conf
Msg "open files"
}
}
# Defined Kernel parameters Functions
function kernel(){
KernelDir=/etc
[ -f "$KernelDir/sysctl.conf" ] && /bin/mv $KernelDir/sysctl.conf{,.ori}
wget -O $KernelDir/sysctl.conf http://$Ip:$Port/$ConfigDir/sysctl.conf &>/dev/null
Msg "Kernel config"
}
# Defined System Startup Services Functions
function boot(){
for oldboy in `chkconfig --list|grep "3:on"|awk '{print $1}'|grep -vE "crond|network|rsyslog|sshd|sysstat"`
do
chkconfig $oldboy off
done
Msg "BOOT config"
}
# Defined Time Synchronization Functions
function Time(){
echo "#time sync by zhangyao at $(date +%F)" >>/var/spool/cron/root
echo '*/5 * * * * /usr/sbin/ntpdate time.nist.gov &>/dev/null' >>/var/spool/cron/root
Msg "Time Synchronization"
}
# Defined main Functions
function main(){
ConfigIP
yum
HideVersion
openfiles
kernel
boot
Time
}
main
# rz上传CentOS-Base.repo、epel.repo、sysctl.conf

optimization.sh 非必须

centos 7 安装完的ks文件模板

[root@cs7-model tmp]# cat anaconda-ks.cfg
#version=DEVEL
# System authorization information
auth --enableshadow --passalgo=sha512
# Use CDROM installation media
cdrom
# Use graphical install
graphical
# Run the Setup Agent on first boot
firstboot --enable
ignoredisk --only-use=sda
# Keyboard layouts
keyboard --vckeymap=us --xlayouts='us'
# System language
lang en_US.UTF-

# Network information
network --bootproto=static --device=eth0 --gateway=10.0.0.254 --ip=10.0.0.210 --nameserver=223.5.5.5 --netmask=255.255.255.0 --ipv6=auto --activate
network --bootproto=static --device=eth1 --gateway=10.0.0.254 --ip=172.16.1.210 --netmask=255.255.255.0 --onboot=off --ipv6=auto --activate
network --hostname=cs7-model

# Root password
rootpw --iscrypted $$fA8sNPkIWX1UZJfA$XuUxCvwPDHeTGKGBrE3Si5udHCEz/zaHctEd9ggRV4TtkJM.Vja4K.JyE5nylfhYZ0OC2BP8e9BxXoJKf5AAY1
# System services
services --disabled="chronyd"
# System timezone
timezone Asia/Shanghai --isUtc --nontp
# System bootloader configuration
bootloader --location=mbr --boot-drive=sda
autopart --type=lvm
# Partition clearing information
clearpart --none --initlabel

%packages
@^minimal
@compat-libraries
@core
@debugging
@development

%end

%addon com_redhat_kdump --disable --reserve-mb='auto'

%end

%anaconda
pwpolicy root --minlen= --minquality= --notstrict --nochanges --notempty
pwpolicy user --minlen= --minquality= --notstrict --nochanges --emptyok
pwpolicy luks --minlen= --minquality= --notstrict --nochanges --notempty
%end

centos 7 ks 安装完模板

 
 
 
 
 

s32 kickstart 批量自动安装系统的更多相关文章

  1. Linux部署之批量自动安装系统之Kickstart篇

    1.         安装   2.         在桌面环境下啊配置   3.         Kickstart之基本配置   4.         Kickstart之安装方法   5.    ...

  2. kvm使用kickstart文件自动安装系统

    假定kvm已经准备好 1.创建磁盘 qemu-img create -f qcow2 /kvm/os/vm-01.qcow2 16G 2.上传或下载安装镜像 mkdir -p /kvm/iso cd ...

  3. Linux部署之批量自动安装系统之测试篇

    1.         客户端从网络启动如下   2.         复制vesamenu.c32文件可解决上面的问题   3.         客户端再次启动   4.         选择第一个进 ...

  4. Linux部署之批量自动安装系统之TFTP篇

    1.         安装:yum install tftp-server –y   2.         配置tftp文件开启tftp功能   3.         开启依赖服务xinetd   4 ...

  5. Linux部署之批量自动安装系统之DHCP篇

    1.         安装:yum install dhcp   2.         Ip配置信息   3.         Dhcp配置文件如下   4.         配置完后检查语法是否错误 ...

  6. Linux部署之批量自动安装系统之NFS篇

    1.         编辑配置文件让远端设备可访问vim /etc/exports   2.         启动服务

  7. kickstart一键自动安装Linux系统

    kickstart,无人值守,自动安装系统.本文介绍kickstart的用法. #安装系统的信息——可以参考 [root@larrywen pdf]# vim ~/anaconda-ks.cfg 第一 ...

  8. CentOS 6.9 CentOS 7.4 自动安装系统 kickstart

    通过ks文件 实现 CentOS 6.9 & 7.4 自动安装系统 环境: VMware 14.0 Pro版 光盘镜像: CentOS-6.9-x86_64-minimal.iso ks文件生 ...

  9. Centos 7 自动安装系统-pxe

    一.简介 PXE(Pre-boot Execution Environment,预启动执行环境)是由Intel公司开发的最新技术,工作于Client/Server的网络模式,支持工作站通过网络从远端服 ...

随机推荐

  1. 第二章 FFmpeg常用命令

    2.1 FFmpeg常见的命令大概分为6个部分 ffmpeg信息查询部分 公共操作参数部分 文件主要操作参数部分 视频操作参数部分 字幕操作参数部分 2.1.1 FFmpeg的封装转换 FFmpeg ...

  2. ARM920T的Cache

    转载自:http://www.eefocus.com/mcu-dsp/242034 ARM920T有16K的数据Cache和16K的指令Cache,这两个Cache是基本相同的,数据Cache多了一些 ...

  3. scp和sftp常用操作

      文件异地直接复制: scp SCP的全称是secure copy (remote file copy program),此命令是openssh-clients附带的,它的作用就是在机器之间实现拷贝 ...

  4. java中将表单转换为PDF

    经过网上搜索大概有三种方式:PDF模板数据填充,html代码转换pdf,借用wkhtmltopdf工具 一 .PDF模板数据填充 1.新建word,在word中做出和表单一样的布局的空表单,然后另存为 ...

  5. java反射的性能问题

    java反射效率到底如何,花了点时间,做了一个简单的测试.供大家参考. 测试背景: 1. 测试简单Bean(int,Integer,String)的set方法2. loop 1亿次3. 测试代码尽可能 ...

  6. Java date 日期计算

    import org.junit.Test; import java.util.Calendar; import java.util.Date; /** * @author cosmo * @Titl ...

  7. 杰克.多西 twitter创始人 必做清单和不必做清单

    必做清单 活在当下 接受脆弱(Be vulnerable) 只喝柠檬水和红酒 每天 6 组下蹲和俯卧撑 每天跑步 3 英里 每天思考本清单 站直了 打拳击沙袋 10 分钟 跟所有人打招呼 每天 7 小 ...

  8. Spring MVC 之 ContentNegotiatingViewResolver

    我们已经知道 对于 RequestMappingInfoHandlerMapping, 它在对带有后缀的http 请求进行匹配的时候,如果找不到精确的pattern, 那么就会 pattern+.* ...

  9. OpenCV代码:画出轮廓的外接矩形,和中心点

    #include <opencv2/highgui/highgui.hpp> #include <opencv2/imgproc/imgproc.hpp> #include & ...

  10. leetcode102

    本题是广度优先遍历(BFS)实现树的层次遍历,使用队列实现. class Solution { public: vector<vector<int>> levelOrder(T ...