前几天机房上架180台服务器,太多了,使用了cobbler批量安装,具体的看我上代码,我把配置cobbler的命令给堆积起来,也算是个脚本吧,欢迎拍砖指正,下面我上脚本:

  1. #!/bin/bash
  2.  
  3. # 关闭selinux
  4. setenforce
  5. # 关闭firewalld防火墙
  6. systemctl stop firewalld
  7. # 下载阿里云镜像源
  8. wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
  9. # 安装cobbler
  10. yum install cobbler cobbler-web pykickstart httpd dhcp tftp-server -y
  11. # 启动httpd、cobblerd
  12. systemctl start httpd
  13. systemctl start cobblerd
  14. # 检查cobbler配置存在的问题,逐一解决
  15. cobbler check
  16. # 修改/etc/cobbler/settings文件中的server参数的值为提供cobbler服务的主机相应的IP地址或主机名,如server: 192.168.222.129
  17. # 备份原文件
  18. cp /etc/cobbler/settings{,.ori}
  19. sed -i 's/server: 127.0.0.1/server: 192.168.222.129/' /etc/cobbler/settings
  20. # 修改/etc/cobbler/settings文件中的next_server参数的值为提供PXE服务的主机相应的IP地址,如next_server: 192.168.222.129
  21. sed -i 's/next_server: 127.0.0.1/next_server: 192.168.222.129/' /etc/cobbler/settings
  22.  
  23. # 修改/etc/xinetd.d/tftp文件中的disable参数修改为 disable = no
  24. # 备份源文件
  25. cp /etc/xinetd.d/tftp{,.ori}
  26. sed -i 's/disable.*= yes/disable = no/g' /etc/xinetd.d/tftp
  27. # 执行 cobbler get-loaders 命令即可;否则,需要安装syslinux程序包,而后复制/usr/share/syslinux/{pxelinux.,memu.c32}等文件至/var/lib/cobbler/loaders/目录中
  28. cobbler get-loaders
  29. # 修改rsync配置文件
  30. sed -i s/"disable.*= yes"/"disable = no"/g /etc/xinetd.d/rsync
  31. # 开启rsync的服务开机自启动
  32. systemctl enable rsyncd
  33. # 开启rsync的服务
  34. systemctl start rsyncd
  35. # 生成密码来取代默认的密码,更安全
  36. openssl passwd - -salt 'renjunjie' ''
  37. sed -i s/'default_password_crypted:.*'/'default_password_crypted: "$1$renjunji$G7LpR5255qFguHrw7E0KP\/"'/g /etc/cobbler/settings
  38. # 安装cman fence-agents
  39. yum install -y cman fence-agents
  40. # 其他一些没有提示报错的小修改
  41. sed -i 's/manage_dhcp: 0/manage_dhcp: 1/g' /etc/cobbler/settings
  42. sed -i 's/pxe_just_once: 0/pxe_just_once: 1/' /etc/cobbler/settings
  43. systemctl restart cobblerd.service
  44. cobbler check
  45. # 配置dhcp
  46. cat > /etc/dhcp/dhcpd.conf <<EOF
  47. subnet 192.168.222.0 netmask 255.255.255.0 {
  48. option domain-name-servers 223.5.5.5;
  49. option routers 192.168.222.1;
  50. range dynamic-bootp 192.168.222.100 192.168.222.250;
  51. option subnet-mask 255.255.255.0;
  52. next-server $next_server;
  53. default-lease-time ;
  54. max-lease-time ;
  55. }
  56. EOF
  57. # 同步cobbler的配置,可以看到同步干了哪些事
  58. cobbler sync
  59. # 设置开机自启动
  60. systemctl enable dhcpd.service
  61. systemctl enable rsyncd.service
  62. systemctl enable tftp.service
  63. systemctl enable httpd.service
  64. systemctl enable cobblerd.service
  65.  
  66. systemctl restart dhcpd.service
  67. systemctl restart rsyncd.service
  68. systemctl restart tftp.service
  69. systemctl restart httpd.service
  70. systemctl restart cobblerd.service
  71.  
  72. # 挂在镜像
  73. mount /dev/cdrom /mnt
  74. # 导入镜像
  75. cobbler import --path=/mnt/ --name=CentOS-7.0-x86_64 --arch=x86_64
  76. # 查看镜像列表
  77. cobbler distro list
  78. # 镜像存放目录,cobbler会将镜像中的所有安装文件拷贝到本地一份,放在/var/www/cobbler/ks_mirror下的CentOS-6.6-x86_64目录下。因此/var/www/cobbler目录必须具有足够容纳安装文件的空间
  79. cd /var/www/cobbler/ks_mirror/
  80. # 配置ks.cfg(使用centos7的镜像的时候,注意下方的ks.cfg要在安装包那里删除掉@server-policy,这玩意在7没有的
  81. cd /var/lib/cobbler/kickstarts/
  82. mkdir CentOS-7.0-x86_64.cfg
  83. cat CentOS-7.0-x86_64.cfg <<EOF
  84. # kickstart template for Fedora and later.
  85. # (includes %end blocks)
  86. # do not use with earlier distros
  87.  
  88. #platform=x86, AMD64, or Intel EM64T
  89. # System authorization information
  90. #auth --useshadow --enablemd5
  91. authconfig --enableshadow --passalgo=sha512
  92. # System bootloader configuration
  93. bootloader --location=mbr --driveorder=sda --append="nomodeset crashkernel=auto rhgb quiet"
  94. # Partition clearing information
  95. clearpart --all --initlabel
  96. # Use text mode install
  97. text
  98. # Firewall configuration
  99. firewall --disabled
  100. # Run the Setup Agent on first boot
  101. firstboot --disable
  102. # System keyboard
  103. keyboard us
  104. # System language
  105. lang en_US
  106. # Use network installation
  107. url --url=$tree
  108. # If any cobbler repo definitions were referenced in the kickstart profile, include them here.
  109. $yum_repo_stanza
  110. # Network information
  111. $SNIPPET('network_config')
  112. # Reboot after installation
  113. reboot
  114. logging --level=info
  115.  
  116. #Root password
  117. rootpw --iscrypted $default_password_crypted
  118. # SELinux configuration
  119. selinux --disabled
  120. # Do not configure the X Window System
  121. skipx
  122. # System timezone
  123. timezone Asia/Shanghai
  124. # Install OS instead of upgrade
  125. install
  126. # Clear the Master Boot Record
  127. zerombr
  128. # Allow anaconda to partition the system as needed
  129. #autopart
  130. part /boot --fstype=ext4 --asprimary --size=
  131. part swap --asprimary --size=
  132. part / --fstype=ext4 --grow --asprimary --size=
  133.  
  134. %pre
  135. $SNIPPET('log_ks_pre')
  136. $SNIPPET('kickstart_start')
  137. $SNIPPET('pre_install_network_config')
  138. # Enable installation monitoring
  139. $SNIPPET('pre_anamon')
  140. %end
  141.  
  142. %packages
  143. @base
  144. @compat-libraries
  145. @core
  146. @debugging
  147. @development
  148. @dial-up
  149. @hardware-monitoring
  150. @performance
  151. sgpio
  152. device-mapper-persistent-data
  153. systemtap-client
  154. tree
  155. lrzsz
  156. telnet
  157. nmap
  158. dos2unix
  159. %end
  160.  
  161. %post --nochroot
  162. $SNIPPET('log_ks_post_nochroot')
  163. %end
  164.  
  165. %post
  166. $SNIPPET('log_ks_post')
  167. # Start yum configuration
  168. $yum_config_stanza
  169. # End yum configuration
  170. $SNIPPET('post_install_kernel_options')
  171. $SNIPPET('post_install_network_config')
  172. $SNIPPET('func_register_if_enabled')
  173. $SNIPPET('download_config_files')
  174. $SNIPPET('koan_environment')
  175. $SNIPPET('redhat_register')
  176. $SNIPPET('cobbler_register')
  177. # Enable post-install boot notification
  178. $SNIPPET('post_anamon')
  179. # Start final steps
  180. $SNIPPET('kickstart_done')
  181. # End final steps
  182. %end
  183. EOF
  184. # 编辑profile,修改关联的ks文件
  185. cobbler profile edit --name=CentOS-7.0-x86_64 --kickstart=/var/lib/cobbler/kickstarts/CentOS-7.0-x86_64.cfg
  186.  
  187. # 同步下cobbler数据,每次修改完都要镜像同步
  188. cobbler sync
  189. # 定制化安装
  190. cobbler system add --name=ren --mac=:0C::2E:FD:0E --profile=CentOS-7.0-x86_64 --ip-address=192.168.222.120 --subnet=255.255.255.0 --gateway=192.168.222.1 --interface=eno16777736 --static= --hostname=linux_node --name-servers="223.5.5.5"
  191. cobbler system list
  192. cobbler sync

一键cobbler批量安装脚本的更多相关文章

  1. Cobbler批量安装Ubuntu/CentOS系统

    2013-07-25    一.安装和修改cobbler配置 1. Cobbler不在CentOS的基本源中,需要导入EPEL源升级软件包, 确保epel-release包的版本为最新,当前最新版本为 ...

  2. 基于CentOS7系统部署cobbler批量安装系统(week3_day5_part1)-技术流ken

    前言 cobbler是一个可以实现批量安装系统的Linux应用程序.它有别于pxe+kickstart,cobbler可以实现同个服务器批量安装不同操作系统版本. 系统环境准备及其下载cobbler ...

  3. 末学者笔记--Centos7系统部署cobbler批量安装系统

      [前言]: cobbler是一个可以实现批量安装系统的Linux应用程序.它有别于pxe+kickstart,cobbler可以实现同个服务器批量安装不同操作系统版本. 系统环境准备及其下载cob ...

  4. cobbler批量安装系统使用详解-技术流ken

    前言 cobbler是一个可以实现批量安装系统的Linux应用程序.它有别于pxe+kickstart,cobbler可以实现同个服务器批量安装不同操作系统版本. 系统环境准备及其下载cobbler ...

  5. cobbler批量安装操作

    打开mirrors.aliyun.com/epel http://mirrors.aliyun.com/epel/epel-release-latest-6.noarch.rpm rpm -ivh h ...

  6. 基于Centos7系统部署cobbler批量安装系统

    前言 cobbler是一个可以实现批量安装系统的Linux应用程序.它有别于pxe+kickstart,cobbler可以实现同个服务器批量安装不同操作系统版本 系统环境的准备及下载cobbler 一 ...

  7. cobbler批量安装系统

    cobbler是一个可以实现批量安装系统的Linux应用程序.它有别于pxe+kickstart,cobbler可以实现同个服务器批量安装不同操作系统版本. 1.系统环境准备及其下载cobbler 1 ...

  8. Cobbler批量安装操作系统

    1,关闭selinux getenforce  查看selinux状态 Disabled 修改/etc/selinux/config 文件 将SELINUX=enforcing改为SELINUX=di ...

  9. 使用cobbler批量安装操作系统(基于Centos7.x )

    1.1 cobbler简介 Cobbler是一个Linux服务器安装的服务,可以通过网络启动(PXE)的方式来快速安装.重装物理服务器和虚拟机,同时还可以管理DHCP,DNS等. Cobbler可以使 ...

随机推荐

  1. IOS 真机调试以及发布应用 1

    参考网站:http://my.oschina.net/u/1245365/blog/196263   Certificates, Identifiers &Profiles 简介 Certif ...

  2. 【行为型】TemplateMethod模式

    模板方法意图是为算法定义好骨架结构,并且其中的某些步骤延迟到子类实现.该模式算是较为简单的一种设计模式.在实际中,应用也较为频繁.模式的类关系图参考如下: 模式的编码结构参考如下: namespace ...

  3. Python新手学习基础之数据结构-序列1

    序列概念 序列,顾名思义就是有顺序的列,在Python里序列类型的数据结构包括字符串,列表和元组.既然都是序列类型,说明他们有很多共通点,他们的每一个元素都可以通过指定的偏移量方式(索引操作)来获得, ...

  4. a标签无disabled属性

    <a class="button">确认</a> 我们经常会用a标签来设置按钮样式,如果点击它跳转页面,那么没有任何问题. 如果绑定了ajax事件,即点击后 ...

  5. 折半插入排序(Binary Insertion Sort)的C语言实现

    原创文章,转载请注明来自钢铁侠Mac博客http://www.cnblogs.com/gangtiexia   折半插入排序(Binary Insertion Sort)的基本思想是将新记录插入到已经 ...

  6. light oj 1248 第六周E题(期望)

    E - 期望(经典问题) Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%lld & %llu   Descri ...

  7. socket本地模拟UDP 服务器+客户端(三)

    UDP: TCP是建立可靠连接,并且通信双方都可以以流的形式发送数据.相对TCP,UDP则是面向无连接的协议. 使用UDP协议时,不需要建立连接,只需要知道对方的IP地址和端口号,就可以直接发数据包. ...

  8. inet_aton等函数

    地址转换函数 int inet_aton(const char *strptr,struct in_addr *addrptr) 将strptr所指C字符串转换成一个32位的网络字节序二进制值,并同过 ...

  9. iPhone 被同步到 Mac上后 如果不希望更新到Mac上在哪里删除?

    前往文件夹   /Users/用户名/Library/Application Support/MobileSync  直接删除  就行了(同时要倾倒废纸篓). 目前iPhone链接Mac 后  不让 ...

  10. struts2整合spring出现的Unable to instantiate Action异常

    在struts2整合spring的时候,完全一步步按照官方文档上去做的,最后发现出现 Unable to instantiate Action,网上一搜发现很多人和我一样的问题,配置什么都没有错误,就 ...