Linux 运维自动化之Cobbler全自动安装Centos管理与使用详解

简介:

Cobbler 可以用来快速建立 Linux 网络安装环境,它已将 Linux 网络安装的技术门槛,从大专以上文化水平,成功降低到初中以下,连补鞋匠都能学会。

网络安装服务器套件 Cobbler(补鞋匠)从前,我们一直在做装机民工这份很有前途的职业。自打若干年前 Red Hat 推出了 Kickstart,此后我们顿觉身价倍增。不再需要刻了光盘一台一台地安装 Linux,只要搞定 PXE、DHCP、TFTP,还有那满屏眼花缭乱不知所云的 Kickstart 脚本,我们就可以像哈里波特一样,轻点魔棒,瞬间安装上百台服务器。这一堆花里胡哨的东西可不是一般人都能整明白的,没有大专以上学历,通不过英语四级,根本别想玩转。总而言之,这是一份多么有前途,多么有技术含量的工作啊。很不幸,Red Hat 最新(Cobbler项目最初在2008年左右发布)发布了网络安装服务器套件 Cobbler(补鞋匠),它已将 Linux 网络安装的技术门槛,从大专以上文化水平,成功降低到初中以下,连补鞋匠都能学会。对于我们这些在装机领域浸淫多年,经验丰富,老骥伏枥,志在千里的民工兄弟们来说,不啻为一个晴天霹雳。

一、安装软件

1、安装cobbler

[[email protected] ~]# yum install cobbler pykickstart debmirror

2、 其他服务的安装

额外需要的服务还有dhcp tftp,rsync,xinetd,httpd,syslinux。所以如果安装系统的时候如果这几个包没装上,请手动安装。

二、启动服务并检测cobbler

1、启动httpd和cobblerd服务

[[email protected] ~]# /etc/init.d/httpd start
Starting httpd: httpd: apr_sockaddr_info_get() failed for node1 [ OK ]
[[email protected] ~]# /etc/init.d/cobblerd start
Starting cobbler daemon: [ OK ]

2、执行“cobbler check命令检查存的问题,逐一按提示解决:

[[email protected] ~]# cobbler 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 : 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. 
4 : change ‘disable‘ to ‘no‘ in /etc/xinetd.d/rsync 
5 : comment out ‘dists‘ on /etc/debmirror.conf for proper debian support 
6 : comment out ‘arches‘ on /etc/debmirror.conf for proper debian support 
7 : 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 
8 : fencing tools were not found, and are required to use the (optional) 
power management features. install cman or fence-agents to use themRestart cobblerd and then run ‘cobbler sync‘ to apply changes. 
如上各问题的解决方法如下所示: 
1、修改/etc/cobbler/settings文件中,server: 172.16.22.6; 
2、修改/etc/cobbler/settings文件中,next_server: 172.16.22.6; 
3、如果当前节点可以访问互联网,执行“cobbler get-loaders”命令即可;否则,需要安装syslinux程序包,执行: 
[[email protected] ~]# cp /usr/share/syslinux/{pxelinux.0,menu.c32} 
/var/lib/cobbler/loaders/ 
4、执行[[email protected] ~]# chkconfig rsync on 
5、注释/etc/debmirror.conf文件中的“@dists="sid";”一行; 
6、注释/etc/debmirror.conf文件中的“@arches="i386";”一行; 
7、执行“openssl passwd -1 -salt ‘random-phrase-here‘ 
‘your-password-here‘”生成密码,并用替换/etc/cobbler/settings文件中default_password_crypted参数的值,如default_password_crypted: 
"$1$random-p$AOw9RDIWQm6tfUo9Ediu/0"; 
8、执行“yum -y install cman fence-agents”命令安装相应的程序包即可;

3、重启cobblerd服务,同步新的配置至cobbler,再次检测

[[email protected] ~]# /etc/init.d/cobblerd restart
Stopping cobbler daemon: [ OK ]
Starting cobbler daemon: [ OK ]
[[email protected] ~]# cobbler sync
task started: 2014-10-05_172520_sync
task started (id=Sync, time=Sun Oct 5 17:25:20 2014)
running pre-sync triggers
cleaning trees
mkdir: /var/lib/tftpboot/pxelinux.cfg
mkdir: /var/lib/tftpboot/grub
mkdir: /var/lib/tftpboot/s390x
mkdir: /var/lib/tftpboot/ppc
mkdir: /var/lib/tftpboot/etc
removing: /var/lib/tftpboot/grub/images
copying bootloaders
trying hardlink /var/lib/cobbler/loaders/pxelinux.0 -> /var/lib/tftpboot/pxelinux.0
trying hardlink /var/lib/cobbler/loaders/menu.c32 -> /var/lib/tftpboot/menu.c32
copying: /usr/share/syslinux/memdisk -> /var/lib/tftpboot/memdisk
copying distros to tftpboot
copying images
generating PXE configuration files
generating PXE menu structure
rendering TFTPD files
generating /etc/xinetd.d/tftp
cleaning link caches
running post-sync triggers
running python triggers from /var/lib/cobbler/triggers/sync/post/*
running python trigger cobbler.modules.sync_post_restart_services
running shell triggers from /var/lib/cobbler/triggers/sync/post/*
running python triggers from /var/lib/cobbler/triggers/change/*
running python trigger cobbler.modules.scm_track
running shell triggers from /var/lib/cobbler/triggers/change/*
*** TASK COMPLETE ***
[[email protected] ~]# cobbler check

三、配置及启动cobbler所依赖的各服务

cobbler的运行依赖于dhcp、tftp、rsync及dns服务。cobbler可自行管理这些服务中的部分甚至是全部,但需要配置/etc/cobbler/settings文件中的“manage_dhcp”、“manage_tftpd”、“manage_rsync”和“manage_dns”分别进行定义。另外,由于每种服务都有着不同的实现方式,如若需要进行自定义,需要通过修改/etc/cobbler/modules.conf配置文件中各服务的模块参数的值来实现。

本文采用了独立管理的方式,即不通过cobbler来管理这些服务。

1、配置dhcp服务

[[email protected] syslinux]# cp /usr/share/doc/dhcp-4.1.1/dhcpd.conf.sample /etc/dhcp/dhcpd.conf
cp: overwrite `/etc/dhcp/dhcpd.conf‘? y
[[email protected] syslinux]# vim /etc/dhcp/dhcpd.conf
option domain-name "whb.com";
option domain-name-servers 172.16.22.1;
default-lease-time 43200;
max-lease-time 86400;
log-facility local7;
subnet 172.16.0.0 netmask 255.255.0.0 {
range 172.16.22.20 172.16.22.25;
option routers 172.16.22.1;
next-server 172.16.22.6;
filename="pxelinux.0";
}

检查配置文件并重启服务

[[email protected] ~]# /etc/init.d/dhcpd configtest
Syntax: OK
[[email protected] ~]# /etc/init.d/dhcpd restart
Shutting down dhcpd: [ OK ]
Starting dhcpd: [ OK ]

2、配置tftp服务

[[email protected] ~]# chkconfig tftp on
[[email protected] ~]# service xinetd restart
Stopping xinetd: [FAILED]
Starting xinetd: [ OK ]

四、配置cobbler

1、管理distro

挂载ISO镜像,并定义distro,可以通过为其指定外部的安装引导内核及ramdisk文件的方式实现。而如果已经有完整的系统安装树(如CentOS6的安装镜像)则推荐使用import直接导入的方式进行。本文为直接导入

[[email protected] ~]# mount /dev/cdrom /mnt/
mount: block device /dev/sr0 is write-protected, mounting read-only
[[email protected] ~]# cobbler import --name=centos-6.5-x86_64 --path=/mnt/
task started: 2014-10-05_181334_import
task started (id=Media import, time=Sun Oct 5 18:13:34 2014)
Found a candidate signature: breed=redhat, version=rhel6
Found a matching signature: breed=redhat, version=rhel6
Adding distros from path /var/www/cobbler/ks_mirror/centos-6.5-x86_64:
creating new distro: centos-6.5-x86_64
trying symlink: /var/www/cobbler/ks_mirror/centos-6.5-x86_64 -> /var/www/cobbler/links/centos-6.5-x86_64
creating new profile: centos-6.5-x86_64
associating repos
checking for rsync repo(s)
checking for rhn repo(s)
checking for yum repo(s)
starting descent into /var/www/cobbler/ks_mirror/centos-6.5-x86_64 for centos-6.5-x86_64
processing repo at : /var/www/cobbler/ks_mirror/centos-6.5-x86_64
need to process repo/comps: /var/www/cobbler/ks_mirror/centos-6.5-x86_64
looking for /var/www/cobbler/ks_mirror/centos-6.5-x86_64/repodata/*comps*.xml
running: createrepo -c cache -s sha --groupfile /var/www/cobbler/ks_mirror/centos-6.5-x86_64/repodata/0dae8d32824acd9dbdf7ed72f628152dd00b85e4bd802e6b46e4d7b78c1042a3-c6-x86_64-comps.xml /var/www/cobbler/ks_mirror/centos-6.5-x86_64
received on stdout: Spawning worker 0 with 3887 pkgs
Workers Finished
Gathering worker results
Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
Sqlite DBs complete
received on stderr:
*** TASK COMPLETE *** 
列出所有的distro:
[[email protected] ~]# cobbler distro list
centos-6.5-x86_64

2、管理profile

cobbler使用profile来为特定的需求类别提供所需要安装配置,即在distro的基础上通过提供kickstart文件来生成一个特定的系统安装配置。distro的profile可以出现在PXE的引导菜单中作为安装的选择之一。

因此,如果需要为前面创建的centos-6.5-x86_64这个distro提供一个可引导安装条目,其用到的kickstart文件为/tmp/centos-6.5-x86_64.cfg(只提供了最基本的程序包),则可通过如下命令实现。

[[email protected] ~]# cobbler profile add --name=centos-6.5-x86_64-basic --distro=centos-6.5-x86_64 --kickstart=/tmp/centos6.x86_64.cfg
列出所有的profile:
[[email protected] tmp]# cobbler profile list
centos-6.5-x86_64
centos-6.5-x86_64-basic

五、测试

新建虚拟机,网络启动

看到这个图就大功告成了!!!!!

时间: 2024-08-01 20:35:03

Linux 运维自动化之Cobbler全自动安装Centos管理与使用详解的相关文章

运维自动化工具Cobbler之——安装实践

运维自动化工具--Cobbler实践 第1章 About Cobbler 1.1 Cobbler Introduction Cobbler是一个Linux服务器安装的服务,可以通过网络启动(PXE)的方式来快速安装.重装物理服务器和虚拟机,同时还可以管理DHCP,DNS等. Cobbler可以使用命令行方式管理,也提供了基于Web的界面管理工具(cobbler-web),还提供了API接口,可以方便二次开发使用.Cobbler是较早前的kickstart的升级版,优点是比较容易配置,还自带web

运维自动化之Cobbler部署安装RHEL7.0(详细图解版)

一.简介     Cobbler 可以用来快速建立 Linux 网络安装环境,它已将 Linux 网络安装的技术门槛,从大专以上文化水平,成功降低到初中以下,连补鞋匠都能学会.          网络安装服务器套件 Cobbler(补鞋匠)从前,我们一直在做装机民工这份很有前途的职业.自打若干年前 Red Hat 推出了 Kickstart,此后我们顿觉身价倍增.不再需要刻了光盘一台一台地安装 Linux,只要搞定 PXE.DHCP.TFTP,还有那满屏眼花缭乱不知所云的 Kickstart 脚

linux运维自动化之puppet简单应用(一)

一.pupper概述 puppet,这是目前运维主流的运维自动化工具,大多数运维管理人员都听说过,或者在使用以及在正在考虑使用中.puppet可以配合cobbler,puppet也可以配合func实现运维自动化,简单化,化繁杂为简单. 1.什么是puppet puppet是一种Linux.Unix平台的集中配置管理系统,使用ruby语言,可管理配置文件.用户.cron任务.软件包.系统服务等.puppet把这些系统实体称之为资源,puppet的设计目标是简化对这些资源的管理以及妥善处理资源间的依

运维自动化之Cobbler系统安装详解

原文链接 参考文档 参考文档SA们现在都知道运维自动化的重要性,尤其是对于在服务器数量按几百台.几千台增加的公司而言,单单是装系统,如果不通过自动化来完成,根本是不可想象的. 运维自动化安装方面,早期一般使用人工配置pxe+dhcp+tftp配合kickstart,现在开源工具就多了,如cobbler,OpenQRM和Spacewalk.本文重点介绍Cobbler. Cobbler介绍 Cobbler是一个快速网络安装linux的服务,而且在经过调整也可以支持网络安装windows.该工具使用p

linux运维自动化之puppet简单应用(二)

上篇博客介绍了在单机环境下的puppet应用,这次我们基于C/S模式来介绍下puppet! 一.实验环境 服务器角色 IP地址 安装软件 主机名 服务器端 172.16.8.1 puppet-server www.gulong.com 客户机端 172.16.8.2 puppet node1.gulong.com 客户机端 172.16.8.3 puppet node2.gulong.com 三台主机时间同步: #ntpdate 172.16.0.1 三台主机可以相互解析: # vim /etc

运维自动化之ansible playbook安装mysql

上次介绍了如何使用ansible playbook安装zabbix客户端(http://dl528888.blog.51cto.com/2382721/1436745),这次介绍一下如何使用playbook安装mysql. 下面是安装mysql的信息: mysql_basedir: /data/mysql/basedir                    源码目录 mysql_datadir: /data/mysql/datadir                    数据目录 mysql

运维自动化之ansible playbook安装ruby环境

本来不想打算写安装ruby的,但看几个puppet的群里有人对安装ruby比较茫然,所以这里简单介绍一下如何安装ruby. ps:话说现在也就gitlab.capistrano.puppet等软件使用ruby,最新2010年的软件好的都是python了,比如ansible.salt等. 下面是安装ruby的信息: ruby_version: 1.9.3 ruby_dir: /usr/local gem_version: 1.8.23 bundle_version: 1.6.3 可以看到ruby的

运维自动化之ansible playbook安装node环境

现在介绍如何使用ansible安装node. 下面是安装node的信息: node_dir: /data node_version: 0.10.21 node_port: 3301 可以看到node的版本是0.10.21,测试的node应用服务监听3301端口 备注:此playbook仅能对centos或者redhat的6.x版本进行安装. 下面是安装node的playbook结构 09:33:16 # tree node_* node_delete ├── files ├── handlers

运维自动化之ansible playbook安装lamp环境

下面介绍使用ansible playbook安装lamp环境 下面是apache的安装信息: apr_version: 1.5.0 apr_util_version: 1.5.3 libiconv_version: 1.14 apache_version: 2.4.7 apache_web_dir: /data/webroot/apache apache_log: /data/webroot/apache/logs apache_vhost: /data/webroot/apache/vhost