博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Cobbler自动化批量部署CentOS6.5系统
阅读量:5111 次
发布时间:2019-06-13

本文共 10307 字,大约阅读时间需要 34 分钟。

Cobbler作为一个预备工具,使批量部署Red Hat/Centos/Fedora系统更容易,同时也支持Suse和Debian系统的部署。

它提供以下服务集成:

  * PXE服务支持

  * DHCP服务管理
  * DNS服务管理
  * Kickstart服务支持
  * yum仓库管理
Cobbler客户端Koan支持虚拟机安装和操作系统重新安装功能.

一、cobbler安装准备

  系统:CentOS6.5 64位

  IP地址:192.168.132.128

1.关闭selinux

[root@localhost ~]#vim /etc/selinux/config#SELINUX=enforcing            #注释掉#SELINUXTYPE=targeted      #注释掉SELINUX=disabled                 #增加:wq!  #保存退出[root@localhost ~]#setenforce 0 	 #使配置立即生效[root@localhost ~]#sestatus		 #重启后查看

2.关闭iptables

[root@localhost ~]#chkconfig iptables off[root@localhost ~]#/etc/init.d/iptables stop

3.下载epel源的rpm安装包并安装cobbler软件

[root@localhost ~]#wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm[root@localhost ~]#rpm -ivh epel-release-6-8.noarch.rpm[root@localhost ~]#yum -y install cobbler cobbler-web httpd rsync tftp-server xinetd dhcp python-ctypes debmirror pykickstart fence-agents cman[root@localhost ~]# /etc/init.d/cobblerd startStarting cobbler daemon:                                   [  OK  ][root@localhost ~]# /etc/init.d/httpd startStarting httpd: 																					 [  OK  ][root@localhost ~]#

4.检查配置执行:

[root@localhost ~]# cobbler checkTraceback (most recent call last):  File "/usr/bin/cobbler", line 36, in 
sys.exit(app.main()) File "/usr/lib/python2.6/site-packages/cobbler/cli.py", line 657, in main rc = cli.run(sys.argv) File "/usr/lib/python2.6/site-packages/cobbler/cli.py", line 270, in run self.token = self.remote.login("", self.shared_secret) File "/usr/lib64/python2.6/xmlrpclib.py", line 1199, in __call__ return self.__send(self.__name, args) File "/usr/lib64/python2.6/xmlrpclib.py", line 1489, in __request verbose=self.__verbose File "/usr/lib64/python2.6/xmlrpclib.py", line 1253, in request return self._parse_response(h.getfile(), sock) File "/usr/lib64/python2.6/xmlrpclib.py", line 1392, in _parse_response return u.close() File "/usr/lib64/python2.6/xmlrpclib.py", line 838, in close raise Fault(**self._stack[0])xmlrpclib.Fault:
:'login failed'">

报错了

经过网上查找这样解决如下:

[root@localhost ~]# /etc/init.d/cobblerd restartStopping cobbler daemon:                                   [  OK  ]Starting cobbler daemon:                                   [  OK  ][root@localhost ~]# [root@localhost ~]# cobbler get-loaderstask started: 2016-04-07_020452_get_loaderstask started (id=Download Bootloader Content, time=Thu Apr  7 02:04:52 2016)downloading http://cobbler.github.io/loaders/README to /var/lib/cobbler/loaders/READMEdownloading http://cobbler.github.io/loaders/COPYING.elilo to /var/lib/cobbler/loaders/COPYING.elilodownloading http://cobbler.github.io/loaders/COPYING.yaboot to /var/lib/cobbler/loaders/COPYING.yabootdownloading http://cobbler.github.io/loaders/COPYING.syslinux to /var/lib/cobbler/loaders/COPYING.syslinuxdownloading http://cobbler.github.io/loaders/elilo-3.8-ia64.efi to /var/lib/cobbler/loaders/elilo-ia64.efidownloading http://cobbler.github.io/loaders/yaboot-1.3.17 to /var/lib/cobbler/loaders/yabootdownloading http://cobbler.github.io/loaders/pxelinux.0-3.86 to /var/lib/cobbler/loaders/pxelinux.0downloading http://cobbler.github.io/loaders/menu.c32-3.86 to /var/lib/cobbler/loaders/menu.c32downloading http://cobbler.github.io/loaders/grub-0.97-x86.efi to /var/lib/cobbler/loaders/grub-x86.efidownloading http://cobbler.github.io/loaders/grub-0.97-x86_64.efi to /var/lib/cobbler/loaders/grub-x86_64.efi*** TASK COMPLETE ***

再次检查配置:

[root@localhost ~]# cobbler checkThe 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/tftp4 : change 'disable' to 'no' in /etc/xinetd.d/rsync5 : file /etc/xinetd.d/rsync does not exist6 : comment out 'dists' on /etc/debmirror.conf for proper debian support7 : comment out 'arches' on /etc/debmirror.conf for proper debian support8 : ksvalidator was not found, install pykickstart9 : 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 oneRestart cobblerd and then run 'cobbler sync' to apply changes.

根据cobbler check 检测所的信息,进行相应配置:

1.配置tftp-server与rsync 设置rsync和tftp服务开机启动.

编辑/etc/cobbler/settings文件,找到 server选项,修改为适当的ip地址,本实例配置ip为:192.168.132.128sed -i 's@manage_dhcp: 0@manage_dhcp: 1@g' /etc/cobbler/settingssed -i 's@next_server: 127.0.0.1@next_server: '192.168.132.128'@g' /etc/cobbler/settingssed -i 's@server: 127.0.0.1@server: '192.168.132.128'@g' /etc/cobbler/settings

2.配置tftp-server与rsync.

sed -i 's/disable.*$/disable = no/g' /etc/xinetd.d/tftpsed -i 's/disable.*$/disable = no/g' /etc/xinetd.d/rsync

3.提示说debmirror没安装。如果不是安装 debian之类的系统,此提示可以忽略。

4.安装pykickstart.

[root@localhost ~]# yum install pykickstart -y

5.生成密码串(设置默认 root 用户的密码):

[root@localhost ~]# openssl passwd -1 -salt 'random-phrase-here' 'saneri'$1$random-p$3a6Zq0MlL6NuutFGzwxGJ.然后将结果替换 /etc/cobbler/settings 文件中的default_password_crypted:

根据提示基本配置完成了,OK再来执行检查.

[root@localhost cobbler]# /etc/init.d/cobblerd restartStopping cobbler daemon:                                   [  OK  ]Starting cobbler daemon:                                   [  OK  ][root@localhost cobbler]# cobbler checkThe following are potential configuration items that you may want to fix:1 : service dhcpd is not running2 : file /etc/xinetd.d/rsync does not exist3 : comment out 'dists' on /etc/debmirror.conf for proper debian support4 : comment out 'arches' on /etc/debmirror.conf for proper debian supportRestart cobblerd and then run 'cobbler sync' to apply changes.

配置dhcp服务 

修改/etc/cobbler/dhcp.template,此文件是cobbler管理dhcp的模板和/etc/dhcp/dhcpd.conf文件,两个配置内容一样cat > /etc/cobbler/dhcp.template <

重新启动相关服务

[root@localhost cobbler]# /etc/init.d/dhcpd restartStarting dhcpd:                                            [  OK  ][root@localhost dhcp]# /etc/init.d/cobblerd restartStopping cobbler daemon:                                   [  OK  ]Starting cobbler daemon:                                   [  OK  ][root@localhost dhcp]# /etc/init.d/xinetd restartStopping xinetd:                                           [  OK  ]Starting xinetd:                                           [  OK  ]

同步配置模板

[root@localhost dhcp]# cobbler sync										#同步配置模板task started: 2016-04-07_052540_synctask started (id=Sync, time=Thu Apr  7 05:25:40 2016)running pre-sync triggerscleaning treesremoving: /var/www/cobbler/images/CentOS6.5-x86_64removing: /var/lib/tftpboot/pxelinux.cfg/defaultremoving: /var/lib/tftpboot/grub/imagesremoving: /var/lib/tftpboot/grub/grub-x86.efiremoving: /var/lib/tftpboot/grub/efidefaultremoving: /var/lib/tftpboot/grub/grub-x86_64.efiremoving: /var/lib/tftpboot/images/CentOS6.5-x86_64removing: /var/lib/tftpboot/s390x/profile_listcopying bootloaderstrying hardlink /var/lib/cobbler/loaders/grub-x86.efi -> /var/lib/tftpboot/grub/grub-x86.efitrying hardlink /var/lib/cobbler/loaders/grub-x86_64.efi -> /var/lib/tftpboot/grub/grub-x86_64.eficopying distros to tftpbootcopying files for distro: CentOS6.5-x86_64trying hardlink /var/www/cobbler/ks_mirror/CentOS6.5-x86_64/images/pxeboot/vmlinuz -> /var/lib/tftpboot/images/CentOS6.5-x86_64/vmlinuztrying hardlink /var/www/cobbler/ks_mirror/CentOS6.5-x86_64/images/pxeboot/initrd.img -> /var/lib/tftpboot/images/CentOS6.5-x86_64/initrd.imgcopying imagesgenerating PXE configuration filesgenerating PXE menu structurecopying files for distro: CentOS6.5-x86_64trying hardlink /var/www/cobbler/ks_mirror/CentOS6.5-x86_64/images/pxeboot/vmlinuz -> /var/www/cobbler/images/CentOS6.5-x86_64/vmlinuztrying hardlink /var/www/cobbler/ks_mirror/CentOS6.5-x86_64/images/pxeboot/initrd.img -> /var/www/cobbler/images/CentOS6.5-x86_64/initrd.imgWriting template files for CentOS6.5-x86_64rendering DHCP filesgenerating /etc/dhcp/dhcpd.confrendering TFTPD filesgenerating /etc/xinetd.d/tftpprocessing boot_files for distro: CentOS6.5-x86_64cleaning link cachesrunning post-sync triggersrunning python triggers from /var/lib/cobbler/triggers/sync/post/*running python trigger cobbler.modules.sync_post_restart_servicesrunning: dhcpd -t -qreceived on stdout: received on stderr: running: service dhcpd restartreceived on stdout: Starting dhcpd: [  OK  ]received on stderr: 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_trackrunning shell triggers from /var/lib/cobbler/triggers/change/**** TASK COMPLETE ***

挂载系统镜像并导入镜像:

[root@localhost ~]#mkdir /mnt/ios/[root@localhost ~]#mount -t iso9660 -o loop /dev/cdrom /mnt/ios/[root@localhost ~]#cobbler import --path=/mnt/ios --name=CentOS6.5 --arch=x86_64#命令格式:cobbler import --path=镜像路径 -- name=安装引导名 --arch=32位或64位

查看导入源库列表:

[root@localhost dhcp]# cobbler distro list    CentOS6.5-x86_64################################################  至此cobbler已经可以使用了################################################

Cobbler常用命令详解:

cobbler check     #检查cobbler配置(主要用于检查cobbler配置是否有错.)

cobbler sync       #同步配置到dhcp/pxe和数据目录(注,同步cobbler配置到数据目录中,更改某些配置后得执行一下,同步一下配置)
cobbler list         #列出所有的cobbler元素
cobbler import    #导入安装的系统镜像
cobbler report        #列出各元素的详细信息
cobbler distro         #查看导入的发行版系统信息
cobbler profile        #查看配置信息
cobbler system       #查看添加的系统信息
cobbler reposync     #同步yum仓库到本地   

cobbler profile remove --name=CentOS6.5x86_64-x86_64                    #移除profilecobbler distro remove --name=CentOS6.5x86_64-x86_64			      #移除distro cobbler profile report --name  CentOS6.5-x86_64 				 #查看profile设置cobbler profile report --name  CentOS6.5-x86_64					 #查看安装镜像文件信息 cobbler profile add --name=centos-6.5-x86_64 --distro=centos-6.5-x86_64 --kickstart=/var/lib/cobbler/kickstarts/centos-6.5-x86_64.ks    #添加

.

.

参阅文档:

       

转载于:https://www.cnblogs.com/saneri/p/5378125.html

你可能感兴趣的文章
oracle 几个时间函数探究
查看>>
第一个Java Web程序
查看>>
树状数组_一维
查看>>
如果没有按照正常的先装iis后装.net的顺序,可以使用此命令重新注册一下:
查看>>
linux install ftp server
查看>>
嵌入式软件设计第8次实验报告
查看>>
算法和数据结构(三)
查看>>
Ubuntu下的eclipse安装subclipse遇到没有javahl的问题...(2天解决了)
查看>>
alter database databasename set single_user with rollback IMMEDIATE 不成功问题
查看>>
Repeater + Resources 列表 [原创][分享]
查看>>
WCF揭秘——使用AJAX+WCF服务进行页面开发
查看>>
【题解】青蛙的约会
查看>>
IO流
查看>>
mybatis调用存储过程,获取返回的游标
查看>>
设计模式之装饰模式(结构型)
查看>>
面向对象的设计原则
查看>>
Swift3.0服务端开发(三) Mustache页面模板与日志记录
查看>>
【转】 FPGA设计的四种常用思想与技巧
查看>>
EntityFrameWork 实现实体类和DBContext分离在不同类库
查看>>
新手算法学习之路----二叉树(在一个二叉查找树中插入一个节点)
查看>>