kickstart自动化系统安装_kickstart自动化安装系统

kickstart

用途:自动化安装系统。

优势:传统装机需要下载系统镜像,然后人工一步一步设置各种参数,然后点击按钮安装,如果需要同时安装100台机器,则重复性工作太多,而且耗费人力和时间,kickstart则可以生成一个设置好各种参数的脚本ks.cfg文件,然后自动化安装。

1.首先下载kickstart,如果没有配置yum源,先配置yum源

yum install system-config-kickstart.noarch -y

2.然后打开httpd服务,关闭防火墙。

[root@localhost Desktop]# systemctl start httpd #打开httpd

[root@localhost Desktop]# systemctl enable httpd

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

[root@localhost Desktop]# systemctl stop firewalld #关闭火墙

[root@localhost Desktop]# systemctl disable firewalld

rm '/etc/systemd/system/basic.target.wants/firewalld.service'

rm '/etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service'

3.启动kickstart

[root@localhost Desktop]# system-config-kickstart #设置自动安装的选择

4.下面对图形界面进行设置

Screenshot from 2019-01-19 16-16-35.png

Screenshot from 2019-01-19 16-10-19.png

![Screenshot from 2019-01-19 16-17-50.png](https://upload-images.jianshu.io/upload_images/15534708-06f3f907d64298d9.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

Screenshot from 2019-01-19 16-17-50.png

Screenshot from 2019-01-19 16-18-13.png

[图片上传中...(Screenshot from 2019-01-19 16-18-32.png-22fdbd-1547886123239-0)]

Screenshot from 2019-01-19 16-18-32.png

[图片上传中...(Screenshot from 2019-01-19 16-18-49.png-63799c-1547886197633-0)]

Screenshot from 2019-01-19 16-18-49.png

Screenshot from 2019-01-19 16-19-04.png

Screenshot from 2019-01-19 16-19-15.png

Screenshot from 2019-01-19 16-19-25.png

Screenshot from 2019-01-19 16-19-36.png

Screenshot from 2019-01-19 16-19-46.png

这个ks.cfg就是你在图形界面上设置参数的配置文件。通过这个配置我们可以实现自动化安装。

5.vim ks.cfg #编辑文件,指定安装过程中需要安装的软件,在文件末尾添加

%packages

@base

%end

ksvalidator ks.cfg #检测语法是否正确

6.转到真机

vim /mnt/xxx.sh

chmod /mnt/xxx.sh #加可执行权限

/mnt/xxx.sh 虚拟机名字 #执行脚本,生成虚拟机

#!/bin/bash

virt-install \

--name $1 \

--ram 1024 \

--cpus 1 \

--disk /var/lib/libvirt/images/$1.qcow2,bus=virtio,size=9 \

--network bridge=br0,model=virtio \

--location http://172.25.254.36/rhel7.0 \ #真机

--extra-args ks=http://172.25.254.100/ks.cfg & #虚拟机下ks.cfg的地址

[root@foundation36 Desktop]# bash kickstart.sh vm

直接在运行kickstart

只有两个区别

1.在配置图形界面的第二项http地址中,HTTP Server应为http://你主机的ip,HTTP Directory为你主机挂载镜像的位置。(我的是/var/www/html/rhel7.0,所以填写rhel7.0)

2.vim kickstart.sh脚本,修改extra-args ks=http://172.25.254.100/ks.cfg & 的ip为你主机的ip,并且要保证你的ks.cfg脚本要在/var/www/html目录下。

如果提示

[root@foundation36 Desktop]# ERROR Error validating install location: Could not find an installable distribution at 'http://172.25.254.36/rhel7.0'

那么说明kickstart没有找到http://172.25.254.36/rhel7.0这个目录或者你的镜像没有挂载到/var/www/html/rhel7.0下面,那么就先新建一个/var/www/html/rhel7.0目录,然后将对应的镜像挂载到/var/www/html/rhel7.0。

[root@foundation36 Desktop]# mount /home/kiosk/Desktop/software/rhel-server-7.0-x86_64-dvd.iso /var/www/html/rhel7.0/ #挂载

mount: /dev/loop1 is write-protected, mounting read-only

[root@foundation36 Desktop]# bash kickstart.sh sd #执行脚本

[root@foundation36 Desktop]#

Starting install... #开始安装

...

你可能感兴趣的:(kickstart自动化系统安装_kickstart自动化安装系统)