summaryrefslogtreecommitdiffstats
path: root/perf-framework/create_gluster_vol
blob: fcb91ce1b70dd1c3c50a180048b3a04398385522 (plain)
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
#!/bin/bash -ue

CONFIG_FILE=gf_perf_config
source $CONFIG_FILE
GF_BIN=/usr/local/sbin

function mgmt_vol_create()
{
        if [ $ENABLE_ACL == "yes" ]
        then
                ./acl on
        else
                ./acl off
        fi
	for brick in $BRICK_IP_ADDRS
	do
		ssh  -l root $MGMT_NODE "$GF_BIN/gluster peer probe $brick"
	done
        ssh -l root $MGMT_NODE "$@"
	ssh -l root $MGMT_NODE "$GF_BIN/gluster volume start $VOLNAME"
	if [ $GF_CONFIG == "stripe" ]; then
	    echo "Setting cache-size to 128MB for stripe tests..."
	    ssh -l root $MGMT_NODE "$GF_BIN/gluster volume set $VOLNAME cache-size 128MB"
	fi
	#mem-factor is set for mount type of nfs to increase performance.
	if [ $MOUNT_TYPE == "nfs" ]; then
	    echo "Setting mem-factor to 20 since mount type is nfs..."
	    ssh -l root $MGMT_NODE "$GF_BIN/gluster volume set $VOLNAME nfs.mem-factor 20"
	fi
}

function cleanup_brick()
{
        ssh -l root $1 "killall glusterd glusterfs glusterfsd > /dev/null 2>&1; rm -rf /etc/glusterd"

	if [ "$SERVER_EXPORT_DIR" != "" ]
	then
        	echo "Deleting export dir $SERVER_EXPORT_DIR on $brick..."
        	ssh -l root $1 "rm -rf $SERVER_EXPORT_DIR"
	else
        	echo "************* Empty export dir in config *************"
		exit
	fi
}

echo "Cleaning bricks..."
for brick in $BRICK_IP_ADDRS
do 
        cleanup_brick $brick &
done

wait

echo "Creating export directory..."
for brick in $BRICK_IP_ADDRS
do 
        ssh -l root $brick "mkdir -p $SERVER_EXPORT_DIR"
done

# Start glusterd on all the bricks
echo "Starting glusterd..."
for brick in $BRICK_IP_ADDRS
do 
	if [ $ENABLE_MEM_ACCT == "yes" ]
	then
        	ssh -l root $brick "GLUSTERFS_DISABLE_MEM_ACCT=0 $GF_BIN/glusterd"
	else
        	ssh -l root $brick "$GF_BIN/glusterd"
	fi
done

# Create the gluster volume according to the config

bricklist=""
count=0
for brick in $BRICK_IP_ADDRS
do 
        bricklist+="$brick:$SERVER_EXPORT_DIR "
        count=$((count+1))
done

if [ "$GF_CONFIG" == "replicate" -a "$count" -gt "2" ]
then
        echo "NOTE:"
        echo "Replicate volume with more than 2 bricks created."
        echo "This will result in a distributed replicate config."
fi

echo "Creating $GF_CONFIG volume..."
if [ "$GF_CONFIG" == "distribute" ]
then
        mgmt_vol_create "gluster volume create $VOLNAME $bricklist"
elif [ "$GF_CONFIG" == "replicate" ]
then
        mgmt_vol_create "gluster volume create $VOLNAME replica 2 $bricklist"
elif [ "$GF_CONFIG" == "distrep" ]
then
        mgmt_vol_create "gluster volume create $VOLNAME replica 2 $bricklist"
elif [ "$GF_CONFIG" == "stripe" ]
then
        mgmt_vol_create "gluster volume create $VOLNAME stripe 4 $bricklist"
else
        echo "Unknown configuration. Exiting..."
        exit 1
fi

sleep 5

if [ $ENABLE_MEM_ACCT == "yes" ]
then
	for brick in $BRICK_IP_ADDRS
	do 
		echo "Memory accounting status on : $brick -"
        	ssh -l root $brick "\
                	echo \"x/x &gf_mem_acct_enable\" > gf_gdb_commands;\
                	echo \"quit\" >> gf_gdb_commands;\
                	gdb -q --command=gf_gdb_commands -p \`pidof glusterfsd\` 2> /dev/null | \
                	grep gf_mem_acct_enable | awk '{print \$(NF-1) \$NF}';\
                	rm gf_gdb_commands > /dev/null 2>&1"
		echo ""
	done
fi