感谢支持
我们一直在努力

RHEL6无人值守安装(NFS安装)

在网络上有很多关于无人值守安装方法,但是大部分都是用 FTP,用HTTP 和 FTP 基本上差不多,所以今天我们没事干就用 NFS 也安装了一个,发现 NFS 和那两个有些区别,所以就和大家一起来分享一下我的实验成果 ,希望能给大家带来一些帮助。


方法:NFS+TFTP+DHCP+Kickstart+PXE
准备两台虚拟机,一台作为测试环境(RHEL6,IP 为 192.168.0.254),另一台作为RHEL6被安装端,设置网络引导安装。
安装所需要的服务及修改相应配置文件 :


1.用 yum 来安装所需要的软件包,先来搭建 yum 光盘源:
[root@www.linuxidc.com ~]# mount /dev/cdrom /mnt
在/etc/yum.repos.d 目录下创建一个以.repo 结尾的文件:
[root@www.linuxidc.com ~]# vi /etc/yum.repos.d/server.repo
配置内容如下:
[server]
name=this is my yum server
baseurl=file:///mnt /Server
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-RedHat-release
然后执行 rpm –import /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
gpgkey
2.安装 TFTP,修改 tftp 配置文件及开启服务
[root@www.linuxidc.com ~]# yum install tftp-server
Loaded plugins: refresh-packagekit, rhnplugin
This system is not registered with RHN.
RHN support will be disabled.
aaa
| 3.7 kB 00:00 …
Setting up Install Process
Resolving Dependencies
–> Running transaction check
—> Package tftp-server.x86_64 0:0.49-5.1.el6 set to be updated
–> Finished Dependency Resolution
Dependencies Resolved
==============================================================
===========================================
Package
Arch
Version
Repository
Size
==============================================================
===========================================
Installing:
tftp-server
x86_64
0.49-5.1.el6
aaa
39 k
Transaction Summary
==============================================================
===========================================
Install
1 Package(s)
Upgrade
0 Package(s)
Total download size: 39 k
Installed size: 57 k
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : tftp-server-0.49-5.1.el6.x86_64
1/1
Installed:
tftp-server.x86_64 0:0.49-5.1.el6
Complete!
[root@www.linuxidc.com ~]#
[root@www.linuxidc.com ~]# vim /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   = no
per_source  = 11
cps    = 100 2
flags   = IPv4
}
[root@www.linuxidc.com ~]# /etc/init.d/xinetd restart
Stopping xinetd:
[ OK ]
Starting xinetd:
[ OK ]
[root@www.linuxidc.com ~]#
~
3.在/下面创建一个 NFS 目录,并且共享出去如下:
[root@www.linuxidc.com ~]# mkdir /NFS
[root@www.linuxidc.com ~]# vim /etc/exports
/NFS
192.168.0.0/24(rw,sync)
[root@www.linuxidc.com ~]# /etc/init.d/nfs restart
Shutting down NFS mountd:
Shutting down NFS daemon:
Shutting down NFS quotas:
Starting NFS services:
Starting NFS quotas:
Starting NFS daemon:
Starting NFS mountd:
[FAILED]
[FAILED]
[FAILED]
[ OK ]
[ OK ]
[ OK ]
[ OK ]
4.安装 dhcp,修改配置文件及开启服务:
[root@www.linuxidc.com ~]# yum install dhcp -y
Loaded plugins: refresh-packagekit, rhnplugin
This system is not registered with RHN.
RHN support will be disabled.
Setting up Install Process
Resolving Dependencies
–> Running transaction check
—> Package dhcp.x86_64 12:4.1.1-12.P1.el6 set to be updated
–> Finished Dependency Resolution
Dependencies Resolved
==============================================================
===========================================
Package
Arch
Version
Repository
Size
==============================================================
===========================================
Installing:
dhcp
x86_64
12:4.1.1-12.P1.el6
aaa
820 k
Transaction Summary
==============================================================
===========================================
Install
1 Package(s)
Upgrade
0 Package(s)
Total download size: 820 k
Installed size: 2.0 M
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : 12:dhcp-4.1.1-12.P1.el6.x86_64
1/1
Installed:
dhcp.x86_64 12:4.1.1-12.P1.el6
Complete!
[root@www.linuxidc.com ~]#
[root@www.linuxidc.com ~]# cp /usr/share/doc/dhcp-4.1.1/dhcpd.conf.sample
/etc/dhcp/dhcpd.conf
[root@www.linuxidc.com ~]# vim /etc/dhcp/dhcpd.conf(RHEL6 原文件内容如下所示,一
开始看上去可能觉得很乱)

# dhcpd.conf
#
# Sample configuration file for ISC dhcpd
#
# option definitions common to all supported networks…
option domain-name “example.org”;
option domain-name-servers ns1.example.org, ns2.example.org;
default-lease-time 600;
max-lease-time 7200;
# Use this to enble / disable dynamic dns updates globally.
#ddns-update-style none;
# If this DHCP server is the official DHCP server for the local
# network, the authoritative directive should be uncommented.
#authoritative;
# Use this to send dhcp log messages to a different log file (you also
# have to hack syslog.conf to complete the redirection).
log-facility local7;
# No service will be given on this subnet, but declaring it helps the
# DHCP server to understand the network topology.
subnet 10.152.187.0 netmask 255.255.255.0 {
}
# This is a very basic subnet declaration.
subnet 10.254.239.0 netmask 255.255.255.224 {
range 10.254.239.10 10.254.239.20;
option routers rtr-239-0-1.example.org, rtr-239-0-2.example.org;
}
# This declaration allows BOOTP clients to get dynamic addresses,
# which we don’t really recommend.
subnet 10.254.239.32 netmask 255.255.255.224 {
range dynamic-bootp 10.254.239.40 10.254.239.60;
option broadcast-address 10.254.239.31;
option routers rtr-239-32-1.example.org;
}
# A slightly different configuration for an internal subnet.
subnet 10.5.5.0 netmask 255.255.255.224 {
range 10.5.5.26 10.5.5.30;
option domain-name-servers ns1.internal.example.org;
option domain-name “internal.example.org”;
option routers 10.5.5.1;
option broadcast-address 10.5.5.31;
default-lease-time 600;
max-lease-time 7200;
}
# Hosts which require special configuration options can be listed in
# host statements. If no address is specified, the address will be
# allocated dynamically (if possible), but the host-specific information
# will still come from the host declaration.
host passacaglia {
hardware ethernet 0:0:c0:5d:bd:95;
filename “vmunix.passacaglia”;
server-name “toccata.fugue.com”;
}
# Fixed IP addresses can also be specified for hosts. These addresses
# should not also be listed as being available for dynamic assignment.
# Hosts for which fixed IP addresses have been specified can boot using
# BOOTP or DHCP. Hosts for which no fixed address is specified can only
# be booted with DHCP, unless there is an address range on the subnet
# to which a BOOTP client is connected which has the dynamic-bootp flag
# set.
host fantasia {
hardware ethernet 08:00:07:26:c0:a5;
fixed-address fantasia.fugue.com;
}
# You can declare a class of clients and then do address allocation
# based on that. The example below shows a case where all clients
# in a certain class get addresses on the 10.17.224/24 subnet, and all
# other clients get addresses on the 10.0.29/24 subnet.
class “foo” {
match if substring (option vendor-class-identifier, 0, 4) = “SUNW”;
}
shared-network 224-29 {
subnet 10.17.224.0 netmask 255.255.255.0 {
option routers rtr-224.example.org;
}
subnet 10.0.29.0 netmask 255.255.255.0 {
option routers rtr-29.example.org;
}
pool {
allow members of “foo”;
range 10.17.224.10 10.17.224.250;
}
pool {
deny members of “foo”;
range 10.0.29.10 10.0.29.230;
}
}
所以我把 RHEL5 里的 dhcp 原文件复制过来如下:
ddns-update-style interim;
ignore client-updates;
filename “pxelinux.0”;
next-server 192.168.0.254; (这两行是新加的内容)

subnet 192.168.0.0 netmask 255.255.255.0 {
# — default gateway
option routers
option subnet-mask
192.168.0.254;
255.255.255.0;
option nis-domain
“domain.org”;
option domain-name
“domain.org”;
option domain-name-servers
192.168.0.254;
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;
range dynamic-bootp 192.168.0.100 192.168.0.200;
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@www.linuxidc.com ~]# /etc/init.d/dhcpd configtest
Syntax: OK
[root@www.linuxidc.com ~]# /etc/init.d/dhcpd restart
Starting dhcpd:
[ OK ]
[root@www.linuxidc.com ~]#

5.准备工作完成,我们开始配置 Kickstart
[root@www.linuxidc.com ~]# cp /mnt/images/pxeboot/initrd.img /var/lib/tftpboot/
[root@www.linuxidc.com ~]# cp /mnt/images/pxeboot/vmlinuz /var/lib/tftpboot/
[root@www.linuxidc.com ~]# cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/(默认syslinux 没有安装)
[root@www.linuxidc.com ~]# yum install syslinux -y
Loaded plugins: refresh-packagekit, rhnplugin
This system is not registered with RHN.
RHN support will be disabled.
Setting up Install Process
Resolving Dependencies
–> Running transaction check
—> Package syslinux.x86_64 0:3.86-1.1.el6 set to be updated
–> Processing Dependency: perl(Digest::SHA1) for package: syslinux-3.86-
1.1.el6.x86_64
–> Processing Dependency: perl(Crypt::PasswdMD5) for package: syslinux-3.86-
1.1.el6.x86_64
–> Running transaction check
—> Package perl-Crypt-PasswdMD5.noarch 0:1.3-6.el6 set to be updated
—> Package perl-Digest-SHA1.x86_64 0:2.12-2.el6 set to be updated
–> Finished Dependency Resolution
Dependencies Resolved
==============================================================
===========================================
Package
Arch
Version
Repository
Size
==============================================================
===========================================
Installing:
syslinux
x86_64
3.86-1.1.el6
aaa
928 k
Installing for dependencies:
perl-Crypt-PasswdMD5
noarch
perl-Digest-SHA1
x86_64
1.3-6.el6
2.12-2.el6
aaa
aaa
11 k
49 k
Transaction Summary
==============================================================
===========================================
Install
3 Package(s)
Upgrade
0 Package(s)
Total download size: 988 k
Installed size: 2.7 M
Downloading Packages:
———————————————————————————————————
Total
5.5 MB/s | 988 kB 00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : perl-Digest-SHA1-2.12-2.el6.x86_64
1/3
Installing : perl-Crypt-PasswdMD5-1.3-6.el6.noarch
2/3
Installing : syslinux-3.86-1.1.el6.x86_64
3/3
Installed:
syslinux.x86_64 0:3.86-1.1.el6
Dependency Installed:
perl-Crypt-PasswdMD5.noarch 0:1.3-6.el6
0:2.12-2.el6
perl-Digest-SHA1.x86_64
Complete!
[root@www.linuxidc.com ~]#
[root@www.linuxidc.com ~]# mkdir /var/lib/tftpboot/pxelinux.cfg
[root@www.linuxidc.com ~]# cp /mnt/isolinux/isolinux.cfg
/var/lib/tftpboot/pxelinux.cfg/default
[root@www.linuxidc.com ~]# vim /var/lib/tftpboot/pxelinux.cfg/default
文件里面需要修改两行,修改第 1 行,后面的 linux 意思是寻找下面 18 行的
label linux,然 后修改下 22 行。
default linux (原来为 vesamenu.c32 )

#prompt 1
timeout 600
display boot.msg
menu background splash.jpg
menu title Welcome to Red Hat Enterprise Linux 6.0!
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
menu label ^Install or upgrade an existing system
menu default
kernel vmlinuz
append initrd=initrd.img ks=nfs:192.168.0.254:/NFS/ks.cfg (添加的内容)
label vesa
menu label Install system with ^basic video driver
kernel vmlinuz
append initrd=initrd.img xdriver=vesa nomodeset
label rescue
menu label ^Rescue installed system
kernel vmlinuz
append initrd=initrd.img rescue
label local
menu label Boot from ^local drive
localboot 0xffff
label memtest86
menu label ^Memory test
kernel memtest
append –
配置文件修改完了,接下来我们制作无人值守安装文件。
在图形化界面运行 system-config-kickstart 弹出来界面。

[root@www.linuxidc.com ~]# yum install system-config-kickstart -y
[root@www.linuxidc.com ~]# system-config-kickstart

650) this.width=650;” border=0>



我们设置下默认安装的语言,时区,根口令,然后勾选下面的安装后重新引导。然后
选择安 装方法。


650) this.width=650;” border=0>

我们配置 NFS 服务器的安装方法。选择执行新安装。然后点击引导装载程
序选项

 

650) this.width=650;” border=0>


 


 


650) this.width=650;” border=0>


到这一步,选择部分参考我的。布局这里,我们自己设置下/分区大小。


650) this.width=650;” border=0>



我们自己设置下/boot 分区大小


650) this.width=650;” border=0>



我们自己设置下 swap 分区大小

650) this.width=650;” border=0>



网络这里,默认没有,点击添加网络,设备名称为 eth0,网络类型为 dhcp


650) this.width=650;” border=0>


650) this.width=650;” border=0>



防火墙和 selinux 根据自己需求选择开启或者禁用


650) this.width=650;” border=0>


在这里勾选一些包,默认可能没有勾选桌面。根据自己需求勾选。后面剩余的两项不需要配置。

650) this.width=650;” border=0>



然后点击左上角的文件选择保存 ,选择下保存的路径,然后
复制 ks.cfg 文件到/NFS 目录下:

[root@www.linuxidc.com ~]# cd /mnt/
[root@www.linuxidc.com mnt]# cp -a * /NFS/
[root@www.linuxidc.com ~]# /etc/init.d/dhcpd restart
Shutting down dhcpd:
[ OK ]
Starting dhcpd:
[ OK ]
[root@www.linuxidc.com ~]# /etc/init.d/xinetd restart
Stopping xinetd:
[ OK ]
Starting xinetd:
[ OK ]
[root@www.linuxidc.com ~]# /etc/init.d/nfs restart
Shutting down NFS mountd:
[FAILED]
Shutting down NFS daemon:
[FAILED]
Shutting down NFS quotas:
[FAILED]
Starting NFS services:
[ OK ]
Starting NFS quotas:
[ OK ]
Starting NFS daemon:
[ OK ]
Starting NFS mountd:
[ OK ]
[root@www.linuxidc.com ~]# iptables -F
[root@www.linuxidc.com ~]# setenforce 0
[root@www.linuxidc.com ~]# chkconfig dhcpd on
[root@www.linuxidc.com ~]# chkconfig xinetd on
建议关闭防火墙和 selinux,如果没有关闭的话,tftp 服务会有问题。
接下来启动你要安装的机器了

赞(0) 打赏
转载请注明出处:服务器评测 » RHEL6无人值守安装(NFS安装)
分享到: 更多 (0)

听说打赏我的人,都进福布斯排行榜啦!

支付宝扫一扫打赏

微信扫一扫打赏