天天看點

RHCE之HTTPD+FTP+KickStart釋出鏡像,用于KVM的VM自動安裝過程

最近在學習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系統的樣子:

RHCE之HTTPD+FTP+KickStart釋出鏡像,用于KVM的VM自動安裝過程

回歸到正文,今天講HTTPD+FTP+KickStart釋出鏡像。

1.先安裝httpd服務,由于我們上一篇已安裝,我們先確定httpd服務能正常啟動,并測試web伺服器的dvd目錄是否正常通路;

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.

RHCE之HTTPD+FTP+KickStart釋出鏡像,用于KVM的VM自動安裝過程

别記錯哦,這裡是對外的ip位址,不是對内的vnet ip位址;

RHCE之HTTPD+FTP+KickStart釋出鏡像,用于KVM的VM自動安裝過程

2.安裝FTP服務;

RHCE之HTTPD+FTP+KickStart釋出鏡像,用于KVM的VM自動安裝過程

3.啟動vsftpd服務,啟用vsftpd服務,測試ftp是否可以正常通路;

ln -s '/usr/lib/systemd/system/vsftpd.service' '/etc/systemd/system/multi-user.target.wants/vsftpd.service'    

[root@localhost ~]# 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.    

RHCE之HTTPD+FTP+KickStart釋出鏡像,用于KVM的VM自動安裝過程
RHCE之HTTPD+FTP+KickStart釋出鏡像,用于KVM的VM自動安裝過程

4.安裝KickStart服務;

RHCE之HTTPD+FTP+KickStart釋出鏡像,用于KVM的VM自動安裝過程

5.啟動Kickstart配置檔案控制台;

RHCE之HTTPD+FTP+KickStart釋出鏡像,用于KVM的VM自動安裝過程

6.在Kickstart Configurator-Basic Configuration界面,配置Time Zone時間為Asia/Shanghai,輸入Root Passowrd,勾選Reboot system after installation和Perform installation in text mode(grahical is default);

RHCE之HTTPD+FTP+KickStart釋出鏡像,用于KVM的VM自動安裝過程

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);

RHCE之HTTPD+FTP+KickStart釋出鏡像,用于KVM的VM自動安裝過程

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裡面;

RHCE之HTTPD+FTP+KickStart釋出鏡像,用于KVM的VM自動安裝過程

15.補充一點,Package Selection預設在Kickstart配置器是不能勾選的;

RHCE之HTTPD+FTP+KickStart釋出鏡像,用于KVM的VM自動安裝過程

16.我們可以通過在/root目錄有個anaconda-ks.cfg,這個也是Kickstart配置檔案,進行将Package Selection的部分内容複制到我們剛才制作的ks.cfg配置檔案中;

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

#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配置檔案;

#platform=x86, AMD64, or Intel EM64T  

#version=DEVEL    

# Install OS instead of upgrade    

install    

keyboard 'us'# Reboot after installation    

text    

firstboot --disable    

# SELinux configuration    

selinux --permissive

# System bootloader configuration  

bootloader --location=mbr    

# Clear the Master Boot Record    

zerombr    

clearpart --all --initlabel    

# Disk partitioning information    

part swap --fstype="swap" --size=1024    

part / --fstype="xfs" --size=5000

@core

%end

在這裡的意思,就是最小安裝模式;

然後我們儲存并退出;

17.啟動virt-manager界面;

RHCE之HTTPD+FTP+KickStart釋出鏡像,用于KVM的VM自動安裝過程

18.在Virtual Machine Manager,點選New,輸入Name,勾選Network Install(HTTP,FTP,or NFS),點選Forward;

RHCE之HTTPD+FTP+KickStart釋出鏡像,用于KVM的VM自動安裝過程

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;

RHCE之HTTPD+FTP+KickStart釋出鏡像,用于KVM的VM自動安裝過程

21.在New VM第四步,點選Forward;

RHCE之HTTPD+FTP+KickStart釋出鏡像,用于KVM的VM自動安裝過程

22.在New VM第五步,點選Finish;

RHCE之HTTPD+FTP+KickStart釋出鏡像,用于KVM的VM自動安裝過程

23.看到這個界面,表示KickStart配置檔案沒問題,可以自動化安裝vm;

RHCE之HTTPD+FTP+KickStart釋出鏡像,用于KVM的VM自動安裝過程
RHCE之HTTPD+FTP+KickStart釋出鏡像,用于KVM的VM自動安裝過程
RHCE之HTTPD+FTP+KickStart釋出鏡像,用于KVM的VM自動安裝過程