cobbler定制化安裝Centos7.2操作系統
阿新 • • 發佈:2018-05-26
creates sda step def hashing inux eat architect groups
一、定制Centos_7_x86_64.ks文件內容
# Cobbler for Kickstart Configurator for CentOS 7.2.1511 by Wolf_Dreams
# Install OS instead of upgrade
install
# Use network installation(The starting "$" variables are all values in the call configuration file)
url --url=$tree #引用cobbler配置文件來進行安裝
# Use text mode install(graphical, text, or cmdline)
text #采用文本方式安裝
# System language
lang en_US.UTF-8 #指定系統語言
# System keyboard
keyboard us #指定鍵盤使用語言
# Clear the Master Boot Record
zerombr #清空系統主引導記錄(原機器有系統)
# System bootloader configuration
bootloader --location=mbr --driveorder=sda --append="crashkernel=auto net.ifnames=0 biosdevname=0 rhgb quiet" #引導啟動器
# Network information
$SNIPPET(‘network_config‘)
# System timezone
timezone --utc Asia/Shanghai --ntpservers=ntp1.aliyun.com
# System authorization information(Use shadow passwords,set up the SHA-512 hashing)
authconfig --enableshadow --passalgo=sha512 #設置認證信息
#Root password
rootpw --iscrypted $default_password_crypted #新裝系統默認密碼
# Partition clearing information
clearpart --all –initlabel #刪除分區信息
# Allow manual partitioning of the system as needed(default fstype xfs or default units MB)
part /boot --fstype xfs --size 500
part swap --size 2048
part / --fstype xfs --grow #邏輯磁盤的所有分區都劃分給根(/)分區
# Run the Setup Agent on first boot
firstboot --disable
# SELinux configuration
selinux --disabled
# Firewall configuration
firewall --disabled
#Controls the error logging of Anaconda during installation. It has no effect on the installed system.
logging --level=info
# Do not configure the X Window System
skipx #不配置x window桌面系統
# Creates a new user group
group --name=development
# Creates a new user on the system
user --name=gandalf --groups=development --homedir=/data/gandalf --password=123456 --shell=/bin/sh
# Reboot after installation
reboot
# Pre-installation Script(The %pre script is run on the system immediately after the Kickstart file has been parsed, but before installation begins. )
%pre --log=/var/log/ks-pre.log
$SNIPPET(‘log_ks_pre‘) #調用的文件存放在/var/lib/cobbler/snippets目錄下
$SNIPPET(‘kickstart_start‘) #調用kickstart開始安裝
$SNIPPET(‘pre_install_network_config‘)
# Enable installation monitoring
$SNIPPET(‘pre_anamon‘)
%end
# Package Selection(The %packages section must end with the %end command.)
%packages #定制安裝完的系統安裝有什麽軟件包(@代表安裝軟件包組-代表不安裝什麽軟件包,沒有前綴代表單個軟件包)
@base
@compat-libraries
@debugging
@development
net-tools
tree
lrzsz
vim
telnet
nmap
sysstat
dos2unix
iptraf
ncurses-devel
openssl-devel
zlib-devel
OpenIPMI-tools
screen
%end
# Post-installation Script(You have the option of adding commands to run on the system once the installation is complete, but before the system is rebooted for the first time)
#Logs the script‘s output into the specified log file(/var/log/ks-post.log)
%post --log=/var/log/ks-post.log
systemctl disable postfix.service
%end
# kdump configuration(enable,The amount of memory you want to reserve for kdump, in MiB)
%addon com_redhat_kdump --enable --reserve-mb=128 #開啟系統崩潰轉存機制kdump
%end
# Jump to local drive boot start
%post
# Start final steps
$SNIPPET(‘kickstart_done‘) #防止系統循環安裝,即調用pxe_just_once=1
%end
二、指定Centos_7_x86_64.ks文件及調整內核net.ifnames=0 biosdevname=0參數
1、切換到存放kickstarts文件目錄並查看其目錄所有文件
[root@cobbler-server ~]# cd /var/lib/cobbler/kickstarts/
[root@cobbler-server kickstarts]# ls
default.ks install_profiles sample_autoyast.xml sample_esxi4.ks sample.ks
esxi4-ks.cfg legacy.ks sample_end.ks #默認ks文件 sample_esxi5.ks sample_old.seed
esxi5-ks.cfg pxerescue.ks sample_esx4.ks sample_esxi6.ks sample.seed
2、執行rz命令上傳定制的Centos_7_x86_64.ks文件
[root@cobbler-server kickstarts]# rz
rz waiting to receive.
Starting zmodem transfer. Press Ctrl+C to cancel.
Transferring Centos_7_x86_64.ks...
100% 2 KB 2 KB/sec 00:00:01 0 Errors
3、查看定制的Centos_7_x86_64.ks文件屬性
[root@cobbler-server kickstarts]# ls -ldh Centos_7_x86_64.ks
-rw-r--r-- 1 root root 2.7K May 26 13:30 Centos_7_x86_64.ks
4、查看cobbler鏡像文件及profile配置文件
[root@cobbler-server kickstarts]# cobbler distro list
CentOS-6.8-x86_64
CentOS-7-x86_64
[root@cobbler-server kickstarts]# cobbler profile list
CentOS-6.8-x86_64
CentOS-7-x86_64
5、查看首次導入系統鏡像後,安裝鏡像的文件信息
[root@cobbler-server kickstarts]# cobbler distro report --name=CentOS-7-x86_64 Name : CentOS-7-x86_64 Architecture : x86_64 TFTP Boot Files : {} Breed : redhat Comment : Fetchable Files : {} Initrd : /var/www/cobbler/ks_mirror/CentOS-7-x86_64/images/pxeboot/initrd.img Kernel : /var/www/cobbler/ks_mirror/CentOS-7-x86_64/images/pxeboot/vmlinuz Kernel Options : {} Kernel Options (Post Install) : {} Kickstart Metadata : {‘tree‘: ‘http://@@http_server@@/cblr/links/CentOS-7-x86_64‘} Management Classes : [] OS Version : rhel7 Owners : [‘admin‘] Red Hat Management Key : <<inherit>> Red Hat Management Server : <<inherit>> Template Files : {}
6、查看指定的profile設置,cobbler默認使用/var/lib/cobbler/kickstarts/sample_end.ks文件
[root@cobbler-server kickstarts]# cobbler profile report --name=CentOS-7-x86_64 Name : CentOS-7-x86_64 TFTP Boot Files : {} Comment : DHCP Tag : default Distribution : CentOS-7-x86_64 Enable gPXE? : 0 Enable PXE Menu? : 1 Fetchable Files : {} Kernel Options : {} Kernel Options (Post Install) : {} Kickstart : /var/lib/cobbler/kickstarts/sample_end.ks #系統默認使用的kickstart文件 Kickstart Metadata : {} Management Classes : [] Management Parameters : <<inherit>> Name Servers : [] Name Servers Search Path : [] Owners : [‘admin‘] Parent Profile : Internal proxy : Red Hat Management Key : <<inherit>> Red Hat Management Server : <<inherit>> Repos : [] Server Override : <<inherit>> Template Files : {} Virt Auto Boot : 1 Virt Bridge : xenbr0 Virt CPUs : 1 Virt Disk Driver Type : raw Virt File Size(GB) : 5 Virt Path : Virt RAM (MB) : 512 Virt Type : kvm
7、檢查kickstart文件的完整性
[root@cobbler-server kickstarts]# ksvalidator Centos_7_x86_64.ks
The following problem occurred on line 18 of the kickstart file:
Unknown command: $SNIPPET(network_config) #忽略該項
8、編輯profile配置文件,修改關聯的kickstart文件
[root@cobbler-server kickstarts]# cobbler profile edit --name=CentOS-7-x86_64 --kickstart=/var/lib/cobbler/kickstarts/Centos_7_x86_64.ks
9、指定更改Centos7網卡名稱為ethx,指定參數--kopts=‘net.ifnames=0 biosdevname=0‘
[root@cobbler-server kickstarts]# cobbler profile edit --name=CentOS-7-x86_64 --kopts=‘net.ifnames=0 biosdevname=0‘
10、再次查看指定的profile設置,kickstart文件/var/lib/cobbler/kickstarts/Centos_7_x86_64.ks
[root@cobbler-server kickstarts]# cobbler profile report --name=CentOS-7-x86_64 Name : CentOS-7-x86_64 TFTP Boot Files : {} Comment : DHCP Tag : default Distribution : CentOS-7-x86_64 Enable gPXE? : 0 Enable PXE Menu? : 1 Fetchable Files : {} Kernel Options : {‘biosdevname‘: ‘0‘, ‘net.ifnames‘: ‘0‘} #centos7需要設置,centos6不需要設置 Kernel Options (Post Install) : {} Kickstart : /var/lib/cobbler/kickstarts/Centos_7_x86_64.ks #更改成指定的kickstart文件 Kickstart Metadata : {} Management Classes : [] Management Parameters : <<inherit>> Name Servers : [] Name Servers Search Path : [] Owners : [‘admin‘] Parent Profile : Internal proxy : Red Hat Management Key : <<inherit>> Red Hat Management Server : <<inherit>> Repos : [] Server Override : <<inherit>> Template Files : {} Virt Auto Boot : 1 Virt Bridge : xenbr0 Virt CPUs : 1 Virt Disk Driver Type : raw Virt File Size(GB) : 5 Virt Path : Virt RAM (MB) : 512 Virt Type : kvm [root@cobbler-server kickstarts]# cobbler sync
三、定制化安裝指定操作系統方法
1、查看指定服務器的MAC地址(區分不同物理服務器采用MAC地址區分)
2、指定服務器使用指定的kickstart文件
[root@cobbler-server kickstarts]# cobbler system add --name=cobbler-client --mac-address=00:0C:29:97:85:40 --profile=CentOS-7-x86_64 --ip-address=172.16.0.100 --netmask=255.255.255.0 --gateway=172.16.0.1 --interface=eth0 --static=1 --hostname=cobbler-client --name-servers="114.114.114.114 8.8.8.8"
[root@cobbler-server kickstarts]# cobbler system list
cobbler-client
[root@cobbler-server kickstarts]# cobbler sysnc
3、修改指定系統的IP地址
[root@cobbler-server kickstarts]# cobbler system edit --name=cobbler-client --ip-address=172.16.0.190 [root@cobbler-server kickstarts]# cobbler system report --name=cobbler-client Name : cobbler-client TFTP Boot Files : {} Comment : Enable gPXE? : <<inherit>> Fetchable Files : {} Gateway : 172.16.0.1 Hostname : cobbler-client Image : IPv6 Autoconfiguration : False IPv6 Default Device : Kernel Options : {} Kernel Options (Post Install) : {} Kickstart : <<inherit>> Kickstart Metadata : {} LDAP Enabled : False LDAP Management Type : authconfig Management Classes : <<inherit>> Management Parameters : <<inherit>> Monit Enabled : False Name Servers : [‘114.114.114.114‘, ‘8.8.8.8‘] Name Servers Search Path : [] Netboot Enabled : True Owners : <<inherit>> Power Management Address : Power Management ID : Power Management Password : Power Management Type : ipmitool Power Management Username : Profile : CentOS-7-x86_64 Internal proxy : <<inherit>> Red Hat Management Key : <<inherit>> Red Hat Management Server : <<inherit>> Repos Enabled : False Server Override : <<inherit>> Status : production Template Files : {} Virt Auto Boot : <<inherit>> Virt CPUs : <<inherit>> Virt Disk Driver Type : <<inherit>> Virt File Size(GB) : <<inherit>> Virt Path : <<inherit>> Virt PXE Boot : 0 Virt RAM (MB) : <<inherit>> Virt Type : <<inherit>> Interface ===== : eth0 Bonding Opts : Bridge Opts : CNAMES : [] InfiniBand Connected Mode : False DHCP Tag : DNS Name : Per-Interface Gateway : Master Interface : Interface Type : IP Address : 172.16.0.190 IPv6 Address : IPv6 Default Gateway : IPv6 MTU : IPv6 Prefix : IPv6 Secondaries : [] IPv6 Static Routes : [] MAC Address : 00:0C:29:97:85:40 Management Interface : False MTU : Subnet Mask : 255.255.255.0 Static : True Static Routes : [] Virt Bridge : [root@cobbler-server kickstarts]# cobbler sync
4、開啟服務器自動安裝指定的操作系統
5、操作系統安裝完成後進行基本驗證
定制kickstart文件的語法參考網址
CentOS7:https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/installation_guide/sect-kickstart-syntax#sect-kickstart-commands
Centos6:https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/6/html/installation_guide/s1-kickstart2-options
cobbler定制化安裝Centos7.2操作系統