本人習慣經過cobbler部署物理機系統,那我就來講說部署系統前須要作哪些準備。linux
1.BIOS設置是否符合標準。好比F1/F2錯誤提示、系統啓動順序、是否有開啓PXE啓動等。ios
2.你從哪一個網卡進行pxe引導,cobbler部署需肯定對應服務器網卡的MAC地址。git
3.作磁盤陣列,此項是最耗費時間的。也是這個緣由,纔有了這個文檔。bash
4.更改idrac root用戶的密碼,並新增一個組內通用用戶。服務器
1、racadm環境部署及文檔說明併發
此文檔僅適用於dell且配置了iDRAC遠程管理卡的機器(主要是配置了idrac ip,方便遠程鏈接)。全文腳本依賴於racadm環境,需在放置腳本的服務器上安裝srvadmin包。如下腳本就是爲解決前文中的系統部署前準備事宜。
ide
環境部署以下:oop
# wget http://downloads.dell.com/FOLDER03574555M/1/OM-MgmtStat-Dell-Web-LX-8.3.0-1908_A00.tar.gz -P /tmp/ # tar zxvf OM-MgmtStat-Dell-Web-LX-8.3.0-1908_A00.tar.gz # cd /tmp/linux/rac/RHEL6/x86_64/ # rpm -ivh srvadmin* # ln -s /opt/dell/srvadmin/bin/racadm /usr/bin/racadm
具體命令和用法,我就不說了,你們能夠參考如下手冊ui
2、 腳本說明
腳本部分一共包含三部分。
run.sh:運行腳本,此腳本從hosts.conf文件中獲取信息並後臺執行bin目錄下的腳本,實現多機器併發。
hosts文件:腳本從文本文件中獲取ip信息,網卡號,需配置的陣列類型等。
README文檔
modules目錄:此目錄放置實現網卡獲取、用戶添加、raid配置等腳本,因篇幅較長,後續逐漸更新。
1.run.sh腳本內容
#!/bin/bash # chenss # date : 2016-09-10 PATH="/opt/dell/srvadmin/bin/:/opt/dell/srvadmin/sbin/:$PATH" if [ $# -gt 0 ]; then echo -e "\e[0;31;1mCorrect syntax: sh run.sh\e[0m" exit fi start=`date +%s` NicGetMac='/data/script/idrac/modules/modules_GetNicMac.sh' CreateRaid='/data/script/idrac/modules/modules/modules_CreateRaid.sh' AddUser='/data/script/idrac/modules/modules_AddUser.sh' Check='/data/script/idrac/modules/modules/modules_SetBios.sh' delvd='/data/script/idrac/modules/modules/modules_DelVds.sh' disk_convert='/data/script/idrac/modules/modules/modules_DiskModeConvert.sh' defpass='/data/script/idrac/modules/modules_RestorPass.sh' reboot='/data/script/idrac/modules/modules/modules_SysReboot.sh' pxe='/data/script/idrac/modules/bootseq.sh' idrac_file='/data/script/idrac/hosts' NewInit='/data/script/idrac/modules/modules_NewInit.sh' cat << EOF ########## please option your choice: [1-10] ############ (1) Get server NIC mac-address (2) Remove all or the virtual disk other than the system disk (3) Physical Disk mode convert (4) Create raid1 or raid5 (5) Add idrac user and change root passwd (6) Bios disable F1/F2 errot prompt and setup HDD first boot (7) check system boot seq (8) Restore the root default password (9) reboot system (10) New server raid、bios init (99) Execute the command manually (*) exit script ######################################################## EOF read -p "please option your choice: " choice case $choice in 1)script="$NicGetMac";; 2)read -p "This operation will remove virtual disk,Are you sure? [Y|N]" confirm if [ "$confirm" == "Y" -o "$confirm" == "y" ]; then script="$delvd" read -p "Romve all or no system virtual disk? [all|nosys]" rmvd if [ "$rmvd" != "all" -a "$rmvd" != "nosys" ]; then echo -e "\e[0;31;1m: argu error,you can only enter 'all' or 'nosys',please enter again\e[0m" exit fi else echo -e "\e[0;31;1mYou can only enter 'Y' or 'N',please enter again\e[0m" exit fi;; 3)read -p "This operation will convert disk mode,May be erase disk data,Are you sure? [Y|N]" confirm if [ "$confirm" == "Y" -o "$confirm" == "y" ]; then script="$disk_convert" else echo -e "\e[0;31;1mYou can only enter 'Y' or 'N',please enter again\e[0m" exit fi;; 4)read -p "This operation will create raid,May be erase disk data,Are you sure? [Y|N]" confirm if [ "$confirm" == "Y" -o "$confirm" == "y" ]; then script="$CreateRaid" else echo -e "\e[0;31;1mYou can only enter 'Y' or 'N',please enter again\e[0m" exit fi;; 5)script="$AddUser";; 6)script="$Check";; 7)script="$pxe";; 8)script="$defpass";; 9)read -p "This operation will reboot system,Are you sure? [Y|N]" confirm if [ "$confirm" == "Y" -o "$confirm" == "y" ]; then script="$reboot" fi;; 10)read -p "This operation will remove virtual disk,Are you sure? [Y|N]" confirm if [ "$confirm" == "Y" -o "$confirm" == "y" ]; then script="$all" else echo -e "\e[0;31;1mYou can only enter 'Y' or 'N',please enter again\e[0m" exit fi;; 99)read -p "please input command: " a b c d e f g;; *)echo -e "\e[0;31;1margu error,please check...\e[0m" exit;; esac if egrep -v '^#|^$|^NIC|^RAID' $idrac_file | grep '[^[:digit:]].*-' &> /dev/null; then menu_ipseq='1' else menu_ipseq='2' fi function ShExec { NUM=`grep '^NIC' $idrac_file | awk '{print $2}'` mode=`egrep '^mode' $idrac_file | awk '{print $2}'` raid_level=`egrep '^RAID' $idrac_file | awk '{print $2}'` if [ -n "$a" ]; then racadm -r $idrac_ip -u root -p calvin $a $b $c $d $e $f $g --nocertwarn | egrep -v -B 9 'Default username' elif [ "`basename $script`" == "modules_GetNicMac.sh" ]; then sh $script $idrac_ip $NUM elif [ "`basename $script`" == "modules_DelVds.sh" ]; then sh $script $idrac_ip $rmvd elif [ "`basename $script`" == "modules_DiskModeConvert.sh" ]; then sh $script $idrac_ip $mode elif [ "`basename $script`" == "all.sh" ]; then sh $script $idrac_ip $mode $raid_level else sh $script $idrac_ip $raid_level fi } function SEQ { egrep -v '^#|^$' $idrac_file | grep '[^[:digit:]].*-' | while read idracs; do prefix=`echo $idracs | awk -F '[.-]' '{print $1"."$2"."$3}'` begin=`echo $idracs | awk -F '[.-]' '{print $4}'` end=`echo $idracs | awk -F '[.-]' '{print $5}'` for i in `seq ${begin} ${end}`; do { idrac_ip=${prefix}.$i ShExec }& done wait done } function NOSEQ { egrep -v '^#|^;|^$' $idrac_file | grep '^[[:digit:]].*$' | while read idracs; do { idrac_ip=`echo $idracs | awk '{print $1}'` ShExec }& wait done } case $menu_ipseq in 1) SEQ;; 2) NOSEQ;; *) echo "usage: error,please check script!" esac over=`date +%s` echo "used time : `expr $over - ${start}`s"
2.hosts文件內容,初步定義以下。
# 網卡編號 NIC_NUM: 1 # 需轉換的硬盤模式 mode: all_raid # RAID 級別 RAID: 5 # IDRAC IP 列表 192.168.1.1-10
3.README文檔介紹
1、腳本運行格式: sh run.sh 而後根據需求選擇需執行的操做 ########## please option your choice: [1-10] ############ (1) Get server NIC mac-address (2) Remove all or the virtual disk other than the system disk (3) Physical Disk mode convert (4) Create raid1 or raid5 (5) Add idrac user (JPush) and change root passwd (6) Bios disable F1/F2 errot prompt and setup HDD first boot (7) check system boot seq (8) Restore the root default password (9) reboot system (10) New server raid、bios init (99) Execute the command manually ######################################################## 2、執行腳本選項說明 1.獲取服務器網卡的 mac-address 2.根據需求刪除全部虛擬磁盤或保留除系統盤的其它全部虛擬磁盤(機器轉hadoop業務或出廠陣列不規劃時應用) 3.硬盤(包含SSD)在直通和raid模式間轉換。 4.建立raid1或raid5。 5.添加idrac用戶、更改及恢復默認root用戶密碼。 6.更改BIOS(禁用F一、硬盤第一引導) 7.檢查系統第一啓動項 8.還原IDRAC root用戶密碼爲 calvin 9.經過IDRAC強行重啓服務器 10.把陣列清除、陣列建立、BIOS更改封裝在一個腳本(陣列建立格式同選項4) 99.執行傳遞的idrac命令 3、hosts文件填寫規範 1.NIC_NUM後的數字表示第幾塊網卡,電口用網口3或4進行PXE安裝,光口用網口1或2進行PXE安裝 2.硬盤模式: [ all_raid | hdd_raid | hdd_jobd | ssd_raid | ssd_jobd ] (腳本會執行機器重啓操做) 書寫格式:mode和」硬盤模式「間必須有空格。例:[ mode: hdd_raid ] 或 [ mode hdd_raid ] 都可。 all_raid:全部硬盤都轉換爲RAID模式 hdd_raid:除2塊558G系統盤外,全部HDD磁盤轉換爲RAID模式 hdd_jobd:除2塊558G系統盤外,全部磁盤轉換爲直通模式 ssd_raid:全部SSD磁盤轉換爲RAID模式 ssd_jobd:全部SSD磁盤轉換爲直通模式 3.陣列類型: [ 1 | 5 ] RAID5說明: 方式一:有2塊558G左右盤作sda ,其他HDD作sdb 方式二:全部HDD大小同樣,劃分300G作sda,剩下作sdb。兩種方式都會判斷是否有SSD) 硬盤模式說明(腳本會執行機器重啓操做): 4.IDRAC IP書寫格式: 方式一:192.168.1.1-10 方式二: 192.168.1.1 192.168.1.2 192.168.1.3