CentOS 配置cobbler經過網絡安裝Linux系統

Cobbler(補鞋匠)裝機系統是較早前kickstart的升級版,配置簡單自帶web界面html

配置環境:node

操做系統:CentOS 6.5python

測試機器ip:100.100.100.100linux

先將iptables selinux 關掉。web

/etc/init.d/iptables stopvim

chkconfig iptables offcentos

setenforce 0服務器

並修改配置文件/etc/sysconfig/selinux 將其disable網絡


1、安裝cobblersession

rpm -Uvh http://mirrors.hustunique.com/epel/6/x86_64/epel-release-6-8.noarch.rpm

yum install cobbler cobbler-web

yum install dhcp httpd

chkconfig cobblerd on

chkconfig httpd on

cobbler check    //檢查cobbler環境,按照提示安裝相應的軟件(可忽略一直提示yum-utils未安裝)


二:配置

1.修改cobbler 的配置文件


vim  /etc/cobbler/settings

修改以下地方:

next_server: 100.100.100.100          //這裏未修改的話執行cobbler check也有提示的

server: 100.100.100.100

manage_dhcp: 1

manage_rsync: 1


2.生成root的密碼串

openssl passwd -1 -salt "cobbler" "123456"    //openssl passwd -1 -salt '任間字符' '密碼'

$1$cobbler$sqDDOBeLKJVmxTCZr52/11


這個命令的用法,其中任意字符能夠隨便寫,然而這個密碼就是安裝完系統root的密碼了。


3.替換配置文件裏的字串。

vim  /etc/cobbler/settings

default_password_crypted: "$1$cobbler$sqDDOBeLKJVmxTCZr52/11"


4.配置tfpt和rsync

vim /etc/xinetd.d/tftp

 disable                 = no    //將yes的值修改爲no

vim /etc/xinetd.d/rsync

 disable                 = no    //將yes的值修改爲no

/etc/init.d/xinetd restart


5.配置dhcp

vim /etc/cobbler/dhcp.template     //修改如下內容便可

ddns-update-style interim;

allow booting;

allow bootp;

ignore client-updates;

set vendorclass = option vendor-class-identifier;

option pxe-system-type code 93 = unsigned integer 16;

subnet 100.100.100.0 netmask 255.255.255.0 {

     option routers             100.100.100.1;

     option domain-name-servers 8.8.8.8;

     option subnet-mask         255.255.255.0;

     range dynamic-bootp        100.100.100.200 100.100.100.254;

     default-lease-time         21600;

     max-lease-time             43200;

     next-server                $next_server;

   }


6.同步文件

cobbler get-loaders     //*** TASK COMPLETE ***輸出這個則同步成功

 

3、配置web環境

1.添加登陸帳號

htdigest /etc/cobbler/users.digest "Cobbler" admin  //添加cobbler用戶web登陸


2.檢查配置

cobbler sync           //*** TASK COMPLETE ***輸出這個則表示配置無錯誤


3.添加系統鏡像

mount /dev/cdrom /mnt/cdrom/                  //掛載鏡像

cobbler import --path=/mnt/cdrom --name=centos6.5      //由於鏡像較大須要一段時間


導入鏡像name可自定義導入成功後web界面會有顯示,須要添加多個鏡像的話也只須要執行這個命令把要添加的鏡像掛載而後導入便可


4.啓動

/etc/init.d/httpd restart

/etc/init.d/cobblerd restart


附上一個啓動cobbler腳本

#!/bin/sh

# chkconfig: - 80 90

# description:cobbler


case $1 in

start)

/etc/init.d/httpd start

/etc/init.d/xinetd start

/etc/init.d/dhcpd start

/etc/init.d/cobblerd start

;;


stop)

/etc/init.d/httpd stop

/etc/init.d/xinetd stop

/etc/init.d/dhcpd stop

/etc/init.d/cobblerd stop

;;


restart)

/etc/init.d/httpd restart

/etc/init.d/xinetd restart

/etc/init.d/dhcpd restart

/etc/init.d/cobblerd restart

;;


status)

/etc/init.d/httpd status

/etc/init.d/xinetd status

/etc/init.d/dhcpd status

/etc/init.d/cobblerd status

;;


sync)

cobbler sync

;;


*)

echo "Input error,please in put 'start|stop|restart|status|sync'!";

exit 2>&1 >/dev/null &

;;

esac


5.進入web界面

https://100.100.100.100/cobbler_web   //訪問這個連接使用剛剛建立的帳號登陸


6.修改啓動配置文件

cd /var/lib/cobbler/kickstarts    //建立系統安裝ks文件

點擊web左邊的Profiles選項選擇剛剛導入鏡像的點擊Edit

修改Kickstart選項選擇你的系統安裝ks文件


附上個人centos6.5ks文件,我這個是最小化安裝方式(能夠根據本身的需求修改)

# Use network installation 

url --url=$tree


#Root password

rootpw  --iscrypted $default_password_crypted


#Install OS instead of upgrade 

install


#Firewall configuration 

firewall --service=ssh


#System authorization information

authconfig --enableshadow --passalgo=sha512


#System keyboard 

keyboard us


#System language

lang en_US.UTF-8


#SELinux configuration 

selinux --disabled


#Installation logging level 

logging --level=info


#Reboot after installation 

reboot


#System timezone 

timezone --utc Asia/Shanghai


#Network information

network --onboot no --device eth0 --bootproto dhcp --noipv6 --hostname=test.test


#System bootloader configuration 

key --skip

bootloader --location=mbr --driveorder=sda --append="crashkernel=auto rhgb quiet"


#Clear the Master Boot Record 

zerombr


#Partition clearing information 

clearpart --all --initlabel


#Disk partitioning information 

part /boot --fstype=ext4 --size=200

part swap --size=4000

part pv.008003 --grow --size=200


volgroup volGroup00 --pesize=4096 pv.008003

logvol / --fstype=ext4 --name=LogVol00 --vgname=volGroup00 --size=20000

logvol /data --fstype=ext4 --name=LogVol01 --vgname=volGroup00 --size=16756



%packages

@chinese-support

@core

@server-policy

@workstation-policy

%end


4、客戶端

設置客戶端經過網絡啓動後即會出現cobbler安裝菜單選項,選擇剛剛配置的系統啓動便可自動安裝

完成後自動重啓,能夠用先前定義好的密碼"123456"登錄了


在已經有系統的的機器要重裝的話

安裝koan  

yum install koan  

查看cobbler服務器有哪些安裝盤  

koan --list-profiles --server=100.100.100.100  

#選擇要重裝的系統並重啓  

koan --replace-self --server=100.100.100.100 --profile=CentOS6.5-x86-64  

reboot




附:錯誤排除

# cobbler check 

The following are potential configuration items that you may want to fix:

1 : Must enable a selinux boolean to enable vital web services components, run: setsebool -P httpd_can_network_connect true 

2 : you need to set some SELinux content rules to ensure cobbler serves content correctly in your SELinux environment, run the following: /usr/sbin/semanage fcontext -a -t public_content_t "/tftpboot/.*" && /usr/sbin/semanage fcontext -a -t public_content_t "/var/www/cobbler"/p_w_picpaths/.* 

3 : you need to set some SELinux rules if you want to use cobbler-web (an optional package), run the following: /usr/sbin/semanage fcontext -a -t httpd_sys_content_rw_t "/var/lib/cobbler/webui_sessions/.*"

解決:關閉selinux

# vim /etc/sysconfig/selinux 

SELINUX=disabled

4 : change 'disable' to 'no' in /etc/xinetd.d/tftp 

解決:編輯/etc/xinetd.d/tftp文件,將文件中的disable字段的配置由yes改成no

5 : change 'disable' to 'no' in /etc/xinetd.d/rsync 

解決:編輯/etc/xinetd.d/rsync文件,將文件中的disable字段的配置由yes改成no

6 : since iptables may be running, ensure 69, 80, and 25151 are unblocked 

解決:在iptables中將69,80,25151端口打開。若是僅僅只是在內部環境中使用,建議直接將防火牆關掉

7 : debmirror package is not installed, it will be required to manage debian deployments and repositories

解決:yum install debmirror

或:rpm -Uvh ftp://rpmfind.net/linux/epel/5/i386/debmirror-20090807-1.el5.noarch.rpm –nodeps –force

8 : ksvalidator was not found, install pykickstart 

解決:yum install pykickstart

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

解決: 修改默認密碼就OK了,而後把密碼寫入到/etc/cobbler/settings中 

# openssl passwd -1 -salt 'random-phrase-here' 'your-password-here'

10 : comment 'dists' on /etc/debmirror.conf for proper debian support 

11 : comment 'arches' on /etc/debmirror.conf for proper debian support

解決:註釋/etc/debmirror.conf 下面兩行 

#@dists="sid"; 

@sections="main,main/debian-installer,contrib,non-free"; 

#@arches="i386";

12:fencing tools were not found, and are required to use the (optional) power management features. install cman or fence-agents to use them 

解決: yum install cman

修復完成,再用 cobbler check 檢查一下,確認沒問題後用 cobbler sync 作同步操做:

# cobbler check

No configuration problems found. All systems go.

13. comment out 'dists' on /etc/debmirror.conf for proper debian support

comment out 'arches' on /etc/debmirror.conf for proper debian supportvim              vi /etc/debmirror.conf

#註釋掉@dists="sid"與@arches="i386便可

#@dists="sid";

#@arches="i386";

14. 較驗cobbler check出錯

Traceback (most recent call last):

 File "/usr/bin/cobbler", line 35, in ?

 sys.exit(app.main())

 File "/usr/lib/python2.4/site-packages/cobbler/cli.py", line 558, in main

 rc = cli.run(sys.argv)

 File "/usr/lib/python2.4/site-packages/cobbler/cli.py", line 202, in run

 self.token = self.remote.login("", self.shared_secret)

 File "/usr/lib64/python2.4/xmlrpclib.py", line 1096, in __call__

 return self.__send(self.__name, args)

 File "/usr/lib64/python2.4/xmlrpclib.py", line 1383, in __request

 verbose=self.__verbose

 File "/usr/lib64/python2.4/xmlrpclib.py", line 1147, in request

 return self._parse_response(h.getfile(), sock)

 File "/usr/lib64/python2.4/xmlrpclib.py", line 1286, in _parse_response

 return u.close()

 File "/usr/lib64/python2.4/xmlrpclib.py", line 744, in close

 raise Fault(**self._stack[0])

xmlrpclib.Fault:

解決方法:此爲BUG,按下方操做執行即

service cobblerd restart

cobbler get-loaders

返回這個結果就OK了



參考:http://blog.chinaunix.net/uid-16728139-id-4174109.html

相關文章
相關標籤/搜索