今天需要完成Hypervisor主机的安装,步骤记录如下:
1. 登录PUSH主机并切换帐号
$ ssh mvv@ess.com
$ sudo -i
2. 去到工作目录
# cd /opt/scripts/EXP
3. 脚本和模板文件
a. 主用脚本
ucs-setup-mass.sh
b. 主机列表文件 :
aan-host.txt
c. 模板文件
ucs-host-template.txt
d. expect脚本 ucs-setup-mass.sh用的:
ucs-setup.exp
e. " ucs-host-dir/ "是ucs-setup-mass.sh生成结果所在目录
4. "ucs-setup-mass.sh"参数说明
a. 主要参数描述:
-v : verbose mode to show more detail, useful for debug
-h : Specify host list file
-e : Specify expect script file , default is "ucs-setup.exp"
-r : Run mode. Without it, only generate target scripts under ucs-host-dir/ . useful for debug
b. 根据主机列表(can-host.txt) 和模板文件(ucs-host-template-pd15.txt)生成目主机脚本文件
# ./ucs-setup-mass.sh -h aan-host.txt -v -t ucs-host-template-pd15.txt -r
5. 具体文件内容参考
a. host文件
$Netmask=255.255.252.0
$Gateway=10.37.60.1
$Nameserver1=10.36.60.23
$Nameserver2=10.36.60.24
$Bridge_Nic1=enp7s0
$Bridge_Nic2=enp8s0
$Access_Nic1=enp5s0
$Access_Nic2=enp6s0
pd-aan[006:008]
pd-aan[014:030]
b. 模板文件ucs-host-template-pd.txt
hostname #HOSTNAME#
grep -q '^restrict -6 ::1' /etc/ntp.conf || sed -i '/^restrict 127/arestrict -6 ::1' /etc/ntp.conf
cd /etc/sysconfig/network-scripts/
for f in ifcfg-enp*; do grep -q NM_CONTROLLED $f || echo 'NM_CONTROLLED=no' >> $f; done
for f in ifcfg-enp*; do echo 'MTU=1500' >> $f; done
sed -i 's/dhcp/static/g' ifcfg-enp*
ifconfig -a|grep mtu|grep 9000|awk '{print "ifconfig "$1" mtu 1500"}'|sh
echo -e "TYPE=Ethernet\nBOOTPROTO=static\nIPV4_FAILURE_FATAL=no\nNAME=#ACCESS_NIC2#\nDEVICE=#ACCESS_NIC2#\nNM_CONTROLLED=no\nIPV6INIT=\"no\"\nMTU=1500\nONBOOT=yes\nIPADDR=#IP#\nNETMASK=#NETMASK#\nGATEWAY=#GATEWAY#" > ifcfg-#ACCESS_NIC1#
echo -e "TYPE=Ethernet\nBOOTPROTO=none\nIPV4_FAILURE_FATAL=no\nNAME=#ACCESS_NIC2#\nDEVICE=#ACCESS_NIC2#\nNM_CONTROLLED=no\nIPV6INIT=\"no\"\nMTU=1500\nONBOOT=yes" > ifcfg-#ACCESS_NIC2#
...
c.目标主机结果文件pd-aan008
hostname pd-aan008
grep -q '^restrict -6 ::1' /etc/ntp.conf || sed -i '/^restrict 127/arestrict -6 ::1' /etc/ntp.conf
grep '^restrict' /etc/ntp.conf
cd /etc/sysconfig/network-scripts/
for f in ifcfg-enp*; do grep -q NM_CONTROLLED $f || echo 'NM_CONTROLLED=no' >> $f; done
for f in ifcfg-enp*; do echo 'MTU=1500' >> $f; done
sed -i 's/dhcp/static/g' ifcfg-enp*
ifconfig -a|grep mtu|grep 9000|awk '{print "ifconfig "$1" mtu 1500"}'|sh
echo -e "TYPE=Ethernet\nBOOTPROTO=static\nIPV4_FAILURE_FATAL=no\nNAME=enp6s0\nDEVICE=enp6s0\nNM_CONTROLLED=no\nIPV6INIT=\"no\"\nMTU=1500\nONBOOT=yes\nIPADDR=10.37.60.38\nNETMASK=255.255.252.0\nGATEWAY=10.37.60.1" > ifcfg-enp5s0
echo -e "TYPE=Ethernet\nBOOTPROTO=none\nIPV4_FAILURE_FATAL=no\nNAME=enp6s0\nDEVICE=enp6s0\nNM_CONTROLLED=no\nIPV6INIT=\"no\"\nMTU=1500\nONBOOT=yes" > ifcfg-enp6s0
...