Today I downloaded Hortonworks HDP Sandbox (filename: HDP_2.6.4_virtualbox_01_02_2018_1428.ova). After importing it into virtualbox on Windows laptop, it stucked when showing "Waiting for amberi agent to connect".
Then I uploaded the ova file to TC, and import it to virtualbox:
vboxmanage import HDP_2.6.4_virtualbox_01_02_2018_1428.ova --vsys 0 --vmname hdpSandbox2.6.4
vboxmanage list vms
vboxmanage list runningvms
vboxmanage startvm hdpSandbox2.6.4 --type headless
ssh root@localhost -p 2222 # default password: hadoop
Add the following into ~/.ssh/config of host machine to simplify ssh login:
Host hort
Hostname localhost
User root
Port 2222
However, the port forwarding in this vm is all binding to localhost, which can't be access outside the TC server. But there are lots of web server which can only be accessed from browser. So I had to modify all port forwarding to enable accessing from outside.
There are more than 60 port forwarding rules in this vm like this
(get these rules with vboxmanage showvminfo hdpSandbox2.6.4 | less
):
NIC 1 Rule(53): name = Tutorials, protocol = tcp, host ip = 127.0.0.1, host port = 8888, guest ip = , guest port = 8888
which should be modified to:
NIC 1 Rule(53): name = Tutorials, protocol = tcp, host ip = , host port = 8888, guest ip = , guest port = 8888
with the following commands:
vboxmanage modifyvm hdpSandbox2.6.4 --natpf1 delete Tutorials
vboxmanage modifyvm hdpSandbox2.6.4 --natpf1 "Tutorials,tcp,,8888,,8888"
VirtualBox has no command to modify rules directly, you have to delete the old one, then create a new one.
It's very boring to modify them manually. So I write a Python script to build a shell script, Then run the shell script to modify the vm:
$ cat << EOF > buildcmds.py
lines = open('origin26.log').read().split('\n')
rules = filter(lambda x: x.startswith('NIC 1 Rule'), lines)
nameports = map(lambda x: (x.split('name = ')[1].split(',')[0],
x.split(' ')[-1]), rules)
new_rules = map(lambda x:
('vboxmanage modifyvm hdpSandbox2.6.4 --natpf1 delete %s\n'
'vboxmanage modifyvm hdpSandbox2.6.4 --natpf1 "%s,tcp,,%s,,%s"')
% (x[0], x[0], x[1], x[1]), nameports)
with open('buildrules.sh', 'w') as f:
f.write('\n'.join(new_rules))
EOF
$ python buildcmds.py
$ bash buildrules.sh
Now I can access the HDP vm with http://172.18.0.253:8080 in browser. The admin password should be modified:
ssh hort
ambari-admin-password-reset
Now login with user name admin and password you set.
Note:
I tried to modify the vm's network from NAT to bridged, but it didn't work:
vboxmanage controlvm hdpSandbox2.6.4 savestate
vboxmanage startvm hdpSandbox2.6.4 --type headless
vboxmanage controlvm hdpSandbox2.6.4 poweroff
vboxmanage modifyvm hdpSandbox2.6.4 --nic2 bridged --bridgeadapter2 eth1
vboxmanage modifyvm hdpSandbox2.6.4 --nic2 none
vboxmanage modifyvm hdpSandbox2.6.4 --nic1 bridged --bridgeadapter1 eth0