kickstart ---无人值守安装
kickstart 实战
http://man.linuxde.net/download/CentOS_6_9镜像
安装:
关闭防火墙
且在编辑虚拟网络的vnet8中要取消使用本地dhcp项
1.yum -y install dhcp
[root@centos6 ~ ]#vim /etc/dhcp/dhcpd.conf
#
# DHCP Server Configuration file.
# see /usr/share/doc/dhcp*/dhcpd.conf.sample
# see 'man 5 dhcpd.conf'
#
subnet 192.168.5.0 netmask 255.255.255.0 {
range 192.168.5.100 192.168.5.120;
option routers 192.168.5.1;
option subnet-mask 255.255.255.0;
default-lease-time 21600;
max-lease-time 43200;
next-server 192.168.5.103;
filename "/pxelinux.0";
}
[root@centos6 ~ ]#vim /etc/sysconfig/dhcpd
# Command line options here
DHCPDARGS=eth0
[root@centos6 ~ ]#/etc/init.d/dhcpd start
2.[root@centos6 ~ ]#yum -y install tftp-server
[root@centos6 ~ ]#cat -n /etc/xinetd.d/tftp
14 disable = yes
只改第14行的yes为no
[root@centos6 ~ ]#sed -i '14s%yes%no%' /etc/xinetd.d/tftp
[root@centos6 ~ ]#/etc/init.d/xinetd restart
Stopping xinetd: [FAILED]
Starting xinetd: [ OK
3.[root@centos6 ~ ]#yum install httpd -y
[root@centos6 ~ ]#grep -n ServerName /etc/httpd/conf/httpd.conf
265:# ServerName gives the name and port that the server uses to identify itself.
276:#ServerName www.example.com:80
283:# ServerName directive.
1006:# ServerName dummy-host.example.com
在277行插入一条如下
[root@centos6 ~ ]#sed -i "277i ServerName 127.0.0.1:80" /etc/httpd/conf/httpd.conf
[root@centos6 ~ ]#/etc/init.d/httpd start
[root@centos6 ~ ]#netstat -tunlp|grep 80
tcp 0 0 :::80 :::* LISTEN 9474/nginx
看上面是80端口的里程起不来,那看一下进程号,原来是被nginx占用了,直接杀掉该进程号
[root@centos6 ~ ]#kill 9474
[root@centos6 ~ ]#mkdir /var/www/html/CentOS-6.9
[root@centos6 ~ ]#mount /dev/cdrom /var/www/html/CentOS-6.9
在浏览器输入ip/并刚才挂载的目录名,效果如下图

4.安装启动引导程序/及pxe引导配置
[root@centos6 ~ ]#yum -y install syslinux
[root@centos6 ~ ]#cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/(tftp根目
把菜单(启动相关的程序)复制过去
[root@centos6 ~ ]#cp -a /var/www/html/CentOS-6.9/isolinux/* /var/lib/tftpboot/
新建pxelinux.cfg目录,存放客户端配置文件
[root@centos6 ~ ]#mkdir -p /var/lib/tftpboot/pxelinux.cfg
[root@centos6 ~ ]#cp /var/www/html/CentOS-6.9/isolinux/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default
如果你想用网络安装方式,那么此时就可以安装了(不要挂载镜像)
5.pxe配置文件default解析
6.创建自动应答文件ks.cfg
[root@centos6 ~ ]# grub-crypt
Password:181818
Retype password:181818
$6$X20eRtuZhkHznTb4$dK0BJByOSAWSDD8jccLVFz0CscijS9ldMWwpoCw/ZEjYw2BTQYGWlgKsn945fFTjRC658UXjuocwJbAjVI5D6/
[root@centos6 ~ ]#mkdir /var/www/html/ks_config
# Kickstart Configurator for CentOS 6.7 by yao zhang
[root@centos6 ~ ]#vim /var/www/html/ks_config/CentOS-6.9-ks.cfg
install
url --url="http://192.168.5.103/CentOS-6.9/"
text
lang en_US.UTF-8
keyboard us
zerombr
bootloader --location=mbr --driveorder=sda --append="crashkernel=auto rhgb qui
et"
network --bootproto=dhcp --device=eth0 --onboot=yes --noipv6 --hostname=CentOS
6
timezone --utc Asia/Shanghai
authconfig --enableshadow --passalgo=sha512
rootpw --iscrypted $6$X20eRtuZhkHznTb4$dK0BJByOSAWSDD8jccLVFz0CscijS9ldMWwpoC
w/ZEjYw2BTQYGWlgKsn945fFTjRC658UXjuocwJbAjVI5D6/
clearpart --all --initlabel
part /boot --fstype=ext4 --asprimary --size=200
part swap --size=1024
part / --fstype=ext4 --grow --asprimary --size=200
firstboot --disable
selinux --disabled
firewall --disabled
logging --level=info
reboot
%packages
@base
@compat-libraries
@debugging
@development
tree
nmap
sysstat
lrzsz
dos2unix
telnet
%post
wget -O /tmp/optimization.sh http://192.168.5.103/ks_config/optimization.sh &>
/dev/null
/bin/sh /tmp/optimization.sh
%end
7.开机优化脚本
[root@centos6 ~ ]#vim /var/www/html/ks_config/optimization.sh
#!/bin/bash
##############################################################
# File Name: /var/www/html/ks_config/optimization.sh
# Version: V1.0
# Author: yao zhang
# Organization: www.zyops.com
# Created Time : 2015-12-03 15:23:08
# Description: Linux system initialization
##############################################################
./etc/init.d/functions
Ip=192.168.5.103
Port=80
ConfigDir=ks_config
# Judge Http server is ok?
# Defined result function
function Msg(){
if [ $? -eq 0 ];then
action "$1" /bin/true
else
action "$1" /bin/false
fi
}
# Defined IP function
function ConfigIP(){
Suffix=`ifconfig eth0 |awk -F"[ .]+" 'NR==2 {print $6}'`
cat >/etc/sysconfig/network-scripts/ifcfg-eth0 <<-END
DEVICE=eth0
TYPE=Ethernet
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=none
IPADDR=10.0.0.$Suffix
PREFIX=24
GATEWAY=10.0.0.2
DNS1=10.0.0.2
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME="System eth0"
END
Msg "config eth0"
}
# Defined Yum source Functions
Msg "YUM source"
#Defined add Ordinary users Functions
function AddUser(){
useradd hua &> /dev/null &&\
echo "181818"|passwd --stdin hua &> /dev/null &&\
sed -i '98a hua ALL=(ALL) NOPASSWD:all' /etc/sudoers &&\
visudo -c &> /dev/null
Msg "AddUser hua"
}
[ -f "/etc/issue" ] && >/etc/issue
Msg "Hide issue"
[ -f "/etc/issue.net" ] && > /etc/issue.net
Msg "Hide issue.net"
}
# Defined OPEN FILES Functions
function openfiles(){
[ -f "/etc/security/limits.conf" ] && {
echo '* - nofile 65535' >> /etc/security/limits.conf
Msg "open files"
}
}
# Defined Kernel parameters Functions
function kernel(){
KernelDir=/etc
[ -f "$KernelDir/sysctl.conf" ] && /bin/mv $KernelDir/sysctl.conf{,.or
i}
wget -O $KernelDir/sysctl.conf http://$Ip:$Port/$ConfigDir/sysctl.conf
&>/dev/null
Msg "Kernel config"
}
# Defined System Startup Services Functions
function boot(){
for oldboy in `chkconfig --list|grep "3:on"|awk '{print $1}'|grep -vE
"crond|network|rsyslog|sshd|sysstat"`
do
chkconfig $oldboy off
done
Msg "BOOT config"
}
# Defined Time Synchronization Functions
function Time(){
echo "#time sync by zhangyao at $(date +%F)" >>/var/spool/cron/root
echo '*/5 * * * * /usr/sbin/ntpdate time.nist.gov &>/dev/null' >>/var/
spool/cron/root
Msg "Time Synchronization"
}
# Defined main Functions
function main(){
ConfigIP
yum
HideVersion
openfiles
kernel
boot
Time
}
main
8.整合编辑default配置文件
[root@centos6 ~ ]#vim /var/lib/tftpboot/pxelinux.cfg/default
default ks
prompt 0
label ks
kernel vmlinuz
append initrd=initrd.img ks=http://192.168.5.103/ks_config/CentOS-6.9-ks.cfg
ksdevice=eth0
[root@centos6 ~ ]#curl http://192.168.5.103/ks_config/CentOS-6.9-ks.cfg 测试下刚才文件有没有对,如果出来的结果是/var/www/html/ks_config/CentOS-6.9-ks.cfg 的内容说明ok
至此一切准备工作就做完了
[root@centos6 ~ ]#netstat -ntulp|egrep '80|67|69'
确认有没有80端口,67,69端口

9 无人值守自动安装
此时启动空白的无人机就行了
[root@centos6 ~ ]#tailf /var/log/messages 可以观看日志过程
kickstart ---无人值守安装的更多相关文章
- KickStart 无人值守安装系统
一.简介 1.1 什么是PXE PXE(Pre-boot Execution Environment,预启动执行环境)是由Intel公司开发的最新技术,工作于Client/Server的网络模式,支持 ...
- [转]CentOS 6.4下PXE+Kickstart无人值守安装操作系统
一.简介 1.1 什么是PXE PXE(Pre-boot Execution Environment,预启动执行环境)是由Intel公司开发的最新技术,工作于Client/Server的网络模式,支持 ...
- 烂泥:kickstart无人值守安装CentOS6.5
本文由秀依林枫提供友情赞助,首发于烂泥行天下. 在本次实验进行之前,首先我们要把公司的网络环境进行介绍. 注意这个网络拓扑图,也是生产环境的一个实例.同时服务器192.168.1.214已关闭ipta ...
- CentOS6 PXE+Kickstart无人值守安装
一.简介 1.1 什么是PXE PXE(Pre-boot Execution Environment,预启动执行环境)是由Intel公司开发的最新技术,工作于Client/Server的网络模式,支持 ...
- CentOS 6.4下PXE+Kickstart无人值守安装操作系统 转
一.简介 1.1 什么是PXE PXE(Pre-boot Execution Environment,预启动执行环境)是由Intel公司开发的最新技术,工作于Client/Server的网络模式,支持 ...
- RHEL7下PXE+NFS+Kickstart无人值守安装操作系统
RHEL7下PXE+NFS+Kickstart无人值守安装操作系统 1.配置yum源 vim /etc/yum.repos.d/development.repo [development] name= ...
- RHEL7下PXE+Apache+Kickstart无人值守安装操作系统
RHEL7下PXE+Apache+Kickstart无人值守安装操作系统 1.配置yum源 vim /etc/yum.repos.d/development.repo [development] na ...
- CentOS 6.6下PXE+Kickstart无人值守安装操作系统
一.简介 1.1 什么是PXE PXE(Pre-boot Execution Environment,预启动执行环境)是由Intel公司开发的最新技术,工作于Client/Server的网络模式,支持 ...
- 【转载】CentOS 6.4下PXE+Kickstart无人值守安装操作系统
[转载]CentOS 6.4下PXE+Kickstart无人值守安装操作系统 转自:CentOS 6.4下PXE+Kickstart无人值守安装操作系统 - David_Tang - 博客园 http ...
- Centos下PXE+Kickstart无人值守安装操作系统
一.简介 1.1 什么是PXE PXE(Pre-boot Execution Environment,预启动执行环境)是由Intel公司开发的最新技术,工作于Client/Server的网络模式,支持 ...
随机推荐
- Android 读写权限,已经授权情况下,仍然(Permission denied)
首次安装APP,获取读写权限以后, 当读取文件时候,仍然会遇见(Permission denied)错误,解决方案是杀掉APP,重新打开APP即可. 应该属于部分版本系统的bug,直到APP所有的pr ...
- SATA主机协议的FPGA实现之准备工作
SATA主机协议的FPGA实现之准备工作 从2月中旬准备开始,经过3个月的奋战,我的又一个项目--基于FPGA的固态硬盘读写控制电路,已经基本实现.由于实用资料的匮乏,以及项目本身颇具挑战性,这个 ...
- Sublime Text3 运行 PHP 文件
在 Zend Studio(12.5)下可以通过 Run(Ctrl + F11)把 PHP 程序的执行结果通过 Debug Output 显示在 IDE 中,这样比开启 Server,再打开浏览器执行 ...
- 【Git】git pull和git pull --rebase的使用
git pull = git fetch + git mergegit pull --rebase = git fetch + git rebase 现在来看看git merge和git rebase ...
- HashMap中capacity、loadFactor、threshold、size等概念的解释<转>
最近在看HashMap的源码,有很多概念都很模糊,今天写了一个测试例子,加深对这几个概念的理解,并演示了扩容及树化的过程(见下篇博文:). 注:本文基于JDK 1.8 HashMap的结构 约定 约 ...
- Mysql数据按天分区,定期删除
需求: 1.日志表需要按天分区 2.只保留一个月数据 方案: 1.创建两个事件,一个事件生成未来需要的分区,另一个事件定期检查过期数据(移除分区) 2.创建事件每小时执行一次,删除事件每天执行一次 3 ...
- windows下JDK环境配置与Android SDK环境配置
一.JDK环境配置1.配置变量名:JAVA_HOME变量值:jdk安装的绝对路径. 变量名:Path(在系统变量中找到并选中Path点击下面的编辑按钮,不要删除原本变量值中的任何一个字母,在这个变量值 ...
- 微信OAuth2.0网页授权设置一个域名需多个域名使用的问题
最近遇到一个问题,一个微信公众号,需要在多个域名上使用OAuth2.0网页授权,但微信OAuth2.0网页授权回调域名只能设置一个. 解决办法: 通过多一次的跳转,解决了微信限制回调域名只能设置一个的 ...
- python3命令行ImportError: No module named 'xxxx'的问题
主要原因:启动脚本不在当前目录下,无法找到上一层 在pycharm写好的脚本程序,在命令行无法运行,报错 Traceback (most recent call last): File "t ...
- stl综合
区别: List封装了链表,Vector封装了数组, list和vector得最主要的区别在于vector使用连续内存存储的,他支持[]运算符,而list是以链表形式实现的,不支持[]. Vector ...