博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
cobbler运维自动化安装linux
阅读量:6278 次
发布时间:2019-06-22

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

Cobbler批量装系统

1、 简介

网络安装服务器套件 Cobbler(补鞋匠)从前,我们一直在做装机民工这份很有前途的职业。自打若干年前 Red Hat 推出了 Kickstart,此后我们顿觉身价倍增。不再需要刻了光盘一台一台地安装 Linux,只要搞定 PXE、DHCP、TFTP,还有那满屏眼花缭乱不知所云的 Kickstart 脚本,我们就可以像哈里波特一样,轻点魔棒,瞬间安装上百台服务器。这一堆花里胡哨的东西可不是一般人都能整明白的,没有大专以上学历,通不过英语四级, 根本别想玩转。总而言之,这是一份多么有前途,多么有技术含量的工作啊。很不幸,Red Hat 最新(Cobbler项目最初在2008年左右发布)发布了网络安装服务器套件 Cobbler(补鞋匠),它已将 Linux 网络安装的技术门槛,从大专以上文化水平,成功降低到初中以下,连补鞋匠都能学会。对于我们这些在装机领域经营多年,经验丰富,老骥伏枥,志在千里的民工兄弟们来说,不啻为一个晴天霹雳。
2、 系统环境准备
[root@bogon ~]# cat /etc/redhat-release
CentOS release 6.7 (Final)
[root@bogon ~]# uname -r
2.6.32-573.el6.x86_64
[root@bogon ~]# ifconfig|awk -F "[ :]+" 'NR==2 {print $4}'
192.168.1.131
添加阿里epel源
[root@bogon ~]# wget -O /etc/yum.repos.d/epel.repo - 6.repo
准备环境软件httpd、dhcp、xinetd、rsync、pykickstart、cobbler和cobbler-web:
[root@bogon ~]# yum install -y httpd dhcp xinetd rsync pykickstart
[root@bogon ~]# yum install -y cobbler cobbler-web
报错:Error: Package: cobbler-web-2.6.11-7.git95749a6.el6.noarch (epel)
Requires: Django >= 1.4
缺少依赖包:Djange,Djange依赖包是python-simplejson,所以
[root@bogon ~]# yum install -y python-simplejson
[root@bogon ~]# wgethttps://kojipkgs.fedoraproject.org//packages/Django14/1.4.14/1.el6/noarch/Django14-1.4.14-1.el6.noarch.rpm
[root@bogon ~]# rpm -ivh Django14-1.4.14-1.el6.noarch.rpm
3、 配置文件
[root@bogon ~]# /etc/init.d/httpd status
httpd (pid 1960) is running...
[root@bogon ~]# /etc/init.d/cobblerd status
cobblerd (pid 1948) is running...
[root@bogon ~]# cobbler check #检查cobcler配置
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 : change 'disable' to 'no' in /etc/xinetd.d/rsync
6 : since iptables may be running, ensure 69, 80/443, and 25151 are unblocked
7 : debmirror package is not installed, it will be required to manage debian deployments and repositories
8 : 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
9 : 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.

关于问题:
6、防火墙iptables还在运行
[root@bogon ~]# setenforce 0
setenforce: SELinux is disabled
[root@bogon ~]# service iptables stop
[root@bogon ~]# chkconfig iptables off
[root@bogon ~]# vim /etc/selinux/config
SELINUX=disabled
1、2、在/etc/cobbler/settings修改server,next_server的IP地址
[root@bogon ~]# sed -i "s/next_server: 127.0.0.1/next_server: 192.168.1.131/g" /etc/cobbler/settings
[root@bogon ~]# sed -i "s/server: 127.0.0.1/server: 192.168.1.131/g" /etc/cobbler/settings
修改cobbler管理dhcp和tftp
[root@bogon ~]# sed -i "s/manage_dhcp: 0/manage_dhcp: 1/" /etc/cobbler/settings
[root@bogon ~]# sed -i "s/manage_rsync: 0/manage_rsync: 1/g" /etc/cobbler/settings
PXE启动时不允许重复装机
[root@bogon ~]# sed -i 's/pxe_just_once: 0/pxe_just_once: 1/g' /etc/cobbler/settings
8、设置系统登录的root密码openssl passwd -1 -salt 'guoge' 'your-password-here'"
[root@bogon ~]# openssl passwd -1 -salt 'guoge' '123456' ##guoge为干扰内
##123456为密码
$1$guoge$4kUDFV7TavolzgIUxLM2m0
[root@bogon ~]# vim /etc/cobbler/settings
default_password_crypted: "$1$guoge$4kUDFV7TavolzgIUxLM2m0" ##红色为修改内容

3、5、修改/etc/xinetd.d/rsync 和/etc/xinetd.d/rsync

[root@bogon ~]# sed -i "s/disable = yes/disable = no/g" /etc/xinetd.d/rsync
[root@bogon ~]#sed -i "s/disable = yes/disa disable = no /g" /etc/xinetd.d/tftp
4、需要使用cobbler get-loaders命令下载loaders文件
[root@bogon ~]# cobbler get-loaders
task started: 2018-07-31_080115_get_loaders
task started (id=Download Bootloader Content, time=Tue Jul 31 08:01:15 2018)
downloading to /var/lib/cobbler/loaders/README
downloading to /var/lib/cobbler/loaders/COPYING.elilo
downloading to /var/lib/cobbler/loaders/COPYING.yaboot
downloading to /var/lib/cobbler/loaders/COPYING.syslinux
downloading to /var/lib/cobbler/loaders/elilo-ia64.efi
downloading to /var/lib/cobbler/loaders/yaboot
downloading to /var/lib/cobbler/loaders/pxelinux.0
downloading to /var/lib/cobbler/loaders/menu.c32
downloading to /var/lib/cobbler/loaders/grub-x86.efi
downloading to /var/lib/cobbler/loaders/grub-x86_64.efi
TASK COMPLETE
所下载的文件在/var/lib/cobbler/loaders/当中
[root@bogon ~]# cobbler sync同步配置
重启服务
[root@bogon ~]# /etc/init.d/xinetd restart
Stopping xinetd: [FAILED]
Starting xinetd: [ OK ]
[root@bogon ~]# /etc/init.d/cobblerd restart
Stopping cobbler daemon: [ OK ]
Starting cobbler daemon: [ OK ]
[root@bogon ~]# cobbler check
The following are potential configuration items that you may want to fix:

1 : service dhcpd is not running

2 : debmirror package is not installed, it will be required to manage debian deployments and repositories # 和debian系统相关,不需要

3 : fencing tools were not found, and are required to use the (optional) power management features. install cman or fence-agents to use them # fence设备相关,不需要

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

问题1、配置并启动DHCP
[root@bogon ~]# vim /etc/cobbler/dhcp.template
subnet 192.168.1.0 netmask 255.255.255.0 {
option routers 192.168.1.131;
option domain-name-servers 192.168.1.131;
option subnet-mask 255.255.255.0;
range dynamic-bootp 192.168.1.100 192.168.1.254;
default-lease-time 21600;
max-lease-time 43200;
next-server $next_server;
[root@bogon ~]# cobbler sync同步配置
设置开机自启动:
[root@bogon ~]# /etc/init.d/httpd restart
[root@bogon ~]#/etc/init.d/xinetd restart
[root@bogon ~]# /etc/init.d/dhcpd restart
[root@bogon ~]# /etc/init.d/cobblerd restart
[root@bogon ~]# chkconfig --level 35 httpd on
[root@bogon ~]# chkconfig --level 35 xinetd on
[root@bogon ~]# chkconfig --level 35 dhcpd on
[root@bogon ~]# chkconfig --level 35 cobblerd on

4、 设置镜像

[root@bogon ~]# mount /dev/cdrom /mnt/
[root@bogon ~]# cobbler import --path=/mnt/ --name=Centos-6.7-x86_64 --arch=x86_64
[root@bogon ~]# cobbler sync
[root@bogon ~]# /etc/init.d/httpd restart
[root@bogon ~]#/etc/init.d/xinetd restart
[root@bogon ~]# /etc/init.d/dhcpd restart
[root@bogon ~]# /etc/init.d/cobblerd restart
5、 ks.cfk文件
[root@bogon ~]# cat /var/lib/cobbler/kickstarts/sample_e
sample_end.ks sample_esx4.ks sample_esxi4.ks sample_esxi5.ks
[root@bogon ~]# cat /var/lib/cobbler/kickstarts/sample_e
sample_end.ks sample_esx4.ks sample_esxi4.ks sample_esxi5.ks
[root@bogon ~]# cat /var/lib/cobbler/kickstarts/sample_end.ks

# kickstart template for Fedora 8 and later.# (includes %end blocks)# do not use with earlier distros#platform=x86, AMD64, or Intel EM64T# System authorization informationauth  --useshadow  --enablemd5# System bootloader configurationbootloader --location=mbr# Partition clearing informationclearpart --all --initlabel# Use text mode installtext# Firewall configurationfirewall --enabled# Run the Setup Agent on first bootfirstboot --disable# System keyboardkeyboard us# System languagelang en_US# Use network installationurl --url=$tree# If any cobbler repo definitions were referenced in the kickstart profile, include them here.$yum_repo_stanza# Network information$SNIPPET('network_config')# Reboot after installationreboot#Root passwordrootpw --iscrypted $default_password_crypted# SELinux configurationselinux --disabled# Do not configure the X Window Systemskipx# System timezonetimezone  America/New_York# Install OS instead of upgrade# install# Clear the Master Boot Recordzerombr#### Allow anaconda to partition the system as neededautopart%pre$SNIPPET('log_ks_pre')$SNIPPET('kickstart_start')$SNIPPET('pre_install_network_config')#### Enable installation monitoring$SNIPPET('pre_anamon')%end%packages$SNIPPET('func_install_if_enabled')%end%post --nochroot$SNIPPET('log_ks_post_nochroot')%end%post$SNIPPET('log_ks_post')#### Start yum configuration$yum_config_stanza#### End yum configuration$SNIPPET('post_install_kernel_options')$SNIPPET('post_install_network_config')$SNIPPET('func_register_if_enabled')$SNIPPET('download_config_files')$SNIPPET('koan_environment')$SNIPPET('redhat_register')$SNIPPET('cobbler_register')#### Enable post-install boot notification$SNIPPET('post_anamon')### Start final steps$SNIPPET('kickstart_done')###  ## End final steps%end

查看安装镜像文件信息

[root@bogon ~]#cobbler distro report --name=CentOS-7.1-x86_64
查看所有的profile设置
[root@bogon ~]# cobbler profile report
查看指定的profile设置
[root@bogon ~]#cobbler profile report --name=CentOS-7.1-x86_64
[root@bogon ~]# cobbler sync同步配置

cobbler运维自动化安装linuxcobbler运维自动化安装linuxcobbler运维自动化安装linuxcobbler运维自动化安装linux

6、 cobbler-web支持网页登录

/etc/cobbler/users.conf # Web服务授权配置文件
/etc/cobbler/users.digest # 用于web访问的用户名密码配置文件 [root@bogon ~]# cat /etc/cobbler/users.digest
cobbler:Cobbler:a2d6bae81669d707b72c0bd9806e01f3
设置Cobbler web用户登陆密码
在Cobbler组添加cobbler用户
[root@linux-node1 ~]# htdigest /etc/cobbler/users.digest "Cobbler" cobbler
Changing password for user cobbler in realm Cobbler
New password: 123456
Re-type new password:123456
登录地址为:
账户密码:cobbler 123456
cobbler运维自动化安装linux
cobbler运维自动化安装linux

参考

转载于:https://blog.51cto.com/11575772/2152537

你可能感兴趣的文章
Web服务器的配置与管理(4) 配置访问权限和安全
查看>>
Linux系统安装VMware Tools
查看>>
asp.net 页面右下角弹出类似QQ或MSN的消息提示
查看>>
游戏开发经常使用算法概述
查看>>
EDM制作要点
查看>>
爆牙齿的Web标准面试考题II(iPhone SMS/iChat UI的Web标准实现)
查看>>
XMOVE3.0手持终端——软件介绍(二):在2KB内存的单片机上实现的彩屏GUI控件库
查看>>
MVC系列——MVC源码学习:打造自己的MVC框架(三:自定义路由规则)
查看>>
找小于N 的所有质数
查看>>
Windows下的Jupyter Notebook 的介绍(写给新手)(图文详解)
查看>>
iOS开发-CocoaPods实战
查看>>
JS组件系列——Bootstrap 树控件使用经验分享
查看>>
HTML-color:rgb()-颜色渐进
查看>>
数据库实例: STOREBOOK > 表空间 > 编辑 表空间: UNDOTBS1
查看>>
Mcad学习笔记之异步编程(AsyncCallback委托,IAsyncResult接口,BeginInvoke方法,EndInvoke方法的使用小总结)...
查看>>
Javascript防冒泡事件与Event对象
查看>>
managed domain与unmanaged domain
查看>>
《中国人工智能学会通讯》——11.47 领域文本中的实体链接技术
查看>>
刚毕业不久,就在人工智能上做出这样大贡献
查看>>
中国人工智能学会通讯——迎接深度学习的“大”挑战(下) 1.2 深度学习的挑战和机遇...
查看>>