標籤:linux pxe cobbler 自動安裝系統
Cobbler實現CentOS自動安裝
大綱
前言
Cobbler介紹
實驗拓撲
實驗步驟
測試
總結
前言
在生產環境中我們可能需要大量安裝作業系統, 我們當然可以一台一台的安裝, 但是營運工作應該標準化、流程化、自動化,降低對特定人員的依賴,節省專業人員的寶貴時間和精力,這樣才能有更多的時間去學習新的知識和提升。
–轉自: 陳明乾 的BLOG
那麼我們就應該使用營運工具來協助我們快速、批量的自動安裝。 現在較為流行的解決方案有Cobbler
, 這篇我們介紹了Cobbler
實現批量自動安裝CenOS 6.7的步驟
Cobbler介紹
Cobbler
是一款實現自動構建和部署系統的軟體, Cobbler
通過自動化實現來簡化管理員的操作, 並可以通過模板重複部署, Cobbler
還能夠實現虛擬化部署
Cobbler的工作群組件
650) this.width=650;" class="alignnone size-full wp-image-122" title="Cobbler實現CentOS自動安裝" src="http://anyisalin.com/wp-content/uploads/2016/05/cobbler%E5%AE%9E%E7%8E%B0centos%E8%87%AA%E5%8A%A8%E5%AE%89%E8%A3%85.png" alt="Cobbler實現CentOS自動安裝" width="880" height="494" style="height:auto;" />
實驗拓撲
650) this.width=650;" class="alignnone size-full wp-image-121" src="http://anyisalin.com/wp-content/uploads/2016/05/%E4%B8%8B%E8%BD%BD-4.png" alt="下載 (4)" width="922" height="475" style="height:auto;" />
實驗步驟
安裝配置dhcp和tftp
dhcp配置
[[email protected] ~]# yum install dhcp tftp-server -y[[email protected] ~]# vim /etc/dhcp/dhcpd.conf option domain-name "anyisalin.com";option domain-name-servers 172.16.1.1;subnet 172.16.1.0 netmask 255.255.255.0 { range 172.16.1.10 172.16.1.20; option routers 172.16.1.1;}next-server 172.16.1.7;filename="pxelinux.0";
tftp和sync配置
[[email protected] ~]# vim /etc/xinetd.d/tftp service tftp{ socket_type = dgram protocol = udp wait = yes user = root server = /usr/sbin/in.tftpd server_args = -s /var/lib/tftpboot disable = no #設定為no per_source = 11 cps = 100 2 flags = IPv4}[[email protected] ~]# vim /etc/xinetd.d/rsync service rsync{ disable = no flags = IPv6 socket_type = stream wait = no user = root server = /usr/bin/rsync server_args = --daemon log_on_failure = USERID}
啟動tftp、rsync和dhcp
[[email protected] ~]# service dhcpd startStarting dhcpd: [ OK ][[email protected] ~]# service xinetd startStarting xinetd: [ OK ]
安裝Cobbler
我們需要epel源[[email protected] ~]# wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo[[email protected] ~]# yum install cobbler cobbler-web pykickstart debmirror -y
啟動並測試Cobbler
[[email protected] ~]# service cobblerd startStarting cobbler daemon: [ OK ][[email protected] ~]# pkill cobbler #不知道為什麼, 第一次啟動要先kill掉進程[[email protected] ~]# service cobblerd start #重新啟動Starting cobbler daemon: [ OK ]
修改cobbler設定檔
[[email protected] ~]# vim /etc/cobbler/settings #修改以下兩項server: 172.16.1.7next_server: 172.16.1.7default_password_crypted: "$1$13b50228$tdXYYYr9hhXqkusGMIOVF/" #指定預設的密碼, 使用openssl passwd -1 -salt `openssl rand -hex 4`產生
下載PXE引導檔案
[[email protected] ~]# cobbler get-loaders #如果不能串連互連網, 則先安裝syslinux, 然後複製/usr/share/syslinux/{pxelinux.0,memu.c32}等檔案至/var/lib/cobbler/loaders/目錄中;[[email protected] ~]# cp /var/lib/cobbler/loaders/* /var/lib/tftpboot/ #將loaders目錄下的檔案複製到tftproot
提供軟體倉庫
[[email protected] ~]# mount /dev/sr0 /mnt/ #掛載本地光碟片 ;
提供ks檔案
[[email protected] ~]# grep -v \\\‘^[[:space:]]*#\\\‘ ks2.cfg #按自己需要自行修改firewall --enabled --service=sshinstallurl --url=$treerootpw --iscrypted $1$PN/zByoq$p3JWVhjzfPwZ6la3k.LED.auth --useshadow --passalgo=sha512graphicalfirstboot --disablekeyboard uslang en_USselinux --enforcinglogging --level=infotimezone America/New_Yorknetwork --bootproto=dhcp --device=eth0 --onboot=onbootloader --append="crashkernel=auto rhgb quiet" --location=mbr --driveorder="sda"zerombrclearpart --all --initlabel part /boot --fstype="ext4" --size=200part / --fstype="ext4" --grow --size=1%packages --nobase@core%end
添加distro和profile
[[email protected] ~]# cobbler import --name=centos-6.7 --path=/mnt/ #出現TASK COMPLETE代表成功了[[email protected] ~]# cobbler distro list #可以查看到當前的distro centos-6.7-x86_64[[email protected] ~]# cp ks2.cfg /var/lib/cobbler/kickstarts/ #將ks檔案複製到指定目錄[[email protected] ~]# cobbler profile add --name cenos-6.5-minal --distro=centos-6.7-X86_64 --kickstart=/var/lib/cobbler/kickstarts/ks2.cfg #添加profile[[email protected] ~]# cobbler profile list #查看profile cenos-6.5-minal centos-6.7-x86_64##由於centos7做法差不多, 所以就不示範了
測試
650) this.width=650;" class="alignnone size-full wp-image-118" src="http://anyisalin.com/wp-content/uploads/2016/05/GIF.gif" alt="GIF" width="1179" height="691" style="height:auto;" />
總結
使用Cobbler
安裝系統提高了我們營運工作的效率, 這樣才能有更多的時間去學習新的知識和提升。
文章內容淺嘗輒止, 大家有更好的見解可以提出
作者: AnyISaIln QQ: 1449472454
感謝: MageEdu
本文出自 “營運工程師之路” 部落格,請務必保留此出處http://anyisalin.blog.51cto.com/10917514/1773493
Cobbler實現CentOS自動安裝