標籤:linux 伺服器 防火牆 service 資料中心
Cobbler是一個開源項目,用來部署和安裝系統。Cobbler不僅僅是一個pxe伺服器,他還可以管理dns和dhcp。一般資料中心裡或者生產環境,是不允許dhcp, 但是pxe需要使用dhcp,所以我們這雷根據mac地址來分配IP,這樣dhcp就不會影響現有網路了。
1、首先關閉selinux
[[email protected] ~]#sed -i ‘/SELINUX/s/enforcing/disabled/‘ /etc/selinux/config
#重新啟動linux系統使配置生效;
2、關閉防火牆iptables
[[email protected] ~]# service iptables stop
3、安裝 epel 包
[[email protected] ~]#yum install http://mirrors.ustc.edu.cn/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm
4、安裝 Cobbler 和它需要的第三方工具包
[[email protected] ~]#yum install cobbler cobbler-web xinetd pykickstart cman dhcp tftp-server bind
安裝完成後需要設定幾個服務自動啟動
[[email protected] ~]# chkconfig httpd on
[[email protected] ~]# chkconfig dhcpd on
[[email protected] ~]# chkconfig cobblerd on
[[email protected] ~]# service httpd start #啟動http服務
[[email protected] ~]# service cobblerd start #啟動cobbler服務
註:此時dhcpd應該啟動失敗,因為還沒有對dhcp做配置。
5、配置
5.1 修改/etc/xinetd.d/tftp
disable = yes
=>
disable = no
5.2 修改/etc/xinetd.d/rsync
disable = yes
=>
disable = no
5.3 編輯 /etc/cobbler/settings 檔案,設定以下各項,其中 172.16.1.2 是當前機器IP。server: 172.16.1.2
next_server: 172.16.1.2
pxe_just_once: 1
manage_rsync: 1
manage_dhcp: 1
5.4 設定預設(通過cobbler安裝的系統) root 使用者的密碼
[[email protected] ~]# openssl passwd -1 -salt ‘random-phrase-here‘ ‘dragon‘ #密碼加密
$1$random-p$KIfNQzryOfZx/kAa0cjXv/
然後將結果替換 /etc/cobbler/settings 檔案中的:default_password_crypted:
5.5 設定 Cobbler Web訪問的密碼
[[email protected] ~]#htdigest /etc/cobbler/users.digest "Cobbler" cobbler
5.6 編輯 /etc/cobbler/dhcp.template 檔案,下面是我改動部分的配置資訊;
option domain-name "172.16.1.2";
option domain-name-servers 172.16.1.2;
default-lease-time 43200;
max-lease-time 86400;
log-facility local7;
subnet 172.16.0.0 netmask 255.255.0.0 {
range 172.16.1.100 172.16.1.254;
option routers 172.16.1.1;
}
next-server 172.16.1.2;
filename="pxelinux.0";
注意:如果在現有網段內已經有DHCP伺服器,需要把 range dynamic-bootp 注釋掉,否則會有衝突。這個地方需要特別注意,要根據自己的網路情況來設定。
5.7 重啟服務,暫時先不啟動DHCP,配置還沒有同步到/etc/dhcp/dhcpd.conf
[[email protected] ~]#service xinetd restart
[[email protected] ~]#service httpd restart
[[email protected] ~]#service cobblerd restart
5.8啟動和檢測 cobbler
[[email protected] ~]#cobbler get-loaders #執行 cobbler get-loaders,系統將自動下載loader程式
[[email protected] ~]#cobbler check #此時如果有錯誤,cobbler會提示,可以根據提示來修複。但是對參數的任何修改都需要使用下面的命令來使其生效
5.9 Web 測試
瀏覽器訪問 http://172.16.1.2/cobbler_web #這裡輸入自己的IP
使用者名稱/密碼:cobbler/dragon #在步驟5.5時設定
6.0 匯入系統鏡像,這裡假定使用CentOS-6.6-x86_64來測試,虛擬機器需要先掛載鏡像;
[[email protected] ~]#mount /dev/cdrom /mnt
[[email protected] ~]#cobbler import --path=/mnt --name=CentOS-6.6 --arch=x86_64
運行這兩條命令後,可以使用下面的命令來查看已經裝載的包
[[email protected] ~]#cobbler distro list
[[email protected] ~]#cobbler profile list
也可以通過 Web 介面的 Distros 和 Profiles 來查看。
7. 自動安裝系統
使用VirtualBox建立一個虛擬機器,網路設定使用和上面同樣的橋接模式。但是在 "虛擬機器設定-> 系統 -> 啟動順序" 裡把網路勾上並上移到第一位,然後啟動虛擬機器。此時就可以進入 Cobbler 的網路安裝介面,選擇上面建立的 CentOS-6.6-x86_64 然後就可以自動安裝了。裝完後,記得把虛擬機器啟動順序改回到硬碟啟動優先,然後就可以啟動新安裝的虛擬機器了。
二、配置Kickstart 配置模板,帶注釋版本(下面有無注釋版本)
[[email protected] ~]# cat kickstart_fc6.ks
#platform=x86, AMD64, or Intel EM64T#version=DEVEL# Upgrade existing installationupgrade# Use network installation#修改成自己的IPurl --url="http://172.168.12/cobbler/ks_mirror/CentOS-6.6-x86_64/"# Root password rootpw dragon# System authorization informationauth --useshadow --passalgo=sha512#關閉防火牆firewall --disabled#選擇時區timezone Asia/Shanghai# Use graphical installgraphicalfirstboot --disable# System keyboardkeyboard us# System language選擇語言,如果想要使用中文填寫:lang zh_CNlang en_US# Installation logging levellogging --level=info# Reboot after installationreboot# System bootloader configuration#--initlabel,根據不同體繫結構把磁碟標籤初始化為預設設定(例如,msdos用於x86而gpt用於Itanium).當安裝到一個嶄新的硬 盤時,這很有用,安裝程式不會詢問是否應該初始化磁碟標籤.#--grow,告訴分區使用所有可用空間(若有),或使用設定的最大值.#--size=,以MB為單位的分區最小值.在此處指定一個整數值,如500.不要在數字後面加MB.#--fstype=,為分區設定檔案系統類型.有效類型為ext2,ext3,swap和vfat.#--asprimary,強迫把分區分配為主要磁碟分割,否則提示分區失敗.#--ondisk=或--ondrive=,強迫分區在指定磁碟上建立.bootloader --location=mbrclearpart --all --drives=sda --initlabelpart /boot --fstype ext3 --size=100 --ondisk=sda part swap --size=4096part / --fstype ext3 --size=100 --grow --asprimary#%packages部分,這部分選擇需要安裝的軟體包.%packages@core@server-policy@workstation-policy%end
無注釋版本,可以直接複製,修改地址路徑即可:
[[email protected] ~]# kickstart.ks
#platform=x86, AMD64, or Intel EM64T#version=DEVEL# Upgrade existing installationupgrade# Use network installation#修改成自己的IPurl --url="http://172.168.12/cobbler/ks_mirror/CentOS-6.6-x86_64/"# Root passwordrootpw --iscrypted $1$CgIgFiPo$rqNvZR480Z5A2dnbxdd7C0# System authorization informationauth --useshadow --passalgo=sha512firewall --disabledtimezone Asia/Shanghai# Use graphical installgraphicalfirstboot --disable# System keyboardkeyboard us# System languagelang en_US# Installation logging levellogging --level=info# Reboot after installationreboot# System bootloader configurationbootloader --location=mbrclearpart --all --drives=sda --initlabelpart /boot --fstype ext3 --size=100 --ondisk=sdapart swap --size=4096part / --fstype ext3 --size=100 --grow --asprimary%packages@core@server-policy@workstation-policy%end
本文出自 “鬼迷心竅” 部落格,請務必保留此出處http://dragondragon.blog.51cto.com/6170889/1765048
使用centos6.6部署Cobbler--自動安裝centos系統