品运维自动化之cobbler的安装序
品茶提示:
1、安装如遇错误,请查看错误报告收集。
2、如遇文章出现错误之处请指出并回复以便帮助更多的朋友,或者发邮件至[email protected],我将定期回复。
2013/10/24更新内容:
1、添加ks.cfg文件 |
2012/11/2更新内容:
1、添加安装条件。 |
2012/11/3更新内容:
1、更新视平教程,建议全屏观看,挺清楚的。{注:声音哑了,不是太好。中间有一个卡顿是由于cobbler improt载入时间太长,将近半个小时。所以后期剪了一下。} |
使用前提:
1、你有一个DVD或ISO文件,您的操作系统的分布。 2、服务器有足够的本地磁盘的可用空间在/var/www/cobbler 解压缩DVD/ISO。 3、服务器和客户端都有一个共同的IP网络。 4、这个网络上的DHCP服务器的服务器是唯一的实例。 5、在此网络上的客户端是支持PXE网络启动。 |
Cobbler工作流程:
一、加载Fedor的Epel源
CentOS 5 x86_64 |
yum install cobbler httpd rsync tftp-server xinetd dhcp python-ctypes -y |
cobbler check |
vi /etc/cobbler/settings |
'next_server: 127.0.0.1' 替换成 'next_server:本机IP地址' {注:此为DHCP服务地址}
'server: 127.0.0.1' 替换成 'server: 192.168.0.28' {此为cobbler服务地址}
'manage_dhcp: 0' 替换成 'manage_dhcp: 1' {注:此为使cobbler管理dhcp也就是后面用于同步更新配置信息[cobbler sync]}
'manage_rsync: 0' 替换成 'manage_rsync: 1' {注:此为使cobbler管理rsync功能}
|
cobbler get-loaders |
vi /etc/xinetd.d/tftp |
vi /etc/xinetd.d/rsync |
openssl passwd -1 -salt 'random-phrase-here' 'your-password-here' |
vi /etc/cobbler/dhcp.template |
ddns-update-style interim;
allow booting;
allow bootp;
ignore client-updates;
set vendorclass = option vendor-class-identifier;
#需要修改192.168.0.0为自己网段
subnet 192.168.0.0 netmask 255.255.255.0 {
#修改自己的路由
option routers 192.168.0.1;
#域名服务器地址
option domain-name-servers 202.106.0.20;
#子网掩码
option subnet-mask 255.255.255.0;
#分配IP地址段
range dynamic-bootp 192.168.0.100 192.168.0.254;
filename "/pxelinux.0";
default-lease-time 21600;
max-lease-time 43200;
next-server $next_server;
}
|
mkdir -p /system/centos5.4-i686 |
mount -o loop ~/install/CentOS-5.5-x86-bin-DVD.iso /system/centos5.4-i686/ |
cobbler import --path=/system/centos5.4-i686/ --name=centos5.4-i686 --arch=x86_64 |
[root@cobbler ~]# du -sh /var/www/cobbler/ks_mirror/centos5.4-i686-x86_64/
3.9G
/var/www/cobbler/ks_mirror/centos5.4-i686-x86_64/
[root@cobbler ~]# du -sh /system/centos5.4-i686/
4.1G
/system/centos5.4-i686/
|
cobbler profile edit --name=centos5.4-i686-x86_64 --kickstart=??? |
Name : centos5.4-i686-x86_64
TFTP Boot Files : {}
Comment :
DHCP Tag : default
Distribution : centos5.4-i686-x86_64
Enable gPXE? : 0
Enable PXE Menu? : 1
Fetchable Files : {}
Kernel Options : {}
Kernel Options (Post Install) : {}
Kickstart : /var/lib/cobbler/kickstarts/sample.ks
Kickstart Metadata : {}
Management Classes : []
Management Parameters : <
Name Servers : []
Name Servers Search Path : []
Owners : ['admin']
Parent Profile :
Proxy :
Red Hat Management Key : <
Red Hat Management Server : <
Repos : []
Server Override : <
Template Files : {}
Virt Auto Boot : 1
Virt Bridge : xenbr0
Virt CPUs : 1
Virt Disk Driver Type : raw
Virt File Size(GB) : 5
Virt Path :
Virt RAM (MB) : 512
Virt Type : qemu
|
cobbler distro list |
cobbler sync |
10、正确安装后客户端启动出现图为如下:
The following are potential configuration items that you may want to fix:
1 : The 'server' field in /etc/cobbler/settings must be set to something other than localhost, or kickstarting features will not work. This should be a resolvable hostname or IP for the boot server as reachable by all machines that will use it.
2 : For PXE to be functional, the 'next_server' field in /etc/cobbler/settings must be set to something other than 127.0.0.1, and should match the IP of the boot server on the PXE network.
3 : you need to set some SELinux content rules to ensure cobbler serves content correctly in your SELinux environment, run the following: /usr/sbin/semanage fcontext -a -t public_content_t "/tftpboot/.*" && /usr/sbin/semanage fcontext -a -t public_content_t "/var/www/cobbler/p_w_picpaths/.*"
4 : you need to set some SELinux rules if you want to use cobbler-web (an optional package), run the following: /usr/sbin/semanage fcontext -a -t httpd_sys_content_rw_t "/var/lib/cobbler/webui_sessions/.*"
5 : some network boot-loaders are missing from /var/lib/cobbler/loaders, you may run 'cobbler get-loaders' to download them, or, if you only want to handle x86/x86_64 netbooting, you may ensure that you have installed a *recent* version of the syslinux package installed and can ignore this message entirely. Files in this directory, should you want to support all architectures, should include pxelinux.0, menu.c32, elilo.efi, and yaboot. The 'cobbler get-loaders' command is the easiest way to resolve these requirements.
6 : change 'disable' to 'no' in /etc/xinetd.d/tftp
7 : change 'disable' to 'no' in /etc/xinetd.d/rsync
8 : debmirror package is not installed, it will be required to manage debian deployments and repositories
9 : The default password used by the sample templates for newly installed machines (default_password_crypted in /etc/cobbler/settings) is still set to 'cobbler' and should be changed, try: "openssl passwd -1 -salt 'random-phrase-here' 'your-password-here'" to generate new one
Restart cobblerd and then run 'cobbler sync' to apply changes.
|
2、什么是Rsync
rsync is an open source utility that provides fast incremental file transfer. rsync is freely available under the GNU General Public License and is currently being maintained by Wayne Davison. Rsync是一个开源的 应用程序,提供快速增量文件传输。Rsync是免费提供根据GNU通用公共许可证,目前正在维护 韦恩·戴维森。 |
3、收集常用命令:
#重命名安装选项名字: cobbler profile rename --name='old name' –newname='new name' #册除选项: cobbler profile rename --name='old name' |
4、KickStart options详解:
引用:
kickstart是什么 许多系统管理员宁愿使用自动化的安装方法来安装红帽企业 Linux.为了满足这种需要,红帽创建了kickstart安装方法.使用kickstart,系统管理员可以创建一个文件,这个文件包含了在典型的安装过程中所遇 到的问题的答案. Kickstart文件可以存放于单一的服务器上,在安装过程中被独立的机器所读取.这个安装方法可以支持使用单一kickstart文件在多台机器上安装红帽企业Linux,这对于网络和系统管理员来说是个理想的选择. Kickstart给用户提供了一种自动化安装红帽企业Linux的方法. 如何执行kickstart安装 kickstart 安装可以使用本地光盘,本地硬盘驱动器,或通过 NFS,FTP,HTTP 来执行. 要使用 kickstart,必须: 1.创建一个kickstart文件. 2.创建有kickstart文件的引导介质或者使这个文件在网络上可用. 3.筹备安装树. 4.开始kickstart安装. |
cobblerd does not appear to be running/accessible |
service cobblerd start
service httpd start
|
Starting httpd: Syntax error on line 10 of /etc/httpd/conf.d/cobbler.conf:
Invalid command 'WSGIScriptAliasMatch', perhaps misspelled or defined by a module not included in the server configuration
|
vi /etc/httpd/conf.d/wsgi.conf |
#LoadModule wsgi_module modules/mod_wsgi.so 去掉#号,使之成为:LoadModule wsgi_module modules/mod_wsgi.so。 |
httpd does not appear to be running and proxying cobbler, or SELinux is in the way. Original traceback:
Traceback (most recent call last):
|
service httpd start
vi /etc/sysconfig/selinux
SELINUX=enforcing更改为SELINUX=disabled,重启使之生效。
|
Traceback (most recent call last):
File "/usr/bin/cobbler", line 35, in ?
sys.exit(app.main())
File "/usr/lib/python2.4/site-packages/cobbler/cli.py", line 558, in main
rc = cli.run(sys.argv)
File "/usr/lib/python2.4/site-packages/cobbler/cli.py", line 202, in run
self.token = self.remote.login("", self.shared_secret)
File "/usr/lib64/python2.4/xmlrpclib.py", line 1096, in __call__
return self.__send(self.__name, args)
File "/usr/lib64/python2.4/xmlrpclib.py", line 1383, in __request
verbose=self.__verbose
File "/usr/lib64/python2.4/xmlrpclib.py", line 1147, in request
return self._parse_response(h.getfile(), sock)
File "/usr/lib64/python2.4/xmlrpclib.py", line 1286, in _parse_response
return u.close()
File "/usr/lib64/python2.4/xmlrpclib.py", line 744, in close
raise Fault(**self._stack[0])
xmlrpclib.Fault: |
service cobblerd restart
cobbler get-loaders
|
https://github.com/cobbler/cobbler/wiki/Start%20Here
http://dl528888.blog.51cto.com/2382721/1004298
#cobbler设置相关:
https://github.com/cobbler/cobbler/wiki/Using%20Cobbler%20Import
#KickStart配置: https://github.com/cobbler/cobbler/wiki/Kickstart%20snippets |
未完待续......
kickstart file:
注:这是从51CTO一网友搞过来的,忘了地址。
#set $swap= $getVar('$swap', '12000') autostep --autoscreenshot install url --url=$tree # If any cobbler repo definitions were referenced in the kickstart profile, include them here. $yum_repo_stanza text skipx lang en_US.UTF-8 keyboard us network --onboot yes --bootproto dhcp --noipv6 --nodns rootpw --iscrypted $1$xzY0mzCP$bBhzWwNV.ECfF.MV9PRkC1 firewall --disabled firstboot --disabled authconfig --enableshadow --passalgo=sha512 selinux --disabled #timezone --isUtc Asia/Shanghai timezone --utc Asia/Shanghai # The following is the partition information you requested # Note that any partitions you deleted are not expressed # here so unless you clear all partitions first, this is # not guaranteed to work logging --level=info #bootloader --append="nohz=off" --location=mbr bootloader --location=mbr #bootloader --location=mbr --driveorder=sda --append="biosdevname=0 nohz=off thash_entries=1048576 rhash_entries=1048576 selinux=0" zerombr yes # clearpart --all --initlabel --drives=sda clearpart --all --initlabel # ignoredisk --only-use=sda #part / --fstype=ext4 --asprimary --size=50000 --maxsize=50000 --label=/ #part swap --asprimary --size=$swap --maxsize=$swap --label=swap #part /data --fstype=xfs --grow --asprimary --size=12000 --label=/data part /boot --fstype="ext4" --size=200 part swap --fstype="swap" --size=1024 part / --fstype="ext4" --grow --size=1 %pre $SNIPPET('pre_install_network_config') # Add Pre-Installation Script here date %end %packages --excludedocs --ignoremissing @base @core @development @server-policy telnet -iptables %end $SNIPPET('services_disable_enable') %post $SNIPPET('post_install_network_config') $SNIPPET('env_init') $SNIPPET('kis_cobbler_api') $SNIPPET('cactirelease') $SNIPPET('kisyum_install') /usr/sbin/eject -rv /dev/sr* # eject P cdrom echo 'v1.3' > ~root/VERSION %end # finish reboot #reboot --eject |
煮酒品茶记于2012/11/1日