分类: LINUX
2010-08-12 17:14:58
一、流程:
需要安装系统的服务器(client);提供服务器安装的服务器(server)
client网卡发出pxe程序要求获得ip - -> server(dhcp)提供ip和bootloader位置;
client会启动tftp来获取bootloader - -> server(tftp)提供syslinux.0;
client请求参数文件 - -> server(tftp) 提供参数文件syslinux.cfg/default
client请求内核文件 - -> server(tftp)提供内核文件,并且把ks文件一并发出
client读取ks文件要求获得install下载地址,并且尝试连接地址 - -> server (http)提供下载路径
client执行安装。
二、要求:
操作系统 linux Red Hat Enterprise Linux AS (2.6.9-34.ELsmp) 32bit cpu
install文件:cp -arx /medea/cdrom /home/install/centos5u2_64
安装软件 dhcp ,tftp ,syslinux,nginx
dhcp:wget
提供动态IP获取
tftp:tftp-0.39-1.i386.rpm;tftp-server-0.39-1.i386.rpm
提供内核相关文件传输到client
方式1:syslinux:syslinux-2.11-1.i386.rpm
方式2:syslinux:wget
提供syslinux.0文件,引导安装系统
http(nginx): wget
提供安装系统文件
三、配置
1.dhcp
tar -zxf dhcp-4.0.1.tar.gz
cd dhcp-4.0.1
./configure --prefix=/usr/local/dhcp --disable-dhcpv6 && make && make install
ln -s /usr/local/dhcp/etc/dhcpd.conf /etc/dhcpd.conf
vi /etc/dhcpd.conf
#######################
allow booting;
allow bootp;
ddns-update-style interim;
ignore client-updates;
default-lease-time 21600;
max-lease-time 43200;
authourtative;
next-server 192.168.11.168; #这里是可有可无的
subnet 192.168.11.0 netmask 255.255.255.0 {
option routers 192.168.11.254;
option subnet-mask 255.255.255.0;
range 192.168.11.230 192.168.11.235;
default-lease-time 21600;
max-lease-time 43200;
filename "pxelinux.0";
option domain-name-servers 202.96.209.5;
}
#######################
保存dhcpd.conf的配置文件
启动服务
/usr/local/dhcp/sbin/dhcpd
netstat -nlp|grep dhcpd
查看端口号:udp:67
启动失败,可能原因1:检查配置文件是否正确
2:需要手动建立/var/lib/dhcp/dhcpd.leases的空文件
##################################################################
2tftp
rpm -ivh tftp-0.39-1.i386.rpm(应该可以不用安装)
rpm -ivh tftp-server-0.39-1.i386.rpm
vi /etc/xinetd.d/tftp
################
disable= yes
server_args= -s /tftpboot
改成
disable=no
server_args= -s /home/install/pxelinux
这里更改tftp目录,保持所有文件在同一个install下,用软连接也可以
###############
保存文件
chkconfig tftp on
启动服务
service xinetd restart
检查是否启动
netstat -nlp|grep xinetd
查看端口号:udp:69
启动如果失败,rp问题,重来一遍吧
需要导入内核文件及其相关文件
cp /home/install/centos5u2_64/images/pxeboot/initrd.img /home/install/pxelinux/initrd.img
cp /home/install/centos5u2_64/images/pxeboot/vmlinuz /home/install/pxelinux/vmlinuz
cp /home/install/centos5u2_64/isolinux/*.msg /home/install/pxelinux/
####################################################################
3syslinux
rpm -ivh syslinux-2.11-1.i386.rpm
cp /usr/lib/syslinux/pxelinux.0 /home/install/pxelinux
mkdir /home/install/pxelinux/pxelinux.cfg
vi /home/install/pxelinux/pxelinux.cfg/default
#################
default ks
#prompt 1
#timeout 30
display boot.msg
F1 boot.msg
F2 options.msg
F3 general.msg
F4 param.msg
F5 rescue.msg
F7 snake.msg
label ks
kernel vmlinuz
append ks= initrd=initrd.img devfs=nomount ramdisk_size=8192 ksdevice=eth0
#####################
保存文件
####################################################################
4http (这一步没有操作,安装以默认安装)
tar -zxf nginx-0.6.34.tar.gz
cd nginx-0.6.34
./configure --prefix=/usr/local/nginx &&make &&make install
配置文件参考:
vi /usr/local/nginx/conf/nginx.conf
#######################
user nobody nobody;
worker_processes 1;
error_log logs/error.log;
pid logs/nginx.pid;
worker_rlimit_nofile 51200;
events {
worker_connections 51200;
use epoll;
}
http {
include mime.types;
include proxy.conf;
default_type application/octet-stream ;
log_format main '$remote_addr - $remote_user [$time_local] '
'"$request" $status $bytes_sent '
'"$http_referer" "$http_user_agent" '
'"$gzip_ratio"';
log_format download '$remote_addr - $remote_user [$time_local] '
'"$request" $status $bytes_sent '
'"$http_referer" "$http_user_agent" '
'"$http_range" "$sent_http_content_range"';
client_header_timeout 3m;
client_body_timeout 3m;
send_timeout 3m;
client_header_buffer_size 1k;
large_client_header_buffers 4 4k;
gzip on;
gzip_proxied any;
gzip_types text/html text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript application/x-httpd-php;
gzip_min_length 1100;
gzip_buffers 4 8k;
output_buffers 1 32k;
postpone_output 1460;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 75 20;
server_names_hash_bucket_size 128; # this seems to be required for some vhosts
server {
listen 8000;
server_name *.test.com;
access_log logs/test.access.log main;
root /home/install/;
}
}
#############################
启动nginx
/usr/local/nginx/sbin/nginx
启动失败,请查看错误提示操作,可能的是1配置文件错误,2缺少日志写权限,3用户权限等等
查看启动进程
netstat -nlp|grep nginx
tcp :8000
##############################################################################
5ks.cfg文件制作
ks文件位置:
vi /home/install/centos5u2_64/ks.cfg
#################
## Kickstart file automatically generated by anaconda.
## File from Phinex .Thanks Phinex.
install
#url --server=192.168.11.168 --dir=/home/install/centos5u2_64
url --url=
keyboard us
lang en_US.UTF-8
langsupport --default=en_US.UTF-8 zh_CN.UTF-8
#network --device eth0 --bootproto static --ip 10.251.1.1 --netmask 255.255.255.0
#network --device eth1 --bootproto static --ip 10.251.1.1 --netmask 255.255.255.0
network --bootproto=dhcp --device=eth0 --onboot=on
text
skipx
rootpw 123456
firewall --enabled --port=22:tcp --port=80:tcp
authconfig --enableshadow --enablemd5
selinux --disabled
timezone Asia/Shanghai
bootloader --location=mbr
# Partitioning
clearpart --all
part /boot --fstype ext3 --size=128
part / --fstype ext3 --size=50000
part /data --fstype ext3 --size=0 --grow
part swap --fstype swap --size=2000
#part /boot --fstype ext3 --size=128 --ondisk=sda
#part / --fstype ext3 --size=50000 --ondisk=sda
#part /data --fstype ext3 --size=0 --grow --ondisk=sda
#part swap --fstype swap --size=2000 --ondisk=sda
reboot
%packages
@ core
@ admin-tools
@ system-tools
@ text-internet
@ development-tools
e2fsprogs
grub
lvm2
net-snmp
sysstat
zlib
xinetd
kernel-xen
xen
%post
echo 'ttyS0' >> /etc/securetty
# disable ipv6
echo "alias net-pf-10 off" >> /etc/modprobe.conf
perl -pi -e 's/NETWORKING_IPV6=yes/NETWORKING_IPV6=no/g' /etc/sysconfig/network
# motd text
echo 'This is a private network device. Activity is monitored. This system cannot be used or accessed without authorization.' > /etc/motd
# setup service
# on service
for svc in snmpd; do
chkconfig --level 3 $svc on
done
# off service
for svc in ip6tables rpcidmapd lm_sensors nfslock apmd xfs arptables_jf mdmonitor pcmcia cups rpcgssd isdn lvm2-monitor openibd sendmail avahi-daemon bluetooth cpuspeed firstboot
setroubleshoot restorecond portmap pcscd netfs mcstrans hidd gpm yum-updatesd ; do
chkconfig --level 3 $svc off
done
# DNS config
echo 'nameserver 10.29.1.110
nameserver 10.29.1.111
search xa.ab.com cdn.ab.com' > /etc/resolv.conf
# ssh config
echo 'ListenAddress 0.0.0.0
SyslogFacility AUTHPRIV
PasswordAuthentication yes
ChallengeResponseAuthentication no
UsePAM yes
AllowTcpForwarding no
UseDNS no
Subsystem sftp /usr/libexec/openssh/sftp-server
#AllowUsers *@10.*.*.*' > /etc/ssh/sshd_config
# network optimize
echo "* - nofile 51200" >> /etc/security/limits.conf
echo "net.ipv4.ip_local_port_range = 1024 65536
net.core.rmem_max=16777216
net.core.wmem_max=16777216
net.ipv4.tcp_rmem=4096 87380 16777216
net.ipv4.tcp_wmem=4096 65536 16777216
net.ipv4.tcp_fin_timeout = 3
net.ipv4.tcp_tw_recycle = 1
net.core.netdev_max_backlog = 30000
net.ipv4.tcp_no_metrics_save=1
net.core.somaxconn = 262144
net.ipv4.tcp_syncookies = 0
net.ipv4.tcp_max_orphans = 262144
net.ipv4.tcp_max_syn_backlog = 262144
net.ipv4.tcp_synack_retries = 2
net.ipv4.tcp_syn_retries = 2
# Decrease the time default value for tcp_fin_timeout connection
net.ipv4.tcp_fin_timeout = 30
net.ipv4.tcp_keepalive_time = 1800
net.ipv4.tcp_window_scaling = 0
net.ipv4.tcp_sack = 0
net.ipv4.tcp_timestamps = 0
fs.file-max = 51200
" >> /etc/sysctl.conf
备注: 安装过程中发现所有配置都正确无误(dhcp,tftp,xinetd,syslinux,nginx,ks),那么有可能是所使用的iso文件有问题,我指的是可能是复制过程中出错,可能本身就有问题。可以考虑换个iso文件再试再找原因