File tree 4 files changed +40
-3
lines changed
4 files changed +40
-3
lines changed Original file line number Diff line number Diff line change @@ -33,3 +33,6 @@ nosetests.xml
33
33
.mr.developer.cfg
34
34
.project
35
35
.pydevproject
36
+
37
+ # JetBrains products
38
+ .idea /
Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+
3
+ # Starting new instance in VPC often results that `hostname` returns something like 'ip-10-1-1-24', which is
4
+ # not resolvable. Which leads to problems like SparkUI failing to bind itself on start up to that hostname as
5
+ # described in https://issues.apache.org/jira/browse/SPARK-5246.
6
+ # This script maps private ip to such hostname via '/etc/hosts'.
7
+ #
8
+
9
+ # Are we in VPC?
10
+ MAC=` wget -q -O - http://169.254.169.254/latest/meta-data/mac`
11
+ VCP_ID=` wget -q -O - http://169.254.169.254/latest/meta-data/network/interfaces/macs/${MAC} /vpc-id`
12
+ if [ -z " ${VCP_ID} " ]; then
13
+ # echo "nothing to do - instance is not in VPC"
14
+ exit 0
15
+ fi
16
+
17
+ SHORT_HOSTNAME=` hostname`
18
+
19
+ PRIVATE_IP=` wget -q -O - http://169.254.169.254/latest/meta-data/local-ipv4`
20
+
21
+ # do changes only if short hostname does not resolve
22
+ if [ ! ping -c 1 -q " ${SHORT_HOSTNAME} " > /dev/null 2>&1 ]; then
23
+ echo -e " \n ${PRIVATE_IP} ${SHORT_HOSTNAME} \n" >> /etc/hosts
24
+
25
+ # let's make sure that it got fixed
26
+ if [ ! ping -c 1 -q " ${SHORT_HOSTNAME} " > /dev/null 2>&1 ]; then
27
+ # return some non-zero code to indicate problem
28
+ echo " Possible bug: unable to fix resolution of local hostname"
29
+ return 62
30
+ fi
31
+
32
+ fi
Original file line number Diff line number Diff line change @@ -14,11 +14,13 @@ source ec2-variables.sh
14
14
15
15
# Set hostname based on EC2 private DNS name, so that it is set correctly
16
16
# even if the instance is restarted with a different private DNS name
17
- PRIVATE_DNS=` wget -q -O - http://instance-data.ec2.internal /latest/meta-data/local-hostname`
17
+ PRIVATE_DNS=` wget -q -O - http://169.254.169.254 /latest/meta-data/local-hostname`
18
18
hostname $PRIVATE_DNS
19
19
echo $PRIVATE_DNS > /etc/hostname
20
20
HOSTNAME=$PRIVATE_DNS # Fix the bash built-in hostname variable too
21
21
22
+ bash /root/spark-ec2/resolve-hostname.sh
23
+
22
24
echo " Setting up slave on ` hostname` ..."
23
25
24
26
# Work around for R3 instances without pre-formatted ext3 disks
Original file line number Diff line number Diff line change @@ -21,8 +21,8 @@ source ec2-variables.sh
21
21
22
22
# Set hostname based on EC2 private DNS name, so that it is set correctly
23
23
# even if the instance is restarted with a different private DNS name
24
- PRIVATE_DNS=` wget -q -O - http://instance-data.ec2.internal /latest/meta-data/local-hostname`
25
- PUBLIC_DNS=` wget -q -O - http://instance-data.ec2.internal /latest/meta-data/hostname`
24
+ PRIVATE_DNS=` wget -q -O - http://169.254.169.254 /latest/meta-data/local-hostname`
25
+ PUBLIC_DNS=` wget -q -O - http://169.254.169.254 /latest/meta-data/hostname`
26
26
hostname $PRIVATE_DNS
27
27
echo $PRIVATE_DNS > /etc/hostname
28
28
export HOSTNAME=$PRIVATE_DNS # Fix the bash built-in hostname variable too
You can’t perform that action at this time.
0 commit comments