批量配备Linux机器,批量配备linux机器

作者: 操作系统  发布:2019-09-06

总括下从前用的东西
系统:centos5/redhat5
软件包:
wget
wget
1、syslinux编写翻译安装,pxe运行目录和文件创设
tar zxvf syslinux-3.86.tar.gz
cd syslinux-3.86
make
mkdir /tftpboot/pxelinux.cfg -p
mkdir /tftpboot/ks -p
mkdir /tftpboot/centos5.3
mkdir /tftpboot/redhat5.4
chmod 755 /tftpboot
#cd gpx/gpxelinux.0 /tftpboot
#cp gpx/pxelinux.gpxe /tftpboot
#cp com32/menu/*.c32 /tftpboot/pxelinux.cfg
#cp com32/modules/reboot.c32 /tftpboot/pxelinux.cfg
#cp com32/modules/chain.c32 /tftpboot/pxelinux.cfg
复制安装盘isolinux目录下的三个主要文件vmlinuz和initrd.img到TFTP根目录/tftpboot下
cp /data/centos5.3/isolinux/vmlinuz /tftpboot/centos5.3
cp /data/centos5.3/isolinux/initrd.img /tftpboot/centos5.3
cp /data/redhat5.4/isolinux/vmlinuz /tftpboot/redhat5.4
cp /data/redhat5.4/isolinux/initrd.img /tftpboot/redhat5.4

批量配置Linux机器(RedHat5.4/CentOS5.3):
系统:centos5/redhat5
软件包:
wget
wget
1、syslinux编译安装,pxe运营目录和文件创制
tar zxvf syslinux-3.86.tar.gz
cd syslinux-3.86
make
mkdir /tftpboot/pxelinux.cfg -p
mkdir /tftpboot/ks -p
mkdir /tftpboot/centos5.3
mkdir /tftpboot/redhat5.4
chmod 755 /tftpboot
#cd gpx/gpxelinux.0 /tftpboot
#cp gpx/pxelinux.gpxe /tftpboot
#cp com32/menu/*.c32 /tftpboot/pxelinux.cfg
#cp com32/modules/reboot.c32 /tftpboot/pxelinux.cfg
#cp com32/modules/chain.c32 /tftpboot/pxelinux.cfg
复制安装盘isolinux目录下的多个主要文件vmlinuz和initrd.img到TFTP根目录/tftpboot下
cp /data/centos5.3/isolinux/vmlinuz /tftpboot/centos5.3
cp /data/centos5.3/isolinux/initrd.img /tftpboot/centos5.3
cp /data/redhat5.4/isolinux/vmlinuz /tftpboot/redhat5.4
cp /data/redhat5.4/isolinux/initrd.img /tftpboot/redhat5.4

复制安装盘isolinux目录下的全体.msg文件(boot.msg,initrd.msg,param.msg,general.msg,options.msg,rescue.msg)到TFTP根目录/tftpboot下
命令:
cp /data/centos5.3/isolinux/*.msg /tftpboot/centos5.3/
cp /data/redhat5.4/isolinux/*msg  /tftpboot/redhat5.4/
复制isolinux目录下的isolinux.cfg文件为tftpboot/pxelinux.cfg下的default
cp /data/centos5.3/isolinux.cfg   /tftpboot/pxelinux.cfg/default

复制安装盘isolinux目录下的全体.msg文件(boot.msg,initrd.msg,param.msg,general.msg,options.msg,rescue.msg)到TFTP根目录/tftpboot下
命令:
cp /data/centos5.3/isolinux/*.msg /tftpboot/centos5.3/
cp /data/redhat5.4/isolinux/*msg  /tftpboot/redhat5.4/
复制isolinux目录下的isolinux.cfg文件为tftpboot/pxelinux.cfg下的default
cp /data/centos5.3/isolinux.cfg   /tftpboot/pxelinux.cfg/default

2、dhcpd配置
yum -y install dhcp dhcp-devel
编纂DHCP配置文件/etc/dhcpd.conf,可以从/usr/share/doc/dhcp*/dhcpd.conf.sample将以此布局文件的样例复制过来,那样编辑起来会越来越快些
dhcpd.conf配置的关于表达:

2、dhcpd配置
yum -y install dhcp dhcp-devel
编排DHCP配置文件/etc/dhcpd.conf,可以从/usr/share/doc/dhcp*/dhcpd.conf.sample将以此布局文件的样例复制过来,那样编辑起来会更加快些
dhcpd.conf配置的关于表达:

parameters(参数):
ddns-update-style 配置DHCP-DNS互动更新形式
default-lease-time 钦赐缺省租借时间的长度,单位是秒
max-lease-time 钦点最大租售时间长度,单位是秒
hardware 钦命网卡接口类型和MAC地址
server-name 通告DHCP顾客服务器名称
get-lease-hostnames flag 检查客户端接纳的IP地址
fixed-address ip 分配给客商端一个固定的地址
authritative 拒绝不正确的IP地址的要求

parameters(参数):
ddns-update-style 配置DHCP-DNS互动更新格局
default-lease-time 钦定缺省租费时间的长短,单位是秒
max-lease-time 钦命最大租费时长,单位是秒
hardware 钦赐网卡接口类型和MAC地址
server-name 通告DHCP顾客服务器名称
get-lease-hostnames flag 检查顾客端应用的IP地址
fixed-address ip 分配给客商端一个恒久的地点
authritative 拒绝不得法的IP地址的需要

declarations(声明):
shared-network 用来告诉是或不是一些子网络分享一样网络
subnet 描述多少个IP地址是还是不是属于该子网
range 开头IP 终止IP 提供动态分配IP 的范围
host 主机名称 参谋特别的主机
group 为一组参数提供评释
allow unknown-clients或deny unknown-client 是还是不是动态分配IP给未知的使用者
allow bootp或deny bootp 是或不是响应激活查询
allow booting或deny booting 是不是响应使用者查询
filename 开端运维文件的名称,应用于无盘专门的学业站
next-server 设置服务器从引导文件中装如主机名,应用于无盘专门的学问站

declarations(声明):
shared-network 用来告诉是不是一些子网络分享一样互连网
subnet 描述一个IP地址是还是不是属于该子网
range 初始IP 终止IP 提供动态分配IP 的范围
host 主机名称 参照他事他说加以考察非常的主机
group 为一组参数提供申明
allow unknown-clients或deny unknown-client 是或不是动态分配IP给未知的使用者
allow bootp或deny bootp 是或不是响应激活查询
allow booting或deny booting 是或不是响应使用者查询
filename 起头运转文件的名目,应用于无盘职业站
next-server 设置服务器从辅导文件中装如主机名,应用于无盘专门的工作站

option(选项):
subnet-mask 为顾客端设定子网掩码
domain-name 为客户端指明DNS名字
domain-name-servers 为顾客端指明DNS服务器IP地址
host-name 为顾客端钦命主机名称
routers 为客商端设定暗许网关
broadcast-address 为客户端设定广播地址
ntp-server 为顾客端设定互联网时间服务器IP地址
time-offset 为顾客端设定和Green威治时间的摇荡时间,单位是秒。

option(选项):
subnet-mask 为顾客端设定子网掩码
domain-name 为客商端指明DNS名字
domain-name-servers 为客商端指明DNS服务器IP地址
host-name 为客商端钦命主机名称
routers 为顾客端设定默许网关
broadcast-address 为客商端设定广播地址
ntp-server 为顾客端设定互联网时间服务器IP地址
time-offset 为顾客端设定和Green威治时间的撼动时间,单位是秒。

命令:
cp /usr/share/doc/dhcp*/dhcpd.conf.sample /etc/dhcpd.conf
vim /etc/dhcpd.conf
#--------------global------------------------------------------
option domain-name-servers 192.168.1.199;
ddns-update-style none;
default-lease-time 14400;
max-lease-time 43200;
#----------tftp------------------------------------------
ignore client-updates;
allow booting;
allow bootp;
class "pxeclients"{
        match if substring(option vendor-class-identifier,0,9) = "PXEClient";
        filename "gpxelinux.0";
        next-server 192.168.1.199;
}
#----------subnet---------------------------------------------
subnet 192.168.1.0 netmask 255.255.255.0 {
        option routers                  192.168.1.1;
        option subnet-mask              255.255.255.0;
        range dynamic-bootp 192.168.1.200 192.168.1.254;
}

命令:
cp /usr/share/doc/dhcp*/dhcpd.conf.sample /etc/dhcpd.conf
vim /etc/dhcpd.conf
#--------------global------------------------------------------
option domain-name-servers 192.168.1.199;
ddns-update-style none;
default-lease-time 14400;
max-lease-time 43200;
#----------tftp------------------------------------------
ignore client-updates;
allow booting;
allow bootp;
class "pxeclients"{
        match if substring(option vendor-class-identifier,0,9) = "PXEClient";
        filename "gpxelinux.0";
        next-server 192.168.1.199;
}
#----------subnet---------------------------------------------
subnet 192.168.1.0 netmask 255.255.255.0 {
        option routers                  192.168.1.1;
        option subnet-mask              255.255.255.0;
        range dynamic-bootp 192.168.1.200 192.168.1.254;
}

自己评杂文件/var/lib/dhcpd/dhcpd.leases,文件存在就能够

反省文件/var/lib/dhcpd/dhcpd.leases,文件存在就能够

假若虚拟到安全主题材料,在多网卡的机械上得以编辑/etc/sysconfig/dhcpd文件来拟定DHCP服务在至极设备上运维
命令:
vim /etc/sysconfig/dhcpd
编辑内容为:
# Command line options here
DHCPDARGS=eth0
重启DHCP服务
service dhcpd restart或/etc/rc.d/ini.d/dhcpd restart

例如思量到平安主题材料,在多网卡的机器上能够编辑/etc/sysconfig/dhcpd文件来制订DHCP服务在至极设备上运转
命令:
vim /etc/sysconfig/dhcpd
编写制定内容为:
# Command line options here
DHCPDARGS=eth0
重启DHCP服务
service dhcpd restart或/etc/rc.d/ini.d/dhcpd restart

3、tftp配置
yum -y install xinetd tftp tftp-server
编排TFTP的配备文件
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             = -u nobody -s /tftpboot
        disable                 = no
        per_source              = 11
        cps                     = 100 2
        flags                   = IPv4
}
重启TFTP服务须要重启xinetd那个守护服务
service xinetd restart

3、tftp配置
yum -y install xinetd tftp tftp-server
编排TFTP的安排文件
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             = -u nobody -s /tftpboot
        disable                 = no
        per_source              = 11
        cps                     = 100 2
        flags                   = IPv4
}
重启TFTP服务要求重启xinetd这些守护服务
service xinetd restart

4、nfs配置:
yum -y install nfs-utils nfs-utils-lib

4、nfs配置:
yum -y install nfs-utils nfs-utils-lib

编排NFS的布局文件
命令:
vim /etc/exports
/tftpboot *(ro,sync)
/data/centos5.3 *(ro,sync)

编纂NFS的配置文件
命令:
vim /etc/exports
/tftpboot *(ro,sync)
/data/centos5.3 *(ro,sync)

重启nfs服务:
service nfs restart
service portmap restart

重启nfs服务:
service nfs restart
service portmap restart

要么能够不必重启整个服务,用上边发号施令更新NFS服务
exportfs -arv

要么能够无需重启整个服务,用上面发号施令更新NFS服务
exportfs -arv

检查目录设置是不是科学:
showmount -e localhost

检查目录设置是或不是科学:
showmount -e localhost

只须求基于自个儿工作定义cfg文件:

只须要基于本身事情定义cfg文件:

/tftpboot/ks下的ceentos5.3.cfg和redhat5.4.cfg
#########/tftpboot/pxelinux.cfg/default#######
default ct53_32
prompt 1
timeout 600
display boot.msg
F1 boot.msg
F2 options.msg
F3 general.msg
F4 param.msg
F5 rescue.msg
label linux
  kernel vmlinuz
  append initrd=initrd.img
label text
  kernel vmlinuz
  append initrd=initrd.img text
label local
  localboot 1
label memtest86
  kernel memtest
  append -

/tftpboot/ks下的ceentos5.3.cfg和redhat5.4.cfg

label ct53_32
  kernel centos5.3/vmlinuz
  append initrd=centos5.3/initrd.img ks=nfs:192.168.1.199:/tftpboot/ks/ct53_32.cfg devfs=nomount ramdisk_size=4096 nofb text
label rh54_32
  kernel redhat5.4/vmlinuz
  append initrd=redhat5.4/initrd.img ks=nfs:192.168.1.199:/tftpboot/ks/rh54_32.cfg devfs=nomount ramdisk_size=4096 nofb text
############/tftpboot/ks/rh54_32.cfg#############
# Kickstart file automatically generated by anaconda.

#########/tftpboot/pxelinux.cfg/default#######

install
nfs --server=192.168.1.199 --dir=/data/redhat5.4
lang en_US.UTF-8
langsupport --default=en_US.UTF-8 en_US.UTF-8
keyboard us
key --skip
network --bootproto=dhcp --device=eth0 --onboot=on
rootpw --iscrypted $1$XPr0sv0o$1.XsUW0h36ZdWetQOefR21
firewall --disabled
selinux --disabled
authconfig --enableshadow --enablemd5
timezone Asia/Shanghai
bootloader --location=mbr
#disk
clearpart --all --initlabel
part /boot --fstype ext3 --size=100
part / --fstype ext3 --size=12000
part swap --fstype swap --size=1024

default ct53_32
prompt 1
timeout 600
display boot.msg
F1 boot.msg
F2 options.msg
F3 general.msg
F4 param.msg
F5 rescue.msg
label linux
  kernel vmlinuz
  append initrd=initrd.img
label text
  kernel vmlinuz
  append initrd=initrd.img text
label local
  localboot 1
label memtest86
  kernel memtest
  append -

%packages
@admin-tools
@editors
#@emacs
@base
@system-tools
@dialup
@server-cfg
@development-tools
@ruby
@text-internet
net-snmp

label ct53_32
  kernel centos5.3/vmlinuz
  append initrd=centos5.3/initrd.img ks=nfs:192.168.1.199:/tftpboot/ks/ct53_32.cfg devfs=nomount ramdisk_size=4096 nofb text
label rh54_32
  kernel redhat5.4/vmlinuz
  append initrd=redhat5.4/initrd.img ks=nfs:192.168.1.199:/tftpboot/ks/rh54_32.cfg devfs=nomount ramdisk_size=4096 nofb text

%post
/sbin/chkconfig --level 2345 anacron off
/sbin/chkconfig --level 2345 apmd off
/sbin/chkconfig --level 2345 atd off
/sbin/chkconfig --level 2345 gpm off
/sbin/chkconfig --level 2345 httpd off
/sbin/chkconfig --level 2345 identd off
/sbin/chkconfig --level 2345 ipchains off
/sbin/chkconfig --level 2345 isdn off
/sbin/chkconfig --level 2345 keytable off
/sbin/chkconfig --level 2345 kudzu off
/sbin/chkconfig --level 2345 linuxconf off
/sbin/chkconfig --level 2345 lpd off
/sbin/chkconfig --level 2345 netfs off
/sbin/chkconfig --level 2345 nfslock off
/sbin/chkconfig --level 2345 pcmcia off
/sbin/chkconfig --level 2345 portmap off
/sbin/chkconfig --level 2345 random off
/sbin/chkconfig --level 2345 rawdevices off
/sbin/chkconfig --level 2345 rhnsd off
/sbin/chkconfig --level 2345 sgi_fam off
/sbin/chkconfig --level 2345 sshd off
/sbin/chkconfig --level 2345 xfs off
/sbin/chkconfig --level 2345 xinetd off
/sbin/chkconfig --level 2345 cups off
/sbin/chkconfig --level 2345 hpoj off
/sbin/chkconfig --level 2345 mdmpd off
/sbin/chkconfig --level 2345 firstboot off
/sbin/chkconfig --level 2345 arptables_jf off
/sbin/chkconfig --level 2345 mdmonitor off
/sbin/chkconfig --level 2345 smartd off
/sbin/chkconfig --level 2345 messagebus off
/sbin/chkconfig --level 2345 acpid off
/sbin/chkconfig --level 2345 avahi-daemon off
/sbin/chkconfig --level 2345 rpcsvcgssd  off
/sbin/chkconfig --level 2345 rpcgssd off
/sbin/chkconfig --level 2345 rpcidmapd off
/sbin/chkconfig --level 2345 irqbalance on
/sbin/chkconfig --level 2345 bluetooth off
/sbin/chkconfig --level 2345 psacct on
/sbin/chkconfig --level 2345 sshd on
/sbin/chkconfig --level 2345 snmpd on
echo "* */5 * * * /usr/sbin/ntpdate  210.72.145.44 > /dev/null  2>&1"  >> /etc/crontab
echo "nameserver 202.106.46.151">/etc/resolv.conf
echo "nameserver 202.106.196.115">>/etc/resolv.conf
 
小编 “Larry学习之路”

############/tftpboot/ks/rh54_32.cfg#############

系统:centos5/redhat5 软件包: wget wget ...

# Kickstart file automatically generated by anaconda.

install
nfs --server=192.168.1.199 --dir=/data/redhat5.4
lang en_US.UTF-8
langsupport --default=en_US.UTF-8 en_US.UTF-8
keyboard us
key --skip
network --bootproto=dhcp --device=eth0 --onboot=on
rootpw --iscrypted $1$XPr0sv0o$1.XsUW0h36ZdWetQOefR21
firewall --disabled
selinux --disabled
authconfig --enableshadow --enablemd5
timezone Asia/Shanghai
bootloader --location=mbr
#disk
clearpart --all --initlabel
part /boot --fstype ext3 --size=100
part / --fstype ext3 --size=12000
part swap --fstype swap --size=1024

%packages
@admin-tools
@editors
#@emacs
@base
@system-tools
@dialup
@server-cfg
@development-tools
@ruby
@text-internet
net-snmp

%post
/sbin/chkconfig --level 2345 anacron off
/sbin/chkconfig --level 2345 apmd off
/sbin/chkconfig --level 2345 atd off
/sbin/chkconfig --level 2345 gpm off
/sbin/chkconfig --level 2345 httpd off
/sbin/chkconfig --level 2345 identd off
/sbin/chkconfig --level 2345 ipchains off
/sbin/chkconfig --level 2345 isdn off
/sbin/chkconfig --level 2345 keytable off
/sbin/chkconfig --level 2345 kudzu off
/sbin/chkconfig --level 2345 linuxconf off
/sbin/chkconfig --level 2345 lpd off
/sbin/chkconfig --level 2345 netfs off
/sbin/chkconfig --level 2345 nfslock off
/sbin/chkconfig --level 2345 pcmcia off
/sbin/chkconfig --level 2345 portmap off
/sbin/chkconfig --level 2345 random off
/sbin/chkconfig --level 2345 rawdevices off
/sbin/chkconfig --level 2345 rhnsd off
/sbin/chkconfig --level 2345 sgi_fam off
/sbin/chkconfig --level 2345 sshd off
/sbin/chkconfig --level 2345 xfs off
/sbin/chkconfig --level 2345 xinetd off
/sbin/chkconfig --level 2345 cups off
/sbin/chkconfig --level 2345 hpoj off
/sbin/chkconfig --level 2345 mdmpd off
/sbin/chkconfig --level 2345 firstboot off
/sbin/chkconfig --level 2345 arptables_jf off
/sbin/chkconfig --level 2345 mdmonitor off
/sbin/chkconfig --level 2345 smartd off
/sbin/chkconfig --level 2345 messagebus off
/sbin/chkconfig --level 2345 acpid off
/sbin/chkconfig --level 2345 avahi-daemon off
/sbin/chkconfig --level 2345 rpcsvcgssd  off
/sbin/chkconfig --level 2345 rpcgssd off
/sbin/chkconfig --level 2345 rpcidmapd off
/sbin/chkconfig --level 2345 irqbalance on
/sbin/chkconfig --level 2345 bluetooth off
/sbin/chkconfig --level 2345 psacct on
/sbin/chkconfig --level 2345 sshd on
/sbin/chkconfig --level 2345 snmpd on

echo "* */5 * * * /usr/sbin/ntpdate  210.72.145.44 > /dev/null  2>&1"  >> /etc/crontab
echo "nameserver 202.106.46.151">/etc/resolv.conf
echo "nameserver 202.106.196.115">>/etc/resolv.conf

图片 1

本文由今晚开什么码发布于操作系统,转载请注明出处:批量配备Linux机器,批量配备linux机器

关键词:

上一篇:没有了
下一篇:没有了