背景:新机房有上百台服务器,需要安装操作系统,如果用光驱安装的话,效率低,严重影响工作进度,于是采取了网络安装的方案对服务器进行批量安装。
网络安装还是需要比较多的手动操作,对于小量,自定义安装的服务器可以采取该方法。
若大批量服务,直接采取无人值守安装,效率比较高。
主要用到了四种软件:
vstpd,kickstart,xinetd,dhcpd
这几个服务就不再介绍了,有兴趣的朋友去了解一下。
下面通过虚拟机测试的过程,介绍两种安装方式
yum install dhcp* tftp-server syslinux* *ftp* *kickstart* xinetd -y
#DHCP Server Configuration file.
#see /usr/share/doc/dhcp*/dhcpd.conf.sample
#see 'man 5 dhcpd.conf'
subnet 192.168.79.0 netmask 255.255.255.0 # //定义dhcp服务分配网段
{
range 192.168.79.10 192.168.79.20; # //定义ip地址池
option routers 192.168.79.2; # //默认网关
next-server 192.168.79.105; # //服务器ip地址
filename "pxelinux.0"; # //引导文件
}
[root@localhost tftpboot]# cd /var/ftp
[root@localhost ftp]# ll
total 4
drwxr-xr-x. 2 root root 4096 Mar 2 2012 pub
[root@localhost ftp]# mkdir rhel6
[root@localhost ftp]# ll
total 12
drwxr-xr-x. 2 root root 4096 Mar 2 2012 pub
drwxr-xr-x 2 root root 4096 Jul 11 19:48 rhel6
[root@localhost ftp]# cd rhel6/
[root@localhost rhel6]# ll
total 0
[root@localhost rhel6]# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/VolGroup-lv_root
47066056 10136852 34538372 23% /
tmpfs 953452 0 953452 0% /dev/shm
/dev/sda1 495844 37406 432838 8% /boot
[root@localhost rhel6]# cd
[root@localhost ~]# mount -o loop rhel-server-6.3-x86_64-dvd.iso /var/ftp/rhel6
[root@localhost ~]# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/VolGroup-lv_root
47066056 10136852 34538372 23% /
tmpfs 953452 0 953452 0% /dev/shm
/dev/sda1 495844 37406 432838 8% /boot
/root/rhel-server-6.3-x86_64-dvd.iso
3592530 3592530 0 100% /var/ftp/rhel6
[root@localhost tftpboot]# ll
total 33660
-r--r--r-- 1 root root 30442765 Jul 11 19:50 initrd.img
-rw-r--r-- 1 root root 26828 Jul 11 19:24 pxelinux.0
drwxr-xr-x 2 root root 4096 Jul 11 20:53 pxelinux.cfg
-r-xr-xr-x 1 root root 3986992 Jul 11 19:50 vmlinuz
[root@localhost tftpboot]# cp /usr/share/syslinux/pxelinux.0 .
[root@localhost tftpboot]# scp /var/ftp/rhel6/isolinux/initrd.img /var/ftp/rhel6/isolinux/vmlinuz .
[root@localhost tftpboot]# mkdir pxelinux.cfg
[root@localhost tftpboot]# vim pxelinux.cfg/default
default auto
prompt 1
#menu title Auto Install redhat
label auto
kernel vmlinuz
append initrd=initrd.img method=ftp://192.168.79.105/rhel6
label linux text
kernel vmlinuz
append text initrd=initrd.img method=ftp://192.168.79.105/rhel6
label linux rescue
kernel vmlinuz
append initrd=initrd.img method=ftp://192.168.79.105/rhel6
#menu end
#tree /var/lib/tftpboot/
[root@localhost tftpboot]# ll
total 33660
-r--r--r-- 1 root root 30442765 Jul 11 19:50 initrd.img
-rw-r--r-- 1 root root 26828 Jul 11 19:24 pxelinux.0
drwxr-xr-x 2 root root 4096 Jul 11 20:53 pxelinux.cfg
-r-xr-xr-x 1 root root 3986992 Jul 11 19:50 vmlinuz
[root@localhost tftpboot]# service restart dhcpd
[root@localhost tftpboot]# service restart vsftpd
[root@localhost tftpboot]# service restart xinetd
[root@localhost ~]#cd /var/ftp/
[root@localhost ~]#system-config-kickstart
[root@localhost ftp]# cd /var/lib/tftpboot/
[root@localhost tftpboot]# ll
total 33660
-r--r--r-- 1 root root 30442765 Jul 11 19:50 initrd.img
-rw-r--r-- 1 root root 26828 Jul 11 19:24 pxelinux.0
drwxr-xr-x 2 root root 4096 Jul 11 20:59 pxelinux.cfg
-r-xr-xr-x 1 root root 3986992 Jul 11 19:50 vmlinuz
[root@localhost tftpboot]# vim pxelinux.cfg/default
default auto
prompt 1
#menu title Auto Install redhat
label auto
kernel vmlinuz
append initrd=initrd.img method=ftp://192.168.79.105/rhel6 ks=ftp://192.168.79.105/ks.cfg
label linux text
kernel vmlinuz
append text initrd=initrd.img method=ftp://192.168.79.105/rhel6
label linux rescue
kernel vmlinuz
append initrd=initrd.img method=ftp://192.168.79.105/rhel6
#menu end
#tree /var/lib/tftpboot/
[root@localhost ftp]# cat ks.cfg
#platform=x86, AMD64, or Intel EM64T
#version=DEVEL
# Firewall configuration
firewall --disabled
# Install OS instead of upgrade
install
# Use CDROM installation media
cdrom
# Root password
rootpw --iscrypted $1$qjXP7yte$dmoJrA3EyHBroNWwvERjv.
# System authorization information
auth --useshadow --passalgo=sha512
# Use network installation
url --url="ftp://192.168.79.105/rhel6"
# Use graphical install
graphical
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
# System bootloader configuration
bootloader --location=mbr
# Partition clearing information
clearpart --all
# Disk partitioning information
part /boot --fstype="ext4" --size=1024
part / --fstype="ext4" --grow --size=1
part swap --fstype="swap" --size=32768
%packages
@additional-devel
@arabic-support
@armenian-support
@assamese-support
@backup-client
@backup-server
@base
@basic-desktop
@bengali-support
@bhutanese-support
@brazilian-support
@burmese-support
@chinese-support
@cifs-file-server
@client-mgmt-tools
@compat-libraries
@console-internet
@czech-support
@debugging
@desktop-debugging
@desktop-platform
@desktop-platform-devel
@development
@dial-up
@directory-client
@directory-server
@eclipse
@emacs
@ethiopic-support
@fonts
@french-support
@ftp-server
@general-desktop
@georgian-support
@german-support
@graphical-admin-tools
@graphics
@gujarati-support
@hardware-monitoring
@hebrew-support
@hindi-support
@identity-management-server
@infiniband
@input-methods
@internet-browser
@inuktitut-support
@italian-support
@japanese-support
@java-platform
@kannada-support
@kashmiri-support
@kde-desktop
@khmer-support
@konkani-support
@korean-support
@kurdish-support
@lao-support
@large-systems
@legacy-unix
@legacy-x
@mail-server
@mainframe-access
@maithili-support
@malayalam-support
@marathi-support
@nepali-support
@network-file-system-client
@network-server
@network-tools
@nfs-file-server
@oriya-support
@performance
@perl-runtime
@php
@print-client
@print-server
@punjabi-support
@remote-desktop-clients
@romanian-support
@ruby-runtime
@russian-support
@sanskrit-support
@scientific
@security-tools
@server-platform
@server-platform-devel
@sindhi-support
@sinhala-support
@smart-card
@spanish-support
@storage-client-fcoe
@storage-client-iscsi
@storage-client-multipath
@storage-server
@system-admin-tools
@system-management
@system-management-messaging-client
@system-management-messaging-server
@system-management-snmp
@system-management-wbem
@tajik-support
@tamil-support
@technical-writing
@telugu-support
@tex
@thai-support
@tibetan-support
@turbogears
@urdu-support
@venda-support
@web-server
@web-servlet
@x11
ElectricFence
ImageMagick
NetworkManager-openswan
OpenIPMI
PyPAM
PyQt4-devel
SDL-devel
abrt-gui
aide
alacarte
amtu
ant
arptables_jf
arpwatch
atlas
audispd-plugins
audit-viewer
authd
babel
bacula-client
bind
bind-chroot
bind-dyndb-ldap
bitmap-fixed-fonts
bitmap-lucida-typewriter-fonts
bltk
brltty
byzanz
bzr
cachefilesd
certmonger
certmonger
chrpath
cjkuni-fonts-ghostscript
cjkuni-fonts-ghostscript
cmake
compat-dapl
compat-gcc-34
compat-gcc-34-c++
compat-gcc-34-g77
compat-openmpi
compat-openmpi-psm
conman
cpufrequtils
crypto-utils
ctags-etags
cups-devel
cups-lpd
cyrus-imapd
dcraw
dejagnu
desktop-file-utils
device-mapper-persistent-data
dhcp
dnsmasq
docbook-utils-pdf
dos2unix
dovecot-mysql
dovecot-pgsql
dovecot-pigeonhole
dropwatch
dtach
dump
dumpet
dvgrab
e2fsprogs-devel
ebtables
eclipse-mylyn-cdt
eclipse-mylyn-pde
eclipse-mylyn-trac
eclipse-mylyn-webtasks
eclipse-mylyn-wikitext
eclipse-pde
eclipse-subclipse-graph
ecryptfs-utils
edac-utils
edac-utils
efax
emacs-auctex
emacs-gnuplot
emacs-nox
expat-devel
expect
expect
fence-agents
fetchmail
fftw
fftw-devel
fftw-static
finger
finger-server
firstaidkit-gui
flightrecorder
freeglut-devel
freeipmi
freeipmi-bmc-watchdog
freeipmi-ipmidetectd
freeradius
ftp
fuse-devel
gcc-gnat
gcc-java
gcc-objc
gcc-objc++
gconf-editor
gdb-gdbserver
gedit-plugins
genisoimage
glade3
glibc-utils
gmp-devel
gnome-common
gnome-devel-docs
gnome-games
gnome-pilot
gnome-pilot-conduits
gnutls-devel
gpm
gsl
gsl-devel
gsl-static
gstreamer-plugins-base-devel
gtk2-devel-docs
hardlink
hesinfo
hmaccalc
hplip
hplip-gui
httpd-devel
hunspell-devel
i2c-tools
icedtea-web
imake
infiniband-diags
inkscape
ipmitool
ipset
iptables-devel
iptraf
iptstate
irssi
isdn4k-utils
isns-utils
jpackage-utils
junit
jwhois
kabi-yum-plugins
kdebase-devel
kdebase-workspace-akonadi
kdebase-workspace-devel
kdebase-workspace-python-applet
kdegraphics-devel
kdelibs-apidocs
kdelibs-devel
kdemultimedia-devel
kdenetwork-devel
kdepim-devel
kdepimlibs-devel
kdesdk
kdesdk-devel
kdewebdev
kernel-doc
krb5-appl-clients
krb5-appl-servers
krb5-auth-dialog
krb5-pkinit-openssl
krb5-server
krb5-server-ldap
krb5-workstation
ksh
lapack
ldapjdk
lftp
libXau-devel
libXaw-devel
libXinerama-devel
libXmu
libXmu-devel
libXp
libXpm-devel
libXrandr-devel
libaio-devel
libblkid-devel
libbonobo-devel
libcap-devel
libdrm-devel
libgcrypt-devel
libglade2-devel
libgnomeui-devel
libgudev1-devel
libhugetlbfs-devel
libibcommon
libibverbs-devel
libmemcached
libnl-devel
libstdc++-docs
libtiff-devel
libtopology-devel
libudev-devel
libusb-devel
libuuid-devel
libxslt-devel
lksctp-tools
lm_sensors
logwatch
lslk
lsscsi
mailman
matahari
mc
memcached
memtest86+
mercurial
mgetty
migrationtools
mingw32-matahari
mipv6-daemon
mkbootdisk
mksh
mod_auth_kerb
mod_auth_mysql
mod_auth_pgsql
mod_authz_ldap
mod_dav_svn
mod_nss
mod_revocator
mpich2
mpitests-mvapich
mpitests-mvapich2
mpitests-openmpi
mrtg
mstflint
mt-st
mtools
mtx
mutt
mvapich
mvapich-psm-devel
mvapich-psm-static
mvapich2
mvapich2-psm-devel
nasm
ncompress
ncurses-term
net-snmp-devel
net-snmp-perl
net-snmp-python
netlabel_tools
netpbm-progs
nmap
nscd
nss-pam-ldapd
nss_db
numactl-devel
numpy
nuxwdog
oddjob
opencryptoki
openhpi
openhpi-subagent
openldap-clients
openldap-servers
openmotif
openmotif-devel
openmotif22
openmpi
openmpi-devel
openscap
openscap-utils
opensm
openwsman-server
oprofile-gui
oprofile-jit
pam_krb5
pam_ldap
papi
papi-devel
pax
pcre-devel
perftest
perl-CGI
perl-CGI-Session
perl-Cache-Memcached
perl-DBD-SQLite
perl-Date-Calc
perl-Date-Manip
perl-Frontier-RPC
perl-LDAP
perl-Mozilla-LDAP
perl-Test-Pod
perl-Test-Pod-Coverage
perl-suidperl
perltidy
pexpect
php-ldap
php-mysql
php-odbc
php-pecl-apc
php-pecl-memcache
php-pgsql
php-soap
php-xmlrpc
policycoreutils-gui
popt-devel
pptp
python-dmidecode
python-docs
python-memcached
python-saslwrapper
python-volume_key
qperf
qpid-tests
qt-doc
qt-mysql
qt-odbc
qt-postgresql
qt3-MySQL
qt3-ODBC
qt3-PostgreSQL
quagga
radvd
rdesktop
rdist
rhythmbox-upnp
rp-pppoe
rpmdevtools
rpmlint
rrdtool
rsh
rsh-server
rsyslog-gnutls
rsyslog-gnutls
rsyslog-gssapi
rsyslog-gssapi
rsyslog-mysql
rsyslog-pgsql
rsyslog-relp
rsyslog-relp
ruby-irb
ruby-irb
ruby-qpid-qmf
rusers
rusers-server
rwho
sabayon
sabayon-apply
samba
samba-winbind
sane-backends-devel
sblim-cim-client
sblim-cim-client2
sblim-cmpi-dhcp
sblim-cmpi-dns
sblim-cmpi-fsvol
sblim-cmpi-network
sblim-cmpi-nfsv3
sblim-cmpi-nfsv4
sblim-cmpi-params
sblim-cmpi-samba
sblim-cmpi-sysfs
sblim-cmpi-syslog
sblim-gather
sblim-gather-provider
sblim-indication_helper
sblim-smis-hba
sblim-tools-libra
screen
scrub
sdparm
seahorse-plugins
sendmail
sendmail-cf
setroubleshoot
sg3_utils
sgpio
slapi-nis
sox
spice-client
spice-xpi
squashfs-tools
squid
srptools
star
startup-notification-devel
stunnel
subscription-manager-migration
subscription-manager-migration-data
symlinks
syslinux
system-config-kickstart
system-config-lvm
systemtap-client
systemtap-grapher
systemtap-initscript
systemtap-sdt-devel
systemtap-server
talk
talk-server
tboot
tcl-devel
tcp_wrappers
tcp_wrappers-devel
tdb-tools
telnet
telnet-server
terminus-fonts
texinfo
tftp
tftp-server
tigervnc
tigervnc-server
tk-devel
tog-pegasus
totem-upnp
tpm-tools
tree
trousers
tsclient
tunctl
tuned
tuned-utils
udftools
unique-devel
unix2dos
unixODBC-devel
uuidd
vim-X11
vinagre
vlock
volume_key
watchdog
wireshark
wireshark-gnome
wodim
x3270-text
x86info
xdelta
xferstats
xfig
xguest
xmlto-tex
xmltoman
xorg-x11-fonts-75dpi
xorg-x11-fonts-ISO8859-1-75dpi
xorg-x11-fonts-ISO8859-14-100dpi
xorg-x11-fonts-ISO8859-14-75dpi
xorg-x11-fonts-ISO8859-15-75dpi
xorg-x11-fonts-ISO8859-2-100dpi
xorg-x11-fonts-ISO8859-2-75dpi
xorg-x11-fonts-ISO8859-9-100dpi
xorg-x11-fonts-ISO8859-9-75dpi
xorg-x11-fonts-cyrillic
xorg-x11-fonts-ethiopic
xorg-x11-proto-devel
xorg-x11-twm
xorg-x11-xdm
xrestop
xterm
xz-devel
ypserv
yum-plugin-aliases
yum-plugin-changelog
yum-plugin-downloadonly
yum-plugin-tmprepo
yum-plugin-verify
yum-plugin-versionlock
yum-presto
zsh
%end
[root@localhost ftp]#
选包的配置可以参照已安装好机器的系统文件
/root/anaconda-ks.cfg
[root@localhost tftpboot]# service restart dhcpd
[root@localhost tftpboot]# service restart vsftpd
[root@localhost tftpboot]# service restart xinetd
选网络启动,可以自动安装操作系统。