大规模部署安装Centos 6时,所用的网络架构图
由上图知,得先在服务器上安装好DHCP服务和tftp服务和NFS服务,在安装Centos 6是我们把这些服务都分开来,安装Centos 7是把这些服务都做到一个主机上来安装。
DHCP服务给网络安装的主机提供ip地址,主机获得ip地址后,需要下载系统安装需要的文件(内核,根文件系统镜像,bootloader等)到tftp服务器上下载,安装需要的应用程序在http服务器上,ks文件也在http服务器上,让系统安装通过读取ks文件自动完成安装。
对于安装过程中有问题的可以互相交流,本人折腾了好几天了
安装和部署DHCP服务
安装DHCP:
[root@dhcp ~]# yum install dhcp -y
查看安装DHCP后,生成哪些文件:
[root@dhcp ~]# rpm -ql dhcp | less 一般文件比较多时,可以使用less分页来查看
/etc/dhcp/dhcpd.conf ipV4的配置文件
/etc/dhcp/dhcpd6.conf ipV6的配置文件
。。。。。
查看一下配置文件内容
[root@dhcp ~]# cat /etc/dhcp/dhcpd.conf
#
# DHCP Server Configuration file.
# see /usr/share/doc/dhcp*/dhcpd.conf.sample 配置文件实例
# see 'man 5 dhcpd.conf' 查看配置文件的帮助手册
#
把dhcpd.conf.sample复制为DHCP的配置文件,名字为dhcpd.conf
[root@dhcp ~]# cp /usr/share/doc/dhcp-4.1.1/dhcpd.conf.sample /etc/dhcp/dhcpd.conf
cp: overwrite `/etc/dhcp/dhcpd.conf'? y
查看修改dhcpd.conf
[root@dhcp ~]# cat /etc/dhcp/dhcpd.conf
# dhcpd.conf
#
# Sample configuration file for ISC dhcpd
#
# option definitions common to all supported networks...
option domain-name "example.org";域名,改为主机名 dhcp
option domain-name-servers ns1.example.org, ns2.example.org; 名称服务器地址 设为DNS服务器地址 202.101.172.35;
default-lease-time 600; 默认租用时长可以根据需要做设定单位是s(秒)
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 { IP地址分配设定,把这里删除
}
# This is a very basic subnet declaration.
所在的网络 所在的掩码
subnet 192.168.20.0 netmask 255.255.255.0 {
range 192.168.20.150 192.168.20.180;动态配置ip的范围,中间使用空格隔开
option routers 192.168.20.254; 指定做转发的地址(路由器的地址)【此处用网关】
}
。。。。
DHCP服务启动成功
[root@dhcp ~]# ss -ulnp
State Recv-Q Send-Q Local Address:Port Peer Address:Port
UNCONN 0 0 *:67 *:* users:(("dhcpd",2261,7))
UNCONN 0 0 *:68 *:* users:(("dhclient",1055,5))
工作在udp的67端口
2. 安装和部署tftp服务
查看与tftp相关的包
[root@tftp ~]# yum list all *tftp*
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
* base: centos.ustc.edu.cn
* extras: centos.ustc.edu.cn
* test: mirrors.aliyun.com
* updates: centos.ustc.edu.cn
Available Packages
syslinux-tftpboot.noarch
4.04-3.el6 base
tftp.x86_64 0.49-7.el6 base
tftp-server.x86_64
0.49-7.el6 base
[root@tftp ~]# yum install tftp-server 安装tftp-server
查看安装后生成了哪些文件
[root@tftp ~]# rpm -ql tftp-server
/etc/xinetd.d/tftp
/usr/sbin/in.tftpd
/usr/share/doc/tftp-server-0.49
/usr/share/doc/tftp-server-0.49/CHANGES
/usr/share/doc/tftp-server-0.49/README
/usr/share/doc/tftp-server-0.49/README.security
/usr/share/doc/tftp-server-0.49/README.security.tftpboot
/usr/share/man/man8/in.tftpd.8.gz
/usr/share/man/man8/tftpd.8.gz
/var/lib/tftpboot tftp服务器默认放置文件的目录
安装时发现依赖的xinetd包也安装了,xinetd是一个超级守护进程,可管理tftp,需要先让xinetd启动,而后tftpd在启动。
查看xinetd启动级别
[root@tftp ~]# chkconfig --list | grep -A13 "xinetd"
xinetd 0:off 1:off 2:off 3:on 4:on 5:on 6:off
xinetd based services: 基于xinetd的服务
chargen-dgram: off
chargen-stream: off
daytime-dgram: off
daytime-stream: off
discard-dgram: off
discard-stream: off
echo-dgram: off
echo-stream: off
rsync: off
tcpmux-server: off
tftp: off
time-dgram: off
time-stream: off
启动xinetd,和上面显示的3,4,5级别on(此时的生效级别是要重启后才会在在对应的级别启动)没关系,需要手动启动xinetd
[root@tftp ~]# service xinetd start
Starting xinetd: [ OK ]
启动基于xinetd的服务
方法1:
[root@tftp ~]# chkconfig tftp on
方法2:可以修改tftp的配置文件/etc/xinetd.d/tftp使disable = no,后再重启xinetd也可
#service xinetd restart 这两种方法都可以
[root@tftp ~]# chkconfig --list | grep -A13 "xinetd"
xinetd 0:off 1:off 2:off 3:on 4:on 5:on 6:off
xinetd based services:
chargen-dgram: off
chargen-stream: off
daytime-dgram: off
daytime-stream: off
discard-dgram: off
discard-stream: off
echo-dgram: off
echo-stream: off
rsync: off
tcpmux-server: off
tftp: on 已经启动了
time-dgram: off
time-stream: off
获取内核,根文件系统镜像,bootloader等文件,我们可以通过挂载centos光盘来实现,也可以直接到官网下载,此处以光盘获取为例。
安装syslinux,得到pxelinux.0,把pxelinux.0复制到/var/lib/tftpboot目录下
[root@tftp cdrom]# yum install syslinux
[root@tftp cdrom]# cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/
光盘为CentOS-6.6-x86_64-netinstall.iso
新建一个虚拟机CentosX,加载一个光盘CentOS-6.6-x86_64-netinstall.iso,启动虚拟机如下
[root@tftp cdrom]# ls isolinux/
boot.cat grub.conf isolinux.bin memtest TRANS.TBL vmlinuz
boot.msg initrd.img isolinux.cfg splash.jpg vesamenu.c32
[root@tftp cdrom]# ls /var/lib/tftpboot/
initrd.img pxelinux.0 pxelinux.cfg vmlinuz
[root@tftp cdrom]# cp isolinux/{boot.msg,splash.jpg,vesamenu.c32} /var/lib/tftpboot/
指定使用的kickstart文件及其位置
ks=cdrom:/path/to/ksfile
ks=http://server/path/to/ksfile
ks=ftp://username:password@server/path/to/ksfile
ks=nfs:server.mydomain.com:/directory/ks.cfg
3. 安装和部署NFS服务
安装nfs在Centos 6上需要装rpcbind和nfs-utils这两个软件,查看是否安装了
[root@nfs ~]# rpm -qi rpcbind
package rpcbind is not installed
[root@nfs ~]# rpm -qi nfs-utils
package nfs-utils is not installed
两个包都没安装,用yum安装
[root@nfs ~]# yum install rpcbind nfs-utils
启动rpcbind和nfs
[root@nfs ~]# service rpcbind start
Starting rpcbind: [ OK ]
[root@nfs ~]# service nfs start
Starting NFS services: [ OK ]
Starting NFS quotas: [ OK ]
Starting NFS mountd: [ OK ]
Starting NFS daemon: [ OK ]
Starting RPC idmapd: [ OK ]
nfs服务的主要配置文件/etc/exports
[root@nfs ~]# vim /etc/exports
[root@nfs ~]# cat /etc/exports
/var/install 192.168.20.0/24(ro)
格式:[共享目录] [主机(权限)]
主机的设置:
可以使用完整的ip或者是网络号,比如192.168.20.89或192.168.20.0/24,或192.168.20.0/255.255.255.0.
可以使用主机名,前提是这个主机名必须要在/etc/hosts内,或可使用DNS找到该主机名。
ro是只读的,所有192.168.20.0网段内的主机都可以共享/var/install目录,但是是只读的方式。
-e 显示某台主机的/etc/exports所共享的目录数据
[root@nfs ~]# showmount -e localhost
Export list for localhost:
没有显示,修改配置文件后需要重读配置文件才能生效,重启nfs。
[root@nfs ~]# service nfs restart
Shutting down NFS daemon: [ OK ]
Shutting down NFS mountd: [ OK ]
Shutting down NFS quotas: [ OK ]
Shutting down RPC idmapd: [ OK ]
Starting NFS services: exportfs: Failed to stat /var/install: No such file or directory [ OK ]
Starting NFS quotas: [ OK ]
Starting NFS mountd: [ OK ]
Starting NFS daemon: [ OK ]
Starting RPC idmapd: [ OK ]
查看共享的目录数据
[root@nfs ~]# showmount -e localhost
Export list for localhost:
/var/install 192.168.20.0/24
新建/var/install目录
[root@nfs ~]# mkdir /var/install
把光盘挂载上
查看这些服务是否都启动
提供ks文件
这个ks文件时根据系统上anaconda-ks.cfg修改而来,anaconda-ks.cfg是每个Centos安装后都会自动生成的一个文件在/root目录下。
在Centos手动安装时,其安装过程是需要选定配置的,在安装好以后其安装过程选定的配置都在记录到anaconda-ks.cfg上了,其中有一些是必须要做的事
安装前的配置阶段: (既可交互式进行,亦可直接读取配置文件自动完成)
键盘类型
安装过程中的语言
支持使用语言
时区
选择要使用磁盘设备
分区、格式化配置
选择要安装的包
管理员密码
安装阶段:
在目标磁盘创建分区、执行分区格式化
将选定的程序包安装至目标磁盘
安装bootloader
ks文件的书写可以查看官方文档Red_Hat_Enterprise_Linux-6-Installation_Guide-en-US.pdf,里面详细介绍了每一项的使用。
安装http,[root@nfs ~]# yum install httpd
在基于网络的无人职守部署Centos系统使用PXE技术实现远程下载和安装,要使用网络安装首先需要设置BIOS通过网络方式启动。开机的时候设置BIOS:
使用nfs安装的错误提示
使用HTTP正常安装过程显示
安装错误的几种提示:
此种情况也是需要加 zerombr
在有多块硬盘时,安装所用的分区只想使用对应的硬盘,可使用一下选项:
ignoredisk (optional)
Causes the installer to ignore the specified disks. T his is useful if you use autopartition and
want to be sure that some disks are ignored. For example, without ignoredisk, attempting to
deploy on a SAN-cluster the kickstart would fail, as the installer detects passive paths to the
SAN that return no partition table.
T he syntax is:
ignoredisk --drives=drive1,drive2,...
where driveN is one of sda, sdb,..., hda,... etc.
T o ignore a multipath device that does not use logical volume management (LVM), use the
format disk/by-id/dm -uuid-m path-WWID, where WWID is the world-wide identifier for the
device. For example, to ignore a disk with WWID 24 16CD96995134 CA5D787F00A5AA11017,
ignoredisk --drives=disk/by-id/dm -uuid-m path-
2416CD96995134CA5D787F00A5AA11017
Multipath devices that use LVM are not assembled until after anaconda has parsed the
kickstart file. T herefore, you cannot specify these devices in the format dm -uuid-m path.
Instead, to ignore a multipath device that uses LVM, use the format disk/by-id/scsi-WWID,
where WWID is the world-wide identifier for the device. For example, to ignore a disk with WWID
58095BEC551094 7BE8C0360F604 351918, use:
ignoredisk --drives=disk/by-id/scsi-58095BEC5510947BE8C0360F604351918
Warning
Never specify multipath devices by device names like m patha. Device names like
m patha are not specific to a particular disk. T he disk named /dev/m patha during
installation might not be the one that you expect it to be. T herefore, the clearpart
command could target the wrong disk.
++++++++++++++++++++++++++++++++++++++++++++++++++++++++
clearpart --all --initlabel
zerombr
ignoredisk --only-use=sda 以下分区都是使用sda进行的
part /boot --fstype=ext4 --size=200
part swap --size=1536
part pv.008003 --grow --size=200
volgroup vg_lvm --pesize=4096 pv.008003
logvol / --fstype=ext4 --name=lv1 --vgname=vg_lvm --size=20480
logvol /var --fstype=ext4 --name=lv2 --vgname=vg_lvm --size=10240
++++++++++++++++++++++++++++++++++++++++
--only-use ― specifies a list of disks for the installer to use. All other disks are ignored.
For example, to use disk sda during installation and ignore all other disks:
ignoredisk --only-use=sda
T o include a multipath device that does not use LVM:
ignoredisk --only-use=disk/by-id/dm -uuid-m path-
2416CD96995134CA5D787F00A5AA11017
T o include a multipath device that uses LVM:
ignoredisk --only-use=disk/by-id/scsi-58095BEC5510947BE8C0360F604351918
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
clearpart --all --initlabel
zerombr
#ignoredisk --only-use=sda
part /boot --fstype=ext4 --size=200 --ondisk=sda 安装后分区只使用sda
part swap --size=1536 --ondisk=sda
part pv.008003 --grow --size=200 --ondisk=sda
volgroup vg_lvm --pesize=4096 pv.008003
logvol / --fstype=ext4 --name=lv1 --vgname=vg_lvm --size=20480
logvol /var --fstype=ext4 --name=lv2 --vgname=vg_lvm --size=10240
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
更多介绍可查看
http://www.cnblogs.com/higkoo/articles/kickstart_onbiosdisk_for_part.html