Linux无人值守自动安装详细配置流程

以下配置流程均在CentOS 6.7实现

实验环境:

PXE + httpd + dhcp + tftp-server + kickstart

实现环境:

PXE+httpd + dhcp + tftp-server + kickstart

简单介绍相关概念:

PXE:是一种安装方式,支持通过网络引导,访问服务器的文件来安装系统,需要网卡支持

http:文件服务器,存放系统ISO文件

dhcp:实现客户机地址分配

tftp:存放PXE相关的文件的服务器

kickstart:是安装程序anaconda的安装配置文件

注意:若没有PXE相关文件,如pxelinux.0,则需要安装syslinux

1.配置文件服务器,http文件服务器
     安装httpd并设置开机启动

[[email protected]_linux ~]# yum install httpd
======================================================================================
 软件包                            架构                       版本                                       仓库                         大小
=======================================================================================
正在安装:
 httpd                             x86_64                     2.2.15-47.el6.centos.4                     updates                     831 k
为依赖而安装:
 apr-util-ldap                     x86_64                     1.3.9-3.el6_0.1                            base                         15 k
 httpd-tools                       x86_64                     2.2.15-47.el6.centos.4                     updates                      77 k

#设置开机启动
[[email protected]_linux ~]# chkconfig httpd on

挂载光盘并复制光盘的所有内容至/var/www/html目录下

我这边挂载点是/madia/dvd1,挂载点可自行创建目录

#挂载光盘
[email protected]_linux ~]# mount /dev/cdrom /media/dvd1

#看一下挂在后光盘的内容
[[email protected]_linux ~]# ls /media/dvd1
CentOS_BuildTag  isolinux                RPM-GPG-KEY-CentOS-Debug-6
EFI               Packages            RPM-GPG-KEY-CentOS-Security-6
EULA             RELEASE-NOTES-en-US.html  RPM-GPG-KEY-CentOS-Testing-6
GPL               repodata            TRANS.TBL
images             RPM-GPG-KEY-CentOS-6

#cp光盘内容至/var/www/html目录
[[email protected]_linux ~]# cp -r /media/dvd1 /var/www/html

#我把文件夹改名为centos6.7方便辨认
[[email protected]_linux ~]# mv /var/www/html/dvd1 /var/www/html/centos6.7


2.配置tftp服务器:
安装tftp-server并设置开机启动

[[email protected]_linux ~]# yum install tftp-server
=====================================================================================
 Package              Arch            Version               
=====================================================================================
Installing:
 tftp-server          x86_64          0.49-7.el6                
Installing for dependencies:
 xinetd               x86_64          2:2.3.14-39.el6_4       

Transaction Summary
=====================================================================================

创建tftpboot文件夹

[[email protected]_linux ~]# mkdir /tftpboot

将以下这些文件复制到tftpboot目录下

boot.msg  initrd.img  pxelinux.0  vmlinuz isolinux.cfg

#复制boot.msg
[[email protected]_linux ~]# cp /var/www/html/centos6.7/isolinux/boot.msg /tftpboot

#复制initrd.img
[[email protected]_linux ~]# ls /var/www/html/centos6.7/images/pxeboot/initrd.img /tftpboot

#复制 vmlinuz
[[email protected]_linux ~]# cp /var/www/html/centos6.7/images/pxeboot/vmlinuz /tftpboot

#复制pxelinux.0
[[email protected]_linux ~]# cp /usr/share/syslinux/pxelinux.0 /tftpboot

#创建pxelinux.cfg目录
[[email protected]_linux ~]# mkdir /tftpboot/pxelinux.cfg

#复制isolinux.cfg文件到/tftpboot目录并改名为default
[[email protected]_linux ~]# cp /var/www/html/centos6.7/isolinux/isolinux.cfg /tftpboot/pxelinux.cfg/default

配置default文件

default linux    # 修改为下面的label名字
#prompt 1
timeout 1

display boot.msg

menu background splash.jpg
menu title Welcome to CentOS 6.7!
menu color border 0 #ffffffff #00000000
menu color sel 7 #ffffffff #ff000000
menu color title 0 #ffffffff #00000000
menu color tabmsg 0 #ffffffff #00000000
menu color unsel 0 #ffffffff #00000000
menu color hotsel 0 #ff000000 #ffffffff
menu color hotkey 7 #ffffffff #ff000000
menu color scrollbar 0 #ffffffff #00000000

label linux    # 此处label名对应上面的default
  menu label ^Install or upgrade an existing system
  menu default
  kernel vmlinuz
  append initrd=initrd.img ks=172.18.0.144      # 添加ks文件的地址

配置/etc/xinetd.d/tftp

修改以下两处即可

service tftp
    {
        socket_type     = dgram
        protocol        = udp
        wait            = yes
        user            = root
        server          = /usr/sbin/in.tftpd
        server_args     = -s /tftpboot  ------#修改为自己创建的目录路径
        disable         = no        ------#此处的yes改为no
        per_source      = 11
        cps             = 100 2
        flags           = IPv4
    }

最后重启tftp服务

[[email protected] ~]# service xinetd restart
Stopping xinetd:                                           [  OK  ]
Starting xinetd:                                           [  OK  ]

#设置开机启动
[[email protected] ~]# chkconfig xinetd on


3.配置dhcp服务器
安装dhcp并设置开机启动

[[email protected] ~]# yum inatall dhcp

=====================================================================================
 Package      Arch           Version                              Repository    Size
=====================================================================================
Installing:
 dhcp         x86_64         12:4.1.1-49.P1.el6.centos            base         822 k

Transaction Summary
====================================================================================

编辑/etc/dhcp/dhcpd.conf

  # dhcpd.conf

    ddns-update-style none;

    next-server 172.18.0.144;                 #tftp地址
    
    filename "pxelinux.0";              # PXE文件名

    subnet 172.18.0.0 netmask 255.255.0.0 {   # 设定子网

    range  172.18.0.0 172.18.200.200;         # 设定可分配的子网范围

    option routers 172.18.0.1;                # 配置路由网关

    }


4.配置kickstart文件
安装system-config-kickstart.noarch    

[[email protected]_linux ~]# yum install system-config-kickstart.noarch

在图形终端打开命令行窗口键入命令system-config-kickstart启动配置窗口

基本配置

引导选项配置

分区配置


网络配置


加密配置

防火墙配置

显示配置

安装包选择


安装脚本配置


 保存退出,文件名ks.cfg   

最后将生成的ks.cfg文件放在/var/www/html目录下即可

至此自动化安装环境配置完毕

使用虚拟器实验一定要将网络设置为桥接,否则服务无法连接dhcp服务器

关于ks文件的配置,想尝试去自己去编写,可以查考anaconda生成的anaconda-ks.cfg文件,就在root的家目录下

贴上我的ks文件:(以下ks文件以马哥的为范本做了简要的修改)

#platform=x86, AMD64, or Intel EM64T
#version=DEVEL
# Firewall configuration
firewall –disabled
# Install OS instead of upgrade
install
# Use network installation
url –url=”http://172.18.17.2/centos6.7″
# Root password
rootpw –iscrypted $1$Ga8vc8m.$fmBL3Rail7oAeErVtJM/9/
# System authorization information
auth  –useshadow  –passalgo=sha512
# Use text mode install
text
firstboot –disable
# System keyboard
keyboard us
# System language
lang en_US
# SELinux configuration
selinux –disabled
# Installation logging level
logging –level=info
# Reboot after installation
reboot
# System timezone
timezone  Asia/Shanghai
# Network information
network  –bootproto=dhcp –device=eth0 –onboot=on
# System bootloader configuration
bootloader –append=”quiet” –location=mbr
# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart –all
# Disk partitioning information
part /boot –fstype=”ext4″ –size=200
part pv.008 –size=61440

volgroup vg0 –pesize=8192 pv.008
logvol / –fstype=ext4 –name=root –vgname=vg0 –size=20480
logvol swap –name=swap –vgname=vg0 –size=2048
logvol /usr –fstype=ext4 –name=usr –vgname=vg0 –size=10240
logvol /var –fstype=ext4 –name=var –vgname=vg0 –size=20480

%post
# set hostname
sed -i ‘[email protected]=.*@[email protected]’ /etc/sysconfig/network

# set hosts
echo “172.18.17.2 johnson_server” >> /etc/hosts

%end

%packages
@base

%end

    总结:ks文件配置比较重要,也是比较有技术含量的一环,网络环境配置可以按部就班,但是ks文件却需要自己去定制,能读懂ks文件是关键,用system-config-kickstart来生成的ks文件也有不足之处,比如分区,就不能使用LVM,需要用到逻辑卷需要自己手动去编写ks文件

时间: 2024-08-26 03:59:23

Linux无人值守自动安装详细配置流程的相关文章

Linux redis的安装与配置

Redis是一个开源的使用ANSI C语言编写.支持网络.可基于内存亦可持久化的日志型.Key-Value数据库,并提供多种语言的API.从2010年3月15日起,Redis的开发工作由VMware主持. 1.环境 # lsb_release LSB Version:    :core-4.0-ia32:core-4.0-noarch:graphics-4.0-ia32:graphics-4.0-noarch:printing-4.0-ia32:printing-4.0-noarchDistri

无人值守自动安装CentOS6.4

在大规模的linux应用环境中,如web集群.分布式计算等,服务器往往并不具备光驱设备,这种情况下为数十乃至上百台服务器裸机快速安装系统,传统的U盘.移动光驱等安装方法显然力所难及,下面我们将部署基于PXE技术网络装机并结合Kickstart配置实现无人值守自动安装系统. PXE技术 PXE是由Inter公司开发的基于Client/Server模式的网络引导技术,其核心功能是让客户端通过网络从远端服务器下载引导镜像,从而实现网络启动.整个过程中,客户端要求服务器分配IP地址,再用TFTP协议下载

Kickstart+PXE实现无人值守自动安装

配置前提 kickstart 在启动引导内核的时候只有传递给其vmlinuz即可,前提是必须让其内核访问的到我们的ks的位置,比如http . ftp.nfs 等,也可以放在本地的路径下可以通过cdrom进行对外告知 如果要通过网络服务器访问,有个前提就是必须将其配置好网络地址才可以:但还需要考虑一个问题,当anaconda启动的时候 它还会读取kickstart配置文件的 但kickstart中也可以配置网络参数的,如果kickstart分配的地址与vmlinuz所获取的不一样的话,则以后续的

Linux CentOS下安装、配置mysql数据库

如果要在Linux上做j2ee开发,首先得搭建好j2ee的开发环境,包括了jdk.tomcat.eclipse的安装(这个在之前的一篇随笔中已经有详细讲解了Linux学习之CentOS(七)--CentOS下j2ee环境搭建),如果要开发web项目,我们当然可以安装一个myeclipse到Linux系统上去,这个安装方法和安装eclipse完全相同,就没有记录下来了,有了jdk.tomcat.eclipse我们就已经能进行我们的程序开发了,但是如果要做一个项目,哪怕是小的不能再小的项目都离不开数

搭建PXE服务器,实现无人值守自动安装系统

实验:搭建PXE服务器,实现无人值守自动安装系统 在PXE服务器和新安装的服务器上分别安装http实现均衡负载 建立主从DNS服务器 第一步,先配置DHCP,目的是给需要安装系统的主机分配ip地址 服务器IP地址设为192.168.100.11 [[email protected] ~]# ifconfig eth0 | grep "inet addr" inet addr:192.168.100.11  Bcast:192.168.100.255  Mask:255.255.255.

cobbler实现无人值守自动安装

Cobbler简介 使用cobbler,第一件事就是定义其distros 指的是定义一个特殊发行版的内核和init文件,这意味着我们要使用独立运行系统之外的独立引导内核来实现,也就是说要启动这个操作系统,首先加载的是init和内核文件,在我们真正启动系统之后initrd和内核则只要不重启则不会被使用,所以distros 主要是用来借助于外在的内核和initrd进行启动系统,而后通过其装置根进行部署 定义distros的方式有两种 ·自己准备外部的内核和initrd 用来引导一些特殊的映像文件 ·

在RedHat Linux系统中安装和配置snmp服务

检查系统是否安装snmp服务 # rpm -qa|grep snmp net-snmp-5.3.2.2-17.el5 net-snmp-perl-5.3.2.2-17.el5 net-snmp-devel-5.3.2.2-17.el5 net-snmp-libs-5.3.2.2-17.el5 net-snmp-utils-5.3.2.2-17.el5 net-snmp-libs-5.3.2.2-17.el5 net-snmp-devel-5.3.2.2-17.el5 SNMP服务安装后会有以上安

Tomcat在Linux上的安装与配置

Tomcat在Linux上的安装与配置 1.  jdk下载地址: http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html tomcat下载地址:http://tomcat.apache.org/download-70.cg 2.jdk安装与配置.(rpm包)    (1)jdk安装    rpm包:    # rpm -ivh jdk-7u79-linux-x64.rpm tar.gz

java环境--JDK和Tomcat在linux上的安装和配置

Tomcat在Linux上的安装与配置 以下使用的Linux版本为: Redhat Enterprise Linux 7.0 x86_64,Tomcat版本为tomcat-7.0.54.1.下载JDK与Tomcat.    jdk下载地址:    http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html    tomcat下载地址:    http://tomcat.apache.org