安装Cobbler

 [root@linux-node3 ~]# yum -y install epel-release
[root@linux-node3 ~]# yum -y install cobbler cobbler-web dhcp httpd xinetd pykickstart fence-agents # 如果你的报错请用163源
[root@linux-node3 ~]# chkconfig cobblerd on
[root@linux-node3 ~]# chkconfig httpd on
[root@linux-node3 ~]# chkconfig dhcpd on
[root@linux-node3 ~]# chkconfig xinetd on
[root@linux-node3 ~]# chkconfig rsyncd on
[root@linux-node3 ~]# sed -i -e 's/\=\ yes/\=\ no/g' /etc/xinetd.d/tftp
[root@linux-node3 ~]# openssl passwd - -salt "cobbler" "centos" # centos为你之后所装所有机器的root密码,cobbler是对centos进行加密时用到的加密文(可以去看下salt加密相关),参数是数字1不是字母l
[root@linux-node3 ~]# cat/etc/cobbler/settings
next_server: 192.168.145.11 # 提供pxe的主机,你的本机ip
server: 192.168.145.11 # 提供cobbler的主机,还是你的本机ip
manage_dhcp:
manage_rsync:
default_password_crypted: "$1$cobbler$DWL2fHTHaRTa2hj5VEuZk." # 刚才使用加密后得到的密文,注意最后有个.
pxe_just_once: # 防止循环装系统,很重要! [root@linux-node3 ~]# cat /etc/cobbler/dhcp.template # 更改第一段就好,其实就是dhcp的配置
subnet 192.168.56.0 netmask 255.255.255.0 {
option routers 192.168.56.2;
option domain-name-servers 8.8.8.8;
option subnet-mask 255.255.255.0;
range dynamic-bootp 192.168.56.100 192.168.56.254;
default-lease-time ;
max-lease-time ;
next-server $next_server;
class "pxeclients" {
match if substring (option vendor-class-identifier, , ) = "PXEClient";
if option pxe-system-type = : {
filename "ia64/elilo.efi";
} else if option pxe-system-type = : {
filename "grub/grub-x86.efi";
} else if option pxe-system-type = : {
filename "grub/grub-x86_64.efi";
} else if option pxe-system-type = : {
filename "grub/grub-x86_64.efi";
} else {
filename "pxelinux.0";
}
} } [root@linux-node3 ~]# systemctl start xinetd
[root@linux-node3 ~]# systemctl start dhcpd
[root@linux-node3 ~]# systemctl start httpd
[root@linux-node3 ~]# systemctl start rsyncd
[root@linux-node3 ~]# systemctl start cobblerd
[root@linux-node3 ~]# cobbler get-loaders # 去git下载cobbler相关包,下载慢的话可以把dns换成114.114.114.
[root@linux-node3 ~]# cobbler sync # 每次有修改过文件后都要执行哦
[root@linux-node3 ~]# cobbler check # cobbler自带的检测命令,出了问题就可以使用下,可以快速帮助你检测出问题的所在点,centos7会出debmirror错误,这是安装debian系统相关的,不会影响到使用
[root@linux-node3 ~]# htdigest /etc/cobbler/users.digest "Cobbler" cobbler # 设置cobbler_web页面的访问密码
访问https://192.168.145.11/cobbler_web # 用户名为cobbler,密码刚才设置的,注意是https [root@linux-node3 ~]# cat /etc/cobbler/pxe/pxedefault.template
DEFAULT menu
PROMPT
MENU TITLE Cobbler | http://www.cnblogs.com/bfmq/
TIMEOUT # 装系统时的等待时间,默认20秒
TOTALTIMEOUT
ONTIMEOUT centos7.-x86_64 # 这个需要改成你自己的cobbler profile list出现的,之后默认不选择系统引导后就会自动选择这个 LABEL local
MENU LABEL (local)
MENU DEFAULT
LOCALBOOT -
$pxe_menu_items MENU end

使用Cobbler

 [root@linux-node3 ~]# mount /dev/sr0 /mnt                # /dev/sr0是centos7.2的iso源镜像
[root@linux-node3 ~]# cobbler import --path=/mnt/ --name=centos7. # 需要一些时间,导入的镜像会放在/var/www/cobbler/ks_mirror内,以name指定的为目录名
[root@linux-node3 ~]# cd /var/lib/cobbler/kickstarts [root@linux-node3 ~]# cat centos7.-x86_64.cfg # 里面不可以有中文,so,不注释含义了,都很好理解
# kickstart template for Fedora and later.
# (includes %end blocks)
# do not use with earlier distros #platform=x86, AMD64, or Intel EM64T
# System authorization information
auth --useshadow --enablemd5
# System bootloader configuration
bootloader --location=mbr
# Partition clearing information
clearpart --all --initlabel
# Use text mode install
text
# Firewall configuration
firewall --disabled
# Run the Setup Agent on first boot
firstboot --disable
# System keyboard
keyboard us
# System language
lang en_US
# Use network installation
url --url=$tree
# If any cobbler repo definitions were referenced in the kickstart profile, include them here.
$yum_repo_stanza
# Network information
$SNIPPET('network_config')
# Reboot after installation
reboot #Root password
rootpw --iscrypted $default_password_crypted
# SELinux configuration
selinux --disabled
# Do not configure the X Window System
skipx
# System timezone
timezone Asia/Shanghai
# Install OS instead of upgrade
install
# Clear the Master Boot Record
zerombr
# Allow anaconda to partition the system as needed
autopart
#clearpart --all --initlabel
#part / --fstype xfs --size 1 --grow --asprimary --onbiosdisk=80 #part swap --maxsize= --asprimary --size= --onbiosdisk=80 #part /boot --fstype=xfs --grow --asprimary --size= --onbiosdisk=80 %packages
@^minimal
@base
@core
@development lftp
openssh-clients
tree
lrzsz
telnet
nc
sysstat
gcc
gcc-c++
%end %post
sed -i "s/#UseDNS yes/UseDNS no/g" /etc/ssh/sshd_config
echo 'export HISTTIMEFORMAT="%Y-%m-%d %H:%M:%S "' >> /etc/bashrc
echo 'export HISTSIZE=9999' >> /etc/bashrc
IP=`ifconfig eth0|grep netmask|awk '{print $2}'`
HN=`echo $IP|awk -F. '{print $NF}'`
sed -i 's/dhcp/none/g' /etc/sysconfig/network-scripts/ifcfg-eth0
echo 'PREFIX=24' >> /etc/sysconfig/network-scripts/ifcfg-eth0
echo "IPADDR=$IP" >> /etc/sysconfig/network-scripts/ifcfg-eth0
echo 'GATEWAY=192.168.145.2' >> /etc/sysconfig/network-scripts/ifcfg-eth0
sed -i 's/nameserver *.*.*.*/nameserver 8.8.8.8/g' /etc/resolv.conf
systemctl restart network
%end %pre
$SNIPPET('log_ks_pre')
$SNIPPET('kickstart_start')
$SNIPPET('pre_install_network_config')
# Enable installation monitoring
$SNIPPET('pre_anamon')
%end [root@linux-node3 ~]# cobbler profile edit --name=centos7.-x86_64 --kickstart=/var/lib/cobbler/kickstarts/centos7.-x86_64.cfg
[root@linux-node3 ~]# cobbler profile edit --name= centos7.-x86_64 --kopts='net.ifnames=0 biosdevname=0' # 装6的系统不需要,这是统一网卡名称用的 96 [root@linux-node3 ~]# cobbler sync

然后你就可以直接开机等待系统自动安装了

最新文章

  1. EntityFramework 7 Join Count LongCount 奇怪问题(已修复)
  2. Python3
  3. Squire – 简洁的 HTML5 富文本编辑器
  4. Silverlight button 图片切换样式
  5. Spring3+hibernate4+struts2整合的 过程中发生如下错误
  6. 通过html5的range属性动态改变图片的大小
  7. fltk demo
  8. 未能从程序集“System.ServiceModel, Version=3.0.0.0”中加载类型“System.ServiceModel.Activation.HttpModule” 的解决办法
  9. shapeless官方指南翻译写在前面
  10. MySQL索引语法+使用场景
  11. Serializable中的serialVersionUID
  12. 全球DDOS安全防护
  13. Unity打包提示UnityEditor.BuildPlayerWindow+BuildMethodException: Build failed with errors.错误
  14. swiper里面几个有用的参数
  15. Java调用FFmpeg进行视频处理及Builder设计模式的应用
  16. 多模块拆分时 DepencyManagement 与 Dependencys区别
  17. 《DSP using MATLAB》Problem 5.21
  18. R基于Bayes理论实现中文人员特性的性别判定
  19. TDD并不是看上去的那么美
  20. np.clip截取函数

热门文章

  1. jstl的函数
  2. 分享ArcGIS Server 10.0修复安装心得
  3. DataSource是什么
  4. UDIMM、RDIMM、SODIMM以及LRDIMM的区别
  5. Allegro PCB中封装焊盘替换操作详解
  6. C++入门一
  7. EasyPusher手机直播推送是如何实现后台直播推送的
  8. Hibernate中的HQL语言
  9. Redis(二)延迟队列
  10. BZOJ 2069 POI2004 ZAW 堆优化Dijkstra