设为首页 收藏本站
查看: 546|回复: 0

[经验分享] PXE安装Centos 6.6 x86-64 basic server

[复制链接]

尚未签到

发表于 2018-10-22 11:36:29 | 显示全部楼层 |阅读模式
#!/bin/bash  
######################################################################
  
#0、Centos 6.6 x86_64
  
#设置服务器IP地址为192.168.11.250
  
#确保该网络中无DHCP服务
  
#且192.168.11.100 - 200 无机器使用
  
######################################################################
  
#1、配置yum源,安装TFTP、FTP、DHCP服务
  
######################################################################
  
#!/bin/bash
  
mkdir /mnt/cdromxxx
  
umount /dev/sr0
  
mount /dev/sr0 /mnt/cdromxxx
  
mkdir /etc/yum.repos.d/bak
  
mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/bak/
  
echo '[local]
  
name=local
  
baseurl=file:///mnt/cdromxxx
  
gpgcheck=0
  
enabled=1
  
'>/etc/yum.repos.d/local.repo
  
yum install dhcp tftp-server vsftpd syslinux -y
  
rm -rf /etc/yum.repos.d/local.repo
  
mv /etc/yum.repos.d/bak/* /etc/yum.repos.d/
  
rm -rf /etc/yum.repos.d/bak
  
umount /dev/sr0
  
rm -rf /mnt/cdromxxx
  
######################################################################
  
#2、配置DHCP服务
  
######################################################################
  
#!/bin/bash
  
echo 'ddns-update-style interim;
  
ignore client-updates;
  
option space PXE;
  
option PXE.mtftp-ip    code 1 = ip-address;
  
option PXE.mtftp-cport code 2 = unsigned integer 16;
  
option PXE.mtftp-sport code 3 = unsigned integer 16;
  
option PXE.mtftp-tmout code 4 = unsigned integer 8;
  
option PXE.mtftp-delay code 5 = unsigned integer 8;
  
option arch code 93 = unsigned integer 16;
  
class "pxeclients" {
  
   match if substring (option vendor-class-identifier, 0, 9) = "PXEClient";
  
   next-server 192.168.11.250;
  
   if option arch = 00:02 {
  
        filename "ia64/elilo.efi";
  
   } else {
  
        filename "legacy/pxelinux.0";
  
   }
  
}
  
#next-server 192.168.11.250;   #指定TFTP服务器的地址
  
#filename "legacy/pxelinux.0";     #指定PXE引导程序的文件名
  
subnet 192.168.11.0 netmask 255.255.255.0 {
  
   option routers 192.168.11.1;
  
   option subnet-mask 255.255.255.0;
  
   range 192.168.11.100 192.168.11.200;
  
   option broadcast-address 192.168.11.255;
  
}
  
'>/etc/dhcp/dhcpd.conf
  
/etc/init.d/dhcpd restart
  
chkconfig dhcpd on
  
######################################################################
  
#3、配置FTP服务
  
######################################################################
  
mkdir /var/ftp/pub/isoxxx
  
mount /dev/sr0 /var/ftp/pub/isoxxx
  
echo 'mount /dev/sr0 /var/ftp/pub/isoxxx'>>/etc/rc.local
  
echo '#platform=x86, AMD64, 或 Intel EM64T
  
#version=DEVEL
  
# Firewall configuration
  
firewall --enabled --ssh
  
# Install OS instead of upgrade
  
install
  
# Use network installation
  
url --url="ftp://192.168.11.250/pub/isoxxx"
  
# Root password
  
rootpw --iscrypted $1$2B0mua0h$2VLnGqw4bvQpvEHuBhObP.
  
# System authorization information
  
auth  --useshadow  --passalgo=sha512
  
# Use text mode install
  
text
  
# System keyboard
  
keyboard us
  
# System language
  
lang en_US
  
# SELinux configuration
  
selinux --permissive
  
# Do not configure the X Window System
  
skipx
  
# Installation logging level
  
logging --level=info
  
# Reboot after installation
  
reboot
  
# System timezone
  
timezone --isUtc Asia/Shanghai
  
# System bootloader configuration
  
bootloader --location=mbr
  
# Clear the Master Boot Record
  
zerombr
  
# Partition clearing information
  
clearpart --all
  
# Disk partitioning information
  
part / --fstype="ext4" --grow --size=1
  

  
%packages
  
@base
  
@console-internet
  
@core
  
@debugging
  
@directory-client
  
@hardware-monitoring
  
@java-platform
  
@large-systems
  
@network-file-system-client
  
@performance
  
@perl-runtime
  
@server-platform
  
@server-policy
  
@workstation-policy
  
pax
  
oddjob
  
sgpio
  
device-mapper-persistent-data
  
samba-winbind
  
certmonger
  
pam_krb5
  
krb5-workstation
  
perl-DBD-SQLite
  
%end
  

  
%pre
  
%end
  

  
%post
  
%end
  
'>/var/ftp/pub/ks.cfg
  
/etc/init.d/vsftpd restart
  
chkconfig vsftpd on
  
######################################################################
  
#4、配置TFTP服务
  
######################################################################
  
sed -i '8 s/^/        disable=no\n/' /etc/xinetd.d/tftp
  
mkdir /var/lib/tftpboot/legacy
  
cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/legacy
  
cp /var/ftp/pub/isoxxx/images/pxeboot/{initrd.img,vmlinuz} /var/lib/tftpboot/legacy
  
cp /var/ftp/pub/isoxxx/isolinux/{boot.msg,vesamenu.c32} /var/lib/tftpboot/legacy
  
mkdir /var/lib/tftpboot/legacy/pxelinux.cfg
  
echo 'default linux
  
prompt 1
  
timeout 5
  
display boot.msg
  
F1 boot.msg
  
F2 options.msg
  
F3 general.msg
  
F4 param.msg
  
F5 rescue.msg
  
label linux
  
kernel vmlinuz
  
append ks=ftp://192.168.11.250/pub/ks.cfg  initrd=initrd.img ksdevice=eth0
  
'>/var/lib/tftpboot/legacy/pxelinux.cfg/default
  
/etc/init.d/xinetd restart
  
chkconfig tftp on
  
chkconfig xinetd on
  
######################################################################
  
#5、更改系统安全设置
  
######################################################################
  
setenforce 0
  
echo '# This file controls the state of SELinux on the system.
  
# SELINUX= can take one of these three values:
  
#       enforcing - SELinux security policy is enforced.
  
#       permissive - SELinux prints warnings instead of enforcing.
  
#       disabled - SELinux is fully disabled.
  
SELINUX=permissive
  
# SELINUXTYPE= type of policy in use. Possible values are:
  
#       targeted - Only targeted network daemons are protected.
  
#       strict - Full SELinux protection.
  
SELINUXTYPE=targeted'>/etc/sysconfig/selinux
  
/etc/init.d/iptables stop
  
chkconfig iptables off



运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-624934-1-1.html 上篇帖子: 多服务器mysql自动化执行sql 下篇帖子: 关于:zabbix server is not running 解决办法
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表