forked from Azure/azurehpc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbeegfssd.sh
executable file
·175 lines (165 loc) · 6.15 KB
/
beegfssd.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
#!/bin/bash
#
disk_type=$1
node_type=$2
pools=$3
pools_restart=$4
MGMT_HOSTNAME=$5
#
if [ $disk_type == "local_ssd" ]; then
BEEGFS_DISK=/mnt/resource/beegfs
else
BEEGFS_DISK=/mnt/beegfs
fi
BEEGFS_HDD=/mnt/hdd
BEEGFS_STORAGE=${BEEGFS_DISK}/storage
#
yum install -y beegfs-storage
if [ $pools == "true" ]; then
sed -i 's|^storeStorageDirectory.*|storeStorageDirectory = '$BEEGFS_HDD,$BEEGFS_STORAGE'|g' /etc/beegfs/beegfs-storage.conf
else
sed -i 's|^storeStorageDirectory.*|storeStorageDirectory = '$BEEGFS_STORAGE'|g' /etc/beegfs/beegfs-storage.conf
fi
sed -i 's/^sysMgmtdHost.*/sysMgmtdHost = '$MGMT_HOSTNAME'/g' /etc/beegfs/beegfs-storage.conf
#
sed -i 's/^connMaxInternodeNum.*/connMaxInternodeNum = 800/g' /etc/beegfs/beegfs-storage.conf
sed -i 's/^tuneNumWorkers.*/tuneNumWorkers = 128/g' /etc/beegfs/beegfs-storage.conf
sed -i 's/^tuneFileReadAheadSize.*/tuneFileReadAheadSize = 32m/g' /etc/beegfs/beegfs-storage.conf
sed -i 's/^tuneFileReadAheadTriggerSize.*/tuneFileReadAheadTriggerSize = 2m/g' /etc/beegfs/beegfs-storage.conf
sed -i 's/^tuneFileReadSize.*/tuneFileReadSize = 256k/g' /etc/beegfs/beegfs-storage.conf
sed -i 's/^tuneFileWriteSize.*/tuneFileWriteSize = 256k/g' /etc/beegfs/beegfs-storage.conf
sed -i 's/^tuneWorkerBufSize.*/tuneWorkerBufSize = 16m/g' /etc/beegfs/beegfs-storage.conf
#
#
setup_data_disks()
{
mountPoint="$1"
filesystem="$2"
devices="$3"
raidDevice="$4"
createdPartitions=""
numdevices=`echo $devices | wc -w`
if [ $numdevices -gt 1 ]
then
# Loop through and partition disks until not found
for disk in $devices; do
fdisk -l /dev/$disk || break
fdisk /dev/$disk << EOF
n
p
1
t
fd
w
EOF
if [ $raidDevice == "md30" ]
then
createdPartitions="$createdPartitions /dev/${disk}p1"
else
createdPartitions="$createdPartitions /dev/${disk}1"
fi
done
else
disk=$(echo $devices | tr -d [:space:])
echo "Warning: Only a single device to partition, $disk"
fdisk -l /dev/$disk || break
fdisk /dev/$disk << EOF
n
p
1
w
EOF
if [ $raidDevice == "md30" ]
then
createdPartitions="$createdPartitions /dev/${disk}p1"
else
createdPartitions="$createdPartitions /dev/${disk}1"
fi
fi
sleep 10
# Create RAID-0 volume
if [ -n "$createdPartitions" ]; then
devices=`echo $createdPartitions | wc -w`
if [ $numdevices -gt 1 ]
then
mdadm --create /dev/$raidDevice --level 0 --raid-devices $devices $createdPartitions
sleep 10
mdadm /dev/$raidDevice
else
echo "Warning: mdadm is not called, we have one partition named, ${disk}1 for mountpoint, $mountPoint"
if [ $raidDevice == "md30" ]
then
raidDevice=${disk}p1
else
raidDevice=${disk}1
fi
fi
if [ $pools_restart == "true" ]; then
systemctl disable beegfs-meta.service
systemctl disable beegfs-storage.service
sed -i '$ d' /etc/fstab
fi
if [ "$filesystem" == "xfs" ]; then
mkfs -t $filesystem /dev/$raidDevice
export xfsuuid="UUID=`blkid |grep dev/$raidDevice |cut -d " " -f 2 |cut -c 7-42`"
echo "$xfsuuid $mountPoint $filesystem rw,noatime,attr2,inode64,nobarrier,nofail 0 2" >> /etc/fstab
else
mkfs.ext4 -i 2048 -I 512 -J size=400 -Odir_index,filetype /dev/$raidDevice
sleep 5
tune2fs -o user_xattr /dev/$raidDevice
export ext4uuid="UUID=`blkid |grep dev/$raidDevice |cut -d " " -f 2 |cut -c 7-42`"
echo "$ext4uuid $mountPoint $filesystem noatime,nodiratime,nobarrier,nofail 0 2" >> /etc/fstab
fi
sleep 10
mount -a
fi
}
#
fdisk -l
lsscsi
#
rootDevice=`mount | grep "on / type" | awk '{print $1}' | sed 's/[0-9]//g'`
tmpDevice=`mount | grep "on /mnt/resource type" | awk '{print $1}' | sed 's/[0-9]//g'`
#
hddDiskSize=default
if [ $pools == "true" ]; then
hddDiskSize=`fdisk -l | grep '^Disk /dev/sdc' | grep -v $rootDevice | grep -v $tmpDevice | awk '{print $3}'`
hddDevices="`fdisk -l | grep '^Disk /dev/' | grep -v $rootDevice | grep -v $tmpDevice | grep $hddDiskSize | awk '{print $2}' | awk -F: '{print $1}' | tr '\n' ' ' | sed 's|/dev/||g'`"
fi
#
metadataDiskSize=`fdisk -l | grep '^Disk /dev/' | grep -v '/dev/md' | grep -v $hddDiskSize | grep -v $rootDevice | grep -v $tmpDevice | awk '{print $3}' | sort -n -r | tail -1`
storageDiskSize=`fdisk -l | grep '^Disk /dev/' | grep -v '/dev/md' | grep -v $hddDiskSize | grep -v $rootDevice | grep -v $tmpDevice | awk '{print $3}' | sort -n | tail -1`
#
if [ "$metadataDiskSize" == "$storageDiskSize" ]; then
nbDisks=`fdisk -l | grep '^Disk /dev/' | grep -v $hddDiskSize | grep -v $rootDevice | grep -v $tmpDevice | wc -l`
let nbMetadaDisks=nbDisks
let nbStorageDisks=nbDisks
if [ $node_type == "both" ] && [ $disk_type == "data_disk" ]; then
let nbMetadaDisks=nbDisks/3
if [ $nbMetadaDisks -lt 2 ]; then
let nbMetadaDisks=2
fi
let nbStorageDisks=nbDisks-nbMetadaDisks
fi
storageDevices="`fdisk -l | grep '^Disk /dev/' | grep -v '/dev/md' | grep -v $hddDiskSize | grep -v $rootDevice | grep -v $tmpDevice | grep $storageDiskSize | awk '{print $2}' | awk -F: '{print $1}' | sort | tail -$nbStorageDisks | tr '\n' ' ' | sed 's|/dev/||g'`"
else
storageDevices="`fdisk -l | grep '^Disk /dev/' | grep -v '/dev/md' | grep -v $hddDiskSize | grep -v $rootDevice | grep -v $tmpDevice | grep $storageDiskSize | awk '{print $2}' | awk -F: '{print $1}' | sort | tr '\n' ' ' | sed 's|/dev/||g'`"
fi
#
if [ $pools == "true" ] && [ $pools_restart == "false" ]; then
mkdir -p $BEEGFS_HDD
setup_data_disks $BEEGFS_HDD "xfs" "$hddDevices" "md40"
fi
mkdir -p $BEEGFS_STORAGE
if [ $disk_type == "nvme" ]; then
setup_data_disks $BEEGFS_DISK "xfs" "$storageDevices" "md30"
mkdir -p $BEEGFS_DISK/storage
elif [ $disk_type == "data_disk" ]; then
setup_data_disks $BEEGFS_STORAGE "xfs" "$storageDevices" "md50"
fi
#
mount -a
#
systemctl daemon-reload
systemctl enable beegfs-storage.service
systemctl start beegfs-storage.service