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

RHEL7配置kickstart

时间:2018-08-07 16:11:36      阅读:171      评论:0      收藏:0      [点我收藏+]

标签:setup   hpc   crash   graph   ignore   ram   ack   dde   input   

1 安装并配置dhcpd服务

yum install dhcp


[root@localhost pub]# vim /etc/dhcp/dhcpd.conf

subnet 172.16.1.0 netmask 255.255.255.0 {

  range 172.16.1.2 172.16.1.253;

  option routers 172.16.1.254;

  option subnet-mask 255.255.255.0;

  option broadcast-address 172.16.1.255;

  default-lease-time 600;

  next-server 172.16.1.1;

  max-lease-time 7200;

  filename "/pxelinux.0";

}


systemctl start dhcpd

systemctl enable dhcpd


2 安装并配置vsftpd服务

本次pxe安装源使用的是vsftp作为安装树

yum install vsftpd


systemctl start vsftpd

systemctl enable vsftpd


这里vsftpd使用的都是默认配置


3 之后把整个iso都拷贝到ftp的目录

[root@localhost pub]# lsblk

NAME            MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT

sda               8:0    0   20G  0 disk

├─sda1            8:1    0  200M  0 part /boot

└─sda2            8:2    0 19.8G  0 part

  ├─server-root 253:0    0 18.8G  0 lvm  /

  └─server-swap 253:1    0    1G  0 lvm  [SWAP]

sr0              11:0    1  3.8G  0 rom  /run/media/root/RHEL-7.2 Server.x86_64


或者使用findmnt来找到光盘挂在在了哪里,或者使用df -h也可以看到


cp -axv /run/media/root/RHEL-7.2 Server.x86_64 /var/ftp/pub


4 安装并配置tftp服务

yum install tftp-server 


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

service tftp

{

        socket_type             = dgram

        protocol                = udp

        wait                    = yes

        user                    = root

        server                  = /usr/sbin/in.tftpd

        server_args             = -s /var/lib/tftpboot

        disable                 = no

        per_source              = 11

        cps                     = 100 2

        flags                   = IPv4

}


systemctl start tftp

systemctl enable tftp


5 将必要文件及配置放到/var/lib/tftpboot

cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/

cp -axv /var/ftp/pub/isolinux/* /var/lib/tftpboot/


mkdir /var/lib/tftpboot/pxelinux.cfg


cp /var/ftp/pub/isolinux/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default


查看default文件的配置==将default文件设置为下边这样

[root@localhost pxelinux.cfg]# vim /var/lib/tftpboot/pxelinux.cfg/default

default linux

timeout 500

display boot.msg

# Clear the screen when exiting the menu, instead of leaving the menu displayed.

# For vesamenu, this means the graphical background is still displayed without

# the menu itself for as long as the screen remains in graphics mode.

menu clear

menu background splash.png

menu title Red Hat Enterprise Linux 7.2

menu vshift 8

menu rows 18

menu margin 8

#menu hidden

menu helpmsgrow 15

menu tabmsgrow 13

# Border Area

menu color border * #00000000 #00000000 none

# Selected item

menu color sel 0 #ffffffff #00000000 none

# Title bar

menu color title 0 #ff7ba3d0 #00000000 none

# Press [Tab] message

menu color tabmsg 0 #ff3a6496 #00000000 none

# Unselected menu item

menu color unsel 0 #84b8ffff #00000000 none

# Selected hotkey

menu color hotsel 0 #84b8ffff #00000000 none

# Unselected hotkey

menu color hotkey 0 #ffffffff #00000000 none

# Help text

menu color help 0 #ffffffff #00000000 none

# A scrollbar of some type? Not sure.

menu color scrollbar 0 #ffffffff #ff355594 none

# Timeout msg

menu color timeout 0 #ffffffff #00000000 none

menu color timeout_msg 0 #ffffffff #00000000 none

# Command prompt text

menu color cmdmark 0 #84b8ffff #00000000 none

menu color cmdline 0 #ffffffff #00000000 none

# Do not display the actual menu unless the user presses a key. All that is displayed is a timeout message.

menu tabmsg Press Tab for full configuration options on menu items.

menu separator # insert an empty line

menu separator # insert an empty line

label linux

  menu label ^Install Red Hat Enterprise Linux 7.2

  kernel vmlinuz

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

  append initrd=initrd.img inst.repo=ftp://172.16.1.1/pub inst.ks=ftp://172.16.1.1/pub/ks.cfg ==这里指定安装源为172.16.1.1/pub,ks文件位于172.16.1.1/pub/ks.cfg这里

label check

  menu label Test this ^media & install Red Hat Enterprise Linux 7.2

  menu default

  kernel vmlinuz

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

menu separator # insert an empty line

# utilities submenu

menu begin ^Troubleshooting

  menu title Troubleshooting

label vesa

  menu indent count 5

  menu label Install Red Hat Enterprise Linux 7.2 in ^basic graphics mode

  text help

    Try this option out if you're having trouble installing

    Red Hat Enterprise Linux 7.2.

  endtext

  kernel vmlinuz

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

label rescue

  menu indent count 5

  menu label ^Rescue a Red Hat Enterprise Linux system

  text help

    If the system will not boot, this lets you access files

    and edit config files to try to get it booting again.

  endtext

  kernel vmlinuz

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

label memtest

  menu label Run a ^memory test

  text help

    If your system is having issues, a problem with your

    system's memory may be the cause. Use this utility to

    see if the memory is working correctly.

  endtext

  kernel memtest

menu separator # insert an empty line

label local

  menu label Boot from ^local drive

  localboot 0xffff

menu separator # insert an empty line

menu separator # insert an empty line

label returntomain

  menu label Return to ^main menu

  menu exit

menu end

[root@localhost pxelinux.cfg]#


6 ks.cfg文件的配置

[root@localhost pub]# vim /var/ftp/pub/ks.cfg

#version=DEVEL

# System authorization information

install

#nfs --server=10.0.97.20 --dir=/var/ftp/pub

url --url=ftp://172.16.1.1/pub

reboot ==注意这个reboot位置不能写在下边,否则会在安装到分区的时候自动重启

autostep --autoscreenshot ===添加这行以后,在客户端安装完毕OS后,会在家目录中有所有步骤的截图

eula --agreed

auth --enableshadow --passalgo=sha512

#repo --name="Server-HighAvailability" --baseurl=file:///run/install/repo/addons/HighAvailability

#repo --name="Server-ResilientStorage" --baseurl=file:///run/install/repo/addons/ResilientStorage

repo --name=ChinaUnicom-Packages --baseurl=ftp://172.16.1.1/pub/

# Use CDROM installation media

#cdrom

# Use graphical install

graphical

# Run the Setup Agent on first boot

firstboot --disable ==默认这里是firstboot --enable,如果为enable的话,在你安装完成后会要求你同意license,或者输入c,表示continue

#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=yes --ipv6=auto

#network  --hostname=server1

firewall --disabled

selinux --disabled

#reboot

# Root password

rootpw --iscrypted $6$3RrnaeWFTcpVgyhb$m02byJ/yLrDvGJdcgGGLf4ybYeyPiTKH3fnS6limNYn***RYK1/MWpY4Ulc7a1hGpUQz1rX5Z9gv5/iHPCMyV0

# System services

services --disabled="chronyd"

# System timezone

timezone Asia/Shanghai --isUtc --nontp

user --name=shichunda --password=$6$Ola.H6Ll3V7UeGSM$ybgxTg9VtrPEsFazm2kb1NzZsSSyl40MIflyfM8CTPUCnAlyGbbQTr3/y1aNIFY4grdKTF1UrGiRgLR5c0afG/ --iscrypted --gecos="shichunda"

# X Window System configuration information

xconfig  --startxonboot

# System bootloader configuration

bootloader --append=" crashkernel=auto" --location=mbr --boot-drive=sda


# Partition clearing information

clearpart --all --initlabel

# Disk partitioning information

part /boot --fstype="xfs" --ondisk=sda --size=300

part pv.12 --grow --fstype="lvmpv" --ondisk=sda --size=300

volgroup server --pesize=32768 pv.12

logvol /  --fstype="xfs" --size=10240 --name=root --vgname=server

logvol swap  --fstype="swap" --size=1024 --name=swap --vgname=server


%packages

@^graphical-server-environment

@base

@core

@fonts

@gnome-desktop

@guest-agents

@guest-desktop-agents

@input-methods

@internet-browser

@print-client

@x11

kexec-tools

%end

%addon com_redhat_kdump --enable --reserve-mb='auto'

%end


%post --log=/root/ks-post.log

# Configure YUM repository

KSIP=172.16.1.1

PUB=ftp://$KSIP/pub

BASE=$PUB

K×××C=http://$KSIP/

RELEASE=rhel6

# Configure the utility/ks machine repo for ChinaUnicom:

# Leave gpgcheck=0 for ChinaUnicom-updates since it may contain unreleased, but required errata.

rpm --import file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-beta

rpm --import file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

cat >> /etc/yum.repos.d/ChinaUnicom.repo << ABC

[ChinaUnicom-Packages]

name=ChinaUnicom-Packages

baseurl=$BASE/

enabled=1

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-beta,file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

ABC

%end


注意:

    1 在pxe安装客户端系统之前,最好先使用光盘或usb来安装一套rhel7,之后使用该物理机作为pxe安装源,这样有2个好处:1 能得到一个针对这批服务器端ks文件;2 能得到这批服务器的网卡名,这样你在这个ks中就可以在network部分写上这个网卡名了。默认情况下rhel7针对不同的服务器,网卡叫不同的名字


7 客户端安装系统

在客户端加电,使用网络引导,客户端会自动安装OS


RHEL7配置kickstart

标签:setup   hpc   crash   graph   ignore   ram   ack   dde   input   

原文地址:http://blog.51cto.com/hashing123/2155743

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