您的位置:首页 > 运维架构 > Linux

Cobbler全自动批量安装部署Linux系统一

2016-03-24 17:48 429 查看
Cobbler全自动批量安装部署Linux系统
2014年04月10日 CentOS 评论数 1 被围观 11,704次+


说明:Cobbler服务器系统:CentOS 5.10 64位IP地址:192.168.21.128需要安装部署的Linux系统:eth0(第一块网卡,用于外网)IP地址段:192.168.21.160-192.168.21.200eth1(第二块网卡,用于内网)IP地址段:10.0.0.160-10.0.0.200子网掩码:255.255.255.0网关:192.168.21.2DNS:8.8.8.8 8.8.4.4所有服务器均支持PXE网络启动实现目的:通过配置Cobbler服务器,全自动批量安装部署Linux系统具体操作:第一部分:在Cobbler服务器上操作一、关闭SELINUXvi /etc/selinux/config#SELINUX=enforcing #注释掉#SELINUXTYPE=targeted #注释掉SELINUX=disabled #增加:wq! #保存退出setenforce 0 #使配置立即生效二、配置防火墙,开启TCP:80端口、TCP:25151端口、UDP:69端口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 #最后重启防火墙使配置生效三、安装Cobblercd /usr/local/srcwget http://dl.fedoraproject.org/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm #CentOS 5.x 64位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位wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm #CentOS6.x 64位wget http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm #CentOS6.x 32位yum install cobbler tftp tftp-server xinetd dhcp httpd rsync #安装cobbleryum install pykickstart debmirror python-ctypes cman #安装运行cobbler需要的软件包四、配置Cobbler1、设置http服务vi /etc/httpd/conf.d/wsgi.confLoadModule wsgi_module modules/mod_wsgi.so #取消前面的注释:wq! #保存退出chkconfig httpd on #设置开机启动service httpd start #启动2、设置tftp服务开机启动vi /etc/cobbler/tftpd.template #编辑service tftp{disable = no #修改为nosocket_type = dgramprotocol = udpwait = yesuser = rootserver = /usr/sbin/in.tftpdserver_args = -B 1380 -v -s /tftpbootper_source = 11cps = 100 2flags = IPv4}:wq! #保存退出3、设置rsync服务开机启动vi /etc/xinetd.d/rsync #编辑配置文件,设置开机启动rsyncservice rsync{disable = no #修改为nosocket_type = streamwait = nouser = rootserver = /usr/bin/rsyncserver_args = --daemonlog_on_failure += USERID}:wq! #保存退出/etc/init.d/xinetd start #启动(CentOS中是以xinetd 来管理Rsync和tftp服务的)4、配置cobbler相关参数vi /etc/debmirror.conf #注释掉 @dists 和 @arches 两行#@dists="sid";#@arches="i386";:wq! #保存退出openssl passwd -1 -salt 'osyunwei' '123456' #生成默认模板下系统安装完成之后root账号登录密码$1$osyunwei$sEV8iwXXuR4CqzLXyLnzm0 #记录下这行,下面会用到vi /etc/cobbler/settings #编辑,修改default_password_crypted: "$1$osyunwei$sEV8iwXXuR4CqzLXyLnzm0"next_server: 192.168.21.128server: 192.168.21.128manage_dhcp: 1default_kickstart: /var/lib/cobbler/kickstarts/default.ks:wq! #保存退出系统运维 www.osyunwei.com 温馨提醒:qihang01原创内容版权所有,转载请注明出处及原文链接5、配置dhcp服务器vi /etc/cobbler/dhcp.template #编辑,修改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;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! #保存退出vi /etc/sysconfig/dhcpd #指定DHCP服务的网络接口DHCPDARGS=eth0:wq! #保存退出dhcpd #测试dhcp服务器配置是否正确chkconfig dhcpd on #设置开机启动chkconfig cobblerd on #设置开机启动cobbler get-loaders #安装cobbler相关工具包,否则检查cobbler配置会报错service cobblerd start #启动cobblercobbler sync #同步配置文件到dhcp服务器service dhcpd start #启动dhcp服务6、设置cobbler相关服务启动脚本vi /etc/rc.d/init.d/cobbler #编辑,添加以下代码#!/bin/sh# chkconfig: - 80 90# description:cobblercase $1 instart)/etc/init.d/httpd start/etc/init.d/xinetd start/etc/init.d/dhcpd start/etc/init.d/cobblerd start;;stop)/etc/init.d/httpd stop/etc/init.d/xinetd stop/etc/init.d/dhcpd stop/etc/init.d/cobblerd stop;;restart)/etc/init.d/httpd restart/etc/init.d/xinetd restart/etc/init.d/dhcpd restart/etc/init.d/cobblerd restart;;status)/etc/init.d/httpd status/etc/init.d/xinetd status/etc/init.d/dhcpd status/etc/init.d/cobblerd status;;sync)cobbler sync;;*)echo "Input error,please in put 'start|stop|restart|status|sync'!";exit 2>&1 >/dev/null &;;esac:wq! #保存退出chmod +x /etc/rc.d/init.d/cobbler #添加脚本执行权限chkconfig cobbler on #添加开机启动service cobbler restart #重启cobblercobbler check #检查cobbler配置,出现下面的提示,SELinux和防火墙前面已经设置过了,不用理会系统运维 www.osyunwei.com 温馨提醒:qihang01原创内容版权所有,转载请注明出处及原文链接=====================================================================================The following are potential configuration items that you may want to fix:1 : SELinux is enabled. Please review the following wiki page for details on ensuring cobbler works correctly in your SELinux environment:https://github.com/cobbler/cobbler/wiki/Selinux2 : since iptables may be running, ensure 69, 80/443, and 25151 are unblockedRestart cobblerd and then run 'cobbler sync' to apply changes=====================================================================================五、挂载系统安装镜像到http服务器站点目录上传系统安装镜像文件CentOS-5.10-x86_64-bin-DVD-1of2.iso到/usr/local/src/目录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 #挂载系统镜像vi /etc/fstab #添加以下代码。实现开机自动挂载/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! #保存退出备注:iso9660使用df -T 查看设备 卸载:umount /var/www/html/os/CentOS-5.10-x86_64重复上面的操作,把自己需要安装的CentOS系统镜像文件都挂载到/var/www/html/os/目录下例如:CentOS-5.10-x86_64-bin-DVD-1of2.isoCentOS-6.5-x86_64-bin-DVD1.iso原文链接: http://www.osyunwei.com/archives/7606.html 后半章节请参考,http://florasky.blog.51cto.com/4246607/1754896
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  cobbler centos kickstart