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

品运维自动化之cobbler的安装序 推荐

2012-11-01 23:52 483 查看
品运维自动化之cobbler的安装序品茶提示:
1、安装如遇错误,请查看错误报告收集。
2、如遇文章出现错误之处请指出并回复以便帮助更多的朋友,或者发邮件至zwhset@163.com,我将定期回复。

2013/10/24更新内容:
1、添加ks.cfg文件
2012/11/2更新内容:

1、添加安装条件。
2、添加图片。
3、添加cobbler工作流程。
4、增加CentOS6的下载源

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
rpm -ivh http://dl.fedoraproject.org/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm CentOS6 x86_64:
rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-7.noarch.rpm CentOS6 i386:
rpm -ivh http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-7.noarch.rpm
二、开始安装1、Yum安装所需文件
yum install cobbler httpd rsync tftp-server xinetd dhcp python-ctypes -y
2、效验cobbler安装条件
cobbler check
3、更改配置以适用于cobbler运行
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功能}
2、针对SELinux权限设置,在此我们关闭SELinux,也可根据提示进行更改。3、进行更新fedora的loader信息
cobbler get-loaders
4、设置 'disable' 为 'no'
vi /etc/xinetd.d/tftp
5、设置 'disable' 为 'no'
vi /etc/xinetd.d/rsync
6、#your-password-here处设置你需要的密码。此为防止误装。
openssl passwd -1 -salt 'random-phrase-here' 'your-password-here'
7、修改默认dhcp。{注:一例实例,详细可查看以前博客kickstart相关。}
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;}
三、导入镜像进行配置1、上传ISO镜像至服务器2、创建文件夹
mkdir -p /system/centos5.4-i686
3、挂载ISO镜像到/system/centos5.4-i686目录
mount -o loop ~/install/CentOS-5.5-x86-bin-DVD.iso /system/centos5.4-i686/
4、从DVD中导入客户端的OS。这将自动设置了“x86_64”,并将其命名为centos5.4-i686。{注:这需要一点时间,不要急。可查看/var/www/cobbler/ks_mirror/centos5.4-i686-x86_64/目录文件生成情况。}
cobbler import --path=/system/centos5.4-i686/ --name=centos5.4-i686 --arch=x86_64
5、比较一下大小
[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/
6、更改kickstart文件,可为http等,具体cobbler --help查看 {可选择执行}
cobbler profile edit --name=centos5.4-i686-x86_64 --kickstart=???
7、cobbler report进行信息查看{注:下面取一段。方便更加详细了解cobbler结构。}
Name : centos5.4-i686-x86_64TFTP Boot Files : {}Comment : DHCP Tag : defaultDistribution : centos5.4-i686-x86_64Enable gPXE? : 0Enable PXE Menu? : 1Fetchable Files : {}Kernel Options : {}Kernel Options (Post Install) : {}Kickstart : /var/lib/cobbler/kickstarts/sample.ksKickstart Metadata : {}Management Classes : []Management Parameters : <<inherit>>Name Servers : []Name Servers Search Path : []Owners : ['admin']Parent Profile : Proxy : Red Hat Management Key : <<inherit>>Red Hat Management Server : <<inherit>>Repos : []Server Override : <<inherit>>Template Files : {}Virt Auto Boot : 1Virt Bridge : xenbr0Virt CPUs : 1Virt Disk Driver Type : rawVirt File Size(GB) : 5Virt Path : Virt RAM (MB) : 512Virt Type : qemu
8、查看导入列表
cobbler distro list
9、获取上述所有配置的cobbler(包括启动DHCP等)
cobbler sync
10、正确安装后客户端启动出现图为如下:



四、信息区:1、coobler check提示信息:
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/images/.*" 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安装.
更多:可查看下载附件。或者网页地址,

http://blog.chinaunix.net/uid-17240700-id-2813881.html
五、错误报告:1、cobblerd校验错误:
cobblerd does not appear to be running/accessible
解决方法:
service cobblerd startservice httpd start
2、重启httpd错误:
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。
3、httpd、SELinux未运行:
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 startvi /etc/sysconfig/selinuxSELINUX=enforcing更改为SELINUX=disabled,重启使之生效。
4、较验cobbler check出错
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: <Fault 1: "cobbler.cexceptions.CX:'login failed'">
解决方法:此为BUG,按下方操作执行即可。
service cobblerd restartcobbler get-loaders
六、参考地址:
https://github.com/cobbler/cobbler/wiki/Start%20Herehttp://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
煮酒品茶:遇错误多看/var/log/message再根据百度谷歌解决。未完待续......

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日
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息