CentOS 6.5 安裝和配置Cobbler,centoscobbler

來源:互聯網
上載者:User

CentOS 6.5 安裝和配置Cobbler,centoscobbler

Cobbler是一個開源項目,用來部署和安裝系統。Cobbler不僅僅是一個pxe伺服器,他還可以管理dns和dhcp。一般資料中心裡或者生產環境,是不允許dhcp, 但是pxe需要使用dhcp,所以我們這雷根據mac地址來分配IP,這樣dhcp就不會影響現有網路了。

1. 首先關閉selinux

sudo sed -i '/SELINUX/s/enforcing/disabled/' /etc/selinux/config

重新啟動linux系統

2. 關閉防火牆iptables

sudo chkconfig iptables offsudo chkconfig ip6tables offsudo /etc/init.d/iptables stopsudo /etc/init.d/ip6tables stop

3. 安裝 epel 包

sudo yum install http://mirrors.ustc.edu.cn/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm

4. 安裝 Cobbler 和它需要的第三方工具包

sudo yum install cobbler cobbler-web xinetd pykickstart cman dhcp tftp-server bind 

安裝完成後需要設定幾個服務自動啟動

sudo chkconfig httpd onsudo chkconfig dhcpd onsudo chkconfig cobblerd onsudo service httpd startsudo service cobblerd start

註:此時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 檔案,設定以下各項,其中 192.168.145.102 是當前機器IP。

server: 192.168.145.102next_server: 192.168.145.102pxe_just_once: 1manage_rsync: 1manage_dhcp: 1

5.4 設定預設 root 使用者的秘密

$ sudo openssl passwd -1 -salt 'random-phrase-here' 'Letmein'

然後將結果替換 /etc/cobbler/settings 檔案中的
default_password_crypted:

5.5 設定 Cobbler Web訪問的密碼

sudo htdigest /etc/cobbler/users.digest "Cobbler" cobbler

5.6 編輯 /etc/cobbler/dhcp.template 檔案,下面是我改動部分的配置資訊

...subnet 192.168.145.0 netmask 255.255.255.0 {     option routers             192.168.145.102;     option domain-name-servers 192.168.145.1;     option subnet-mask         255.255.255.0;     #range dynamic-bootp        192.168.145.150 192.168.145.200;     default-lease-time         21600;     max-lease-time             43200;     next-server                $next_server;     filename           "/pxelinux.0";     host test { # 為指定機器指定ip地址          hardware ethernet 08:00:27:2C:30:8C;            fixed-address 192.168.145.155;     }}...

注意:如果在現有網段內已經有DHCP伺服器,需要把 range dynamic-bootp 注釋掉,否則會有衝突。這個地方需要特別注意,要根據自己的網路情況來設定。


5.7 重啟服務

sudo service xinetd restartsudo service httpd restartsudo service cobblerd restart

5.8 啟動和檢測 cobbler

sudo cobbler get-loaderssudo cobbler check

此時如果有錯誤,cobbler會提示,可以根據提示來修複。但是對參數的任何修改都需要使用下面的命令來使其生效

sudo cobbler sync

5.9 Web 測試

訪問 http://192.168.145.102/cobbler_web使用者名稱/密碼:cobbler/Letmein

6. 匯入系統鏡像
這裡假定使用CentOS-6.6-x86_64來測試

sudo mount -t auto -o loop /home/kongxx/share/os/CentOS-6.6-x86_64-bin-DVD1.iso /mntsudo cobbler import --path=/mnt --name=CentOS-6.6 --arch=x86_64

運行這兩條命令後,可以使用下面的命令來查看了

$ sudo cobbler distro list$ sudo cobbler profile list

也可以通過 Web 介面的 Distros 和 Profiles 來查看。

7. 自動安裝系統
由於是在家裡的虛擬機器裡做測試,所以沒法使用 IPMI 來管理物理機。這裡就只測試一下新的虛擬機器可以通過PXE來自動安裝系統。

使用VirtualBox建立一個虛擬機器,網路設定使用和上面同樣的橋接模式。但是在 "虛擬機器設定-> 系統 -> 啟動順序" 裡把網路勾上並上移到第一位,然後啟動虛擬機器。此時就可以進入 Cobbler 的網路安裝介面,選擇上面建立的 CentOS-6.6-x86_64 然後就可以自動安裝了。裝完後,記得把虛擬機器啟動順序改回到硬碟啟動優先,然後就可以啟動新安裝的虛擬機器了。







相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.