cobbler 實現無人值守網絡批量安裝操做系統

2016-12-02node

這裏只是安裝文檔:不涉及介紹linux

環境:
     VMware: 12
     cobbler 主機:CentOS 6.7 
     IP: 
          eth0:10.10.111.20/24 管理使用
          eth1: VM dhcp 聯網
     
     dhcp地址池:10.10.111.191-10.10.111.200/24
          GATEWAY:10.10.111.1 (物理的vm1網卡地址)                

環境配置:
     關閉selinux:
     sed -i '/^SELINUX=/ s/^SELINUX=.*/SELINUX=disabled/g' /etc/selinux/config
     關閉iptables:
     service iptables stop && chkconfig iptables off
     重啓生效

安裝配置epel源:
     安裝yum優先級插件:
     yum install yum-priorities -y
     安裝epel源:
     rpm -Uvh http://mirrors.ustc.edu.cn/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm
     rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
     導入key:
      rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
     重建緩存
     yum makecache

安裝Cobbler:
     這裏 sync tftpd都是使用Cobbler自帶
     yum install cobbler cobbler-web pykickstart debmirror cman fence-agents dhcp bind -y
     
啓動服務:
     service httpd start && service cobblerd start

cobbler配置文件路徑:/etc/cobbler/
     主配置文件:settings

檢查cobbler環境:
     cobbler check
     問題:
    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 : file /etc/xinetd.d/rsync does not exist
    7 : comment out 'dists' on /etc/debmirror.conf for proper debian support
    8 : comment out 'arches' on /etc/debmirror.conf for proper debian support
    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
     問題解決:根據提示解決,我的的以下
          修改配置文件:settings
                   server  IP 爲管理地址:10.10.111.20
                   next_server  IP 爲管理地址:10.10.111.20 這個須要在配置dhcpd 同樣
          修改/etc/xinetd.d/ tftp 和 rsync 文件:
          sed -i '/disable/c disable = no' /etc/xinetd.d/tftp
          sed -i -e 's/= yes/= no/g' /etc/xinetd.d/rsync
          service xinetd restart                 
          執行cobbler get-loaders 加載部分缺失的網絡boot-loaders
          註釋文件/etc/debmirror.conf 中的 dists 和 arches
          建立系統默認初始密碼:cobbler' and should be changed, try: "openssl   passwd -1 -salt 'random-phrase-here' '12345678'  12345678就是系統安裝好後root初始密碼
               修改settings 文件:default_password_crypted: "$1$222222$D38AxheCTHf/nVAzlN0.z0"
  
配置dhcpd服務:
     cd /etc/dhcp   &&   cp /usr/share/doc/dhcp-4.1.1/dhcpd.conf.sample ./dhcpd.conf
          #############vim dhcpd.conf
          # option definitions common to all supported networks...
          option domain-name "flinux.org";
          option domain-name-servers 10.10.111.20, 192.168.131.2;
          default-lease-time 43200;
          max-lease-time 86400;
          # Use this to enble / disable dynamic dns updates globally.
          #ddns-update-style none;
          # If this DHCP server is the official DHCP server for the local
          # network, the authoritative directive should be uncommented.
          #authoritative;
          # Use this to send dhcp log messages to a different log file (you also
          # have to hack syslog.conf to complete the redirection).
          log-facility local7;
          # No service will be given on this subnet, but declaring it helps the
          subnet 10.10.111.0 netmask 255.255.255.0 {
                option routers             10.10.111.1;
                range dynamic-bootp        10.10.111.191 10.10.111.200;
          }
          next-server 10.10.111.20;
          filename="pxelinux.0";

配置服務:
     service httpd start 
     service cobblerd restart
     service dhcpd restart
     chkconfig httpd on
     chkconfig cobblerd on
     chkconfig dhcpd on

同步數據:
     cobbler  sync  基本修改操做以後都要運行

添加鏡像:
這裏使用光盤掛載添加:
     cobbler import --path=/media/ --name=CentOS-6.7-x86_64       
     --arch=x86_64
     --path:鏡像路徑
     --name:生成鏡像名稱:
     --arch:32位或者64位

     其實到這裏,就能夠使用上面導入的鏡像profile進行無人值守網絡安裝了:
     查看distro和profile
     cobbler distro list
     cobbler profile list    

/var/lib/tftpboot/pxelinux.cfg/default
小小的排錯思路:
1、一個是dhcp不能配置好,dhcpd next-server 10.10.111.20; ====》本地管理地址,也是cobbler的 next_server 地址
2、一個小小的坑:vm默認開啓dhcp。因此這會對實驗有影響。在安裝系統的時候:影響就是找不到http://10.10.111.20/cblr/svc/op/ks/profile/CentOS-6.5-x86_64  這是本身的鏡像 。關閉vm的dhcp

本身定製鏡像模板profile:
先寫一個xxx.cfg
     

建立profile:
cobbler profile add --name=centos-6.7-x86_64-basic 
     --distro=centos-6.7-x86_64    
     --kickstart=/var/lib/cobbler/kickstarts/CentOS-6.7-x86_64.cfg
     --name:定義profile名稱
     --distro:指定distro
     --kickstart: 指定kickstart文件 xxx.cfg

     
安裝系統的時候,能夠使用原導入的鏡像profile。也能夠使用新建的profile
        

 .cfg文件附上:web

#Kickstart Configurator by Jason Zhao
#platform=x86, AMD64, or Intel EM64T
#System language
lang en_US
#System keyboard
keyboard us
#Sytem timezone
timezone Asia/Shanghai
#Root password
rootpw --iscrypted$default_password_crypted
#rootpw --iscrypted$1$ops-node$7hqdpgEmIE7Z0RbtQkxW20
#Use text mode install
text
#Install OS instead of upgrade
install
#Use NFS installation Media
url --url=$tree
#url--url=http://172.16.1.199/CentOS-6.7-x86_64
#System bootloader configuration
bootloader --location=mbr
#Clear the Master Boot Record
zerombr
#Partition clearing information
clearpart --all --initlabel 
#Disk partitioning information
part /boot --fstype ext4 --size 1024--ondisk sda
part swap --size 16384 --ondisk sda
part / --fstype ext4 --size 1 --grow--ondisk sda
#System authorization infomation
auth --useshadow  --enablemd5 
#Network information
$SNIPPET('network_config')
#network --bootproto=dhcp --device=eth0--onboot=on
# Reboot after installation
reboot
#Firewall configuration
firewall --disabled 
#SELinux configuration
selinux --disabled
#Do not configure XWindows
skipx
 
%pre
$SNIPPET('log_ks_pre')
$SNIPPET('kickstart_start')
$SNIPPET('pre_install_network_config')
# Enable installation monitoring
$SNIPPET('pre_anamon')
%end
 
#Package install information
%packages
@ base
@ core
@debugging
@development
sysstat
tree
telnet
dos2unix
ntp
lrzsz
nfs-utils
rpcbind
openssl-devel
zlib-devel
nmap
screen
%end
 
%post
%end
View Code
相關文章
相關標籤/搜索