学习笔记 十八: kickstart

简介:

一 kickstart简介

   ks是自动批量安装工具,它可以从网络自动安装操作系统,不需要与用户交互,对于需要安装大批量机器,可以很方便快速的安装和使用。


相关变量参数详解:

%packages   定义需要安装的包裹

%pre        预先安装

%post        



ks配置文件详解:

url --url="ftp://xxxx"      指定URL


vnc  --password=redhat


clearpart:  clears the specified partitions before installation.

clearpart --all --drives=sda,sdb --initlabel


part :   specifies the size,format,and name of a partition.

part /home --fstype=ext4 --label=homes --size=4096 --maxsize=8128 --grow


ignoredisk :   ignores the specified disks when installing.


ignoredisk --drives=sdc


bootloader: defines where to install the bootloader.


bootloader --location=mbr -boot-drive=sda


volgroup,logvol: creates lvm volume groups and logical volumes.


part pv.01 --size=8192

volgroup myvg pv.0.1

logvol / --vgname=myvg --fstype=xfs --size=2048 --name=rootvol --grow


Network commands:


#启动网络配置为dhcp

network --device=eth0 --bootproto=dhcp


#启动防火墙

firewall --enabled --service=ssh,cups


#配置语言为utf8

lang en_US.UTF-8


#键盘

keyboard --vckeymap=us --xlayouts='us','us'


timezone --utc  --ntpservers=time.xxx.com Europe/ASIA


#root密码

rootpw --plaintext redhat


selinux --enforcing


services --disabled=network,iptables,ip6tables --enabled=firewalld


group --name=admins --gid=10001

user --name=cw --gecos="chen wei" --groups=admins --password=chenwei --plaintext


loggin --host=www --level=info


firstboot --disabled


检查语法工具:ksvalidator ks.cfg




二 安装配置


1.需要安装的有:

  • Network servers:FTP,HTTP,NFS

  • DHCP/TFTP SERVER

  • USB disk or CDROM

  • local hard disk



2.启动方式:

ks=http://server/dir/file

ks=ftp://server/dir/file

ks=nfs:server/dir/file

ks=cdrom:/dir/file





三  案例

使用system-config-kickstart工具,创建一个配置文件


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

一  tftp配置用于pxe启动

二  dhcp配置

三  kickstart文件配置

四  yum服务器


通过选择安装不同的linux。 

比如:安装rhel6/rhel7等等

=============================================================


一 环境说明:

  1.1  环境是

  RHEL5.7 64


dhcp服务器 : 要求可以正常分配ip并且指定TFTP服务器

vsftp 服务器 : 用于存放 Yum 仓库

tftp  服务器 : 存放系统安装所需要的引导文件pxelinux.0文件、启动菜单、内核vmlinuz及initrd.img、ks无人值守配置文件ks.cfg

pxelinux.0 pxe专用启动引导文件,/usr/share/syslinux 目录中找到,直接存放在TFTP要目录即可(也可在/etc/dhcpd.conf 指定)

客户端需要

 

支持PXE启动的网卡

具体过程

建好Yum源,vsftp/PXE 启动的准备工作




二 安装步骤:

2.1 tftp安装配置

cd /var/lib/tftpboot/

[root@chenwei tftpboot]# cp /usr/lib/syslinux/pxelinux.0 .

[root@chenwei tftpboot]# ls

linux-install  pxelinux.0

[root@chenwei tftpboot]# mkdir pexlinux.cfg

[root@chenwei tftpboot]# cp /opt/yum/pub/isolinux/isolinux.cfg pexlinux.cfg/default

[root@chenwei tftpboot]# cp /opt/yum/pub/images/

boot.iso      diskboot.img  minstg2.img   pxeboot/      README        stage2.img    TRANS.TBL     xen/

[root@chenwei tftpboot]# cp /opt/yum/pub/images/pxeboot/initrd.img .

[root@chenwei tftpboot]# cp /opt/yum/pub/images/pxeboot/vmlinuz .

[root@chenwei tftpboot]# ls

initrd.img  linux-install  pexlinux.cfg  pxelinux.0  vmlinuz

[root@chenwei tftpboot]# vi pxelinux.0 

initrd.img     linux-install/ pexlinux.cfg/  pxelinux.0     vmlinuz        

[root@chenwei tftpboot]# mv pexlinux.cfg pxelinux.cfg

[root@chenwei tftpboot]# vi pxelinux.cfg/default 

default linux     

prompt 1          #prompt用来设置是否等待用户选择

timeout 6

display boot.msg

F1 boot.msg

F2 options.msg

F3 general.msg

F4 param.msg

F5 rescue.msg

label linux

  kernel vmlinuz

  append initrd=initrd.img

label text

  kernel vmlinuz

  append initrd=initrd.img text

label ks

  kernel vmlinuz

  append ks initrd=initrd.img

label local

  localboot 1

label memtest86

  kernel memtest

  append -


~

~

~

~

~

~

~

~

~

~

[root@chenwei tftpboot]# ls


[root@hb-node2 ~]# vi /etc/xinetd.d/tftp 

# default: off

# description: The tftp server serves files using the trivial file transfer \

#       protocol.  The tftp protocol is often used to boot diskless \

#       workstations, download configuration files to network-aware printers, \

#       and to start the installation process for some operating systems.

service tftp

{

        socket_type             = dgram

        protocol                = udp

        wait                    = yes

        user                    = root

        server                  = /usr/sbin/in.tftpd

        server_args             = -s /var/lib/tftpboot

        disable                 = yes

        per_source              = 11

        cps                     = 100 2

        flags                   = IPv4

}

~

~

~

~

~

~

[root@hb-node2 ~]# service xinetd restart

Stopping xinetd: [FAILED]

Starting xinetd: [  OK  ]

[root@hb-node2 ~]# 







2.2 yum install dhcp


2.3 配置dhcp

[root@chenwei tftpboot]# cp /usr/share/doc/dhcp-3.0.5/dhcpd.conf.sample /etc/dhcpd.conf 

cp: overwrite `/etc/dhcpd.conf'? y  

[root@chenwei tftpboot]# 


[root@chenwei tftpboot]# cat /etc/dhcpd.conf 

ddns-update-style interim;

ignore client-updates;



subnet 192.168.1.0 netmask 255.255.255.0 {


# --- default gateway

        option routers                  192.168.1.1;

        option subnet-mask              255.255.255.0;


#       option nis-domain               "domain.org";

#       option domain-name              "domain.org";

        option domain-name-servers      192.168.1.1;


        option time-offset              -18000; # Eastern Standard Time

#       option ntp-servers              192.168.1.1;

#       option netbios-name-servers     192.168.1.1;

# --- Selects point-to-point node (default is hybrid). Don't change this unless

# -- you understand Netbios very well

#       option netbios-node-type 2;


allow booting;

allow bootp;

next-server 192.168.1.99;   #指定tftp服务器

filename "/pxelinux.0";    #指定启动文件    


        range dynamic-bootp 192.168.1.80 192.168.1.90;  #分配IP地址

        default-lease-time 21600;

        max-lease-time 43200;


        # we want the nameserver to appear at a fixed address

        host ns {

                next-server marvin.redhat.com;

                hardware ethernet 12:34:56:78:AB:CD;

                fixed-address 207.175.42.254;

        }

}

[root@chenwei tftpboot]# 


[root@chenwei tftpboot]# service dhcpd restart

Starting dhcpd: [  OK  ]




三 编辑kickstart文件

[root@chenwei tftpboot]# yum install system-config-kickstart

[root@chenwei ~]# more /opt/yum/ks.cfg 

#platform=x86, AMD64, or Intel EM64T

# System authorization information

key --skip

auth  --useshadow  --enablemd5 

# System bootloader configuration

bootloader --location=mbr

# Partition clearing information

clearpart --none  

# Use graphical install

graphical

# Firewall configuration

firewall --disabled

# Run the Setup Agent on first boot

firstboot --disable

# System keyboard

keyboard us

# System language

lang en_US

# Installation logging level

logging --level=info

# Use network installation

url --url=ftp://192.168.1.99/pub

# Network information

network --bootproto=dhcp --device=eth0 --onboot=on

#Root password

rootpw --iscrypted $1$ykHcHjmI$2TnvnafG2p1LyRi3Lpod3/


# SELinux configuration

selinux --enforcing

# System timezone

timezone  America/New_York

# Install OS instead of upgrade

install

# X Window System configuration information

xconfig  --defaultdesktop=GNOME --depth=8 --resolution=640x480

# Disk partitioning information

clearpart --all --initlabel   #clear all data

part /boot --bytes-per-inode=4096 --fstype="ext3" --size=100

part swap --bytes-per-inode=4096 --fstype="swap" --size=2048

part / --bytes-per-inode=4096 --fstype="ext3" --grow --size=1


%packages

@admin-tools

@base

@core

@development-libs

@development-tools

@mysql

@network-server

@openfabrics-enterprise-distribution

@server-cfg

@x-software-development

@base-x

[root@chenwei ~]# 



四 yum服务器 ----参考其它配置

[root@chenwei ~]# cd /opt/yum/pub/

[root@chenwei pub]# ls

Cluster         README-or.html         RELEASE-NOTES-ml.html     RELEASE-NOTES-U7-ml.html

ClusterStorage  README-pa.html         RELEASE-NOTES-mr.html     RELEASE-NOTES-U7-mr.html

EULA            README-pt_BR.html      RELEASE-NOTES-or.html     RELEASE-NOTES-U7-or.html

eula.en_US      README-ru.html         RELEASE-NOTES-pa.html     RELEASE-NOTES-U7-pa.html

GPL             README-si.html         RELEASE-NOTES-pt_BR.html  RELEASE-NOTES-U7-pt_BR.html

images          README-ta.html         RELEASE-NOTES-ru.html     RELEASE-NOTES-U7-ru.html

isolinux        README-te.html         RELEASE-NOTES-si.html     RELEASE-NOTES-U7-si.html

README-as.html  README-zh_CN.html      RELEASE-NOTES-ta.html     RELEASE-NOTES-U7-ta.html

README-bn.html  README-zh_TW.html      RELEASE-NOTES-te.html     RELEASE-NOTES-U7-te.html

README-de.html  RELEASE-NOTES-as.html  RELEASE-NOTES-U7-as.html  RELEASE-NOTES-U7-zh_CN.html

README-en       RELEASE-NOTES-bn.html  RELEASE-NOTES-U7-bn.html  RELEASE-NOTES-U7-zh_TW.html

README-en.html  RELEASE-NOTES-de.html  RELEASE-NOTES-U7-de.html  RELEASE-NOTES-zh_CN.html

README-es.html  RELEASE-NOTES-en       RELEASE-NOTES-U7-en       RELEASE-NOTES-zh_TW.html

README-fr.html  RELEASE-NOTES-en.html  RELEASE-NOTES-U7-en.html  repodata

README-gu.html  RELEASE-NOTES-es.html  RELEASE-NOTES-U7-es.html  RPM-GPG-KEY-redhat-beta

README-hi.html  RELEASE-NOTES-fr.html  RELEASE-NOTES-U7-fr.html  RPM-GPG-KEY-redhat-release

README-it.html  RELEASE-NOTES-gu.html  RELEASE-NOTES-U7-gu.html  Server

README-ja.html  RELEASE-NOTES-hi.html  RELEASE-NOTES-U7-hi.html  TRANS.TBL

README-kn.html  RELEASE-NOTES-it.html  RELEASE-NOTES-U7-it.html  VT

README-ko.html  RELEASE-NOTES-ja.html  RELEASE-NOTES-U7-ja.html

README-ml.html  RELEASE-NOTES-kn.html  RELEASE-NOTES-U7-kn.html

README-mr.html  RELEASE-NOTES-ko.html  RELEASE-NOTES-U7-ko.html

[root@chenwei pub]# 



本文转自 woshiwei201 51CTO博客,原文链接:http://blog.51cto.com/chenwei/1841989
相关文章
|
3月前
|
安全 Linux 数据安全/隐私保护
Linux 学习笔记十八:SELinux 相关概念
Linux 学习笔记十八:SELinux 相关概念
|
9月前
|
Ubuntu Linux 开发工具
嵌入式Linux开发环境搭建之四----Vim的安装
嵌入式Linux开发环境搭建之四----Vim的安装
63 0
|
9月前
|
Linux 开发工具 C++
【Linux环境基础开发工具】编辑器-vim(一)
【Linux环境基础开发工具】编辑器-vim(一)
84 0
|
9月前
|
IDE Linux Shell
【Linux环境基础开发工具】编辑器-vim(二)
【Linux环境基础开发工具】编辑器-vim(二)
58 0
|
11月前
|
JavaScript 前端开发 调度
|
SQL 程序员 数据库
Phalcon在Windows上安装 《Phalcon入坑指南系列 二》(2)
Phalcon在Windows上安装 《Phalcon入坑指南系列 二》
96 0
Phalcon在Windows上安装 《Phalcon入坑指南系列 二》(2)
|
SQL PHP 开发工具
Phalcon在Windows上安装 《Phalcon入坑指南系列 一》
Phalcon在Windows上安装 《Phalcon入坑指南系列 一》
328 0
Phalcon在Windows上安装 《Phalcon入坑指南系列 一》
|
机器学习/深度学习 运维 Shell