- 实现基于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 6月 5 19:01 /var/www/html/ks1.cfg
- 启动
httpd
服务
[root@my Desktop]# systemctl start httpd.service
- 然后通过
virt-manager
提供的管理界面,来安装一个测试主机
- 选择
open
左边的按钮,然后选择第二个选项
- 然后添加
system
的UDL
以及ks.cfg
文件的路径
- 这里内存的大小建议为
1024
否则在安装过程中会出现错误
- 关于磁盘的配置可以根据自己的要求进行配置
- 然后选择主机名以及和网卡的信息,填写本机的网卡信息
然后安装过程就会自动开始
安装完成之后,主机会自动重启
安装过程中出现的几个错误
- 1.内存分配过于小,导致安装进程被杀死,由于安装过程中,分配的内存只有
512M
,导致安装进程被杀死,建议内存在800MB
以上;
- 安装完成之后,没有启动,这个是因为没有安装
bootloader
导致的;