Cobbler Server System: CentOS 5.10 64-bit
IP Address: 192.168.21.128
You need to install a deployed Linux system:
Eth0 (first network card, for extranet) IP address segment: 192.168.21.160-192.168.21.200
ETH1 (second network card, for intranet) IP address segment: 10.0.0.160-10.0.0.200
Subnet Mask: 255.255.255.0
All servers support PXE network boot
Achieve the goal: by configuring the Cobbler server, the automatic batch installs the Linux system deployment
Part I: Operating on the Cobbler server
#SELINUXTYPE =targeted #注释掉
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需要此端口
/etc/init.d/iptables Restart #最后重启防火墙使配置生效
Iii. Installation of Cobbler
wget http://dl.fedoraproject.org/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm #CentOS 5.x 64-bit
RPM-IVH epel-release-5-4.noarch.rpm
wget http://dl.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm #CentOS 5.x 32-bit
wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm #CentOS6. x 64 bits
wget http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm #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
Vi/etc/httpd/conf.d/wsgi.conf
LoadModule Wsgi_module modules/mod_wsgi.so #取消前面的注释
Chkconfig httpd on #设置开机启动
2, set up the TFTP service boot
Vi/etc/cobbler/tftpd.template #编辑
Server =/USR/SBIN/IN.TFTPD
Server_args =-B 1380-v-s/tftpboot
3, set up the Rsync service start-up
Vi/etc/xinetd.d/rsync #编辑配置文件, set power-on start rsync
Log_on_failure + + USERID
/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
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"
next_server:192.168.21.128
Default_kickstart:/VAR/LIB/COBBLER/KICKSTARTS/DEFAULT.KS
System Yun-wei Www.111cn.net 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 192.168.21.0 netmask 255.255.255.0 {#设置网段
Option routers 192.168.21.2; #设置网关
Option Domain-name-servers 8.8.8.8,8.8.4.4; #设置dns服务器地址
Option Subnet-mask 255.255.255.0; #设置子网掩码
Range DYNAMIC-BOOTP 192.168.21.160 192.168.21.200; #设置dhcp服务器IP地址租用的范围
Default-lease-time 21600; #默认租约时间
Max-lease-time 43200; #最大租约时间
Next-server $next _server;
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";
VI/ETC/SYSCONFIG/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
/etc/init.d/cobblerd start
/etc/init.d/cobblerd stop
/ETC/INIT.D/HTTPD restart
/etc/init.d/xinetd restart
/ETC/INIT.D/DHCPD restart
/etc/init.d/cobblerd restart
/ETC/INIT.D/XINETD status
/etc/init.d/cobblerd status
echo "Input error,please in put ' Start|stop|restart|status|sync '!"
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 Www.111cn.net 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:
Https://github.com/cobbler/cobbler/wiki/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
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
Centos-5.10-x86_64-bin-dvd-1of2.iso
Centos-6.5-x86_64-bin-dvd1.iso
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.
URL--url=http://192.168.21.128/cobbler/ks_mirror/centos-5.10-x86_64-x86_64/
Network--device eth0--bootproto DHCP--onboot on
#network--device eth0--bootproto static--ip 192.168.21.250--netmask 255.255.255.0--gateway 192.168.21.2--nameserver 8.8.8.8--hostname CentOS5.10
ROOTPW--iscrypted $1$qqobzz1g$rynrawi9kyleeuuq1vcrs/
Firewall--enabled--port=22:tcp
Authconfig--enableshadow--ENABLEMD5
Bootloader--LOCATION=MBR--DRIVEORDER=SDA
# The following is the partition information for you requested
# that ' any partitions ' deleted are not expressed
# Here I unless you clear all partitions the
Clearpart--all--initlabel
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 cn.pool.ntp.org >/dev/null" >>/etc/crontab
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 '
Chkconfig yum-updatesd off
Chkconfig readahead_early 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 '
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
wget http://192.168.21.128/cobbler/ks_mirror/config/autoip.sh
Vi/var/www/cobbler/ks_mirror/config/autoip.sh #创建脚本, automatically set Linux system static IP address, DNS, Gateway, computer name
route=$ (route-n|grep "^0.0.0.0" |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
ipaddr1=$ (Echo $IPADDR |awk-f "." ' {print $} ')
Cat >/etc/sysconfig/network-scripts/ifcfg-eth1<<eof
hwaddr=$ (/sbin/ifconfig eth1|grep-i Hwaddr|awk ' {print $} ')
hostname=osyunwei_hz_$ (Echo $IPADDR |awk-f "." ' {print $} ')
Cat >/etc/sysconfig/network<<eof
echo "127.0.0.1 $HOSTNAME" >>/etc/hosts
echo "NameServer 8.8.8.8" >/etc/resolv.conf
echo "NameServer 8.8.4.4" >>/etc/resolv.conf
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
#通过profile查找对应的kickstart自动安装文件文件
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 Www.111cn.net warm reminder: qihang01 original Content © Copyright, reproduced please specify the source and the original link
Install Koan on a server that needs to reinstall the system
wget http://dl.fedoraproject.org/pub/epel/5/x86_64/koan-2.4.0-1.el5.noarch.rpm #CentOS 5.X
RPM-IVH koan-2.4.0-1.el5.noarch.rpm #安装koan
http://dl.fedoraproject.org/pub/epel/6/x86_64/koan-2.4.0-1.el6.noarch.rpm #CentOS 6.X
Yum Install cobbler Debmirror pykickstart python-ctypes cman #安装koan运行依赖包 ( need to set Epel source)
Koan--list=profiles--server=192.168.21.128 #查看Cobbler服务器系统镜像列表
Koan--replace-self--server=192.168.21.128--profile=centos-5.10-x86_64 #选择要重装的系统
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日志