forked from colinmarc/hdfs
-
Notifications
You must be signed in to change notification settings - Fork 1
/
travis-setup-cdh6.sh
executable file
·196 lines (172 loc) · 5.33 KB
/
travis-setup-cdh6.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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
#!/bin/sh
set -e
KERBEROS=${KERBEROS-"false"}
AES=${AES-"false"}
if [ "$DATA_TRANSFER_PROTECTION" = "privacy" ]; then
KERBEROS="true"
ENCRYPT_DATA_TRANSFER="true"
ENCRYPT_DATA_TRANSFER_ALG="rc4"
if [ "$AES" = "true" ]; then
ENCRYPT_DATA_TRANSFER_CIPHER="AES/CTR/NoPadding"
fi
else
ENCRYPT_DATA_TRANSFER="false"
fi
UBUNTU_CODENAME=$(lsb_release -cs)
UBUNTU_VERSION=$(lsb_release -rs | sed s/\\.//)
CDH_VERSION=6.3.2
sudo tee /etc/apt/sources.list.d/cdh.list <<EOF
deb [arch=amd64] https://archive.cloudera.com/cdh6/$CDH_VERSION/ubuntu$UBUNTU_VERSION/apt $UBUNTU_CODENAME-cdh6 contrib
EOF
sudo tee /etc/apt/preferences.d/cloudera.pref <<EOF
Package: *
Pin: release o=Cloudera, l=Cloudera
Pin-Priority: 501
EOF
sudo apt-get update
CONF_AUTHENTICATION="simple"
if [ $KERBEROS = "true" ]; then
CONF_AUTHENTICATION="kerberos"
HOSTNAME=$(hostname)
KERBEROS_REALM="EXAMPLE.COM"
KERBEROS_PRINCIPLE="administrator"
KERBEROS_PASSWORD="password1234"
sudo tee /etc/krb5.conf << EOF
[libdefaults]
default_realm = $KERBEROS_REALM
dns_lookup_realm = false
dns_lookup_kdc = false
[realms]
$KERBEROS_REALM = {
kdc = localhost
admin_server = localhost
}
[logging]
default = FILE:/var/log/krb5libs.log
kdc = FILE:/var/log/krb5kdc.log
admin_server = FILE:/var/log/kadmind.log
[domain_realm]
.localhost = $KERBEROS_REALM
localhost = $KERBEROS_REALM
EOF
sudo mkdir /etc/krb5kdc
sudo printf '*/*@%s\t*' "$KERBEROS_REALM" | sudo tee /etc/krb5kdc/kadm5.acl
sudo apt-get install -y krb5-user krb5-kdc krb5-admin-server
printf "$KERBEROS_PASSWORD\n$KERBEROS_PASSWORD" | sudo kdb5_util -r "$KERBEROS_REALM" create -s
for p in nn dn travis gohdfs1 gohdfs2; do
sudo kadmin.local -q "addprinc -randkey $p/$HOSTNAME@$KERBEROS_REALM"
sudo kadmin.local -q "addprinc -randkey $p/localhost@$KERBEROS_REALM"
sudo kadmin.local -q "xst -k /tmp/$p.keytab $p/$HOSTNAME@$KERBEROS_REALM"
sudo kadmin.local -q "xst -k /tmp/$p.keytab $p/localhost@$KERBEROS_REALM"
sudo chmod +rx /tmp/$p.keytab
done
sudo service krb5-kdc restart
sudo service krb5-admin-server restart
kinit -kt /tmp/travis.keytab "travis/localhost@$KERBEROS_REALM"
# The go tests need ccache files for these principles in a specific place.
for p in travis gohdfs1 gohdfs2; do
kinit -kt "/tmp/$p.keytab" -c "/tmp/krb5cc_gohdfs_$p" "$p/localhost@$KERBEROS_REALM"
done
fi
sudo mkdir -p /etc/hadoop/conf.gohdfs
sudo tee /etc/hadoop/conf.gohdfs/core-site.xml <<EOF
<configuration>
<property>
<name>fs.defaultFS</name>
<value>hdfs://localhost:9000</value>
</property>
<property>
<name>hadoop.security.authentication</name>
<value>$CONF_AUTHENTICATION</value>
</property>
<property>
<name>hadoop.security.authorization</name>
<value>$KERBEROS</value>
</property>
<property>
<name>dfs.namenode.keytab.file</name>
<value>/tmp/nn.keytab</value>
</property>
<property>
<name>dfs.namenode.kerberos.principal</name>
<value>nn/localhost@$KERBEROS_REALM</value>
</property>
<property>
<name>dfs.web.authentication.kerberos.principal</name>
<value>nn/localhost@$KERBEROS_REALM</value>
</property>
<property>
<name>dfs.datanode.keytab.file</name>
<value>/tmp/dn.keytab</value>
</property>
<property>
<name>dfs.datanode.kerberos.principal</name>
<value>dn/localhost@$KERBEROS_REALM</value>
</property>
<property>
<name>hadoop.rpc.protection</name>
<value>$RPC_PROTECTION</value>
</property>
</configuration>
EOF
sudo tee /etc/hadoop/conf.gohdfs/hdfs-site.xml <<EOF
<configuration>
<property>
<name>dfs.namenode.name.dir</name>
<value>/opt/hdfs/name</value>
</property>
<property>
<name>dfs.datanode.data.dir</name>
<value>/opt/hdfs/data</value>
</property>
<property>
<name>dfs.permissions.superusergroup</name>
<value>hadoop</value>
</property>
<property>
<name>dfs.safemode.extension</name>
<value>0</value>
</property>
<property>
<name>dfs.safemode.min.datanodes</name>
<value>1</value>
</property>
<property>
<name>dfs.block.access.token.enable</name>
<value>$KERBEROS</value>
</property>
<property>
<name>ignore.secure.ports.for.testing</name>
<value>true</value>
</property>
<property>
<name>dfs.data.transfer.protection</name>
<value>$DATA_TRANSFER_PROTECTION</value>
</property>
<property>
<name>dfs.encrypt.data.transfer</name>
<value>$ENCRYPT_DATA_TRANSFER</value>
</property>
<property>
<name>dfs.encrypt.data.transfer.algorithm</name>
<value>$ENCRYPT_DATA_TRANSFER_ALG</value>
</property>
<property>
<name>dfs.encrypt.data.transfer.cipher.suites</name>
<value>$ENCRYPT_DATA_TRANSFER_CIPHER</value>
</property>
</configuration>
EOF
sudo update-alternatives --install /etc/hadoop/conf hadoop-conf /etc/hadoop/conf.gohdfs 99
sudo apt-get install -y --allow-unauthenticated hadoop-hdfs-namenode hadoop-hdfs-datanode
sudo mkdir -p /opt/hdfs/data /opt/hdfs/name
sudo chown -R hdfs:hdfs /opt/hdfs
sudo -u hdfs hdfs namenode -format -nonInteractive
sudo adduser travis hadoop
if [ $ENCRYPT_DATA_TRANSFER = "true" ]; then
sudo apt-get install -y --allow-unauthenticated hadoop-kms hadoop-kms-server
sudo service hadoop-kms-server restart
fi
sudo service hadoop-hdfs-datanode restart
sudo service hadoop-hdfs-namenode restart
hdfs dfsadmin -safemode wait