RHEL7.3通过kickstart以及HTTP实现网络批量安装Rhel6.5操作系统

  • 实现基于HTTP协议网络安装操作系统的过程
  • 这个不是PXE,是通过网络进行安装:
    这里写图片描述
  • 1.配置DHCP服务器用于提供动态主机配置
[root@my Desktop]#  yum install dhcp
  • 提供的配置信息如下
 subnet 172.25.23.0  netmask 255.255.255.0 {
     range   172.25.23.1 172.25.23.200;
     option routers  172.25.23.250;
     default-lease-time  3600;                                               
     max-lease-time  7200;
     next-server 172.25.23.250;
     allow unknown-clients;
 }
  • 并且需要启动DHCP服务器
[root@my Desktop]# systemctl start dhcpd.service
  • 接下来配置ks.cfg,首先需要下载
[root@my Desktop]#  yum install system-config-kickstart -y 
  • 执行命令,打开一个图形化的界面
[root@my Desktop]# system-config-kickstart 
  • Basic Configuration配置如下
    这里写图片描述
  • instalication Method配置如下
    这里写图片描述
  • Bootloader配置如下
    这里写图片描述
  • partition information配置如下
    这里写图片描述
  • 然后还需要选择分区信息 ,首先是swap分区,这里的分区类型必须是swap,否则会出现swap分区无法时别,而导致分区失败
    这里写图片描述
  • 然后创建根分区,这里的大小选择自动增长
    这里写图片描述
  • 其余的分区信息可以根据实际的需要进行添加,这里还支持创建RAID阵列,但是不支持创建LVM,如果需要创建LVM卷组,需要修改配置文件ks.cfg;
    这里写图片描述
  • 关于Network Configuration的选项,选择eth0以及DHCP
    这里写图片描述
  • 关于Authentication,如果存在认证服务器,可以根据实际要求填写
    这里写图片描述
  • 关于Firewall Configuration也可以根据实际的要求进行配置
    这里写图片描述
  • 关于package Selection会根据软件包的依赖关系自行解决
    这里写图片描述
  • 关于Post-Installation Script可以根据需要提供脚本来执行
    这里写图片描述
  • 查看生成的ks.cfg并且修改如下
#platform=x86, AMD64, or Intel EM64T
#version=DEVEL
# Install OS instead of upgrade
install
# Keyboard layouts
keyboard 'us'
# Root password
rootpw --iscrypted $1$c8DHhVJd$kLRxhLJNbUKPiOIQGSzje.
# System timezone
timezone Asia/Shanghai
# Use network installation
url --url="http://172.25.23.250/rhel6.5"
# System language
lang en_US
# Firewall configuration
firewall --enabled --service=ftp,ssh
# System authorization information
auth  --useshadow  --passalgo=sha512
# Use text mode install
text
firstboot --disable
# SELinux configuration
selinux --permissive

# Network information
network  --bootproto=dhcp --device=eth0
# Reboot after installation
reboot
# System bootloader configuration
bootloader --location=mbr   //安装MBR一定要有,否则安装完成之后无法启动;
# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart --all         //这个使用图形界面可能没有生成,需要手动添加,否则安装过程中,需要自己确定;
# Disk partitioning information
part / --fstype="ext4" --grow --size=1
part /swap --fstype="swap" --size=1     //这个分区类型一定选为swap,否则提示没有分区类型

%post       //这个是执行的一个脚本,用来更新Yum源
rm -f /etc/yum.repos.d/*

cat > /etc/yum.repos.d/yum.repo << end
# repos on instructor for classroom use

# Main rhel6.5 server
[base]
name=Instructor Server Repository
baseurl=http://172.25.23.250/rhel6.5
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

# HighAvailability rhel6.5
[HighAvailability]
name=Instructor HighAvailability Repository
baseurl=http://172.25.23.250/rhel6.5/HighAvailability
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

# LoadBalancer packages
[LoadBalancer]
name=Instructor LoadBalancer Repository
baseurl=http://172.25.23.250/rhel6.5/LoadBalancer
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

# ResilientStorage
[ResilientStorage]
name=Instructor ResilientStorage Repository
baseurl=http://172.25.23.250/rhel6.5/ResilientStorage
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

# ScalableFileSystem
[ScalableFileSystem]
name=Instructor ScalableFileSystem Repository
baseurl=http://172.25.23.250/rhel6.5/ScalableFileSystem
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
end
%end

%packages
@base
vim     //这里可以提供需要安装的软件包
%end
  • 后续的一些准备工作,编辑/etc/fstab添加第四行
    这里写图片描述
  • 2.安装httpd服务
[root@my Desktop]# yum install httpd -y
  • 执行
[root@my Desktop]# mount -a 
  • ks.cfg放在发布目录里面
[root@my Desktop]# ll /var/www/html/ks1.cfg 
-rw-r--r--. 1 root root 2064 65 19:01 /var/www/html/ks1.cfg
  • 启动httpd服务
[root@my Desktop]# systemctl start httpd.service
  • 然后通过virt-manager提供的管理界面,来安装一个测试主机
    这里写图片描述
  • 选择open左边的按钮,然后选择第二个选项
    这里写图片描述
  • 然后添加systemUDL以及ks.cfg文件的路径
    这里写图片描述
  • 这里内存的大小建议为1024否则在安装过程中会出现错误
    这里写图片描述
  • 关于磁盘的配置可以根据自己的要求进行配置
    这里写图片描述
  • 然后选择主机名以及和网卡的信息,填写本机的网卡信息
    这里写图片描述
  • 然后安装过程就会自动开始
    这里写图片描述

  • 安装完成之后,主机会自动重启
    这里写图片描述

  • 安装过程中出现的几个错误

  • 1.内存分配过于小,导致安装进程被杀死,由于安装过程中,分配的内存只有512M,导致安装进程被杀死,建议内存在800MB以上;
    这里写图片描述
  • 安装完成之后,没有启动,这个是因为没有安装bootloader导致的;
    这里写图片描述

猜你喜欢

转载自blog.csdn.net/qq_36294875/article/details/80586349
今日推荐