forked from int32bit/openstack-cheat-sheet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate-spark-cluster.sh
executable file
·141 lines (130 loc) · 3.64 KB
/
create-spark-cluster.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
#!/bin/sh
NAME=test
IMAGE_ID=6ba27a59-ecd7-47d4-8df4-925acb23bb87
FLOATING_IP=7517cbd2-2d07-44ad-8eaa-b9ec7098071a
FLAVOR_ID=2
KEYPAIR_NAME=server-230
NETWORK_ID=e478bc87-a067-402f-98e2-9bdc9b180d5e
# Create master node group template
cat > spark-master-node-group-template.json <<EOF
{
"auto_security_group": true,
"availability_zone": "",
"description": "spark 1.6.0 master node group",
"flavor_id": "${FLAVOR_ID}",
"floating_ip_pool": "${FLOATING_IP}",
"hadoop_version": "1.6.0",
"image_id": "${IMAGE_ID}",
"is_protected": false,
"is_proxy_gateway": false,
"is_public": true,
"name": "${NAME}-master",
"node_configs": {
"HDFS": {}
},
"node_processes": [
"namenode",
"master"
],
"plugin_name": "spark",
"security_groups": [],
"shares": [],
"use_autoconfig": true,
"volumes_per_node": 1,
"volumes_size": 20
}
EOF
echo $NAME-master:
cat spark-master-node-group-template.json
sahara node-group-template-create --json spark-master-node-group-template.json 2>/dev/null
# Create worker node group template
cat > spark-worker-node-group-template.json <<EOF
{
"auto_security_group": true,
"availability_zone": "",
"description": "spark 1.6.0 master node group",
"flavor_id": "2",
"floating_ip_pool": "${FLOATING_IP}",
"hadoop_version": "1.6.0",
"image_id": "${IMAGE_ID}",
"is_protected": false,
"is_proxy_gateway": false,
"is_public": true,
"name": "${NAME}-worker",
"node_configs": {
"HDFS": {}
},
"node_processes": [
"datanode",
"slave"
],
"plugin_name": "spark",
"security_groups": [],
"shares": [],
"use_autoconfig": true,
"volumes_per_node": 1,
"volumes_size": 20
}
EOF
echo $NAME-worker:
cat spark-worker-node-group-template.json
sahara node-group-template-create --json spark-worker-node-group-template.json
SPARK_MASTER_GROUP_ID=$(sahara node-group-template-list 2>/dev/null | grep -P -- "\s$NAME-master\s" | awk '{print $4}')
SPARK_WORKER_GROUP_ID=$(sahara node-group-template-list 2>/dev/null | grep -P -- "\s$NAME-worker\s" | awk '{print $4}')
# Create cluster template
cat >spark-cluster-template.json <<EOF
{
"anti_affinity": [],
"cluster_configs": {
"HDFS": {
"dfs.replication": 1
},
"Spark": {},
"general": {
"Enable XFS": true
}
},
"description": "spark 1.6.0",
"hadoop_version": "1.6.0",
"is_protected": false,
"is_public": true,
"name": "${NAME}-cluster-template",
"node_groups": [
{
"count": 1,
"name": "${NAME}-master",
"node_group_template_id": "${SPARK_MASTER_GROUP_ID}"
},
{
"count": 1,
"name": "${NAME}-worker",
"node_group_template_id": "${SPARK_WORKER_GROUP_ID}"
}
],
"plugin_name": "spark",
"shares": [],
"use_autoconfig": true
}
EOF
echo $NAME-cluster-template:
cat spark-cluster-template.json
sahara cluster-template-create --json spark-cluster-template.json
# Create cluster
CLUSTER_TEMPLATE_ID=$(sahara cluster-template-list 2>/dev/null | grep -P "\s${NAME}-cluster-template\s" | awk '{print $4}')
cat >spark_cluster.json <<EOF
{
"cluster_template_id": "${CLUSTER_TEMPLATE_ID}",
"default_image_id": "${IMAGE_ID}",
"description": "",
"hadoop_version": "1.6.0",
"is_protected": false,
"is_public": true,
"name": "${NAME}",
"neutron_management_network": "${NETWORK_ID}",
"plugin_name": "spark",
"user_keypair_id": "${KEYPAIR_NAME}"
}
EOF
echo $NAME:
cat spark_cluster.json
sahara cluster-create --json spark_cluster.json