码迷,mamicode.com
首页 > 其他好文 > 详细

kickstart自动装机

时间:2016-07-08 20:03:01      阅读:140      评论:0      收藏:0      [点我收藏+]

标签:kickstart

1、安装epel源

[root@kickstart src]# rpm -Uvh epel-release-6-8.noarch.rpm


2、安装DHCP

[root@kickstart ~]# yum install dhcp -y

3、配置DHCP

[root@kickstart ~]# cp /usr/share/doc/dhcp-4.1.1/dhcpd.conf.sample /etc/dhcp/dhcpd.conf
cp: overwrite `/etc/dhcp/dhcpd.conf‘? y

[root@kickstart ~]# sed -i -e ‘/^$/d‘ -e ‘/^#/d‘ /etc/dhcp/dhcpd.conf

修改dhcpd.conf配置文件

ddns-update-style none;
ignore client-updates;
default-lease-time 86400;
max-lease-time 604800;

subnet 20.0.0.0 netmask 255.255.255.0 {
  range 20.0.0.30 20.0.0.100;
  option domain-name-servers 20.0.0.10;
  option domain-name "kickstart";
  option subnet-mask 255.255.255.0;
  option routers 20.0.0.1;
  next-server 20.0.0.10;
  filename "pxelinux.0";
}


4、指定网卡启动DHCP服务

[root@kickstart ~]# vim /etc/sysconfig/dhcpd
# Command line options here
DHCPDARGS=eth1


5、启动DHCP

[root@kickstart ~]# service dhcpd restart
[root@kickstart ~]# ps -ef | grep dhcpd | grep -v grep
dhcpd      2832      1  0 23:41 ?        00:00:00 /usr/sbin/dhcpd -user dhcpd -group dhcpd eth1


6、安装TFTP

[root@kickstart ~]# yum install tftp-server -y

[root@kickstart ~]# vim /etc/xinetd.d/tftp
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@kickstart ~]# /etc/init.d/xinetd start
Starting xinetd:                                           [  OK  ]
[root@kickstart ~]# netstat -lnup
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name   
udp        0      0 0.0.0.0:67                  0.0.0.0:*                               2832/dhcpd          
udp        0      0 0.0.0.0:69                  0.0.0.0:*                               2893/xinetd


7、安装nginx

[root@kickstart src]# useradd nginx -M -s /sbin/nologin

[root@kickstart nginx-1.8.1]# yum install gcc gcc-c++ zlib pcre pcre-devel openssl openssl-devel -y

[root@kickstart nginx-1.8.1]# ./configure \
> --user=nginx \
> --group=nginx \
> --prefix=/usr/local/nginx \
> --sbin-path=/usr/sbin/nginx \
> --conf-path=/etc/nginx/nginx.conf \
> --with-http_stub_status_module \
> --with-http_ssl_module \
> --with-http_gzip_static_module \
> --with-http_sub_module \
> --with-pcre


8、创建kickstart存放centos镜像的目录

[root@kickstart ~]# mkdir /data/www/Cent6.7 -p

[root@kickstart ~]# mount /dev/sr0 /data/www/Cent6.7
mount: block device /dev/sr0 is write-protected, mounting read-only

[root@kickstart ~]# ls /data/www/Cent6.7
CentOS_BuildTag  GPL       Packages                  RPM-GPG-KEY-CentOS-6           RPM-GPG-KEY-CentOS-Testing-6
EFI              images    RELEASE-NOTES-en-US.html  RPM-GPG-KEY-CentOS-Debug-6     TRANS.TBL
EULA             isolinux  repodata                  RPM-GPG-KEY-CentOS-Security-6


9、Nginx配置

user nginx nginx;
worker_processes 4;
error_log /var/log/nginx/error.log notice;
worker_rlimit_nofile 65535;

events
{
    use epoll;
    worker_connections 65535;
}

http {
    include       mime.types;
    default_type  application/octet-stream;

    log_format  main  ‘$remote_addr - $remote_user [$time_local] "$request" ‘
                      ‘$status $body_bytes_sent "$http_referer" ‘
                      ‘"$http_user_agent" "$http_x_forwarded_for"‘;

    sendfile    on;
    tcp_nopush  on;
    tcp_nodelay on;
    send_timeout        60;
    keepalive_timeout   60;
   
    gzip  on;
    gzip_min_length 1k;
    gzip_buffers 4 32k;
    gzip_comp_level 3;
    gzip_http_version 1.1;
    gzip_types text/plain application/x-javascript text/css text/htm application/xml;
    gzip_vary on;

    include vhosts/*.conf;
}



[root@kickstart ~]# mkdir /etc/nginx/vhosts

[root@kickstart ~]# vim /etc/nginx/vhosts/mirror.conf

server {
    listen      80;
    server_name 20.0.0.10;
    index index.html index.htm index.jsp;
    server_tokens       off;
    access_log  /var/log/nginx/mirror.access.log main;

    location / {
    root        /data/www;
    autoindex on;
    autoindex_exact_size off;
    autoindex_localtime on;
    }
}

技术分享



10、配置PXE引导

[root@kickstart ~]# yum install syslinux -y
[root@kickstart ~]# cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/
[root@kickstart ~]# cp -a /data/www/Cent6.7/isolinux/* /var/lib/tftpboot/
[root@kickstart ~]# ls /var/lib/tftpboot/
boot.cat  grub.conf   isolinux.bin  memtest     splash.jpg  vesamenu.c32
boot.msg  initrd.img  isolinux.cfg  pxelinux.0  TRANS.TBL   vmlinuz


[root@kickstart ~]# cd /var/lib/tftpboot/
[root@kickstart tftpboot]# mkdir pxelinux.cfg

[root@kickstart tftpboot]# cp /data/www/Cent6.7/isolinux/isolinux.cfg pxelinux.cfg/default


11、创建ks.cfg配置文件

[root@kickstart ~]# mkdir /data/www/config

[root@kickstart ~]# vim /data/www/config/ks.cfg

# Kickstart file automatically generated by anaconda.

#version=RHEL6
install
url --url="http://20.0.0.10/CentOS6.7/"
lang en_US.UTF-8
keyboard us
network --bootproto=dhcp --device=eth0 --onboot=on
# Root passwd
rootpw redhat
firewall --disabled
auth --useshadow --enablemd5
selinux --disabled
timezone Asia/Shanghai
bootloader --location=mbr --driveorder=sda --append="nomodeset crashkernel=auto rhgb quiet"
firstboot --disable
logging --level=info
zerombr
skipx

#part /boot --fstype=ext4 --asprimary --size=200
#part swap --asprimary --size=512
#part / --fstype=ext4 --grow --asprimary --size=200

clearpart --all --initlabel
part /boot --fstype=ext4 --size=200
part swap --fstype=swap --size=2048
part / --fstype=ext4 --grow --size=1
reboot

%packages
@development
%end



12、修改/var/lib/tftpboot/pxelinux.cfg/default

[root@kickstart ~]# vim /var/lib/tftpboot/pxelinux.cfg/default

default linux

#prompt 1
timeout 600

display boot.msg

menu background splash.jpg
menu title Welcome to CentOS 6.7!
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=http://20.0.0.10/config/ks.cfg
label vesa
  menu label Install system with ^basic video driver
  kernel vmlinuz
  append initrd=initrd.img 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@kickstart ~]# /etc/init.d/xinetd restart
Stopping xinetd:                                           [  OK  ]
Starting xinetd:                                           [  OK  ]


13、新建虚拟机

技术分享











kickstart自动装机

标签:kickstart

原文地址:http://7424593.blog.51cto.com/7414593/1812719

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!