Archive for 2020年6月9日


#!/bin/bash
i=1

# 硬盘数量,除系统盘之外是12块
while [ $i -lt 13 ]
do
# 若不足2位数,则左侧补0
k=`printf “%02d" $i`
# ready for convert ascii value to char
u=$((97+$i))
# 系统盘是sda,%c格式化为单个字符
#j=`echo $i|awk ‘{printf “%c",97+$i}’`
#j=echo $u|awk ‘{printf(“%c",$1)}’
j=$(printf \\x`printf %x $u`)

# 每个物理硬盘整块分成一个区
parted -s /dev/sd$j mklabel gpt
parted /dev/sd$j mkpart primary ext4 0% 100%
# 格式化磁盘
mkfs.ext4 /dev/sd${j}1

# 建立挂载点目录
mkdir /mnt/disk${k}
# 导入挂载硬盘信息
mountfs="/dev/sd${j}1 /mnt/disk${k} ext4 defaults 0 0″

# 写入分区表
echo $mountfs >>/etc/fstab

i=$(($i+1))
done
echo “It’s mounting all of the disk, wait a min, plz"
# 挂载fstab里所有的磁盘
mount -a
echo “SUCCESS, CONGRATULATIONS!"

#!/bin/bash
# 业务IP
IP=10.131.0.117
GW=10.131.0.251
# 心跳IP
HB=172.17.0.117
# 业务网卡
ETH1=eno1
ETH2=ens6f0
# 心跳网卡
ETH3=eno2
ETH4=ens6f1

modprobe –first-time bonding
#modprobe bonding

cd /etc/sysconfig/network-scripts/
mkdir bak
mv ifcfg-$ETH1 ifcfg-$ETH2 ifcfg-$ETH3 ifcfg-$ETH4 bak/

cat < /etc/sysconfig/network-scripts/ifcfg-bond0
DEVICE=bond0
#NAME=bond0
TYPE=Bond
BONDING_MASTER=yes
IPADDR=$IP
PREFIX=24
GATEWAY=$GW
ONBOOT=yes
BOOTPROTO=none
BONDING_OPTS="mode=6 miimon=100"
NM_CONTROLLED="no"
USERCTL=no
EOF

cat < /etc/sysconfig/network-scripts/ifcfg-bond1
DEVICE=bond1
#NAME=bond1
TYPE=Bond
BONDING_MASTER=yes
IPADDR=$HB
PREFIX=24
ONBOOT=yes
BOOTPROTO=none
BONDING_OPTS="mode=6 miimon=100"
NM_CONTROLLED="no"
USERCTL=no
EOF

cat < /etc/sysconfig/network-scripts/ifcfg-$ETH1
DEVICE=$ETH1
#NAME=bond0-slave1
TYPE=Ethernet
BOOTPROTO=none
ONBOOT=yes
MASTER=bond0
SLAVE=yes
NM_CONTROLLED="no"
EOF

cat < /etc/sysconfig/network-scripts/ifcfg-$ETH2
DEVICE=$ETH2
#NAME=bond0-slave2
TYPE=Ethernet
BOOTPROTO=none
ONBOOT=yes
MASTER=bond0
SLAVE=yes
NM_CONTROLLED="no"
EOF

cat < /etc/sysconfig/network-scripts/ifcfg-$ETH3
DEVICE=$ETH3
#NAME=bond1-slave1
TYPE=Ethernet
BOOTPROTO=none
ONBOOT=yes
MASTER=bond1
SLAVE=yes
NM_CONTROLLED="no"
EOF

cat < /etc/sysconfig/network-scripts/ifcfg-$ETH4
DEVICE=$ETH4
#NAME=bond1-slave2
TYPE=Ethernet
BOOTPROTO=none
ONBOOT=yes
MASTER=bond1
SLAVE=yes
NM_CONTROLLED="no"
EOF

systemctl restart network
echo $IP
ping -c 3 $GW