Cobbler Automatic bulk Installation Deployment Linux system

Source: Internet
Author: User
Tags mkdir stdin centos iptables nameserver rsync
Cobbler Server System: CentOS 5.10 64-bit
IP Address:
You need to install a deployed Linux system:
Eth0 (first network card, for extranet) IP address segment:
ETH1 (second network card, for intranet) IP address segment:
Subnet Mask:
All servers support PXE network boot
Achieve the goal: by configuring the Cobbler server, the automatic batch installs the Linux system deployment
Specific actions:
Part I: Operating on the Cobbler server
First, close SELinux
#SELINUX =enforcing #注释掉
#SELINUXTYPE =targeted #注释掉
Selinux=disabled #增加
: wq! #保存退出
Setenforce 0 #使配置立即生效
Second, configure the firewall, open tcp:80 port, tcp:25151 port, udp:69 port
Vi/etc/sysconfig/iptables #编辑
-A rh-firewall-1-input-m state--state new-m tcp-p TCP--dport 80-j ACCEPT #http服务需要此端口
-A rh-firewall-1-input-m state--state new-m udp-p UDP--dport 69-j ACCEPT #tftp服务需要此端口
-A rh-firewall-1-input-m state--state new-m tcp-p TCP--dport 25151-j ACCEPT #cobbler需要此端口
: wq! #保存退出
/etc/init.d/iptables Restart #最后重启防火墙使配置生效
Iii. Installation of Cobbler
wget #CentOS 5.x 64-bit
RPM-IVH epel-release-5-4.noarch.rpm
wget #CentOS 5.x 32-bit
wget #CentOS6. x 64 bits
wget #CentOS6. x 32 bits
Yum Install cobbler tftp tftp-server xinetd DHCP httpd rsync #安装cobbler
Yum install Pykickstart debmirror python-ctypes cman #安装运行cobbler需要的软件包
Iv. Configuration of Cobbler
1. Set up HTTP Service
LoadModule Wsgi_module modules/ #取消前面的注释
: wq! #保存退出
Chkconfig httpd on #设置开机启动
Service httpd Start #启动
2, set up the TFTP service boot
Vi/etc/cobbler/tftpd.template #编辑
Service TFTP
Disable = no #修改为no
Socket_type = Dgram
protocol = UDP
Wait = yes
user = root
Server_args =-B 1380-v-s/tftpboot
Per_source = 11
CPS = 100 2
Flags = IPV4
: wq! #保存退出
3, set up the Rsync service start-up
Vi/etc/xinetd.d/rsync #编辑配置文件, set power-on start rsync
Service rsync
Disable = no #修改为no
Socket_type = Stream
wait = no
user = root
Server =/usr/bin/rsync
Server_args =--daemon
Log_on_failure + + USERID
: wq! #保存退出
/etc/init.d/xinetd start #启动 ( CentOS is xinetd to manage rsync and TFTP services)
4, configure cobbler related parameters
vi/etc/debmirror.conf #注释掉 @dists and @arches two lines
# @dists = "Sid";
# @arches = "i386";
: wq! #保存退出
OpenSSL passwd-1-salt ' Osyunwei ' 123456 ' #生成默认模板下系统安装完成之后root账号登录密码
$1$osyunwei$sev8iwxxur4cqzlxylnzm0 #记录下这行, the following will be used
Vi/etc/cobbler/settings #编辑, modify
default_password_crypted: "$1$osyunwei$sev8iwxxur4cqzlxylnzm0"
: wq! #保存退出
System Yun-wei warm reminder: qihang01 original Content © Copyright, reproduced please specify the source and the original link
5. Configure the DHCP server
Vi/etc/cobbler/dhcp.template #编辑, modify
Subnet netmask {#设置网段
Option routers; #设置网关
Option Domain-name-servers,; #设置dns服务器地址
Option Subnet-mask; #设置子网掩码
Range DYNAMIC-BOOTP; #设置dhcp服务器IP地址租用的范围
Default-lease-time 21600; #默认租约时间
Max-lease-time 43200; #最大租约时间
Next-server $next _server;
Class "Pxeclients" {
Match if substring (option vendor-class-identifier, 0, 9) = "Pxeclient";
If option Pxe-system-type = 00:02 {
FileName "Ia64/elilo.efi";
else if option Pxe-system-type = 00:06 {
FileName "Grub/grub-x86.efi";
else if option Pxe-system-type = 00:07 {
FileName "Grub/grub-x86_64.efi";
} else {
FileName "pxelinux.0";
: wq! #保存退出
: wq! #保存退出
DHCPD #测试dhcp服务器配置是否正确
Chkconfig DHCPD on #设置开机启动
Chkconfig Cobblerd on #设置开机启动
Cobbler Get-loaders #安装cobbler相关工具包, otherwise check cobbler configuration will error
Service Cobblerd Start #启动cobbler
Cobbler Sync #同步配置文件到dhcp服务器
Service DHCPD Start #启动dhcp服务
6, set up Cobbler related service startup script
Vi/etc/rc.d/init.d/cobbler #编辑, add the following code
# Chkconfig:-80 90
# Description:cobbler
Case is in
/etc/init.d/xinetd start
/etc/init.d/cobblerd start
/etc/init.d/xinetd stop
/etc/init.d/cobblerd stop
/etc/init.d/xinetd restart
/etc/init.d/cobblerd restart
/etc/init.d/cobblerd status
Cobbler Sync
echo "Input error,please in put ' Start|stop|restart|status|sync '!"
Exit 2>&1 >/dev/null &
: wq! #保存退出
chmod +x/etc/rc.d/init.d/cobbler #添加脚本执行权限
Chkconfig Cobbler on #添加开机启动
Service Cobbler Restart #重启cobbler
Cobbler Check #检查cobbler配置, the following prompts, SELinux and firewalls have been set before, don't bother
System Yun-wei warm reminder: qihang01 original Content © Copyright, reproduced please specify the source and the original link
The following are potential configuration items that are want to fix:
1:selinux is enabled. Please review the "following wiki page for details" Ensuring cobbler works correctly in your SELinux:
2:since Iptables may running, ensure, 80/443, and 25151 are
Restart Cobblerd and then run ' Cobbler Sync ' to apply changes
V. Mount system installation mirroring to HTTP Server site Directory
Upload system installation image file Centos-5.10-x86_64-bin-dvd-1of2.iso to/usr/local/src/directory
Mkdir-p/var/www/html/os/centos-5.10-x86_64 #创建挂载目录
Mount-t Iso9660-o loop/usr/local/src/centos-5.10-x86_64-bin-dvd-1of2.iso/var/www/html/os/centos-5.10-x86_64 # Mount System Mirroring
Vi/etc/fstab #添加以下代码. Enable automatic mount on boot
/usr/local/src/centos-5.10-x86_64-bin-dvd-1of2.iso/var/www/html/os/centos-5.10-x86_64 iso9660 Defaults,ro,loop 0 0
: wq! #保存退出
Note: iso9660 use DF-T to view device uninstall: umount/var/www/html/os/centos-5.10-x86_64
Repeat the above operation to mount the CentOS system image files that you need to install to the /var/www/html/os/directory
For example:
Vi. creating kickstarts automatic installation Scripts
Cd/var/lib/cobbler/kickstarts #进入默认Kickstart模板目录
VI/VAR/LIB/COBBLER/KICKSTARTS/CENTOS-5.10-X86_64.KS #创建CentOS -5.10-x86_64 Installation Script
# Kickstart file automatically generated by Anaconda.
Lang en_US. UTF-8
Keyboard US
Network--device eth0--bootproto DHCP--onboot on
#network--device eth0--bootproto static--ip CentOS5.10
ROOTPW--iscrypted $1$qqobzz1g$rynrawi9kyleeuuq1vcrs/
TimeZone Asia/shanghai
# The following is the partition information for you requested
# that ' any partitions ' deleted are not expressed
# Here I unless you clear all partitions the
# Not guaranteed to work
Part/--bytes-per-inode=4096--fstype= "ext3"--size=2048
Part/boot--bytes-per-inode=4096--fstype= "ext3"--size=128
Part swap--bytes-per-inode=4096--fstype= "swap"--size=500
Part/data--bytes-per-inode=4096--fstype= "ext3"--grow--size=1
ECHO-E "0 1 * * * root/usr/sbin/ntpdate >/dev/null" >>/etc/crontab
Service Crond Restart
Groupadd Maintain
Groupadd Develop
Useradd-g Maintain user01-d/home/maintain/user01-m
echo "123456" |passwd User01--stdin
Useradd-g Maintain user02-d/home/maintain/user02-m
echo "123456" |passwd user02--stdin
Useradd-g Maintain user03-d/home/maintain/user03-m
echo "123456" |passwd user03--stdin
Useradd-g Maintain user04-d/home/maintain/user04-m
echo "123456" |passwd user04--stdin
Sed-i "s/#PermitRootLogin yes/permitrootlogin no/g" '/etc/ssh/sshd_config '
Service sshd Restart
Chkconfig Acpid off
Chkconfig ATD Off
Chkconfig AutoFS off
Chkconfig bluetooth off
Chkconfig Cpuspeed off
Chkconfig Firstboot off
Chkconfig gpm Off
Chkconfig Haldaemon off
Chkconfig Hidd off
Chkconfig Ip6tables off
Chkconfig ISDN Off
Chkconfig Messagebus off
Chkconfig Nfslock off
Chkconfig PCSCD off
Chkconfig Portmap off
Chkconfig RPCGSSD off
Chkconfig RPCIDMAPD off
Chkconfig yum-updatesd off
Chkconfig SendMail off
Chkconfig Crond on
Chkconfig kudzu on
Chkconfig Network on
Chkconfig readahead_early on
Chkconfig sshd on
Chkconfig syslog on
#禁止使用Ctrl +alt+del shortcut keys to restart the server
Sed-i "S/ca::ctrlaltdel:/sbin/shutdown-t3-r now/#ca:: Ctrlaltdel:/sbin/shutdown-t3-r now/g" '/etc/inittab '
Telinit Q
Echo-e "Ulimit-c Unlimited" >>/etc/profile
Echo-e "Ulimit-s Unlimited" >>/etc/profile
Echo-e "Ulimit-shn 65535" >>/etc/profile
Sed-i "S/net.ipv4.ip_forward = 0/net.ipv4.ip_forward = 1/g" '/etc/sysctl.conf '
Echo-e "net.core.somaxconn = 262144" >>/etc/sysctl.conf
Echo-e "Net.core.netdev_max_backlog = 262144" >>/etc/sysctl.conf
Echo-e "Net.core.wmem_default = 8388608" >>/etc/sysctl.conf
Echo-e "Net.core.rmem_default = 8388608" >>/etc/sysctl.conf
Echo-e "Net.core.rmem_max = 16777216" >>/etc/sysctl.conf
Echo-e "Net.core.wmem_max = 16777216" >>/etc/sysctl.conf
Echo-e "Net.ipv4.netfilter.ip_conntrack_max = 131072" >>/etc/sysctl.conf
Echo-e "net.ipv4.netfilter.ip_conntrack_tcp_timeout_established = 180" >>/etc/sysctl.conf
Echo-e "net.ipv4.route.gc_timeout =" >>/etc/sysctl.conf
Echo-e "Net.ipv4.ip_conntrack_max = 819200" >>/etc/sysctl.conf
Echo-e "Net.ipv4.ip_local_port_range = 10024 65535" >>/etc/sysctl.conf
Echo-e "Net.ipv4.tcp_retries2 = 5" >>/etc/sysctl.conf
Echo-e "net.ipv4.tcp_fin_timeout = >>/etc/sysctl.conf"
Echo-e "net.ipv4.tcp_syn_retries = 1" >>/etc/sysctl.conf
Echo-e "net.ipv4.tcp_synack_retries = 1" >>/etc/sysctl.conf
Echo-e "net.ipv4.tcp_timestamps = 0" >>/etc/sysctl.conf
Echo-e "net.ipv4.tcp_tw_recycle = 1" >>/etc/sysctl.conf
Echo-e "Net.ipv4.tcp_tw_len = 1" >>/etc/sysctl.conf
Echo-e "Net.ipv4.tcp_tw_reuse = 1" >>/etc/sysctl.conf
Echo-e "net.ipv4.tcp_keepalive_time =/etc/sysctl.conf" >>
Echo-e "Net.ipv4.tcp_keepalive_probes = 3" >>/etc/sysctl.conf
Echo-e "NET.IPV4.TCP_KEEPALIVE_INTVL =" >>/etc/sysctl.conf
Echo-e "net.ipv4.tcp_max_tw_buckets = 36000" >>/etc/sysctl.conf
Echo-e "Net.ipv4.tcp_max_orphans = 3276800" >>/etc/sysctl.conf
Echo-e "Net.ipv4.tcp_max_syn_backlog = 262144" >>/etc/sysctl.conf
Echo-e "Net.ipv4.tcp_wmem = 8192 131072 16777216" >>/etc/sysctl.conf
Echo-e "Net.ipv4.tcp_rmem = 32768 131072 16777216" >>/etc/sysctl.conf
Echo-e "Net.ipv4.tcp_mem = 94500000 915000000 927000000" >>/etc/sysctl.conf
: wq! #保存退出
Vi/var/www/cobbler/ks_mirror/config/ #创建脚本, automatically set Linux system static IP address, DNS, Gateway, computer name
route=$ (route-n|grep "^" |awk ' {print $} ')
broadcast=$ (/sbin/ifconfig eth0|grep-i Bcast|awk ' {print $} ' |awk-f ': ' ' {print $} ')
hwaddr=$ (/sbin/ifconfig eth0|grep-i Hwaddr|awk ' {print $} ')
ipaddr=$ (/sbin/ifconfig eth0|grep "inet addr" |awk ' {print $} ' |awk-f ":" ' {print $} ')
netmask=$ (/sbin/ifconfig eth0|grep "inet addr" |awk ' {print $} ' |awk-f ': "' {print $} ')
Cat >/etc/sysconfig/network-scripts/ifcfg-eth0<<eof
broadcast= $BROADCAST
Hwaddr= $HWADDR
Ipaddr= $IPADDR
netmask= $NETMASK
gateway= $ROUTE
ipaddr1=$ (Echo $IPADDR |awk-f "." ' {print $} ')
Cat >/etc/sysconfig/network-scripts/ifcfg-eth1<<eof
hwaddr=$ (/sbin/ifconfig eth1|grep-i Hwaddr|awk ' {print $} ')
ipaddr=10.0.0. $IPADDR 1
hostname=osyunwei_hz_$ (Echo $IPADDR |awk-f "." ' {print $} ')
Cat >/etc/sysconfig/network<<eof
Hostname= $HOSTNAME
gateway= $ROUTE
echo " $HOSTNAME" >>/etc/hosts
Hostname= $HOSTNAME
echo "NameServer" >/etc/resolv.conf
echo "NameServer" >>/etc/resolv.conf
: wq! #保存退出
Vii. Import system mirroring to Cobbler
Cobbler Import--path=/var/www/html/os/centos-5.10-x86_64--name=centos-5.10-x86_64--arch=x86_64 #导入系统镜像文件, it will take some time
Cd/var/www/cobbler/ks_mirror #进入系统镜像导入目录
Command format: Cobbler import--path= Mirroring path-name= Install boot name--arch=32 bit or 64-bit
Repeat the above operation to import the other system image files into the Cobbler
Eight, set profile, according to the operating system version of the associated system image files and Kickstart automatic installation files
The first time you import a system mirror, cobbler specifies a default kickstart automatic installation file for the installation image
For example: The centos-5.10-x86_64 version of the Kickstart automatic installation file is:/VAR/LIB/COBBLER/KICKSTARTS/SAMPLE.KS
Cobbler Profile--name centos-5.10-x86_64 #查看profile设置
Cobbler distro--name centos-5.10-x86_64 #查看安装镜像文件信息
Cobbler profile Remove--name=centos-5.10-x86_64 #移除profile
Cobbler profile Add--name=centos-5.10-x86_64--distro=centos-5.10-x86_64--kickstart=/var/lib/cobbler/kickstarts/ CENTOS-5.10-X86_64.KS #添加
Cobbler profile Edit--name=centos-5.10-x86_64--distro=centos-5.10-x86_64--kickstart=/var/lib/cobbler/kickstarts/ CENTOS-5.10-X86_64.KS #编辑
Command: Cobbler profile add|edit|remove--name= installation boot name--distro= system Mirror name--kickstart=kickstart automatic installation file path
--name: Custom Installation Boot name, note cannot repeat
--distro: System installation Mirror name, with cobbler distro list to view
--kickstart: Kickstart automatic installation files associated with system mirroring files
Cobbler List
Cobbler profile
Cobbler distro List
For example:
ksfile=$ (Cobbler profile--name centos-5.10-x86_64|grep-e ' ^kickstart ' |head-n 1|cut-d ': ' F 2); Cat $ksfile;
Repeat the above operation to associate the other system image files with the Kickstart automatic installation file
1. Kickstart automatic installation files need to be pre-configured
2, every time you modify the configuration file, you need to perform a synchronous operation: Cobbler sync configuration to be effective
3, Kickstart automatic installation files can be generated using tools (graphics interface required to operate)
Yum install System-config-kickstart #安装
Yum Groupinstall "X Window System" #安装X window graphical interface
System-config-kickstart #运行kickstart配置
Service Cobbler sync #与cobbler sync function the same
Service Cobbler Restart #重启cobbler
Part Two: Set up the server to be installed from the network boot
After the boot, as shown in the following figure, select the appropriate system version as needed to install, after the installation is complete, the system will automatically restart
System Yun-wei warm reminder: qihang01 original Content © Copyright, reproduced please specify the source and the original link
Reinstall System:
Install Koan on a server that needs to reinstall the system
wget #CentOS 5.X
RPM-IVH koan-2.4.0-1.el5.noarch.rpm #安装koan #CentOS 6.X
Yum Install cobbler Debmirror pykickstart python-ctypes cman #安装koan运行依赖包 ( need to set Epel source)
Koan--list=profiles--server= #查看Cobbler服务器系统镜像列表
Koan--replace-self--server= #选择要重装的系统
Reboot #重新启动系统进行自动安装
Extended reading:
Cobbler Directory Description:
1, Cobbler configuration file directory:/etc/cobbler
/etc/cobbler/settings #cobbler主配置文件
/etc/cobbler/dhcp.template #DHCP服务的配置模板
/etc/cobbler/tftpd.template #tftp服务的配置模板
/etc/cobbler/rsync.template #rsync服务的配置模板
/etc/cobbler/iso #iso模板配置文件
/etc/cobbler/pxe #pxe模板文件
/etc/cobbler/power #电源的配置文件
/etc/cobbler/users.conf #Web服务授权配置文件
/etc/cobbler/users.digest #用于web访问的用户名密码配置文件
/etc/cobbler/dnsmasq.template #DNS服务的配置模板
/etc/cobbler/modules.conf #Cobbler模块配置文件
2, Cobbler Data directory:/var/lib/cobbler
/var/lib/cobbler/config #配置文件
/var/lib/cobbler/triggers #Cobbler命令
/var/lib/cobbler/kickstarts #默认存放kickstart文件
/var/lib/cobbler/loaders #存放的各种引导程序
3. System Installation Mirror directory:/var/www/cobbler
/var/www/cobbler/ks_mirror #导入的系统镜像列表
/var/www/cobbler/images #导入的系统镜像启动文件
/var/www/cobbler/repo_mirror #yum源存储目录
4, log directory:/var/log/cobbler
/var/log/cobbler/install.log #客户端系统安装日志
/var/log/cobbler/cobbler.log #cobbler日志
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.