1.kickstart的安装和部署(用网络安装系统)
[root@localhost ~]# yum install httpd system-config-kickstart
##我们先安装共享kickstart的工具http,还有kickstart的制作工具,因为我们已经有dhcp了这里就不用安装了
[root@localhost ~]# systemctl status httpd
##查看httpd状态,发现已经打开和开机自启动了,我们就不需要再设置了
● httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
Active: active (running) since Mon 2020-06-22 15:15:58 CST; 19h ago
Docs: man:httpd(8)
man:apachectl(8)
Main PID: 7679 (httpd)
Status: "Total requests: 0; Current requests/sec: 0; Current traffic: 0 B/sec"
Tasks: 6
CGroup: /system.slice/httpd.service
├─7679 /usr/sbin/httpd -DFOREGROUND
├─7859 /usr/sbin/httpd -DFOREGROUND
├─7860 /usr/sbin/httpd -DFOREGROUND
├─7861 /usr/sbin/httpd -DFOREGROUND
├─7862 /usr/sbin/httpd -DFOREGROUND
└─7863 /usr/sbin/httpd -DFOREGROUND
Jun 22 15:15:53 localhost.localdomain systemd[1]: Starting The Apache HTTP Server...
Jun 22 15:15:58 localhost.localdomain httpd[7679]: AH00558: httpd: Could not reliably determine ...age
Jun 22 15:15:58 localhost.localdomain systemd[1]: Started The Apache HTTP Server.
Hint: Some lines were ellipsized, use -l to show in full.
[root@localhost ~]# systemctl status firewalld
##发现火墙是打开的
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
Active: active (running) since Mon 2020-06-22 15:15:47 CST; 19h ago
Docs: man:firewalld(1)
Main PID: 7166 (firewalld)
Tasks: 2
CGroup: /system.slice/firewalld.service
└─7166 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid
Jun 22 15:15:41 localhost.localdomain systemd[1]: Starting firewalld - dynamic firewall daemon...
Jun 22 15:15:47 localhost.localdomain systemd[1]: Started firewalld - dynamic firewall daemon.
[root@localhost ~]# systemctl stop firewalld
##我们关掉火墙
[root@localhost ~]# system-config-kickstart
##制作工具也可以打开
##上面这个页面是基本设置页面,分别是默认语言,键盘,时区, root用户密码,确定密码,encrypt root passwd 选中就是显示密码以加密字符的样子显示,不选中就是以明文的样子显示
target architecure(目标构架)这个是显示cpu是什么类型的,有AMD的 intel的 IBM小鸡,IBM服务器,IBM的超级PC,因为我们的cpu的设置我们选择×86架构
下面是 安装后重启和执行文本模式(默认是图形):其实就是没有文本的命令行模式,但是这个是安装系统过程中有没有图形而不是安装完毕后是否有图形,我们选择命令行模式,这样更快,因为图形也是个软件,他也需要加载。
##这就是我们配置好的基本配置,下面设置安装方法
##上面这个第一个是perform new installation 就相当于我们刚设置好虚拟机那个页面选择的第一个安装新的虚拟机系统一样,接下来是加载全新的引导
##拓展:硬盘相当于这个⚪,然后里面有数据的地方为1,没有数据的地方为0,然后我们扫描硬盘的数据用的是磁头(磁头扫描的时候磁头是不动的,是磁盘在转圈),就是红色这个,磁盘刚通电的时候磁盘就先扫描他下方那个粗红线的区域,这个区域叫做主引导记录(大约446个字节)(mbr),这个mbr的作用就是磁头扫描完这片区域后,他告诉磁盘接下来要去读取其他地方(系统盘C)的资源
##所以这个主引导程序是我们安装系统的时候安装上去的,也就是 下面的install new boot loader,如果我们选择第二个do not install a boot loader就是代表不安装这个引导程序,这可能导致我们安装完成系统后,磁头找不到系统(就是没有发号指令的对象来让他去那边)
##接下来是分区
##这三个设置分别是清空那个引导程序,移除所有已经存在的分区,初始化设备标签
##然后再点Add添加,选择为boot目录下,fixed size(确定分区大小为)200M,还有Format partition格式这个boot原本的内容,在选择OK
##再add一个swap分区,他的大小为物理内存的两倍,这里选500就行,再点击确定
##在选择根分区,把剩余的空间都给他
##这是选择好的分区划分,下面是Network Confuguration(网络配置)
##网络类型我们选择动态的,让他自动匹配,这样我们安装多台主机的时候我们手动输入IP可能会导致几个IP相同,最后导致冲突,下面是Authentication(认证),我们不选择了直接默认就行
##下面是火墙设置,我们先直接关闭它就行,并且不让他自启
##下面是Display Configuration(显示配置),我们选择disabled就是第一次启动我们不做任何的设定
##下面是软件包的选择,因为这个软件有bug,这里没法显示,我们可以后期加软件包进去
##下面两个是安装之前要准备的和安装之后要准备的
##比如我们安装完成后想搭建个yum源,我们就可以以脚本的形式把他写进去
##我们可以示例安装完成后在桌面创建10个文件
##最后点击左上角的file选择save到/var/www/html/下(因为我们有apache)
##我们也可以利用apache来访问
##但是我们前面那个bug软件还有时区的选择还没有选,所有这个文件时缺失的,现在我们需要选择他们
##我们将原本的时区注释掉,现在改为亚洲的上海
##这个@base相当于我们的安装整个组件软件包,下面的dhcp就是单个软件包,我们没有选择图形,因此安装后也没有图形,如果我们想装图形怎么办加上@GNOME和@X11,软件包前面不用加@,组软件包需要加@
[root@localhost html]# yum group info GNOME
##这是我们的GNOME的组软件包里面都是图形的信息
Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
Group: GNOME
Group-Id: gnome-desktop
Description: GNOME is a highly intuitive and user friendly desktop environment.
Mandatory Packages:
NetworkManager-libreswan-gnome
PackageKit-command-not-found
PackageKit-gtk3-module
abrt-desktop
at-spi2-atk
at-spi2-core
avahi
baobab
+caribou
+caribou-gtk2-module
+caribou-gtk3-module
cheese
compat-cheese314
control-center
dconf
empathy
eog
evince
evince-nautilus
file-roller
file-roller-nautilus
firewall-config
firstboot
fprintd-pam
gdm
gedit
glib-networking
gnome-bluetooth
gnome-boxes
gnome-calculator
gnome-classic-session
gnome-clocks
gnome-color-manager
gnome-contacts
gnome-dictionary
gnome-disk-utility
gnome-font-viewer
gnome-getting-started-docs
gnome-icon-theme
gnome-icon-theme-extras
gnome-icon-theme-symbolic
gnome-initial-setup
gnome-packagekit
gnome-packagekit-updater
gnome-screenshot
gnome-session
gnome-session-xsession
gnome-settings-daemon
gnome-shell
gnome-software
gnome-system-log
gnome-system-monitor
gnome-terminal
gnome-terminal-nautilus
gnome-themes-standard
gnome-tweak-tool
gnome-user-docs
gnome-weather
gucharmap
gvfs-afc
gvfs-afp
gvfs-archive
gvfs-fuse
gvfs-goa
gvfs-gphoto2
gvfs-mtp
gvfs-smb
initial-setup-gui
libcanberra-gtk2
libcanberra-gtk3
libproxy-mozjs
librsvg2
libsane-hpaio
metacity
mousetweaks
nautilus
nautilus-sendto
nm-connection-editor
orca
redhat-access-gui
rhn-setup-gnome
sane-backends-drivers-scanners
seahorse
setroubleshoot
subscription-manager-gui
subscription-manager-initial-setup-addon
sushi
totem
totem-nautilus
vinagre
vino
xdg-user-dirs-gtk
yelp
Default Packages:
qgnomeplatform
xdg-desktop-portal-gtk
Optional Packages:
alacarte
dconf-editor
dvgrab
fonts-tweak-tool
gconf-editor
gedit-plugins
gnome-shell-browser-plugin
gnote
libappindicator-gtk3
seahorse-nautilus
seahorse-sharing
vim-X11
xguest
[root@localhost html]# yum group info X11
##这个是也是图形的软件包
Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
Group: X Window System
Group-Id: x11
Description: X Window System Support.
Mandatory Packages:
glx-utils
initial-setup-gui
mesa-dri-drivers
plymouth-system-theme
spice-vdagent
xorg-x11-drivers
xorg-x11-server-Xorg
xorg-x11-utils
xorg-x11-xauth
xorg-x11-xinit
xvattr
Optional Packages:
mesa-libGLES
tigervnc-server
wayland-protocols-devel
xorg-x11-drv-keyboard
xorg-x11-drv-libinput
xorg-x11-drv-mouse
xorg-x11-drv-openchrome
##因为我们现在做测试,考虑到有图形软件包多就先不装图形软件包了
[root@localhost html]# ksvalidator ks.cfg
##这个命令是检测的ks.cfg文件的,可以看到提示说40行有问题,Packages有问题,没注意写成大写了,把他调整成小写
The following problem occurred on line 40 of the kickstart file:
Unknown kickstart section: %Packages
[root@localhost html]# ksvalidator ks.cfg
##这次又提示我们packages要用end结尾
The following problem occurred on line 44 of the kickstart file:
Section %packages does not end with %end.
[root@localhost html]# ksvalidator ks.cfg
##这次检测没有问题了
##我们打开虚拟机的管理,创建一个虚拟机,详情颗见XVM管理那章,然后设置完成后打开虚拟机
##我们在这个页面按一下TAB键,输入ks=http://192.168.0.100/ks.cfg 就可以利用我们编辑的内容完成虚拟机的安装
pxe的原理就是我们安装dhcp和apache,dhcp提供IP支持,apache提供共享支持,因为我们是dhcp的网络,会自动分发出来IP,然后当我们给另外一个系统IP的时,就可以带上apache共享的文件,然后将IP和预安装的系统的设置一并传输过去,完成系统的安装
##我们第二次在做pxe的时候选择的源这块就可以是我们的apache的共享出来的那个源了
##其他设置不变
##我们这次可以直接让安装的系统配置好yum源,如上,并且这次保存的文件名为westos.cfg
[root@localhost html]# vim westos.cfg
##编辑我们不完整的配置给他加上软件包
[root@localhost html]# ksvalidator westos.cfg
##检测完没有问题
##配置好dhcp,方法查看上一章
##这样我们kickstart和http还有dhcp都已经设置好了
[root@localhost html]# ls
ks.cfg rhel7.6 westos.cfg westos.html
[root@localhost html]# cd rhel7.6/
[root@localhost rhel7.6]# ls
addons EFI EULA extra_files.json GPL images isolinux LiveOS media.repo Packages repodata RPM-GPG-KEY-redhat-beta RPM-GPG-KEY-redhat-release TRANS.TBL
[root@localhost rhel7.6]# cd isolinux/
##这个里面是镜像的linux 系统
[root@localhost isolinux]# ls
boot.cat grub.conf isolinux.bin memtest TRANS.TBL vesamenu.c32
boot.msg initrd.img isolinux.cfg splash.png upgrade.img vmlinuz
[root@localhost isolinux]# vim isolinux.cfg
##打开后可以看到isolinux镜像的的内容
##这边显示等待的时间是600毫秒,也就是1分钟
##就是这个界面等一分钟
##title是Red Hat Enterprise linux 7.6
##第一个大的标题也是install Red Hat Enterprise linux 7.6
##第二个大的标题Test this ^media & install Red Hat Enterprise Linux 7.6(检测再安装)
##第三个是^Troubleshooting
##因此可见开机读取的是这个文件
##并且这个里面加载了内核文件,还有初始化镜像文件
[root@localhost isolinux]# ls
##这两个文件在我们系统也存在,因此我们利用virt启动镜像的时候使用的资源文件都是在我们的isolinux里面
boot.cat grub.conf isolinux.bin memtest TRANS.TBL vesamenu.c32
boot.msg initrd.img isolinux.cfg splash.png upgrade.img vmlinuz
##因此我们的dhcp分出去一个package里面包含IP和islinux里面的资源,把这些东西给我们要装的这个虚拟机(client)
##islinux里面的文件是靠什么来读取的
[root@localhost isolinux]# yum search pxelinux
##我们查找pxe环境的安装包
Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
====================================== Matched: pxelinux ======================================
syslinux.x86_64 : Simple kernel loader which boots from a FAT filesystem
syslinux-extlinux.x86_64 : The EXTLINUX bootloader, for booting the local system.
syslinux-tftpboot.noarch : SYSLINUX modules in /var/lib/tftpboot, available for network booting
##syslinux发现这个就是
[root@localhost isolinux]# yum install syslinux
##我们对其进行安装
[root@localhost isolinux]# rpm -ql syslinux
##查看他的配置文件
[root@localhost isolinux]# less /usr/share/doc/syslinux-4.05/pxelinux.txt
##查看这个文件
##这个写了如何配置pxelinux,上面说了我们必须在TFTP服务器上做一个默认访问目录目录,并且把pxelinux.0这个文件放进去
##因此我们第一步是先安装RFTP
[root@localhost isolinux]# yum search tftp
##查询tftp的安装包信息
Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
====================================== N/S matched: tftp ======================================
syslinux-tftpboot.noarch : SYSLINUX modules in /var/lib/tftpboot, available for network booting
tftp.x86_64 : The client for the Trivial File Transfer Protocol (TFTP)
tftp-server.x86_64 : The server for the Trivial File Transfer Protocol (TFTP)
Name and summary matches only, use "search all" for everything.
##可以看到是tftp-server.x86_64
[root@localhost isolinux]# yum install tftp-server.x86_64
##安装TFCP
[root@localhost isolinux]# rpm -ql tftp-server
##查看软件包的安装路径,然后查询tftp的启动文件
/etc/xinetd.d/tftp
/usr/lib/systemd/system/tftp.service
/usr/lib/systemd/system/tftp.socket
/usr/sbin/in.tftpd
/usr/share/doc/tftp-server-5.2
/usr/share/doc/tftp-server-5.2/CHANGES
/usr/share/doc/tftp-server-5.2/README
/usr/share/doc/tftp-server-5.2/README.security
/usr/share/man/man8/in.tftpd.8.gz
/usr/share/man/man8/tftpd.8.gz
/var/lib/tftpboot
##/usr/lib/systemd/system/tftp.service这个是启动文件,/var/lib/tftpboot这个是默认访问路径
[root@localhost isolinux]# systemctl start tftp
[root@localhost isolinux]# systemctl enable tftp
Created symlink from /etc/systemd/system/sockets.target.wants/tftp.socket to /usr/lib/systemd/system/tftp.socket.
[root@localhost isolinux]# systemctl status tftp
##tftp功能已经打开
● tftp.service - Tftp Server
Loaded: loaded (/usr/lib/systemd/system/tftp.service; indirect; vendor preset: disabled)
Active: active (running) since Wed 2020-06-24 11:24:49 CST; 52s ago
Docs: man:in.tftpd
Main PID: 37477 (in.tftpd)
CGroup: /system.slice/tftp.service
└─37477 /usr/sbin/in.tftpd -s /var/lib/tftpboot
Jun 24 11:24:49 localhost.localdomain systemd[1]: Started Tftp Server.
##第二步做默认访问目录和放文件进去
[root@localhost isolinux]# cd /var/lib/tftpboot/
[root@localhost tftpboot]# ls
[root@localhost tftpboot]# rpm -ql syslinux
##找到了pxelinux.0
[root@localhost tftpboot]# cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/
##再将这个文件拷贝到tftpboot里面
[root@localhost tftpboot]# ls
pxelinux.0
[root@localhost tftpboot]# file pxelinux.0
##查看pxelinux文件的属性为数据,这个数据的目的是用它的数据读pxelinux.cfg然后把他重新命名为default,里面的内容就和/var/www/html/rhel7.6/isolinux/isolinux.cfg文件内容一样,这个文件的功能就是读取vmlinuz文件让他启动isolinux文件里面的所有服务
pxelinux.0: data
##然后建立一个/tftpboot/pxelinux.cfg这个目录
[root@localhost tftpboot]# mkdir pxelinux.cfg
##这个目录缺少文件default
[root@localhost tftpboot]# ls
pxelinux.0 pxelinux.cfg
[root@localhost tftpboot]# cp /var/www/html/rhel7.6/isolinux/isolinux.cfg pxelinux.cfg/default
##复制/isolinux.cfg过来到pxelinux.cfg里面并且命名为defalt
[root@localhost tftpboot]# cd pxelinux.cfg/
[root@localhost pxelinux.cfg]# ls
default
##那如何dhcp分配IP的时候带上我们要让他带上的pxe.linux。0文件
##这个就是配置好dhcp后,next-server 192.168.0.1;马上去找ip为192.168.0.1的文件名为pxelinux.0的文件,意思就是配置好网络后就去寻找192.168.0.100里面的pxelinux.0文件他会告诉你下一步干什么(读取pxelinux.cfg或者说是default文件,deault就是我们装系统读取的那个页面文件)
[root@localhost dhcp]# systemctl stop dhcpd
[root@localhost dhcp]# systemctl mask dhcpd
##打开虚拟机设置为pxe链接
##可以看到他在找dhcp,并且获得了IP,但是最后加载pxelinux.cfg下的default失败了,是不能找到vesamenu.c32这个文件
[root@localhost dhcp]# cd /var/www/html/rhel7.6/isolinux
[root@localhost isolinux]# ls
##我们的镜像有versameau.c32这个文件
boot.cat grub.conf isolinux.bin memtest TRANS.TBL vesamenu.c32
boot.msg initrd.img isolinux.cfg splash.png upgrade.img vmlinuz
[root@localhost isolinux]# cp vesamenu.c32 /var/lib/tftpboot
##复制这个文件到tftpboot里面就行
##下次我们重新打开虚拟机,发现已经到安装的页面了,但是还是不能安装,因为他要读取vmlinuz文件,initrd.img这个文件
[root@localhost isolinux]# ls
##因此可见这个目录的文件都需要
boot.cat boot.msg grub.conf initrd.img isolinux.bin isolinux.cfg memtest splash.png TRANS.TBL upgrade.img vesamenu.c32 vmlinuz
[root@localhost isolinux]# cp -r * /var/lib/tftpboot
##将isolinux里面的内容都复制到tffpboot里面
[root@localhost isolinux]# cd /var/lib/tftpboot
[root@localhost tftpboot]# ls
##可以看到都拷贝过去了
boot.cat grub.conf isolinux.bin memtest pxelinux.cfg TRANS.TBL vesamenu.c32
boot.msg initrd.img isolinux.cfg pxelinux.0 splash.png upgrade.img vmlinuz
##当我们选择安装linux7.6的时候读取的文件就是我们设置的资源指向文件
##再次重新启动虚拟机,发现kickstart有问题,就是我们使用的根分区有问题
[root@localhost html]# system-config-kickstart westos.cfg
##发现分区确实没有整好
##最后保存到westos.cfg下,然后再次打开虚拟机,这下就没有问题了
##我们可以看到默认等待时间是60秒,默认的选项是第二个,我们如何更改呢
[root@localhost tftpboot]# cd /var/lib/tftpboot/
[root@localhost tftpboot]# ls
boot.cat grub.conf isolinux.bin memtest pxelinux.cfg TRANS.TBL vesamenu.c32
boot.msg initrd.img isolinux.cfg pxelinux.0 splash.png upgrade.img vmlinuz
[root@localhost tftpboot]# vim pxelinux.cfg/default
##我们将他改为20,就是2秒等待时间
##我们也可以将他上方的原本的标题改为WESTOS AUTO INSTALL SYSTEM(上面原本的RED hat那行要删除,留在这里只是方面看清修改之前的内容)
##我们可以看到第二个标题上有menu default,就是说默认在这,我们将menu default放到第一个位置默认位置就变成第一个标题了