Chinaunix首页 | 论坛 | 博客
  • 博客访问: 6791388
  • 博文数量: 3857
  • 博客积分: 6409
  • 博客等级: 准将
  • 技术积分: 15948
  • 用 户 组: 普通用户
  • 注册时间: 2008-09-02 16:48
个人简介

迷彩 潜伏 隐蔽 伪装

文章分类

全部博文(3857)

文章存档

2017年(5)

2016年(63)

2015年(927)

2014年(677)

2013年(807)

2012年(1241)

2011年(67)

2010年(7)

2009年(36)

2008年(28)

分类: 系统运维

2015-09-20 23:41:02

Linux运维自动化之Cobbler安装部署RHEL7.0

[日期:2015-09-20] 来源:Linux社区  作者:luoj1992 [字体:  ]

一、简介

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

网络安装服务器套件 Cobbler(补鞋匠)从前,我们一直在做装机民工这份很有前途的职业。自打若干年前 Red Hat 推出了 Kickstart,此后我们顿觉身价倍增。不再需要刻了光盘一台一台地安装 Linux,只要搞定 PXE、DHCP、TFTP,还有那满屏眼花缭乱不知所云的 Kickstart 脚本,我们就可以像哈里波特一样,轻点魔棒,瞬间安装上百台服务器。这一堆花里胡哨的东西可不是一般人都能整明白的,没有大专以上学历,通不过英语四级, 根本别想玩转。总而言之,这是一份多么有前途,多么有技术含量的工作啊。

很不幸,Red Hat 最新(Cobbler项目最初在2008年左右发布)发布了网络安装服务器套件 Cobbler(补鞋匠),它已将 Linux 网络安装的技术门槛,从大专以上文化水平,成功降低到初中以下,连补鞋匠都能学会。对于我们这些在装机领域浸淫多年,经验丰富,老骥伏枥,志在千里的民工兄弟们来说,不啻为一个晴天霹雳。

--------------------------------------------分割线------------------------------------------------------

系统环境

实验环境:VMware Workstation 11

系统平台:RHEL7

网络模式:NAT(使用本地DHCP)

Cobbler版本:2.6.9.

网段:192.168.27.0

本机IP:192.168.27.131

防火墙已关闭/iptables: Firewall is not running.

SELINUX=disabled

--------------------------------------------分割线------------------------------------------------------

前期准备

所需要用到的服务:EPEL、DHCP、TFTP、HTTP、VSFTP

注:EPEL (Extra Packages for Enterprise Linux,企业版Linux的额外软件包) 是Fedora小组维护的一个软件仓库项目,为RHEL/CentOS提供他们默认不提供的软件包。这个源兼容RHEL及像CentOS和Scientific Linux这样的衍生版本。

1.配置本地yum仓库,挂载光盘镜像

[root@linuxidc 桌面]#vim /etc/yum.repos.d/rhel7.repo

[rhel7]

name=rhel7

basurel=file:///mnt

enabled=1

gpgcheck=0

将光盘挂载到/mnt中

[root@linuxidc 桌面]#mount /dev/cdrom /mnt

2.安装EPEL

要想安装EPEL,我们先要下载EPEL的rpm安装包。

CentOS7/RHEL7的下载页面如下,版本不用担心一般都能用,不一定非要用我这个版本,根据你们不同版本的操作系统选择自己合适的包。

通过以下命令安装EPEL 软件包

[root@linuxidc 桌面]#rpm -ivh epel-release-6-8.noarch.rpm

安装好EPEL 源后,用yum 命令来检查是否添加到源列表

[root@linuxidc 桌面]# yum repolist
已加载插件:langpacks, product-id, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
源标识              源名称                                                状态
epel/x86_64        Extra Packages for Enterprise Linux 7 - x86_64        8,477
rhel7              rhel7                                                  4,305
repolist: 12,782

--------------------------------------------分割线------------------------------------------------------

安装Cobbler-Web 界面和DHCP

Cobbler 提供了一个很有用的 Web 界面,您可以通过该界面实现此目的。要使用这个界面,首先需要安装它的程序包:

[root@linuxidc 桌面]#yum -y install cobbler-web

上面这个步骤可能会出现依赖包问题,解决方案见文章底下的解决方案。

安装完成后系统会给你安装以下所有的包,如果有的包没有安装上,还请手动安装

已安装:

cobbler-web.noarch 0:2.6.9-1.el7                                             

作为依赖被安装:

  • PyYAML.x86_64 0:3.10-11.el7                                                 
  • apr.x86_64 0:1.4.8-3.el7                                                     
  • apr-util.x86_64 0:1.5.2-6.el7                                               
  • cobbler.noarch 0:2.6.9-1.el7                                                 
  • httpd.x86_64 0:2.4.6-17.el7                                                 
  • httpd-tools.x86_64 0:2.4.6-17.el7                                           
  • mod_ssl.x86_64 1:2.4.6-17.el7                                               
  • mod_wsgi.x86_64 0:3.4-11.el7                                                 
  • python-cheetah.x86_64 0:2.4.4-4.el7                                         
  • python-django.noarch 0:1.6.11-2.el7                                         
  • python-django-bash-completion.noarch 0:1.6.11-2.el7                         
  • python-markdown.noarch 0:2.4.1-1.el7                                         
  • python-netaddr.noarch 0:0.7.5-7.el7                                         
  • python-simplejson.x86_64 0:3.3.3-1.el7                                       
  • tftp-server.x86_64 0:5.2-11.el7                                             
  • xinetd.x86_64 2:2.3.15-12.el7   

[root@linuxidc 桌面]# yum -y install dhcp

--------------------------------------------分割线------------------------------------------------------

命令配置Cobbler

一、重启cobbler服务

[root@linuxidc 桌面]#systemctl enable cobblerd.service

[root@linuxidc 桌面]#systemctl start cobblerd.service

[root@linuxidc 桌面]#systemctl enable httpd

[root@linuxidc 桌面]#systemctl start httpd

--------------------------------------------------------------------------------------------------------

二、检查cobbler配置

执行检查配置命令

[root@linuxidc 桌面]#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 : change 'disable' to 'no' in /etc/xinetd.d/tftp

4 : 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.

5 : file /etc/xinetd.d/rsync does not exist

6 : debmirror package is not installed, it will be required to manage debian deployments and repositories

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 them

Restart cobblerd and then run 'cobbler sync' to apply changes.

上面这段信息大意就是

1,编辑/etc/cobbler/settings文件,找到 server选项,修改为提供服务的ip地址(也就是你这台机器的IP地址,不能是127.0.0.1)

2,编辑/etc/cobbler/settings文件,找到 next_server选项,修改为127.0.0.1以外的地址(也就是本机IP地址)

3,编辑/etc/xinetd.d/tftp文件,将文件中的disable字段的配置由yes改为no

4,执行 cobbler get-loaders,系统将自动下载loader程序,完成提示4的修复工作。

5,文件/etc/xinetd.d/rsync不存在

6,提示说debmirror没安装。如果不是安装 debian之类的系??,此提示可以忽略,如果需要安装,下载地址为:

7,修改cobbler用户的默认密码,可以使用如下命令生成密码,并使用生成后的密码替换/etc/cobbler/settings中的密码。生成密码命令:openssl passwd -1 -salt 'random-phrase-here' 'your-password-here'

-------------------------------------------------------------------------------------------

三、配置过程

[root@linuxidc 桌面]# openssl passwd -1 -salt "cobbler" "123456"                  //生成新的密码,密码为123456,此密码就是安装完系统后的root密码

$1$cobbler$sqDDOBeLKJVmxTCZr52/11                  //复制该代码

[root@linuxidc 桌面]# vim /etc/cobbler/settings        //打开配置文件,修改3处地方

server: 192.168.27.131            //把127.0.0.1改为本机的IP地址

next_server: 192.168.27.131            //把127.0.0.1改为本机的IP地址

default_password_crypted: "$1$cobbler$sqDDOBeLKJVmxTCZr52/11"            //把原来的加密密码改为上面咱们复制的那个密码

[root@linuxidc 桌面]# vim /etc/xinetd.d/tftp       

disable                = no                //找到disable那行把yes改成no

[root@linuxidc 桌面]# cobbler get-loaders 

......        //略过

......

*** TASK COMPLETE ***        //最后出现这个提示说明操作正确,其他均为错误

[root@linuxidc 桌面]# cobbler import --path=/mnt/ --name=rhel7.0            //把挂载光盘镜像的mnt目录中的内容导入到cobbler里

......        //略过

......

*** TASK COMPLETE ***        //最后出现这个提示说明操作正确,其他均为错误

注意:检查挂载路径是否正确,挂载路径可去前期准备中查看。

[root@linuxidc 桌面]# systemctl restart cobblerd.service

--------------------------------------------------------------------------------------------------------

四、配置DHCP服务

首先修改cobbler配置,让cobbler来管理dhcp服务,编辑文件/etc/cobbler/settings

[root@linuxidc 桌面]# vim /etc/cobbler/settings

manage_dhcp: 1

接下来修改/etc/cobbler/dhcp.template,此文件是cobbler管理dhcp的模板

对于此文件,本例中只需要修改如下部分:

subnet 192.168.27.0 netmask 255.255.255.0 {

option routers            192.168.27.131;

option domain-name-servers 192.168.27.131;

option subnet-mask        255.255.255.0;

range dynamic-bootp        192.168.27.100 192.168.27.120;

default-lease-time        21600;

max-lease-time            43200;

next-server                $next_server;

其余部分维持默认值即可。

到目前为止,全部的准备工作已经就算全部完成。

--------------------------------------------------------------------------------------------------------------------------

五、同步cobbler配置

[root@linuxidc 桌面]# cobbler sync    //执行同步命令

......        //略过

......

*** TASK COMPLETE ***        //最后出现这个提示说明操作正确,其他均为错误

cobbler会自动进行初始化工作,移除已经存在的启动项,然后根据模板拷贝loader文件。之后再生成pxe的配置文件,生成dhcp的配置文件,最后再重启dhcp服务。

[root@linuxidc 桌面]# systemctl restart cobblerd.service 
[root@linuxidc 桌面]# systemctl restart xinetd.service 
[root@linuxidc 桌面]# cobbler sync

至此,就可以使用虚拟机来测试cobbler安装了。

===========================================================================================

打开Cobbler-web进行配置

上面所有步骤均为命令方式进行配置,咱们还可以用一种简单的方法进行配置,那就是网页图形化配置了。

用火狐浏览器打开下面的网站

用户名和密码均为:cobbler

功能讲解(左侧标签):

Distros:关于要安装系统的版本信息,包括启动文件的地址,版本,架构

Profiles:主要就是选择ks文件以及虚拟化的配置

Kickstart Templates:集中管理ks文件,可以在里面创建新的ks文件(手写)或者导入ks文件。

Snippets:片段这个玩意暂时还没搞清楚,如果有人了解还望不吝赐教。

Settings:这个里面的数据就是/etc/cobbler/settings的配置文件,你可以通过网页来直接修改配置文件中的内容

Import DVD:导入安装源镜像,如果没有导入过Distros和Profiles不会有内容

Sync:同步的意思

Check:检查   

    对于Web界面下的配置我这里就不过多讲解了,大部分都是点点鼠标的事,大家可以用命令配置完成后打开网页来观察一下,我上面的功能注释都是大家需要配置的,点击Profiles后右侧会出现你导入的系统,然后点击Edit按钮就可以找到选择ks脚本,ks脚本是从Kickstart Templates中调用的,ks文件你可以自己编译,如果懒得编译,安装完成后就是最小化安装。

    关于ks文件的编译我建议是用kiskstart来进行(比较方便,不容易出错)

--------------------------------------------分割线------------------------------------------------------

--------------------------------------------分割线------------------------------------------------------

实验过程中可能会遇到的问题

1.

python-pygments依赖包关系错误解决办法:

打开下面的网页,找到对应你系统的rpm包,我最后选择的是CentOS 7.1.1503 for x86_64这个系统版本的,没有找到红帽的。

我会在附件中加上这个rpm包,大家可以自己去下载,也可以用我这个包。

在安装python-pygments包的时候可能还需要安装一个依赖包python-imanging。

这个包直接yum -y install python-imanging就可以直接安装上,然后再去安装python-pygments。

rpm -ivh --force python-pygments-1.4-9.el7.noarch.rpm

安装完成后即可安装cobbler-web包了。

2.

[root@linuxidc 桌面]# cobbler check
httpd does not appear to be running and proxying cobbler, or SELinux is in the way. Original traceback:
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/cobbler/cli.py", line 252, in check_setup
    s.ping()

解决办法:遇到这种问题查看httpd服务是否正常启动,关闭SELinux服务并重启即可。

3.注意,一定要先配置cobbler管理dhcp的模板,不要过早启动DHCP不然会出现BUG。而且DHCP服务不需要你手动去开启,只要你在/etc/cobbler/settings文件中把manage_dhcp改为1之后你在同步配置文件DHCP会自动起来。

4.如果全都配置完毕,客户机可以获取到DHCP但卡在TFTP的时候就去检查防火墙是否关闭。

资源包

EPEL包

epel-release-7-5.noarch.rpmepel-release-7-5.noarch

Python-pygments包

选其一

  • python-pygments-1.4-9.el7.noarch
  • python-pygments-1.1.1-1.el6.noarch
  • python-pygments-1.4-1.el6.rfx.noarch

Linux运维自动化之Cobbler安装部署RHEL7.0 相关资源包下载

百度云网盘下载

------------------------------------------分割线------------------------------------------

免费下载地址在 

用户名与密码都是

具体下载目录在 /2015年资料/9月/20日/Linux运维自动化之Cobbler安装部署RHEL7.0/

下载方法见 

------------------------------------------分割线------------------------------------------

 更多RedHat相关信息见RedHat 专题页面 

本文永久更新链接地址

阅读(637) | 评论(0) | 转发(0) |
0

上一篇:CentOS下安装JDK8

下一篇:在CentOS下安装pip

给主人留下些什么吧!~~