《Cobbler自动化安装操作系统手册.docx》由会员分享,可在线阅读,更多相关《Cobbler自动化安装操作系统手册.docx(19页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、Cobbler自动化安装操作系统手册Cobbler自动化安装操作系统手册一、基础环境服务器与网络环境:Cobbler服务器系统:CentOS release 6.6 64位需要安装部署的Linux系统:Centos or Ubuntueth0(第一块网卡,用于外网)IP地址段:192.168.76.*-192.168.76*.*子网掩码:255.255.255.0网关:192.168. 75.*二、Cobbler部署 通过配置Cobbler服务器,全自动批量安装部署Linux系统,以下均在Cobbler服务器上操作1、关闭SELINUXvim /etc/selinux/config#注释掉#S
2、ELINUX=enforcing#注释掉#SELINUXTYPE=targeted#增加SELINUX=disabled 使配置立即生效:setenforce 0验证: /usr/sbin/sestatus -v 或 getenforce2、配置防火墙开放TCP:80、TCP:25151、UDP:69等 或 关闭防火墙vim /etc/sysconfig/iptables#http服务需要此端口-A RH-Firewall-1-INPUT -m state -state NEW -m tcp -p tcp -dport 80 -j ACCEPT#tftp服务需要此端口-A RH-Firewal
3、l-1-INPUT -m state -state NEW -m udp -p udp -dport 69 -j ACCEPT#cobbler需要此端口-A RH-Firewall-1-INPUT -m state -state NEW -m tcp -p tcp -dport 25151 -j ACCEPT 重启防火墙使配置生效:/etc/init.d/iptables restart关闭防火墙: service iptables stop开机off:chkconfig iptables off验证:service iptables status3、安装Cobbler安装centos6.x
4、64位 cobbler依赖源和cobbler# 安装centos6.xcobbler依赖源cd /usr/local/srcwget http:/dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm rpm ivh epel-release-6-8.noarch.rpm# 安装cobbleryum install cobbler tftp tftp-server xinetd dhcp httpd rsync#安装运行cobbler依赖软件包yum install pykickstart debmirror pyt
5、hon-ctypes cman备注: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/5/i386/epel-release-5-4.noarch.rpm #CentOS 5.x 32位wget http:/dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm #CentOS6.x 32位4、配置Cobble
6、r(1)设置http服务vim /etc/httpd/conf.d/wsgi.conf#取消前面的注释LoadModule wsgi_module modules/mod_wsgi.so 开机启动:chkconfig httpd on 启动:service httpd start (2)设置tftp服务开机启动vim /etc/cobbler/tftpd.template service tftp disable = no socket_type = dgram protocol = udp wait = yes user = $user server = $binary server_arg
7、s = -B 1380 -v -s $args per_source = 11 cps = 100 2 flags = IPv4(3)设置rsync服务开机启动CentOS中是以xinetd 来管理Rsync和tftp服务vim /etc/xinetd.d/rsync service rsync #修改为nodisable = no socket_type = streamwait = nouser = rootserver = /usr/bin/rsyncserver_args = -daemonlog_on_failure += USERID启动:/etc/init.d/xinetd st
8、art(4)配置cobbler相关参数注释掉debmirro.conf文件中 dists 和 arches 两行vim /etc/debmirror.conf #dists=sid;#arches=i386; 生成默认模板下系统安装完成之后root账号登录密码,并记录下输出行openssl passwd -1 -salt osyunwei 123456 #记录下这行,下面会用到$1$osyunwei$sEV8iwXXuR4CqzLXyLnzm0 vim /etc/cobbler/settings default_password_crypted: $1$osyunwei$sEV8iwXXuR4
9、CqzLXyLnzm0next_server: 192.168.21.128server: 192.168.21.128manage_dhcp: 1default_kickstart: /var/lib/cobbler/kickstarts/default.ks(5)配置dhcp服务器vim /etc/cobbler/dhcp.template #设置网段subnet 192.168.21.0 netmask 255.255.255.0 #设置网关option routers 192.168.21.2; #设置dns服务器地址option domain-name-servers 8.8.8.8
10、,8.8.4.4; #设置子网掩码option subnet-mask 255.255.255.0;#设置dhcp服务器IP地址租用的范围range dynamic-bootp 192.168.21.160 192.168.21.200;#默认租约时间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
11、 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;指定DHCP服务的网络接口,eth0 必须是服务器可以用的网卡vim /etc/sysconfig/dhcpd DHCPDARGS=eth0测试dhcp服务器配置是否正确:dh
12、cpddhcpd设置开机启动:chkconfig dhcpd oncobblerd设置开机启动:chkconfig cobblerd on 安装cobbler相关工具包,否则检查cobbler配置会报错cobbler get-loaders启动cobbler: service cobblerd start 同步配置文件到dhcp服务器:cobbler sync启动dhcp服务:service dhcpd start 注意:cobbler sync#安装cobbler错误集锦:xmlrpclib.Fault: 查看导入列表,如果报如下内容,需要重启cobbler,并执行cobbler get-l
13、oaders.service cobblerd restartcobbler get-loaders页面方位cobbler_web: http:/Ip /cobbler_web(6)设置cobbler相关服务启动脚本将上面的cobbler脚本文件放于/etc/rc.d/init.d/目录下,并通过chmod +x /etc/rc.d/init.d/cobbler 赋予执行权限设置开机启动:chkconfig cobbler on启动cobbler服务:service cobbler restart检查cobbler配置,出现下面的提示,SELinux和防火墙前面已经设置,不用理会cobbler
14、 check =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: 2 : since iptables may be running, ensure 69, 80/443, and 25151 are unblockedRes
15、tart cobblerd and then run cobbler sync to apply changes=5、安装cobbler-webyum install cobbler-web修改认证方式为密码文件类型vi /etc/cobbler/modules.conf module = authn_configfile = module = authn_pam 设置用户名密码为已存在的用户cobbler重置密码htdigest /etc/cobbler/users.digest Cobbler cobbler添加新用户htdigest /etc/cobbler/users.digest C
16、obbler Test_user1cobbler同步:cobbler sync,输出* TASK COMPLETE * 表示配置无错误重启cobbler、http/etc/init.d/httpd restart/etc/init.d/cobblerd restart访问,登录http:/192.168.10.128/cobbler_web/do_login6、挂载系统镜像到http服务器站点目录上传系统安装镜像文件CentOS-5.10-x86_64-bin-DVD-1of2.iso到/usr/local/src/目录# 创建挂载目录mkdir -p /var/www/html/os/Cen
17、tOS-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备注:iso9660使用df -T 查看设备 卸载:umo
18、unt /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.iso7、创建kickstarts自动安装脚本将CentOS-5.10-x86_64.ks(Centos.*)、ubuntu1204.seed、 ubuntu1404-docker.seed(ubuntu*)文件放于/var/lib/cobbler/kickstarts/(默认Kicks
19、tart模板目录)下,并修改其中Cobbler地址、root用户密码、时区、用户与用户组等. . .url -url=http:/192.168.21.128/cobbler/ks_mirror/CentOS-5.10-x86_64-x86_64/rootpw -iscrypted $1$QqobZZ1g$rYnrawi9kYlEeUuq1vcRS/timezone Asia/Shanghai. . .#添加用户useradd -g maintain user01 -d /home/maintain/user01 -mecho 123456|passwd user01 -stdinuserad
20、d -g maintain user02 -d /home/maintain/user02 -m. . .# cd /root# wget http:/192.168.21.128/cobbler/ks_mirror/config/autoip.sh# sh /root/autoip.sh若配置了执行外部脚本。则可将autoip.sh文件等外部脚本放于/var/www/cobbler/ks_mirror/config/下,并修改hostname与DNS、广播地址等参数。8、导入系统镜像到cobbler#导入系统镜像文件,需要一段时间cobbler import -path=/var/www/h
21、tml/os/CentOS-5.10-x86_64 -name=CentOS-5.10-x86_64 -arch=x86_64#查看系统镜像导入目录cd /var/www/cobbler/ks_mirror 命令格式:cobbler import -path=镜像路径 - name=安装引导名 -arch=32位或64位重复上面的操作,把其他的系统镜像文件导入到cobbler9、设置profile按操作系统版本分别关联系统镜像文件和kickstart自动安装文件在第一次导入系统镜像时,cobbler会给安装镜像指定一个默认的kickstart自动安装文件例如:CentOS-5.10-x86_6
22、4版本的kickstart自动安装文件为:/var/lib/cobbler/kickstarts/sample.ks#查看profile设置cobbler profile report -name CentOS-5.10-x86_64 #查看安装镜像文件信息cobbler distro report -name CentOS-5.10-x86_64#移除profilecobbler profile remove -name=CentOS-5.10-x86_64 #添加cobbler profile add -name=CentOS-5.10-x86_64 -distro=CentOS-5.10
23、-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 附: cobbler profile add|edit|remove -name=安装引导名 -distro=系统镜像名 -kickstart=kickstart自动安装文件路径-name:
24、自定义的安装引导名,注意不能重复-distro:系统安装镜像名,用cobbler distro list可以查看-kickstart:与系统镜像文件相关联的kickstart自动安装文件#查看Cobbler列表cobbler listcobbler reportcobbler profile reportcobbler distro list#通过profile查找对应的kickstart自动安装文件文件例如:ksfile=$( cobbler profile report name CentOS-5.10-x86_64|grep -E Kickstart |head -n 1|cut -d
25、: -f 2 );cat $ksfile;重复上面的操作,把其他的系统镜像文件和kickstart自动安装文件关联起来注意:1、kickstart自动安装文件需要预先配置好2、每次修改完配置文件,需要执行一次同步操作:cobbler sync 配置才能生效3、kickstart自动安装文件可以用工具生成(需要用到图形界面操作)#安装yum install system-config-kickstart #安装X Window图形界面yum groupinstall X Window System #运行kickstart配置system-config-kickstart #与cobbler s
26、ync作用相同service cobbler sync#重启cobblerservice cobbler restart三、自动化安装系统1、首次安装系统设置要安装的服务器从网络启动开机之后,如下图所示,根据需要选择相应的系统版本进行安装,安装完成之后,系统会自动重启2、重新安装系统在需要重装系统的服务器上安装koan#CentOS 5.Xwget http:/dl.fedoraproject.org/pub/epel/5/x86_64/koan-2.4.0-1.el5.noarch.rpm #安装koanrpm -ivh koan-2.4.0-1.el5.noarch.rpm#CentOS
27、6.Xhttp:/dl.fedoraproject.org/pub/epel/6/x86_64/koan-2.4.0-1.el6.noarch.rpm #安装koan运行依赖包(需要设置epel源)yum install cobbler debmirror pykickstart python-ctypes cman#查看Cobbler服务器系统镜像列表koan -list=profiles -server=192.168.21.128 #选择要重装的系统koan -replace-self -server=192.168.21.128 -profile=CentOS-5.10-x86_64#
28、重新启动系统进行自动安装reboot 四、扩展阅读Cobbler目录说明1、Cobbler配置文件目录:/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 #电源的配置文件/e
29、tc/cobbler/users.conf #Web服务授权配置文件/etc/cobbler/users.digest #用于web访问的用户名密码配置文件/etc/cobbler/dnsmasq.template #DNS服务的配置模板/etc/cobbler/modules.conf #Cobbler模块配置文件2、Cobbler数据目录:/var/lib/cobbler/var/lib/cobbler/config #配置文件/var/lib/cobbler/triggers #Cobbler命令/var/lib/cobbler/kickstarts #默认存放kickstart文件/var/lib/cobbler/loaders #存放的各种引导程序3、系统安装镜像目录:/var/www/cobbler/var/www/cobbler/ks_mirror #导入的系统镜像列表/var/www/cobbler/images #导入的系统镜像启动文件/var/www/cobbler/repo_mirror #yum源存储目录4、日志目录:/var/log/cobbler/var/log/cobbler/install.log #客户端系统安装日志/var/log/cobbler/cobbler.log #cobbler日志
限制150内