码迷,mamicode.com
首页 > 其他好文 > 详细

西部开源学习笔记BOOK2《自动安装系统》

时间:2016-11-24 22:15:58      阅读:241      评论:0      收藏:0      [点我收藏+]

标签:linux学习笔记

#############################

#####  unit1自动安装系统 #####

#############################

 

 

###################################

#### Network Install(HTTP,FTP,NFS) ####

###################################

 

#######1.kickstart脚本######

kickstart脚本是自动应答系统在安装过程中一切问题的脚本文件

在这个文件可以实现系统的自动安装

在系统安装完毕后会在系统的root家目录中生成

anaconda-ks.cfg这个文件就是以此系统为模板生成的kickstart脚本

 

#######2.kickstart脚本的制作######

手动编写kickstart的难度太大

系统中system-config-kickstart工具可以以图形的方式制作kickstart

 

yum install system-config-kickstart -y##安装kickstart图形制作工具

system-config-kickstart ##打开图形ks制作工具

ksvalidator ks.cfg##检测ks语法(只能检测语法错误)

 

补充注意:

因为ks工具的自身bug,导致软件包的安装功能不能选择。所以需要编辑/mnt/ks.cfg配置文件

vim /mnt/ks.cfg

 38 %packages##安装软件包

 39 @base##@表示组,base表示基本组。

此行表示只安装基本组,即安装之后的系统无图形

 40 %end    

如果想要安装图形等软件,可以参考真机家目录下的anaconda-ks.cfg文件。

 

 

#######3.kickstart文件共享######

yum install httpd -y##通过http协议共享ks文件

systemctl stop firewalld.server

systemctl enable firewalld.server

systemctl start httpd

systemctl enable httpd

cp /mnt/ks.cfg /var/www/html##/var/www/htmlhttp服务器默认的发布路径

 

 

######4.安装虚拟机#####

[root@localhost ~]#virt-install \

> --name kstest \

> --ram 1000 \

> --file /var/lib/libvirt/images/kstest.qcow2 \

> --file--size 8 \

> --extra-args "ks=http://172.25.254.119/ks.cfg" &##安装时查看的ks文件

 

##############################

######Network Boot(PXE)#######

##############################

 

######1.PXE网络安装的相应软件安装######

[root@localhost ~]# yum whatprovides */pxelinux.0

Loaded plugins: langpacks, product-id, subscription-manager

This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.

syslinux-4.05-12.el7.x86_64 : Simple kernel loader which boots

                            : from a FAT filesystem

Repo        : SOURCE

Matched from:

Filename    : /usr/share/syslinux/pxelinux.0

 

 

 

syslinux-4.05-12.el7.x86_64 : Simple kernel loader which boots

                            : from a FAT filesystem

Repo        : @SOURCE

Matched from:

Filename    : /usr/share/syslinux/pxelinux.0

 

##通过yum whatprovides查看pxelinux.0文件的安装包叫做syslinux

 

[root@localhost ~]# yum install dhcp tftp-server syslinux httpd xinetd.x86_64 -y

[root@localhost ~]# systemctl stop firewalld.service

[root@localhost ~]# systemctl disable firewalld.service

[root@localhost ~]# vim /etc/xinetd.d/tftp

 14         disable                 = yes

                                       || 改为

                                       \/

 14         disable                 = no

 

[root@localhost ~]# systemctl restart xinetd.service

[root@localhost ~]# systemctl start httpd

[root@localhost ~]# systemctl enable httpd

 

 

########2.必须文件的下载复制########

[root@localhost ~]# rpm -ql syslinux |grep pxelinux.0##查询软件生成文件

/usr/share/syslinux/gpxelinux.0

/usr/share/syslinux/pxelinux.0##这个是配置文件

[root@localhost ~]# cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/##将该配置文件(即pxe启动的所有配置文件)复制到tftp server的默认目录下

 

linux系统的iso镜像挂载到/var/lib/tftpboot/下,或者将iso里的文件复制到/var/lib/tftpboot/

由于该实验是用虚拟机作为tftp server的所以可以用给虚拟即加光驱的方式添加系统iso镜像:(方式如图)

 

[root@localhost ~]# cd /var/lib/tftpboot/##切换到/var/lib/tftpboot/目录下

[root@localhost tftpboot]# mkdir pxelinux.cfg##创建pxelinux.cfg文件

[root@localhost tftpboot]# ls##查看默认目录下的文件和目录

boot.cat    isolinux.bin  pxelinux.cfg  vesamenu.c32

boot.msg    isolinux.cfg  splash.png    vmlinuz

grub.conf   memtest       TRANS.TBL

initrd.img  pxelinux.0    upgrade.img

[root@localhost tftpboot]# cp isolinux.cfg pxelinux.cfg/default##将引导界面配置文件放到pxe启动的引导界面的默认配置文件目录下

##因为pxe启动读取的文件是pxelinux.cfg文件,而用iso启动则读取的是

 

 

########3.dhcp server的配置##########

[root@localhost dhcp]# cp /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example /etc/dhcp/dhcpd.conf

[root@localhost dhcp]# vim dhcpd.conf

(删除2728)

  7 option domain-name "localhost.localdomain";

  8 option domain-name-servers 172.25.254.250; ##dns服务器地址

 32 subnet 172.25.254.0 netmask 255.255.255.0 {##dhcp的网段,和子网掩码

 33   range 172.25.254.200 172.25.254.220;##地址池

 34   option routers 172.25.254.19;##网关

 35   next-server 172.25.254.119;##tftp server地址

 36   filename "pxelinux.0";##配置文件名

 37 }

[root@localhost tftpboot]# systemctl restart dhcpd

 

 

[root@localhost tftpboot]# vim pxelinux.cfg/default##编辑pxe安装引导界面的配置

  2 timeout 600##引导界面上显示的多少秒不操作之后按默认选项启动

 11 menu title Red Hat Enterprise Linux 7.2##引导界面的标题

 61 label linux

 62   menu label ^Install Red Hat Enterprise Linux 7.2

 63   kernel vmlinuz

 64   append initrd=initrd.img inst.stage2=hd:LABEL=RHEL-7.2    \x20Server.x86_64 quiet

 65

 66 label check

 67   menu label Test this ^media & install Red Hat Enterpri    se Linux 7.2

 68   menu default##默认选择该选项

 69   kernel vmlinuz

 70 append initrd=initrd.img inst.stage2=hd:LABEL=RHEL-7.2\x20Server.x86_64 rd.live.check quiet

##引导界面的菜单的选项

||

||

\/

 61 label linux

 62   menu label ^Install Red Hat Enterprise Linux 7.1

 63   kernel vmlinuz

 64   menu default##默认选择该选项

 65   append initrd=initrd.img repo=ftp://172.25.254.119/pub    /rhel7.1 ks=172.25.254.119/ks.cfg##设置repoks文件的路径

 66

 67 label check

 68   menu label Test this ^media & install Red Hat Enterpri    se Linux 7.2

 69   kernel vmlinuz                                        

 70   append initrd=initrd.img inst.stage2=hd:LABEL=RHEL-7.2    \x20Server.x86_64 rd.live.check quiet

 


西部开源学习笔记BOOK2《自动安装系统》

标签:linux学习笔记

原文地址:http://10664148.blog.51cto.com/10654148/1876270

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!