您的位置:首页 > 其它

搭建Cobbler自动化装机平台

2015-09-01 12:43 295 查看
1.安装软件包


yum -y install cobbler dhcp tftp rsync httpd cobbler-web
2.关闭SELinuxsetenforce 0
3.启动Cobbler
/etc/init.d/cobblerd start
4.启动HTTPD
/etc/init.d/httpd start

5.配置HTTP服务# vim /etc/httpd/conf/httpd.conf ServerName xxxx:80
6.启动wsgi模块# vim /etc/httpd/conf.d/wsgi.conf LoadModule wsgi_module modules/mod_wsgi.so
7.配置TFTP和RSYNC# vim /etc/xinetd.d/tftp disable = no
#chkconfig tftp on
# vim /etc/xinetd.d/rsync disable = no

#chkconfig rsync on
# service xinetd restart
8.配置Cobbler主配置文件# vim /etc/cobbler/settingsserver选项是设置cobbler服务端的IP地址server: xxxx
next_server选项是DHCP/PXE网络引导文件被下载的TFTP服务器的IPnext_server: xxxx
pxe_just_once选项用于设置PXE安装只允许一次,防止误重装系统pxe_just_once: 1
生产cobbler安装系统root初始密码先用openssl生成密码串-1 这里是数字1openssl passwd -1 -salt ‘任间字符’ ‘密码’ (是数字1 不是字母L)# openssl passwd -1 -salt 'xxx' '123456a'# vim /etc/cobbler/settingsdefault_password_crypted: "$1$xxx$GixGhTQvUbfvgwZDIwwKr1"系统安装完成后的root初始密码就是123456a
9.Cobbler配置管理rsync# vim /etc/cobbler/settingsmanage_rsync: 1
10.Cobbler配置管理DHCP启用Cobbler管理DHCP# vim /etc/cobbler/settingsmanage_dhcp: 1
修改/etc/cobbler/dhcp.template# vim /etc/cobbler/dhcp.template
subnet 192.168.2.0 netmask 255.255.255.0 {
option routers 192.168.2.252;
option domain-name-servers 8.8.8.8;
option subnet-mask 255.255.255.0;
range dynamic-bootp 192.168.2.137 192.168.2.141;
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";
}
}

}
如果是多网卡需要指定DHCP服务的网络接口# vim /etc/sysconfig/dhcpdDHCPDARGS=eth0
然后执行cobbler sync然后测试dhcp服务器配置是否正确,可以看到cobbler把/etc/cobbler/dhcp.template同步到/etc/dhcp/dhcpd.conf 了

11.设置debmirror# vim /etc/debmirror.conf #@dists=#@arches=

Cobbler 子命令介绍-------------------------------------------------------------------------------------------cobbler check #检查cobbler配置cobbler sync #同步配置到dhcp pxe和数据目录cobbler list #列出所有的cobbler元素cobbler import #导入安装的系统光盘镜像cobbler report #列出各元素的详细信息cobbler distro #查看导入的发行版系统信息cobbler profile #查看配置信息cobbler system #查看添加的系统信息cobbler reposync #同步yum仓库到本地cobbler signature updatecobbler --help #获得cobbler的帮助 cobbler distro --help #获得cobbler子命令的帮助
12.加载部分缺失的启动文件# cobbler get-loaders
13.检查cobbler配置# cobbler check重新启动和更新相关配置# service cobblerd restart
查看cobbler监听端口# ss -tulnp|grep cobbler
设置相关服务开机自动启动# chkconfig httpd on# chkconfig xinetd on# chkconfig cobblerd on# chkconfig dhcpd on

14.安装和配置Cobbler的WEB管理界面使用WEB界面管理Cobbler很方便,需要安装cobbler-web软件包
设置cobbler web登录的用户名和密码# htdigest /etc/cobbler/users.digest "Cobbler" cobbler
配置cobbler web登录认证# vim /etc/cobbler/modules.conf[authentication]module = authn_configfile
同步cobbler# cobbler sync
重启cobbler 与http # /etc/init.d/cobblerd restart# /etc/init.d/httpd restart

也可以使用pam认证:在/etc/cobbler/modules.conf文件中修改认证方式为authn_pam module = authn_pam新加用户 useradd cobbleradmin passwd cobbleradmin
在/etc/cobbler/users.conf文件中把新加的用户加入cobbler管理员组# vim /etc/cobbler/users.conf [admins]admin = "cobbler"

访问WEB页面http://xxxx/cobbler_web


16.使用cobblermount -o loop /soft/CentOS-6.3-x86_64-bin-DVD1.iso /mnt/cobbler import --path=/mnt/ --name=CentOS-6.3 --arch=x86_64

命令格式:cobbler import --path=镜像路径 -- name=安装引导名 --arch=32位或64位参数说明: --name 为安装源定义一个名字--arch 指定安装源是32位还是64位、ia64, 目前支持的选项有: x86│x86_64│ia64
cobbler会将镜像中的所有安装文件拷贝到本地一份/var/www/cobbler/ks_mirror/CentOS-6.3-x86_64/
导入过后可以对比一下文件大小#du -sh /var/www/cobbler/ks_mirror/CentOS-6.3-x86_64/#du -sh /mnt/

如果上述两个命令执行过显示的结果出入较大, 则可能文件没有正常导入在重新导入之前最好先把之前的内容删除再导入cobbler [distro] remove –name=[CentOS-6.6] 方括号中的内容根据自己的情况来填写 , 更多命令通过cobbler –help 来查看剩下其它系统导入方法类似,只是名字和路径更改下即可。重复上面的操作,把其他的系统镜像文件导入到Cobbler导入完成之后,可通过 cobbler list 来查看导入的结果。
创建kickstarts自动安装脚本(For Centos/RHEL)
CentOS 6的Kickstart参数资料https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Installation_Guide/s1-kickstart2-options.html
默认kickstart文件是/var/lib/cobbler/kickstarts/sample.ks,需要手动为每个发行版单独指定,或单独修改。
自定义ks文件/var/lib/cobbler/kickstarts# vim CentOS-6.3-x86_64.ks
可以使用ksvalidator程序验证kickstart文件中是否有语法错误# ksvalidator CentOS-6.3-x86_64.ks
修改profile指定新的KS启动文件查看profile设置# cobbler profile report --name CentOS6.3-x86_64
查看安装镜像文件信息# cobbler distro report --name CentOS6.3-x86_64
移除profile# cobbler profile remove --name CentOS6.3-x86_64

添加profile# cobbler profile add --name=CentOS-6.3-x86_64 --distro=CentOS-6.3-x86_64 --kickstart=/var/lib/cobbler/kickstarts/CentOS-6.3-x86_64.ks
再次检查profile# cobbler check

注意:
kickstart自动安装文件需要预先配置好每次修改完配置文件,需要执行一次同步操作:cobbler sync 配置才能生效kickstart自动安装文件可以用工具生成(需要用到图形界面操作)yum install system-config-kickstart #安装yum groupinstall "X Window System" #安装X Window图形界面system-config-kickstart #运行kickstart配置

在使用bobbler profile add添加配置文件以后使用cobbler sync同步,其实是把刚才配置的改变写入/var/lib/tftpboot/pxelinux.cfg/default

为Cobbler添加RPM仓库# cobbler repo add --mirror=http://mirrors.ustc.edu.cn/epel/6/x86_64/ --name=epel6-x86_64 --arch=x86_64 --breed=yum
这个只是对centos有效,如果你吧repo添加到profle,他会自动添加到节点上的repo上,指向内网,非常方便。# cobbler profile edit --name=CentOS-6.3-x86_64 --repos="epel6-x86_64"

# cobbler reposync如果执行出错,可以直接手动执行/usr/bin/reposync -l -n -d --config=/var/www/cobbler/repo_mirror/epel6-x86_64/.origin/epel6-x86_64.repo --repoid=epel6-x86_64 --download_path=/var/www/cobbler/repo_mirror -a x86_64
同步Cobbler配置注:每次更改Kickstart 配置文件,都需要使用cobbler sync重新同步所有配置# cobbler sync

17.添加指定客户机系统配置到Cobbler 指定一个网段使用特定的装机配置# cobbler system add --name=xgc --interface=eth0 --subnet=172.28.2.0/24 --profile=CentOS-6.3-x86_64

cobbler checkcobbler sync
18.说明cobbler有许多的配置文件,但是只有少部分基本功能需要修改。
Cobbler最主要的setting file就是/etc/cobbler/settings。Cobbler2.4.0开始引入动态修改模式(Dynamic Settings),我们只需启动这一模式,便不用再手动修改这个文件了。该文件是YAML格式的,如果直接修改setting文件,则必须重启cobbler服务才会生效,但如果是通过CLI命令或者是Web GUI进行修改的话,改动会立即生效,无需重启服务。
修改allow_dynamic_settings的值为1
修改完成后重新启动cobbler/etc/init.d/cobblerd restart
可以通过命令行动态设置
cobbler setting reportcobbler setting report [--name=option]cobbler setting edit --name=option --value=xxx

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 #电源的配置文件
/etc/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日志

###########################################################排错经历部分服务器默认是em开始的网卡,而不是eth开始的网卡在使用cobbler安装系统的过程中,kickstart文件中的网卡识别有两种配置方式network --bootproto=dhcp --device=em1或者$SNIPPET('network_config')

参考资料:http://os.51cto.com/art/201109/288604.htmhttp://werewolftj.blog.51cto.com/1606482/1673779https://github.com/cobbler/cobbler/issues/367http://www.chenshake.com/centos6-4-installation-and-configuration-cobbler-2-4/https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Installation_Guide/s1-kickstart2-options.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: