加入收藏 | 设为首页 | 会员中心 | 我要投稿 应用网_丽江站长网 (http://www.0888zz.com/)- 科技、建站、数据工具、云上网络、机器学习!
当前位置: 首页 > 站长资讯 > 外闻 > 正文

酸爽!我用这套无人值守安装系统瞬间搞定上百台服务器

发布时间:2018-12-19 21:17:06 所属栏目:外闻 来源:DBAplus社群
导读:副标题#e# 一、前言 为啥要用无人值守安装系统?很简单的答案,就是方便日常工作。 常规装系统的办法有哪些? 光盘安装系统:一个服务器DVD内置光驱百千块,百台服务器都配光驱就浪费了,因为一台服务器也就开始装系统能用的上,以后用的机会屈指可数。 U盘安

ks.cfg

  1. #version=DEVEL 
  2.   install #表示是安装系统 
  3.   # System authorization information 
  4.   auth --enableshadow --passalgo=sha512   #启用加密 
  5.   text        #文本安装 
  6.   #graphical  #图形化安装,注释掉 
  7.   # Use graphical install 
  8.   url --url=http://192.168.1.1/CentOS-7.5/    #用于读取系统的url 
  9.   # Firewall configuration 
  10.   firewall --disabled #关闭防火墙 
  11.   # SELinux configuration 
  12.   selinux --disabled  #关闭selinux 
  13.   # Run the Setup Agent on first boot 
  14.   firstboot --disable #关闭第一次启动后的安装配置 
  15.   ignoredisk --only-use=sda   #默认第一块启动盘 
  16.   # Keyboard layouts 
  17.   keyboard --vckeymap=us --xlayouts='us'  #键盘 
  18.   # System language 
  19.   lang en_US.UTF-8        #语言和编码 
  20.   # Network information 
  21.   network  --bootproto=dhcp --device=ens33 --onboot=off --ipv6=auto --no-activate #安装时配置网卡地址 
  22.   network  --hostname=localhost.localdomain   #安装时配置主机名 
  23.   # System timezone 
  24.   timezone Asia/Shanghai      #时区 
  25.   # System bootloader configuration 
  26.   bootloader --append=" crashkernel=auto" --location=mbr --boot-drive=sda #指定引导装载程序怎样被安装 
  27.   # Root password 
  28.   rootpw --iscrypted $1$vIP9ZiKA$ryz7cg0/2NwoOYVnHhHCF1   #root密码 
  29.   # System services 
  30.   #services --enabled="chronyd" 
  31.   # Do not configure the X Window System 
  32.   skipx       #不使用图形界面 
  33.   # Accept license 
  34.   eula --agreed       #同意最终用户许可协议 
  35.   # Reboot after installation 
  36.   reboot  #安装后重启 
  37.   # Disk partitioning information 
  38.   %include /tmp/partition.ks 
  39.    
  40.   %pre    #系统安装前所执行的脚本 
  41.   #!/bin/sh 
  42.   # 创建分区,如果分区比较简单,可以放在上面,分区比较多的,可以像这样写脚本放在%pre块内 
  43.   act_mem=$(cat /proc/meminfo | grep MemTotal | awk '{printf("%d",$2/1024)}') 
  44.   echo "" > /tmp/partition.ks 
  45.   echo "clearpart --all --initlabel" >> /tmp/partition.ks 
  46.   echo 'part pv.767 --fstype="lvmpv" --ondisk=sda --size=1 --grow' >> /tmp/partition.ks..ec01]oho 'part biosboot --fstype="biosboot" --ondisk=sda --size=2' >> /tmp/partition.ks 
  47.   echo 'part /boot --fstype="ext4" --ondisk=sda --size=512' >> /tmp/partition.ks 
  48.   echo 'volgroup rhel --pesize=4096 pv.767' >> /tmp/partition.ks 
  49.   echo 'logvol /data  --fstype="ext4" --size=1 --grow --name=data --vgname=rhel' >> /tmp/partition.ks 
  50.   echo 'logvol /  --fstype="ext4" --size=102400 --name=root --vgname=rhel' >> /tmp/partition.ks 
  51.   if [ ${act_mem} -ge 65536  ] 
  52.   then 
  53.   echo "logvol swap --fstype=swap --name=swap --vgname=rhel --size=65536" >> /tmp/partition.ks 
  54.   elif [ ${act_mem} -le 8192 ] 
  55.   then 
  56.   echo "logvol swap --fstype=swap --name=swap --vgname=rhel --size=${act_mem}" >> /tmp/partition.ks 
  57.   else 
  58.   echo "logvol swap --fstype=swap --name=swap --vgname=rhel --size=$(expr ${act_mem} / 2)" >> /tmp/partition.ks 
  59.   fi 
  60.   %end 
  61.    
  62.   %post       #系统安装后所执行的脚本 
  63.    
  64.   #Sshd config 
  65.   sed -i 's/#PermitRootLogin yes/PermitRootLogin no/' /etc/ssh/sshd_config 
  66.   ...... 
  67.   wget -O /tmp/ip.txt http://192.168.1.1/ks_cfg/ip.txt 
  68.   wget -O /tmp/ip.sh http://192.168.1.1/ks_cfg/ip.sh 
  69.   /bin/sh /tmp/ip.sh 
  70.   wget -O /tmp/zabbix_agent.sh http://http://192.168.1.1/ks_cfg/zabbix_agent.sh 
  71.   /bin/sh /tmp/zabbix_agent.sh 
  72.   ...... 
  73.   %end 
  74.    
  75.   %packages       #安装包,%packages块指定以下都是需要进行安装的包。 
  76.   @base       #最小化安装需要@base和@core。@后写的是包组 
  77.   @console-internet 
  78.   @core 
  79.   autoconf    #没有任何前缀的表示需要安装的包 
  80.   chrony 
  81.   expect 
  82.   gcc 
  83.   gcc-c++ 
  84.   ...... 
  85.   %end        #最后需要用%end结尾 
  86.    
  87.   %addon com_redhat_kdump --enable --reserve-mb='auto' 
  88.    
  89.   %end 

(编辑:应用网_丽江站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

热点阅读