KICKSTART无人值守安装
一, 安装DHCP
yum -y install dhcp
二, 配置dhcp
1 # 2 # DHCP Server Configuration file. 3 # see /usr/share/doc/dhcp*/dhcpd.conf.sample 4 # see 'man 5 dhcpd.conf' 5 6 subnet 10.0.0.0 netmask 255.255.255.0 { 7 8 range 10.0.0.206 10.0.0.240; 9 10 option subnet-mask 255.255.255.0; 11 12 default-lease-time 21600; 13 14 max-lease-time 43200; 15 16 next-server 10.0.0.70; 17 18 filename "/pxelinux.0"; 19 20 }
启动 dhcp
/etc/init.d/dhcpd start
三,安装tftp
yum -y install tftp-server
四,配置TFTP
1 # default: off 2 # description: The tftp server serves files using the trivial file transfer \ 3 # protocol. The tftp protocol is often used to boot diskless \ 4 # workstations, download configuration files to network-aware printers, \ 5 # and to start the installation process for some operating systems. 6 service tftp 7 { 8 socket_type = dgram 9 protocol = udp 10 wait = yes 11 user = root 12 server = /usr/sbin/in.tftpd 13 server_args = -s /var/lib/tftpboot 14 disable = no 15 per_source = 11 16 cps = 100 2 17 flags = IPv4 18 }
启动xinetd.d
/etc/init.d/xinetd
五, 安装http服务
nginx安装
1 . /etc/rc.d/init.d/functions 2 nginx_name="nginx-1.14.0.tar.gz" 3 Nginx_Dir="nginx-1.14.0" 4 Nginx_Install_Dir="/application/nginx-1.14.0" 5 Install_Nginx(){ 6 #跟新源 7 wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo 8 # 安装依赖包 9 yum install -y pcre pcre-devel openssl openssl-devel gcc make gcc-c++ 10 if [ -f $nginx_name ] 11 then 12 echo 'nginx need have' 13 # t解压文件 14 tar zxf ${nginx_name} && cd ${Nginx_Dir} 15 # 添加僵尸用户 16 useradd nginx -s /sbin/nologin -M -u 664 17 # 编译安装 18 ./configure --user=nginx --group=nginx --prefix=${Nginx_Install_Dir} --with-http_stub_status_module --with-http_ssl_module 19 [ $(echo $?) -eq 0 ] && make && make install 20 [ $(echo $?) -eq 0 ] && action nginx安装 /bin/true || action nginx安装 /bin/false 21 #创建软链接 22 ln -s ${Nginx_Install_Dir} /application/nginx 23 fi 24 } 25 Install_Nginx
配置nginx.conf
/application/nginx-1.14.0/conf/nginx.conf
1 worker_processes 1; 2 events { 3 worker_connections 1024; 4 } 5 http { 6 include mime.types; 7 default_type application/octet-stream; 8 sendfile on; 9 keepalive_timeout 65; 10 server { 11 listen 80; 12 server_name localhost; 13 location / { 14 autoindex on; 15 root html; 16 index index.html index.htm; 17 } 18 error_page 500 502 503 504 /50x.html; 19 location = /50x.html { 20 root html; 21 } 22 } 23 }
启动服务
/application/nginx/sbin/nginx
netstat -lntup |grep 80
六,挂载光盘
cd /application/nginx-1.14.0/html && \rm *.html mkdir -p /application/nginx-1.14.0/html/iso/
mount /dev/cdrom /application/nginx-1.14.0/html/iso/
七,配置支持PXE的启动程序
yum -y install syslinux
cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/
cp -a /application/nginx-1.14.0/html/isolinux/* /var/lib/tftpboot/
八,尝试启动
显示这个为正确
九,配置自动安装
mkdir /application/nginx-1.14.0/html/ks_config -p
cat /application/nginx-1.14.0/html/ks_config/CentOS-6.9-ks.cfg
1 install 2 url --url="http://10.0.0.70/ios/" 3 text 4 lang en_US.UTF-8 5 keyboard us 6 zerombr 7 bootloader --location=mbr --driveorder=sda --append="crashkernel=auto rhgb quiet" 8 network --bootproto=dhcp --device=eth0 --onboot=yes --noipv6 --hostname=CentOS6 9 timezone --utc Asia/Shanghai 10 authconfig --enableshadow --passalgo=sha512 11 rootpw --iscrypted $6$V2FYo1/vjuD/Fh5x$cbxS3NgXIkLPdk7k.TJQN/HAaRHDW3qxIRlOIbxBF5eT0zmTgKNS.RgeuV/ZMAoeb43T4gLajio/Vpz1f/NGc0 12 clearpart --all --initlabel 13 part /boot --fstype=ext4 --asprimary --size=200 14 part swap --size=768 15 part / --fstype=ext4 --grow --asprimary --size=200 16 firstboot --disable 17 selinux --disabled 18 firewall --disabled 19 logging --level=info 20 reboot 21 %packages 22 @base 23 @compat-libraries 24 @debugging 25 @development 26 tree 27 nmap 28 sysstat 29 lrzsz 30 dos2unix 31 telnet 32 %post 33 wget -O /tmp/linux.sh http://10.0.0.70/ks_config/linux.sh &>/dev/null 34 /bin/sh /tmp/linux.sh 35 %end
配置启动配置
cat /var/lib/tftpboot/pxelinux.cfg/default
1 [root@jumpserver ks_config]# cat /var/lib/tftpboot/pxelinux.cfg/default 2 default ks 3 prompt 0 4 timeout 600 5 6 display boot.msg 7 8 menu background splash.jpg 9 menu title Welcome to CentOS 6.9! 10 menu color border 0 #ffffffff #00000000 11 menu color sel 7 #ffffffff #ff000000 12 menu color title 0 #ffffffff #00000000 13 menu color tabmsg 0 #ffffffff #00000000 14 menu color unsel 0 #ffffffff #00000000 15 menu color hotsel 0 #ff000000 #ffffffff 16 menu color hotkey 7 #ffffffff #ff000000 17 menu color scrollbar 0 #ffffffff #00000000 18 19 label linux 20 menu label ^Install or upgrade an existing system 21 menu default 22 kernel vmlinuz 23 append initrd=initrd.img 24 label vesa 25 menu label Install system with ^basic video driver 26 kernel vmlinuz 27 append initrd=initrd.img nomodeset 28 label rescue 29 menu label ^Rescue installed system 30 kernel vmlinuz 31 append initrd=initrd.img rescue 32 label local 33 menu label Boot from ^local drive 34 localboot 0xffff 35 label memtest86 36 menu label ^Memory test 37 kernel memtest 38 append - 39 label ks 40 kernel vmlinuz 41 append initrd=initrd.img ks=http://10.0.0.70/ks_config/CentOS-6.9-ks.cfg
优化脚本
1 #!/bin/sh 2 . /etc/init.d/functions 3 ip=10.0.0.250 4 Port=80 5 ConfigDir=ks_config 6 # Judge Http server is ok? 7 PortNum=`nmap $Ip -p $Port 2>/dev/null|grep open|wc -l` 8 [ $PortNum -lt 1 ] && { 9 echo "Http server is bad!" 10 exit 1 11 } 12 # Defined result function 13 function Msg(){ 14 if [ $? -eq 0 ];then 15 action "$1" /bin/true 16 else 17 action "$1" /bin/false 18 fi 19 } 20 # Defined IP function 21 function ConfigIP(){ 22 Suffix=`ifconfig eth0|awk -F "[ .]+" 'NR==2 {print $6}'` 23 cat >/etc/sysconfig/network-scripts/ifcfg-eth0 <<-END 24 DEVICE=eth0 25 TYPE=Ethernet 26 ONBOOT=yes 27 NM_CONTROLLED=yes 28 BOOTPROTO=none 29 IPADDR=10.0.0.$Suffix 30 PREFIX=24 31 GATEWAY=10.0.0.254 32 DNS1=223.5.5.5 33 DEFROUTE=yes 34 IPV4_FAILURE_FATAL=yes 35 IPV6INIT=no 36 NAME="System eth0" 37 END 38 Msg "config eth0" 39 } 40 # Defined Yum source Functions 41 function yum(){ 42 YumDir=/etc/yum.repos.d 43 [ -f "$YumDir/CentOS-Base.repo" ] && cp $YumDir/CentOS-Base.repo{,.ori} 44 wget -O $YumDir/CentOS-Base.repo http://$Ip:$Port/$ConfigDir/CentOS-Base.repo &>/dev/null &&\ 45 wget -O $YumDir/epel.repo http://$Ip:$Port/$ConfigDir/epel.repo &>/dev/null &&\ 46 Msg "YUM source" 47 } 48 # Defined Hide the system version number Functions 49 function HideVersion(){ 50 [ -f "/etc/issue" ] && >/etc/issue 51 Msg "Hide issue" 52 [ -f "/etc/issue.net" ] && > /etc/issue.net 53 Msg "Hide issue.net" 54 } 55 # Defined OPEN FILES Functions 56 function openfiles(){ 57 [ -f "/etc/security/limits.conf" ] && { 58 echo '* - nofile 65535' >> /etc/security/limits.conf 59 Msg "open files" 60 } 61 } 62 # Defined Kernel parameters Functions 63 function kernel(){ 64 KernelDir=/etc 65 [ -f "$KernelDir/sysctl.conf" ] && /bin/mv $KernelDir/sysctl.conf{,.ori} 66 wget -O $KernelDir/sysctl.conf http://$Ip:$Port/$ConfigDir/sysctl.conf &>/dev/null 67 Msg "Kernel config" 68 } 69 # Defined System Startup Services Functions 70 function boot(){ 71 for oldboy in `chkconfig --list|grep "3:on"|awk '{print $1}'|grep -vE "crond|network|rsyslog|sshd|sysstat"` 72 do 73 chkconfig $oldboy off 74 done 75 Msg "BOOT config" 76 } 77 # Defined Time Synchronization Functions 78 function Time(){ 79 echo "#time sync by houzhaoshun at $(date +%F)" >>/var/spool/cron/root 80 echo '*/5 * * * * /usr/sbin/ntpdate time.nist.gov &>/dev/null' >>/var/spool/cron/root 81 Msg "Time Synchronization" 82 } 83 # Defined main Functions 84 function main(){ 85 ConfigIP 86 yum 87 HideVersion 88 openfiles 89 kernel 90 boot 91 Time 92 } 93 main
启动一台没有配置光盘虚拟机,开始安装就完成了
人生就像一滴水,非要落下才后悔!
--kingle