Chinaunix首页 | 论坛 | 博客
  • 博客访问: 108153
  • 博文数量: 29
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 397
  • 用 户 组: 普通用户
  • 注册时间: 2014-12-26 15:36
文章分类

全部博文(29)

文章存档

2016年(3)

2015年(13)

2014年(13)

我的朋友
PXE

分类: 系统运维

2014-12-31 14:44:59

PXE

环境:Centos 6.2 x64
软件:dhcp、tftp、xinetd

一、设置防火墙

/etc/init.d/iptables stop
当然SElinux,肯定也是需要关闭的!

二、挂载ISO

mkdir /iso ; mkdir -p /var/www/html/6.2/hrsjw1_key

[root@PXE opt]# mount -o loop CentOS-6.2-x86_64-bin-DVD1.iso /mnt/
[root@PXE mnt]# cp -rf *

将centos安装盘下的内容全部拷贝进入web目录

三、DHCP设置
[root@PXE dhcp]# cat /etc/dhcp/dhcpd.conf
#
# DHCP Server Configuration file.
# see /usr/share/doc/dhcp*/dhcpd.conf.sample
# see 'man 5 dhcpd.conf'
#
#
ddns-update-style interim;
ignore client-updates;
allow booting;
allow bootp;
subnet 192.168.0.0 netmask 255.255.255.0 {

option routers 192.168.0.1;
option subnet-mask 255.255.255.0;
next-server 192.168.0.10;
filename "pxelinux.0";

option time-offset -18000;

range dynamic-bootp 192.168.0.10 192.168.0.20;
default-lease-time 21600;
max-lease-time 43200;
}

[root@PXE dhcp]# /etc/init.d/dhcpd restart
正在启动 dhcpd: [确定]

四、TFTP、Syslinux相关配置

yum -y install tftp-server syslinux xinetd

[root@PXE ~]# cat /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@PXE ~]# /etc/init.d/xinetd restart
停止 xinetd: [失败]
正在启动 xinetd: [确定]
[root@PXE ~]#

五、调试PXE并配置

如无tftpboot 目录的情况下:
已经找到dhcp 服务器从dhcp 获得IP 地址,不过tftp 服务没有响应。

复制下面文件
#CentOS 5
cd /usr/lib/syslinux/
#CentOS 6
cd /usr/share/syslinux/
cp pxelinux.0 menu.c32 memdisk mboot.c32 chain.c32 /var/lib/tftpboot/

找到启动的文件,开始从/var/lib/tftpboot/pxelinux.cfg 找相关的文件,注意他们的寻找的顺序。最后是找到
/var/lib/tftpboot/pxelinux.cfg/default 不过当前目录是没有default 的文件。

创建下面的目录
mkdir

cp /var/www/html/isolinux/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default
[root@PXE isolinux]# cat

default vesamenu.c32
#prompt 1
timeout 6

display boot.msg

menu background splash.jpg
menu title Welcome to CentOS 6.2!
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 ksdevice=em1 ks= initrd=initrd.img
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 -

在复制下面内容

[root@PXE isolinux]# cp /var/www/html/6.2/isolinux/* /var/lib/tftpboot/

这个时候,就完成的pxe server 的设置。

创建ks.cfg 文件
下面是我的ks.cfg 文件,最简单创建文件的方式,就是把你安装系统的anaconda-ks.cfg 文件修改一下就ok!
注意,我的root的密码是hrsjw1
关于系统分区、安装系统包、时区等等,你可通过进行自定义配置ks.cfg

如下:


root@PXE dhcp]# cat /mnt/ks.cfg
#platform=x86, AMD64, or Intel EM64T
#version=DEVEL
# Firewall configuration
firewall --disabled
# Install OS instead of upgrade
install
# Use network installation
#选择协议
#nfs --server=10.101.0.18 --dir=/mnt
url --url="http://10.101.0.18/6.2"
# Root password
rootpw --plaintext hrsjw1
# System authorization information
auth  --useshadow  --passalgo=md5
# 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=em1 --onboot=on
# System bootloader configuration
bootloader --location=mbr
# Partition clearing information
#如果sda/sdb分区均是小盘,开启下一行:
clearpart --all --initlabel
# Disk partitioning information
part /boot --fstype="ext4" --ondisk=sda --size=512
part swap --ondisk=sda --size=2100
#--grow=告诉逻辑卷使用所有可用空间(若有),或使用设置的最大值.
#将剩下空间分给/目录
part / --fstype="ext4" --ondisk=sda --grow --size=1
#part / --fstype="ext4" --size=102400 --ondisk=sda
%pre
#sda/sdb分区均大于2T开启下两行 ()
#parted -s /dev/sda mklabel gpt

#parted /dev/sdb mklabel gpt
%end

%post
chkconfig --level 012345 acpid off
chkconfig --level 012345 anacron off
chkconfig --level 012345 auditd off
chkconfig --level 012345 autofs off
chkconfig --level 012345 avahi-daemon off
chkconfig --level 012345 bluetooth off
chkconfig --level 012345 cpuspeed off
chkconfig --level 012345 cups off
chkconfig --level 012345 firstboot off
chkconfig --level 012345 gpm off
chkconfig --level 012345 haldaemon off
chkconfig --level 012345 hidd off
chkconfig --level 012345 hplip off
chkconfig --level 012345 irqbalance off
chkconfig --level 012345 isdn off
chkconfig --level 012345 kudzu off
chkconfig --level 012345 lvm2-monitor off
chkconfig --level 012345 mcstrans off
chkconfig --level 012345 mdmonitor off
chkconfig --level 012345 messagebus off
chkconfig --level 012345 netfs off
chkconfig --level 012345 nfslock off
chkconfig --level 012345 pcscd off
chkconfig --level 012345 portmap off
chkconfig --level 012345 readahead_early off
chkconfig --level 012345 restorecond off
chkconfig --level 012345 rhnsd off
chkconfig --level 012345 rpcgssd off
chkconfig --level 012345 rpcidmapd off
chkconfig --level 012345 rpcbind off
chkconfig --level 012345 sendmail off
chkconfig --level 012345 setroubleshoot off
chkconfig --level 012345 smartd off
chkconfig --level 012345 xfs off
chkconfig --level 012345 modclusterd off
chkconfig --level 012345 yum-updatesd off

sed -i 's/id:5:initdefault/id:3:initdefault/g' /etc/inittab
sed -i 's/#UseDNS yes/UseDNS no/' /etc/ssh/sshd_config
mkdir -m 700 /root/.ssh
cd /root/.ssh/; wget
echo 'nameserver 202.106.0.20' >>/etc/resolv.conf

#Open File
echo '*       soft    nofile    32768' >> /etc/security/limits.conf
echo '*       hard    nofile    32768' >> /etc/security/limits.conf
echo 'ulimit -u 5120' >> /etc/profile
echo "ulimit -SHn 102400">> /etc/rc.local

#Disabled Ipv6
cat > /etc/modprobe.d/ipv6.conf << EOF
alias net-pf-10 off
options ipv6 disable=1
EOF

#Kernel Optimization
cat >> /etc/sysctl.conf << EOF
net.ipv4.tcp_syncookies = 1
# 1是开启SYN Cookies,当出现SYN等待队列溢出时,启用Cookies来处,理,可防范少量SYN攻击,默认是0关闭

net.ipv4.tcp_tw_reuse = 1
# 1是开启重用,允许讲TIME_AIT sockets重新用于新的TCP连接,默认是0关闭

net.ipv4.tcp_tw_recycle = 1
# TCP失败重传次数,默认是15,减少次数可释放内核资源

net.ipv4.ip_local_port_range = 4096 65000
# 应用程序可使用的端口范围

vm.swappiness = 30
#系统对于swap的写入

net.ipv4.tcp_max_tw_buckets = 5000
# 系统同时保持TIME_WAIT套接字的最大数量,如果超出这个数字,TIME_WATI套接字将立刻被清除并

net.ipv4.tcp_max_syn_backlog = 4096
# 进入SYN的最大请求队列,默认是1024

net.core.netdev_max_backlog =  10240
# 允许送到队列的数据包最大设备队列,默认300

net.core.somaxconn = 2048
# listen挂起请求的最大数量,默认128

net.core.wmem_default = 8388608
# 发送缓存区大小的缺省值

net.core.rmem_default = 8388608
# 接受套接字缓冲区大小的缺省值(以字节为单位)

net.core.rmem_max = 16777216
# 最大接收缓冲区大小的最大值

net.core.wmem_max = 16777216
# 发送缓冲区大小的最大值

net.ipv4.tcp_synack_retries = 2
# SYN-ACK握手状态重试次数,默认5

net.ipv4.tcp_syn_retries = 2
# 向外SYN握手重试次数,默认4

net.ipv4.tcp_tw_recycle = 1
# 开启TCP连接中TIME_WAIT sockets的快速回收,默认是0关闭

net.ipv4.tcp_max_orphans = 3276800
# 系统中最多有多少个TCP套接字不被关联到任何一个用户文件句柄上,如果超出这个数字,孤儿连接将立即复位并打印警告信息
EOF

mkdir -p /home/sysop/script
%end

%packages
@additional-devel
@base
@client-mgmt-tools
@compat-libraries
@console-internet
@core
@development
@network-tools
@performance
@security-tools
@server-platform-devel
@server-policy
@system-admin-tools
@system-management
gnutls-devel
hmaccalc
jpackage-utils
libXau-devel
libXinerama-devel
libXrandr-devel
libbonobo-devel
libgcrypt-devel
libglade2-devel
libgnomeui-devel
libxslt-devel
mtools
popt-devel
sgpio
startup-notification-devel
xorg-x11-proto-devel
%end

阅读(944) | 评论(0) | 转发(0) |
0

上一篇:Linux 5 配置MD3200i 存储

下一篇:ubuntu.list

给主人留下些什么吧!~~