最近在学习RHCE课程,上一篇简单的讲一下如何用HTTP来作为KVM的VM网络安装过程,请阅读:http://gshao.blog.51cto.com/3512873/1882093
今天讲到FTP+HTTP+KickStart发布,当然还有PXE安装RHEL(后续讲)。
环境:
虚拟宿主机:RHEL 7.0
硬件:4vCPU+8G+40Gdisk
IP地址:172.16.38.10
vnet ip地址:192.168.100.1
先截图上一篇装完rhel系统的样子:
回归到正文,今天讲HTTPD+FTP+KickStart发布镜像。
1.先安装httpd服务,由于我们上一篇已安装,我们先确保httpd服务能正常启动,并测试web服务器的dvd目录是否正常访问;
[[email protected] ~]# systemctl status httpd #查看HTPPD服务状态
httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled)
Active: active (running) since Mon 2016-12-12 21:56:18 CST; 21h ago
Main PID: 14615 (httpd)
Status: "Total requests: 698; Current requests/sec: 0; Current traffic: 0 B/sec"
CGroup: /system.slice/httpd.service
├─14615 /usr/sbin/httpd -DFOREGROUND
├─14616 /usr/sbin/httpd -DFOREGROUND
├─14617 /usr/sbin/httpd -DFOREGROUND
├─14618 /usr/sbin/httpd -DFOREGROUND
├─14619 /usr/sbin/httpd -DFOREGROUND
├─14620 /usr/sbin/httpd -DFOREGROUND
├─14881 /usr/sbin/httpd -DFOREGROUND
├─14933 /usr/sbin/httpd -DFOREGROUND
├─14934 /usr/sbin/httpd -DFOREGROUND
└─14935 /usr/sbin/httpd -DFOREGROUND
Dec 12 21:56:18 localhost.localdomain httpd[14615]: AH00558: httpd: Could not reliably...e
Dec 12 21:56:18 localhost.localdomain systemd[1]: Started The Apache HTTP Server.
Hint: Some lines were ellipsized, use -l to show in full.
别记错哦,这里是对外的ip地址,不是对内的vnet ip地址;
2.安装FTP服务;
[[email protected] ~]# yum install vsftpd -y #安装vsftpd服务
3.启动vsftpd服务,启用vsftpd服务,测试ftp是否可以正常访问;
[[email protected] ~]# systemctl start vsftpd #启动vsftpd服务 [[email protected] ~]# systemctl enable vsftpd #启用vsftpd服务
ln -s ‘/usr/lib/systemd/system/vsftpd.service‘ ‘/etc/systemd/system/multi-user.target.wants/vsftpd.service‘
[[email protected] ~]# systemctl status vsftpd
vsftpd.service - Vsftpd ftp daemon
Loaded: loaded (/usr/lib/systemd/system/vsftpd.service; enabled)
Active: active (running) since Tue 2016-12-13 19:41:51 CST; 21s ago
Main PID: 48905 (vsftpd)
CGroup: /system.slice/vsftpd.service
└─48905 /usr/sbin/vsftpd /etc/vsftpd/vsftpd.conf
Dec 13 19:41:51 localhost.localdomain systemd[1]: Starting Vsftpd ftp daemon...
Dec 13 19:41:51 localhost.localdomain systemd[1]: Started Vsftpd ftp daemon.
4.安装KickStart服务;
[[email protected] ~]# yum install system-config-k #安装KickStart服务
5.启动Kickstart配置文件控制面板;
[[email protected] ~]# system-config-kickstart & #启动kickstart控制面板
6.在Kickstart Configurator-Basic Configuration界面,配置Time Zone时间为Asia/Shanghai,输入Root Passowrd,勾选Reboot system after installation和Perform installation in text mode(grahical is default);
7.在Kickstart Configurator-Installation Method,勾选Perform new installation,勾选HTTP,输入HTTP Server地址:192.168.100.1,HTTP Diretory为dvd/;
8.在Kickstart Configurator-Boot Loader Options,勾选install new boot loader,勾选Install boot loader on Master Boot Record(MBR);
9.在Kickstart Configurator-Partition Information,勾选Clear Master Boot Record,勾选Remove all existing partitions,勾选Initialize the disk label,Add swap和/分区,并分配空间;
10.在Kickstart Configurator-Network Configuration,点击Add Network Device,输入Network Device名,配置Network Type为DHCP;
11.在Kickstart Configurator-Firewall Configuration,配置SELinux为Warn,配置Security level为Disable firewall;
12.其他部分保持默认,如果你要添加shell,可以在Pre-Installation Script或者Post-Installation Script添加对应的shell脚本
13.点击File-Save;
14.因为我们之前搭建vsftp服务,我们直接存放在/var/ftp/pub里面;
15.补充一点,Package Selection默认在Kickstart配置器是不能勾选的;
16.我们可以通过在/root目录有个anaconda-ks.cfg,这个也是Kickstart配置文件,进行将Package Selection的部分内容复制到我们刚才制作的ks.cfg配置文件中;
[[email protected] ~]# ll #查看/root目录下的文件和目录信息
total 8
-rw-------. 1 root root 1039 Dec 13 05:26 anaconda-ks.cfg
drwxr-xr-x. 2 root root 6 Dec 12 21:29 Desktop
drwxr-xr-x. 2 root root 6 Dec 12 21:29 Documents
drwxr-xr-x. 2 root root 6 Dec 12 21:29 Downloads
-rw-r--r--. 1 root root 1090 Dec 12 21:27 initial-setup-ks.cfg
drwxr-xr-x. 2 root root 6 Dec 12 21:29 Music
drwxr-xr-x. 2 root root 6 Dec 12 21:29 Pictures
drwxr-xr-x. 2 root root 6 Dec 12 21:29 Public
drwxr-xr-x. 2 root root 6 Dec 12 21:29 Templates
drwxr-xr-x. 2 root root 6 Dec 12 21:29 Videos
[[email protected] ~]# vim anaconda-ks.cfg #编辑anaconda-ks.cfg配置文件
#version=RHEL7
# System authorization information
auth --enableshadow --passalgo=sha512
# Use CDROM installation media
cdrom
# 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-8
# Network information
network --bootproto=dhcp --device=eno16777736 --onboot=off --ipv6=auto
network --hostname=localhost.localdomain
# Root password
rootpw --iscrypted $6$ut0phHAB7rUmESNG$zaX4Uy86lOmzJYkIoBWeY4Baq.W0.7qoe8PakPZAyH/Gmmb9im0rx9GpR8hWv3aV9Axq9dRq8Y.C7Hj6fbiCg/
# System timezone
timezone America/New_York --isUtc
# X Window System configuration information
xconfig --startxonboot
# System bootloader configuration
bootloader --location=mbr --boot-drive=sda
autopart --type=lvm
# Partition clearing information
clearpart --none --initlabel
%packages
@base
@core
@desktop-debugging
@dial-up
@fonts
@gnome-desktop
@guest-agents
@guest-desktop-agents
@input-methods
@internet-browser
@multimedia
@print-client
@x11
%end
我们将这部分复制出来,张贴到ks.cfg配置文件;
[[email protected] ~]# vim /var/ftp/pub/ks.cfg #编辑ks.cfg配置文件
#platform=x86, AMD64, or Intel EM64T
#version=DEVEL
# Install OS instead of upgrade
install
# Keyboard layouts
keyboard ‘us‘# Reboot after installation
text
firstboot --disable
# SELinux configuration
selinux --permissive
# System bootloader configuration
bootloader --location=mbr
# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart --all --initlabel
# Disk partitioning information
part swap --fstype="swap" --size=1024
part / --fstype="xfs" --size=5000
%packages
@base
@core
%end
在这里的意思,就是最小安装模式;
然后我们保存并退出;
17.启动virt-manager界面;
[[email protected] ~]# virt-manager #启动virt-manager界面
18.在Virtual Machine Manager,点击New,输入Name,勾选Network Install(HTTP,FTP,or NFS),点击Forward;
19.在New VM第二部,输入URL:http://192.168.100.1/dvd,配置KickStart URL:ftp://192.168.100.1/pub/ks.cfg,点击Forward;
20.在New VM第三步,点击Forward;
21.在New VM第四步,点击Forward;
22.在New VM第五步,点击Finish;
23.看到这个界面,表示KickStart配置文件没问题,可以自动化安装vm;